ht-2.0.22/0000755000175000017500000000000012156433676007226 500000000000000ht-2.0.22/htmenu.h0000644000175000001440000001120410615341620010572 00000000000000/* * HT Editor * htmenu.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTMENU_H__ #define __HTMENU_H__ #include "data.h" #include "htdialog.h" #include "htobj.h" /* * CLASS ht_context_menu_entry */ class ht_context_menu; #define CME_ENTRY 0 #define CME_SEPARATOR 1 #define CME_SUBMENU 2 class ht_context_menu_entry: public Object { public: int type; union { struct { char *name; char *shortcut; char *comment; int command; int key; bool active; } entry; ht_context_menu *submenu; }; virtual ~ht_context_menu_entry(); }; /* * CLASS ht_context_menu */ class ht_context_menu: public Object { private: char *name; char *shortcut; public: int xpos, width; /* used externally */ void init(const char *name); virtual void done(); /* new */ virtual int count(); virtual ht_context_menu_entry *enum_entry_first(); virtual ht_context_menu_entry *enum_entry_next(); virtual ht_context_menu_entry *get_entry(int n); virtual const char *get_name(); virtual const char *get_shortcut(); }; /* * CLASS ht_static_context_menu */ class ht_static_context_menu: public ht_context_menu { protected: List *context_menu_entry; int enum_idx; public: void init(const char *name); virtual void done(); /* new */ void insert_entry(const char *name, const char *comment, int command, int key, bool active); void insert_separator(); void insert_submenu(ht_context_menu *submenu); /* overwritten */ virtual int count(); virtual ht_context_menu_entry *enum_entry_first(); virtual ht_context_menu_entry *enum_entry_next(); }; /* * CLASS ht_menu */ class ht_menu: public ht_view { protected: int lastmenux; List *menu; int curmenu; int localmenu; bool context_menu_hack2; ht_context_menu *context_menu_hack; ht_context_menu *last_context_menu_hack; void execute_menu(int i); ht_context_menu *get_context_menu(int i); bool handle_key_context_menu(ht_context_menu *a, int k); /* overwritten */ virtual const char *defaultpalette(); virtual const char *defaultpaletteclass(); public: void init(Bounds *b); virtual void done(); /* overwritten */ virtual void draw(); virtual void handlemsg(htmsg *msg); virtual void getminbounds(int *width, int *height); /* new */ int count(); void insert_menu(ht_context_menu *m); void insert_local_menu(); bool set_local_menu(ht_context_menu *m); void delete_local_menu(); }; /* * CLASS ht_context_menu_window_body */ class ht_context_menu_window_body: public ht_view { protected: ht_context_menu *context_menu; int selected; /* new */ int next_selectable(int to); int prev_selectable(int to); /* overwritten */ virtual const char *defaultpalette(); virtual const char *defaultpaletteclass(); public: void init(Bounds *b, ht_context_menu *menu); virtual void done(); /* overwritten */ virtual void draw(); virtual void handlemsg(htmsg *msg); virtual void getdata(ObjectStream &s); virtual void setdata(ObjectStream &s); }; /* * CLASS ht_menu_window */ class ht_menu_window_body; struct ht_menu_window_data { int selected; }; class ht_menu_window: public ht_dialog { protected: ht_menu_window_body *body; ht_context_menu *menu; public: void init(Bounds *b, ht_context_menu *menu); virtual void done(); /* overwritten */ virtual void getdata(ObjectStream &s); virtual void handlemsg(htmsg *msg); virtual void setdata(ObjectStream &s); }; /* * CLASS ht_menu_window_body */ class ht_menu_window_body: public ht_context_menu_window_body { public: void init(Bounds *b, ht_context_menu *menu); virtual void done(); /* overwritten */ virtual void handlemsg(htmsg *msg); }; /* * CLASS ht_menu_frame */ class ht_menu_frame: public ht_frame { protected: /* overwritten */ virtual int getcurcol_normal(); virtual int getcurcol_killer(); /* overwritten */ virtual const char *defaultpalette(); virtual const char *defaultpaletteclass(); public: void init(Bounds *b, const char *desc, uint style, uint number=0); virtual void done(); }; /* * INIT */ bool init_menu(); /* * DONE */ void done_menu(); #endif /* !__HTMENU_H__ */ ht-2.0.22/htelfrel.h0000644000175000001440000000156110206756707011120 00000000000000/* * HT Editor * htelfrel.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTELFREL_H__ #define __HTELFREL_H__ #include "htobj.h" #include "formats.h" extern format_viewer_if htelfreloctable_if; #endif /* !__HTELFREL_H__ */ ht-2.0.22/htpeexp.h0000644000175000001440000000310010615341623010746 00000000000000/* * HT Editor * htpeexp.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTPEEXP_H__ #define __HTPEEXP_H__ #include "data.h" #include "htdialog.h" #include "formats.h" extern format_viewer_if htpeexports_if; /* * CLASS ht_pe_export_viewer */ class ht_pe_export_viewer: public ht_itext_listbox { protected: ht_format_group *format_group; public: void init(Bounds *b, ht_format_group *fg); virtual void done(); /* overwritten */ virtual void handlemsg(htmsg *msg); virtual bool select_entry(void *entry); /* new */ const char *func(uint i, bool execute); }; /* * CLASS ht_pe_export_function */ class ht_pe_export_function: public Object { public: uint ordinal; bool byname; char *name; RVA address; ht_pe_export_function(RVA address, uint ordinal); ht_pe_export_function(RVA address, uint ordinal, const char *name); ~ht_pe_export_function(); }; struct ht_pe_export { Container *funcs; }; #endif /* !__HTPEEXP_H__ */ ht-2.0.22/htpehead.cc0000644000175000001440000003433310771304342011225 00000000000000/* * HT Editor * htpehead.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "formats.h" #include "htapp.h" #include "atom.h" #include "htcoff.h" #include "htctrl.h" #include "endianess.h" #include "hthex.h" #include "htiobox.h" #include "htnewexe.h" #include "htpe.h" #include "htpehead.h" #include "httag.h" #include "strtools.h" #include "snprintf.h" #include "pestruct.h" #include static int_hash pe_optional_magics[] = { {COFF_OPTMAGIC_ROMIMAGE, "ROM image"}, {COFF_OPTMAGIC_PE32, "PE/PE32"}, {COFF_OPTMAGIC_PE64, "PE32+/PE64"}, {0, 0} }; static int_hash pe_subsystems[] = { {0, "generic"}, {PE_SUBSYSTEM_NATIVE, "native"}, {PE_SUBSYSTEM_WINDOWS_GUI, "Windows GUI"}, {PE_SUBSYSTEM_WINDOWS_CUI, "Windows CUI"}, {PE_SUBSYSTEM_OS2_CUI, "OS/2 CUI"}, {PE_SUBSYSTEM_POSIX_CUI, "POSIX CUI"}, {PE_SUBSYSTEM_CE_GUI, "Windows CE GUI"}, {PE_SUBSYSTEM_EFI_APPLICATION, "EFI"}, {PE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER, "EFI/boot"}, {PE_SUBSYSTEM_EFI_RUNTIME_DRIVER, "EFI/runtime"}, {0, 0} }; static ht_mask_ptable pemagic[] = { {"magic", STATICTAG_EDIT_DWORD_LE("00000000")}, {0, 0} }; static ht_mask_ptable pe32header[] = { {"optional magic", STATICTAG_EDIT_WORD_LE("00000014")" "STATICTAG_DESC_WORD_LE("00000014", ATOM_PE_OPTIONAL_MAGICS_STR)}, {"major linker version", STATICTAG_EDIT_BYTE("00000016")}, {"minor linker version", STATICTAG_EDIT_BYTE("00000017")}, {"size of code", STATICTAG_EDIT_DWORD_LE("00000018")}, {"size of data", STATICTAG_EDIT_DWORD_LE("0000001c")}, {"size of bss", STATICTAG_EDIT_DWORD_LE("00000020")}, {"entry point", STATICTAG_EDIT_DWORD_LE("00000024")}, {"code base", STATICTAG_EDIT_DWORD_LE("00000028")}, {"data base", STATICTAG_EDIT_DWORD_LE("0000002c")}, {0, 0} }; static ht_tag_flags_s pe_dll_characteristics[] = { {-1, "PE - dll characteristics"}, {0, "[00] * reserved"}, {1, "[01] * reserved"}, {2, "[02] * reserved"}, {3, "[03] * reserved"}, {11, "[11] do not bind"}, {13, "[13] WDM driver"}, {15, "[15] image is terminal server aware"}, {0, 0} }; static ht_mask_ptable pe32header_nt[] = { {"image base", STATICTAG_EDIT_DWORD_LE("00000030")}, {"section alignment", STATICTAG_EDIT_DWORD_LE("00000034")}, {"file alignment", STATICTAG_EDIT_DWORD_LE("00000038")}, {"major OS version", STATICTAG_EDIT_WORD_LE("0000003c")}, {"minor OS version", STATICTAG_EDIT_WORD_LE("0000003e")}, {"major image version", STATICTAG_EDIT_WORD_LE("00000040")}, {"minor image version", STATICTAG_EDIT_WORD_LE("00000042")}, {"major subsystem version", STATICTAG_EDIT_WORD_LE("00000044")}, {"minor subsystem version", STATICTAG_EDIT_WORD_LE("00000046")}, {"Win32 version", STATICTAG_EDIT_DWORD_LE("00000048")}, {"size of image", STATICTAG_EDIT_DWORD_LE("0000004c")}, {"size of headers", STATICTAG_EDIT_DWORD_LE("00000050")}, {"checksum", STATICTAG_EDIT_DWORD_LE("00000054")}, {"subsystem", STATICTAG_EDIT_WORD_LE("00000058")" "STATICTAG_DESC_WORD_LE("00000058", ATOM_PE_SUBSYSTEMS_STR)}, {"dll characteristics", STATICTAG_EDIT_WORD_LE("0000005a")" "STATICTAG_FLAGS("0000005a", ATOM_PE_DLL_CHARACTERISTICS_STR)}, {"stack reserve", STATICTAG_EDIT_DWORD_LE("0000005c")}, {"stack commit", STATICTAG_EDIT_DWORD_LE("00000060")}, {"heap reserve", STATICTAG_EDIT_DWORD_LE("00000064")}, {"heap commit", STATICTAG_EDIT_DWORD_LE("00000068")}, {"loader flags", STATICTAG_EDIT_DWORD_LE("0000006c")}, {"number of directory entries", STATICTAG_EDIT_DWORD_LE("00000070")}, {0, 0} }; static ht_mask_ptable pe64header_nt[] = { {"image base", STATICTAG_EDIT_QWORD_LE("0000002c")}, {"section alignment", STATICTAG_EDIT_DWORD_LE("00000034")}, {"file alignment", STATICTAG_EDIT_DWORD_LE("00000038")}, {"major OS version", STATICTAG_EDIT_WORD_LE("0000003c")}, {"minor OS version", STATICTAG_EDIT_WORD_LE("0000003e")}, {"major image version", STATICTAG_EDIT_WORD_LE("00000040")}, {"minor image version", STATICTAG_EDIT_WORD_LE("00000042")}, {"major subsystem version", STATICTAG_EDIT_WORD_LE("00000044")}, {"minor subsystem version", STATICTAG_EDIT_WORD_LE("00000046")}, {"Win32 version", STATICTAG_EDIT_DWORD_LE("00000048")}, {"size of image", STATICTAG_EDIT_DWORD_LE("0000004c")}, {"size of headers", STATICTAG_EDIT_DWORD_LE("00000050")}, {"checksum", STATICTAG_EDIT_DWORD_LE("00000054")}, {"subsystem", STATICTAG_EDIT_WORD_LE("00000058")" "STATICTAG_DESC_WORD_LE("00000058", ATOM_PE_SUBSYSTEMS_STR)}, {"dll characteristics", STATICTAG_EDIT_WORD_LE("0000005a")}, {"stack reserve", STATICTAG_EDIT_QWORD_LE("0000005c")}, {"stack commit", STATICTAG_EDIT_QWORD_LE("00000064")}, {"heap reserve", STATICTAG_EDIT_QWORD_LE("0000006c")}, {"heap commit", STATICTAG_EDIT_QWORD_LE("00000074")}, {"loader flags", STATICTAG_EDIT_DWORD_LE("0000007c")}, {"number of directory entries", STATICTAG_EDIT_DWORD_LE("00000080")}, {0, 0} }; static ht_mask_ptable pe32header_nt_dirs[] = { {"export directory (rva/size)", STATICTAG_EDIT_DWORD_LE("00000000")" "STATICTAG_EDIT_DWORD_LE("00000004")" "STATICTAG_REF("0000000000000000", "03", "raw")" "STATICTAG_REF("0000000100000000", "04", "cook")}, {"import directory (rva/size)", STATICTAG_EDIT_DWORD_LE("00000008")" "STATICTAG_EDIT_DWORD_LE("0000000c")" "STATICTAG_REF("0000000000000001", "03", "raw")" "STATICTAG_REF("0000000200000000", "04", "cook")}, {"resource directory (rva/size)", STATICTAG_EDIT_DWORD_LE("00000010")" "STATICTAG_EDIT_DWORD_LE("00000014")" "STATICTAG_REF("0000000000000002", "03", "raw")" "STATICTAG_REF("0000000300000000", "04", "cook")}, {"exception directory (rva/size)", STATICTAG_EDIT_DWORD_LE("00000018")" "STATICTAG_EDIT_DWORD_LE("0000001c")" "STATICTAG_REF("0000000000000003", "03", "raw")}, {"security directory (rva/size)", STATICTAG_EDIT_DWORD_LE("00000020")" "STATICTAG_EDIT_DWORD_LE("00000024")" "STATICTAG_REF("0000000000000004", "03", "raw")}, {"base relocation table (rva/size)", STATICTAG_EDIT_DWORD_LE("00000028")" "STATICTAG_EDIT_DWORD_LE("0000002c")" "STATICTAG_REF("0000000000000005", "03", "raw")}, {"debug directory (rva/size)", STATICTAG_EDIT_DWORD_LE("00000030")" "STATICTAG_EDIT_DWORD_LE("00000034")" "STATICTAG_REF("0000000000000006", "03", "raw")}, {"description string (rva/size)", STATICTAG_EDIT_DWORD_LE("00000038")" "STATICTAG_EDIT_DWORD_LE("0000003c")" "STATICTAG_REF("0000000000000007", "03", "raw")}, {"machine value (GP) (rva/size)", STATICTAG_EDIT_DWORD_LE("00000040")" "STATICTAG_EDIT_DWORD_LE("00000044")" "STATICTAG_REF("0000000000000008", "03", "raw")}, {"thread local storage (TLS) (rva/size)", STATICTAG_EDIT_DWORD_LE("00000048")" "STATICTAG_EDIT_DWORD_LE("0000004c")" "STATICTAG_REF("0000000000000009", "03", "raw")}, {"load configuration directory (rva/size)", STATICTAG_EDIT_DWORD_LE("00000050")" "STATICTAG_EDIT_DWORD_LE("00000054")" "STATICTAG_REF("000000000000000a", "03", "raw")}, {"bound import directory (ofs/size)", STATICTAG_EDIT_DWORD_LE("00000058")" "STATICTAG_EDIT_DWORD_LE("0000005c")" "STATICTAG_REF("000000040000000b", "03", "raw")}, {"import address table (IAT) (rva/size)", STATICTAG_EDIT_DWORD_LE("00000060")" "STATICTAG_EDIT_DWORD_LE("00000064")" "STATICTAG_REF("000000000000000c", "03", "raw")}, {"delay import descriptor (rva/size)", STATICTAG_EDIT_DWORD_LE("00000068")" "STATICTAG_EDIT_DWORD_LE("0000006c")" "STATICTAG_REF("000000000000000d", "03", "raw")}, {"COM+ runtime header (rva/size)", STATICTAG_EDIT_DWORD_LE("00000070")" "STATICTAG_EDIT_DWORD_LE("00000074")" "STATICTAG_REF("000000000000000e", "03", "raw")" "STATICTAG_REF("0000000f00000000", "04", "cook")}, {"reserved (15) (rva/size)", STATICTAG_EDIT_DWORD_LE("00000078")" "STATICTAG_EDIT_DWORD_LE("0000007c")" "STATICTAG_REF("000000000000000f", "03", "raw")}, {0, 0} }; static ht_view *htpeheader_init(Bounds *b, File *file, ht_format_group *group) { ht_pe_shared_data *pe_shared=(ht_pe_shared_data *)group->get_shared_data(); FileOfs h=pe_shared->header_ofs; ht_pe_header_viewer *v=new ht_pe_header_viewer(); v->init(b, DESC_PE_HEADER, VC_EDIT | VC_SEARCH, file, group); registerAtom(ATOM_COFF_MACHINES, coff_machines); registerAtom(ATOM_COFF_CHARACTERISTICS, coff_characteristics); registerAtom(ATOM_COFF_SECTION_CHARACTERISTICS, coff_section_characteristics); registerAtom(ATOM_PE_OPTIONAL_MAGICS, pe_optional_magics); registerAtom(ATOM_PE_SUBSYSTEMS, pe_subsystems); registerAtom(ATOM_PE_DLL_CHARACTERISTICS, pe_dll_characteristics); ht_mask_sub *s; ht_collapsable_sub *cs; s=new ht_mask_sub(); s->init(file, 0); char info[128]; ht_snprintf(info, sizeof info, "* PE header at offset 0x%08qx", h); s->add_mask(info); v->insertsub(s); /* FIXME: */ bool pe_bigendian = false; s=new ht_mask_sub(); s->init(file, 1); s->add_staticmask_ptable(pemagic, h, pe_bigendian); /* COFF header */ s->add_staticmask_ptable(coffheader, h+4, pe_bigendian); cs=new ht_collapsable_sub(); cs->init(file, s, 1, "COFF header", 1); v->insertsub(cs); /* optional header */ s=new ht_mask_sub(); s->init(file, 2); uint16 opt; file->seek(h+24); file->read(&opt, 2); opt = createHostInt(&opt, 2, little_endian); switch (opt) { case COFF_OPTMAGIC_PE32: case COFF_OPTMAGIC_PE64: { bool pe32 = (opt==COFF_OPTMAGIC_PE32); s->add_staticmask_ptable(pe32header, h+4, pe_bigendian); cs=new ht_collapsable_sub(); cs->init(file, s, 1, "optional header", 1); v->insertsub(cs); s=new ht_mask_sub(); s->init(file, 3); s->add_staticmask_ptable(pe32?pe32header_nt:pe64header_nt, h+4, pe_bigendian); cs=new ht_collapsable_sub(); cs->init(file, s, 1, "optional header: NT fields", 1); v->insertsub(cs); s=new ht_mask_sub(); s->init(file, 4); s->add_staticmask_ptable(pe32header_nt_dirs, h+4+(pe32?0x74:0x84), pe_bigendian); cs=new ht_collapsable_sub(); cs->init(file, s, 1, "optional header: directories", 1); v->insertsub(cs); break; } default: { s->add_staticmask("optional magic "STATICTAG_EDIT_WORD_LE("00000014")" "STATICTAG_DESC_WORD_LE("00000014", ATOM_PE_OPTIONAL_MAGICS_STR), h+4, pe_bigendian); s->add_mask("-------------------------------------------------------------------------"); s->add_mask("Unsupported optional magic ! If you get this message in an original"); s->add_mask("(unmodified) file, please contact us (see help)."); cs=new ht_collapsable_sub(); cs->init(file, s, 1, "optional header", 1); v->insertsub(cs); } } /* section headers */ for (uint i=0; isections.section_count; i++) { s=new ht_mask_sub(); s->init(file, 100+i); s->add_staticmask_ptable(coff_section, h+24+pe_shared->coffheader.optional_header_size+i*COFF_SIZEOF_SECTION_HEADER, pe_bigendian); char nm[9]; memcpy(nm, pe_shared->sections.sections[i].name, 8); nm[8]=0; char t[256]; ht_snprintf(t, sizeof t, "section header %d: %-8s rva %08x vsize %08x", i, nm, pe_shared->sections.sections[i].data_address, pe_shared->sections.sections[i].data_vsize); cs=new ht_collapsable_sub(); cs->init(file, s, 1, t, 1); v->insertsub(cs); } return v; } format_viewer_if htpeheader_if = { htpeheader_init, 0 }; /* * CLASS ht_pe_header_viewer */ void ht_pe_header_viewer::init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *group) { ht_uformat_viewer::init(b, desc, caps, file, group); VIEW_DEBUG_NAME("ht_pe_header_viewer"); } static ht_format_viewer *find_hex_viewer(ht_group *group) { // FIXME: God forgive us... ht_group *vr_group = group; while (strcmp(vr_group->desc, VIEWERGROUP_NAME)) vr_group = vr_group->group; ht_view *c = vr_group->getfirstchild(); while (c) { if (c->desc && strcmp(c->desc, DESC_HEX) == 0) { return (ht_format_viewer*)c; } c = c->next; } return NULL; } bool ht_pe_header_viewer::ref_sel(LINE_ID *id) { ht_pe_shared_data *pe_shared = (ht_pe_shared_data *)format_group->get_shared_data(); switch (id->id1) { case 0: { ht_format_viewer *hexv = find_hex_viewer(group); if (hexv) { uint rva; uint size; if (pe_shared->opt_magic == COFF_OPTMAGIC_PE32) { rva = pe_shared->pe32.header_nt.directory[id->id2].address; size = pe_shared->pe32.header_nt.directory[id->id2].size; } else { rva = pe_shared->pe64.header_nt.directory[id->id2].address; size = pe_shared->pe64.header_nt.directory[id->id2].size; } FileOfs ofs = 0; if (pe_rva_to_ofs(&pe_shared->sections, rva, &ofs)) { vstate_save(); hexv->goto_offset(ofs, false); hexv->pselect_set(ofs, ofs+size); app->focus(hexv); } else errorbox("Can't follow: directory RVA %08x is not valid!", rva); } break; } case 1: if (pe_shared->v_exports) { vstate_save(); app->focus(pe_shared->v_exports); } break; case 2: if (pe_shared->v_imports) { vstate_save(); app->focus(pe_shared->v_imports); } break; case 3: if (pe_shared->v_resources) { vstate_save(); app->focus(pe_shared->v_resources); } break; case 4: { ht_format_viewer *hexv = find_hex_viewer(group); if (hexv) { uint ofs; uint size; if (pe_shared->opt_magic == COFF_OPTMAGIC_PE32) { ofs = pe_shared->pe32.header_nt.directory[id->id2].address; size = pe_shared->pe32.header_nt.directory[id->id2].size; } else { ofs = pe_shared->pe64.header_nt.directory[id->id2].address; size = pe_shared->pe64.header_nt.directory[id->id2].size; } if (size) { vstate_save(); hexv->goto_offset(ofs, false); hexv->pselect_set(ofs, ofs+size); app->focus(hexv); } else errorbox("can't follow: No bound import directory!", ofs); } break; } case 15: { if (pe_shared->v_il) { vstate_save(); app->focus(pe_shared->v_il); } break; } } return true; } ht-2.0.22/textedit.h0000644000175000001440000002744110615341624011142 00000000000000/* * HT Editor * textedit.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __TEXTEDIT_H__ #define __TEXTEDIT_H__ #include "htobj.h" #include "textfile.h" #include "htformat.h" #define TEXTEDITOPT_NULL 0 #define TEXTEDITOPT_INPUTTABS 1 #define TEXTEDITOPT_UNDO 2 struct text_viewer_pos { uint line; uint pofs; }; union text_search_pos { FileOfs offset; }; class ht_text_editor; #define ATOM_HT_UNDO_DATA_INSERT MAGIC32("UND\x01") #define ATOM_HT_UNDO_DATA_OVERWRITE MAGIC32("UND\x02") #define ATOM_HT_UNDO_DATA_DELETE MAGIC32("UND\x03") #define ATOM_HT_UNDO_DATA_DELETE2 MAGIC32("UND\x04") #define ATOM_HT_UNDO_DATA_SPLIT_LINE MAGIC32("UND\x05") #define ATOM_HT_UNDO_DATA_JOIN_LINE MAGIC32("UND\x06") #define ATOM_HT_UNDO_DATA_INSERT_BLOCK MAGIC32("UND\x07") #define ATOM_HT_UNDO_DATA_DELETE_BLOCK MAGIC32("UND\x08") /* * CLASS ht_undo_data */ class ht_undo_data: public Object { public: virtual bool combine(ht_undo_data *ud); virtual uint getsize() = 0; virtual void gettext(char *text, uint maxlen) = 0; virtual void apply(ht_text_editor *te) = 0; virtual void unapply(ht_text_editor *te, bool *goto_only) = 0; }; /* * CLASS ht_undo_data_delete_string */ class ht_undo_data_delete_string: public ht_undo_data { text_viewer_pos apos; /* cursor before */ text_viewer_pos bpos; /* cursor after */ void *string; uint len; public: ht_undo_data_delete_string(text_viewer_pos *apos, text_viewer_pos *bpos, void *string, uint len); ~ht_undo_data_delete_string(); virtual bool combine(ht_undo_data *ud); virtual uint getsize(); virtual void gettext(char *text, uint maxlen); virtual ObjectID getObjectID() const; virtual void apply(ht_text_editor *te); virtual void unapply(ht_text_editor *te, bool *goto_only); }; /* * CLASS ht_undo_data_delete_string2 */ class ht_undo_data_delete_string2: public ht_undo_data { text_viewer_pos apos; /* cursor before */ text_viewer_pos bpos; /* cursor after */ void *string; uint len; public: ht_undo_data_delete_string2(text_viewer_pos *apos, text_viewer_pos *bpos, void *string, uint len); ~ht_undo_data_delete_string2(); virtual bool combine(ht_undo_data *ud); virtual uint getsize(); virtual void gettext(char *text, uint maxlen); virtual ObjectID getObjectID() const; virtual void apply(ht_text_editor *te); virtual void unapply(ht_text_editor *te, bool *goto_only); }; /* * CLASS ht_undo_data_insert_string */ class ht_undo_data_insert_string: public ht_undo_data { text_viewer_pos apos; text_viewer_pos bpos; text_viewer_pos cpos; void *string; uint len; public: ht_undo_data_insert_string(text_viewer_pos *apos, text_viewer_pos *bpos, void *string, uint len); ~ht_undo_data_insert_string(); virtual bool combine(ht_undo_data *ud); virtual uint getsize(); virtual void gettext(char *text, uint maxlen); virtual ObjectID getObjectID() const; virtual void apply(ht_text_editor *te); virtual void unapply(ht_text_editor *te, bool *goto_only); }; /* * CLASS ht_undo_data_overwrite_string */ class ht_undo_data_overwrite_string: public ht_undo_data { text_viewer_pos apos; text_viewer_pos bpos; text_viewer_pos cpos; void *string; uint len; void *string2; uint len2; public: ht_undo_data_overwrite_string(text_viewer_pos *apos, text_viewer_pos *bpos, void *string, uint len, void *string2, uint len2); ~ht_undo_data_overwrite_string(); virtual bool combine(ht_undo_data *ud); virtual uint getsize(); virtual void gettext(char *text, uint maxlen); virtual ObjectID getObjectID() const; virtual void apply(ht_text_editor *te); virtual void unapply(ht_text_editor *te, bool *goto_only); }; /* * CLASS ht_undo_data_split_line */ class ht_undo_data_split_line: public ht_undo_data { text_viewer_pos apos; text_viewer_pos bpos; uint indent; public: ht_undo_data_split_line(text_viewer_pos *apos, text_viewer_pos *bpos, uint Indent); virtual uint getsize(); virtual void gettext(char *text, uint maxlen); virtual ObjectID getObjectID() const; virtual void apply(ht_text_editor *te); virtual void unapply(ht_text_editor *te, bool *goto_only); }; /* * CLASS ht_undo_data_join_line */ class ht_undo_data_join_line: public ht_undo_data { text_viewer_pos apos; text_viewer_pos bpos; text_viewer_pos cpos; public: ht_undo_data_join_line(text_viewer_pos *apos, text_viewer_pos *bpos); virtual uint getsize(); virtual void gettext(char *text, uint maxlen); virtual ObjectID getObjectID() const; virtual void apply(ht_text_editor *te); virtual void unapply(ht_text_editor *te, bool *goto_only); }; /* * CLASS ht_undo_data_insert_block */ class ht_undo_data_insert_block: public ht_undo_data { text_viewer_pos apos; text_viewer_pos bpos; text_viewer_pos cpos; text_viewer_pos sel_start; text_viewer_pos sel_end; void *block; uint size; public: ht_undo_data_insert_block(text_viewer_pos *apos, text_viewer_pos *bpos, void *block, uint size); ~ht_undo_data_insert_block(); virtual uint getsize(); virtual void gettext(char *text, uint maxlen); virtual ObjectID getObjectID() const; virtual void apply(ht_text_editor *te); virtual void unapply(ht_text_editor *te, bool *goto_only); }; /* * CLASS ht_undo_data_delete_block */ class ht_undo_data_delete_block: public ht_undo_data { text_viewer_pos apos; text_viewer_pos bpos; text_viewer_pos cpos; text_viewer_pos sel_start; text_viewer_pos sel_end; void *block; uint size; public: ht_undo_data_delete_block(text_viewer_pos *apos, text_viewer_pos *bpos, text_viewer_pos *Sel_start, text_viewer_pos *Sel_end); ~ht_undo_data_delete_block(); virtual uint getsize(); virtual void gettext(char *text, uint maxlen); virtual ObjectID getObjectID() const; virtual void apply(ht_text_editor *te); virtual void unapply(ht_text_editor *te, bool *goto_only); }; /* * CLASS ht_text_editor_undo */ class ht_text_editor_undo: public Array { public: uint size, max_size; int clean_state; int current_position; bool goto_state; public: ht_text_editor_undo(uint max_undo_size); void insert_undo(ht_text_editor *te, ht_undo_data *undo); bool is_clean(); bool is_clean(int i); int get_current_position(); void mark_clean(); void undo(ht_text_editor *te, bool place_cursor_first); void redo(ht_text_editor *te); }; /* * CLASS ht_text_viewer */ #define cmd_text_viewer_goto HT_COMMAND(601) #define cmd_text_viewer_change_highlight HT_COMMAND(602) #define cmd_text_editor_undo HT_COMMAND(620) #define cmd_text_editor_redo HT_COMMAND(621) #define cmd_text_editor_protocol HT_COMMAND(622) #define cmd_text_editor_delete_line HT_COMMAND(623) class ht_text_viewer: public ht_view { friend class ht_undo_data; friend class ht_undo_data_delete_string; friend class ht_undo_data_delete_string2; friend class ht_undo_data_insert_string; friend class ht_undo_data_overwrite_string; friend class ht_undo_data_split_line; friend class ht_undo_data_join_line; friend class ht_undo_data_insert_block; friend class ht_undo_data_delete_block; protected: ht_textfile *textfile; bool own_textfile; Container *lexers; ht_syntax_lexer *lexer; bool own_lexer; uint cursorx, cursory; text_viewer_pos sel_start, sel_end; uint top_line; uint xofs; bool selectcursor; bool selectmode; text_viewer_pos selectstart; char *EOL_string; char *EOF_string; bool show_EOL; bool show_EOF; bool highlight_wrap; uint tab_size; ht_search_request *last_search_request; FileOfs last_search_end_ofs; /* new */ int buf_lprint0(int x, int y, int c, int l, char *text); uint char_vsize(char c, uint x); void clipboard_copy_cmd(); bool continue_search(); virtual vcp get_bgcolor(); void make_pos_physical(text_viewer_pos *p); void normalize_selection(); uint physical_cursorx(); void popup_change_highlight(); void render_meta(uint x, uint y, text_viewer_pos *pos, vcp color); void render_str(int x, int y, vcp color, text_viewer_pos *pos, uint len, char *str, bool multi); void render_str_color(vcp *color, text_viewer_pos *pos); ht_search_result *search(ht_search_request *request, text_search_pos *start, text_search_pos *end); bool show_search_result(ht_search_result *result); public: void init(Bounds *b, bool own_textfile, ht_textfile *textfile, Container *lexers); virtual void done(); /* overwritten */ virtual void config_changed(); virtual void draw(); virtual void handlemsg(htmsg *msg); virtual void resize(int rw, int rh); /* new */ virtual const char *func(uint i, bool execute); uint get_line_length(uint line); uint get_line_vlength(uint line); uint get_line_indent(uint line); void get_selection(text_viewer_pos *start, text_viewer_pos *end); bool goto_line(uint line); /* position indicator string */ virtual int get_pindicator_str(char *buf, int max_len); /* scrollbar pos */ virtual bool get_hscrollbar_pos(int *pstart, int *psize); virtual bool get_vscrollbar_pos(int *pstart, int *psize); /* cursor */ virtual CursorMode get_cursor_mode(); virtual void get_cursor_pos(text_viewer_pos *cursor); /* conversions */ virtual bool pos_to_offset(text_viewer_pos *pos, FileOfs *ofs); /**/ ht_syntax_lexer *get_lexer(); int ppos_str(char *buf, uint bufsize, text_viewer_pos *ppos); void set_lexer(ht_syntax_lexer *l, bool own_l); void set_textfile(ht_textfile *t, bool own_t); ht_textfile *get_textfile(); /**/ uint cursor_up(uint n); uint cursor_down(uint n); uint cursor_left(uint n); uint cursor_right(uint n); void cursor_home(); void cursor_end(); void cursor_vput(uint vx); void cursor_pput(uint px); void cursor_set(text_viewer_pos *pos); uint scroll_up(uint n); uint scroll_down(uint n); uint scroll_left(uint n); uint scroll_right(uint n); void select_add(text_viewer_pos *from, text_viewer_pos *to); void select_clear(); void select_end(); void select_set(text_viewer_pos *from, text_viewer_pos *to); void select_start(); }; /* * CLASS ht_text_editor */ class ht_text_editor: public ht_text_viewer { protected: uint edit_options; ht_text_editor_undo *undo_list; bool auto_indent; bool overwrite_mode; /* new */ void clipboard_cut_cmd(); void clipboard_delete_cmd(); void clipboard_paste_cmd(); virtual vcp get_bgcolor(); bool save(); public: void init(Bounds *b, bool own_textfile, ht_textfile *textfile, Container *lexers, uint edit_options); virtual void done(); /* overwritten */ virtual void config_changed(); virtual const char *func(uint i, bool execute); virtual void handlemsg(htmsg *msg); /* position indicator string */ virtual int get_pindicator_str(char *buf, int max_len); /* cursor mode */ virtual CursorMode get_cursor_mode(); /* new */ bool concat_lines(uint a); void delete_chars(uint line, uint ofs, uint count); void delete_lines(uint line, uint count); void indent(uint line, uint start, uint size); void insert_chars(uint line, uint ofs, void *chars, uint len); void insert_lines(uint line, uint count); void split_line(uint a, uint pos); void unindent(uint line, uint start, uint size); /* undo/redo */ void textoperation_apply(ht_undo_data *ud); void redo(); void show_protocol(); void undo(bool place_cursor_first); }; extern int text_viewer_pos_compare(text_viewer_pos *a, text_viewer_pos *b); #endif /* __TEXTEDIT_H__ */ ht-2.0.22/htdebug.h0000644000175000017500000000410012127651417010725 00000000000000/* * HT Editor * htdebug.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTDEBUG_H__ #define __HTDEBUG_H__ #include #include "io/types.h" /****************************************************************************/ #define HTDEBUG /****************************************************************************/ void ht_assert_failed(const char *file, int line, const char *assertion) __attribute__ ((noreturn)); void ht_error(const char *file, int line, const char *format,...) __attribute__ ((noreturn)); void ht_trace(const char *file, int line, const char *format,...); void ht_warn(const char *file, int line, const char *format,...); typedef uint64 timepoint; typedef int timer_handle; timer_handle new_timer(); void start_timer(timer_handle handle); void stop_timer(timer_handle handle); void delete_timer(timer_handle handle); uint get_timer_sec(timer_handle handle); uint get_timer_msec(timer_handle handle); uint get_timer_tick(timer_handle h); #define HT_ERROR(a...) ht_error(__FILE__, __LINE__, a) #define HT_WARN(a...) ht_warn(__FILE__, __LINE__, a) #ifdef HTDEBUG #define HT_TRACE(a...) ht_trace(__FILE__, __LINE__, a) #else #define HT_TRACE(a...) ((void)0) #endif #ifdef assert #undef assert #endif #ifdef HTDEBUG # define assert(a) if (!(a)) ht_assert_failed(__FILE__, __LINE__, (#a)); #else # define assert(a) ((void)0) #endif #define ASSERT(a) assert(a) #define HERE __FILE__, __LINE__ #endif /* !__HTDEBUG_H__ */ ht-2.0.22/htneent.h0000644000175000001440000000177610615341620010754 00000000000000/* * HT Editor * htneent.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTNEENT_H__ #define __HTNEENT_H__ #include "formats.h" extern format_viewer_if htneentrypoints_if; /* * CLASS ht_ne_entrypoint_viewer */ class ht_ne_entrypoint_viewer: public ht_uformat_viewer { public: /* overwritten */ virtual bool ref_sel(LINE_ID *id); }; #endif /* !__HTNEENT_H__ */ ht-2.0.22/defreg.h0000644000175000017500000000017512127651417010547 00000000000000#ifndef __DEFREG_H #define __DEFREG_H extern #ifdef __cplusplus "C" #endif char default_reg[1605]; #endif /* __DEFREG_H */ ht-2.0.22/blockop.h0000644000175000001440000000227210615341616010735 00000000000000/* * HT Editor * blockop.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __BLOCKOP_H__ #define __BLOCKOP_H__ #include "htdialog.h" #include "htformat.h" /* * CLASS ht_blockop_dialog */ class ht_blockop_dialog: public ht_dialog { protected: ht_strinputfield *start; ht_strinputfield *end; ht_listpopup *mode; ht_strinputfield *action; public: void init(Bounds *b, FileOfs pstart, FileOfs pend, List *history = NULL); virtual void done(); }; void blockop_dialog(ht_format_viewer *format, FileOfs pstart, FileOfs pend); #endif /* __BLOCKOP_H__ */ ht-2.0.22/asm/0000755000175000017500000000000012156433676010006 500000000000000ht-2.0.22/asm/x86opc.h0000644000175000017500000001650612127651420011221 00000000000000/* * HT Editor * x86opc.h * * Copyright (C) 1999-2002 Stefan Weyergraf * Copyright (C) 2005-2007 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __X86OPC_H__ #define __X86OPC_H__ #include "io/types.h" #define X86_PREFIX_NO -1 #define X86_PREFIX_LOCK 0 /* f0 */ #define X86_PREFIX_ES 0 /* 26 */ #define X86_PREFIX_CS 1 /* 2e */ #define X86_PREFIX_SS 2 /* 36 */ #define X86_PREFIX_DS 3 /* 3e */ #define X86_PREFIX_FS 4 /* 64 */ #define X86_PREFIX_GS 5 /* 65 */ #define X86_PREFIX_REPNZ 0 /* f2 */ #define X86_PREFIX_REPZ 1 /* f3 */ #define X86_PREFIX_OPSIZE 0 /* 66 */ #define X86_PREFIX_NOOPSIZE 1 /* no 66 allowed */ enum X86OpSize { X86_OPSIZEUNKNOWN = -1, X86_OPSIZE16 = 0, X86_OPSIZE32 = 1, X86_OPSIZE64 = 2, }; enum X86AddrSize { X86_ADDRSIZEUNKNOWN = -1, X86_ADDRSIZE16 = 0, X86_ADDRSIZE32 = 1, X86_ADDRSIZE64 = 2, }; enum X86_Optype { X86_OPTYPE_EMPTY = 0, X86_OPTYPE_IMM = 1, X86_OPTYPE_REG = 2, X86_OPTYPE_SEG = 3, X86_OPTYPE_MEM = 4, X86_OPTYPE_CRX = 5, X86_OPTYPE_DRX = 6, X86_OPTYPE_STX = 7, X86_OPTYPE_MMX = 8, X86_OPTYPE_XMM = 9, X86_OPTYPE_YMM = 10, X86_OPTYPE_FARPTR = 11, // user defined types start here X86_OPTYPE_USER = 32, }; struct x86_insn_op { X86_Optype type; int size; bool need_rex; bool forbid_rex; union { struct { uint32 seg; uint32 offset; } farptr; uint64 imm; int reg; int seg; struct { uint64 disp; int base; int index; int scale; int addrsize; bool floatptr; bool addrptr; bool hasdisp; } mem; int crx; int drx; int trx; int stx; int mmx; int xmm; int ymm; union { int i; void *p; } user[4]; }; }; enum { TYPE_0 = 0, TYPE_A, /* direct address without ModR/M (generally */ /* like imm, but can be 16:32 = 48 bit) */ TYPE_C, /* reg of ModR/M picks control register */ TYPE_D, /* reg of ModR/M picks debug register */ TYPE_E, /* ModR/M (general reg or memory) */ TYPE_F, /* r/m of ModR/M picks a fpu register */ TYPE_Fx, /* extra picks a fpu register */ TYPE_G, /* reg of ModR/M picks general register */ TYPE_Is, /* signed immediate */ TYPE_I, /* unsigned immediate */ TYPE_I4, /* 4 bit immediate (see TYPE_VI, TYPE_YI) */ TYPE_Ix, /* fixed immediate */ TYPE_J, /* relative branch offset */ TYPE_M, /* ModR/M (memory only) */ TYPE_MR, /* Same as E, but extra picks reg size */ TYPE_O, /* direct memory without ModR/M */ TYPE_P, /* reg of ModR/M picks MMX register */ TYPE_PR, /* rm of ModR/M picks MMX register */ TYPE_Q, /* ModR/M (MMX reg or memory) */ TYPE_R, /* rm of ModR/M picks general register */ TYPE_Rx, /* extra picks register */ TYPE_RXx, /* extra picks register, no REX extension */ TYPE_RV, /* VEX.vvvv picks general register */ TYPE_S, /* reg of ModR/M picks segment register */ TYPE_Sx, /* extra picks segment register */ TYPE_V, /* reg of ModR/M picks XMM register */ TYPE_VI, /* bits 7-4 of imm picks XMM register */ TYPE_VV, /* VEX.vvvv pick XMM register */ TYPE_Vx, /* extra picks XMM register */ TYPE_VR, /* rm of ModR/M picks XMM register */ TYPE_W, /* ModR/M (XMM reg or memory) */ TYPE_Y, /* reg of ModR/M picks YMM register */ TYPE_YV, /* VEX.vvvv picks YMM register */ TYPE_YI, /* bits 7-4 of imm picks YMM register */ TYPE_YR, /* rm of ModR/M picks YMM register */ TYPE_X, /* ModR/M (YMM reg or memory) */ TYPE_VD, /* SSE5: drex.dest */ TYPE_VS, /* SSE5: src (mod/rm) */ }; enum X86_VEX { W0 = 0x00, W1 = 0x80, _128 = 0x00, _256 = 0x40, _66 = 0x01, _f3 = 0x02, _f2 = 0x03, _0f = 0x04, // mmmm = 1 _0f38 = 0x08, // mmmm = 2 _0f3a = 0x0c, // mmmm = 3 // _0f4 = 0x10, // mmmm = 4 // _0f5 = 0x14, // mmmm = 5 // _0f6 = 0x18, // mmmm = 6 // _0f7 = 0x1c, // mmmm = 7 _0f24 = 0x20, // mmmm = 8 _0f25 = 0x24, // mmmm = 9 _0fA = 0x28, // mmmm = 10 }; /* when name is == 0, the first op has a special meaning (layout see x86_insn_op_special) */ #define SPECIAL_TYPE_INVALID 0 #define SPECIAL_TYPE_PREFIX 1 #define SPECIAL_TYPE_OPC_GROUP 2 #define SPECIAL_TYPE_GROUP 3 #define SPECIAL_TYPE_SGROUP 4 #define SPECIAL_TYPE_FGROUP 5 enum { SIZE_0 = '0', /* size unimportant */ SIZE_B = 'b', /* byte */ SIZE_BV = 'B', /* byte, extended to SIZE_V */ SIZE_W = 'w', /* word */ SIZE_D = 'd', /* dword */ SIZE_Q = 'q', /* qword */ SIZE_U = 'u', /* qword OR oword (depending on 0x66 prefix) */ SIZE_Z = 'z', /* dword OR qword (depending on 0x66 prefix) */ SIZE_O = 'o', /* oword (128 bit) */ SIZE_V = 'v', /* word OR dword OR qword */ SIZE_VV = 'V', /* word OR dword OR sign extended dword */ SIZE_R = 'r', /* dword OR qword (depending on rex size) */ SIZE_P = 'p', /* word:word OR word:dword, memory only! */ SIZE_S = 's', /* short/single real (32-bit) */ SIZE_L = 'l', /* long/double real (64-bit) */ SIZE_T = 't', /* temp/extended real (80-bit) */ SIZE_A = 'a', /* packed decimal (80-bit BCD) */ SIZE_Y = 'y', /* ymmword (256 bit) */ }; #define INFO_DEFAULT_64 0x80 struct x86opc_insn_op { byte type; byte extra; byte info; byte size; }; struct x86opc_insn { const char *name; byte op[4]; }; struct x86opc_vex_insn { const char *name; byte vex; byte op[5]; }; struct x86_64_insn_patch { int opc; x86opc_insn insn; }; /* this can be a group (group!=0), an insn (group==0) && (insn.name!=0) or (otherwise) a reserved instruction. */ struct x86opc_finsn { x86opc_insn *group; x86opc_insn insn; }; #define X86_REG_INVALID -2 #define X86_REG_NO (-1 & ~8) #define X86_REG_AX 0 #define X86_REG_CX 1 #define X86_REG_DX 2 #define X86_REG_BX 3 #define X86_REG_SP 4 #define X86_REG_BP 5 #define X86_REG_SI 6 #define X86_REG_DI 7 #define X86_REG_R8 8 #define X86_REG_R9 9 #define X86_REG_R10 10 #define X86_REG_R11 11 #define X86_REG_R12 12 #define X86_REG_R13 13 #define X86_REG_R14 14 #define X86_REG_R15 15 #define X86_REG_IP 66 #define X86_OPC_GROUPS 9 #define X86_SPECIAL_GROUPS 15 extern x86opc_insn x86_les; extern x86opc_insn x86_lds; extern x86opc_insn x86_pop_group; extern const char *x86_regs[4][8]; extern const char *x86_64regs[4][16]; extern const char *x86_ipregs[4]; extern const char *x86_segs[8]; extern x86opc_insn_op x86_op_type[]; extern x86opc_insn x86_32_insns[256]; extern x86_64_insn_patch x86_64_insn_patches[]; extern x86opc_insn x86_insns_ext[256]; extern x86opc_insn x86_insns_ext_66[256]; extern x86opc_insn x86_insns_ext_f2[256]; extern x86opc_insn x86_insns_ext_f3[256]; extern x86opc_insn x86_opc_group_insns[X86_OPC_GROUPS][256]; extern x86opc_insn x86_group_insns[][8]; extern x86opc_insn x86_special_group_insns[X86_SPECIAL_GROUPS][9]; extern x86opc_vex_insn *x86_vex_insns[256]; extern x86opc_vex_insn x86_group_vex_insns[][8]; extern x86opc_insn x86_modfloat_group_insns[8][8]; extern x86opc_finsn x86_float_group_insns[8][8]; #endif /* __X86OPC_H__ */ ht-2.0.22/asm/ildis.h0000644000175000001440000000417510636023333011170 00000000000000/* * HT Editor * ildis.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ILDIS_H #define ILDIS_H #include "asm.h" #include "data.h" #include "ilopc.h" struct ILDisInsn { bool valid; int size; byte op; union { uint32 ui; uint64 q; float f; double df; int i; } data; ILOpcodeTabEntry *prefix; ILOpcodeTabEntry *opcode; }; /* * CLASS alphadis */ class ILDisassembler: public Disassembler { protected: char insnstr[256]; ILDisInsn insn; void *context; char* (*string_func)(uint32 string_ofs, void *context); char* (*token_func)(uint32 token, void *context); public: ILDisassembler(char* (*string_func)(uint32 string_ofs, void *context), char* (*token_func)(uint32 token, void *context), void *context); ILDisassembler(BuildCtorArg&a): Disassembler(a) {}; virtual dis_insn *decode(byte *code, int maxlen, CPU_ADDR addr); virtual dis_insn *duplicateInsn(dis_insn *disasm_insn); virtual void getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align); virtual byte getSize(dis_insn *disasm_insn); virtual const char *getName(); void initialize(char* (*string_func)(uint32 string_ofs, void *context), char* (*token_func)(uint32 token, void *context), void *context); virtual const char *str(dis_insn *disasm_insn, int style); virtual const char *strf(dis_insn *disasm_insn, int style, const char *format); virtual ObjectID getObjectID() const; virtual bool validInsn(dis_insn *disasm_insn); }; #endif ht-2.0.22/asm/alphadis.h0000644000175000001440000000345112156427024011651 00000000000000/* * HT Editor * alphadis.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ALPHADIS_H #define ALPHADIS_H #include "asm.h" #include "alphaopc.h" struct alphadis_insn { bool valid; int size; /* only useful if invalid (else 4) */ sint32 data; /* must be signed */ uint64 address; uint16 code; byte regA; byte regB; byte regC; alpha_opcode_tab_entry *table; }; /* * CLASS alphadis */ class Alphadis: public Disassembler { protected: char insnstr[256]; alphadis_insn insn; public: Alphadis(); Alphadis(BuildCtorArg&a): Disassembler(a) {}; virtual dis_insn *decode(byte *code, int maxlen, CPU_ADDR addr); virtual dis_insn *duplicateInsn(dis_insn *disasm_insn); virtual void getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align); virtual byte getSize(dis_insn *disasm_insn); virtual const char *getName(); virtual const char *str(dis_insn *disasm_insn, int style); virtual const char *strf(dis_insn *disasm_insn, int style, const char *format); virtual ObjectID getObjectID() const; virtual bool validInsn(dis_insn *disasm_insn); }; #endif ht-2.0.22/asm/arm-dis.cc0000644000175000001440000032256711003705547011571 00000000000000/* Instruction printing code for the ARM Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org) Modification by James G. Smith (jsmith@cygnus.co.uk) This file is part of libopcodes. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "arm.h" #include "dis-asm.h" /* FIXME: Belongs in global header. */ #ifndef strneq #define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0) #endif #ifndef NUM_ELEM #define NUM_ELEM(a) (sizeof (a) / sizeof (a)[0]) #endif struct opcode32 { unsigned long arch; /* Architecture defining this insn. */ unsigned long value, mask; /* Recognise insn if (op&mask)==value. */ const char *assembler; /* How to disassemble this insn. */ }; struct opcode16 { unsigned long arch; /* Architecture defining this insn. */ unsigned short value, mask; /* Recognise insn if (op&mask)==value. */ const char *assembler; /* How to disassemble this insn. */ }; /* print_insn_coprocessor recognizes the following format control codes: %% % %c print condition code (always bits 28-31) %A print address for ldc/stc/ldf/stf instruction %I print cirrus signed shift immediate: bits 0..3|4..6 %F print the COUNT field of a LFM/SFM instruction. %P print floating point precision in arithmetic insn %Q print floating point precision in ldf/stf insn %R print floating point rounding mode %r print as an ARM register %d print the bitfield in decimal %x print the bitfield in hex %X print the bitfield as 1 hex digit without leading "0x" %f print a floating point constant if >7 else a floating point register %w print as an iWMMXt width field - [bhwd]ss/us %g print as an iWMMXt 64-bit register %G print as an iWMMXt general purpose or control register %y print a single precision VFP reg. Codes: 0=>Sm, 1=>Sd, 2=>Sn, 3=>multi-list, 4=>Sm pair %z print a double precision VFP reg Codes: 0=>Dm, 1=>Dd, 2=>Dn, 3=>multi-list %'c print specified char iff bit is one %`c print specified char iff bit is zero %?ab print a if bit is one else print b %L print as an iWMMXt N/M width field. %Z print the Immediate of a WSHUFH instruction. %l like 'A' except use byte offsets for 'B' & 'H' versions. */ /* Common coprocessor opcodes shared between Arm and Thumb-2. */ static const struct opcode32 coprocessor_opcodes[] = { /* XScale instructions. */ {ARM_CEXT_XSCALE, 0x0e200010, 0x0fff0ff0, "mia%c\tacc0, %0-3r, %12-15r"}, {ARM_CEXT_XSCALE, 0x0e280010, 0x0fff0ff0, "miaph%c\tacc0, %0-3r, %12-15r"}, {ARM_CEXT_XSCALE, 0x0e2c0010, 0x0ffc0ff0, "mia%17'T%17`B%16'T%16`B%c\tacc0, %0-3r, %12-15r"}, {ARM_CEXT_XSCALE, 0x0c400000, 0x0ff00fff, "mar%c\tacc0, %12-15r, %16-19r"}, {ARM_CEXT_XSCALE, 0x0c500000, 0x0ff00fff, "mra%c\t%12-15r, %16-19r, acc0"}, /* Intel Wireless MMX technology instructions. */ #define FIRST_IWMMXT_INSN 0x0e130130 #define IWMMXT_INSN_COUNT 47 {ARM_CEXT_IWMMXT, 0x0e130130, 0x0f3f0fff, "tandc%22-23w%c\t%12-15r"}, {ARM_CEXT_XSCALE, 0x0e400010, 0x0ff00f3f, "tbcst%6-7w%c\t%16-19g, %12-15r"}, {ARM_CEXT_XSCALE, 0x0e130170, 0x0f3f0ff8, "textrc%22-23w%c\t%12-15r, #%0-2d"}, {ARM_CEXT_XSCALE, 0x0e100070, 0x0f300ff0, "textrm%3?su%22-23w%c\t%12-15r, %16-19g, #%0-2d"}, {ARM_CEXT_XSCALE, 0x0e600010, 0x0ff00f38, "tinsr%6-7w%c\t%16-19g, %12-15r, #%0-2d"}, {ARM_CEXT_XSCALE, 0x0e000110, 0x0ff00fff, "tmcr%c\t%16-19G, %12-15r"}, {ARM_CEXT_XSCALE, 0x0c400000, 0x0ff00ff0, "tmcrr%c\t%0-3g, %12-15r, %16-19r"}, {ARM_CEXT_XSCALE, 0x0e2c0010, 0x0ffc0e10, "tmia%17?tb%16?tb%c\t%5-8g, %0-3r, %12-15r"}, {ARM_CEXT_XSCALE, 0x0e200010, 0x0fff0e10, "tmia%c\t%5-8g, %0-3r, %12-15r"}, {ARM_CEXT_XSCALE, 0x0e280010, 0x0fff0e10, "tmiaph%c\t%5-8g, %0-3r, %12-15r"}, {ARM_CEXT_XSCALE, 0x0e100030, 0x0f300fff, "tmovmsk%22-23w%c\t%12-15r, %16-19g"}, {ARM_CEXT_XSCALE, 0x0e100110, 0x0ff00ff0, "tmrc%c\t%12-15r, %16-19G"}, {ARM_CEXT_XSCALE, 0x0c500000, 0x0ff00ff0, "tmrrc%c\t%12-15r, %16-19r, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e130150, 0x0f3f0fff, "torc%22-23w%c\t%12-15r"}, {ARM_CEXT_XSCALE, 0x0e0001c0, 0x0f300fff, "wacc%22-23w%c\t%12-15g, %16-19g"}, {ARM_CEXT_XSCALE, 0x0e000180, 0x0f000ff0, "wadd%20-23w%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e000020, 0x0f800ff0, "waligni%c\t%12-15g, %16-19g, %0-3g, #%20-22d"}, {ARM_CEXT_XSCALE, 0x0e800020, 0x0fc00ff0, "walignr%20-21d%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e200000, 0x0fe00ff0, "wand%20'n%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e800000, 0x0fa00ff0, "wavg2%22?hb%20'r%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e000060, 0x0f300ff0, "wcmpeq%22-23w%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e100060, 0x0f100ff0, "wcmpgt%21?su%22-23w%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0xfc100100, 0xfe500f00, "wldrw\t%12-15G, %A"}, {ARM_CEXT_XSCALE, 0x0c100000, 0x0e100e00, "wldr%L%c\t%12-15g, %l"}, {ARM_CEXT_XSCALE, 0x0e400100, 0x0fc00ff0, "wmac%21?su%20'z%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e800100, 0x0fd00ff0, "wmadd%21?su%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e000160, 0x0f100ff0, "wmax%21?su%22-23w%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e100160, 0x0f100ff0, "wmin%21?su%22-23w%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e000100, 0x0fc00ff0, "wmul%21?su%20?ml%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e000000, 0x0ff00ff0, "wor%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e000080, 0x0f000ff0, "wpack%20-23w%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e300040, 0x0f300ff0, "wror%22-23w%8'g%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e300148, 0x0f300ffc, "wror%22-23w%8'g%c\t%12-15g, %16-19g, %0-3G"}, {ARM_CEXT_XSCALE, 0x0e000120, 0x0fa00ff0, "wsad%22?hb%20'z%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e0001e0, 0x0f000ff0, "wshufh%c\t%12-15g, %16-19g, #%Z"}, {ARM_CEXT_XSCALE, 0x0e100040, 0x0f300ff0, "wsll%22-23w%8'g%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e100148, 0x0f300ffc, "wsll%22-23w%8'g%c\t%12-15g, %16-19g, %0-3G"}, {ARM_CEXT_XSCALE, 0x0e000040, 0x0f300ff0, "wsra%22-23w%8'g%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e000148, 0x0f300ffc, "wsra%22-23w%8'g%c\t%12-15g, %16-19g, %0-3G"}, {ARM_CEXT_XSCALE, 0x0e200040, 0x0f300ff0, "wsrl%22-23w%8'g%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e200148, 0x0f300ffc, "wsrl%22-23w%8'g%c\t%12-15g, %16-19g, %0-3G"}, {ARM_CEXT_XSCALE, 0xfc000100, 0xfe500f00, "wstrw\t%12-15G, %A"}, {ARM_CEXT_XSCALE, 0x0c000000, 0x0e100e00, "wstr%L%c\t%12-15g, %l"}, {ARM_CEXT_XSCALE, 0x0e0001a0, 0x0f000ff0, "wsub%20-23w%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e0000c0, 0x0f100fff, "wunpckeh%21?su%22-23w%c\t%12-15g, %16-19g"}, {ARM_CEXT_XSCALE, 0x0e0000e0, 0x0f100fff, "wunpckel%21?su%22-23w%c\t%12-15g, %16-19g"}, {ARM_CEXT_XSCALE, 0x0e1000c0, 0x0f300ff0, "wunpckih%22-23w%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e1000e0, 0x0f300ff0, "wunpckil%22-23w%c\t%12-15g, %16-19g, %0-3g"}, {ARM_CEXT_XSCALE, 0x0e100000, 0x0ff00ff0, "wxor%c\t%12-15g, %16-19g, %0-3g"}, /* Floating point coprocessor (FPA) instructions */ {FPU_FPA_EXT_V1, 0x0e000100, 0x0ff08f10, "adf%c%P%R\t%12-14f, %16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e100100, 0x0ff08f10, "muf%c%P%R\t%12-14f, %16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e200100, 0x0ff08f10, "suf%c%P%R\t%12-14f, %16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e300100, 0x0ff08f10, "rsf%c%P%R\t%12-14f, %16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e400100, 0x0ff08f10, "dvf%c%P%R\t%12-14f, %16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e500100, 0x0ff08f10, "rdf%c%P%R\t%12-14f, %16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e600100, 0x0ff08f10, "pow%c%P%R\t%12-14f, %16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e700100, 0x0ff08f10, "rpw%c%P%R\t%12-14f, %16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e800100, 0x0ff08f10, "rmf%c%P%R\t%12-14f, %16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e900100, 0x0ff08f10, "fml%c%P%R\t%12-14f, %16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0ea00100, 0x0ff08f10, "fdv%c%P%R\t%12-14f, %16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0eb00100, 0x0ff08f10, "frd%c%P%R\t%12-14f, %16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0ec00100, 0x0ff08f10, "pol%c%P%R\t%12-14f, %16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e008100, 0x0ff08f10, "mvf%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e108100, 0x0ff08f10, "mnf%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e208100, 0x0ff08f10, "abs%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e308100, 0x0ff08f10, "rnd%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e408100, 0x0ff08f10, "sqt%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e508100, 0x0ff08f10, "log%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e608100, 0x0ff08f10, "lgn%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e708100, 0x0ff08f10, "exp%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e808100, 0x0ff08f10, "sin%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e908100, 0x0ff08f10, "cos%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0ea08100, 0x0ff08f10, "tan%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0eb08100, 0x0ff08f10, "asn%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0ec08100, 0x0ff08f10, "acs%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0ed08100, 0x0ff08f10, "atn%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0ee08100, 0x0ff08f10, "urd%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0ef08100, 0x0ff08f10, "nrm%c%P%R\t%12-14f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0e000110, 0x0ff00f1f, "flt%c%P%R\t%16-18f, %12-15r"}, {FPU_FPA_EXT_V1, 0x0e100110, 0x0fff0f98, "fix%c%R\t%12-15r, %0-2f"}, {FPU_FPA_EXT_V1, 0x0e200110, 0x0fff0fff, "wfs%c\t%12-15r"}, {FPU_FPA_EXT_V1, 0x0e300110, 0x0fff0fff, "rfs%c\t%12-15r"}, {FPU_FPA_EXT_V1, 0x0e400110, 0x0fff0fff, "wfc%c\t%12-15r"}, {FPU_FPA_EXT_V1, 0x0e500110, 0x0fff0fff, "rfc%c\t%12-15r"}, {FPU_FPA_EXT_V1, 0x0e90f110, 0x0ff8fff0, "cmf%c\t%16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0eb0f110, 0x0ff8fff0, "cnf%c\t%16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0ed0f110, 0x0ff8fff0, "cmfe%c\t%16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0ef0f110, 0x0ff8fff0, "cnfe%c\t%16-18f, %0-3f"}, {FPU_FPA_EXT_V1, 0x0c000100, 0x0e100f00, "stf%c%Q\t%12-14f, %A"}, {FPU_FPA_EXT_V1, 0x0c100100, 0x0e100f00, "ldf%c%Q\t%12-14f, %A"}, {FPU_FPA_EXT_V2, 0x0c000200, 0x0e100f00, "sfm%c\t%12-14f, %F, %A"}, {FPU_FPA_EXT_V2, 0x0c100200, 0x0e100f00, "lfm%c\t%12-14f, %F, %A"}, /* Floating point coprocessor (VFP) instructions */ {FPU_VFP_EXT_V1, 0x0eb00bc0, 0x0fff0ff0, "fabsd%c\t%1z, %0z"}, {FPU_VFP_EXT_V1xD, 0x0eb00ac0, 0x0fbf0fd0, "fabss%c\t%1y, %0y"}, {FPU_VFP_EXT_V1, 0x0e300b00, 0x0ff00ff0, "faddd%c\t%1z, %2z, %0z"}, {FPU_VFP_EXT_V1xD, 0x0e300a00, 0x0fb00f50, "fadds%c\t%1y, %2y, %0y"}, {FPU_VFP_EXT_V1, 0x0eb40b40, 0x0fff0f70, "fcmp%7'ed%c\t%1z, %0z"}, {FPU_VFP_EXT_V1xD, 0x0eb40a40, 0x0fbf0f50, "fcmp%7'es%c\t%1y, %0y"}, {FPU_VFP_EXT_V1, 0x0eb50b40, 0x0fff0f70, "fcmp%7'ezd%c\t%1z"}, {FPU_VFP_EXT_V1xD, 0x0eb50a40, 0x0fbf0f70, "fcmp%7'ezs%c\t%1y"}, {FPU_VFP_EXT_V1, 0x0eb00b40, 0x0fff0ff0, "fcpyd%c\t%1z, %0z"}, {FPU_VFP_EXT_V1xD, 0x0eb00a40, 0x0fbf0fd0, "fcpys%c\t%1y, %0y"}, {FPU_VFP_EXT_V1, 0x0eb70ac0, 0x0fff0fd0, "fcvtds%c\t%1z, %0y"}, {FPU_VFP_EXT_V1, 0x0eb70bc0, 0x0fbf0ff0, "fcvtsd%c\t%1y, %0z"}, {FPU_VFP_EXT_V1, 0x0e800b00, 0x0ff00ff0, "fdivd%c\t%1z, %2z, %0z"}, {FPU_VFP_EXT_V1xD, 0x0e800a00, 0x0fb00f50, "fdivs%c\t%1y, %2y, %0y"}, {FPU_VFP_EXT_V1, 0x0d100b00, 0x0f700f00, "fldd%c\t%1z, %A"}, {FPU_VFP_EXT_V1xD, 0x0c900b00, 0x0fd00f00, "fldmia%0?xd%c\t%16-19r%21'!, %3z"}, {FPU_VFP_EXT_V1xD, 0x0d300b00, 0x0ff00f00, "fldmdb%0?xd%c\t%16-19r!, %3z"}, {FPU_VFP_EXT_V1xD, 0x0d100a00, 0x0f300f00, "flds%c\t%1y, %A"}, {FPU_VFP_EXT_V1xD, 0x0c900a00, 0x0f900f00, "fldmias%c\t%16-19r%21'!, %3y"}, {FPU_VFP_EXT_V1xD, 0x0d300a00, 0x0fb00f00, "fldmdbs%c\t%16-19r!, %3y"}, {FPU_VFP_EXT_V1, 0x0e000b00, 0x0ff00ff0, "fmacd%c\t%1z, %2z, %0z"}, {FPU_VFP_EXT_V1xD, 0x0e000a00, 0x0fb00f50, "fmacs%c\t%1y, %2y, %0y"}, {FPU_VFP_EXT_V1, 0x0e200b10, 0x0ff00fff, "fmdhr%c\t%2z, %12-15r"}, {FPU_VFP_EXT_V1, 0x0e000b10, 0x0ff00fff, "fmdlr%c\t%2z, %12-15r"}, {FPU_VFP_EXT_V2, 0x0c400b10, 0x0ff00ff0, "fmdrr%c\t%0z, %12-15r, %16-19r"}, {FPU_VFP_EXT_V1, 0x0e300b10, 0x0ff00fff, "fmrdh%c\t%12-15r, %2z"}, {FPU_VFP_EXT_V1, 0x0e100b10, 0x0ff00fff, "fmrdl%c\t%12-15r, %2z"}, {FPU_VFP_EXT_V1, 0x0c500b10, 0x0ff00ff0, "fmrrd%c\t%12-15r, %16-19r, %0z"}, {FPU_VFP_EXT_V2, 0x0c500a10, 0x0ff00fd0, "fmrrs%c\t%12-15r, %16-19r, %4y"}, {FPU_VFP_EXT_V1xD, 0x0e100a10, 0x0ff00f7f, "fmrs%c\t%12-15r, %2y"}, {FPU_VFP_EXT_V1xD, 0x0ef1fa10, 0x0fffffff, "fmstat%c"}, {FPU_VFP_EXT_V1xD, 0x0ef00a10, 0x0fff0fff, "fmrx%c\t%12-15r, fpsid"}, {FPU_VFP_EXT_V1xD, 0x0ef10a10, 0x0fff0fff, "fmrx%c\t%12-15r, fpscr"}, {FPU_VFP_EXT_V1xD, 0x0ef80a10, 0x0fff0fff, "fmrx%c\t%12-15r, fpexc"}, {FPU_VFP_EXT_V1xD, 0x0ef90a10, 0x0fff0fff, "fmrx%c\t%12-15r, fpinst\t@ Impl def"}, {FPU_VFP_EXT_V1xD, 0x0efa0a10, 0x0fff0fff, "fmrx%c\t%12-15r, fpinst2\t@ Impl def"}, {FPU_VFP_EXT_V1xD, 0x0ef00a10, 0x0ff00fff, "fmrx%c\t%12-15r, "}, {FPU_VFP_EXT_V1, 0x0e100b00, 0x0ff00ff0, "fmscd%c\t%1z, %2z, %0z"}, {FPU_VFP_EXT_V1xD, 0x0e100a00, 0x0fb00f50, "fmscs%c\t%1y, %2y, %0y"}, {FPU_VFP_EXT_V1xD, 0x0e000a10, 0x0ff00f7f, "fmsr%c\t%2y, %12-15r"}, {FPU_VFP_EXT_V2, 0x0c400a10, 0x0ff00fd0, "fmsrr%c\t%12-15r, %16-19r, %4y"}, {FPU_VFP_EXT_V1, 0x0e200b00, 0x0ff00ff0, "fmuld%c\t%1z, %2z, %0z"}, {FPU_VFP_EXT_V1xD, 0x0e200a00, 0x0fb00f50, "fmuls%c\t%1y, %2y, %0y"}, {FPU_VFP_EXT_V1xD, 0x0ee00a10, 0x0fff0fff, "fmxr%c\tfpsid, %12-15r"}, {FPU_VFP_EXT_V1xD, 0x0ee10a10, 0x0fff0fff, "fmxr%c\tfpscr, %12-15r"}, {FPU_VFP_EXT_V1xD, 0x0ee80a10, 0x0fff0fff, "fmxr%c\tfpexc, %12-15r"}, {FPU_VFP_EXT_V1xD, 0x0ee90a10, 0x0fff0fff, "fmxr%c\tfpinst, %12-15r\t@ Impl def"}, {FPU_VFP_EXT_V1xD, 0x0eea0a10, 0x0fff0fff, "fmxr%c\tfpinst2, %12-15r\t@ Impl def"}, {FPU_VFP_EXT_V1xD, 0x0ee00a10, 0x0ff00fff, "fmxr%c\t, %12-15r"}, {FPU_VFP_EXT_V1, 0x0eb10b40, 0x0fff0ff0, "fnegd%c\t%1z, %0z"}, {FPU_VFP_EXT_V1xD, 0x0eb10a40, 0x0fbf0fd0, "fnegs%c\t%1y, %0y"}, {FPU_VFP_EXT_V1, 0x0e000b40, 0x0ff00ff0, "fnmacd%c\t%1z, %2z, %0z"}, {FPU_VFP_EXT_V1xD, 0x0e000a40, 0x0fb00f50, "fnmacs%c\t%1y, %2y, %0y"}, {FPU_VFP_EXT_V1, 0x0e100b40, 0x0ff00ff0, "fnmscd%c\t%1z, %2z, %0z"}, {FPU_VFP_EXT_V1xD, 0x0e100a40, 0x0fb00f50, "fnmscs%c\t%1y, %2y, %0y"}, {FPU_VFP_EXT_V1, 0x0e200b40, 0x0ff00ff0, "fnmuld%c\t%1z, %2z, %0z"}, {FPU_VFP_EXT_V1xD, 0x0e200a40, 0x0fb00f50, "fnmuls%c\t%1y, %2y, %0y"}, {FPU_VFP_EXT_V1, 0x0eb80bc0, 0x0fff0fd0, "fsitod%c\t%1z, %0y"}, {FPU_VFP_EXT_V1xD, 0x0eb80ac0, 0x0fbf0fd0, "fsitos%c\t%1y, %0y"}, {FPU_VFP_EXT_V1, 0x0eb10bc0, 0x0fff0ff0, "fsqrtd%c\t%1z, %0z"}, {FPU_VFP_EXT_V1xD, 0x0eb10ac0, 0x0fbf0fd0, "fsqrts%c\t%1y, %0y"}, {FPU_VFP_EXT_V1, 0x0d000b00, 0x0f700f00, "fstd%c\t%1z, %A"}, {FPU_VFP_EXT_V1xD, 0x0c800b00, 0x0fd00f00, "fstmia%0?xd%c\t%16-19r%21'!, %3z"}, {FPU_VFP_EXT_V1xD, 0x0d200b00, 0x0ff00f00, "fstmdb%0?xd%c\t%16-19r!, %3z"}, {FPU_VFP_EXT_V1xD, 0x0d000a00, 0x0f300f00, "fsts%c\t%1y, %A"}, {FPU_VFP_EXT_V1xD, 0x0c800a00, 0x0f900f00, "fstmias%c\t%16-19r%21'!, %3y"}, {FPU_VFP_EXT_V1xD, 0x0d200a00, 0x0fb00f00, "fstmdbs%c\t%16-19r!, %3y"}, {FPU_VFP_EXT_V1, 0x0e300b40, 0x0ff00ff0, "fsubd%c\t%1z, %2z, %0z"}, {FPU_VFP_EXT_V1xD, 0x0e300a40, 0x0fb00f50, "fsubs%c\t%1y, %2y, %0y"}, {FPU_VFP_EXT_V1, 0x0ebc0b40, 0x0fbe0f70, "fto%16?sui%7'zd%c\t%1y, %0z"}, {FPU_VFP_EXT_V1xD, 0x0ebc0a40, 0x0fbe0f50, "fto%16?sui%7'zs%c\t%1y, %0y"}, {FPU_VFP_EXT_V1, 0x0eb80b40, 0x0fff0fd0, "fuitod%c\t%1z, %0y"}, {FPU_VFP_EXT_V1xD, 0x0eb80a40, 0x0fbf0fd0, "fuitos%c\t%1y, %0y"}, /* Cirrus coprocessor instructions. */ {ARM_CEXT_MAVERICK, 0x0d100400, 0x0f500f00, "cfldrs%c\tmvf%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0c100400, 0x0f500f00, "cfldrs%c\tmvf%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0d500400, 0x0f500f00, "cfldrd%c\tmvd%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0c500400, 0x0f500f00, "cfldrd%c\tmvd%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0d100500, 0x0f500f00, "cfldr32%c\tmvfx%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0c100500, 0x0f500f00, "cfldr32%c\tmvfx%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0d500500, 0x0f500f00, "cfldr64%c\tmvdx%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0c500500, 0x0f500f00, "cfldr64%c\tmvdx%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0d000400, 0x0f500f00, "cfstrs%c\tmvf%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0c000400, 0x0f500f00, "cfstrs%c\tmvf%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0d400400, 0x0f500f00, "cfstrd%c\tmvd%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0c400400, 0x0f500f00, "cfstrd%c\tmvd%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0d000500, 0x0f500f00, "cfstr32%c\tmvfx%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0c000500, 0x0f500f00, "cfstr32%c\tmvfx%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0d400500, 0x0f500f00, "cfstr64%c\tmvdx%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0c400500, 0x0f500f00, "cfstr64%c\tmvdx%12-15d, %A"}, {ARM_CEXT_MAVERICK, 0x0e000450, 0x0ff00ff0, "cfmvsr%c\tmvf%16-19d, %12-15r"}, {ARM_CEXT_MAVERICK, 0x0e100450, 0x0ff00ff0, "cfmvrs%c\t%12-15r, mvf%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e000410, 0x0ff00ff0, "cfmvdlr%c\tmvd%16-19d, %12-15r"}, {ARM_CEXT_MAVERICK, 0x0e100410, 0x0ff00ff0, "cfmvrdl%c\t%12-15r, mvd%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e000430, 0x0ff00ff0, "cfmvdhr%c\tmvd%16-19d, %12-15r"}, {ARM_CEXT_MAVERICK, 0x0e100430, 0x0ff00fff, "cfmvrdh%c\t%12-15r, mvd%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e000510, 0x0ff00fff, "cfmv64lr%c\tmvdx%16-19d, %12-15r"}, {ARM_CEXT_MAVERICK, 0x0e100510, 0x0ff00fff, "cfmvr64l%c\t%12-15r, mvdx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e000530, 0x0ff00fff, "cfmv64hr%c\tmvdx%16-19d, %12-15r"}, {ARM_CEXT_MAVERICK, 0x0e100530, 0x0ff00fff, "cfmvr64h%c\t%12-15r, mvdx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e200440, 0x0ff00fff, "cfmval32%c\tmvax%12-15d, mvfx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e100440, 0x0ff00fff, "cfmv32al%c\tmvfx%12-15d, mvax%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e200460, 0x0ff00fff, "cfmvam32%c\tmvax%12-15d, mvfx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e100460, 0x0ff00fff, "cfmv32am%c\tmvfx%12-15d, mvax%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e200480, 0x0ff00fff, "cfmvah32%c\tmvax%12-15d, mvfx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e100480, 0x0ff00fff, "cfmv32ah%c\tmvfx%12-15d, mvax%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e2004a0, 0x0ff00fff, "cfmva32%c\tmvax%12-15d, mvfx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e1004a0, 0x0ff00fff, "cfmv32a%c\tmvfx%12-15d, mvax%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e2004c0, 0x0ff00fff, "cfmva64%c\tmvax%12-15d, mvdx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e1004c0, 0x0ff00fff, "cfmv64a%c\tmvdx%12-15d, mvax%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e2004e0, 0x0fff0fff, "cfmvsc32%c\tdspsc, mvdx%12-15d"}, {ARM_CEXT_MAVERICK, 0x0e1004e0, 0x0fff0fff, "cfmv32sc%c\tmvdx%12-15d, dspsc"}, {ARM_CEXT_MAVERICK, 0x0e000400, 0x0ff00fff, "cfcpys%c\tmvf%12-15d, mvf%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e000420, 0x0ff00fff, "cfcpyd%c\tmvd%12-15d, mvd%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e000460, 0x0ff00fff, "cfcvtsd%c\tmvd%12-15d, mvf%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e000440, 0x0ff00fff, "cfcvtds%c\tmvf%12-15d, mvd%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e000480, 0x0ff00fff, "cfcvt32s%c\tmvf%12-15d, mvfx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e0004a0, 0x0ff00fff, "cfcvt32d%c\tmvd%12-15d, mvfx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e0004c0, 0x0ff00fff, "cfcvt64s%c\tmvf%12-15d, mvdx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e0004e0, 0x0ff00fff, "cfcvt64d%c\tmvd%12-15d, mvdx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e100580, 0x0ff00fff, "cfcvts32%c\tmvfx%12-15d, mvf%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e1005a0, 0x0ff00fff, "cfcvtd32%c\tmvfx%12-15d, mvd%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e1005c0, 0x0ff00fff, "cftruncs32%c\tmvfx%12-15d, mvf%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e1005e0, 0x0ff00fff, "cftruncd32%c\tmvfx%12-15d, mvd%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e000550, 0x0ff00ff0, "cfrshl32%c\tmvfx%16-19d, mvfx%0-3d, %12-15r"}, {ARM_CEXT_MAVERICK, 0x0e000570, 0x0ff00ff0, "cfrshl64%c\tmvdx%16-19d, mvdx%0-3d, %12-15r"}, {ARM_CEXT_MAVERICK, 0x0e000500, 0x0ff00f10, "cfsh32%c\tmvfx%12-15d, mvfx%16-19d, #%I"}, {ARM_CEXT_MAVERICK, 0x0e200500, 0x0ff00f10, "cfsh64%c\tmvdx%12-15d, mvdx%16-19d, #%I"}, {ARM_CEXT_MAVERICK, 0x0e100490, 0x0ff00ff0, "cfcmps%c\t%12-15r, mvf%16-19d, mvf%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e1004b0, 0x0ff00ff0, "cfcmpd%c\t%12-15r, mvd%16-19d, mvd%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e100590, 0x0ff00ff0, "cfcmp32%c\t%12-15r, mvfx%16-19d, mvfx%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e1005b0, 0x0ff00ff0, "cfcmp64%c\t%12-15r, mvdx%16-19d, mvdx%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e300400, 0x0ff00fff, "cfabss%c\tmvf%12-15d, mvf%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e300420, 0x0ff00fff, "cfabsd%c\tmvd%12-15d, mvd%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e300440, 0x0ff00fff, "cfnegs%c\tmvf%12-15d, mvf%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e300460, 0x0ff00fff, "cfnegd%c\tmvd%12-15d, mvd%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e300480, 0x0ff00ff0, "cfadds%c\tmvf%12-15d, mvf%16-19d, mvf%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e3004a0, 0x0ff00ff0, "cfaddd%c\tmvd%12-15d, mvd%16-19d, mvd%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e3004c0, 0x0ff00ff0, "cfsubs%c\tmvf%12-15d, mvf%16-19d, mvf%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e3004e0, 0x0ff00ff0, "cfsubd%c\tmvd%12-15d, mvd%16-19d, mvd%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e100400, 0x0ff00ff0, "cfmuls%c\tmvf%12-15d, mvf%16-19d, mvf%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e100420, 0x0ff00ff0, "cfmuld%c\tmvd%12-15d, mvd%16-19d, mvd%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e300500, 0x0ff00fff, "cfabs32%c\tmvfx%12-15d, mvfx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e300520, 0x0ff00fff, "cfabs64%c\tmvdx%12-15d, mvdx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e300540, 0x0ff00fff, "cfneg32%c\tmvfx%12-15d, mvfx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e300560, 0x0ff00fff, "cfneg64%c\tmvdx%12-15d, mvdx%16-19d"}, {ARM_CEXT_MAVERICK, 0x0e300580, 0x0ff00ff0, "cfadd32%c\tmvfx%12-15d, mvfx%16-19d, mvfx%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e3005a0, 0x0ff00ff0, "cfadd64%c\tmvdx%12-15d, mvdx%16-19d, mvdx%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e3005c0, 0x0ff00ff0, "cfsub32%c\tmvfx%12-15d, mvfx%16-19d, mvfx%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e3005e0, 0x0ff00ff0, "cfsub64%c\tmvdx%12-15d, mvdx%16-19d, mvdx%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e100500, 0x0ff00ff0, "cfmul32%c\tmvfx%12-15d, mvfx%16-19d, mvfx%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e100520, 0x0ff00ff0, "cfmul64%c\tmvdx%12-15d, mvdx%16-19d, mvdx%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e100540, 0x0ff00ff0, "cfmac32%c\tmvfx%12-15d, mvfx%16-19d, mvfx%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e100560, 0x0ff00ff0, "cfmsc32%c\tmvfx%12-15d, mvfx%16-19d, mvfx%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e000600, 0x0ff00f10, "cfmadd32%c\tmvax%5-7d, mvfx%12-15d, mvfx%16-19d, mvfx%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e100600, 0x0ff00f10, "cfmsub32%c\tmvax%5-7d, mvfx%12-15d, mvfx%16-19d, mvfx%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e200600, 0x0ff00f10, "cfmadda32%c\tmvax%5-7d, mvax%12-15d, mvfx%16-19d, mvfx%0-3d"}, {ARM_CEXT_MAVERICK, 0x0e300600, 0x0ff00f10, "cfmsuba32%c\tmvax%5-7d, mvax%12-15d, mvfx%16-19d, mvfx%0-3d"}, /* Generic coprocessor instructions */ {ARM_EXT_V2, 0x0c400000, 0x0ff00000, "mcrr%c\t%8-11d, %4-7d, %12-15r, %16-19r, cr%0-3d"}, {ARM_EXT_V2, 0x0c500000, 0x0ff00000, "mrrc%c\t%8-11d, %4-7d, %12-15r, %16-19r, cr%0-3d"}, {ARM_EXT_V2, 0x0e000000, 0x0f000010, "cdp%c\t%8-11d, %20-23d, cr%12-15d, cr%16-19d, cr%0-3d, {%5-7d}"}, {ARM_EXT_V2, 0x0e100010, 0x0f100010, "mrc%c\t%8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}"}, {ARM_EXT_V2, 0x0e000010, 0x0f100010, "mcr%c\t%8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}"}, {ARM_EXT_V2, 0x0c000000, 0x0e100000, "stc%c%22'l\t%8-11d, cr%12-15d, %A"}, {ARM_EXT_V2, 0x0c100000, 0x0e100000, "ldc%c%22'l\t%8-11d, cr%12-15d, %A"}, /* V6 coprocessor instructions */ {ARM_EXT_V6, 0xfc500000, 0xfff00000, "mrrc2\t%8-11d, %4-7d, %12-15r, %16-19r, cr%0-3d"}, {ARM_EXT_V6, 0xfc400000, 0xfff00000, "mcrr2\t%8-11d, %4-7d, %12-15r, %16-19r, cr%0-3d"}, /* V5 coprocessor instructions */ {ARM_EXT_V5, 0xfc100000, 0xfe100000, "ldc2%22'l\t%8-11d, cr%12-15d, %A"}, {ARM_EXT_V5, 0xfc000000, 0xfe100000, "stc2%22'l\t%8-11d, cr%12-15d, %A"}, {ARM_EXT_V5, 0xfe000000, 0xff000010, "cdp2\t%8-11d, %20-23d, cr%12-15d, cr%16-19d, cr%0-3d, {%5-7d}"}, {ARM_EXT_V5, 0xfe000010, 0xff100010, "mcr2\t%8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}"}, {ARM_EXT_V5, 0xfe100010, 0xff100010, "mrc2\t%8-11d, %21-23d, %12-15r, cr%16-19d, cr%0-3d, {%5-7d}"}, {0, 0, 0, 0} }; /* Opcode tables: ARM, 16-bit Thumb, 32-bit Thumb. All three are partially ordered: they must be searched linearly from the top to obtain a correct match. */ /* print_insn_arm recognizes the following format control codes: %% % %a print address for ldr/str instruction %s print address for ldr/str halfword/signextend instruction %b print branch destination %c print condition code (always bits 28-31) %m print register mask for ldm/stm instruction %o print operand2 (immediate or register + shift) %p print 'p' iff bits 12-15 are 15 %t print 't' iff bit 21 set and bit 24 clear %B print arm BLX(1) destination %C print the PSR sub type. %U print barrier type. %P print address for pli instruction. %r print as an ARM register %d print the bitfield in decimal %W print the bitfield plus one in decimal %x print the bitfield in hex %X print the bitfield as 1 hex digit without leading "0x" %'c print specified char iff bit is one %`c print specified char iff bit is zero %?ab print a if bit is one else print b %e print arm SMI operand (bits 0..7,8..19). %E print the LSB and WIDTH fields of a BFI or BFC instruction. %V print the 16-bit immediate field of a MOVT or MOVW instruction. */ static const struct opcode32 arm_opcodes[] = { /* ARM instructions. */ {ARM_EXT_V1, 0xe1a00000, 0xffffffff, "nop\t\t\t(mov r0,r0)"}, {ARM_EXT_V4T | ARM_EXT_V5, 0x012FFF10, 0x0ffffff0, "bx%c\t%0-3r"}, {ARM_EXT_V2, 0x00000090, 0x0fe000f0, "mul%c%20's\t%16-19r, %0-3r, %8-11r"}, {ARM_EXT_V2, 0x00200090, 0x0fe000f0, "mla%c%20's\t%16-19r, %0-3r, %8-11r, %12-15r"}, {ARM_EXT_V2S, 0x01000090, 0x0fb00ff0, "swp%c%22'b\t%12-15r, %0-3r, [%16-19r]"}, {ARM_EXT_V3M, 0x00800090, 0x0fa000f0, "%22?sumull%c%20's\t%12-15r, %16-19r, %0-3r, %8-11r"}, {ARM_EXT_V3M, 0x00a00090, 0x0fa000f0, "%22?sumlal%c%20's\t%12-15r, %16-19r, %0-3r, %8-11r"}, /* V7 instructions. */ {ARM_EXT_V7, 0xf450f000, 0xfd70f000, "pli\t%P"}, {ARM_EXT_V7, 0x0320f0f0, 0x0ffffff0, "dbg%c\t#%0-3d"}, {ARM_EXT_V7, 0xf57ff050, 0xfffffff0, "dmb\t%U"}, {ARM_EXT_V7, 0xf57ff040, 0xfffffff0, "dsb\t%U"}, {ARM_EXT_V7, 0xf57ff060, 0xfffffff0, "isb\t%U"}, /* ARM V6T2 instructions. */ {ARM_EXT_V6T2, 0x07c0001f, 0x0fe0007f, "bfc%c\t%12-15r, %E"}, {ARM_EXT_V6T2, 0x07c00010, 0x0fe00070, "bfi%c\t%12-15r, %0-3r, %E"}, {ARM_EXT_V6T2, 0x00600090, 0x0ff000f0, "mls%c\t%16-19r, %0-3r, %8-11r, %12-15r"}, {ARM_EXT_V6T2, 0x006000b0, 0x0f7000f0, "str%cht\t%12-15r, %s"}, {ARM_EXT_V6T2, 0x00300090, 0x0f300090, "ldr%c%6's%5?hbt\t%12-15r, %s"}, {ARM_EXT_V6T2, 0x03000000, 0x0ff00000, "movw%c\t%12-15r, %V"}, {ARM_EXT_V6T2, 0x03400000, 0x0ff00000, "movt%c\t%12-15r, %V"}, {ARM_EXT_V6T2, 0x03ff0f30, 0x0fff0ff0, "rbit%c\t%12-15r, %0-3r"}, {ARM_EXT_V6T2, 0x07a00050, 0x0fa00070, "%22?usbfx%c\t%12-15r, %0-3r, #%7-11d, #%16-20W"}, /* ARM V6Z instructions. */ {ARM_EXT_V6Z, 0x01600070, 0x0ff000f0, "smc%c\t%e"}, /* ARM V6K instructions. */ {ARM_EXT_V6K, 0xf57ff01f, 0xffffffff, "clrex"}, {ARM_EXT_V6K, 0x01d00f9f, 0x0ff00fff, "ldrexb%c\t%12-15r, [%16-19r]"}, {ARM_EXT_V6K, 0x01b00f9f, 0x0ff00fff, "ldrexd%c\t%12-15r, [%16-19r]"}, {ARM_EXT_V6K, 0x01f00f9f, 0x0ff00fff, "ldrexh%c\t%12-15r, [%16-19r]"}, {ARM_EXT_V6K, 0x01c00f90, 0x0ff00ff0, "strexb%c\t%12-15r, %0-3r, [%16-19r]"}, {ARM_EXT_V6K, 0x01a00f90, 0x0ff00ff0, "strexd%c\t%12-15r, %0-3r, [%16-19r]"}, {ARM_EXT_V6K, 0x01e00f90, 0x0ff00ff0, "strexh%c\t%12-15r, %0-3r, [%16-19r]"}, /* ARM V6K NOP hints. */ {ARM_EXT_V6K, 0x0320f001, 0x0fffffff, "yield%c"}, {ARM_EXT_V6K, 0x0320f002, 0x0fffffff, "wfe%c"}, {ARM_EXT_V6K, 0x0320f003, 0x0fffffff, "wfi%c"}, {ARM_EXT_V6K, 0x0320f004, 0x0fffffff, "sev%c"}, {ARM_EXT_V6K, 0x0320f000, 0x0fffff00, "nop%c\t{%0-7d}"}, /* ARM V6 instructions. */ {ARM_EXT_V6, 0xf1080000, 0xfffdfe3f, "cpsie\t%8'a%7'i%6'f"}, {ARM_EXT_V6, 0xf1080000, 0xfffdfe20, "cpsie\t%8'a%7'i%6'f,#%0-4d"}, {ARM_EXT_V6, 0xf10C0000, 0xfffdfe3f, "cpsid\t%8'a%7'i%6'f"}, {ARM_EXT_V6, 0xf10C0000, 0xfffdfe20, "cpsid\t%8'a%7'i%6'f,#%0-4d"}, {ARM_EXT_V6, 0xf1000000, 0xfff1fe20, "cps\t#%0-4d"}, {ARM_EXT_V6, 0x06800010, 0x0ff00ff0, "pkhbt%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06800010, 0x0ff00070, "pkhbt%c\t%12-15r, %16-19r, %0-3r, LSL #%7-11d"}, {ARM_EXT_V6, 0x06800050, 0x0ff00ff0, "pkhtb%c\t%12-15r, %16-19r, %0-3r, ASR #32"}, {ARM_EXT_V6, 0x06800050, 0x0ff00070, "pkhtb%c\t%12-15r, %16-19r, %0-3r, ASR #%7-11d"}, {ARM_EXT_V6, 0x01900f9f, 0x0ff00fff, "ldrex%c\tr%12-15d, [%16-19r]"}, {ARM_EXT_V6, 0x06200f10, 0x0ff00ff0, "qadd16%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06200f90, 0x0ff00ff0, "qadd8%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06200f30, 0x0ff00ff0, "qaddsubx%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06200f70, 0x0ff00ff0, "qsub16%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06200ff0, 0x0ff00ff0, "qsub8%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06200f50, 0x0ff00ff0, "qsubaddx%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06100f10, 0x0ff00ff0, "sadd16%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06100f90, 0x0ff00ff0, "sadd8%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06100f30, 0x0ff00ff0, "saddaddx%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06300f10, 0x0ff00ff0, "shadd16%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06300f90, 0x0ff00ff0, "shadd8%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06300f30, 0x0ff00ff0, "shaddsubx%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06300f70, 0x0ff00ff0, "shsub16%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06300ff0, 0x0ff00ff0, "shsub8%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06300f50, 0x0ff00ff0, "shsubaddx%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06100f70, 0x0ff00ff0, "ssub16%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06100ff0, 0x0ff00ff0, "ssub8%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06100f50, 0x0ff00ff0, "ssubaddx%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06500f10, 0x0ff00ff0, "uadd16%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06500f90, 0x0ff00ff0, "uadd8%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06500f30, 0x0ff00ff0, "uaddsubx%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06700f10, 0x0ff00ff0, "uhadd16%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06700f90, 0x0ff00ff0, "uhadd8%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06700f30, 0x0ff00ff0, "uhaddsubx%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06700f70, 0x0ff00ff0, "uhsub16%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06700ff0, 0x0ff00ff0, "uhsub8%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06700f50, 0x0ff00ff0, "uhsubaddx%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06600f10, 0x0ff00ff0, "uqadd16%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06600f90, 0x0ff00ff0, "uqadd8%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06600f30, 0x0ff00ff0, "uqaddsubx%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06600f70, 0x0ff00ff0, "uqsub16%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06600ff0, 0x0ff00ff0, "uqsub8%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06600f50, 0x0ff00ff0, "uqsubaddx%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06500f70, 0x0ff00ff0, "usub16%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06500ff0, 0x0ff00ff0, "usub8%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06500f50, 0x0ff00ff0, "usubaddx%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06bf0f30, 0x0fff0ff0, "rev%c\t\%12-15r, %0-3r"}, {ARM_EXT_V6, 0x06bf0fb0, 0x0fff0ff0, "rev16%c\t\%12-15r, %0-3r"}, {ARM_EXT_V6, 0x06ff0fb0, 0x0fff0ff0, "revsh%c\t\%12-15r, %0-3r"}, {ARM_EXT_V6, 0xf8100a00, 0xfe50ffff, "rfe%23?id%24?ba\t\%16-19r%21'!"}, {ARM_EXT_V6, 0x06bf0070, 0x0fff0ff0, "sxth%c\t%12-15r, %0-3r"}, {ARM_EXT_V6, 0x06bf0470, 0x0fff0ff0, "sxth%c\t%12-15r, %0-3r, ROR #8"}, {ARM_EXT_V6, 0x06bf0870, 0x0fff0ff0, "sxth%c\t%12-15r, %0-3r, ROR #16"}, {ARM_EXT_V6, 0x06bf0c70, 0x0fff0ff0, "sxth%c\t%12-15r, %0-3r, ROR #24"}, {ARM_EXT_V6, 0x068f0070, 0x0fff0ff0, "sxtb16%c\t%12-15r, %0-3r"}, {ARM_EXT_V6, 0x068f0470, 0x0fff0ff0, "sxtb16%c\t%12-15r, %0-3r, ROR #8"}, {ARM_EXT_V6, 0x068f0870, 0x0fff0ff0, "sxtb16%c\t%12-15r, %0-3r, ROR #16"}, {ARM_EXT_V6, 0x068f0c70, 0x0fff0ff0, "sxtb16%c\t%12-15r, %0-3r, ROR #24"}, {ARM_EXT_V6, 0x06af0070, 0x0fff0ff0, "sxtb%c\t%12-15r, %0-3r"}, {ARM_EXT_V6, 0x06af0470, 0x0fff0ff0, "sxtb%c\t%12-15r, %0-3r, ROR #8"}, {ARM_EXT_V6, 0x06af0870, 0x0fff0ff0, "sxtb%c\t%12-15r, %0-3r, ROR #16"}, {ARM_EXT_V6, 0x06af0c70, 0x0fff0ff0, "sxtb%c\t%12-15r, %0-3r, ROR #24"}, {ARM_EXT_V6, 0x06ff0070, 0x0fff0ff0, "uxth%c\t%12-15r, %0-3r"}, {ARM_EXT_V6, 0x06ff0470, 0x0fff0ff0, "uxth%c\t%12-15r, %0-3r, ROR #8"}, {ARM_EXT_V6, 0x06ff0870, 0x0fff0ff0, "uxth%c\t%12-15r, %0-3r, ROR #16"}, {ARM_EXT_V6, 0x06ff0c70, 0x0fff0ff0, "uxth%c\t%12-15r, %0-3r, ROR #24"}, {ARM_EXT_V6, 0x06cf0070, 0x0fff0ff0, "uxtb16%c\t%12-15r, %0-3r"}, {ARM_EXT_V6, 0x06cf0470, 0x0fff0ff0, "uxtb16%c\t%12-15r, %0-3r, ROR #8"}, {ARM_EXT_V6, 0x06cf0870, 0x0fff0ff0, "uxtb16%c\t%12-15r, %0-3r, ROR #16"}, {ARM_EXT_V6, 0x06cf0c70, 0x0fff0ff0, "uxtb16%c\t%12-15r, %0-3r, ROR #24"}, {ARM_EXT_V6, 0x06ef0070, 0x0fff0ff0, "uxtb%c\t%12-15r, %0-3r"}, {ARM_EXT_V6, 0x06ef0470, 0x0fff0ff0, "uxtb%c\t%12-15r, %0-3r, ROR #8"}, {ARM_EXT_V6, 0x06ef0870, 0x0fff0ff0, "uxtb%c\t%12-15r, %0-3r, ROR #16"}, {ARM_EXT_V6, 0x06ef0c70, 0x0fff0ff0, "uxtb%c\t%12-15r, %0-3r, ROR #24"}, {ARM_EXT_V6, 0x06b00070, 0x0ff00ff0, "sxtah%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06b00470, 0x0ff00ff0, "sxtah%c\t%12-15r, %16-19r, %0-3r, ROR #8"}, {ARM_EXT_V6, 0x06b00870, 0x0ff00ff0, "sxtah%c\t%12-15r, %16-19r, %0-3r, ROR #16"}, {ARM_EXT_V6, 0x06b00c70, 0x0ff00ff0, "sxtah%c\t%12-15r, %16-19r, %0-3r, ROR #24"}, {ARM_EXT_V6, 0x06800070, 0x0ff00ff0, "sxtab16%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06800470, 0x0ff00ff0, "sxtab16%c\t%12-15r, %16-19r, %0-3r, ROR #8"}, {ARM_EXT_V6, 0x06800870, 0x0ff00ff0, "sxtab16%c\t%12-15r, %16-19r, %0-3r, ROR #16"}, {ARM_EXT_V6, 0x06800c70, 0x0ff00ff0, "sxtab16%c\t%12-15r, %16-19r, %0-3r, ROR #24"}, {ARM_EXT_V6, 0x06a00070, 0x0ff00ff0, "sxtab%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06a00470, 0x0ff00ff0, "sxtab%c\t%12-15r, %16-19r, %0-3r, ROR #8"}, {ARM_EXT_V6, 0x06a00870, 0x0ff00ff0, "sxtab%c\t%12-15r, %16-19r, %0-3r, ROR #16"}, {ARM_EXT_V6, 0x06a00c70, 0x0ff00ff0, "sxtab%c\t%12-15r, %16-19r, %0-3r, ROR #24"}, {ARM_EXT_V6, 0x06f00070, 0x0ff00ff0, "uxtah%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06f00470, 0x0ff00ff0, "uxtah%c\t%12-15r, %16-19r, %0-3r, ROR #8"}, {ARM_EXT_V6, 0x06f00870, 0x0ff00ff0, "uxtah%c\t%12-15r, %16-19r, %0-3r, ROR #16"}, {ARM_EXT_V6, 0x06f00c70, 0x0ff00ff0, "uxtah%c\t%12-15r, %16-19r, %0-3r, ROR #24"}, {ARM_EXT_V6, 0x06c00070, 0x0ff00ff0, "uxtab16%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06c00470, 0x0ff00ff0, "uxtab16%c\t%12-15r, %16-19r, %0-3r, ROR #8"}, {ARM_EXT_V6, 0x06c00870, 0x0ff00ff0, "uxtab16%c\t%12-15r, %16-19r, %0-3r, ROR #16"}, {ARM_EXT_V6, 0x06c00c70, 0x0ff00ff0, "uxtab16%c\t%12-15r, %16-19r, %0-3r, ROR #24"}, {ARM_EXT_V6, 0x06e00070, 0x0ff00ff0, "uxtab%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0x06e00470, 0x0ff00ff0, "uxtab%c\t%12-15r, %16-19r, %0-3r, ROR #8"}, {ARM_EXT_V6, 0x06e00870, 0x0ff00ff0, "uxtab%c\t%12-15r, %16-19r, %0-3r, ROR #16"}, {ARM_EXT_V6, 0x06e00c70, 0x0ff00ff0, "uxtab%c\t%12-15r, %16-19r, %0-3r, ROR #24"}, {ARM_EXT_V6, 0x06800fb0, 0x0ff00ff0, "sel%c\t%12-15r, %16-19r, %0-3r"}, {ARM_EXT_V6, 0xf1010000, 0xfffffc00, "setend\t%9?ble"}, {ARM_EXT_V6, 0x0700f010, 0x0ff0f0d0, "smuad%5'x%c\t%16-19r, %0-3r, %8-11r"}, {ARM_EXT_V6, 0x0700f050, 0x0ff0f0d0, "smusd%5'x%c\t%16-19r, %0-3r, %8-11r"}, {ARM_EXT_V6, 0x07000010, 0x0ff000d0, "smlad%5'x%c\t%16-19r, %0-3r, %8-11r, %12-15r"}, {ARM_EXT_V6, 0x07400010, 0x0ff000d0, "smlald%5'x%c\t%12-15r, %16-19r, %0-3r, %8-11r"}, {ARM_EXT_V6, 0x07000050, 0x0ff000d0, "smlsd%5'x%c\t%16-19r, %0-3r, %8-11r, %12-15r"}, {ARM_EXT_V6, 0x07400050, 0x0ff000d0, "smlsld%5'x%c\t%12-15r, %16-19r, %0-3r, %8-11r"}, {ARM_EXT_V6, 0x0750f010, 0x0ff0f0d0, "smmul%5'r%c\t%16-19r, %0-3r, %8-11r"}, {ARM_EXT_V6, 0x07500010, 0x0ff000d0, "smmla%5'r%c\t%16-19r, %0-3r, %8-11r, %12-15r"}, {ARM_EXT_V6, 0x075000d0, 0x0ff000d0, "smmls%5'r%c\t%16-19r, %0-3r, %8-11r, %12-15r"}, {ARM_EXT_V6, 0xf84d0500, 0xfe5fffe0, "srs%23?id%24?ba\t#%0-4d%21'!"}, {ARM_EXT_V6, 0x06a00010, 0x0fe00ff0, "ssat%c\t%12-15r, #%16-20W, %0-3r"}, {ARM_EXT_V6, 0x06a00010, 0x0fe00070, "ssat%c\t%12-15r, #%16-20W, %0-3r, LSL #%7-11d"}, {ARM_EXT_V6, 0x06a00050, 0x0fe00070, "ssat%c\t%12-15r, #%16-20W, %0-3r, ASR #%7-11d"}, {ARM_EXT_V6, 0x06a00f30, 0x0ff00ff0, "ssat16%c\t%12-15r, #%16-19W, %0-3r"}, {ARM_EXT_V6, 0x01800f90, 0x0ff00ff0, "strex%c\t%12-15r, %0-3r, [%16-19r]"}, {ARM_EXT_V6, 0x00400090, 0x0ff000f0, "umaal%c\t%12-15r, %16-19r, %0-3r, %8-11r"}, {ARM_EXT_V6, 0x0780f010, 0x0ff0f0f0, "usad8%c\t%16-19r, %0-3r, %8-11r"}, {ARM_EXT_V6, 0x07800010, 0x0ff000f0, "usada8%c\t%16-19r, %0-3r, %8-11r, %12-15r"}, {ARM_EXT_V6, 0x06e00010, 0x0fe00ff0, "usat%c\t%12-15r, #%16-20d, %0-3r"}, {ARM_EXT_V6, 0x06e00010, 0x0fe00070, "usat%c\t%12-15r, #%16-20d, %0-3r, LSL #%7-11d"}, {ARM_EXT_V6, 0x06e00050, 0x0fe00070, "usat%c\t%12-15r, #%16-20d, %0-3r, ASR #%7-11d"}, {ARM_EXT_V6, 0x06e00f30, 0x0ff00ff0, "usat16%c\t%12-15r, #%16-19d, %0-3r"}, /* V5J instruction. */ {ARM_EXT_V5J, 0x012fff20, 0x0ffffff0, "bxj%c\t%0-3r"}, /* V5 Instructions. */ {ARM_EXT_V5, 0xe1200070, 0xfff000f0, "bkpt\t0x%16-19X%12-15X%8-11X%0-3X"}, {ARM_EXT_V5, 0xfa000000, 0xfe000000, "blx\t%B"}, {ARM_EXT_V5, 0x012fff30, 0x0ffffff0, "blx%c\t%0-3r"}, {ARM_EXT_V5, 0x016f0f10, 0x0fff0ff0, "clz%c\t%12-15r, %0-3r"}, /* V5E "El Segundo" Instructions. */ {ARM_EXT_V5E, 0x000000d0, 0x0e1000f0, "ldr%cd\t%12-15r, %s"}, {ARM_EXT_V5E, 0x000000f0, 0x0e1000f0, "str%cd\t%12-15r, %s"}, {ARM_EXT_V5E, 0xf450f000, 0xfc70f000, "pld\t%a"}, {ARM_EXT_V5ExP, 0x01000080, 0x0ff000f0, "smlabb%c\t%16-19r, %0-3r, %8-11r, %12-15r"}, {ARM_EXT_V5ExP, 0x010000a0, 0x0ff000f0, "smlatb%c\t%16-19r, %0-3r, %8-11r, %12-15r"}, {ARM_EXT_V5ExP, 0x010000c0, 0x0ff000f0, "smlabt%c\t%16-19r, %0-3r, %8-11r, %12-15r"}, {ARM_EXT_V5ExP, 0x010000e0, 0x0ff000f0, "smlatt%c\t%16-19r, %0-3r, %8-11r, %12-15r"}, {ARM_EXT_V5ExP, 0x01200080, 0x0ff000f0, "smlawb%c\t%16-19r, %0-3r, %8-11r, %12-15r"}, {ARM_EXT_V5ExP, 0x012000c0, 0x0ff000f0, "smlawt%c\t%16-19r, %0-3r, %8-11r, %12-15r"}, {ARM_EXT_V5ExP, 0x01400080, 0x0ff000f0, "smlalbb%c\t%12-15r, %16-19r, %0-3r, %8-11r"}, {ARM_EXT_V5ExP, 0x014000a0, 0x0ff000f0, "smlaltb%c\t%12-15r, %16-19r, %0-3r, %8-11r"}, {ARM_EXT_V5ExP, 0x014000c0, 0x0ff000f0, "smlalbt%c\t%12-15r, %16-19r, %0-3r, %8-11r"}, {ARM_EXT_V5ExP, 0x014000e0, 0x0ff000f0, "smlaltt%c\t%12-15r, %16-19r, %0-3r, %8-11r"}, {ARM_EXT_V5ExP, 0x01600080, 0x0ff0f0f0, "smulbb%c\t%16-19r, %0-3r, %8-11r"}, {ARM_EXT_V5ExP, 0x016000a0, 0x0ff0f0f0, "smultb%c\t%16-19r, %0-3r, %8-11r"}, {ARM_EXT_V5ExP, 0x016000c0, 0x0ff0f0f0, "smulbt%c\t%16-19r, %0-3r, %8-11r"}, {ARM_EXT_V5ExP, 0x016000e0, 0x0ff0f0f0, "smultt%c\t%16-19r, %0-3r, %8-11r"}, {ARM_EXT_V5ExP, 0x012000a0, 0x0ff0f0f0, "smulwb%c\t%16-19r, %0-3r, %8-11r"}, {ARM_EXT_V5ExP, 0x012000e0, 0x0ff0f0f0, "smulwt%c\t%16-19r, %0-3r, %8-11r"}, {ARM_EXT_V5ExP, 0x01000050, 0x0ff00ff0, "qadd%c\t%12-15r, %0-3r, %16-19r"}, {ARM_EXT_V5ExP, 0x01400050, 0x0ff00ff0, "qdadd%c\t%12-15r, %0-3r, %16-19r"}, {ARM_EXT_V5ExP, 0x01200050, 0x0ff00ff0, "qsub%c\t%12-15r, %0-3r, %16-19r"}, {ARM_EXT_V5ExP, 0x01600050, 0x0ff00ff0, "qdsub%c\t%12-15r, %0-3r, %16-19r"}, /* ARM Instructions. */ {ARM_EXT_V1, 0x00000090, 0x0e100090, "str%c%6's%5?hb\t%12-15r, %s"}, {ARM_EXT_V1, 0x00100090, 0x0e100090, "ldr%c%6's%5?hb\t%12-15r, %s"}, {ARM_EXT_V1, 0x00000000, 0x0de00000, "and%c%20's\t%12-15r, %16-19r, %o"}, {ARM_EXT_V1, 0x00200000, 0x0de00000, "eor%c%20's\t%12-15r, %16-19r, %o"}, {ARM_EXT_V1, 0x00400000, 0x0de00000, "sub%c%20's\t%12-15r, %16-19r, %o"}, {ARM_EXT_V1, 0x00600000, 0x0de00000, "rsb%c%20's\t%12-15r, %16-19r, %o"}, {ARM_EXT_V1, 0x00800000, 0x0de00000, "add%c%20's\t%12-15r, %16-19r, %o"}, {ARM_EXT_V1, 0x00a00000, 0x0de00000, "adc%c%20's\t%12-15r, %16-19r, %o"}, {ARM_EXT_V1, 0x00c00000, 0x0de00000, "sbc%c%20's\t%12-15r, %16-19r, %o"}, {ARM_EXT_V1, 0x00e00000, 0x0de00000, "rsc%c%20's\t%12-15r, %16-19r, %o"}, {ARM_EXT_V3, 0x0120f000, 0x0db0f000, "msr%c\t%22?SCPSR%C, %o"}, {ARM_EXT_V3, 0x010f0000, 0x0fbf0fff, "mrs%c\t%12-15r, %22?SCPSR"}, {ARM_EXT_V1, 0x01000000, 0x0de00000, "tst%c%p\t%16-19r, %o"}, {ARM_EXT_V1, 0x01200000, 0x0de00000, "teq%c%p\t%16-19r, %o"}, {ARM_EXT_V1, 0x01400000, 0x0de00000, "cmp%c%p\t%16-19r, %o"}, {ARM_EXT_V1, 0x01600000, 0x0de00000, "cmn%c%p\t%16-19r, %o"}, {ARM_EXT_V1, 0x01800000, 0x0de00000, "orr%c%20's\t%12-15r, %16-19r, %o"}, {ARM_EXT_V1, 0x01a00000, 0x0de00000, "mov%c%20's\t%12-15r, %o"}, {ARM_EXT_V1, 0x01c00000, 0x0de00000, "bic%c%20's\t%12-15r, %16-19r, %o"}, {ARM_EXT_V1, 0x01e00000, 0x0de00000, "mvn%c%20's\t%12-15r, %o"}, {ARM_EXT_V1, 0x04000000, 0x0e100000, "str%c%22'b%t\t%12-15r, %a"}, {ARM_EXT_V1, 0x06000000, 0x0e100ff0, "str%c%22'b%t\t%12-15r, %a"}, {ARM_EXT_V1, 0x04000000, 0x0c100010, "str%c%22'b%t\t%12-15r, %a"}, {ARM_EXT_V1, 0x06000010, 0x0e000010, "undefined"}, {ARM_EXT_V1, 0x04100000, 0x0c100000, "ldr%c%22'b%t\t%12-15r, %a"}, {ARM_EXT_V1, 0x08000000, 0x0e100000, "stm%c%23?id%24?ba\t%16-19r%21'!, %m%22'^"}, {ARM_EXT_V1, 0x08100000, 0x0e100000, "ldm%c%23?id%24?ba\t%16-19r%21'!, %m%22'^"}, {ARM_EXT_V1, 0x0a000000, 0x0e000000, "b%24'l%c\t%b"}, {ARM_EXT_V1, 0x0f000000, 0x0f000000, "svc%c\t%0-23x"}, /* The rest. */ {ARM_EXT_V1, 0x00000000, 0x00000000, "undefined instruction %0-31x"}, {0, 0x00000000, 0x00000000, 0} }; /* print_insn_thumb16 recognizes the following format control codes: %S print Thumb register (bits 3..5 as high number if bit 6 set) %D print Thumb register (bits 0..2 as high number if bit 7 set) %I print bitfield as a signed decimal (top bit of range being the sign bit) %N print Thumb register mask (with LR) %O print Thumb register mask (with PC) %M print Thumb register mask %b print CZB's 6-bit unsigned branch destination %s print Thumb right-shift immediate (6..10; 0 == 32). %r print bitfield as an ARM register %d print bitfield as a decimal %H print (bitfield * 2) as a decimal %W print (bitfield * 4) as a decimal %a print (bitfield * 4) as a pc-rel offset + decoded symbol %B print Thumb branch destination (signed displacement) %c print bitfield as a condition code %'c print specified char iff bit is one %?ab print a if bit is one else print b. */ static const struct opcode16 thumb_opcodes[] = { /* Thumb instructions. */ /* ARM V6K no-argument instructions. */ {ARM_EXT_V6K, 0xbf00, 0xffff, "nop"}, {ARM_EXT_V6K, 0xbf10, 0xffff, "yield"}, {ARM_EXT_V6K, 0xbf20, 0xffff, "wfe"}, {ARM_EXT_V6K, 0xbf30, 0xffff, "wfi"}, {ARM_EXT_V6K, 0xbf40, 0xffff, "sev"}, {ARM_EXT_V6K, 0xbf00, 0xff0f, "nop\t{%4-7d}"}, /* ARM V6T2 instructions. */ {ARM_EXT_V6T2, 0xb900, 0xfd00, "cbnz\t%0-2r, %b"}, {ARM_EXT_V6T2, 0xb100, 0xfd00, "cbz\t%0-2r, %b"}, {ARM_EXT_V6T2, 0xbf08, 0xff0f, "it\t%4-7c"}, {ARM_EXT_V6T2, 0xbf14, 0xff17, "it%3?te\t%4-7c"}, {ARM_EXT_V6T2, 0xbf04, 0xff17, "it%3?et\t%4-7c"}, {ARM_EXT_V6T2, 0xbf12, 0xff13, "it%3?te%2?te\t%4-7c"}, {ARM_EXT_V6T2, 0xbf02, 0xff13, "it%3?et%2?et\t%4-7c"}, {ARM_EXT_V6T2, 0xbf11, 0xff11, "it%3?te%2?te%1?te\t%4-7c"}, {ARM_EXT_V6T2, 0xbf01, 0xff11, "it%3?et%2?et%1?et\t%4-7c"}, /* ARM V6. */ {ARM_EXT_V6, 0xb660, 0xfff8, "cpsie\t%2'a%1'i%0'f"}, {ARM_EXT_V6, 0xb670, 0xfff8, "cpsid\t%2'a%1'i%0'f"}, {ARM_EXT_V6, 0x4600, 0xffc0, "mov\t%0-2r, %3-5r"}, {ARM_EXT_V6, 0xba00, 0xffc0, "rev\t%0-2r, %3-5r"}, {ARM_EXT_V6, 0xba40, 0xffc0, "rev16\t%0-2r, %3-5r"}, {ARM_EXT_V6, 0xbac0, 0xffc0, "revsh\t%0-2r, %3-5r"}, {ARM_EXT_V6, 0xb650, 0xfff7, "setend\t%3?ble"}, {ARM_EXT_V6, 0xb200, 0xffc0, "sxth\t%0-2r, %3-5r"}, {ARM_EXT_V6, 0xb240, 0xffc0, "sxtb\t%0-2r, %3-5r"}, {ARM_EXT_V6, 0xb280, 0xffc0, "uxth\t%0-2r, %3-5r"}, {ARM_EXT_V6, 0xb2c0, 0xffc0, "uxtb\t%0-2r, %3-5r"}, /* ARM V5 ISA extends Thumb. */ {ARM_EXT_V5T, 0xbe00, 0xff00, "bkpt\t%0-7x"}, /* This is BLX(2). BLX(1) is a 32-bit instruction. */ {ARM_EXT_V5T, 0x4780, 0xff87, "blx\t%3-6r"}, /* note: 4 bit register number. */ /* ARM V4T ISA (Thumb v1). */ {ARM_EXT_V4T, 0x46C0, 0xFFFF, "nop\t\t\t(mov r8, r8)"}, /* Format 4. */ {ARM_EXT_V4T, 0x4000, 0xFFC0, "ands\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x4040, 0xFFC0, "eors\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x4080, 0xFFC0, "lsls\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x40C0, 0xFFC0, "lsrs\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x4100, 0xFFC0, "asrs\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x4140, 0xFFC0, "adcs\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x4180, 0xFFC0, "sbcs\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x41C0, 0xFFC0, "rors\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x4200, 0xFFC0, "tst\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x4240, 0xFFC0, "negs\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x4280, 0xFFC0, "cmp\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x42C0, 0xFFC0, "cmn\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x4300, 0xFFC0, "orrs\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x4340, 0xFFC0, "muls\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x4380, 0xFFC0, "bics\t%0-2r, %3-5r"}, {ARM_EXT_V4T, 0x43C0, 0xFFC0, "mvns\t%0-2r, %3-5r"}, /* format 13 */ {ARM_EXT_V4T, 0xB000, 0xFF80, "add\tsp, #%0-6W"}, {ARM_EXT_V4T, 0xB080, 0xFF80, "sub\tsp, #%0-6W"}, /* format 5 */ {ARM_EXT_V4T, 0x4700, 0xFF80, "bx\t%S"}, {ARM_EXT_V4T, 0x4400, 0xFF00, "add\t%D, %S"}, {ARM_EXT_V4T, 0x4500, 0xFF00, "cmp\t%D, %S"}, {ARM_EXT_V4T, 0x4600, 0xFF00, "mov\t%D, %S"}, /* format 14 */ {ARM_EXT_V4T, 0xB400, 0xFE00, "push\t%N"}, {ARM_EXT_V4T, 0xBC00, 0xFE00, "pop\t%O"}, /* format 2 */ {ARM_EXT_V4T, 0x1800, 0xFE00, "adds\t%0-2r, %3-5r, %6-8r"}, {ARM_EXT_V4T, 0x1A00, 0xFE00, "subs\t%0-2r, %3-5r, %6-8r"}, {ARM_EXT_V4T, 0x1C00, 0xFE00, "adds\t%0-2r, %3-5r, #%6-8d"}, {ARM_EXT_V4T, 0x1E00, 0xFE00, "subs\t%0-2r, %3-5r, #%6-8d"}, /* format 8 */ {ARM_EXT_V4T, 0x5200, 0xFE00, "strh\t%0-2r, [%3-5r, %6-8r]"}, {ARM_EXT_V4T, 0x5A00, 0xFE00, "ldrh\t%0-2r, [%3-5r, %6-8r]"}, {ARM_EXT_V4T, 0x5600, 0xF600, "ldrs%11?hb\t%0-2r, [%3-5r, %6-8r]"}, /* format 7 */ {ARM_EXT_V4T, 0x5000, 0xFA00, "str%10'b\t%0-2r, [%3-5r, %6-8r]"}, {ARM_EXT_V4T, 0x5800, 0xFA00, "ldr%10'b\t%0-2r, [%3-5r, %6-8r]"}, /* format 1 */ {ARM_EXT_V4T, 0x0000, 0xF800, "lsls\t%0-2r, %3-5r, #%6-10d"}, {ARM_EXT_V4T, 0x0800, 0xF800, "lsrs\t%0-2r, %3-5r, %s"}, {ARM_EXT_V4T, 0x1000, 0xF800, "asrs\t%0-2r, %3-5r, %s"}, /* format 3 */ {ARM_EXT_V4T, 0x2000, 0xF800, "movs\t%8-10r, #%0-7d"}, {ARM_EXT_V4T, 0x2800, 0xF800, "cmp\t%8-10r, #%0-7d"}, {ARM_EXT_V4T, 0x3000, 0xF800, "adds\t%8-10r, #%0-7d"}, {ARM_EXT_V4T, 0x3800, 0xF800, "subs\t%8-10r, #%0-7d"}, /* format 6 */ {ARM_EXT_V4T, 0x4800, 0xF800, "ldr\t%8-10r, [pc, #%0-7W]\t(%0-7a)"}, /* TODO: Disassemble PC relative "LDR rD,=" */ /* format 9 */ {ARM_EXT_V4T, 0x6000, 0xF800, "str\t%0-2r, [%3-5r, #%6-10W]"}, {ARM_EXT_V4T, 0x6800, 0xF800, "ldr\t%0-2r, [%3-5r, #%6-10W]"}, {ARM_EXT_V4T, 0x7000, 0xF800, "strb\t%0-2r, [%3-5r, #%6-10d]"}, {ARM_EXT_V4T, 0x7800, 0xF800, "ldrb\t%0-2r, [%3-5r, #%6-10d]"}, /* format 10 */ {ARM_EXT_V4T, 0x8000, 0xF800, "strh\t%0-2r, [%3-5r, #%6-10H]"}, {ARM_EXT_V4T, 0x8800, 0xF800, "ldrh\t%0-2r, [%3-5r, #%6-10H]"}, /* format 11 */ {ARM_EXT_V4T, 0x9000, 0xF800, "str\t%8-10r, [sp, #%0-7W]"}, {ARM_EXT_V4T, 0x9800, 0xF800, "ldr\t%8-10r, [sp, #%0-7W]"}, /* format 12 */ {ARM_EXT_V4T, 0xA000, 0xF800, "add\t%8-10r, pc, #%0-7W\t(adr %8-10r,%0-7a)"}, {ARM_EXT_V4T, 0xA800, 0xF800, "add\t%8-10r, sp, #%0-7W"}, /* format 15 */ {ARM_EXT_V4T, 0xC000, 0xF800, "stmia\t%8-10r!, %M"}, {ARM_EXT_V4T, 0xC800, 0xF800, "ldmia\t%8-10r!, %M"}, /* format 17 */ {ARM_EXT_V4T, 0xDF00, 0xFF00, "svc\t%0-7d"}, /* format 16 */ {ARM_EXT_V4T, 0xD000, 0xF000, "b%8-11c.n\t%0-7B"}, /* format 18 */ {ARM_EXT_V4T, 0xE000, 0xF800, "b.n\t%0-10B"}, /* The E800 .. FFFF range is unconditionally redirected to the 32-bit table, because even in pre-V6T2 ISAs, BL and BLX(1) pairs are processed via that table. Thus, we can never encounter a bare "second half of BL/BLX(1)" instruction here. */ {ARM_EXT_V1, 0x0000, 0x0000, "undefined"}, {0, 0, 0, 0} }; /* Thumb32 opcodes use the same table structure as the ARM opcodes. We adopt the convention that hw1 is the high 16 bits of .value and .mask, hw2 the low 16 bits. print_insn_thumb32 recognizes the following format control codes: %% % %I print a 12-bit immediate from hw1[10],hw2[14:12,7:0] %M print a modified 12-bit immediate (same location) %J print a 16-bit immediate from hw1[3:0,10],hw2[14:12,7:0] %K print a 16-bit immediate from hw2[3:0],hw1[3:0],hw2[11:4] %S print a possibly-shifted Rm %a print the address of a plain load/store %w print the width and signedness of a core load/store %m print register mask for ldm/stm %E print the lsb and width fields of a bfc/bfi instruction %F print the lsb and width fields of a sbfx/ubfx instruction %b print a conditional branch offset %B print an unconditional branch offset %s print the shift field of an SSAT instruction %R print the rotation field of an SXT instruction %U print barrier type. %P print address for pli instruction. %d print bitfield in decimal %W print bitfield*4 in decimal %r print bitfield as an ARM register %c print bitfield as a condition code %'c print "c" iff bit is one %`c print "c" iff bit is zero %?ab print "a" if bit is one, else "b" With one exception at the bottom (done because BL and BLX(1) need to come dead last), this table was machine-sorted first in decreasing order of number of bits set in the mask, then in increasing numeric order of mask, then in increasing numeric order of opcode. This order is not the clearest for a human reader, but is guaranteed never to catch a special-case bit pattern with a more general mask, which is important, because this instruction encoding makes heavy use of special-case bit patterns. */ static const struct opcode32 thumb32_opcodes[] = { /* V7 instructions. */ {ARM_EXT_V7, 0xf910f000, 0xff70f000, "pli\t%a"}, {ARM_EXT_V7, 0xf3af80f0, 0xfffffff0, "dbg\t#%0-3d"}, {ARM_EXT_V7, 0xf3bf8f50, 0xfffffff0, "dmb\t%U"}, {ARM_EXT_V7, 0xf3bf8f40, 0xfffffff0, "dsb\t%U"}, {ARM_EXT_V7, 0xf3bf8f60, 0xfffffff0, "isb\t%U"}, {ARM_EXT_DIV, 0xfb90f0f0, 0xfff0f0f0, "sdiv\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_DIV, 0xfbb0f0f0, 0xfff0f0f0, "udiv\t%8-11r, %16-19r, %0-3r"}, /* Instructions defined in the basic V6T2 set. */ {ARM_EXT_V6T2, 0xf3af8000, 0xffffffff, "nop.w"}, {ARM_EXT_V6T2, 0xf3af8001, 0xffffffff, "yield.w"}, {ARM_EXT_V6T2, 0xf3af8002, 0xffffffff, "wfe.w"}, {ARM_EXT_V6T2, 0xf3af8003, 0xffffffff, "wfi.w"}, {ARM_EXT_V6T2, 0xf3af9004, 0xffffffff, "sev.w"}, {ARM_EXT_V6T2, 0xf3af8000, 0xffffff00, "nop.w\t{%0-7d}"}, {ARM_EXT_V6T2, 0xf3bf8f2f, 0xffffffff, "clrex"}, {ARM_EXT_V6T2, 0xf3af8400, 0xffffff1f, "cpsie.w\t%7'a%6'i%5'f"}, {ARM_EXT_V6T2, 0xf3af8600, 0xffffff1f, "cpsid.w\t%7'a%6'i%5'f"}, {ARM_EXT_V6T2, 0xf3c08f00, 0xfff0ffff, "bxj\t%16-19r"}, {ARM_EXT_V6T2, 0xe810c000, 0xffd0ffff, "rfedb\t%16-19r%21'!"}, {ARM_EXT_V6T2, 0xe990c000, 0xffd0ffff, "rfeia\t%16-19r%21'!"}, {ARM_EXT_V6T2, 0xf3ef8000, 0xffeff000, "mrs\t%8-11r, %D"}, {ARM_EXT_V6T2, 0xf3af8100, 0xffffffe0, "cps\t#%0-4d"}, {ARM_EXT_V6T2, 0xe8d0f000, 0xfff0fff0, "tbb\t[%16-19r, %0-3r]"}, {ARM_EXT_V6T2, 0xe8d0f010, 0xfff0fff0, "tbh\t[%16-19r, %0-3r, lsl #1]"}, {ARM_EXT_V6T2, 0xf3af8500, 0xffffff00, "cpsie\t%7'a%6'i%5'f, #%0-4d"}, {ARM_EXT_V6T2, 0xf3af8700, 0xffffff00, "cpsid\t%7'a%6'i%5'f, #%0-4d"}, {ARM_EXT_V6T2, 0xf3de8f00, 0xffffff00, "subs\tpc, lr, #%0-7d"}, {ARM_EXT_V6T2, 0xf3808000, 0xffe0f000, "msr\t%C, %16-19r"}, {ARM_EXT_V6T2, 0xe8500f00, 0xfff00fff, "ldrex\t%12-15r, [%16-19r]"}, {ARM_EXT_V6T2, 0xe8d00f4f, 0xfff00fef, "ldrex%4?hb\t%12-15r, [%16-19r]"}, {ARM_EXT_V6T2, 0xe800c000, 0xffd0ffe0, "srsdb\t#%0-4d%21'!"}, {ARM_EXT_V6T2, 0xe980c000, 0xffd0ffe0, "srsia\t#%0-4d%21'!"}, {ARM_EXT_V6T2, 0xfa0ff080, 0xfffff0c0, "sxth.w\t%8-11r, %0-3r%R"}, {ARM_EXT_V6T2, 0xfa1ff080, 0xfffff0c0, "uxth.w\t%8-11r, %0-3r%R"}, {ARM_EXT_V6T2, 0xfa2ff080, 0xfffff0c0, "sxtb16\t%8-11r, %0-3r%R"}, {ARM_EXT_V6T2, 0xfa3ff080, 0xfffff0c0, "uxtb16\t%8-11r, %0-3r%R"}, {ARM_EXT_V6T2, 0xfa4ff080, 0xfffff0c0, "sxtb.w\t%8-11r, %0-3r%R"}, {ARM_EXT_V6T2, 0xfa5ff080, 0xfffff0c0, "uxtb.w\t%8-11r, %0-3r%R"}, {ARM_EXT_V6T2, 0xe8400000, 0xfff000ff, "strex\t%8-11r, %12-15r, [%16-19r]"}, {ARM_EXT_V6T2, 0xe8d0007f, 0xfff000ff, "ldrexd\t%12-15r, %8-11r, [%16-19r]"}, {ARM_EXT_V6T2, 0xfa80f000, 0xfff0f0f0, "sadd8\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa80f010, 0xfff0f0f0, "qadd8\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa80f020, 0xfff0f0f0, "shadd8\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa80f040, 0xfff0f0f0, "uadd8\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa80f050, 0xfff0f0f0, "uqadd8\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa80f060, 0xfff0f0f0, "uhadd8\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa80f080, 0xfff0f0f0, "qadd\t%8-11r, %0-3r, %16-19r"}, {ARM_EXT_V6T2, 0xfa80f090, 0xfff0f0f0, "qdadd\t%8-11r, %0-3r, %16-19r"}, {ARM_EXT_V6T2, 0xfa80f0a0, 0xfff0f0f0, "qsub\t%8-11r, %0-3r, %16-19r"}, {ARM_EXT_V6T2, 0xfa80f0b0, 0xfff0f0f0, "qdsub\t%8-11r, %0-3r, %16-19r"}, {ARM_EXT_V6T2, 0xfa90f000, 0xfff0f0f0, "sadd16\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa90f010, 0xfff0f0f0, "qadd16\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa90f020, 0xfff0f0f0, "shadd16\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa90f040, 0xfff0f0f0, "uadd16\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa90f050, 0xfff0f0f0, "uqadd16\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa90f060, 0xfff0f0f0, "uhadd16\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa90f080, 0xfff0f0f0, "rev.w\t%8-11r, %16-19r"}, {ARM_EXT_V6T2, 0xfa90f090, 0xfff0f0f0, "rev16.w\t%8-11r, %16-19r"}, {ARM_EXT_V6T2, 0xfa90f0a0, 0xfff0f0f0, "rbit\t%8-11r, %16-19r"}, {ARM_EXT_V6T2, 0xfa90f0b0, 0xfff0f0f0, "revsh.w\t%8-11r, %16-19r"}, {ARM_EXT_V6T2, 0xfaa0f000, 0xfff0f0f0, "saddsubx\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfaa0f010, 0xfff0f0f0, "qaddsubx\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfaa0f020, 0xfff0f0f0, "shaddsubx\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfaa0f040, 0xfff0f0f0, "uaddsubx\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfaa0f050, 0xfff0f0f0, "uqaddsubx\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfaa0f060, 0xfff0f0f0, "uhaddsubx\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfaa0f080, 0xfff0f0f0, "sel\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfab0f080, 0xfff0f0f0, "clz\t%8-11r, %16-19r"}, {ARM_EXT_V6T2, 0xfac0f000, 0xfff0f0f0, "ssub8\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfac0f010, 0xfff0f0f0, "qsub8\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfac0f020, 0xfff0f0f0, "shsub8\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfac0f040, 0xfff0f0f0, "usub8\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfac0f050, 0xfff0f0f0, "uqsub8\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfac0f060, 0xfff0f0f0, "uhsub8\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfad0f000, 0xfff0f0f0, "ssub16\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfad0f010, 0xfff0f0f0, "qsub16\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfad0f020, 0xfff0f0f0, "shsub16\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfad0f040, 0xfff0f0f0, "usub16\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfad0f050, 0xfff0f0f0, "uqsub16\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfad0f060, 0xfff0f0f0, "uhsub16\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfae0f000, 0xfff0f0f0, "ssubaddx\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfae0f010, 0xfff0f0f0, "qsubaddx\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfae0f020, 0xfff0f0f0, "shsubaddx\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfae0f040, 0xfff0f0f0, "usubaddx\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfae0f050, 0xfff0f0f0, "uqsubaddx\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfae0f060, 0xfff0f0f0, "uhsubaddx\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfb00f000, 0xfff0f0f0, "mul.w\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfb70f000, 0xfff0f0f0, "usad8\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa00f000, 0xffe0f0f0, "lsl%20's.w\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa20f000, 0xffe0f0f0, "lsr%20's.w\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa40f000, 0xffe0f0f0, "asr%20's.w\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa60f000, 0xffe0f0f0, "ror%20's.w\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xe8c00f40, 0xfff00fe0, "strex%4?hb\t%0-3r, %12-15r, [%16-19r]"}, {ARM_EXT_V6T2, 0xf3200000, 0xfff0f0e0, "ssat16\t%8-11r, #%0-4d, %16-19r"}, {ARM_EXT_V6T2, 0xf3a00000, 0xfff0f0e0, "usat16\t%8-11r, #%0-4d, %16-19r"}, {ARM_EXT_V6T2, 0xfb20f000, 0xfff0f0e0, "smuad%4'x\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfb30f000, 0xfff0f0e0, "smulw%4?tb\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfb40f000, 0xfff0f0e0, "smusd%4'x\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfb50f000, 0xfff0f0e0, "smmul%4'r\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfa00f080, 0xfff0f0c0, "sxtah\t%8-11r, %16-19r, %0-3r%R"}, {ARM_EXT_V6T2, 0xfa10f080, 0xfff0f0c0, "uxtah\t%8-11r, %16-19r, %0-3r%R"}, {ARM_EXT_V6T2, 0xfa20f080, 0xfff0f0c0, "sxtab16\t%8-11r, %16-19r, %0-3r%R"}, {ARM_EXT_V6T2, 0xfa30f080, 0xfff0f0c0, "uxtab16\t%8-11r, %16-19r, %0-3r%R"}, {ARM_EXT_V6T2, 0xfa40f080, 0xfff0f0c0, "sxtab\t%8-11r, %16-19r, %0-3r%R"}, {ARM_EXT_V6T2, 0xfa50f080, 0xfff0f0c0, "uxtab\t%8-11r, %16-19r, %0-3r%R"}, {ARM_EXT_V6T2, 0xfb10f000, 0xfff0f0c0, "smul%5?tb%4?tb\t%8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xf36f0000, 0xffff8020, "bfc\t%8-11r, %E"}, {ARM_EXT_V6T2, 0xea100f00, 0xfff08f00, "tst.w\t%16-19r, %S"}, {ARM_EXT_V6T2, 0xea900f00, 0xfff08f00, "teq\t%16-19r, %S"}, {ARM_EXT_V6T2, 0xeb100f00, 0xfff08f00, "cmn.w\t%16-19r, %S"}, {ARM_EXT_V6T2, 0xebb00f00, 0xfff08f00, "cmp.w\t%16-19r, %S"}, {ARM_EXT_V6T2, 0xf0100f00, 0xfbf08f00, "tst.w\t%16-19r, %M"}, {ARM_EXT_V6T2, 0xf0900f00, 0xfbf08f00, "teq\t%16-19r, %M"}, {ARM_EXT_V6T2, 0xf1100f00, 0xfbf08f00, "cmn.w\t%16-19r, %M"}, {ARM_EXT_V6T2, 0xf1b00f00, 0xfbf08f00, "cmp.w\t%16-19r, %M"}, {ARM_EXT_V6T2, 0xea4f0000, 0xffef8000, "mov%20's.w\t%8-11r, %S"}, {ARM_EXT_V6T2, 0xea6f0000, 0xffef8000, "mvn%20's.w\t%8-11r, %S"}, {ARM_EXT_V6T2, 0xe8c00070, 0xfff000f0, "strexd\t%0-3r, %12-15r, %8-11r, [%16-19r]"}, {ARM_EXT_V6T2, 0xfb000000, 0xfff000f0, "mla\t%8-11r, %16-19r, %0-3r, %12-15r"}, {ARM_EXT_V6T2, 0xfb000010, 0xfff000f0, "mls\t%8-11r, %16-19r, %0-3r, %12-15r"}, {ARM_EXT_V6T2, 0xfb700000, 0xfff000f0, "usada8\t%8-11r, %16-19r, %0-3r, %12-15r"}, {ARM_EXT_V6T2, 0xfb800000, 0xfff000f0, "smull\t%12-15r, %8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfba00000, 0xfff000f0, "umull\t%12-15r, %8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfbc00000, 0xfff000f0, "smlal\t%12-15r, %8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfbe00000, 0xfff000f0, "umlal\t%12-15r, %8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfbe00060, 0xfff000f0, "umaal\t%12-15r, %8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xe8500f00, 0xfff00f00, "ldrex\t%12-15r, [%16-19r, #%0-7W]"}, {ARM_EXT_V6T2, 0xf7f08000, 0xfff0f000, "smc\t%K"}, {ARM_EXT_V6T2, 0xf04f0000, 0xfbef8000, "mov%20's.w\t%8-11r, %M"}, {ARM_EXT_V6T2, 0xf06f0000, 0xfbef8000, "mvn%20's.w\t%8-11r, %M"}, {ARM_EXT_V6T2, 0xf810f000, 0xff70f000, "pld\t%a"}, {ARM_EXT_V6T2, 0xfb200000, 0xfff000e0, "smlad%4'x\t%8-11r, %16-19r, %0-3r, %12-15r"}, {ARM_EXT_V6T2, 0xfb300000, 0xfff000e0, "smlaw%4?tb\t%8-11r, %16-19r, %0-3r, %12-15r"}, {ARM_EXT_V6T2, 0xfb400000, 0xfff000e0, "smlsd%4'x\t%8-11r, %16-19r, %0-3r, %12-15r"}, {ARM_EXT_V6T2, 0xfb500000, 0xfff000e0, "smmla%4'r\t%8-11r, %16-19r, %0-3r, %12-15r"}, {ARM_EXT_V6T2, 0xfb600000, 0xfff000e0, "smmls%4'r\t%8-11r, %16-19r, %0-3r, %12-15r"}, {ARM_EXT_V6T2, 0xfbc000c0, 0xfff000e0, "smlald%4'x\t%12-15r, %8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xfbd000c0, 0xfff000e0, "smlsld%4'x\t%12-15r, %8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xeac00000, 0xfff08030, "pkhbt\t%8-11r, %16-19r, %S"}, {ARM_EXT_V6T2, 0xeac00020, 0xfff08030, "pkhtb\t%8-11r, %16-19r, %S"}, {ARM_EXT_V6T2, 0xf3400000, 0xfff08020, "sbfx\t%8-11r, %16-19r, %F"}, {ARM_EXT_V6T2, 0xf3c00000, 0xfff08020, "ubfx\t%8-11r, %16-19r, %F"}, {ARM_EXT_V6T2, 0xf8000e00, 0xff900f00, "str%wt\t%12-15r, %a"}, {ARM_EXT_V6T2, 0xfb100000, 0xfff000c0, "smla%5?tb%4?tb\t%8-11r, %16-19r, %0-3r, %12-15r"}, {ARM_EXT_V6T2, 0xfbc00080, 0xfff000c0, "smlal%5?tb%4?tb\t%12-15r, %8-11r, %16-19r, %0-3r"}, {ARM_EXT_V6T2, 0xf3600000, 0xfff08020, "bfi\t%8-11r, %16-19r, %E"}, {ARM_EXT_V6T2, 0xf8100e00, 0xfe900f00, "ldr%wt\t%12-15r, %a"}, {ARM_EXT_V6T2, 0xf3000000, 0xffd08020, "ssat\t%8-11r, #%0-4d, %16-19r%s"}, {ARM_EXT_V6T2, 0xf3800000, 0xffd08020, "usat\t%8-11r, #%0-4d, %16-19r%s"}, {ARM_EXT_V6T2, 0xf2000000, 0xfbf08000, "addw\t%8-11r, %16-19r, %I"}, {ARM_EXT_V6T2, 0xf2400000, 0xfbf08000, "movw\t%8-11r, %J"}, {ARM_EXT_V6T2, 0xf2a00000, 0xfbf08000, "subw\t%8-11r, %16-19r, %I"}, {ARM_EXT_V6T2, 0xf2c00000, 0xfbf08000, "movt\t%8-11r, %J"}, {ARM_EXT_V6T2, 0xea000000, 0xffe08000, "and%20's.w\t%8-11r, %16-19r, %S"}, {ARM_EXT_V6T2, 0xea200000, 0xffe08000, "bic%20's.w\t%8-11r, %16-19r, %S"}, {ARM_EXT_V6T2, 0xea400000, 0xffe08000, "orr%20's.w\t%8-11r, %16-19r, %S"}, {ARM_EXT_V6T2, 0xea600000, 0xffe08000, "orn%20's\t%8-11r, %16-19r, %S"}, {ARM_EXT_V6T2, 0xea800000, 0xffe08000, "eor%20's.w\t%8-11r, %16-19r, %S"}, {ARM_EXT_V6T2, 0xeb000000, 0xffe08000, "add%20's.w\t%8-11r, %16-19r, %S"}, {ARM_EXT_V6T2, 0xeb400000, 0xffe08000, "adc%20's.w\t%8-11r, %16-19r, %S"}, {ARM_EXT_V6T2, 0xeb600000, 0xffe08000, "sbc%20's.w\t%8-11r, %16-19r, %S"}, {ARM_EXT_V6T2, 0xeba00000, 0xffe08000, "sub%20's.w\t%8-11r, %16-19r, %S"}, {ARM_EXT_V6T2, 0xebc00000, 0xffe08000, "rsb%20's\t%8-11r, %16-19r, %S"}, {ARM_EXT_V6T2, 0xe8400000, 0xfff00000, "strex\t%8-11r, %12-15r, [%16-19r, #%0-7W]"}, {ARM_EXT_V6T2, 0xf0000000, 0xfbe08000, "and%20's.w\t%8-11r, %16-19r, %M"}, {ARM_EXT_V6T2, 0xf0200000, 0xfbe08000, "bic%20's.w\t%8-11r, %16-19r, %M"}, {ARM_EXT_V6T2, 0xf0400000, 0xfbe08000, "orr%20's.w\t%8-11r, %16-19r, %M"}, {ARM_EXT_V6T2, 0xf0600000, 0xfbe08000, "orn%20's\t%8-11r, %16-19r, %M"}, {ARM_EXT_V6T2, 0xf0800000, 0xfbe08000, "eor%20's.w\t%8-11r, %16-19r, %M"}, {ARM_EXT_V6T2, 0xf1000000, 0xfbe08000, "add%20's.w\t%8-11r, %16-19r, %M"}, {ARM_EXT_V6T2, 0xf1400000, 0xfbe08000, "adc%20's.w\t%8-11r, %16-19r, %M"}, {ARM_EXT_V6T2, 0xf1600000, 0xfbe08000, "sbc%20's.w\t%8-11r, %16-19r, %M"}, {ARM_EXT_V6T2, 0xf1a00000, 0xfbe08000, "sub%20's.w\t%8-11r, %16-19r, %M"}, {ARM_EXT_V6T2, 0xf1c00000, 0xfbe08000, "rsb%20's\t%8-11r, %16-19r, %M"}, {ARM_EXT_V6T2, 0xe8800000, 0xffd00000, "stmia.w\t%16-19r%21'!, %m"}, {ARM_EXT_V6T2, 0xe8900000, 0xffd00000, "ldmia.w\t%16-19r%21'!, %m"}, {ARM_EXT_V6T2, 0xe9000000, 0xffd00000, "stmdb\t%16-19r%21'!, %m"}, {ARM_EXT_V6T2, 0xe9100000, 0xffd00000, "ldmdb\t%16-19r%21'!, %m"}, {ARM_EXT_V6T2, 0xe9c00000, 0xffd000ff, "strd\t%12-15r, %8-11r, [%16-19r]"}, {ARM_EXT_V6T2, 0xe9d00000, 0xffd000ff, "ldrd\t%12-15r, %8-11r, [%16-19r]"}, {ARM_EXT_V6T2, 0xe9400000, 0xff500000, "strd\t%12-15r, %8-11r, [%16-19r, #%23`-%0-7W]"}, {ARM_EXT_V6T2, 0xe9500000, 0xff500000, "ldrd\t%12-15r, %8-11r, [%16-19r, #%23`-%0-7W]"}, {ARM_EXT_V6T2, 0xf8000000, 0xff100000, "str%w.w\t%12-15r, %a"}, {ARM_EXT_V6T2, 0xf8100000, 0xfe100000, "ldr%w.w\t%12-15r, %a"}, /* Filter out Bcc with cond=E or F, which are used for other instructions. */ {ARM_EXT_V6T2, 0xf3c08000, 0xfbc0d000, "undefined (bcc, cond=0xF)"}, {ARM_EXT_V6T2, 0xf3808000, 0xfbc0d000, "undefined (bcc, cond=0xE)"}, {ARM_EXT_V6T2, 0xf0008000, 0xf800d000, "b%22-25c.w\t%b"}, {ARM_EXT_V6T2, 0xf0009000, 0xf800d000, "b.w\t%B"}, /* These have been 32-bit since the invention of Thumb. */ {ARM_EXT_V4T, 0xf000c000, 0xf800d000, "blx\t%B"}, {ARM_EXT_V4T, 0xf000d000, 0xf800d000, "bl\t%B"}, /* Fallback. */ {ARM_EXT_V1, 0x00000000, 0x00000000, "undefined"}, {0, 0, 0, 0} }; static const char *const arm_conditional[] = {"eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc", "hi", "ls", "ge", "lt", "gt", "le", "", ""}; static const char *const arm_fp_const[] = {"0.0", "1.0", "2.0", "3.0", "4.0", "5.0", "0.5", "10.0"}; static const char *const arm_shift[] = {"lsl", "lsr", "asr", "ror"}; typedef struct { const char *name; const char *description; const char *reg_names[16]; } arm_regname; static const arm_regname regnames[] = { { "raw" , "Select raw register names", { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"}}, { "gcc", "Select register names used by GCC", { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "sl", "fp", "ip", "sp", "lr", "pc" }}, { "std", "Select register names used in ARM's ISA documentation", { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc" }}, { "apcs", "Select register names used in the APCS", { "a1", "a2", "a3", "a4", "v1", "v2", "v3", "v4", "v5", "v6", "sl", "fp", "ip", "sp", "lr", "pc" }}, { "atpcs", "Select register names used in the ATPCS", { "a1", "a2", "a3", "a4", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "IP", "SP", "LR", "PC" }}, { "special-atpcs", "Select special register names used in the ATPCS", { "a1", "a2", "a3", "a4", "v1", "v2", "v3", "WR", "v5", "SB", "SL", "FP", "IP", "SP", "LR", "PC" }}, }; static const char *const iwmmxt_wwnames[] = {"b", "h", "w", "d"}; static const char *const iwmmxt_wwssnames[] = {"b", "bus", "b", "bss", "h", "hus", "h", "hss", "w", "wus", "w", "wss", "d", "dus", "d", "dss" }; static const char *const iwmmxt_regnames[] = { "wr0", "wr1", "wr2", "wr3", "wr4", "wr5", "wr6", "wr7", "wr8", "wr9", "wr10", "wr11", "wr12", "wr13", "wr14", "wr15" }; static const char *const iwmmxt_cregnames[] = { "wcid", "wcon", "wcssf", "wcasf", "reserved", "reserved", "reserved", "reserved", "wcgr0", "wcgr1", "wcgr2", "wcgr3", "reserved", "reserved", "reserved", "reserved" }; /* Default to GCC register name set. */ static unsigned int regname_selected = 1; #define NUM_ARM_REGNAMES NUM_ELEM (regnames) #define arm_regnames regnames[regname_selected].reg_names static bool force_thumb = false; /* Functions. */ int get_arm_regname_num_options(void) { return NUM_ARM_REGNAMES; } int set_arm_regname_option(int option) { int old = regname_selected; regname_selected = option; return old; } int get_arm_regnames(int option, const char **setname, const char **setdescription, const char *const **register_names) { *setname = regnames[option].name; *setdescription = regnames[option].description; *register_names = regnames[option].reg_names; return 16; } static void arm_decode_shift(long given, fprintf_ftype func, void *stream) { func(stream, "%s", arm_regnames[given & 0xf]); if ((given & 0xff0) != 0) { if ((given & 0x10) == 0) { int amount = (given & 0xf80) >> 7; int shift = (given & 0x60) >> 5; if (amount == 0) { if (shift == 3) { func(stream, ", rrx"); return; } amount = 32; } func(stream, ", %s #%d", arm_shift[shift], amount); } else { func(stream, ", %s %s", arm_shift[(given & 0x60) >> 5], arm_regnames[(given & 0xf00) >> 8]); } } } /* Print one coprocessor instruction on INFO->STREAM. Return TRUE if the instuction matched, FALSE if this is not a recognised coprocessor instruction. */ static bool print_insn_coprocessor(struct disassemble_info *info, long given, bool thumb) { const struct opcode32 *insn; void *stream = info->stream; fprintf_ftype func = info->fprintf_func; unsigned long mask; unsigned long value; for (insn = coprocessor_opcodes; insn->assembler; insn++) { if (insn->value == FIRST_IWMMXT_INSN && info->mach != bfd_mach_arm_XScale && info->mach != bfd_mach_arm_iWMMXt) { insn = insn + IWMMXT_INSN_COUNT; } mask = insn->mask; value = insn->value; if (thumb) { /* The high 4 bits are 0xe for Arm conditional instructions, and 0xe for arm unconditional instructions. The rest of the encoding is the same. */ mask |= 0xf0000000; value |= 0xe0000000; } else { /* Only match unconditional instuctions against unconditional patterns. */ if ((given & 0xf0000000) == 0xf0000000) { mask |= 0xf0000000; } } if ((given & mask) == value) { const char *c; for (c = insn->assembler; *c; c++) { if (*c == '%') { switch (*++c) { case '%': func(stream, "%%"); break; case 'A': func(stream, "[%s", arm_regnames [(given >> 16) & 0xf]); if ((given & (1 << 24)) != 0) { int offset = given & 0xff; if (offset) { func(stream, ", #%s%d]%s", ((given & 0x00800000) == 0 ? "-" : ""), offset * 4, ((given & 0x00200000) != 0 ? "!" : "")); } else { func(stream, "]"); } } else { int offset = given & 0xff; func(stream, "]"); if (given & (1 << 21)) { if (offset) { func(stream, ", #%s%d", ((given & 0x00800000) == 0 ? "-" : ""), offset * 4); } } else { func(stream, ", {%d}", offset); } } break; case 'c': func(stream, "%s", arm_conditional[(given >> 28) & 0xf]); break; case 'I': { /* Print a Cirrus/DSP shift immediate. */ /* Immediates are 7bit signed ints with bits 0..3 in bits 0..3 of opcode and bits 4..6 in bits 5..7 of opcode. */ int imm; imm = (given & 0xf) | ((given & 0xe0) >> 1); /* Is ``imm'' a negative number? */ if (imm & 0x40) imm |= (-1 << 7); func(stream, "%d", imm); break; } case 'F': switch (given & 0x00408000) { case 0: func(stream, "4"); break; case 0x8000: func(stream, "1"); break; case 0x00400000: func(stream, "2"); break; default: func(stream, "3"); } break; case 'P': switch (given & 0x00080080) { case 0: func(stream, "s"); break; case 0x80: func(stream, "d"); break; case 0x00080000: func(stream, "e"); break; default: func(stream, _("")); } break; case 'Q': switch (given & 0x00408000) { case 0: func(stream, "s"); break; case 0x8000: func(stream, "d"); break; case 0x00400000: func(stream, "e"); break; default: func(stream, "p"); } break; case 'R': switch (given & 0x60) { case 0: break; case 0x20: func(stream, "p"); break; case 0x40: func(stream, "m"); break; default: func(stream, "z"); } break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { int bitstart = *c++ - '0'; int bitend = 0; while (*c >= '0' && *c <= '9') { bitstart = (bitstart * 10) + *c++ - '0'; } switch (*c) { case '-': c++; while (*c >= '0' && *c <= '9') { bitend = (bitend * 10) + *c++ - '0'; } if (!bitend) abort (); switch (*c) { case 'r': { long reg; reg = given >> bitstart; reg &= (2 << (bitend - bitstart)) - 1; func(stream, "%s", arm_regnames[reg]); break; } case 'd': { long reg; reg = given >> bitstart; reg &= (2 << (bitend - bitstart)) - 1; func(stream, "%ld", reg); break; } case 'f': { long reg; reg = given >> bitstart; reg &= (2 << (bitend - bitstart)) - 1; if (reg > 7) { func(stream, "#%s", arm_fp_const[reg & 7]); } else { func(stream, "f%ld", reg); } break; } case 'w': { long reg; if (bitstart != bitend) { reg = given >> bitstart; reg &= (2 << (bitend - bitstart)) - 1; if (bitend - bitstart == 1) { func(stream, "%s", iwmmxt_wwnames[reg]); } else { func(stream, "%s", iwmmxt_wwssnames[reg]); } } else { reg = (((given >> 8) & 0x1) | ((given >> 22) & 0x1)); func(stream, "%s", iwmmxt_wwnames[reg]); } break; } case 'g': { long reg; reg = given >> bitstart; reg &= (2 << (bitend - bitstart)) - 1; func(stream, "%s", iwmmxt_regnames[reg]); break; } case 'G': { long reg; reg = given >> bitstart; reg &= (2 << (bitend - bitstart)) - 1; func(stream, "%s", iwmmxt_cregnames[reg]); break; } default: abort (); } break; case 'y': case 'z': { int single = *c == 'y'; int regno; switch (bitstart) { case 4: /* Sm pair */ func(stream, "{"); /* Fall through. */ case 0: /* Sm, Dm */ regno = given & 0x0000000f; if (single) { regno <<= 1; regno += (given >> 5) & 1; } break; case 1: /* Sd, Dd */ regno = (given >> 12) & 0x0000000f; if (single) { regno <<= 1; regno += (given >> 22) & 1; } break; case 2: /* Sn, Dn */ regno = (given >> 16) & 0x0000000f; if (single) { regno <<= 1; regno += (given >> 7) & 1; } break; case 3: /* List */ func(stream, "{"); regno = (given >> 12) & 0x0000000f; if (single) { regno <<= 1; regno += (given >> 22) & 1; } break; default: abort(); } func(stream, "%c%d", single ? 's' : 'd', regno); if (bitstart == 3) { int count = given & 0xff; if (single == 0) count >>= 1; if (--count) { func(stream, "-%c%d", single ? 's' : 'd', regno + count); } func(stream, "}"); } else if (bitstart == 4) { func(stream, ", %c%d}", single ? 's' : 'd', regno + 1); } break; } case '`': c++; if ((given & (1 << bitstart)) == 0) func(stream, "%c", *c); break; case '\'': c++; if ((given & (1 << bitstart)) != 0) func(stream, "%c", *c); break; case '?': ++c; if ((given & (1 << bitstart)) != 0) { func(stream, "%c", *c++); } else { func(stream, "%c", *++c); } break; default: abort(); } break; } case 'L': switch (given & 0x00400100) { case 0x00000000: func(stream, "b"); break; case 0x00400000: func(stream, "h"); break; case 0x00000100: func(stream, "w"); break; case 0x00400100: func(stream, "d"); break; } break; case 'Z': { int value; /* given (20, 23) | given (0, 3) */ value = ((given >> 16) & 0xf0) | (given & 0xf); func(stream, "%d", value); break; } case 'l': { /* This is like the 'A' operator, except that if the width field "M" is zero, then the offset is *not* multiplied by four. */ int offset = given & 0xff; int multiplier = (given & 0x00000100) ? 4 : 1; func(stream, "[%s", arm_regnames [(given >> 16) & 0xf]); if (offset) { if ((given & 0x01000000) != 0) { func(stream, ", #%s%d]%s", ((given & 0x00800000) == 0 ? "-" : ""), offset * multiplier, ((given & 0x00200000) != 0 ? "!" : "")); } else { func(stream, "], #%s%d", ((given & 0x00800000) == 0 ? "-" : ""), offset * multiplier); } } else { func(stream, "]"); } break; } default: abort(); } // switch } else { func(stream, "%c", *c); } // if } // for return true; } // if } // for return false; } static void print_arm_address(bfd_vma pc, struct disassemble_info *info, long given) { void *stream = info->stream; fprintf_ftype func = info->fprintf_func; if (((given & 0x000f0000) == 0x000f0000) && ((given & 0x02000000) == 0)) { int offset = given & 0xfff; func(stream, "[pc"); if (given & 0x01000000) { if ((given & 0x00800000) == 0) offset = - offset; /* Pre-indexed. */ func(stream, ", #%d]", offset); offset += pc + 8; /* Cope with the possibility of write-back being used. Probably a very dangerous thing for the programmer to do, but who are we to argue ? */ if (given & 0x00200000) func(stream, "!"); } else { /* Post indexed. */ func(stream, "], #%d", offset); /* ie ignore the offset. */ offset = pc + 8; } func(stream, "\t; "); info->print_address_func(offset, info); } else { func(stream, "[%s", arm_regnames[(given >> 16) & 0xf]); if ((given & 0x01000000) != 0) { if ((given & 0x02000000) == 0) { int offset = given & 0xfff; if (offset) { func(stream, ", #%s%d", (((given & 0x00800000) == 0) ? "-" : ""), offset); } } else { func(stream, ", %s", (((given & 0x00800000) == 0) ? "-" : "")); arm_decode_shift (given, func, stream); } func(stream, "]%s", ((given & 0x00200000) != 0) ? "!" : ""); } else { if ((given & 0x02000000) == 0) { int offset = given & 0xfff; if (offset) { func(stream, "], #%s%d", (((given & 0x00800000) == 0) ? "-" : ""), offset); } else { func(stream, "]"); } } else { func(stream, "], %s", (((given & 0x00800000) == 0) ? "-" : "")); arm_decode_shift (given, func, stream); } } } } /* Print one ARM instruction from PC on INFO->STREAM. */ static void print_insn_arm(bfd_vma pc, struct disassemble_info *info, long given) { const struct opcode32 *insn; void *stream = info->stream; fprintf_ftype func = info->fprintf_func; if (print_insn_coprocessor(info, given, false)) return; for (insn = arm_opcodes; insn->assembler; insn++) { if (insn->value == FIRST_IWMMXT_INSN && info->mach != bfd_mach_arm_XScale && info->mach != bfd_mach_arm_iWMMXt) { insn = insn + IWMMXT_INSN_COUNT; } if ((given & insn->mask) == insn->value /* Special case: an instruction with all bits set in the condition field (0xFnnn_nnnn) is only matched if all those bits are set in insn->mask, or by the catchall at the end of the table. */ && ((given & 0xF0000000) != 0xF0000000 || (insn->mask & 0xF0000000) == 0xF0000000 || (insn->mask == 0 && insn->value == 0))) { const char *c; for (c = insn->assembler; *c; c++) { if (*c == '%') { switch (*++c) { case '%': func(stream, "%%"); break; case 'a': print_arm_address (pc, info, given); break; case 'P': /* Set P address bit and use normal address printing routine. */ print_arm_address (pc, info, given | (1 << 24)); break; case 's': if ((given & 0x004f0000) == 0x004f0000) { /* PC relative with immediate offset. */ int offset = ((given & 0xf00) >> 4) | (given & 0xf); if ((given & 0x00800000) == 0) offset = -offset; func(stream, "[pc, #%d]\t; ", offset); info->print_address_func(offset + pc + 8, info); } else { func(stream, "[%s", arm_regnames[(given >> 16) & 0xf]); if ((given & 0x01000000) != 0) { /* Pre-indexed. */ if ((given & 0x00400000) == 0x00400000) { /* Immediate. */ int offset = ((given & 0xf00) >> 4) | (given & 0xf); if (offset) { func(stream, ", #%s%d", (((given & 0x00800000) == 0) ? "-" : ""), offset); } } else { /* Register. */ func(stream, ", %s%s", (((given & 0x00800000) == 0) ? "-" : ""), arm_regnames[given & 0xf]); } func(stream, "]%s", ((given & 0x00200000) != 0) ? "!" : ""); } else { /* Post-indexed. */ if ((given & 0x00400000) == 0x00400000) { /* Immediate. */ int offset = ((given & 0xf00) >> 4) | (given & 0xf); if (offset) { func(stream, "], #%s%d", (((given & 0x00800000) == 0) ? "-" : ""), offset); } else { func(stream, "]"); } } else { /* Register. */ func(stream, "], %s%s",(((given & 0x00800000) == 0) ? "-" : ""), arm_regnames[given & 0xf]); } } } break; case 'b': { int disp = (((given & 0xffffff) ^ 0x800000) - 0x800000); info->print_address_func(disp*4 + pc + 8, info); break; } case 'c': func(stream, "%s", arm_conditional[(given >> 28) & 0xf]); break; case 'm': { bool started = false; int reg; func(stream, "{"); for (reg = 0; reg < 16; reg++) { if ((given & (1 << reg)) != 0) { if (started) func(stream, ", "); started = true; func(stream, "%s", arm_regnames[reg]); } } func(stream, "}"); break; } case 'o': if ((given & 0x02000000) != 0) { int rotate = (given & 0xf00) >> 7; int immed = (given & 0xff); immed = (((immed << (32 - rotate)) | (immed >> rotate)) & 0xffffffff); func(stream, "#%d\t; 0x%x", immed, immed); } else { arm_decode_shift(given, func, stream); } break; case 'p': if ((given & 0x0000f000) == 0x0000f000) func(stream, "p"); break; case 't': if ((given & 0x01200000) == 0x00200000) func(stream, "t"); break; case 'A': func(stream, "[%s", arm_regnames [(given >> 16) & 0xf]); if ((given & (1 << 24)) != 0) { int offset = given & 0xff; if (offset) { func(stream, ", #%s%d]%s", ((given & 0x00800000) == 0 ? "-" : ""), offset * 4, ((given & 0x00200000) != 0 ? "!" : "")); } else { func(stream, "]"); } } else { int offset = given & 0xff; func(stream, "]"); if (given & (1 << 21)) { if (offset) { func(stream, ", #%s%d", ((given & 0x00800000) == 0 ? "-" : ""), offset * 4); } } else { func(stream, ", {%d}", offset); } } break; case 'B': { /* Print ARM V5 BLX(1) address: pc+25 bits. */ bfd_vma address; bfd_vma offset = 0; if (given & 0x00800000) { /* Is signed, hi bits should be ones. */ offset = (-1) ^ 0x00ffffff; } /* Offset is (SignExtend(offset field)<<2). */ offset += given & 0x00ffffff; offset <<= 2; address = offset + pc + 8; if (given & 0x01000000) { /* H bit allows addressing to 2-byte boundaries. */ address += 2; } info->print_address_func(address, info); break; } case 'C': func(stream, "_"); if (given & 0x80000) func(stream, "f"); if (given & 0x40000) func(stream, "s"); if (given & 0x20000) func(stream, "x"); if (given & 0x10000) func(stream, "c"); break; case 'U': switch (given & 0xf) { case 0xf: func(stream, "sy"); break; case 0x7: func(stream, "un"); break; case 0xe: func(stream, "st"); break; case 0x6: func(stream, "unst"); break; default: func(stream, "#%d", (int)given & 0xf); } break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { int bitstart = *c++ - '0'; int bitend = 0; while (*c >= '0' && *c <= '9') { bitstart = (bitstart * 10) + *c++ - '0'; } switch (*c) { case '-': c++; while (*c >= '0' && *c <= '9') { bitend = (bitend * 10) + *c++ - '0'; } if (!bitend) abort(); switch (*c) { case 'r': { long reg; reg = given >> bitstart; reg &= (2 << (bitend - bitstart)) - 1; func(stream, "%s", arm_regnames[reg]); break; } case 'd': { long reg; reg = given >> bitstart; reg &= (2 << (bitend - bitstart)) - 1; func(stream, "%ld", reg); break; } case 'W': { long reg; reg = given >> bitstart; reg &= (2 << (bitend - bitstart)) - 1; func(stream, "%ld", reg + 1); break; } case 'x': { long reg; reg = given >> bitstart; reg &= (2 << (bitend - bitstart)) - 1; func(stream, "0x%08lx", reg); /* Some SWI instructions have special meanings. */ if ((given & 0x0fffffff) == 0x0FF00000) { func(stream, "\t; IMB"); } else if ((given & 0x0fffffff) == 0x0FF00001) { func(stream, "\t; IMBRange"); } break; } case 'X': { long reg; reg = given >> bitstart; reg &= (2 << (bitend - bitstart)) - 1; func(stream, "%01lx", reg & 0xf); break; } default: abort(); } break; case '`': c++; if ((given & (1 << bitstart)) == 0) { func(stream, "%c", *c); } break; case '\'': c++; if ((given & (1 << bitstart)) != 0) { func(stream, "%c", *c); } break; case '?': ++c; if ((given & (1 << bitstart)) != 0) { func(stream, "%c", *c++); } else { func(stream, "%c", *++c); } break; default: abort(); } break; } case 'e': { int imm; imm = (given & 0xf) | ((given & 0xfff00) >> 4); func(stream, "%d", imm); break; } case 'E': { /* LSB and WIDTH fields of BFI or BFC. The machine- language instruction encodes LSB and MSB. */ long msb = (given & 0x001f0000) >> 16; long lsb = (given & 0x00000f80) >> 7; long width = msb - lsb + 1; if (width > 0) { func(stream, "#%lu, #%lu", lsb, width); } else { func(stream, "(invalid: %lu:%lu)", lsb, msb); } break; } case 'V': { /* 16-bit unsigned immediate from a MOVT or MOVW instruction, encoded in bits 0:11 and 15:19. */ long hi = (given & 0x000f0000) >> 4; long lo = (given & 0x00000fff); long imm16 = hi | lo; func(stream, "#%lu\t; 0x%lx", imm16, imm16); break; } default: abort(); } // switch } else { func(stream, "%c", *c); } // if } // for return; } // if } // for abort(); } /* Print one 16-bit Thumb instruction from PC on INFO->STREAM. */ static void print_insn_thumb16(bfd_vma pc, struct disassemble_info *info, long given) { const struct opcode16 *insn; void *stream = info->stream; fprintf_ftype func = info->fprintf_func; for (insn = thumb_opcodes; insn->assembler; insn++) if ((given & insn->mask) == insn->value) { const char *c = insn->assembler; for (; *c; c++) { int domaskpc = 0; int domasklr = 0; if (*c != '%') { func(stream, "%c", *c); continue; } switch (*++c) { case '%': func(stream, "%%"); break; case 'S': { long reg; reg = (given >> 3) & 0x7; if (given & (1 << 6)) reg += 8; func(stream, "%s", arm_regnames[reg]); } break; case 'D': { long reg; reg = given & 0x7; if (given & (1 << 7)) reg += 8; func(stream, "%s", arm_regnames[reg]); } break; case 'N': if (given & (1 << 8)) domasklr = 1; /* Fall through. */ case 'O': if (*c == 'O' && (given & (1 << 8))) domaskpc = 1; /* Fall through. */ case 'M': { int started = 0; int reg; func(stream, "{"); /* It would be nice if we could spot ranges, and generate the rS-rE format: */ for (reg = 0; (reg < 8); reg++) if ((given & (1 << reg)) != 0) { if (started) func(stream, ", "); started = 1; func(stream, "%s", arm_regnames[reg]); } if (domasklr) { if (started) func(stream, ", "); started = 1; func(stream, arm_regnames[14] /* "lr" */); } if (domaskpc) { if (started) func(stream, ", "); func(stream, arm_regnames[15] /* "pc" */); } func(stream, "}"); } break; case 'b': /* Print ARM V6T2 CZB address: pc+4+6 bits. */ { bfd_vma address = (pc + 4 + ((given & 0x00f8) >> 2) + ((given & 0x0200) >> 3)); info->print_address_func(address, info); } break; case 's': /* Right shift immediate -- bits 6..10; 1-31 print as themselves, 0 prints as 32. */ { long imm = (given & 0x07c0) >> 6; if (imm == 0) imm = 32; func(stream, "#%ld", imm); } break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { int bitstart = *c++ - '0'; int bitend = 0; while (*c >= '0' && *c <= '9') bitstart = (bitstart * 10) + *c++ - '0'; switch (*c) { case '-': { long reg; c++; while (*c >= '0' && *c <= '9') bitend = (bitend * 10) + *c++ - '0'; if (!bitend) abort (); reg = given >> bitstart; reg &= (2 << (bitend - bitstart)) - 1; switch (*c) { case 'r': func(stream, "%s", arm_regnames[reg]); break; case 'd': func(stream, "%ld", reg); break; case 'H': func(stream, "%ld", reg << 1); break; case 'W': func(stream, "%ld", reg << 2); break; case 'a': /* PC-relative address -- the bottom two bits of the address are dropped before the calculation. */ info->print_address_func (((pc + 4) & ~3) + (reg << 2), info); break; case 'x': func(stream, "0x%04lx", reg); break; case 'B': reg = ((reg ^ (1 << bitend)) - (1 << bitend)); info->print_address_func(reg * 2 + pc + 4, info); break; case 'c': { /* Must print 0xE as 'al' to distinguish unconditional B from conditional BAL. */ if (reg == 0xE) func(stream, "al"); else func(stream, "%s", arm_conditional [reg]); } break; default: abort (); } } break; case '\'': c++; if ((given & (1 << bitstart)) != 0) func(stream, "%c", *c); break; case '?': ++c; if ((given & (1 << bitstart)) != 0) func(stream, "%c", *c++); else func(stream, "%c", *++c); break; default: abort (); } } break; default: abort (); } } return; } /* No match. */ abort(); } /* Return the name of an V7M special register. */ static const char *psr_name (int regno) { switch (regno) { case 0: return "APSR"; case 1: return "IAPSR"; case 2: return "EAPSR"; case 3: return "PSR"; case 5: return "IPSR"; case 6: return "EPSR"; case 7: return "IEPSR"; case 8: return "MSP"; case 9: return "PSP"; case 16: return "PRIMASK"; case 17: return "BASEPRI"; case 18: return "BASEPRI_MASK"; case 19: return "FAULTMASK"; case 20: return "CONTROL"; default: return ""; } } /* Print one 32-bit Thumb instruction from PC on INFO->STREAM. */ static void print_insn_thumb32 (bfd_vma pc, struct disassemble_info *info, long given) { const struct opcode32 *insn; void *stream = info->stream; fprintf_ftype func = info->fprintf_func; if (print_insn_coprocessor (info, given, true)) return; for (insn = thumb32_opcodes; insn->assembler; insn++) if ((given & insn->mask) == insn->value) { const char *c = insn->assembler; for (; *c; c++) { if (*c != '%') { func(stream, "%c", *c); continue; } switch (*++c) { case '%': func(stream, "%%"); break; case 'I': { unsigned int imm12 = 0; imm12 |= (given & 0x000000ffu); imm12 |= (given & 0x00007000u) >> 4; imm12 |= (given & 0x04000000u) >> 15; func(stream, "#%u\t; 0x%x", imm12, imm12); } break; case 'M': { unsigned int bits = 0, imm, imm8, mod; bits |= (given & 0x000000ffu); bits |= (given & 0x00007000u) >> 4; bits |= (given & 0x04000000u) >> 15; imm8 = (bits & 0x0ff); mod = (bits & 0xf00) >> 8; switch (mod) { case 0: imm = imm8; break; case 1: imm = ((imm8<<16) | imm8); break; case 2: imm = ((imm8<<24) | (imm8 << 8)); break; case 3: imm = ((imm8<<24) | (imm8 << 16) | (imm8 << 8) | imm8); break; default: mod = (bits & 0xf80) >> 7; imm8 = (bits & 0x07f) | 0x80; imm = (((imm8 << (32 - mod)) | (imm8 >> mod)) & 0xffffffff); } func(stream, "#%u\t; 0x%x", imm, imm); } break; case 'J': { unsigned int imm = 0; imm |= (given & 0x000000ffu); imm |= (given & 0x00007000u) >> 4; imm |= (given & 0x04000000u) >> 15; imm |= (given & 0x000f0000u) >> 4; func(stream, "#%u\t; 0x%x", imm, imm); } break; case 'K': { unsigned int imm = 0; imm |= (given & 0x000f0000u) >> 16; imm |= (given & 0x00000ff0u) >> 0; imm |= (given & 0x0000000fu) << 12; func(stream, "#%u\t; 0x%x", imm, imm); } break; case 'S': { unsigned int reg = (given & 0x0000000fu); unsigned int stp = (given & 0x00000030u) >> 4; unsigned int imm = 0; imm |= (given & 0x000000c0u) >> 6; imm |= (given & 0x00007000u) >> 10; func(stream, "%s", arm_regnames[reg]); switch (stp) { case 0: if (imm > 0) func(stream, ", lsl #%u", imm); break; case 1: if (imm == 0) imm = 32; func(stream, ", lsr #%u", imm); break; case 2: if (imm == 0) imm = 32; func(stream, ", asr #%u", imm); break; case 3: if (imm == 0) func(stream, ", rrx"); else func(stream, ", ror #%u", imm); } } break; case 'a': { unsigned int Rn = (given & 0x000f0000) >> 16; unsigned int U = (given & 0x00800000) >> 23; unsigned int op = (given & 0x00000f00) >> 8; unsigned int i12 = (given & 0x00000fff); unsigned int i8 = (given & 0x000000ff); bool writeback = false, postind = false; int offset = 0; func(stream, "[%s", arm_regnames[Rn]); if (U) /* 12-bit positive immediate offset */ offset = i12; else if (Rn == 15) /* 12-bit negative immediate offset */ offset = -(int)i12; else if (op == 0x0) /* shifted register offset */ { unsigned int Rm = (i8 & 0x0f); unsigned int sh = (i8 & 0x30) >> 4; func(stream, ", %s", arm_regnames[Rm]); if (sh) func(stream, ", lsl #%u", sh); func(stream, "]"); break; } else switch (op) { case 0xE: /* 8-bit positive immediate offset */ offset = i8; break; case 0xC: /* 8-bit negative immediate offset */ offset = -i8; break; case 0xF: /* 8-bit + preindex with wb */ offset = i8; writeback = true; break; case 0xD: /* 8-bit - preindex with wb */ offset = -i8; writeback = true; break; case 0xB: /* 8-bit + postindex */ offset = i8; postind = true; break; case 0x9: /* 8-bit - postindex */ offset = -i8; postind = true; break; default: func(stream, ", ]"); goto skip; } if (postind) func(stream, "], #%d", offset); else { if (offset) func(stream, ", #%d", offset); func(stream, writeback ? "]!" : "]"); } if (Rn == 15) { func(stream, "\t; "); info->print_address_func(((pc + 4) & ~3) + offset, info); } } skip: break; case 'A': { unsigned int P = (given & 0x01000000) >> 24; unsigned int U = (given & 0x00800000) >> 23; unsigned int W = (given & 0x00400000) >> 21; unsigned int Rn = (given & 0x000f0000) >> 16; unsigned int off = (given & 0x000000ff); func(stream, "[%s", arm_regnames[Rn]); if (P) { if (off || !U) func(stream, ", #%c%u", U ? '+' : '-', off * 4); func(stream, "]"); if (W) func(stream, "!"); } else { func(stream, "], "); if (W) func(stream, "#%c%u", U ? '+' : '-', off * 4); else func(stream, "{%u}", off); } } break; case 'w': { unsigned int Sbit = (given & 0x01000000) >> 24; unsigned int type = (given & 0x00600000) >> 21; switch (type) { case 0: func(stream, Sbit ? "sb" : "b"); break; case 1: func(stream, Sbit ? "sh" : "h"); break; case 2: if (Sbit) func(stream, "??"); break; case 3: func(stream, "??"); break; } } break; case 'm': { int started = 0; int reg; func(stream, "{"); for (reg = 0; reg < 16; reg++) if ((given & (1 << reg)) != 0) { if (started) func(stream, ", "); started = 1; func(stream, "%s", arm_regnames[reg]); } func(stream, "}"); } break; case 'E': { unsigned int msb = (given & 0x0000001f); unsigned int lsb = 0; lsb |= (given & 0x000000c0u) >> 6; lsb |= (given & 0x00007000u) >> 10; func(stream, "#%u, #%u", lsb, msb - lsb + 1); } break; case 'F': { unsigned int width = (given & 0x0000001f) + 1; unsigned int lsb = 0; lsb |= (given & 0x000000c0u) >> 6; lsb |= (given & 0x00007000u) >> 10; func(stream, "#%u, #%u", lsb, width); } break; case 'b': { unsigned int S = (given & 0x04000000u) >> 26; unsigned int J1 = (given & 0x00002000u) >> 13; unsigned int J2 = (given & 0x00000800u) >> 11; int offset = 0; offset |= !S << 20; offset |= J2 << 19; offset |= J1 << 18; offset |= (given & 0x003f0000) >> 4; offset |= (given & 0x000007ff) << 1; offset -= (1 << 20); info->print_address_func(pc + 4 + offset, info); } break; case 'B': { unsigned int S = (given & 0x04000000u) >> 26; unsigned int I1 = (given & 0x00002000u) >> 13; unsigned int I2 = (given & 0x00000800u) >> 11; int offset = 0; offset |= !S << 24; offset |= !(I1 ^ S) << 23; offset |= !(I2 ^ S) << 22; offset |= (given & 0x03ff0000u) >> 4; offset |= (given & 0x000007ffu) << 1; offset -= (1 << 24); offset += pc + 4; /* BLX target addresses are always word aligned. */ if ((given & 0x00001000u) == 0) offset &= ~2u; info->print_address_func(offset, info); } break; case 's': { unsigned int shift = 0; shift |= (given & 0x000000c0u) >> 6; shift |= (given & 0x00007000u) >> 10; if (given & 0x00200000u) func(stream, ", asr #%u", shift); else if (shift) func(stream, ", lsl #%u", shift); /* else print nothing - lsl #0 */ } break; case 'R': { unsigned int rot = (given & 0x00000030) >> 4; if (rot) func(stream, ", ror #%u", rot * 8); } break; case 'U': switch (given & 0xf) { case 0xf: func(stream, "sy"); break; case 0x7: func(stream, "un"); break; case 0xe: func(stream, "st"); break; case 0x6: func(stream, "unst"); break; default: func(stream, "#%d", (int)given & 0xf); break; } break; case 'C': if ((given & 0xff) == 0) { func(stream, "%cPSR_", (given & 0x100000) ? 'S' : 'C'); if (given & 0x800) func(stream, "f"); if (given & 0x400) func(stream, "s"); if (given & 0x200) func(stream, "x"); if (given & 0x100) func(stream, "c"); } else { func(stream, psr_name (given & 0xff)); } break; case 'D': if ((given & 0xff) == 0) func(stream, "%cPSR", (given & 0x100000) ? 'S' : 'C'); else func(stream, psr_name (given & 0xff)); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { int bitstart = *c++ - '0'; int bitend = 0; unsigned int val; while (*c >= '0' && *c <= '9') bitstart = (bitstart * 10) + *c++ - '0'; if (*c == '-') { c++; while (*c >= '0' && *c <= '9') bitend = (bitend * 10) + *c++ - '0'; if (!bitend) abort (); val = given >> bitstart; val &= (2 << (bitend - bitstart)) - 1; } else val = (given >> bitstart) & 1; switch (*c) { case 'd': func(stream, "%u", val); break; case 'W': func(stream, "%u", val * 4); break; case 'r': func(stream, "%s", arm_regnames[val]); break; case 'c': if (val == 0xE) func(stream, "al"); else func(stream, "%s", arm_conditional[val]); break; case '\'': if (val) func(stream, "%c", c[1]); c++; break; case '`': if (!val) func(stream, "%c", c[1]); c++; break; case '?': func(stream, "%c", val ? c[1] : c[2]); c += 2; break; default: abort (); } } break; default: abort (); } } return; } /* No match. */ abort (); } /* Disallow mapping symbols ($a, $b, $d, $t etc) from being displayed in symbol relative addresses. */ bool arm_symbol_is_valid (asymbol * sym, struct disassemble_info * info ATTRIBUTE_UNUSED) { const char * name; if (sym == NULL) return false; name = bfd_asymbol_name(sym); return (name && *name != '$'); } /* NOTE: There are no checks in these routines that the relevant number of data bytes exist. */ static int print_insn(bfd_vma pc, struct disassemble_info *info, bool little) { unsigned char b[4]; long given; int status; bool is_thumb; int size; void (*printer) (bfd_vma, struct disassemble_info *, long); is_thumb = force_thumb; #if 0 if (!is_thumb && info->symbols != NULL) { if (bfd_asymbol_flavour (*info->symbols) == bfd_target_coff_flavour) { coff_symbol_type * cs; cs = coffsymbol (*info->symbols); is_thumb = ( cs->native->u.syment.n_sclass == C_THUMBEXT || cs->native->u.syment.n_sclass == C_THUMBSTAT || cs->native->u.syment.n_sclass == C_THUMBLABEL || cs->native->u.syment.n_sclass == C_THUMBEXTFUNC || cs->native->u.syment.n_sclass == C_THUMBSTATFUNC); } else if (bfd_asymbol_flavour (*info->symbols) == bfd_target_elf_flavour) { elf_symbol_type * es; unsigned int type; es = *(elf_symbol_type **)(info->symbols); type = ELF_ST_TYPE (es->internal_elf_sym.st_info); is_thumb = (type == STT_ARM_TFUNC) || (type == STT_ARM_16BIT); } } #endif info->display_endian = little ? BFD_ENDIAN_LITTLE : BFD_ENDIAN_BIG; info->bytes_per_line = 4; if (!is_thumb) { /* In ARM mode endianness is a straightforward issue: the instruction is four bytes long and is either ordered 0123 or 3210. */ printer = print_insn_arm; info->bytes_per_chunk = 4; size = 4; status = info->read_memory_func(pc, (bfd_byte *)b, 4, info); if (little) { given = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24); } else { given = (b[3]) | (b[2] << 8) | (b[1] << 16) | (b[0] << 24); } } else { /* In Thumb mode we have the additional wrinkle of two instruction lengths. Fortunately, the bits that determine the length of the current instruction are always to be found in the first two bytes. */ printer = print_insn_thumb16; info->bytes_per_chunk = 2; size = 2; status = info->read_memory_func(pc, (bfd_byte *)b, 2, info); if (little) { given = (b[0]) | (b[1] << 8); } else { given = (b[1]) | (b[0] << 8); } if (!status) { /* These bit patterns signal a four-byte Thumb instruction. */ if ((given & 0xF800) == 0xF800 || (given & 0xF800) == 0xF000 || (given & 0xF800) == 0xE800) { status = info->read_memory_func(pc + 2, (bfd_byte *)b, 2, info); if (little) { given = (b[0]) | (b[1] << 8) | (given << 16); } else { given = (b[1]) | (b[0] << 8) | (given << 16); } printer = print_insn_thumb32; size = 4; } } } if (status) { info->memory_error_func(status, pc, info); return -1; } if (info->flags & INSN_HAS_RELOC) { /* If the instruction has a reloc associated with it, then the offset field in the instruction will actually be the addend for the reloc. (We are using REL type relocs). In such cases, we can ignore the pc when computing addresses, since the addend is not currently pc-relative. */ pc = 0; } printer (pc, info, given); return size; } int print_insn_big_arm(bfd_vma pc, struct disassemble_info *info) { return print_insn (pc, info, false); } int print_insn_little_arm(bfd_vma pc, struct disassemble_info *info) { return print_insn (pc, info, true); } ht-2.0.22/asm/alphadis.cc0000644000175000017500000002666512156426561012034 00000000000000/* * HT Editor * alphadis.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "alphadis.h" #include "alphaopc.h" #include "htdebug.h" #include "tools.h" #include #include #define BITS_OPC(opcode) ((opcode >> 26) & 0x3f) #define BITS_FFUN(opcode) ((opcode >> 5) & 0x7ff) #define BITS_IFUN(opcode) ((opcode >> 5) & 0x7f) #define BITS_MFUN(opcode) (opcode & 0xffff) #define BITS_JFUN(opcode) ((opcode >> 14) & 0x3) #define BITS_ISLIT(opcode) ((opcode >> 12) & 0x1) #define BITS_IMMED(opcode) ((opcode >> 13) & 0xff) #define BITS_REGA(opcode) ((opcode >> 21) & 0x1f) #define BITS_REGB(opcode) ((opcode >> 16) & 0x1f) #define BITS_REGC(opcode) (opcode & 0x1f) #define BITS_BDISP(opcode) (opcode & 0x1fffff) #define BITS_BSIGN(opcode) (opcode & 0x100000) #define BITS_MDISP(opcode) (opcode & 0xffff) #define BITS_MSIGN(opcode) (opcode & 0x8000) #define BITS_PAL(opcode) (opcode & 0x3ffffff) #define BITS_HINT(opcode) (opcode & 0x3fff) /* only needed for assembler.. */ #define MAKE_OPC(opcode) ((opcode & 0x3f) << 26) #define MAKE_FFUN(opcode) ((opcode & 0x7ff) << 5) #define MAKE_IFUN(opcode) ((opcode & 0x7f) << 5) #define MAKE_MFUN(opcode) (opcode & 0xffff) #define MAKE_JFUN(opcode) ((opcode & 0x3) << 14) #define MAKE_LIT (1<<12) #define MAKE_IMMED(opcode) ((opcode & 0xff) << 13 ) #define MAKE_REGA(opcode) ((opcode & 0x1f) << 21) #define MAKE_REGB(opcode) ((opcode & 0x1f) << 16) #define MAKE_REGC(opcode) (opcode & 0x1f) #define MAKE_BDISP(opcode) (opcode & 0x1fffff) #define MAKE_MDISP(opcode) (opcode & 0xffff) #define MAKE_PAL(opcode) (opcode & 0x3ffffff) #define MAKE_HINT(opcode) (opcode & 0x3fff) Alphadis::Alphadis() :Disassembler() { insn.valid = false; } int find_alpha_instruction(alpha_opcode_tab_entry *table, int f) { int i=0; while (f > (table+i)->fcode) i++; return i; } dis_insn *Alphadis::decode(byte *code, int maxlen, CPU_ADDR addr) { // alpha code instructions must be 32 bits long if (maxlen < 4) { // invalid insn.valid = false; insn.size = maxlen; insn.table = 0; // FIXME: this reads too many bytes! memcpy(&insn.data, code, sizeof(insn.data)); } else { insn.valid = true; insn.size = 4; insn.table = &alpha_instr_tbl[0]; uint32 opcode = *((uint32 *)code); int idx = BITS_OPC(opcode); switch (alpha_instr_tbl[idx].type) { case ALPHA_EXTENSION_10: idx = find_alpha_instruction(&alpha_instr_tbl_ext10[0], BITS_IFUN(opcode)); insn.table = &alpha_instr_tbl_ext10[0]; break; case ALPHA_EXTENSION_11: idx = find_alpha_instruction(&alpha_instr_tbl_ext11[0], BITS_IFUN(opcode)); insn.table = &alpha_instr_tbl_ext11[0]; break; case ALPHA_EXTENSION_12: idx = find_alpha_instruction(&alpha_instr_tbl_ext12[0], BITS_IFUN(opcode)); insn.table = &alpha_instr_tbl_ext12[0]; break; case ALPHA_EXTENSION_13: idx = find_alpha_instruction(&alpha_instr_tbl_ext13[0], BITS_IFUN(opcode)); insn.table = &alpha_instr_tbl_ext13[0]; break; case ALPHA_EXTENSION_14: idx = find_alpha_instruction(&alpha_instr_tbl_ext14[0], BITS_FFUN(opcode)); insn.table = &alpha_instr_tbl_ext14[0]; break; case ALPHA_EXTENSION_15: idx = find_alpha_instruction(&alpha_instr_tbl_ext15[0], BITS_FFUN(opcode)); insn.table = &alpha_instr_tbl_ext15[0]; break; case ALPHA_EXTENSION_16: idx = find_alpha_instruction(&alpha_instr_tbl_ext16[0], BITS_FFUN(opcode)); insn.table = &alpha_instr_tbl_ext16[0]; break; case ALPHA_EXTENSION_17: idx = find_alpha_instruction(&alpha_instr_tbl_ext17[0], BITS_FFUN(opcode)); insn.table = &alpha_instr_tbl_ext17[0]; break; case ALPHA_EXTENSION_18: idx = find_alpha_instruction(&alpha_instr_tbl_ext18[0], BITS_MFUN(opcode)); insn.table = &alpha_instr_tbl_ext18[0]; break; case ALPHA_EXTENSION_1A: idx = find_alpha_instruction(&alpha_instr_tbl_ext1a[0], BITS_JFUN(opcode)); insn.table = &alpha_instr_tbl_ext1a[0]; break; case ALPHA_EXTENSION_1C: idx = find_alpha_instruction(&alpha_instr_tbl_ext1c[0], BITS_IFUN(opcode)); insn.table = &alpha_instr_tbl_ext1c[0]; break; } insn.code = idx; switch ((insn.table+idx)->type) { case ALPHA_GROUP1: insn.regA = BITS_REGA(opcode); insn.regC = BITS_REGC(opcode); if (BITS_ISLIT(opcode)) { insn.regB = REG_LIT; insn.data = BITS_IMMED(opcode); } else { insn.regB = BITS_REGB(opcode); insn.data = 0; } break; case ALPHA_GROUP2: insn.regA = BITS_REGA(opcode) + REG_FLOAT; insn.regB = BITS_REGB(opcode) + REG_FLOAT; insn.regC = BITS_REGC(opcode) + REG_FLOAT; insn.data = 0; break; case ALPHA_GROUP3: insn.regA = BITS_REGA(opcode); insn.regB = BITS_REGB(opcode); insn.regC = REG_ZERO; insn.data = BITS_MDISP(opcode); if (BITS_MSIGN(insn.data)) insn.data |= -1 ^ 0xffff; break; case ALPHA_GROUP_FLD: insn.regA = BITS_REGA(opcode) + REG_FLOAT; insn.regB = BITS_REGB(opcode); insn.regC = REG_ZERO; insn.data = BITS_MDISP(opcode); if (BITS_MSIGN(insn.data)) insn.data |= -1 ^ 0xffff; break; case ALPHA_GROUP4: insn.regA = BITS_REGA(opcode); insn.regB = BITS_REGB(opcode); insn.regC = REG_ZERO; insn.data = BITS_MDISP(opcode); if (BITS_MSIGN(insn.data)) insn.data |= -1 ^ 0xffff; break; case ALPHA_GROUP_FST: insn.regA = BITS_REGA(opcode) + REG_FLOAT; insn.regB = BITS_REGB(opcode); insn.regC = REG_ZERO; insn.data = BITS_MDISP(opcode); if (BITS_MSIGN(insn.data)) insn.data |= -1 ^ 0xffff; break; case ALPHA_GROUP_F2I: insn.regA = BITS_REGA(opcode) + REG_FLOAT; insn.regB = REG_ZERO; insn.regC = BITS_REGC(opcode); insn.data = 0; break; case ALPHA_GROUP_I2F: insn.regA = BITS_REGA(opcode); insn.regB = REG_ZERO; insn.regC = BITS_REGC(opcode) + REG_FLOAT; insn.data = 0; break; case ALPHA_GROUP_BRA: insn.regA = BITS_REGA(opcode); insn.regB = REG_ZERO; insn.regC = REG_ZERO; insn.data = BITS_BDISP(opcode); if (BITS_BSIGN(insn.data)) insn.data |= -1 ^ 0x1fffff; insn.data += 1; insn.data *= 4; insn.address = sint64(insn.data) + addr.flat64.addr; break; case ALPHA_GROUP_FBR: insn.regA = BITS_REGA(opcode) + REG_FLOAT; insn.regB = REG_ZERO; insn.regC = REG_ZERO; insn.data = BITS_BDISP(opcode); if (BITS_BSIGN(insn.data)) insn.data |= -1 ^ 0x1fffff; insn.data += 1; insn.data *= 4; insn.address = sint64(insn.data) + addr.flat64.addr; break; case ALPHA_GROUP_JMP: insn.regA = BITS_REGA(opcode); insn.regB = BITS_REGB(opcode); insn.regC = REG_ZERO; insn.data = BITS_HINT(opcode); insn.address = sint64(insn.data); break; case ALPHA_GROUP_PAL: insn.regA = REG_ZERO; insn.regB = REG_ZERO; insn.regC = REG_ZERO; insn.data = BITS_PAL(opcode); break; default: insn.valid = false; insn.data = *(uint32 *)code; break; } } return &insn; } dis_insn *Alphadis::duplicateInsn(dis_insn *disasm_insn) { alphadis_insn *insn = ht_malloc(sizeof (alphadis_insn)); *insn = *(alphadis_insn *)disasm_insn; return insn; } void Alphadis::getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align) { min_length = 4; max_length = 4; min_look_ahead = 4; avg_look_ahead = 4; addr_align = 4; } const char *Alphadis::getName() { return "alpha/disassembler"; } byte Alphadis::getSize(dis_insn *disasm_insn) { return ((alphadis_insn*)disasm_insn)->size; } ObjectID Alphadis::getObjectID() const { return ATOM_DISASM_ALPHA; } const char *Alphadis::str(dis_insn *disasm_insn, int style) { return strf(disasm_insn, style, ""); } #define A_REG_A alpha_reg_names[alpha_insn->regA] #define A_REG_B alpha_reg_names[alpha_insn->regB] #define A_REG_C alpha_reg_names[alpha_insn->regC] #define A_NAME (alpha_insn->table+alpha_insn->code)->name const char *Alphadis::strf(dis_insn *disasm_insn, int style, const char *format) { if (style & DIS_STYLE_HIGHLIGHT) enable_highlighting(); const char *cs_default = get_cs(e_cs_default); const char *cs_number = get_cs(e_cs_number); const char *cs_symbol = get_cs(e_cs_symbol); alphadis_insn *alpha_insn = (alphadis_insn *) disasm_insn; if (!alpha_insn->valid) { is_invalid: switch (alpha_insn->size) { case 1: strcpy(insnstr, "db ?"); break; case 2: strcpy(insnstr, "dw ?"); break; case 3: strcpy(insnstr, "db ? * 3"); break; case 4: sprintf(insnstr, "dd %s0x%08x", cs_number, alpha_insn->data); break; default: { /* braces for empty assert */ assert(0); } } } else switch ((alpha_insn->table+alpha_insn->code)->type) { case ALPHA_GROUP1: case ALPHA_GROUP2: if (alpha_insn->regB != REG_LIT) sprintf(insnstr, "%-10s %s%s,%s %s%s,%s %s", A_NAME, A_REG_A, cs_symbol, cs_default, A_REG_B, cs_symbol, cs_default, A_REG_C); else sprintf(insnstr, "%-10s %s%s,%s %s0x%x%s,%s %s", A_NAME, A_REG_A, cs_symbol, cs_default, cs_number, alpha_insn->data, cs_symbol, cs_default, A_REG_C); break; case ALPHA_GROUP3: case ALPHA_GROUP_FLD: case ALPHA_GROUP4: case ALPHA_GROUP_FST: { short sdata = (short)(alpha_insn->data&0xffff); char c; if (sdata<0) { c = '-'; sdata = -sdata; } else { c = '+'; } sprintf(insnstr, "%-10s %s%s, [%s%s%s%c%s0x%x%s]", A_NAME, A_REG_A, cs_symbol, cs_default, A_REG_B, cs_symbol, c, cs_number, sdata, cs_symbol); break; } case ALPHA_GROUP_I2F: case ALPHA_GROUP_F2I: sprintf(insnstr, "%-10s %s%s,%s %s", A_NAME, A_REG_A, cs_symbol, cs_default, A_REG_C); break; case ALPHA_GROUP_BRA: case ALPHA_GROUP_FBR: { CPU_ADDR caddr; caddr.flat64.addr = alpha_insn->address; int slen; char *p; char *s = (addr_sym_func) ? addr_sym_func(caddr, &slen, addr_sym_func_context) : 0; if (s) { p = insnstr+sprintf(insnstr, "%-10s %s%s,%s ", A_NAME, A_REG_A, cs_symbol, cs_default); memmove(p, s, slen); p[slen] = 0; } else { sprintf(insnstr, "%-10s %s%s, %s0x%qx", A_NAME, A_REG_A, cs_symbol, cs_number, &alpha_insn->address); } break; } case ALPHA_GROUP_JMP: { CPU_ADDR caddr; caddr.flat64.addr = alpha_insn->address; int slen; char *s = (addr_sym_func) ? addr_sym_func(caddr, &slen, addr_sym_func_context) : 0; if (s) { char *p = insnstr + sprintf(insnstr, "%-10s %s %s(%s%s%s),%s ", A_NAME, A_REG_A, cs_symbol, cs_default, A_REG_B, cs_symbol, cs_default); memmove(p, s, slen); p[slen] = 0; } else { sprintf(insnstr, "%-10s %s %s(%s%s%s), %s0x%x", A_NAME, A_REG_A, cs_symbol, cs_default, A_REG_B, cs_symbol, cs_number, (uint32)alpha_insn->data); } break; } case ALPHA_GROUP_PAL: sprintf(insnstr, "%-10s %s0x%08x", A_NAME, cs_number, alpha_insn->data); break; default: goto is_invalid; } disable_highlighting(); return insnstr; } bool Alphadis::validInsn(dis_insn *disasm_insn) { return ((alphadis_insn *)disasm_insn)->valid; } ht-2.0.22/asm/javadis.h0000644000175000001440000000540310636023333011500 00000000000000/* * HT Editor * javadis.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __JAVADIS_H__ #define __JAVADIS_H__ #include "asm.h" #include "javaopc.h" /* x86-specific styles */ //#define X86DIS_STYLE_EXPLICIT_MEMSIZE 0x00000001 /* IF SET: mov uint16 ptr [0000], ax ELSE: mov [0000], ax */ //#define X86DIS_STYLE_OPTIMIZE_ADDR 0x00000002 /* IF SET: mov [eax*3], ax ELSE: mov [eax+eax*2+00000000], ax */ /*#define X86DIS_STYLE_USE16 0x00000004 #define X86DIS_STYLE_USE32 0x00000008*/ struct javadis_insn { bool invalid; int size; int opcode; uint32 addr; bool wideopcode; const char *name; java_insn_op op[JAVAINSN_MAX_PARAM_COUNT]; }; /* * CLASS x86dis */ typedef int (*java_token_func)(char *result, int maxlen, uint32 token, void *context); class javadis: public Disassembler { protected: javadis_insn insn; char insnstr[1024]; /* initme! */ unsigned char *codep, *ocodep; int maxlen; java_token_func token_func; void *context; uint32 addr; /* new */ void decode_insn(javaopc_insn *insn); void decode_op(int optype, bool wideopc, java_insn_op *op); byte getbyte(); uint16 getword(); uint32 getdword(); void invalidate(); void str_format(char **str, const char **format, const char *p, const char *n, char *op[3], int oplen[3], char stopchar, int print); virtual void str_op(char *opstr, int *opstrlen, javadis_insn *insn, java_insn_op *op); public: javadis(BuildCtorArg&a): Disassembler(a) {}; javadis(java_token_func token_func, void *context); void initialize(java_token_func token_func, void *context); /* overwritten */ virtual dis_insn *decode(byte *code, int maxlen, CPU_ADDR addr); virtual dis_insn *duplicateInsn(dis_insn *disasm_insn); virtual void getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align); virtual const char *getName(); virtual byte getSize(dis_insn *disasm_insn); virtual ObjectID getObjectID() const; virtual const char *str(dis_insn *disasm_insn, int options); virtual const char *strf(dis_insn *disasm_insn, int options, const char *format); virtual bool validInsn(dis_insn *disasm_insn); }; #endif /* __JAVADIS_H__ */ ht-2.0.22/asm/javadis.cc0000644000175000001440000002217010636023333011636 00000000000000/* * HT Editor * javadis.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "stream.h" #include "tools.h" #include "javadis.h" #include "strtools.h" /* * CLASS javadis */ javadis::javadis(java_token_func tf, void *c) { initialize(tf, c); } void javadis::initialize(java_token_func tf, void *c) { token_func = tf; context = c; } dis_insn *javadis::decode(byte *code, int Maxlen, CPU_ADDR Addr) { ocodep = code; codep = ocodep; maxlen = Maxlen; memset(&insn, 0, sizeof insn); addr = Addr.addr32.offset; insn.addr = Addr.addr32.offset; insn.invalid = false; insn.opcode = getbyte(); if (insn.opcode == JAVA_WIDE_OPCODE) { insn.wideopcode = true; insn.opcode = getbyte(); } else { insn.wideopcode = false; } decode_insn(&java_insns[insn.opcode]); if (insn.invalid) { insn.name = "db"; insn.size = 1; insn.op[0].type = JAVA_OPTYPE_IMM; insn.op[0].size = 1; insn.op[0].imm = *code; for (int i=1; i < JAVAINSN_MAX_PARAM_COUNT; i++) insn.op[i].type=JAVA_OPTYPE_EMPTY; } else { insn.size = codep-ocodep; } return &insn; } void javadis::decode_insn(javaopc_insn *xinsn) { if (!xinsn->name) { invalidate(); return; } insn.name = xinsn->name; for (int i=0; ioptype[i], insn.wideopcode, &insn.op[i]); } } void javadis::decode_op(int optype, bool wideopc, java_insn_op *op) { bool widesize = wideopc || (JOPC_SIZE(optype) == JOPC_SIZE_WIDE); switch (JOPC_TYPE(optype)) { case JOPC_TYPE_BYTE: op->type = JAVA_OPTYPE_IMM; op->size = 1; op->imm = getbyte(); break; case JOPC_TYPE_CHAR: op->type = JAVA_OPTYPE_IMM; op->size = 1; op->imm = sint8(getbyte()); break; case JOPC_TYPE_SHORT: op->type = JAVA_OPTYPE_IMM; op->size = 2; op->imm = sint16(getword()); break; case JOPC_TYPE_SIMM: op->type = JAVA_OPTYPE_IMM; if (widesize) { op->size = 2; op->imm = sint16(getword()); } else { op->size = 1; op->imm = sint8(getbyte()); } break; case JOPC_TYPE_CONST: op->type = JAVA_OPTYPE_CONST; if (widesize) { op->size = 2; op->imm = getword(); } else { op->size = 1; op->imm = getbyte(); } break; case JOPC_TYPE_LOCAL: op->type = JAVA_OPTYPE_IMM; if (widesize) { op->size = 2; op->imm = getword(); } else { op->size = 1; op->imm = getbyte(); } break; case JOPC_TYPE_LABEL: op->type = JAVA_OPTYPE_LABEL; if (widesize) { op->size = 4; op->label = addr - 2; op->label += sint32(getdword()); } else { op->size = 2; op->label = addr - 1; op->label += sint16(getword()); } break; case JOPC_TYPE_ATYPE: op->type = JAVA_OPTYPE_ATYPE; op->size = 1; op->imm = getbyte(); break; default: op->type = JAVA_OPTYPE_EMPTY; } } dis_insn *javadis::duplicateInsn(dis_insn *disasm_insn) { javadis_insn *insn = ht_malloc(sizeof (javadis_insn)); *insn = *(javadis_insn *)disasm_insn; return insn; } byte javadis::getbyte() { if (codep-ocodep+1<=maxlen) { addr++; return *(codep++); } else { invalidate(); return 0; } } uint16 javadis::getword() { if (codep-ocodep+2<=maxlen) { uint16 w; addr += 2; w = codep[1] | (codep[0]<<8); codep += 2; return w; } else { invalidate(); return 0; } } uint32 javadis::getdword() { if (codep-ocodep+4<=maxlen) { uint32 w; addr += 4; w = codep[3] | (codep[2]<<8) | (codep[1]<<16) | (codep[0]<<24); codep += 4; return w; } else { invalidate(); return 0; } } void javadis::getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align) { min_length = 1; max_length = 6; min_look_ahead = 120; avg_look_ahead = 24; addr_align = 1; } const char *javadis::getName() { return "Java/Disassembler"; } byte javadis::getSize(dis_insn *disasm_insn) { return ((javadis_insn*)disasm_insn)->size; } void javadis::invalidate() { insn.invalid = true; } ObjectID javadis::getObjectID() const { return ATOM_DISASM_JAVA; } void javadis::str_op(char *opstr, int *opstrlen, javadis_insn *insn, java_insn_op *op) { const char *cs_default = get_cs(e_cs_default); const char *cs_number = get_cs(e_cs_number); // const char *cs_symbol = get_cs(e_cs_symbol); const char *cs_comment = get_cs(e_cs_comment); char *opstrold = opstr; switch (op->type) { case JAVA_OPTYPE_CONST: { strcpy(opstr, cs_comment); opstr += strlen(cs_comment); opstr += token_func(opstr, 1024, op->imm, context); *opstr++ = ' '; strcpy(opstr, cs_number); opstr += strlen(cs_number); switch (op->size) { case 1: hexd(&opstr, 2, options, op->imm); break; case 2: hexd(&opstr, 4, options, op->imm); break; case 4: hexd(&opstr, 8, options, op->imm); break; } break; } case JAVA_OPTYPE_LABEL: { CPU_ADDR a; a.addr32.offset = op->imm; int slen; char *s = (addr_sym_func) ? addr_sym_func(a, &slen, addr_sym_func_context) : NULL; if (s) { memcpy(opstr, s, slen); opstr[slen]=0; opstr += slen; } else { strcpy(opstr, cs_number); opstr += strlen(cs_number); switch (op->size) { case 1: hexd(&opstr, 2, options, op->imm); break; case 2: hexd(&opstr, 4, options, op->imm); break; case 4: hexd(&opstr, 8, options, op->imm); break; } strcpy(opstr, cs_default); opstr += strlen(cs_default); } break; } case JAVA_OPTYPE_IMM: { CPU_ADDR a; a.addr32.offset=op->imm; strcpy(opstr, cs_number); opstr += strlen(cs_number); switch (op->size) { case 1: hexd(&opstr, 2, options, op->imm); break; case 2: hexd(&opstr, 4, options, op->imm); break; case 4: hexd(&opstr, 8, options, op->imm); break; } strcpy(opstr, cs_default); opstr += strlen(cs_default); break; } case JAVA_OPTYPE_ATYPE: { const char *atypes[] = {"boolean", "char", "float", "double", "byte", "short", "int", "long"}; strcpy(opstr, cs_comment); opstr += strlen(cs_comment); if (op->imm >= 4 && op->imm <= 11) { *(opstr++) = '<'; opstr += ht_strlcpy(opstr, atypes[op->imm - 4], 8); *(opstr++) = '>'; *(opstr++) = 0; } else { strcpy(opstr, ""); } break; } default: opstr[0]=0; } *opstrlen = opstr - opstrold; } void javadis::str_format(char **str, const char **format, const char *p, const char *n, char *op[3], int oplen[3], char stopchar, int print) { const char *cs_default = get_cs(e_cs_default); const char *cs_symbol = get_cs(e_cs_symbol); const char *f = *format; char *s = *str; while (*f) { if (*f == stopchar) break; switch (*f) { case '\t': if (print) do *s++ = ' '; while ((s-insnstr) % 16); break; case DISASM_STRF_VAR: f++; if (print) { const char *t = NULL; int tl = 0; switch (*f) { case DISASM_STRF_PREFIX: t=p; break; case DISASM_STRF_NAME: t=n; break; case DISASM_STRF_FIRST: t=op[0]; tl=oplen[0]; break; case DISASM_STRF_SECOND: t=op[1]; tl=oplen[1]; break; case DISASM_STRF_THIRD: t=op[2]; tl=oplen[2]; break; } if (tl) { memcpy(s, t, tl); s += tl; *s = 0; } else { strcpy(s, t); s += strlen(s); } } break; case DISASM_STRF_COND: { const char *t = NULL; f++; switch (*f) { case DISASM_STRF_PREFIX: t=p; break; case DISASM_STRF_NAME: t=n; break; case DISASM_STRF_FIRST: t=op[0]; break; case DISASM_STRF_SECOND: t=op[1]; break; case DISASM_STRF_THIRD: t=op[2]; break; } f += 2; str_format(&s, &f, p, n, op, oplen, *(f-1), t && t[0]); break; } default: if (print) { bool x = (strchr(",.-=+-*/[]()", *f) != NULL) && *f; if (x) { strcpy(s, cs_symbol); s += strlen(cs_symbol); } *(s++) = *f; if (x) { strcpy(s, cs_default); s += strlen(cs_default); } } } f++; } *s = 0; *format = f; *str = s; } const char *javadis::str(dis_insn *disasm_insn, int options) { return strf(disasm_insn, options, DISASM_STRF_DEFAULT_FORMAT); } const char *javadis::strf(dis_insn *disasm_insn, int opt, const char *format) { javadis_insn *insn = (javadis_insn*)disasm_insn; char prefix[64]; char *p = prefix; options = opt; *p = 0; char ops[3][512]; /* FIXME: possible buffer overflow ! */ char *op[3]; int oplen[3]; if (options & DIS_STYLE_HIGHLIGHT) enable_highlighting(); for (int i=0; i < JAVAINSN_MAX_PARAM_COUNT; i++) { op[i] = ops[i]; str_op(op[i], &oplen[i], insn, &insn->op[i]); } char *s = insnstr; str_format(&s, &format, prefix, insn->name, op, oplen, 0, 1); disable_highlighting(); return insnstr; } bool javadis::validInsn(dis_insn *disasm_insn) { return !((javadis_insn *)disasm_insn)->invalid; } ht-2.0.22/asm/dis-asm.h0000644000175000001440000002624510615342570011427 00000000000000/* Interface between the opcode library and its callers. Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. Written by Cygnus Support, 1993. The opcode library (libopcodes.a) provides instruction decoders for a large variety of instruction sets, callable with an identical interface, for making instruction-processing programs more independent of the instruction set being processed. */ #ifndef DIS_ASM_H #define DIS_ASM_H #include #define ATTRIBUTE_FPTR_PRINTF_2 #define ATTRIBUTE_UNUSED enum bfd_flavour {dummy1}; enum bfd_architecture {dummy2}; enum bfd_endian {BFD_ENDIAN_LITTLE, BFD_ENDIAN_BIG}; #define asection void #define asymbol void typedef unsigned bfd_vma; typedef unsigned char bfd_byte; typedef int bfd; #define bfd_mach_arm_XScale 1 #define bfd_mach_arm_iWMMXt 2 #define bfd_asymbol_name(x) "?" #define ISSPACE(x) 0 #define _(X) X typedef int (*fprintf_ftype) (void *, const char*, ...) ATTRIBUTE_FPTR_PRINTF_2; enum dis_insn_type { dis_noninsn, /* Not a valid instruction */ dis_nonbranch, /* Not a branch instruction */ dis_branch, /* Unconditional branch */ dis_condbranch, /* Conditional branch */ dis_jsr, /* Jump to subroutine */ dis_condjsr, /* Conditional jump to subroutine */ dis_dref, /* Data reference instruction */ dis_dref2 /* Two data references in instruction */ }; /* This struct is passed into the instruction decoding routine, and is passed back out into each callback. The various fields are used for conveying information from your main routine into your callbacks, for passing information into the instruction decoders (such as the addresses of the callback functions), or for passing information back from the instruction decoders to their callers. It must be initialized before it is first passed; this can be done by hand, or using one of the initialization macros below. */ typedef struct disassemble_info { fprintf_ftype fprintf_func; void *stream; void *application_data; /* Target description. We could replace this with a pointer to the bfd, but that would require one. There currently isn't any such requirement so to avoid introducing one we record these explicitly. */ /* The bfd_flavour. This can be bfd_target_unknown_flavour. */ enum bfd_flavour flavour; /* The bfd_arch value. */ enum bfd_architecture arch; /* The bfd_mach value. */ unsigned long mach; /* Endianness (for bi-endian cpus). Mono-endian cpus can ignore this. */ enum bfd_endian endian; /* An arch/mach-specific bitmask of selected instruction subsets, mainly for processors with run-time-switchable instruction sets. The default, zero, means that there is no constraint. CGEN-based opcodes ports may use ISA_foo masks. */ void *insn_sets; /* Some targets need information about the current section to accurately display insns. If this is NULL, the target disassembler function will have to make its best guess. */ asection *section; /* An array of pointers to symbols either at the location being disassembled or at the start of the function being disassembled. The array is sorted so that the first symbol is intended to be the one used. The others are present for any misc. purposes. This is not set reliably, but if it is not NULL, it is correct. */ asymbol **symbols; /* Number of symbols in array. */ int num_symbols; /* For use by the disassembler. The top 16 bits are reserved for public use (and are documented here). The bottom 16 bits are for the internal use of the disassembler. */ unsigned long flags; #define INSN_HAS_RELOC 0x80000000 void *private_data; /* Function used to get bytes to disassemble. MEMADDR is the address of the stuff to be disassembled, MYADDR is the address to put the bytes in, and LENGTH is the number of bytes to read. INFO is a pointer to this struct. Returns an errno value or 0 for success. */ int (*read_memory_func) (bfd_vma memaddr, bfd_byte *myaddr, unsigned int length, struct disassemble_info *info); /* Function which should be called if we get an error that we can't recover from. STATUS is the errno value from read_memory_func and MEMADDR is the address that we were trying to read. INFO is a pointer to this struct. */ void (*memory_error_func) (int status, bfd_vma memaddr, struct disassemble_info *info); /* Function called to print ADDR. */ void (*print_address_func) (bfd_vma addr, struct disassemble_info *info); /* Function called to determine if there is a symbol at the given ADDR. If there is, the function returns 1, otherwise it returns 0. This is used by ports which support an overlay manager where the overlay number is held in the top part of an address. In some circumstances we want to include the overlay number in the address, (normally because there is a symbol associated with that address), but sometimes we want to mask out the overlay bits. */ int (* symbol_at_address_func) (bfd_vma addr, struct disassemble_info * info); /* Function called to check if a SYMBOL is can be displayed to the user. This is used by some ports that want to hide special symbols when displaying debugging outout. */ bool (* symbol_is_valid) (asymbol *, struct disassemble_info * info); /* These are for buffer_read_memory. */ bfd_byte *buffer; bfd_vma buffer_vma; unsigned int buffer_length; /* This variable may be set by the instruction decoder. It suggests the number of bytes objdump should display on a single line. If the instruction decoder sets this, it should always set it to the same value in order to get reasonable looking output. */ int bytes_per_line; /* The next two variables control the way objdump displays the raw data. */ /* For example, if bytes_per_line is 8 and bytes_per_chunk is 4, the */ /* output will look like this: 00: 00000000 00000000 with the chunks displayed according to "display_endian". */ int bytes_per_chunk; enum bfd_endian display_endian; /* Number of octets per incremented target address Normally one, but some DSPs have byte sizes of 16 or 32 bits. */ unsigned int octets_per_byte; /* The number of zeroes we want to see at the end of a section before we start skipping them. */ unsigned int skip_zeroes; /* The number of zeroes to skip at the end of a section. If the number of zeroes at the end is between SKIP_ZEROES_AT_END and SKIP_ZEROES, they will be disassembled. If there are fewer than SKIP_ZEROES_AT_END, they will be skipped. This is a heuristic attempt to avoid disassembling zeroes inserted by section alignment. */ unsigned int skip_zeroes_at_end; /* Whether the disassembler always needs the relocations. */ bool disassembler_needs_relocs; /* Results from instruction decoders. Not all decoders yet support this information. This info is set each time an instruction is decoded, and is only valid for the last such instruction. To determine whether this decoder supports this information, set insn_info_valid to 0, decode an instruction, then check it. */ char insn_info_valid; /* Branch info has been set. */ char branch_delay_insns; /* How many sequential insn's will run before a branch takes effect. (0 = normal) */ char data_size; /* Size of data reference in insn, in bytes */ enum dis_insn_type insn_type; /* Type of instruction */ bfd_vma target; /* Target address of branch or dref, if known; zero if unknown. */ bfd_vma target2; /* Second target address for dref2 */ /* Command line options specific to the target disassembler. */ char * disassembler_options; } disassemble_info; /* Standard disassemblers. Disassemble one instruction at the given target address. Return number of octets processed. */ typedef int (*disassembler_ftype)(bfd_vma, disassemble_info *); extern int print_insn_big_arm(bfd_vma, disassemble_info *); extern int print_insn_little_arm(bfd_vma, disassemble_info *); extern disassembler_ftype arc_get_disassembler(void *); extern disassembler_ftype cris_get_disassembler(bfd *); extern void print_arm_disassembler_options(FILE *); extern void parse_arm_disassembler_option(char *); extern int get_arm_regname_num_options(void); extern int set_arm_regname_option(int); extern int get_arm_regnames(int, const char **, const char **, const char *const **); extern bool arm_symbol_is_valid(asymbol *, struct disassemble_info *); /* Fetch the disassembler for a given BFD, if that support is available. */ extern disassembler_ftype disassembler(bfd *); /* Amend the disassemble_info structure as necessary for the target architecture. Should only be called after initialising the info->arch field. */ extern void disassemble_init_for_target(struct disassemble_info * info); /* Document any target specific options available from the disassembler. */ extern void disassembler_usage(FILE *); /* This block of definitions is for particular callers who read instructions into a buffer before calling the instruction decoder. */ /* Here is a function which callers may wish to use for read_memory_func. It gets bytes from a buffer. */ extern int buffer_read_memory (bfd_vma, bfd_byte *, unsigned int, struct disassemble_info *); /* This function goes with buffer_read_memory. It prints a message using info->fprintf_func and info->stream. */ extern void perror_memory (int, bfd_vma, struct disassemble_info *); /* Just print the address in hex. This is included for completeness even though both GDB and objdump provide their own (to print symbolic addresses). */ extern void generic_print_address(bfd_vma, struct disassemble_info *); /* Always true. */ extern int generic_symbol_at_address(bfd_vma, struct disassemble_info *); /* Also always true. */ extern bool generic_symbol_is_valid(asymbol *, struct disassemble_info *); /* Method to initialize a disassemble_info struct. This should be called by all applications creating such a struct. */ extern void init_disassemble_info (struct disassemble_info *info, void *stream, fprintf_ftype fprintf_func); /* For compatibility with existing code. */ #define INIT_DISASSEMBLE_INFO(INFO, STREAM, FPRINTF_FUNC) \ init_disassemble_info (&(INFO), (STREAM), (fprintf_ftype) (FPRINTF_FUNC)) #define INIT_DISASSEMBLE_INFO_NO_ARCH(INFO, STREAM, FPRINTF_FUNC) \ init_disassemble_info (&(INFO), (STREAM), (fprintf_ftype) (FPRINTF_FUNC)) #endif /* ! defined (DIS_ASM_H) */ ht-2.0.22/asm/alphaopc.h0000644000175000001440000000464610615342401011653 00000000000000/* * HT Editor * alphaopc.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ALPHAOPC_H #define ALPHAOPC_H #include "io/types.h" struct alpha_opcode_tab_entry { uint16 fcode; const char *name; byte type; }; extern const char *alpha_reg_names[]; extern alpha_opcode_tab_entry alpha_instr_tbl[]; extern alpha_opcode_tab_entry alpha_instr_tbl_ext10[]; extern alpha_opcode_tab_entry alpha_instr_tbl_ext11[]; extern alpha_opcode_tab_entry alpha_instr_tbl_ext12[]; extern alpha_opcode_tab_entry alpha_instr_tbl_ext13[]; extern alpha_opcode_tab_entry alpha_instr_tbl_ext14[]; extern alpha_opcode_tab_entry alpha_instr_tbl_ext15[]; extern alpha_opcode_tab_entry alpha_instr_tbl_ext16[]; extern alpha_opcode_tab_entry alpha_instr_tbl_ext17[]; extern alpha_opcode_tab_entry alpha_instr_tbl_ext18[]; extern alpha_opcode_tab_entry alpha_instr_tbl_ext1a[]; extern alpha_opcode_tab_entry alpha_instr_tbl_ext1c[]; #define REG_ZERO 0x1f #define REG_FLOAT 0x20 #define REG_FZERO 0x3f #define REG_LIT 0x40 /* unknown/undefined/illegal opcode */ #define ALPHA_ERROR 0 /* extensions */ #define ALPHA_EXTENSION_10 100 #define ALPHA_EXTENSION_11 101 #define ALPHA_EXTENSION_12 102 #define ALPHA_EXTENSION_13 103 #define ALPHA_EXTENSION_14 104 #define ALPHA_EXTENSION_15 105 #define ALPHA_EXTENSION_16 106 #define ALPHA_EXTENSION_17 107 #define ALPHA_EXTENSION_18 108 #define ALPHA_EXTENSION_1A 109 #define ALPHA_EXTENSION_1C 110 /* opcode groups somehow without system */ #define ALPHA_GROUP1 200 #define ALPHA_GROUP2 201 #define ALPHA_GROUP3 202 #define ALPHA_GROUP_FLD 203 #define ALPHA_GROUP4 204 #define ALPHA_GROUP_FST 205 #define ALPHA_GROUP_F2I 206 #define ALPHA_GROUP_I2F 207 #define ALPHA_GROUP_BRA 208 #define ALPHA_GROUP_FBR 209 #define ALPHA_GROUP_JMP 210 #define ALPHA_GROUP_PAL 211 #endif ht-2.0.22/asm/asm.h0000644000175000001440000001340210775014730010642 00000000000000/* * The HT Editor * asm.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __ASM_H__ #define __ASM_H__ #include "data.h" #define MAX_INSN_SIZE 16 struct CPU_ADDR { union { struct { uint16 seg; uint32 offset; } addr32; struct { uint64 addr; } flat64; }; }; struct asm_code { asm_code *next; int size; byte data[MAX_INSN_SIZE]; void *context; }; typedef void dis_insn; typedef void asm_insn; /* * CLASS assembler */ class Assembler: public Object { protected: int (*imm_eval_proc)(void *context, const char *s, uint64 &v); void *imm_eval_context; asm_code *codes; asm_code code; char error_msg[256]; bool error; int options; bool bigendian; void emitbyte(byte b); void emitword(uint16 w); void emitdword(uint32 d); void emitqword(uint64 q); void free_asm_codes(); void deletecode(asm_code *c); void clearcode(); void newcode(); void pushcode(); public: Assembler(bool bigendian); Assembler(BuildCtorArg&a): Object(a) {}; virtual ~Assembler(); /* new */ virtual asm_insn *alloc_insn(); virtual asm_code *encode(asm_insn *asm_insn, int options, CPU_ADDR cur_address); const char *get_error_msg(); virtual const char *get_name(); virtual bool translate_str(asm_insn *asm_insn, const char *s) = 0; void set_error_msg(const char *format, ...); void set_imm_eval_proc(int (*imm_eval_proc)(void *context, const char *s, uint64 &v), void *imm_eval_context); asm_code *shortest(asm_code *codes); }; /* * CLASS disassembler */ /* generic disassembler styles */ #define DIS_STYLE_HIGHLIGHT 0x80000000 /* create highlighting information in strf() */ #define DIS_STYLE_HEX_CSTYLE 0x40000000 /* IF SET: mov eax, 0x12345678 ELSE: mov eax, 12345678 */ #define DIS_STYLE_HEX_ASMSTYLE 0x20000000 /* IF SET: mov eax, 12345678h ELSE: mov eax, 12345678 */ #define DIS_STYLE_HEX_UPPERCASE 0x10000000 /* IF SET: mov eax, 5678ABCD ELSE: mov eax, 5678abcd */ #define DIS_STYLE_HEX_NOZEROPAD 0x08000000 /* IF SET: mov eax, 8002344 ELSE: mov eax, 008002344 */ #define DIS_STYLE_SIGNED 0x04000000 /* IF SET: mov eax, -1 ELSE: mov eax, 0ffffffffh */ #define DIS_STYLE_TABSIZE 12 extern char* (*addr_sym_func)(CPU_ADDR addr, int *symstrlen, void *context); extern void* addr_sym_func_context; enum AsmSyntaxHighlightEnum { e_cs_default=0, e_cs_comment, e_cs_number, e_cs_symbol, e_cs_string }; class Disassembler: public Object { protected: int options; bool highlight; const char *get_cs(AsmSyntaxHighlightEnum style); void hexd(char **s, int size, int options, uint32 imm); void hexq(char **s, int size, int options, uint64 imm); void enable_highlighting(); void disable_highlighting(); public: Disassembler(); Disassembler(BuildCtorArg&a): Object(a) {}; void load(ObjectStream &f); /* new */ virtual dis_insn *createInvalidInsn(); virtual dis_insn *decode(byte *code, int maxlen, CPU_ADDR cur_address)=0; virtual dis_insn *duplicateInsn(dis_insn *disasm_insn)=0; virtual void getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align)=0; virtual byte getSize(dis_insn *disasm_insn)=0; virtual const char *getName()=0; virtual bool selectNext(dis_insn *disasm_insn); virtual const char *str(dis_insn *disasm_insn, int style); virtual const char *strf(dis_insn *disasm_insn, int style, const char *format)=0; virtual bool validInsn(dis_insn *disasm_insn)=0; }; /***************************************************************************** * The strf() format * ***************************************************************************** String Action -------------------------------------------------- %x substitute expression with symbol "x" ?xy...y if symbol "x" is undefined leave out the whole expression, otherwise subsitute expression with string between the two "y"s Symbol Desc -------------------------------------------------- p prefix n name 1 first operand 2 second operand 3 third operand 4 forth operand */ #define DISASM_STRF_VAR '%' #define DISASM_STRF_COND '?' #define DISASM_STRF_PREFIX 'p' #define DISASM_STRF_NAME 'n' #define DISASM_STRF_FIRST '1' #define DISASM_STRF_SECOND '2' #define DISASM_STRF_THIRD '3' #define DISASM_STRF_FORTH '4' #define DISASM_STRF_FIFTH '5' //#define DISASM_STRF_DEFAULT_FORMAT "?p#%p #%n\t%1?2#, %2?3/, %3/?4-, %4-#" #define DISASM_STRF_DEFAULT_FORMAT "?p#%p #%n\t%1?2#, %2#?3#, %3#?4#, %4#?5#, %5#" #define DISASM_STRF_SMALL_FORMAT "?p#%p #%n?1# %1#?2#,%2#?3#,%3#?4#,%4#?5#,%5#" #define ATOM_DISASM_X86 MAGIC32("DIS\x01") #define ATOM_DISASM_ALPHA MAGIC32("DIS\x02") #define ATOM_DISASM_JAVA MAGIC32("DIS\x03") #define ATOM_DISASM_IA64 MAGIC32("DIS\x04") #define ATOM_DISASM_IL MAGIC32("DIS\x05") #define ATOM_DISASM_X86_VXD MAGIC32("DIS\x06") #define ATOM_DISASM_PPC MAGIC32("DIS\x07") #define ATOM_DISASM_X86_64 MAGIC32("DIS\x08") #define ATOM_DISASM_ARM MAGIC32("DIS\x09") #define ASM_SYNTAX_DEFAULT "\\@d" #define ASM_SYNTAX_COMMENT "\\@#" #define ASM_SYNTAX_NUMBER "\\@n" #define ASM_SYNTAX_SYMBOL "\\@c" #define ASM_SYNTAX_STRING "\\@s" bool init_asm(); void done_asm(); #endif /* __ASM_H__ */ ht-2.0.22/asm/armdis.h0000644000175000001440000000204410615342570011340 00000000000000#ifndef ARMDIS_20060407_H #define ARMDIS_20060407_H #include "asm.h" struct ArmDisInsn { bool invalid; bool iscond; byte size; unsigned offset; char opstr[100]; }; class ArmDisassembler : public Disassembler { class BFDInterface; BFDInterface *bfdif; protected: ArmDisInsn insn; virtual dis_insn *decode(byte *code, int maxlen, CPU_ADDR addr); virtual dis_insn *duplicateInsn(dis_insn *disasm_insn); virtual void getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align); virtual byte getSize(dis_insn *disasm_insn); virtual const char *getName(); virtual const char *strf(dis_insn *disasm_insn, int style, const char *format); virtual ObjectID getObjectID() const; virtual bool validInsn(dis_insn *disasm_insn); public: ArmDisassembler(); ArmDisassembler(BuildCtorArg&a): Disassembler(a) {}; void load(ObjectStream &f); }; #endif ht-2.0.22/asm/ppcopc.h0000644000175000001440000002255610615342402011351 00000000000000/* * HT Editor * ppcopc.cc * * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) * Copyright 1994, 1995, 1999, 2000, 2001, 2002 * Free Software Foundation, Inc. * Written by Ian Lance Taylor, Cygnus Support * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __PPC_OPC_H__ #define __PPC_OPC_H__ #include "io/types.h" /* The opcode table is an array of struct powerpc_opcode. */ struct powerpc_opcode { /* The opcode name. */ const char *name; /* The opcode itself. Those bits which will be filled in with operands are zeroes. */ uint32 opcode; /* The opcode mask. This is used by the disassembler. This is a mask containing ones indicating those bits which must match the opcode field, and zeroes indicating those bits which need not match (and are presumably filled in by operands). */ uint32 mask; /* One bit flags for the opcode. These are used to indicate which specific processors support the instructions. The defined values are listed below. */ uint32 flags; /* An array of operand codes. Each code is an index into the operand table. They appear in the order which the operands must appear in assembly code, and are terminated by a zero. */ byte operands[8]; }; /* The table itself is sorted by major opcode number, and is otherwise in the order in which the disassembler should consider instructions. */ extern const struct powerpc_opcode powerpc_opcodes[]; extern const int powerpc_num_opcodes; /* Values defined for the flags field of a struct powerpc_opcode. */ /* Opcode is defined for the PowerPC architecture. */ #define PPC_OPCODE_PPC (01) /* Opcode is defined for the POWER (RS/6000) architecture. */ #define PPC_OPCODE_POWER (02) /* Opcode is defined for the POWER2 (Rios 2) architecture. */ #define PPC_OPCODE_POWER2 (04) /* Opcode is only defined on 32 bit architectures. */ #define PPC_OPCODE_32 (010) /* Opcode is only defined on 64 bit architectures. */ #define PPC_OPCODE_64 (020) /* Opcode is supported by the Motorola PowerPC 601 processor. The 601 is assumed to support all PowerPC (PPC_OPCODE_PPC) instructions, but it also supports many additional POWER instructions. */ #define PPC_OPCODE_601 (040) /* Opcode is supported in both the Power and PowerPC architectures (ie, compiler's -mcpu=common or assembler's -mcom). */ #define PPC_OPCODE_COMMON (0100) /* Opcode is supported for any Power or PowerPC platform (this is for the assembler's -many option, and it eliminates duplicates). */ #define PPC_OPCODE_ANY (0200) /* Opcode is supported as part of the 64-bit bridge. */ #define PPC_OPCODE_64_BRIDGE (0400) /* Opcode is supported by Altivec Vector Unit */ #define PPC_OPCODE_ALTIVEC (01000) /* Opcode is supported by PowerPC 403 processor. */ #define PPC_OPCODE_403 (02000) /* Opcode is supported by PowerPC BookE processor. */ #define PPC_OPCODE_BOOKE (04000) /* Opcode is only supported by 64-bit PowerPC BookE processor. */ #define PPC_OPCODE_BOOKE64 (010000) /* Opcode is only supported by Power4 architecture. */ #define PPC_OPCODE_POWER4 (020000) /* Opcode isn't supported by Power4 architecture. */ #define PPC_OPCODE_NOPOWER4 (040000) /* Opcode is only supported by POWERPC Classic architecture. */ #define PPC_OPCODE_CLASSIC (0100000) /* Opcode is only supported by e500x2 Core. */ #define PPC_OPCODE_SPE (0200000) /* Opcode is supported by e500x2 Integer select APU. */ #define PPC_OPCODE_ISEL (0400000) /* Opcode is an e500 SPE floating point instruction. */ #define PPC_OPCODE_EFS (01000000) /* Opcode is supported by branch locking APU. */ #define PPC_OPCODE_BRLOCK (02000000) /* Opcode is supported by performance monitor APU. */ #define PPC_OPCODE_PMR (04000000) /* Opcode is supported by cache locking APU. */ #define PPC_OPCODE_CACHELCK (010000000) /* Opcode is supported by machine check APU. */ #define PPC_OPCODE_RFMCI (020000000) /* A macro to extract the major opcode from an instruction. */ #define PPC_OP(i) (((i) >> 26) & 0x3f) /* The operands table is an array of struct powerpc_operand. */ struct powerpc_operand { /* The number of bits in the operand. */ byte bits; /* How far the operand is left shifted in the instruction. */ byte shift; /* Extraction function. This is used by the disassembler. To extract this operand type from an instruction, check this field. If it is NULL, compute op = ((i) >> o->shift) & ((1 << o->bits) - 1); if ((o->flags & PPC_OPERAND_SIGNED) != 0 && (op & (1 << (o->bits - 1))) != 0) op -= 1 << o->bits; (i is the instruction, o is a pointer to this structure, and op is the result; this assumes twos complement arithmetic). If this field is not NULL, then simply call it with the instruction value. It will return the value of the operand. If the INVALID argument is not NULL, *INVALID will be set to non-zero if this operand type can not actually be extracted from this operand (i.e., the instruction does not match). If the operand is valid, *INVALID will not be changed. */ uint32 (*extract)(uint32 instruction, bool *invalid); /* One bit syntax flags. */ uint32 flags; }; /* Elements in the table are retrieved by indexing with values from the operands field of the powerpc_opcodes table. */ extern const struct powerpc_operand powerpc_operands[]; /* Values defined for the flags field of a struct powerpc_operand. */ /* This operand takes signed values. */ #define PPC_OPERAND_SIGNED (01) /* This operand takes signed values, but also accepts a full positive range of values when running in 32 bit mode. That is, if bits is 16, it takes any value from -0x8000 to 0xffff. In 64 bit mode, this flag is ignored. */ #define PPC_OPERAND_SIGNOPT (02) /* This operand does not actually exist in the assembler input. This is used to support extended mnemonics such as mr, for which two operands fields are identical. The assembler should call the insert function with any op value. The disassembler should call the extract function, ignore the return value, and check the value placed in the valid argument. */ #define PPC_OPERAND_FAKE (04) /* The next operand should be wrapped in parentheses rather than separated from this one by a comma. This is used for the load and store instructions which want their operands to look like reg,displacement(reg) */ #define PPC_OPERAND_PARENS (010) /* This operand may use the symbolic names for the CR fields, which are lt 0 gt 1 eq 2 so 3 un 3 cr0 0 cr1 1 cr2 2 cr3 3 cr4 4 cr5 5 cr6 6 cr7 7 These may be combined arithmetically, as in cr2*4+gt. These are only supported on the PowerPC, not the POWER. */ #define PPC_OPERAND_CR (020) /* This operand names a register. The disassembler uses this to print register names with a leading 'r'. */ #define PPC_OPERAND_GPR (040) /* Like PPC_OPERAND_GPR, but don't print a leading 'r' for r0. */ #define PPC_OPERAND_GPR_0 (0100) /* This operand names a floating point register. The disassembler prints these with a leading 'f'. */ #define PPC_OPERAND_FPR (0200) /* This operand is a relative branch displacement. The disassembler prints these symbolically if possible. */ #define PPC_OPERAND_RELATIVE (0400) /* This operand is an absolute branch address. The disassembler prints these symbolically if possible. */ #define PPC_OPERAND_ABSOLUTE (01000) /* This operand is optional, and is zero if omitted. This is used for the optional BF and L fields in the comparison instructions. The assembler must count the number of operands remaining on the line, and the number of operands remaining for the opcode, and decide whether this operand is present or not. The disassembler should print this operand out only if it is not zero. */ #define PPC_OPERAND_OPTIONAL (02000) /* This flag is only used with PPC_OPERAND_OPTIONAL. If this operand is omitted, then for the next operand use this operand value plus 1, ignoring the next operand field for the opcode. This wretched hack is needed because the Power rotate instructions can take either 4 or 5 operands. The disassembler should print this operand out regardless of the PPC_OPERAND_OPTIONAL field. */ #define PPC_OPERAND_NEXT (04000) /* This operand should be regarded as a negative number for the purposes of overflow checking (i.e., the normal most negative number is disallowed and one more than the normal most positive number is allowed). This flag will only be set for a signed operand. */ #define PPC_OPERAND_NEGATIVE (010000) /* This operand names a vector unit register. The disassembler prints these with a leading 'v'. */ #define PPC_OPERAND_VR (020000) /* This operand is for the DS field in a DS form instruction. */ #define PPC_OPERAND_DS (040000) /* This operand is for the DQ field in a DQ form instruction. */ #define PPC_OPERAND_DQ (0100000) #endif ht-2.0.22/asm/Makefile.am0000644000175000017500000000107011724770100011742 00000000000000AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/io/${IO_DIR} \ -I$(top_srcdir)/io AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_LIBRARIES = libasm.a libasm_a_SOURCES = alphadis.cc alphadis.h alphaopc.cc alphaopc.h\ asm.cc asm.h x86asm.cc x86asm.h x86dis.cc x86dis.h x86opc.cc x86opc.h\ javadis.cc javadis.h javaopc.cc javaopc.h ildis.cc ildis.h \ ilopc.cc ilopc.h ia64dis.cc ia64dis.h ia64opc.cc ia64opc.h \ ppcopc.cc ppcopc.h ppcdis.cc ppcdis.h armdis.cc armdis.h \ arm-dis.cc dis-asm.h arm.h ht-2.0.22/asm/armdis.cc0000644000175000001440000001150510615342570011500 00000000000000#include #include "armdis.h" #include "snprintf.h" #include "dis-asm.h" class ArmDisassembler::BFDInterface { disassemble_info di; char *pos; char buf[4]; ArmDisInsn *insn; static int read_mem(bfd_vma, bfd_byte *myaddr, unsigned int length, disassemble_info *info) { BFDInterface *thiz = static_cast(info->application_data); memcpy(myaddr, thiz->buf, length); return 0; } static void mem_err(int, bfd_vma, disassemble_info *) {} static void paf(bfd_vma addr, disassemble_info *info) { BFDInterface *thiz = static_cast(info->application_data); thiz->insn->offset = addr; bfdif_printf(info->stream, "@"); } static int bfdif_printf(void *s, const char *fmt, ...) { BFDInterface *thiz = static_cast(s); va_list ap; unsigned siz = sizeof(thiz->insn->opstr) - (thiz->pos - thiz->insn->opstr); va_start(ap, fmt); int n = ht_vsnprintf(thiz->pos, siz, fmt, ap); thiz->pos += n; va_end(ap); return n; } public: BFDInterface() { memset(&di, 0, sizeof(di)); di.fprintf_func = bfdif_printf; di.stream = this; di.endian = BFD_ENDIAN_LITTLE; di.read_memory_func = read_mem; di.print_address_func = paf; di.application_data = this; } void Decode(byte *code, int maxlen, unsigned addr, ArmDisInsn *insn_) { memset(buf, 0, sizeof(buf)); memcpy(buf, code, maxlen > 4 ? 4 : maxlen); insn = insn_; pos = insn->opstr; insn->offset = ~0U; // little endian specific insn->iscond = (unsigned) buf[3] < 0xe0; print_insn_little_arm(addr, &di); // FILE *f=fopen("/tmp/htlog","a");fprintf(f,"%s\n",insn->opstr);fclose(f); } }; ArmDisassembler::ArmDisassembler() { bfdif = new BFDInterface; } void ArmDisassembler::load(ObjectStream &f) { bfdif = new BFDInterface; Disassembler::load(f); } dis_insn *ArmDisassembler::duplicateInsn(dis_insn *disasm_insn) { ArmDisInsn *insn = (ArmDisInsn *) malloc(sizeof(ArmDisInsn)); *insn = *(ArmDisInsn *)disasm_insn; return insn; } void ArmDisassembler::getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align) { min_length = 4; max_length = 4; min_look_ahead = 4; avg_look_ahead = 4; addr_align = 4; } byte ArmDisassembler::getSize(dis_insn *disasm_insn) { return 4;//((ArmDisInsn*)disasm_insn)->size; } const char *ArmDisassembler::getName() { return "Arm/Disassembler"; } ObjectID ArmDisassembler::getObjectID() const { return ATOM_DISASM_ARM; } bool ArmDisassembler::validInsn(dis_insn *disasm_insn) { return true; ArmDisInsn *adi = static_cast(disasm_insn); return memcmp(adi->opstr, "undefined", 9) != 0; } dis_insn *ArmDisassembler::decode(byte *code, int maxlen, CPU_ADDR addr) { bfdif->Decode(code, maxlen, addr.addr32.offset, &insn); #if 0 char *pc; if (insn.offset == ~0u && (pc = strstr(insn.opstr, ", pc, #")) != 0) insn.offset = atol(pc + 7); #endif return &insn; } const char *ArmDisassembler::strf(dis_insn *disasm_insn, int style, const char *) { ArmDisInsn *adi = static_cast(disasm_insn); if (style & DIS_STYLE_HIGHLIGHT) enable_highlighting(); //const char *cs_default = get_cs(e_cs_default); const char *cs_number = get_cs(e_cs_number); //const char *cs_symbol = get_cs(e_cs_symbol); static char buf[512]; char *out = buf; const char *in = adi->opstr; while (in[0] && in[0] != '\t') *out++ = *in++; if (!in[0]) goto strfend; in++; // skip tab while (out < buf + 12) *out++ = ' '; while (*in && *in != ';') { if (*in != '@') { *out++ = *in++; } else { in++; CPU_ADDR caddr; caddr.addr32.offset = adi->offset; int slen; char *s = (addr_sym_func) ? addr_sym_func(caddr, &slen, addr_sym_func_context) : 0; if (s) { if (out + slen > buf + sizeof(buf) - 1) slen = buf + sizeof(buf) - 1 - out; memcpy(out, s, slen); out[slen] = 0; out += slen; } else { out += sprintf(out, "%s0x%x", cs_number, adi->offset); } } } if (*in == ';' && out[-1] == '\t') out--; { char *p = strstr(buf, "[pc, #"); if (p && adi->offset != ~0u) { CPU_ADDR caddr; caddr.addr32.offset = adi->offset; int slen; char *s = (addr_sym_func) ? addr_sym_func(caddr, &slen, addr_sym_func_context) : 0; if (s) { if (out + slen > buf + sizeof(buf) - 1) slen = buf + sizeof(buf) - 1 - out; memcpy(out = p, s, slen); out += slen; } } } strfend: *out = 0; disable_highlighting(); return buf; } ht-2.0.22/asm/ilopc.cc0000644000175000001440000003042010615342402011316 00000000000000/* * HT Editor * ilopc.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "io/types.h" #include "ilopc.h" ILOpcodeTabEntry il_opcode_table[MAX_IL_OPCODE] = { {"nop", IL_OPCODE_ARGS_NONE, 1}, {"break", IL_OPCODE_ARGS_NONE, 1}, {"ldarg.0", IL_OPCODE_ARGS_NONE, 1}, {"ldarg.1", IL_OPCODE_ARGS_NONE, 1}, {"ldarg.2", IL_OPCODE_ARGS_NONE, 1}, {"ldarg.3", IL_OPCODE_ARGS_NONE, 1}, {"ldloc.0", IL_OPCODE_ARGS_NONE, 1}, {"ldloc.1", IL_OPCODE_ARGS_NONE, 1}, {"ldloc.2", IL_OPCODE_ARGS_NONE, 1}, {"ldloc.3", IL_OPCODE_ARGS_NONE, 1}, {"stloc.0", IL_OPCODE_ARGS_NONE, 1}, {"stloc.1", IL_OPCODE_ARGS_NONE, 1}, {"stloc.2", IL_OPCODE_ARGS_NONE, 1}, {"stloc.3", IL_OPCODE_ARGS_NONE, 1}, {"ldarg.s", IL_OPCODE_ARGS_SHORT_ARG, 2}, {"ldarga.s", IL_OPCODE_ARGS_SHORT_ARG, 2}, {"starg.s", IL_OPCODE_ARGS_SHORT_ARG, 2}, {"ldloc.s", IL_OPCODE_ARGS_SHORT_VAR, 2}, {"ldloca.s", IL_OPCODE_ARGS_SHORT_VAR, 2}, {"stloc.s", IL_OPCODE_ARGS_SHORT_VAR, 2}, {"ldnull", IL_OPCODE_ARGS_NONE, 1}, {"ldc.i4.m1", IL_OPCODE_ARGS_NONE, 1}, {"ldc.i4.0", IL_OPCODE_ARGS_NONE, 1}, {"ldc.i4.1", IL_OPCODE_ARGS_NONE, 1}, {"ldc.i4.2", IL_OPCODE_ARGS_NONE, 1}, {"ldc.i4.3", IL_OPCODE_ARGS_NONE, 1}, {"ldc.i4.4", IL_OPCODE_ARGS_NONE, 1}, {"ldc.i4.5", IL_OPCODE_ARGS_NONE, 1}, {"ldc.i4.6", IL_OPCODE_ARGS_NONE, 1}, {"ldc.i4.7", IL_OPCODE_ARGS_NONE, 1}, {"ldc.i4.8", IL_OPCODE_ARGS_NONE, 1}, {"ldc.i4.s", IL_OPCODE_ARGS_INT8, 2}, {"ldc.i4", IL_OPCODE_ARGS_INT32, 5}, {"ldc.i8", IL_OPCODE_ARGS_INT64, 9}, {"ldc.r4", IL_OPCODE_ARGS_FLOAT32, 5}, {"ldc.r8", IL_OPCODE_ARGS_FLOAT64, 9}, {"ldptr", IL_OPCODE_ARGS_INT32, 5}, {"dup", IL_OPCODE_ARGS_NONE, 1}, {"pop", IL_OPCODE_ARGS_NONE, 1}, {"jmp", IL_OPCODE_ARGS_CALL, 5}, {"call", IL_OPCODE_ARGS_CALL, 5}, {"calli", IL_OPCODE_ARGS_CALLI, 5}, {"ret", IL_OPCODE_ARGS_NONE, 1}, {"br.s", IL_OPCODE_ARGS_SHORT_JUMP, 2}, {"brfalse.s", IL_OPCODE_ARGS_SHORT_JUMP, 2}, {"brtrue.s", IL_OPCODE_ARGS_SHORT_JUMP, 2}, {"beq.s", IL_OPCODE_ARGS_SHORT_JUMP, 2}, {"bge.s", IL_OPCODE_ARGS_SHORT_JUMP, 2}, {"bgt.s", IL_OPCODE_ARGS_SHORT_JUMP, 2}, {"ble.s", IL_OPCODE_ARGS_SHORT_JUMP, 2}, {"blt.s", IL_OPCODE_ARGS_SHORT_JUMP, 2}, {"bne.un.s", IL_OPCODE_ARGS_SHORT_JUMP, 2}, {"bge.un.s", IL_OPCODE_ARGS_SHORT_JUMP, 2}, {"bgt.un.s", IL_OPCODE_ARGS_SHORT_JUMP, 2}, {"ble.un.s", IL_OPCODE_ARGS_SHORT_JUMP, 2}, {"blt.un.s", IL_OPCODE_ARGS_SHORT_JUMP, 2}, {"br", IL_OPCODE_ARGS_LONG_JUMP, 5}, {"brfalse", IL_OPCODE_ARGS_LONG_JUMP, 5}, {"brtrue", IL_OPCODE_ARGS_LONG_JUMP, 5}, {"beq", IL_OPCODE_ARGS_LONG_JUMP, 5}, {"bge", IL_OPCODE_ARGS_LONG_JUMP, 5}, {"bgt", IL_OPCODE_ARGS_LONG_JUMP, 5}, {"ble", IL_OPCODE_ARGS_LONG_JUMP, 5}, {"blt", IL_OPCODE_ARGS_LONG_JUMP, 5}, {"bne.un", IL_OPCODE_ARGS_LONG_JUMP, 5}, {"bge.un", IL_OPCODE_ARGS_LONG_JUMP, 5}, {"bgt.un", IL_OPCODE_ARGS_LONG_JUMP, 5}, {"ble.un", IL_OPCODE_ARGS_LONG_JUMP, 5}, {"blt.un", IL_OPCODE_ARGS_LONG_JUMP, 5}, {"switch", IL_OPCODE_ARGS_SWITCH, 5}, // must be at least 5 bytes long {"ldind.i1", IL_OPCODE_ARGS_NONE, 1}, {"ldind.u1", IL_OPCODE_ARGS_NONE, 1}, {"ldind.i2", IL_OPCODE_ARGS_NONE, 1}, {"ldind.u2", IL_OPCODE_ARGS_NONE, 1}, {"ldind.i4", IL_OPCODE_ARGS_NONE, 1}, {"ldind.u4", IL_OPCODE_ARGS_NONE, 1}, {"ldind.i8", IL_OPCODE_ARGS_NONE, 1}, {"ldind.i", IL_OPCODE_ARGS_NONE, 1}, {"ldind.r4", IL_OPCODE_ARGS_NONE, 1}, {"ldind.r8", IL_OPCODE_ARGS_NONE, 1}, {"ldind.ref", IL_OPCODE_ARGS_NONE, 1}, {"stind.ref", IL_OPCODE_ARGS_NONE, 1}, {"stind.i1", IL_OPCODE_ARGS_NONE, 1}, {"stind.i2", IL_OPCODE_ARGS_NONE, 1}, {"stind.i4", IL_OPCODE_ARGS_NONE, 1}, {"stind.i8", IL_OPCODE_ARGS_NONE, 1}, {"stind.r4", IL_OPCODE_ARGS_NONE, 1}, {"stind.r8", IL_OPCODE_ARGS_NONE, 1}, {"add", IL_OPCODE_ARGS_NONE, 1}, {"sub", IL_OPCODE_ARGS_NONE, 1}, {"mul", IL_OPCODE_ARGS_NONE, 1}, {"div", IL_OPCODE_ARGS_NONE, 1}, {"div.un", IL_OPCODE_ARGS_NONE, 1}, {"rem", IL_OPCODE_ARGS_NONE, 1}, {"rem.un", IL_OPCODE_ARGS_NONE, 1}, {"and", IL_OPCODE_ARGS_NONE, 1}, {"or", IL_OPCODE_ARGS_NONE, 1}, {"xor", IL_OPCODE_ARGS_NONE, 1}, {"shl", IL_OPCODE_ARGS_NONE, 1}, {"shr", IL_OPCODE_ARGS_NONE, 1}, {"shr.un", IL_OPCODE_ARGS_NONE, 1}, {"neg", IL_OPCODE_ARGS_NONE, 1}, {"not", IL_OPCODE_ARGS_NONE, 1}, {"conv.i1", IL_OPCODE_ARGS_NONE, 1}, {"conv.i2", IL_OPCODE_ARGS_NONE, 1}, {"conv.i4", IL_OPCODE_ARGS_NONE, 1}, {"conv.i8", IL_OPCODE_ARGS_NONE, 1}, {"conv.r4", IL_OPCODE_ARGS_NONE, 1}, {"conv.r8", IL_OPCODE_ARGS_NONE, 1}, {"conv.u4", IL_OPCODE_ARGS_NONE, 1}, {"conv.u8", IL_OPCODE_ARGS_NONE, 1}, {"callvirt", IL_OPCODE_ARGS_CALLVIRT, 5}, {"cpobj", IL_OPCODE_ARGS_TOKEN, 5}, {"ldobj", IL_OPCODE_ARGS_TOKEN, 5}, {"ldstr", IL_OPCODE_ARGS_STRING, 5}, {"newobj", IL_OPCODE_ARGS_NEW, 5}, {"castclass", IL_OPCODE_ARGS_TOKEN, 5}, {"isinst", IL_OPCODE_ARGS_TOKEN, 5}, {"conv.r.un", IL_OPCODE_ARGS_NONE, 1}, {"ann.data.s", IL_OPCODE_ARGS_ANN_DATA_S, 2}, // // must be at least 2 bytes long {NULL, IL_OPCODE_ARGS_INVALID, 1}, // 0x78 {"unbox", IL_OPCODE_ARGS_TOKEN, 5}, {"throw", IL_OPCODE_ARGS_NONE, 1}, {"ldfld", IL_OPCODE_ARGS_TOKEN, 5}, {"ldflda", IL_OPCODE_ARGS_TOKEN, 5}, {"stfld", IL_OPCODE_ARGS_TOKEN, 5}, {"ldsfld", IL_OPCODE_ARGS_TOKEN, 5}, {"ldsflda", IL_OPCODE_ARGS_TOKEN, 5}, {"stsfld", IL_OPCODE_ARGS_TOKEN, 5}, {"stobj", IL_OPCODE_ARGS_TOKEN, 5}, {"conv.ovf.i1.un", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.i2.un", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.i4.un", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.i8.un", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.u1.un", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.u2.un", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.u4.un", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.u8.un", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.i.un", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.u.un", IL_OPCODE_ARGS_NONE, 1}, {"box", IL_OPCODE_ARGS_TOKEN, 5}, {"newarr", IL_OPCODE_ARGS_TOKEN, 5}, {"ldlen", IL_OPCODE_ARGS_NONE, 1}, {"ldelema", IL_OPCODE_ARGS_TOKEN, 5}, {"ldelem.i1", IL_OPCODE_ARGS_NONE, 1}, {"ldelem.u1", IL_OPCODE_ARGS_NONE, 1}, {"ldelem.i2", IL_OPCODE_ARGS_NONE, 1}, {"ldelem.u2", IL_OPCODE_ARGS_NONE, 1}, {"ldelem.i4", IL_OPCODE_ARGS_NONE, 1}, {"ldelem.u4", IL_OPCODE_ARGS_NONE, 1}, {"ldelem.i8", IL_OPCODE_ARGS_NONE, 1}, {"ldelem.i", IL_OPCODE_ARGS_NONE, 1}, {"ldelem.r4", IL_OPCODE_ARGS_NONE, 1}, {"ldelem.r8", IL_OPCODE_ARGS_NONE, 1}, {"ldelem.ref", IL_OPCODE_ARGS_NONE, 1}, {"stelem.i", IL_OPCODE_ARGS_NONE, 1}, {"stelem.i1", IL_OPCODE_ARGS_NONE, 1}, {"stelem.i2", IL_OPCODE_ARGS_NONE, 1}, {"stelem.i4", IL_OPCODE_ARGS_NONE, 1}, {"stelem.i8", IL_OPCODE_ARGS_NONE, 1}, {"stelem.r4", IL_OPCODE_ARGS_NONE, 1}, {"stelem.r8", IL_OPCODE_ARGS_NONE, 1}, {"stelem.ref", IL_OPCODE_ARGS_NONE, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, // 0xa3 {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, // 0xb2 {"conv.ovf.i1", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.u1", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.i2", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.u2", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.i4", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.u4", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.i8", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.u8", IL_OPCODE_ARGS_NONE, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, // 0xbb {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, // 0xc1 {"refanyval", IL_OPCODE_ARGS_TOKEN, 5}, {"ckfinite", IL_OPCODE_ARGS_NONE, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, // 0xc4 {NULL, IL_OPCODE_ARGS_INVALID, 1}, // 0xc5 {"mkrefany", IL_OPCODE_ARGS_TOKEN, 5}, {"ann.call", IL_OPCODE_ARGS_TOKEN, 5}, {"ann.catch", IL_OPCODE_ARGS_NONE, 1}, {"ann.dead", IL_OPCODE_ARGS_ANN_DEAD, 3}, {"ann.hoisted", IL_OPCODE_ARGS_NONE, 1}, {"ann.hoisted_call", IL_OPCODE_ARGS_TOKEN, 5}, {"ann.lab", IL_OPCODE_ARGS_NONE, 1}, {"ann.def", IL_OPCODE_ARGS_NONE, 1}, {"ann.ref.s", IL_OPCODE_ARGS_ANN_REF_S, 2}, {"ann.phi", IL_OPCODE_ARGS_ANN_PHI, 3}, // must be at least 3 bytes long {"ldtoken", IL_OPCODE_ARGS_TOKEN, 5}, {"conv.u2", IL_OPCODE_ARGS_NONE, 1}, {"conv.u1", IL_OPCODE_ARGS_NONE, 1}, {"conv.i", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.i", IL_OPCODE_ARGS_NONE, 1}, {"conv.ovf.u", IL_OPCODE_ARGS_NONE, 1}, {"add.ovf", IL_OPCODE_ARGS_NONE, 1}, {"add.ovf.un", IL_OPCODE_ARGS_NONE, 1}, {"mul.ovf", IL_OPCODE_ARGS_NONE, 1}, {"mul.ovf.un", IL_OPCODE_ARGS_NONE, 1}, {"sub.ovf", IL_OPCODE_ARGS_NONE, 1}, {"sub.ovf.un", IL_OPCODE_ARGS_NONE, 1}, {"endfinally", IL_OPCODE_ARGS_NONE, 1}, {"leave", IL_OPCODE_ARGS_LONG_JUMP, 5}, {"leave.s", IL_OPCODE_ARGS_SHORT_JUMP, 2}, {"stdind.i", IL_OPCODE_ARGS_NONE, 1}, {"conv.u", IL_OPCODE_ARGS_NONE, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, // 0xe1 {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, // 0xef {NULL, IL_OPCODE_ARGS_INVALID, 1}, // 0xf0 {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, {NULL, IL_OPCODE_ARGS_INVALID, 1}, // 0xfd {NULL, IL_OPCODE_ARGS_PREFIX, 3}, // special: prefix {NULL, IL_OPCODE_ARGS_INVALID, 1}, }; ILOpcodeTabEntry il_prefix_opcode_table[MAX_IL_OPCODE_PREFIX] = { {"arglist", IL_OPCODE_ARGS_NONE, 2}, {"ceq", IL_OPCODE_ARGS_NONE, 2}, {"cgt", IL_OPCODE_ARGS_NONE, 2}, {"cgt.un", IL_OPCODE_ARGS_NONE, 2}, {"clt", IL_OPCODE_ARGS_NONE, 2}, {"clt.un", IL_OPCODE_ARGS_NONE, 2}, {"ldftn", IL_OPCODE_ARGS_TOKEN, 6}, {"ldvirtftn", IL_OPCODE_ARGS_TOKEN, 6}, {"jmpi", IL_OPCODE_ARGS_CALLI, 6}, {"ldarg", IL_OPCODE_ARGS_LONG_VAR, 4}, {"ldarga", IL_OPCODE_ARGS_LONG_VAR, 4}, {"starg", IL_OPCODE_ARGS_LONG_VAR, 4}, {"ldloc", IL_OPCODE_ARGS_LONG_VAR, 4}, {"ldloca", IL_OPCODE_ARGS_LONG_VAR, 4}, {"stloc", IL_OPCODE_ARGS_LONG_VAR, 4}, {"localloc", IL_OPCODE_ARGS_NONE, 2}, {NULL, IL_OPCODE_ARGS_INVALID, 2}, // 0x10 {"endfilter", IL_OPCODE_ARGS_NONE, 2}, {"unaligned.", IL_OPCODE_ARGS_UINT8, 3}, {"volatile.", IL_OPCODE_ARGS_NONE, 2}, {"tail.", IL_OPCODE_ARGS_NONE, 2}, {"initobj", IL_OPCODE_ARGS_TOKEN, 6}, {"ann.live", IL_OPCODE_ARGS_ANN_LIVE, 4}, {"cpblk", IL_OPCODE_ARGS_NONE, 2}, {"initblk", IL_OPCODE_ARGS_NONE, 2}, {"ann.ref", IL_OPCODE_ARGS_ANN_REF, 4}, {"rethrow", IL_OPCODE_ARGS_NONE, 2}, {NULL, IL_OPCODE_ARGS_INVALID, 2}, // 0x1b {"sizeof", IL_OPCODE_ARGS_TOKEN, 6}, {"refanytype", IL_OPCODE_ARGS_NONE, 2}, {NULL, IL_OPCODE_ARGS_INVALID, 2}, // 0x1e {NULL, IL_OPCODE_ARGS_INVALID, 2}, // 0x1f {NULL, IL_OPCODE_ARGS_INVALID, 2}, // 0x20 {NULL, IL_OPCODE_ARGS_INVALID, 2}, // 0x21 {"ann.data", IL_OPCODE_ARGS_ANN_DATA, 6}, // must be at least 6 bytes long {"ann.arg", IL_OPCODE_ARGS_ANN_ARG, 4}, }; ht-2.0.22/asm/ppcopc.cc0000644000175000001440000043014510615342402011504 00000000000000/* * HT Editor * ppcopc.cc * * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) * Copyright 1994 Free Software Foundation, Inc. * Written by Ian Lance Taylor, Cygnus Support * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "ppcopc.h" /* The functions used to insert and extract complicated operands. */ /* The BA field in an XL form instruction when it must be the same as the BT field in the same instruction. This operand is marked FAKE. The insertion function just copies the BT field into the BA field, and the extraction function just checks that the fields are the same. */ static uint32 extract_bat(uint32 insn, bool *invalid) { if (invalid != NULL && ((insn >> 21) & 0x1f) != ((insn >> 16) & 0x1f)) *invalid = 1; return 0; } /* The BB field in an XL form instruction when it must be the same as the BA field in the same instruction. This operand is marked FAKE. The insertion function just copies the BA field into the BB field, and the extraction function just checks that the fields are the same. */ static uint32 extract_bba(uint32 insn, bool *invalid) { if (invalid != NULL && ((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f)) *invalid = 1; return 0; } /* The BD field in a B form instruction. The lower two bits are forced to zero. */ static uint32 extract_bd(uint32 insn, bool *invalid) { if ((insn & 0x8000) != 0) { return (insn & 0xfffc) - 0x10000; } else { return insn & 0xfffc; } } /* The BD field in a B form instruction when the - modifier is used. This modifier means that the branch is not expected to be taken. For chips built to versions of the architecture prior to version 2 (ie. not Power4 compatible), we set the y bit of the BO field to 1 if the offset is negative. When extracting, we require that the y bit be 1 and that the offset be positive, since if the y bit is 0 we just want to print the normal form of the instruction. Power4 compatible targets use two bits, "a", and "t", instead of the "y" bit. "at" == 00 => no hint, "at" == 01 => unpredictable, "at" == 10 => not taken, "at" == 11 => taken. The "t" bit is 00001 in BO field, the "a" bit is 00010 for branch on CR(BI) and 01000 for branch on CTR. We only handle the taken/not-taken hint here. */ static uint32 extract_bdm(uint32 insn, bool *invalid) { if (invalid) { if ((insn & (0x17 << 21)) != (0x06 << 21) && (insn & (0x1d << 21)) != (0x18 << 21)) *invalid = true; } return ((insn & 0xfffc) ^ 0x8000) - 0x8000; } /* The BD field in a B form instruction when the + modifier is used. This is like BDM, above, except that the branch is expected to be taken. */ static uint32 extract_bdp(uint32 insn, bool *invalid) { if (invalid) { if ((insn & (0x17 << 21)) != (0x07 << 21) && (insn & (0x1d << 21)) != (0x19 << 21)) *invalid = true; } return ((insn & 0xfffc) ^ 0x8000) - 0x8000; } /* Check for legal values of a BO field. */ static bool valid_bo(uint32 value) { /* Certain encodings have bits that are required to be zero. These are (z must be zero, a & t may be anything): 0000z 0001z 0100z 0101z 001at 011at 1a00t 1a01t 1z1zz */ switch (value & 0x14) { case 0: return (value & 1) == 0; case 0x4: case 0x10: return true; case 0x14: return value == 0x14; } return false; } /* The BO field in a B form instruction. Warn about attempts to set the field to an illegal value. */ static uint32 extract_bo(uint32 insn, bool *invalid) { uint32 value; value = (insn >> 21) & 0x1f; if (invalid != NULL && !valid_bo(value)) *invalid = true; return value; } /* The BO field in a B form instruction when the + or - modifier is used. This is like the BO field, but it must be even. When extracting it, we force it to be even. */ static uint32 extract_boe(uint32 insn, bool *invalid) { uint32 value; value = (insn >> 21) & 0x1f; if (invalid != NULL && !valid_bo(value)) *invalid = true; return value & 0x1e; } /* The DS field in a DS form instruction. This is like D, but the lower two bits are forced to zero. */ static uint32 extract_ds(uint32 insn, bool *invalid) { if ((insn & 0x8000) != 0) { return (insn & 0xfffc) - 0x10000; } else { return insn & 0xfffc; } } /* The DE field in a DE form instruction. */ static uint32 extract_de(uint32 insn, bool *invalid) { return (insn & 0xfff0) >> 4; } /* The DES field in a DES form instruction. */ static uint32 extract_des(uint32 insn, bool *invalid) { return (((insn >> 2) & 0x3ffc) ^ 0x2000) - 0x2000; } /* The DQ field in a DQ form instruction. This is like D, but the lower four bits are forced to zero. */ static uint32 extract_dq(uint32 insn, bool *invalid) { return ((insn & 0xfff0) ^ 0x8000) - 0x8000; } /* The LI field in an I form instruction. The lower two bits are forced to zero. */ static uint32 extract_li(uint32 insn, bool *invalid) { if ((insn & 0x2000000) != 0) { return (insn & 0x3fffffc) - 0x4000000; } else { return insn & 0x3fffffc; } } /* The MB and ME fields in an M form instruction expressed as a single operand which is itself a bitmask. The extraction function always marks it as invalid, since we never want to recognize an instruction which uses a field of this type. */ static uint32 extract_mbe(uint32 insn, bool *invalid) { uint32 ret; int mb, me; int i; if (invalid != NULL) *invalid = 1; ret = 0; mb = (insn >> 6) & 0x1f; me = (insn >> 1) & 0x1f; for (i = mb; i < me; i++) ret |= 1 << (31 - i); return ret; } static uint32 extract_mbe_special1(uint32 insn, bool *invalid) { // slwi if (invalid) { int sh = (insn >> 11) & 0x1f; int mb = (insn >> 6) & 0x1f; int me = (insn >> 1) & 0x1f; *invalid = !(mb == 0 && me == 31-sh); } return 0; } static uint32 extract_mbe_special2(uint32 insn, bool *invalid) { // srwi if (invalid) { int sh = (insn >> 11) & 0x1f; int mb = (insn >> 6) & 0x1f; int me = (insn >> 1) & 0x1f; *invalid = !(sh == 32-mb && me == 31); } return 0; } /* The MB or ME field in an MD or MDS form instruction. The high bit is wrapped to the low end. */ static uint32 extract_mb6(uint32 insn, bool *invalid) { return ((insn >> 6) & 0x1f) | (insn & 0x20); } /* The NB field in an X form instruction. The value 32 is stored as 0. */ static uint32 extract_nb(uint32 insn, bool *invalid) { uint32 ret; ret = (insn >> 11) & 0x1f; if (ret == 0) ret = 32; return ret; } /* The NSI field in a D form instruction. This is the same as the SI field, only negated. The extraction function always marks it as invalid, since we never want to recognize an instruction which uses a field of this type. */ static uint32 extract_nsi(uint32 insn, bool *invalid) { if (invalid != NULL) *invalid = 1; if ((insn & 0x8000) != 0) { return - ((insn & 0xffff) - 0x10000); } else { return - (insn & 0xffff); } } /* The RA field in a D or X form instruction which is an updating load, which means that the RA field may not be zero and may not equal the RT field. */ /* The RB field in an X form instruction when it must be the same as the RS field in the instruction. This is used for extended mnemonics like mr. This operand is marked FAKE. The insertion function just copies the BT field into the BA field, and the extraction function just checks that the fields are the same. */ static uint32 extract_rbs(uint32 insn, bool *invalid) { if (invalid != NULL && ((insn >> 21) & 0x1f) != ((insn >> 11) & 0x1f)) *invalid = true; return 0; } static uint32 extract_vab(uint32 insn, bool *invalid) { if (invalid != NULL && ((insn >> 16) & 0x1f) != ((insn >> 11) & 0x1f)) *invalid = true; return 0; } /* The SH field in an MD form instruction. This is split. */ static uint32 extract_sh6(uint32 insn, bool *invalid) { return ((insn >> 11) & 0x1f) | ((insn << 4) & 0x20); } /* The SPR field in an XFX form instruction. This is flipped--the lower 5 bits are stored in the upper 5 and vice- versa. */ static uint32 extract_spr(uint32 insn, bool *invalid) { return ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0); } /* The TBR field in an XFX instruction. This is just like SPR, but it is optional. When TBR is omitted, it must be inserted as 268 (the magic number of the TB register). These functions treat 0 (indicating an omitted optional operand) as 268. This means that ``mftb 4,0'' is not handled correctly. This does not matter very much, since the architecture manual does not define mftb as accepting any values other than 268 or 269. */ #define TB (268) static uint32 extract_tbr(uint32 insn, bool *invalid) { uint32 ret = ((insn >> 16) & 0x1f) | ((insn >> 6) & 0x3e0); if (ret == TB) ret = 0; return ret; } static uint32 extract_vds128(uint32 insn, bool *invalid) { return ((insn<<3) & 0x60) | ((insn>>21) & 0x1f); } static uint32 extract_va128(uint32 insn, bool *invalid) { return ((insn>>4) & 0x40) | (insn & 0x20) | ((insn>>16) & 0x1f); } static uint32 extract_vb128(uint32 insn, bool *invalid) { return ((insn<<5) & 0x60) | ((insn>>11) & 0x1f); } static uint32 extract_vperm(uint32 insn, bool *invalid) { return ((insn>>1) & 0xe0) | ((insn>>16) & 0x1f); } /* The operands table. The fields are bits, shift, signed, extract, flags. */ #undef UNUSED const struct powerpc_operand powerpc_operands[] = { /* The zero index is used to indicate the end of the list of operands. */ #define UNUSED 0 { 0, 0, 0, 0 }, /* The BA field in an XL form instruction. */ #define BA UNUSED + 1 #define BA_MASK (0x1f << 16) { 5, 16, 0, PPC_OPERAND_CR }, /* The BA field in an XL form instruction when it must be the same as the BT field in the same instruction. */ #define BAT BA + 1 { 5, 16, extract_bat, PPC_OPERAND_FAKE }, /* The BB field in an XL form instruction. */ #define BB BAT + 1 #define BB_MASK (0x1f << 11) { 5, 11, 0, PPC_OPERAND_CR }, /* The BB field in an XL form instruction when it must be the same as the BA field in the same instruction. */ #define BBA BB + 1 { 5, 11, extract_bba, PPC_OPERAND_FAKE }, /* The BD field in a B form instruction. The lower two bits are forced to zero. */ #define BD BBA + 1 { 16, 0, extract_bd, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED }, /* The BD field in a B form instruction when absolute addressing is used. */ #define BDA BD + 1 { 16, 0, extract_bd, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED }, /* The BD field in a B form instruction when the - modifier is used. This sets the y bit of the BO field appropriately. */ #define BDM BDA + 1 { 16, 0, extract_bdm, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED }, /* The BD field in a B form instruction when the - modifier is used and absolute address is used. */ #define BDMA BDM + 1 { 16, 0, extract_bdm, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED }, /* The BD field in a B form instruction when the + modifier is used. This sets the y bit of the BO field appropriately. */ #define BDP BDMA + 1 { 16, 0, extract_bdp, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED }, /* The BD field in a B form instruction when the + modifier is used and absolute addressing is used. */ #define BDPA BDP + 1 { 16, 0, extract_bdp, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED }, /* The BF field in an X or XL form instruction. */ #define BF BDPA + 1 { 3, 23, 0, PPC_OPERAND_CR }, /* An optional BF field. This is used for comparison instructions, in which an omitted BF field is taken as zero. */ #define OBF BF + 1 { 3, 23, 0, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL }, /* The BFA field in an X or XL form instruction. */ #define BFA OBF + 1 { 3, 18, 0, PPC_OPERAND_CR }, /* The BI field in a B form or XL form instruction. */ #define BI BFA + 1 #define BI_MASK (0x1f << 16) { 5, 16, 0, PPC_OPERAND_CR }, /* The BO field in a B form instruction. Certain values are illegal. */ #define BO BI + 1 #define BO_MASK (0x1f << 21) { 5, 21, extract_bo, 0 }, /* The BO field in a B form instruction when the + or - modifier is used. This is like the BO field, but it must be even. */ #define BOE BO + 1 { 5, 21, extract_boe, 0 }, /* The BT field in an X or XL form instruction. */ #define BT BOE + 1 { 5, 21, 0, PPC_OPERAND_CR }, /* The condition register number portion of the BI field in a B form or XL form instruction. This is used for the extended conditional branch mnemonics, which set the lower two bits of the BI field. This field is optional. */ #define CR BT + 1 { 3, 18, 0, PPC_OPERAND_CR | PPC_OPERAND_OPTIONAL }, /* The CRB field in an X form instruction. */ #define CRB CR + 1 { 5, 6, 0, 0 }, /* The CRFD field in an X form instruction. */ #define CRFD CRB + 1 { 3, 23, 0, PPC_OPERAND_CR }, /* The CRFS field in an X form instruction. */ #define CRFS CRFD + 1 { 3, 0, 0, PPC_OPERAND_CR }, /* The CT field in an X form instruction. */ #define CT CRFS + 1 { 5, 21, 0, PPC_OPERAND_OPTIONAL }, /* The D field in a D form instruction. This is a displacement off a register, and implies that the next operand is a register in parentheses. */ #define D CT + 1 { 16, 0, 0, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED }, /* The DE field in a DE form instruction. This is like D, but is 12 bits only. */ #define DE D + 1 { 14, 0, extract_de, PPC_OPERAND_PARENS }, /* The DES field in a DES form instruction. This is like DS, but is 14 bits only (12 stored.) */ #define DES DE + 1 { 14, 0, extract_des, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED }, /* The DQ field in a DQ form instruction. This is like D, but the lower four bits are forced to zero. */ #define DQ DES + 1 { 16, 0, extract_dq, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED | PPC_OPERAND_DQ }, /* The DS field in a DS form instruction. This is like D, but the lower two bits are forced to zero. */ #define DS DQ + 1 { 16, 0, extract_ds, PPC_OPERAND_PARENS | PPC_OPERAND_SIGNED | PPC_OPERAND_DS }, /* The FLM field in an XFL form instruction. */ #define FLM DS + 1 { 8, 17, 0, 0 }, /* The FRA field in an X or A form instruction. */ #define FRA FLM + 1 #define FRA_MASK (0x1f << 16) { 5, 16, 0, PPC_OPERAND_FPR }, /* The FRB field in an X or A form instruction. */ #define FRB FRA + 1 #define FRB_MASK (0x1f << 11) { 5, 11, 0, PPC_OPERAND_FPR }, /* The FRC field in an A form instruction. */ #define FRC FRB + 1 #define FRC_MASK (0x1f << 6) { 5, 6, 0, PPC_OPERAND_FPR }, /* The FRS field in an X form instruction or the FRT field in a D, X or A form instruction. */ #define FRS FRC + 1 #define FRT FRS { 5, 21, 0, PPC_OPERAND_FPR }, /* The FXM field in an XFX instruction. */ #define FXM FRS + 1 #define FXM_MASK (0xff << 12) { 8, 12, 0, 0 }, /* The L field in a D or X form instruction. */ #define L FXM + 1 { 1, 21, 0, PPC_OPERAND_OPTIONAL }, /* The LI field in an I form instruction. The lower two bits are forced to zero. */ #define LI L + 1 { 26, 0, extract_li, PPC_OPERAND_RELATIVE | PPC_OPERAND_SIGNED }, /* The LI field in an I form instruction when used as an absolute address. */ #define LIA LI + 1 { 26, 0, extract_li, PPC_OPERAND_ABSOLUTE | PPC_OPERAND_SIGNED }, /* The LS field in an X (sync) form instruction. */ #define LS LIA + 1 { 2, 21, 0, PPC_OPERAND_OPTIONAL }, /* The MB field in an M form instruction. */ #define MB LS + 1 #define MB_MASK (0x1f << 6) { 5, 6, 0, 0 }, /* The ME field in an M form instruction. */ #define ME MB + 1 #define ME_MASK (0x1f << 1) { 5, 1, 0, 0 }, /* The MB and ME fields in an M form instruction expressed a single operand which is a bitmask indicating which bits to select. This is a two operand form using PPC_OPERAND_NEXT. See the description in opcode/ppc.h for what this means. */ #define MBE ME + 1 { 5, 6, 0, PPC_OPERAND_OPTIONAL | PPC_OPERAND_NEXT }, { 32, 0, extract_mbe, 0 }, /* The MB or ME field in an MD or MDS form instruction. The high bit is wrapped to the low end. */ #define MB6 MBE + 2 #define ME6 MB6 #define MB6_MASK (0x3f << 5) { 6, 5, extract_mb6, 0 }, #define MSLWI MB6 + 1 { 0, 0, extract_mbe_special1, PPC_OPERAND_FAKE }, #define MSRWI MSLWI + 1 { 0, 0, extract_mbe_special2, PPC_OPERAND_FAKE }, /* The MO field in an mbar instruction. */ #define MO MSRWI + 1 { 5, 21, 0, 0 }, /* The NB field in an X form instruction. The value 32 is stored as 0. */ #define NB MO + 1 { 6, 11, extract_nb, 0 }, /* The NSI field in a D form instruction. This is the same as the SI field, only negated. */ #define NSI NB + 1 { 16, 0, extract_nsi, PPC_OPERAND_NEGATIVE | PPC_OPERAND_SIGNED }, /* The RA field in an D, DS, X, XO, M, or MDS form instruction. */ #define RA NSI + 1 #define RAM RA #define RAS RA #define RAL RA #define RA_MASK (0x1f << 16) { 5, 16, 0, PPC_OPERAND_GPR }, /* As above, but 0 in the RA field means zero, not r0. */ #define RA0 RA + 1 #define RAQ RA0 { 5, 16, 0, PPC_OPERAND_GPR_0 }, /* The RB field in an X, XO, M, or MDS form instruction. */ #define RB RA0 + 1 #define RB_MASK (0x1f << 11) { 5, 11, 0, PPC_OPERAND_GPR }, /* The RB field in an X form instruction when it must be the same as the RS field in the instruction. This is used for extended mnemonics like mr. */ #define RBS RB + 1 { 5, 1, extract_rbs, PPC_OPERAND_FAKE }, /* The RS field in a D, DS, X, XFX, XS, M, MD or MDS form instruction or the RT field in a D, DS, X, XFX or XO form instruction. */ #define RS RBS + 1 #define RT RS #define RT_MASK (0x1f << 21) { 5, 21, 0, PPC_OPERAND_GPR }, /* The RS field of the DS form stq instruction, which has special value restrictions. */ #define RSQ RS + 1 { 5, 21, 0, PPC_OPERAND_GPR_0 }, /* The RT field of the DQ form lq instruction, which has special value restrictions. */ #define RTQ RSQ + 1 { 5, 21, 0, PPC_OPERAND_GPR_0 }, /* The SH field in an X or M form instruction. */ #define SH RTQ + 1 #define SH_MASK (0x1f << 11) { 5, 11, 0, 0 }, /* The SH field in an MD form instruction. This is split. */ #define SH6 SH + 1 #define SH6_MASK ((0x1f << 11) | (1 << 1)) { 6, 1, extract_sh6, 0 }, /* The SI field in a D form instruction. */ #define SI SH6 + 1 { 16, 0, 0, PPC_OPERAND_SIGNED }, /* The SI field in a D form instruction when we accept a wide range of positive values. */ #define SISIGNOPT SI + 1 { 16, 0, 0, PPC_OPERAND_SIGNED | PPC_OPERAND_SIGNOPT }, /* The SPR field in an XFX form instruction. This is flipped--the lower 5 bits are stored in the upper 5 and vice- versa. */ #define SPR SISIGNOPT + 1 #define PMR SPR #define SPR_MASK (0x3ff << 11) { 10, 11, extract_spr, 0 }, /* The BAT index number in an XFX form m[ft]ibat[lu] instruction. */ #define SPRBAT SPR + 1 #define SPRBAT_MASK (0x3 << 17) { 2, 17, 0, 0 }, /* The SPRG register number in an XFX form m[ft]sprg instruction. */ #define SPRG SPRBAT + 1 #define SPRG_MASK (0x3 << 16) { 2, 16, 0, 0 }, /* The SR field in an X form instruction. */ #define SR SPRG + 1 { 4, 16, 0, 0 }, /* The STRM field in an X AltiVec form instruction. */ #define STRM SR + 1 #define STRM_MASK (0x3 << 21) { 2, 21, 0, 0 }, /* The SV field in a POWER SC form instruction. */ #define SV STRM + 1 { 14, 2, 0, 0 }, /* The TBR field in an XFX form instruction. This is like the SPR field, but it is optional. */ #define TBR SV + 1 { 10, 11, extract_tbr, PPC_OPERAND_OPTIONAL }, /* The TO field in a D or X form instruction. */ #define TO TBR + 1 #define TO_MASK (0x1f << 21) { 5, 21, 0, 0 }, /* The U field in an X form instruction. */ #define U TO + 1 { 4, 12, 0, 0 }, /* The UI field in a D form instruction. */ #define UI U + 1 { 16, 0, 0, 0 }, /* The VA field in a VA, VX or VXR form instruction. */ #define VA UI + 1 #define VA_MASK (0x1f << 16) { 5, 16, 0, PPC_OPERAND_VR }, /* The VB field in a VA, VX or VXR form instruction. */ #define VB VA + 1 #define VB_MASK (0x1f << 11) { 5, 11, 0, PPC_OPERAND_VR }, /* The VB field in a VA, VX or VXR form instruction. */ #define VAB VB + 1 #define VAB_MASK (0x1f << 11) { 5, 11, extract_vab, PPC_OPERAND_FAKE }, /* The VC field in a VA form instruction. */ #define VC VAB + 1 #define VC_MASK (0x1f << 6) { 5, 6, 0, PPC_OPERAND_VR }, /* The VD or VS field in a VA, VX, VXR or X form instruction. */ #define VD VC + 1 #define VS VD #define VD_MASK (0x1f << 21) { 5, 21, 0, PPC_OPERAND_VR }, /* The VD or VS field in a VA, VX, VXR or X form instruction. */ #define VD128 VD + 1 #define VS128 VD128 #define VD128_MASK (0x1f << 21) { 0, 0, extract_vds128, PPC_OPERAND_VR }, /* The VD or VS field in a VA, VX, VXR or X form instruction. */ #define VA128 VD128 + 1 #define VA128_MASK (0x1f << 21) { 0, 0, extract_va128, PPC_OPERAND_VR }, /* The VD or VS field in a VA, VX, VXR or X form instruction. */ #define VB128 VA128 + 1 #define VB128_MASK (0x1f << 21) { 0, 0, extract_vb128, PPC_OPERAND_VR }, /* The VD or VS field in a VA, VX, VXR or X form instruction. */ #define VC128 VB128 + 1 #define VC128_MASK (0x1f << 21) { 3, 6, 0, PPC_OPERAND_VR }, #define VPERM128 VC128 + 1 #define VPERM_MASK (0x1f << 21) { 0, 0, extract_vperm, 0 }, #define VD3D0 VPERM128 + 1 { 3, 18, 0, 0 }, #define VD3D1 VD3D0 + 1 { 2, 16, 0, 0 }, #define VD3D2 VD3D1 + 1 { 2, 6, 0, 0 }, /* The SIMM field in a VX form instruction. */ #define SIMM VD3D2 + 1 { 5, 16, 0, PPC_OPERAND_SIGNED}, /* The UIMM field in a VX form instruction. */ #define UIMM SIMM + 1 { 5, 16, 0, 0 }, /* The SHB field in a VA form instruction. */ #define SHB UIMM + 1 { 4, 6, 0, 0 }, /* The WS field. */ #define WS SHB + 1 #define WS_MASK (0x7 << 11) { 3, 11, 0, 0 }, /* The L field in an mtmsrd instruction */ #define MTMSRD_L WS + 1 { 1, 16, 0, PPC_OPERAND_OPTIONAL }, /* The DCM field in a Z form instruction. */ #define DCM MTMSRD_L + 1 #define DGM DCM { 6, 16, 0, 0 }, #define TE DGM + 1 { 5, 11, 0, 0 }, #define RMC TE + 1 { 2, 21, 0, 0 }, #define R RMC + 1 { 1, 15, 0, 0 }, #define SP R + 1 { 2, 11, 0, 0 }, #define S SP + 1 { 1, 11, 0, 0 }, /* SH field starting at bit position 16. */ #define SH16 S + 1 { 6, 10, 0, 0 }, }; /* Macros used to form opcodes. */ /* The main opcode. */ #define OP(x) ((((unsigned long)(x)) & 0x3f) << 26) #define OP_MASK OP (0x3f) /* The main opcode combined with a trap code in the TO field of a D form instruction. Used for extended mnemonics for the trap instructions. */ #define OPTO(x,to) (OP (x) | ((((unsigned long)(to)) & 0x1f) << 21)) #define OPTO_MASK (OP_MASK | TO_MASK) /* The main opcode combined with a comparison size bit in the L field of a D form or X form instruction. Used for extended mnemonics for the comparison instructions. */ #define OPL(x,l) (OP (x) | ((((unsigned long)(l)) & 1) << 21)) #define OPL_MASK OPL (0x3f,1) /* An A form instruction. */ #define A(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1) | (((unsigned long)(rc)) & 1)) #define A_MASK A (0x3f, 0x1f, 1) /* An A_MASK with the FRB field fixed. */ #define AFRB_MASK (A_MASK | FRB_MASK) /* An A_MASK with the FRC field fixed. */ #define AFRC_MASK (A_MASK | FRC_MASK) /* An A_MASK with the FRA and FRC fields fixed. */ #define AFRAFRC_MASK (A_MASK | FRA_MASK | FRC_MASK) /* A B form instruction. */ #define B(op, aa, lk) (OP (op) | ((((unsigned long)(aa)) & 1) << 1) | ((lk) & 1)) #define B_MASK B (0x3f, 1, 1) /* A B form instruction setting the BO field. */ #define BBO(op, bo, aa, lk) (B ((op), (aa), (lk)) | ((((unsigned long)(bo)) & 0x1f) << 21)) #define BBO_MASK BBO (0x3f, 0x1f, 1, 1) /* A BBO_MASK with the y bit of the BO field removed. This permits matching a conditional branch regardless of the setting of the y bit. Similarly for the 'at' bits used for power4 branch hints. */ #define Y_MASK (((unsigned long) 1) << 21) #define AT1_MASK (((unsigned long) 3) << 21) #define AT2_MASK (((unsigned long) 9) << 21) #define BBOY_MASK (BBO_MASK &~ Y_MASK) #define BBOAT_MASK (BBO_MASK &~ AT1_MASK) /* A B form instruction setting the BO field and the condition bits of the BI field. */ #define BBOCB(op, bo, cb, aa, lk) \ (BBO ((op), (bo), (aa), (lk)) | ((((unsigned long)(cb)) & 0x3) << 16)) #define BBOCB_MASK BBOCB (0x3f, 0x1f, 0x3, 1, 1) /* A BBOCB_MASK with the y bit of the BO field removed. */ #define BBOYCB_MASK (BBOCB_MASK &~ Y_MASK) #define BBOATCB_MASK (BBOCB_MASK &~ AT1_MASK) #define BBOAT2CB_MASK (BBOCB_MASK &~ AT2_MASK) /* A BBOYCB_MASK in which the BI field is fixed. */ #define BBOYBI_MASK (BBOYCB_MASK | BI_MASK) #define BBOATBI_MASK (BBOAT2CB_MASK | BI_MASK) /* An Context form instruction. */ #define CTX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x7)) #define CTX_MASK CTX(0x3f, 0x7) /* An User Context form instruction. */ #define UCTX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x1f)) #define UCTX_MASK UCTX(0x3f, 0x1f) /* The main opcode mask with the RA field clear. */ #define DRA_MASK (OP_MASK | RA_MASK) /* A DS form instruction. */ #define DSO(op, xop) (OP (op) | ((xop) & 0x3)) #define DS_MASK DSO (0x3f, 3) /* A DE form instruction. */ #define DEO(op, xop) (OP (op) | ((xop) & 0xf)) #define DE_MASK DEO (0x3e, 0xf) /* An EVSEL form instruction. */ #define EVSEL(op, xop) (OP (op) | (((unsigned long)(xop)) & 0xff) << 3) #define EVSEL_MASK EVSEL(0x3f, 0xff) /* An M form instruction. */ #define M(op, rc) (OP (op) | ((rc) & 1)) #define M_MASK M (0x3f, 1) /* An M form instruction with the ME field specified. */ #define MME(op, me, rc) (M ((op), (rc)) | ((((unsigned long)(me)) & 0x1f) << 1)) /* An M_MASK with the MB and ME fields fixed. */ #define MMBME_MASK (M_MASK | MB_MASK | ME_MASK) /* An M_MASK with the SH and ME fields fixed. */ #define MSHME_MASK (M_MASK | SH_MASK | ME_MASK) /* An MD form instruction. */ #define MD(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x7) << 2) | ((rc) & 1)) #define MD_MASK MD (0x3f, 0x7, 1) /* An MD_MASK with the MB field fixed. */ #define MDMB_MASK (MD_MASK | MB6_MASK) /* An MD_MASK with the SH field fixed. */ #define MDSH_MASK (MD_MASK | SH6_MASK) /* An MDS form instruction. */ #define MDS(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0xf) << 1) | ((rc) & 1)) #define MDS_MASK MDS (0x3f, 0xf, 1) /* An MDS_MASK with the MB field fixed. */ #define MDSMB_MASK (MDS_MASK | MB6_MASK) /* An SC form instruction. */ #define SC(op, sa, lk) (OP (op) | ((((unsigned long)(sa)) & 1) << 1) | ((lk) & 1)) #define SC_MASK (OP_MASK | (((unsigned long)0x3ff) << 16) | (((unsigned long)1) << 1) | 1) /* An VX form instruction. */ #define VX(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x7ff)) /* The mask for an VX form instruction. */ #define VX_MASK VX(0x3f, 0x7ff) /* The mask for an VX form instruction. */ #define VX_MASK VX(0x3f, 0x7ff) /* An VA form instruction. */ #define VXA(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x03f)) /* The mask for an VA form instruction. */ #define VXA_MASK VXA(0x3f, 0x3f) /* An VXR form instruction. */ #define VXR(op, xop, rc) (OP (op) | (((rc) & 1) << 10) | (((unsigned long)(xop)) & 0x3ff)) /* The mask for a VXR form instruction. */ #define VXR_MASK VXR(0x3f, 0x3ff, 1) /* An VX128 form instruction. */ #define VX128(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x3d0)) /* The mask for an VX form instruction. */ #define VX128_MASK VX(0x3f, 0x3d0) /* An VX128 form instruction. */ #define VX128_1(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x7f3)) /* The mask for an VX form instruction. */ #define VX128_1_MASK VX(0x3f, 0x7f3) /* An VX128 form instruction. */ #define VX128_2(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x210)) /* The mask for an VX form instruction. */ #define VX128_2_MASK VX(0x3f, 0x210) /* An VX128 form instruction. */ #define VX128_3(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x7f0)) /* The mask for an VX form instruction. */ #define VX128_3_MASK VX(0x3f, 0x7f0) #define VX128_P(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x630)) #define VX128_P_MASK VX(0x3f, 0x630) #define VX128_4(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x730)) #define VX128_4_MASK VX(0x3f, 0x730) #define VX128_5(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x10)) #define VX128_5_MASK VX(0x3f, 0x10) /* An X form instruction. */ #define X(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1)) /* A Z form instruction. */ #define Z(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 1)) /* An X form instruction with the RC bit specified. */ #define XRC(op, xop, rc) (X ((op), (xop)) | ((rc) & 1)) /* A Z form instruction with the RC bit specified. */ #define ZRC(op, xop, rc) (Z ((op), (xop)) | ((rc) & 1)) /* The mask for an X form instruction. */ #define X_MASK XRC (0x3f, 0x3ff, 1) /* The mask for a Z form instruction. */ #define Z_MASK ZRC (0x3f, 0x1ff, 1) /* An X_MASK with the RA field fixed. */ #define XRA_MASK (X_MASK | RA_MASK) /* An X_MASK with the RB field fixed. */ #define XRB_MASK (X_MASK | RB_MASK) /* An X_MASK with the RT field fixed. */ #define XRT_MASK (X_MASK | RT_MASK) /* An X_MASK with the RA and RB fields fixed. */ #define XRARB_MASK (X_MASK | RA_MASK | RB_MASK) /* An XRARB_MASK, but with the L bit clear. */ #define XRLARB_MASK (XRARB_MASK & ~((unsigned long) 1 << 16)) /* An X_MASK with the RT and RA fields fixed. */ #define XRTRA_MASK (X_MASK | RT_MASK | RA_MASK) /* An XRTRA_MASK, but with L bit clear. */ #define XRTLRA_MASK (XRTRA_MASK & ~((unsigned long) 1 << 21)) /* An X form comparison instruction. */ #define XCMPL(op, xop, l) (X ((op), (xop)) | ((((unsigned long)(l)) & 1) << 21)) /* The mask for an X form comparison instruction. */ #define XCMP_MASK (X_MASK | (((unsigned long)1) << 22)) /* The mask for an X form comparison instruction with the L field fixed. */ #define XCMPL_MASK (XCMP_MASK | (((unsigned long)1) << 21)) /* An X form instruction with the L bit specified. */ #define XOPL(op, xop, l) (X ((op), (xop)) | ((((unsigned long)(l)) & 1) << 21)) /* An X form trap instruction with the TO field specified. */ #define XTO(op, xop, to) (X ((op), (xop)) | ((((unsigned long)(to)) & 0x1f) << 21)) #define XTO_MASK (X_MASK | TO_MASK) /* An X form tlb instruction with the SH field specified. */ #define XTLB(op, xop, sh) (X ((op), (xop)) | ((((unsigned long)(sh)) & 0x1f) << 11)) #define XTLB_MASK (X_MASK | SH_MASK) /* An X form sync instruction. */ #define XSYNC(op, xop, l) (X ((op), (xop)) | ((((unsigned long)(l)) & 3) << 21)) /* An X form sync instruction with everything filled in except the LS field. */ #define XSYNC_MASK (0xff9fffff) /* An X form AltiVec dss instruction. */ #define XDSS(op, xop, a) (X ((op), (xop)) | ((((unsigned long)(a)) & 1) << 25)) #define XDSS_MASK XDSS(0x3f, 0x3ff, 1) /* An XFL form instruction. */ #define XFL(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1) | (((unsigned long)(rc)) & 1)) #define XFL_MASK (XFL (0x3f, 0x3ff, 1) | (((unsigned long)1) << 25) | (((unsigned long)1) << 16)) /* An X form isel instruction. */ #define XISEL(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x1f) << 1)) #define XISEL_MASK XISEL(0x3f, 0x1f) /* An XL form instruction with the LK field set to 0. */ #define XL(op, xop) (OP (op) | ((((unsigned long)(xop)) & 0x3ff) << 1)) /* An XL form instruction which uses the LK field. */ #define XLLK(op, xop, lk) (XL ((op), (xop)) | ((lk) & 1)) /* The mask for an XL form instruction. */ #define XL_MASK XLLK (0x3f, 0x3ff, 1) /* An XL form instruction which explicitly sets the BO field. */ #define XLO(op, bo, xop, lk) \ (XLLK ((op), (xop), (lk)) | ((((unsigned long)(bo)) & 0x1f) << 21)) #define XLO_MASK (XL_MASK | BO_MASK) /* An XL form instruction which explicitly sets the y bit of the BO field. */ #define XLYLK(op, xop, y, lk) (XLLK ((op), (xop), (lk)) | ((((unsigned long)(y)) & 1) << 21)) #define XLYLK_MASK (XL_MASK | Y_MASK) /* An XL form instruction which sets the BO field and the condition bits of the BI field. */ #define XLOCB(op, bo, cb, xop, lk) \ (XLO ((op), (bo), (xop), (lk)) | ((((unsigned long)(cb)) & 3) << 16)) #define XLOCB_MASK XLOCB (0x3f, 0x1f, 0x3, 0x3ff, 1) /* An XL_MASK or XLYLK_MASK or XLOCB_MASK with the BB field fixed. */ #define XLBB_MASK (XL_MASK | BB_MASK) #define XLYBB_MASK (XLYLK_MASK | BB_MASK) #define XLBOCBBB_MASK (XLOCB_MASK | BB_MASK) /* An XL_MASK with the BO and BB fields fixed. */ #define XLBOBB_MASK (XL_MASK | BO_MASK | BB_MASK) /* An XL_MASK with the BO, BI and BB fields fixed. */ #define XLBOBIBB_MASK (XL_MASK | BO_MASK | BI_MASK | BB_MASK) /* An XO form instruction. */ #define XO(op, xop, oe, rc) \ (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 1) | ((((unsigned long)(oe)) & 1) << 10) | (((unsigned long)(rc)) & 1)) #define XO_MASK XO (0x3f, 0x1ff, 1, 1) /* An XO_MASK with the RB field fixed. */ #define XORB_MASK (XO_MASK | RB_MASK) /* An XS form instruction. */ #define XS(op, xop, rc) (OP (op) | ((((unsigned long)(xop)) & 0x1ff) << 2) | (((unsigned long)(rc)) & 1)) #define XS_MASK XS (0x3f, 0x1ff, 1) /* A mask for the FXM version of an XFX form instruction. */ #define XFXFXM_MASK (X_MASK | (((unsigned long)1) << 20) | (((unsigned long)1) << 11)) #define XFXFXM_MASK2 (X_MASK | (((unsigned long)1) << 20)) /* An XFX form instruction with the FXM field filled in. */ #define XFXM(op, xop, fxm) \ (X ((op), (xop)) | ((((unsigned long)(fxm)) & 0xff) << 12)) /* An XFX form instruction with the SPR field filled in. */ #define XSPR(op, xop, spr) \ (X ((op), (xop)) | ((((unsigned long)(spr)) & 0x1f) << 16) | ((((unsigned long)(spr)) & 0x3e0) << 6)) #define XSPR_MASK (X_MASK | SPR_MASK) /* An XFX form instruction with the SPR field filled in except for the SPRBAT field. */ #define XSPRBAT_MASK (XSPR_MASK &~ SPRBAT_MASK) /* An XFX form instruction with the SPR field filled in except for the SPRG field. */ #define XSPRG_MASK (XSPR_MASK &~ SPRG_MASK) /* An X form instruction with everything filled in except the E field. */ #define XE_MASK (0xffff7fff) /* An X form user context instruction. */ #define XUC(op, xop) (OP (op) | (((unsigned long)(xop)) & 0x1f)) #define XUC_MASK XUC(0x3f, 0x1f) /* The BO encodings used in extended conditional branch mnemonics. */ #define BODNZF (0x0) #define BODNZFP (0x1) #define BODZF (0x2) #define BODZFP (0x3) #define BODNZT (0x8) #define BODNZTP (0x9) #define BODZT (0xa) #define BODZTP (0xb) #define BOF (0x4) #define BOFP (0x5) #define BOFM4 (0x6) #define BOFP4 (0x7) #define BOT (0xc) #define BOTP (0xd) #define BOTM4 (0xe) #define BOTP4 (0xf) #define BODNZ (0x10) #define BODNZP (0x11) #define BODZ (0x12) #define BODZP (0x13) #define BODNZM4 (0x18) #define BODNZP4 (0x19) #define BODZM4 (0x1a) #define BODZP4 (0x1b) #define BOU (0x14) /* The BI condition bit encodings used in extended conditional branch mnemonics. */ #define CBLT (0) #define CBGT (1) #define CBEQ (2) #define CBSO (3) /* The TO encodings used in extended trap mnemonics. */ #define TOLGT (0x1) #define TOLLT (0x2) #define TOEQ (0x4) #define TOLGE (0x5) #define TOLNL (0x5) #define TOLLE (0x6) #define TOLNG (0x6) #define TOGT (0x8) #define TOGE (0xc) #define TONL (0xc) #define TOLT (0x10) #define TOLE (0x14) #define TONG (0x14) #define TONE (0x18) #define TOU (0x1f) /* Smaller names for the flags so each entry in the opcodes table will fit on a single line. */ #undef PPC #define PPC PPC_OPCODE_PPC #define PPCCOM PPC_OPCODE_PPC | PPC_OPCODE_COMMON #define NOPOWER4 PPC_OPCODE_NOPOWER4 | PPCCOM #define POWER4 PPC_OPCODE_POWER4 #define POWER5 0 #define PPC32 PPC_OPCODE_32 | PPC_OPCODE_PPC #define PPC64 PPC_OPCODE_64 | PPC_OPCODE_PPC #define PPC403 PPC_OPCODE_403 #define PPC405 PPC403 #define PPC440 PPC_OPCODE_440 #define PPC750 PPC #define PPC860 PPC #define PPCVEC PPC_OPCODE_ALTIVEC #define CELL 0 #define POWER6 0 #define POWER PPC_OPCODE_POWER #define POWER2 PPC_OPCODE_POWER | PPC_OPCODE_POWER2 #define PPCPWR2 PPC_OPCODE_PPC | PPC_OPCODE_POWER | PPC_OPCODE_POWER2 #define POWER32 PPC_OPCODE_POWER | PPC_OPCODE_32 #define PPCONLY PPC_OPCODE_PPC #define COM PPC_OPCODE_POWER | PPC_OPCODE_PPC | PPC_OPCODE_COMMON #define COM32 PPC_OPCODE_POWER | PPC_OPCODE_PPC | PPC_OPCODE_COMMON | PPC_OPCODE_32 #define M601 PPC_OPCODE_POWER | PPC_OPCODE_601 #define PWRCOM PPC_OPCODE_POWER | PPC_OPCODE_601 | PPC_OPCODE_COMMON #define MFDEC1 PPC_OPCODE_POWER #define MFDEC2 PPC_OPCODE_PPC | PPC_OPCODE_601 | PPC_OPCODE_BOOKE #define BOOKE PPC_OPCODE_BOOKE #define BOOKE64 PPC_OPCODE_BOOKE64 #define CLASSIC PPC_OPCODE_CLASSIC #define PPCE300 PPC_OPCODE_E300 #define PPCSPE PPC_OPCODE_SPE #define PPCISEL PPC_OPCODE_ISEL #define PPCEFS PPC_OPCODE_EFS #define PPCBRLK PPC_OPCODE_BRLOCK #define PPCPMR PPC_OPCODE_PMR #define PPCCHLK PPC_OPCODE_CACHELCK #define PPCCHLK64 PPC_OPCODE_CACHELCK | PPC_OPCODE_BOOKE64 #define PPCRFMCI PPC_OPCODE_RFMCI /* The opcode table. The format of the opcode table is: NAME OPCODE MASK FLAGS { OPERANDS } NAME is the name of the instruction. OPCODE is the instruction opcode. MASK is the opcode mask; this is used to tell the disassembler which bits in the actual opcode must match OPCODE. FLAGS are flags indicated what processors support the instruction. OPERANDS is the list of operands. The disassembler reads the table in order and prints the first instruction which matches, so this table is sorted to put more specific instructions before more general instructions. It is also sorted by major opcode. */ const struct powerpc_opcode powerpc_opcodes[] = { { "tdlgti", OPTO(2,TOLGT), OPTO_MASK, PPC64, { RA, SI } }, { "tdllti", OPTO(2,TOLLT), OPTO_MASK, PPC64, { RA, SI } }, { "tdeqi", OPTO(2,TOEQ), OPTO_MASK, PPC64, { RA, SI } }, { "tdlgei", OPTO(2,TOLGE), OPTO_MASK, PPC64, { RA, SI } }, { "tdlnli", OPTO(2,TOLNL), OPTO_MASK, PPC64, { RA, SI } }, { "tdllei", OPTO(2,TOLLE), OPTO_MASK, PPC64, { RA, SI } }, { "tdlngi", OPTO(2,TOLNG), OPTO_MASK, PPC64, { RA, SI } }, { "tdgti", OPTO(2,TOGT), OPTO_MASK, PPC64, { RA, SI } }, { "tdgei", OPTO(2,TOGE), OPTO_MASK, PPC64, { RA, SI } }, { "tdnli", OPTO(2,TONL), OPTO_MASK, PPC64, { RA, SI } }, { "tdlti", OPTO(2,TOLT), OPTO_MASK, PPC64, { RA, SI } }, { "tdlei", OPTO(2,TOLE), OPTO_MASK, PPC64, { RA, SI } }, { "tdngi", OPTO(2,TONG), OPTO_MASK, PPC64, { RA, SI } }, { "tdnei", OPTO(2,TONE), OPTO_MASK, PPC64, { RA, SI } }, { "tdi", OP(2), OP_MASK, PPC64, { TO, RA, SI } }, { "twlgti", OPTO(3,TOLGT), OPTO_MASK, PPCCOM, { RA, SI } }, { "tlgti", OPTO(3,TOLGT), OPTO_MASK, PWRCOM, { RA, SI } }, { "twllti", OPTO(3,TOLLT), OPTO_MASK, PPCCOM, { RA, SI } }, { "tllti", OPTO(3,TOLLT), OPTO_MASK, PWRCOM, { RA, SI } }, { "tweqi", OPTO(3,TOEQ), OPTO_MASK, PPCCOM, { RA, SI } }, { "teqi", OPTO(3,TOEQ), OPTO_MASK, PWRCOM, { RA, SI } }, { "twlgei", OPTO(3,TOLGE), OPTO_MASK, PPCCOM, { RA, SI } }, { "tlgei", OPTO(3,TOLGE), OPTO_MASK, PWRCOM, { RA, SI } }, { "twlnli", OPTO(3,TOLNL), OPTO_MASK, PPCCOM, { RA, SI } }, { "tlnli", OPTO(3,TOLNL), OPTO_MASK, PWRCOM, { RA, SI } }, { "twllei", OPTO(3,TOLLE), OPTO_MASK, PPCCOM, { RA, SI } }, { "tllei", OPTO(3,TOLLE), OPTO_MASK, PWRCOM, { RA, SI } }, { "twlngi", OPTO(3,TOLNG), OPTO_MASK, PPCCOM, { RA, SI } }, { "tlngi", OPTO(3,TOLNG), OPTO_MASK, PWRCOM, { RA, SI } }, { "twgti", OPTO(3,TOGT), OPTO_MASK, PPCCOM, { RA, SI } }, { "tgti", OPTO(3,TOGT), OPTO_MASK, PWRCOM, { RA, SI } }, { "twgei", OPTO(3,TOGE), OPTO_MASK, PPCCOM, { RA, SI } }, { "tgei", OPTO(3,TOGE), OPTO_MASK, PWRCOM, { RA, SI } }, { "twnli", OPTO(3,TONL), OPTO_MASK, PPCCOM, { RA, SI } }, { "tnli", OPTO(3,TONL), OPTO_MASK, PWRCOM, { RA, SI } }, { "twlti", OPTO(3,TOLT), OPTO_MASK, PPCCOM, { RA, SI } }, { "tlti", OPTO(3,TOLT), OPTO_MASK, PWRCOM, { RA, SI } }, { "twlei", OPTO(3,TOLE), OPTO_MASK, PPCCOM, { RA, SI } }, { "tlei", OPTO(3,TOLE), OPTO_MASK, PWRCOM, { RA, SI } }, { "twngi", OPTO(3,TONG), OPTO_MASK, PPCCOM, { RA, SI } }, { "tngi", OPTO(3,TONG), OPTO_MASK, PWRCOM, { RA, SI } }, { "twnei", OPTO(3,TONE), OPTO_MASK, PPCCOM, { RA, SI } }, { "tnei", OPTO(3,TONE), OPTO_MASK, PWRCOM, { RA, SI } }, { "twi", OP(3), OP_MASK, PPCCOM, { TO, RA, SI } }, { "ti", OP(3), OP_MASK, PWRCOM, { TO, RA, SI } }, { "mfvscr", VX(4, 1540), VX_MASK, PPCVEC, { VD } }, { "mtvscr", VX(4, 1604), VX_MASK, PPCVEC, { VB } }, { "vaddcuw", VX(4, 384), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vaddfp", VX(4, 10), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vaddsbs", VX(4, 768), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vaddshs", VX(4, 832), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vaddsws", VX(4, 896), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vaddubm", VX(4, 0), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vaddubs", VX(4, 512), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vadduhm", VX(4, 64), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vadduhs", VX(4, 576), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vadduwm", VX(4, 128), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vadduws", VX(4, 640), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vand", VX(4, 1028), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vandc", VX(4, 1092), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vavgsb", VX(4, 1282), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vavgsh", VX(4, 1346), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vavgsw", VX(4, 1410), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vavgub", VX(4, 1026), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vavguh", VX(4, 1090), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vavguw", VX(4, 1154), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vcfsx", VX(4, 842), VX_MASK, PPCVEC, { VD, VB, UIMM } }, { "vcfux", VX(4, 778), VX_MASK, PPCVEC, { VD, VB, UIMM } }, { "vcmpbfp", VXR(4, 966, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpbfp.", VXR(4, 966, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpeqfp", VXR(4, 198, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpeqfp.", VXR(4, 198, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpequb", VXR(4, 6, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpequb.", VXR(4, 6, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpequh", VXR(4, 70, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpequh.", VXR(4, 70, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpequw", VXR(4, 134, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpequw.", VXR(4, 134, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgefp", VXR(4, 454, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgefp.", VXR(4, 454, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgtfp", VXR(4, 710, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgtfp.", VXR(4, 710, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgtsb", VXR(4, 774, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgtsb.", VXR(4, 774, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgtsh", VXR(4, 838, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgtsh.", VXR(4, 838, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgtsw", VXR(4, 902, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgtsw.", VXR(4, 902, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgtub", VXR(4, 518, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgtub.", VXR(4, 518, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgtuh", VXR(4, 582, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgtuh.", VXR(4, 582, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgtuw", VXR(4, 646, 0), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vcmpgtuw.", VXR(4, 646, 1), VXR_MASK, PPCVEC, { VD, VA, VB } }, { "vctsxs", VX(4, 970), VX_MASK, PPCVEC, { VD, VB, UIMM } }, { "vctuxs", VX(4, 906), VX_MASK, PPCVEC, { VD, VB, UIMM } }, { "vexptefp", VX(4, 394), VX_MASK, PPCVEC, { VD, VB } }, { "vlogefp", VX(4, 458), VX_MASK, PPCVEC, { VD, VB } }, { "vmaddfp", VXA(4, 46), VXA_MASK, PPCVEC, { VD, VA, VC, VB } }, { "vmaxfp", VX(4, 1034), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmaxsb", VX(4, 258), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmaxsh", VX(4, 322), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmaxsw", VX(4, 386), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmaxub", VX(4, 2), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmaxuh", VX(4, 66), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmaxuw", VX(4, 130), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmhaddshs", VXA(4, 32), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, { "vmhraddshs", VXA(4, 33), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, { "vminfp", VX(4, 1098), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vminsb", VX(4, 770), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vminsh", VX(4, 834), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vminsw", VX(4, 898), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vminub", VX(4, 514), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vminuh", VX(4, 578), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vminuw", VX(4, 642), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmladduhm", VXA(4, 34), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, { "vmrghb", VX(4, 12), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmrghh", VX(4, 76), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmrghw", VX(4, 140), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmrglb", VX(4, 268), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmrglh", VX(4, 332), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmrglw", VX(4, 396), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmsummbm", VXA(4, 37), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, { "vmsumshm", VXA(4, 40), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, { "vmsumshs", VXA(4, 41), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, { "vmsumubm", VXA(4, 36), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, { "vmsumuhm", VXA(4, 38), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, { "vmsumuhs", VXA(4, 39), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, { "vmulesb", VX(4, 776), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmulesh", VX(4, 840), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmuleub", VX(4, 520), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmuleuh", VX(4, 584), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmulosb", VX(4, 264), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmulosh", VX(4, 328), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmuloub", VX(4, 8), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmulouh", VX(4, 72), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vnmsubfp", VXA(4, 47), VXA_MASK, PPCVEC, { VD, VA, VC, VB } }, { "vnot", VX(4, 1284), VX_MASK, PPCVEC, { VD, VA, VAB } }, { "vnor", VX(4, 1284), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vmr", VX(4, 1156), VX_MASK, PPCVEC, { VD, VA, VAB } }, { "vor", VX(4, 1156), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vperm", VXA(4, 43), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, { "vpkpx", VX(4, 782), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vpkshss", VX(4, 398), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vpkshus", VX(4, 270), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vpkswss", VX(4, 462), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vpkswus", VX(4, 334), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vpkuhum", VX(4, 14), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vpkuhus", VX(4, 142), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vpkuwum", VX(4, 78), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vpkuwus", VX(4, 206), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vrefp", VX(4, 266), VX_MASK, PPCVEC, { VD, VB } }, { "vrfim", VX(4, 714), VX_MASK, PPCVEC, { VD, VB } }, { "vrfin", VX(4, 522), VX_MASK, PPCVEC, { VD, VB } }, { "vrfip", VX(4, 650), VX_MASK, PPCVEC, { VD, VB } }, { "vrfiz", VX(4, 586), VX_MASK, PPCVEC, { VD, VB } }, { "vrlb", VX(4, 4), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vrlh", VX(4, 68), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vrlw", VX(4, 132), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vrsqrtefp", VX(4, 330), VX_MASK, PPCVEC, { VD, VB } }, { "vsel", VXA(4, 42), VXA_MASK, PPCVEC, { VD, VA, VB, VC } }, { "vsl", VX(4, 452), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vslb", VX(4, 260), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsldoi", VXA(4, 44), VXA_MASK, PPCVEC, { VD, VA, VB, SHB } }, { "vslh", VX(4, 324), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vslo", VX(4, 1036), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vslw", VX(4, 388), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vspltb", VX(4, 524), VX_MASK, PPCVEC, { VD, VB, UIMM } }, { "vsplth", VX(4, 588), VX_MASK, PPCVEC, { VD, VB, UIMM } }, { "vspltisb", VX(4, 780), VX_MASK, PPCVEC, { VD, SIMM } }, { "vspltish", VX(4, 844), VX_MASK, PPCVEC, { VD, SIMM } }, { "vspltisw", VX(4, 908), VX_MASK, PPCVEC, { VD, SIMM } }, { "vspltw", VX(4, 652), VX_MASK, PPCVEC, { VD, VB, UIMM } }, { "vsr", VX(4, 708), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsrab", VX(4, 772), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsrah", VX(4, 836), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsraw", VX(4, 900), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsrb", VX(4, 516), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsrh", VX(4, 580), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsro", VX(4, 1100), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsrw", VX(4, 644), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsubcuw", VX(4, 1408), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsubfp", VX(4, 74), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsubsbs", VX(4, 1792), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsubshs", VX(4, 1856), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsubsws", VX(4, 1920), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsububm", VX(4, 1024), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsububs", VX(4, 1536), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsubuhm", VX(4, 1088), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsubuhs", VX(4, 1600), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsubuwm", VX(4, 1152), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsubuws", VX(4, 1664), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsumsws", VX(4, 1928), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsum2sws", VX(4, 1672), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsum4sbs", VX(4, 1800), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsum4shs", VX(4, 1608), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsum4ubs", VX(4, 1544), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vupkhpx", VX(4, 846), VX_MASK, PPCVEC, { VD, VB } }, { "vupkhsb", VX(4, 526), VX_MASK, PPCVEC, { VD, VB } }, { "vupkhsh", VX(4, 590), VX_MASK, PPCVEC, { VD, VB } }, { "vupklpx", VX(4, 974), VX_MASK, PPCVEC, { VD, VB } }, { "vupklsb", VX(4, 654), VX_MASK, PPCVEC, { VD, VB } }, { "vupklsh", VX(4, 718), VX_MASK, PPCVEC, { VD, VB } }, { "vxor", VX(4, 1220), VX_MASK, PPCVEC, { VD, VA, VB } }, { "vsldoi128", VX128_5(4, 16), VX128_5_MASK, PPCVEC, { VS128, VA128, VB128, SHB } }, { "lvsl128", VX128_1(4, 3), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "lvsr128", VX128_1(4, 67), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "lvewx128", VX128_1(4, 131), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "lvx128", VX128_1(4, 195), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "stvewx128", VX128_1(4, 387), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "stvx128", VX128_1(4, 451), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "lvxl128", VX128_1(4, 707), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "stvxl128", VX128_1(4, 963), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "lvlx128", VX128_1(4, 1027), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "lvrx128", VX128_1(4, 1091), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "stvlx128", VX128_1(4, 1283), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "stvrx128", VX128_1(4, 1347), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "lvlxl128", VX128_1(4, 1539), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "lvrxl128", VX128_1(4, 1603), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "stvlxl128", VX128_1(4, 1795), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "stvrxl128", VX128_1(4, 1859), VX128_1_MASK, PPCVEC, { VS128, RA0, RB } }, { "vperm128", VX128_2(5, 0), VX128_2_MASK, PPCVEC, { VD128, VA128, VB128, VC128 } }, { "vaddfp128", VX128(5, 16), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vsubfp128", VX128(5, 80), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vmulfp128", VX128(5, 144), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vmaddfp128", VX128(5, 208), VX128_MASK, PPCVEC, { VD128, VA128, VB128, VS128 } }, { "vmaddcfp128",VX128(5, 272), VX128_MASK, PPCVEC, { VD128, VA128, VS128, VB128 } }, { "vnmsubfp128",VX128(5, 336), VX128_MASK, PPCVEC, { VD128, VA128, VB128, VS128 } }, { "vmsum3fp128",VX128(5, 400), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vmsum4fp128",VX128(5, 464), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vpkshss128", VX128(5, 512), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vand128", VX128(5, 528), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vpkshus128", VX128(5, 576), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vandc128", VX128(5, 592), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vpkswss128", VX128(5, 640), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vnor128", VX128(5, 656), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vpkswus128", VX128(5, 704), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vor128", VX128(5, 720), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vpkuhum128", VX128(5, 768), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vxor128", VX128(5, 784), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vpkuhus128", VX128(5, 832), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vsel128", VX128(5, 848), VX128_MASK, PPCVEC, { VD128, VA128, VB128, VS128 } }, { "vpkuwum128", VX128(5, 896), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vslo128", VX128(5, 912), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vpkuwus128", VX128(5, 960), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vsro128", VX128(5, 976), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vpermwi128", VX128_P(6, 528), VX128_P_MASK, PPCVEC, { VD128, VB128, VPERM128 } }, { "vcfpsxws128", VX128_3(6, 560), VX128_3_MASK, PPCVEC, { VD128, VB128, SIMM } }, { "vcfpuxws128", VX128_3(6, 624), VX128_3_MASK, PPCVEC, { VD128, VB128, UIMM } }, { "vcsxwfp128", VX128_3(6, 688), VX128_3_MASK, PPCVEC, { VD128, VB128, SIMM } }, { "vcuxwfp128", VX128_3(6, 752), VX128_3_MASK, PPCVEC, { VD128, VB128, UIMM } }, { "vrfim128", VX128_3(6, 816), VX128_3_MASK, PPCVEC, { VD128, VB128 } }, { "vrfin128", VX128_3(6, 880), VX128_3_MASK, PPCVEC, { VD128, VB128 } }, { "vrfip128", VX128_3(6, 944), VX128_3_MASK, PPCVEC, { VD128, VB128 } }, { "vrfiz128", VX128_3(6, 1008), VX128_3_MASK, PPCVEC, { VD128, VB128 } }, { "vpkd3d128", VX128_4(6, 1552), VX128_4_MASK, PPCVEC, { VD128, VB128, VD3D0, VD3D1, VD3D2} }, { "vrefp128", VX128_3(6, 1584), VX128_3_MASK, PPCVEC, { VD128, VB128 } }, { "vrsqrtefp128",VX128_3(6, 1648), VX128_3_MASK, PPCVEC, { VD128, VB128 } }, { "vexptefp128", VX128_3(6, 1712), VX128_3_MASK, PPCVEC, { VD128, VB128 } }, { "vlogefp128", VX128_3(6, 1776), VX128_3_MASK, PPCVEC, { VD128, VB128 } }, { "vrlimi128", VX128_4(6, 1808), VX128_4_MASK, PPCVEC, { VD128, VB128, UIMM, VD3D2} }, { "vspltw128", VX128_3(6, 1840), VX128_3_MASK, PPCVEC, { VD128, VB128, UIMM } }, { "vspltisw128", VX128_3(6, 1904), VX128_3_MASK, PPCVEC, { VD128, VB128, SIMM } }, { "vupkd3d128", VX128_3(6, 2032), VX128_3_MASK, PPCVEC, { VD128, VB128, UIMM } }, { "vcmpeqfp128", VX128(6, 0), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vcmpeqfp128.",VX128(6, 64), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vrlw128", VX128(6, 80), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vcmpgefp128", VX128(6, 128), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vcmpgefp128.",VX128(6, 192), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vslw128", VX128(6, 208), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vcmpgtfp128", VX128(6, 256), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vcmpgtfp128.",VX128(6, 320), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vsraw128", VX128(6, 336), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vcmpbfp128", VX128(6, 384), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vcmpbfp128.", VX128(6, 448), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vsrw128", VX128(6, 464), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vcmpequw128", VX128(6, 512), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vcmpequw128.",VX128(6, 576), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vmaxfp128", VX128(6, 640), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vminfp128", VX128(6, 704), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vmrghw128", VX128(6, 768), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vmrglw128", VX128(6, 832), VX128_MASK, PPCVEC, { VD128, VA128, VB128 } }, { "vupkhsb128", VX128(6, 896), VX128_MASK, PPCVEC, { VD128, VB128 } }, { "vupklsb128", VX128(6, 960), VX128_MASK, PPCVEC, { VD128, VB128 } }, { "mulli", OP(7), OP_MASK, PPCCOM, { RT, RA, SI } }, { "subfic", OP(8), OP_MASK, PPCCOM, { RT, RA, SI } }, { "cmplwi", OPL(10,0), OPL_MASK, PPCCOM, { OBF, RA, UI } }, { "cmpldi", OPL(10,1), OPL_MASK, PPC64, { OBF, RA, UI } }, { "cmpli", OP(10), OP_MASK, PPCONLY, { BF, L, RA, UI } }, { "cmpwi", OPL(11,0), OPL_MASK, PPCCOM, { OBF, RA, SI } }, { "cmpdi", OPL(11,1), OPL_MASK, PPC64, { OBF, RA, SI } }, { "cmpi", OP(11), OP_MASK, PPCONLY, { BF, L, RA, SI } }, { "addic", OP(12), OP_MASK, PPCCOM, { RT, RA, SI } }, { "subic", OP(12), OP_MASK, PPCCOM, { RT, RA, NSI } }, { "addic.", OP(13), OP_MASK, PPCCOM, { RT, RA, SI } }, { "subic.", OP(13), OP_MASK, PPCCOM, { RT, RA, NSI } }, { "li", OP(14), DRA_MASK, PPCCOM, { RT, SI } }, { "addi", OP(14), OP_MASK, PPCCOM, { RT, RA0, SI } }, { "subi", OP(14), OP_MASK, PPCCOM, { RT, RA0, NSI } }, { "la", OP(14), OP_MASK, PPCCOM, { RT, D, RA } }, { "lis", OP(15), DRA_MASK, PPCCOM, { RT, SISIGNOPT } }, { "addis", OP(15), OP_MASK, PPCCOM, { RT, RA0, SISIGNOPT } }, { "subis", OP(15), OP_MASK, PPCCOM, { RT, RA0, NSI } }, { "bdnz-", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BDM } }, { "bdnz+", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BDP } }, { "bdnz", BBO(16,BODNZ,0,0), BBOATBI_MASK, PPCCOM, { BD } }, { "bdnzl-", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, { BDM } }, { "bdnzl+", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, { BDP } }, { "bdnzl", BBO(16,BODNZ,0,1), BBOATBI_MASK, PPCCOM, { BD } }, { "bdnza-", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, { BDMA } }, { "bdnza+", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, { BDPA } }, { "bdnza", BBO(16,BODNZ,1,0), BBOATBI_MASK, PPCCOM, { BDA } }, { "bdnzla-", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, { BDMA } }, { "bdnzla+", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, { BDPA } }, { "bdnzla", BBO(16,BODNZ,1,1), BBOATBI_MASK, PPCCOM, { BDA } }, { "bdz-", BBO(16,BODZ,0,0), BBOATBI_MASK, PPCCOM, { BDM } }, { "bdz+", BBO(16,BODZ,0,0), BBOATBI_MASK, PPCCOM, { BDP } }, { "bdz", BBO(16,BODZ,0,0), BBOATBI_MASK, COM, { BD } }, { "bdzl-", BBO(16,BODZ,0,1), BBOATBI_MASK, PPCCOM, { BDM } }, { "bdzl+", BBO(16,BODZ,0,1), BBOATBI_MASK, PPCCOM, { BDP } }, { "bdzl", BBO(16,BODZ,0,1), BBOATBI_MASK, COM, { BD } }, { "bdza-", BBO(16,BODZ,1,0), BBOATBI_MASK, PPCCOM, { BDMA } }, { "bdza+", BBO(16,BODZ,1,0), BBOATBI_MASK, PPCCOM, { BDPA } }, { "bdza", BBO(16,BODZ,1,0), BBOATBI_MASK, COM, { BDA } }, { "bdzla-", BBO(16,BODZ,1,1), BBOATBI_MASK, PPCCOM, { BDMA } }, { "bdzla+", BBO(16,BODZ,1,1), BBOATBI_MASK, PPCCOM, { BDPA } }, { "bdzla", BBO(16,BODZ,1,1), BBOATBI_MASK, COM, { BDA } }, { "blt-", BBOCB(16,BOT,CBLT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "blt+", BBOCB(16,BOT,CBLT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "blt", BBOCB(16,BOT,CBLT,0,0), BBOATCB_MASK, COM, { CR, BD } }, { "bltl-", BBOCB(16,BOT,CBLT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bltl+", BBOCB(16,BOT,CBLT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bltl", BBOCB(16,BOT,CBLT,0,1), BBOATCB_MASK, COM, { CR, BD } }, { "blta-", BBOCB(16,BOT,CBLT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "blta+", BBOCB(16,BOT,CBLT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "blta", BBOCB(16,BOT,CBLT,1,0), BBOATCB_MASK, COM, { CR, BDA } }, { "bltla-", BBOCB(16,BOT,CBLT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bltla+", BBOCB(16,BOT,CBLT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bltla", BBOCB(16,BOT,CBLT,1,1), BBOATCB_MASK, COM, { CR, BDA } }, { "bgt-", BBOCB(16,BOT,CBGT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bgt+", BBOCB(16,BOT,CBGT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bgt", BBOCB(16,BOT,CBGT,0,0), BBOATCB_MASK, COM, { CR, BD } }, { "bgtl-", BBOCB(16,BOT,CBGT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bgtl+", BBOCB(16,BOT,CBGT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bgtl", BBOCB(16,BOT,CBGT,0,1), BBOATCB_MASK, COM, { CR, BD } }, { "bgta-", BBOCB(16,BOT,CBGT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bgta+", BBOCB(16,BOT,CBGT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bgta", BBOCB(16,BOT,CBGT,1,0), BBOATCB_MASK, COM, { CR, BDA } }, { "bgtla-", BBOCB(16,BOT,CBGT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bgtla+", BBOCB(16,BOT,CBGT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bgtla", BBOCB(16,BOT,CBGT,1,1), BBOATCB_MASK, COM, { CR, BDA } }, { "beq-", BBOCB(16,BOT,CBEQ,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "beq+", BBOCB(16,BOT,CBEQ,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "beq", BBOCB(16,BOT,CBEQ,0,0), BBOATCB_MASK, COM, { CR, BD } }, { "beql-", BBOCB(16,BOT,CBEQ,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "beql+", BBOCB(16,BOT,CBEQ,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "beql", BBOCB(16,BOT,CBEQ,0,1), BBOATCB_MASK, COM, { CR, BD } }, { "beqa-", BBOCB(16,BOT,CBEQ,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "beqa+", BBOCB(16,BOT,CBEQ,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "beqa", BBOCB(16,BOT,CBEQ,1,0), BBOATCB_MASK, COM, { CR, BDA } }, { "beqla-", BBOCB(16,BOT,CBEQ,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "beqla+", BBOCB(16,BOT,CBEQ,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "beqla", BBOCB(16,BOT,CBEQ,1,1), BBOATCB_MASK, COM, { CR, BDA } }, { "bso-", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bso+", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bso", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, COM, { CR, BD } }, { "bsol-", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bsol+", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bsol", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, COM, { CR, BD } }, { "bsoa-", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bsoa+", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bsoa", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, COM, { CR, BDA } }, { "bsola-", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bsola+", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bsola", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, COM, { CR, BDA } }, { "bun-", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bun+", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bun", BBOCB(16,BOT,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BD } }, { "bunl-", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bunl+", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bunl", BBOCB(16,BOT,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BD } }, { "buna-", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "buna+", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "buna", BBOCB(16,BOT,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDA } }, { "bunla-", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bunla+", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bunla", BBOCB(16,BOT,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDA } }, { "bge-", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bge+", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bge", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, COM, { CR, BD } }, { "bgel-", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bgel+", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bgel", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, COM, { CR, BD } }, { "bgea-", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bgea+", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bgea", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, COM, { CR, BDA } }, { "bgela-", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bgela+", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bgela", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, COM, { CR, BDA } }, { "bnl-", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bnl+", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bnl", BBOCB(16,BOF,CBLT,0,0), BBOATCB_MASK, COM, { CR, BD } }, { "bnll-", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bnll+", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bnll", BBOCB(16,BOF,CBLT,0,1), BBOATCB_MASK, COM, { CR, BD } }, { "bnla-", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bnla+", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bnla", BBOCB(16,BOF,CBLT,1,0), BBOATCB_MASK, COM, { CR, BDA } }, { "bnlla-", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bnlla+", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bnlla", BBOCB(16,BOF,CBLT,1,1), BBOATCB_MASK, COM, { CR, BDA } }, { "ble-", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "ble+", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "ble", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, COM, { CR, BD } }, { "blel-", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "blel+", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "blel", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, COM, { CR, BD } }, { "blea-", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "blea+", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "blea", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, COM, { CR, BDA } }, { "blela-", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "blela+", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "blela", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, COM, { CR, BDA } }, { "bng-", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bng+", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bng", BBOCB(16,BOF,CBGT,0,0), BBOATCB_MASK, COM, { CR, BD } }, { "bngl-", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bngl+", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bngl", BBOCB(16,BOF,CBGT,0,1), BBOATCB_MASK, COM, { CR, BD } }, { "bnga-", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bnga+", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bnga", BBOCB(16,BOF,CBGT,1,0), BBOATCB_MASK, COM, { CR, BDA } }, { "bngla-", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bngla+", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bngla", BBOCB(16,BOF,CBGT,1,1), BBOATCB_MASK, COM, { CR, BDA } }, { "bne-", BBOCB(16,BOF,CBEQ,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bne+", BBOCB(16,BOF,CBEQ,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bne", BBOCB(16,BOF,CBEQ,0,0), BBOATCB_MASK, COM, { CR, BD } }, { "bnel-", BBOCB(16,BOF,CBEQ,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bnel+", BBOCB(16,BOF,CBEQ,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bnel", BBOCB(16,BOF,CBEQ,0,1), BBOATCB_MASK, COM, { CR, BD } }, { "bnea-", BBOCB(16,BOF,CBEQ,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bnea+", BBOCB(16,BOF,CBEQ,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bnea", BBOCB(16,BOF,CBEQ,1,0), BBOATCB_MASK, COM, { CR, BDA } }, { "bnela-", BBOCB(16,BOF,CBEQ,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bnela+", BBOCB(16,BOF,CBEQ,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bnela", BBOCB(16,BOF,CBEQ,1,1), BBOATCB_MASK, COM, { CR, BDA } }, { "bns-", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bns+", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bns", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, COM, { CR, BD } }, { "bnsl-", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bnsl+", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bnsl", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, COM, { CR, BD } }, { "bnsa-", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bnsa+", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bnsa", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, COM, { CR, BDA } }, { "bnsla-", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bnsla+", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bnsla", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, COM, { CR, BDA } }, { "bnu-", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bnu+", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bnu", BBOCB(16,BOF,CBSO,0,0), BBOATCB_MASK, PPCCOM, { CR, BD } }, { "bnul-", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDM } }, { "bnul+", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BDP } }, { "bnul", BBOCB(16,BOF,CBSO,0,1), BBOATCB_MASK, PPCCOM, { CR, BD } }, { "bnua-", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bnua+", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bnua", BBOCB(16,BOF,CBSO,1,0), BBOATCB_MASK, PPCCOM, { CR, BDA } }, { "bnula-", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDMA } }, { "bnula+", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDPA } }, { "bnula", BBOCB(16,BOF,CBSO,1,1), BBOATCB_MASK, PPCCOM, { CR, BDA } }, { "bdnzt-", BBO(16,BODNZT,0,0), BBOY_MASK, NOPOWER4, { BI, BDM } }, { "bdnzt+", BBO(16,BODNZT,0,0), BBOY_MASK, NOPOWER4, { BI, BDP } }, { "bdnzt", BBO(16,BODNZT,0,0), BBOY_MASK, PPCCOM, { BI, BD } }, { "bdnztl-", BBO(16,BODNZT,0,1), BBOY_MASK, NOPOWER4, { BI, BDM } }, { "bdnztl+", BBO(16,BODNZT,0,1), BBOY_MASK, NOPOWER4, { BI, BDP } }, { "bdnztl", BBO(16,BODNZT,0,1), BBOY_MASK, PPCCOM, { BI, BD } }, { "bdnzta-", BBO(16,BODNZT,1,0), BBOY_MASK, NOPOWER4, { BI, BDMA } }, { "bdnzta+", BBO(16,BODNZT,1,0), BBOY_MASK, NOPOWER4, { BI, BDPA } }, { "bdnzta", BBO(16,BODNZT,1,0), BBOY_MASK, PPCCOM, { BI, BDA } }, { "bdnztla-",BBO(16,BODNZT,1,1), BBOY_MASK, NOPOWER4, { BI, BDMA } }, { "bdnztla+",BBO(16,BODNZT,1,1), BBOY_MASK, NOPOWER4, { BI, BDPA } }, { "bdnztla", BBO(16,BODNZT,1,1), BBOY_MASK, PPCCOM, { BI, BDA } }, { "bdnzf-", BBO(16,BODNZF,0,0), BBOY_MASK, NOPOWER4, { BI, BDM } }, { "bdnzf+", BBO(16,BODNZF,0,0), BBOY_MASK, NOPOWER4, { BI, BDP } }, { "bdnzf", BBO(16,BODNZF,0,0), BBOY_MASK, PPCCOM, { BI, BD } }, { "bdnzfl-", BBO(16,BODNZF,0,1), BBOY_MASK, NOPOWER4, { BI, BDM } }, { "bdnzfl+", BBO(16,BODNZF,0,1), BBOY_MASK, NOPOWER4, { BI, BDP } }, { "bdnzfl", BBO(16,BODNZF,0,1), BBOY_MASK, PPCCOM, { BI, BD } }, { "bdnzfa-", BBO(16,BODNZF,1,0), BBOY_MASK, NOPOWER4, { BI, BDMA } }, { "bdnzfa+", BBO(16,BODNZF,1,0), BBOY_MASK, NOPOWER4, { BI, BDPA } }, { "bdnzfa", BBO(16,BODNZF,1,0), BBOY_MASK, PPCCOM, { BI, BDA } }, { "bdnzfla-",BBO(16,BODNZF,1,1), BBOY_MASK, NOPOWER4, { BI, BDMA } }, { "bdnzfla+",BBO(16,BODNZF,1,1), BBOY_MASK, NOPOWER4, { BI, BDPA } }, { "bdnzfla", BBO(16,BODNZF,1,1), BBOY_MASK, PPCCOM, { BI, BDA } }, { "bt-", BBO(16,BOT,0,0), BBOAT_MASK, PPCCOM, { BI, BDM } }, { "bt+", BBO(16,BOT,0,0), BBOAT_MASK, PPCCOM, { BI, BDP } }, { "bt", BBO(16,BOT,0,0), BBOAT_MASK, PPCCOM, { BI, BD } }, { "btl-", BBO(16,BOT,0,1), BBOAT_MASK, PPCCOM, { BI, BDM } }, { "btl+", BBO(16,BOT,0,1), BBOAT_MASK, PPCCOM, { BI, BDP } }, { "btl", BBO(16,BOT,0,1), BBOAT_MASK, PPCCOM, { BI, BD } }, { "bta-", BBO(16,BOT,1,0), BBOAT_MASK, PPCCOM, { BI, BDMA } }, { "bta+", BBO(16,BOT,1,0), BBOAT_MASK, PPCCOM, { BI, BDPA } }, { "bta", BBO(16,BOT,1,0), BBOAT_MASK, PPCCOM, { BI, BDA } }, { "btla-", BBO(16,BOT,1,1), BBOAT_MASK, PPCCOM, { BI, BDMA } }, { "btla+", BBO(16,BOT,1,1), BBOAT_MASK, PPCCOM, { BI, BDPA } }, { "btla", BBO(16,BOT,1,1), BBOAT_MASK, PPCCOM, { BI, BDA } }, { "bf-", BBO(16,BOF,0,0), BBOAT_MASK, PPCCOM, { BI, BDM } }, { "bf+", BBO(16,BOF,0,0), BBOAT_MASK, PPCCOM, { BI, BDP } }, { "bf", BBO(16,BOF,0,0), BBOAT_MASK, PPCCOM, { BI, BD } }, { "bfl-", BBO(16,BOF,0,1), BBOAT_MASK, PPCCOM, { BI, BDM } }, { "bfl+", BBO(16,BOF,0,1), BBOAT_MASK, PPCCOM, { BI, BDP } }, { "bfl", BBO(16,BOF,0,1), BBOAT_MASK, PPCCOM, { BI, BD } }, { "bfa-", BBO(16,BOF,1,0), BBOAT_MASK, PPCCOM, { BI, BDMA } }, { "bfa+", BBO(16,BOF,1,0), BBOAT_MASK, PPCCOM, { BI, BDPA } }, { "bfa", BBO(16,BOF,1,0), BBOAT_MASK, PPCCOM, { BI, BDA } }, { "bfla-", BBO(16,BOF,1,1), BBOAT_MASK, PPCCOM, { BI, BDMA } }, { "bfla+", BBO(16,BOF,1,1), BBOAT_MASK, PPCCOM, { BI, BDPA } }, { "bfla", BBO(16,BOF,1,1), BBOAT_MASK, PPCCOM, { BI, BDA } }, { "bdzt-", BBO(16,BODZT,0,0), BBOY_MASK, NOPOWER4, { BI, BDM } }, { "bdzt+", BBO(16,BODZT,0,0), BBOY_MASK, NOPOWER4, { BI, BDP } }, { "bdzt", BBO(16,BODZT,0,0), BBOY_MASK, PPCCOM, { BI, BD } }, { "bdztl-", BBO(16,BODZT,0,1), BBOY_MASK, NOPOWER4, { BI, BDM } }, { "bdztl+", BBO(16,BODZT,0,1), BBOY_MASK, NOPOWER4, { BI, BDP } }, { "bdztl", BBO(16,BODZT,0,1), BBOY_MASK, PPCCOM, { BI, BD } }, { "bdzta-", BBO(16,BODZT,1,0), BBOY_MASK, NOPOWER4, { BI, BDMA } }, { "bdzta+", BBO(16,BODZT,1,0), BBOY_MASK, NOPOWER4, { BI, BDPA } }, { "bdzta", BBO(16,BODZT,1,0), BBOY_MASK, PPCCOM, { BI, BDA } }, { "bdztla-", BBO(16,BODZT,1,1), BBOY_MASK, NOPOWER4, { BI, BDMA } }, { "bdztla+", BBO(16,BODZT,1,1), BBOY_MASK, NOPOWER4, { BI, BDPA } }, { "bdztla", BBO(16,BODZT,1,1), BBOY_MASK, PPCCOM, { BI, BDA } }, { "bdzf-", BBO(16,BODZF,0,0), BBOY_MASK, NOPOWER4, { BI, BDM } }, { "bdzf+", BBO(16,BODZF,0,0), BBOY_MASK, NOPOWER4, { BI, BDP } }, { "bdzf", BBO(16,BODZF,0,0), BBOY_MASK, PPCCOM, { BI, BD } }, { "bdzfl-", BBO(16,BODZF,0,1), BBOY_MASK, NOPOWER4, { BI, BDM } }, { "bdzfl+", BBO(16,BODZF,0,1), BBOY_MASK, NOPOWER4, { BI, BDP } }, { "bdzfl", BBO(16,BODZF,0,1), BBOY_MASK, PPCCOM, { BI, BD } }, { "bdzfa-", BBO(16,BODZF,1,0), BBOY_MASK, NOPOWER4, { BI, BDMA } }, { "bdzfa+", BBO(16,BODZF,1,0), BBOY_MASK, NOPOWER4, { BI, BDPA } }, { "bdzfa", BBO(16,BODZF,1,0), BBOY_MASK, PPCCOM, { BI, BDA } }, { "bdzfla-", BBO(16,BODZF,1,1), BBOY_MASK, NOPOWER4, { BI, BDMA } }, { "bdzfla+", BBO(16,BODZF,1,1), BBOY_MASK, NOPOWER4, { BI, BDPA } }, { "bdzfla", BBO(16,BODZF,1,1), BBOY_MASK, PPCCOM, { BI, BDA } }, { "bc-", B(16,0,0), B_MASK, PPCCOM, { BOE, BI, BDM } }, { "bc+", B(16,0,0), B_MASK, PPCCOM, { BOE, BI, BDP } }, { "bc", B(16,0,0), B_MASK, COM, { BO, BI, BD } }, { "bcl-", B(16,0,1), B_MASK, PPCCOM, { BOE, BI, BDM } }, { "bcl+", B(16,0,1), B_MASK, PPCCOM, { BOE, BI, BDP } }, { "bcl", B(16,0,1), B_MASK, COM, { BO, BI, BD } }, { "bca-", B(16,1,0), B_MASK, PPCCOM, { BOE, BI, BDMA } }, { "bca+", B(16,1,0), B_MASK, PPCCOM, { BOE, BI, BDPA } }, { "bca", B(16,1,0), B_MASK, COM, { BO, BI, BDA } }, { "bcla-", B(16,1,1), B_MASK, PPCCOM, { BOE, BI, BDMA } }, { "bcla+", B(16,1,1), B_MASK, PPCCOM, { BOE, BI, BDPA } }, { "bcla", B(16,1,1), B_MASK, COM, { BO, BI, BDA } }, { "sc", SC(17,1,0), 0xffffffff, PPC, { 0 } }, { "b", B(18,0,0), B_MASK, COM, { LI } }, { "bl", B(18,0,1), B_MASK, COM, { LI } }, { "ba", B(18,1,0), B_MASK, COM, { LIA } }, { "bla", B(18,1,1), B_MASK, COM, { LIA } }, { "mcrf", XL(19,0), XLBB_MASK|(3<<21)|(3<<16), COM, { BF, BFA } }, { "blr", XLO(19,BOU,16,0), XLBOBIBB_MASK, PPCCOM, { 0 } }, { "blrl", XLO(19,BOU,16,1), XLBOBIBB_MASK, PPCCOM, { 0 } }, { "bdnzlr", XLO(19,BODNZ,16,0), XLBOBIBB_MASK, PPCCOM, { 0 } }, { "bdnzlr-", XLO(19,BODNZ,16,0), XLBOBIBB_MASK, NOPOWER4, { 0 } }, { "bdnzlr+", XLO(19,BODNZP,16,0), XLBOBIBB_MASK, NOPOWER4, { 0 } }, { "bdnzlr-", XLO(19,BODNZM4,16,0), XLBOBIBB_MASK, POWER4, { 0 } }, { "bdnzlr+", XLO(19,BODNZP4,16,0), XLBOBIBB_MASK, POWER4, { 0 } }, { "bdnzlrl", XLO(19,BODNZ,16,1), XLBOBIBB_MASK, PPCCOM, { 0 } }, { "bdnzlrl-",XLO(19,BODNZ,16,1), XLBOBIBB_MASK, NOPOWER4, { 0 } }, { "bdnzlrl+",XLO(19,BODNZP,16,1), XLBOBIBB_MASK, NOPOWER4, { 0 } }, { "bdnzlrl-",XLO(19,BODNZM4,16,1), XLBOBIBB_MASK, POWER4, { 0 } }, { "bdnzlrl+",XLO(19,BODNZP4,16,1), XLBOBIBB_MASK, POWER4, { 0 } }, { "bdzlr", XLO(19,BODZ,16,0), XLBOBIBB_MASK, PPCCOM, { 0 } }, { "bdzlr-", XLO(19,BODZ,16,0), XLBOBIBB_MASK, NOPOWER4, { 0 } }, { "bdzlr+", XLO(19,BODZP,16,0), XLBOBIBB_MASK, NOPOWER4, { 0 } }, { "bdzlr-", XLO(19,BODZM4,16,0), XLBOBIBB_MASK, POWER4, { 0 } }, { "bdzlr+", XLO(19,BODZP4,16,0), XLBOBIBB_MASK, POWER4, { 0 } }, { "bdzlrl", XLO(19,BODZ,16,1), XLBOBIBB_MASK, PPCCOM, { 0 } }, { "bdzlrl-", XLO(19,BODZ,16,1), XLBOBIBB_MASK, NOPOWER4, { 0 } }, { "bdzlrl+", XLO(19,BODZP,16,1), XLBOBIBB_MASK, NOPOWER4, { 0 } }, { "bdzlrl-", XLO(19,BODZM4,16,1), XLBOBIBB_MASK, POWER4, { 0 } }, { "bdzlrl+", XLO(19,BODZP4,16,1), XLBOBIBB_MASK, POWER4, { 0 } }, { "bltlr", XLOCB(19,BOT,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bltlr-", XLOCB(19,BOT,CBLT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bltlr+", XLOCB(19,BOTP,CBLT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bltlr-", XLOCB(19,BOTM4,CBLT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bltlr+", XLOCB(19,BOTP4,CBLT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bltr", XLOCB(19,BOT,CBLT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bltlrl", XLOCB(19,BOT,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bltlrl-", XLOCB(19,BOT,CBLT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bltlrl+", XLOCB(19,BOTP,CBLT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bltlrl-", XLOCB(19,BOTM4,CBLT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bltlrl+", XLOCB(19,BOTP4,CBLT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bltrl", XLOCB(19,BOT,CBLT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bgtlr", XLOCB(19,BOT,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bgtlr-", XLOCB(19,BOT,CBGT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgtlr+", XLOCB(19,BOTP,CBGT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgtlr-", XLOCB(19,BOTM4,CBGT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bgtlr+", XLOCB(19,BOTP4,CBGT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bgtr", XLOCB(19,BOT,CBGT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bgtlrl", XLOCB(19,BOT,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bgtlrl-", XLOCB(19,BOT,CBGT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgtlrl+", XLOCB(19,BOTP,CBGT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgtlrl-", XLOCB(19,BOTM4,CBGT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bgtlrl+", XLOCB(19,BOTP4,CBGT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bgtrl", XLOCB(19,BOT,CBGT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, { "beqlr", XLOCB(19,BOT,CBEQ,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "beqlr-", XLOCB(19,BOT,CBEQ,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "beqlr+", XLOCB(19,BOTP,CBEQ,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "beqlr-", XLOCB(19,BOTM4,CBEQ,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "beqlr+", XLOCB(19,BOTP4,CBEQ,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "beqr", XLOCB(19,BOT,CBEQ,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, { "beqlrl", XLOCB(19,BOT,CBEQ,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "beqlrl-", XLOCB(19,BOT,CBEQ,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "beqlrl+", XLOCB(19,BOTP,CBEQ,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "beqlrl-", XLOCB(19,BOTM4,CBEQ,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "beqlrl+", XLOCB(19,BOTP4,CBEQ,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "beqrl", XLOCB(19,BOT,CBEQ,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bsolr", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bsolr-", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bsolr+", XLOCB(19,BOTP,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bsolr-", XLOCB(19,BOTM4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bsolr+", XLOCB(19,BOTP4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bsor", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bsolrl", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bsolrl-", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bsolrl+", XLOCB(19,BOTP,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bsolrl-", XLOCB(19,BOTM4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bsolrl+", XLOCB(19,BOTP4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bsorl", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bunlr", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bunlr-", XLOCB(19,BOT,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bunlr+", XLOCB(19,BOTP,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bunlr-", XLOCB(19,BOTM4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bunlr+", XLOCB(19,BOTP4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bunlrl", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bunlrl-", XLOCB(19,BOT,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bunlrl+", XLOCB(19,BOTP,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bunlrl-", XLOCB(19,BOTM4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bunlrl+", XLOCB(19,BOTP4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bgelr", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bgelr-", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgelr+", XLOCB(19,BOFP,CBLT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgelr-", XLOCB(19,BOFM4,CBLT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bgelr+", XLOCB(19,BOFP4,CBLT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bger", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bgelrl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bgelrl-", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgelrl+", XLOCB(19,BOFP,CBLT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgelrl-", XLOCB(19,BOFM4,CBLT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bgelrl+", XLOCB(19,BOFP4,CBLT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bgerl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bnllr", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnllr-", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnllr+", XLOCB(19,BOFP,CBLT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnllr-", XLOCB(19,BOFM4,CBLT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnllr+", XLOCB(19,BOFP4,CBLT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnlr", XLOCB(19,BOF,CBLT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bnllrl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnllrl-", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnllrl+", XLOCB(19,BOFP,CBLT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnllrl-", XLOCB(19,BOFM4,CBLT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnllrl+", XLOCB(19,BOFP4,CBLT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnlrl", XLOCB(19,BOF,CBLT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, { "blelr", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "blelr-", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "blelr+", XLOCB(19,BOFP,CBGT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "blelr-", XLOCB(19,BOFM4,CBGT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "blelr+", XLOCB(19,BOFP4,CBGT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bler", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, { "blelrl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "blelrl-", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "blelrl+", XLOCB(19,BOFP,CBGT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "blelrl-", XLOCB(19,BOFM4,CBGT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "blelrl+", XLOCB(19,BOFP4,CBGT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "blerl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bnglr", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnglr-", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnglr+", XLOCB(19,BOFP,CBGT,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnglr-", XLOCB(19,BOFM4,CBGT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnglr+", XLOCB(19,BOFP4,CBGT,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bngr", XLOCB(19,BOF,CBGT,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bnglrl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnglrl-", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnglrl+", XLOCB(19,BOFP,CBGT,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnglrl-", XLOCB(19,BOFM4,CBGT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnglrl+", XLOCB(19,BOFP4,CBGT,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bngrl", XLOCB(19,BOF,CBGT,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bnelr", XLOCB(19,BOF,CBEQ,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnelr-", XLOCB(19,BOF,CBEQ,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnelr+", XLOCB(19,BOFP,CBEQ,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnelr-", XLOCB(19,BOFM4,CBEQ,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnelr+", XLOCB(19,BOFP4,CBEQ,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bner", XLOCB(19,BOF,CBEQ,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bnelrl", XLOCB(19,BOF,CBEQ,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnelrl-", XLOCB(19,BOF,CBEQ,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnelrl+", XLOCB(19,BOFP,CBEQ,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnelrl-", XLOCB(19,BOFM4,CBEQ,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnelrl+", XLOCB(19,BOFP4,CBEQ,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnerl", XLOCB(19,BOF,CBEQ,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bnslr", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnslr-", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnslr+", XLOCB(19,BOFP,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnslr-", XLOCB(19,BOFM4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnslr+", XLOCB(19,BOFP4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnsr", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bnslrl", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnslrl-", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnslrl+", XLOCB(19,BOFP,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnslrl-", XLOCB(19,BOFM4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnslrl+", XLOCB(19,BOFP4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnsrl", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PWRCOM, { CR } }, { "bnulr", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnulr-", XLOCB(19,BOF,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnulr+", XLOCB(19,BOFP,CBSO,16,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnulr-", XLOCB(19,BOFM4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnulr+", XLOCB(19,BOFP4,CBSO,16,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnulrl", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnulrl-", XLOCB(19,BOF,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnulrl+", XLOCB(19,BOFP,CBSO,16,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnulrl-", XLOCB(19,BOFM4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnulrl+", XLOCB(19,BOFP4,CBSO,16,1), XLBOCBBB_MASK, POWER4, { CR } }, { "btlr", XLO(19,BOT,16,0), XLBOBB_MASK, PPCCOM, { BI } }, { "btlr-", XLO(19,BOT,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "btlr+", XLO(19,BOTP,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "bbtr", XLO(19,BOT,16,0), XLBOBB_MASK, PWRCOM, { BI } }, { "btlrl", XLO(19,BOT,16,1), XLBOBB_MASK, PPCCOM, { BI } }, { "btlrl-", XLO(19,BOT,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "btlrl+", XLO(19,BOTP,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "bbtrl", XLO(19,BOT,16,1), XLBOBB_MASK, PWRCOM, { BI } }, { "bflr", XLO(19,BOF,16,0), XLBOBB_MASK, PPCCOM, { BI } }, { "bflr-", XLO(19,BOF,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "bflr+", XLO(19,BOFP,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "bflrl", XLO(19,BOF,16,1), XLBOBB_MASK, PPCCOM, { BI } }, { "bflrl-", XLO(19,BOF,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "bflrl+", XLO(19,BOFP,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "bflrl-", XLO(19,BOFM4,16,1), XLBOBB_MASK, POWER4, { BI } }, { "bflrl+", XLO(19,BOFP4,16,1), XLBOBB_MASK, POWER4, { BI } }, { "bdnztlr", XLO(19,BODNZT,16,0), XLBOBB_MASK, PPCCOM, { BI } }, { "bdnztlr-",XLO(19,BODNZT,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdnztlr+",XLO(19,BODNZTP,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdnztlrl",XLO(19,BODNZT,16,1), XLBOBB_MASK, PPCCOM, { BI } }, { "bdnztlrl-",XLO(19,BODNZT,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdnztlrl+",XLO(19,BODNZTP,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdnzflr", XLO(19,BODNZF,16,0), XLBOBB_MASK, PPCCOM, { BI } }, { "bdnzflr-",XLO(19,BODNZF,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdnzflr+",XLO(19,BODNZFP,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdnzflrl",XLO(19,BODNZF,16,1), XLBOBB_MASK, PPCCOM, { BI } }, { "bdnzflrl-",XLO(19,BODNZF,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdnzflrl+",XLO(19,BODNZFP,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdztlr", XLO(19,BODZT,16,0), XLBOBB_MASK, PPCCOM, { BI } }, { "bdztlr-", XLO(19,BODZT,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdztlr+", XLO(19,BODZTP,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdztlrl", XLO(19,BODZT,16,1), XLBOBB_MASK, PPCCOM, { BI } }, { "bdztlrl-",XLO(19,BODZT,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdztlrl+",XLO(19,BODZTP,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdzflr", XLO(19,BODZF,16,0), XLBOBB_MASK, PPCCOM, { BI } }, { "bdzflr-", XLO(19,BODZF,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdzflr+", XLO(19,BODZFP,16,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdzflrl", XLO(19,BODZF,16,1), XLBOBB_MASK, PPCCOM, { BI } }, { "bdzflrl-",XLO(19,BODZF,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "bdzflrl+",XLO(19,BODZFP,16,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "bclr", XLLK(19,16,0), XLYBB_MASK, PPCCOM, { BO, BI } }, { "bclrl", XLLK(19,16,1), XLYBB_MASK, PPCCOM, { BO, BI } }, { "bclr+", XLYLK(19,16,1,0), XLYBB_MASK, PPCCOM, { BOE, BI } }, { "bclrl+", XLYLK(19,16,1,1), XLYBB_MASK, PPCCOM, { BOE, BI } }, { "bclr-", XLYLK(19,16,0,0), XLYBB_MASK, PPCCOM, { BOE, BI } }, { "bclrl-", XLYLK(19,16,0,1), XLYBB_MASK, PPCCOM, { BOE, BI } }, { "bcr", XLLK(19,16,0), XLBB_MASK, PWRCOM, { BO, BI } }, { "bcrl", XLLK(19,16,1), XLBB_MASK, PWRCOM, { BO, BI } }, { "rfid", XL(19,18), 0xffffffff, PPC64, { 0 } }, { "crnot", XL(19,33), XL_MASK, PPCCOM, { BT, BA, BBA } }, { "crnor", XL(19,33), XL_MASK, COM, { BT, BA, BB } }, // XXX { "rfmci", X(19,38), 0xffffffff, PPCRFMCI, { 0 } }, { "rfi", XL(19,50), 0xffffffff, COM, { 0 } }, { "crandc", XL(19,129), XL_MASK, COM, { BT, BA, BB } }, { "isync", XL(19,150), 0xffffffff, PPCCOM, { 0 } }, { "crclr", XL(19,193), XL_MASK, PPCCOM, { BT, BAT, BBA } }, { "crxor", XL(19,193), XL_MASK, COM, { BT, BA, BB } }, { "crnand", XL(19,225), XL_MASK, COM, { BT, BA, BB } }, { "crand", XL(19,257), XL_MASK, COM, { BT, BA, BB } }, { "hrfid", XL(19,274), 0xffffffff, POWER5 | CELL, { 0 } }, { "crset", XL(19,289), XL_MASK, PPCCOM, { BT, BAT, BBA } }, { "creqv", XL(19,289), XL_MASK, COM, { BT, BA, BB } }, { "doze", XL(19,402), 0xffffffff, POWER6, { 0 } }, { "crorc", XL(19,417), XL_MASK, COM, { BT, BA, BB } }, { "nap", XL(19,434), 0xffffffff, POWER6, { 0 } }, { "crmove", XL(19,449), XL_MASK, PPCCOM, { BT, BA, BBA } }, { "cror", XL(19,449), XL_MASK, COM, { BT, BA, BB } }, { "sleep", XL(19,466), 0xffffffff, POWER6, { 0 } }, { "rvwinkle", XL(19,498), 0xffffffff, POWER6, { 0 } }, { "bctr", XLO(19,BOU,528,0), XLBOBIBB_MASK, COM, { 0 } }, { "bctrl", XLO(19,BOU,528,1), XLBOBIBB_MASK, COM, { 0 } }, { "bltctr", XLOCB(19,BOT,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bltctr-", XLOCB(19,BOT,CBLT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bltctr+", XLOCB(19,BOTP,CBLT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bltctr-", XLOCB(19,BOTM4,CBLT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bltctr+", XLOCB(19,BOTP4,CBLT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bltctrl", XLOCB(19,BOT,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bltctrl-",XLOCB(19,BOT,CBLT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bltctrl+",XLOCB(19,BOTP,CBLT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bltctrl-",XLOCB(19,BOTM4,CBLT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bltctrl+",XLOCB(19,BOTP4,CBLT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bgtctr", XLOCB(19,BOT,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bgtctr-", XLOCB(19,BOT,CBGT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgtctr+", XLOCB(19,BOTP,CBGT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgtctr-", XLOCB(19,BOTM4,CBGT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bgtctr+", XLOCB(19,BOTP4,CBGT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bgtctrl", XLOCB(19,BOT,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bgtctrl-",XLOCB(19,BOT,CBGT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgtctrl+",XLOCB(19,BOTP,CBGT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgtctrl-",XLOCB(19,BOTM4,CBGT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bgtctrl+",XLOCB(19,BOTP4,CBGT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "beqctr", XLOCB(19,BOT,CBEQ,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "beqctr-", XLOCB(19,BOT,CBEQ,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "beqctr+", XLOCB(19,BOTP,CBEQ,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "beqctr-", XLOCB(19,BOTM4,CBEQ,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "beqctr+", XLOCB(19,BOTP4,CBEQ,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "beqctrl", XLOCB(19,BOT,CBEQ,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "beqctrl-",XLOCB(19,BOT,CBEQ,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "beqctrl+",XLOCB(19,BOTP,CBEQ,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "beqctrl-",XLOCB(19,BOTM4,CBEQ,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "beqctrl+",XLOCB(19,BOTP4,CBEQ,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bsoctr", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bsoctr-", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bsoctr+", XLOCB(19,BOTP,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bsoctr-", XLOCB(19,BOTM4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bsoctr+", XLOCB(19,BOTP4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bsoctrl", XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bsoctrl-",XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bsoctrl+",XLOCB(19,BOTP,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bsoctrl-",XLOCB(19,BOTM4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bsoctrl+",XLOCB(19,BOTP4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bunctr", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bunctr-", XLOCB(19,BOT,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bunctr+", XLOCB(19,BOTP,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bunctr-", XLOCB(19,BOTM4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bunctr+", XLOCB(19,BOTP4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bunctrl", XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bunctrl-",XLOCB(19,BOT,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bunctrl+",XLOCB(19,BOTP,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bunctrl-",XLOCB(19,BOTM4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bunctrl+",XLOCB(19,BOTP4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bgectr", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bgectr-", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgectr+", XLOCB(19,BOFP,CBLT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgectr-", XLOCB(19,BOFM4,CBLT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bgectr+", XLOCB(19,BOFP4,CBLT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bgectrl", XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bgectrl-",XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgectrl+",XLOCB(19,BOFP,CBLT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bgectrl-",XLOCB(19,BOFM4,CBLT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bgectrl+",XLOCB(19,BOFP4,CBLT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnlctr", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnlctr-", XLOCB(19,BOF,CBLT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnlctr+", XLOCB(19,BOFP,CBLT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnlctr-", XLOCB(19,BOFM4,CBLT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnlctr+", XLOCB(19,BOFP4,CBLT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnlctrl", XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnlctrl-",XLOCB(19,BOF,CBLT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnlctrl+",XLOCB(19,BOFP,CBLT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnlctrl-",XLOCB(19,BOFM4,CBLT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnlctrl+",XLOCB(19,BOFP4,CBLT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "blectr", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "blectr-", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "blectr+", XLOCB(19,BOFP,CBGT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "blectr-", XLOCB(19,BOFM4,CBGT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "blectr+", XLOCB(19,BOFP4,CBGT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "blectrl", XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "blectrl-",XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "blectrl+",XLOCB(19,BOFP,CBGT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "blectrl-",XLOCB(19,BOFM4,CBGT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "blectrl+",XLOCB(19,BOFP4,CBGT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bngctr", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bngctr-", XLOCB(19,BOF,CBGT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bngctr+", XLOCB(19,BOFP,CBGT,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bngctr-", XLOCB(19,BOFM4,CBGT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bngctr+", XLOCB(19,BOFP4,CBGT,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bngctrl", XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bngctrl-",XLOCB(19,BOF,CBGT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bngctrl+",XLOCB(19,BOFP,CBGT,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bngctrl-",XLOCB(19,BOFM4,CBGT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bngctrl+",XLOCB(19,BOFP4,CBGT,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnectr", XLOCB(19,BOF,CBEQ,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnectr-", XLOCB(19,BOF,CBEQ,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnectr+", XLOCB(19,BOFP,CBEQ,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnectr-", XLOCB(19,BOFM4,CBEQ,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnectr+", XLOCB(19,BOFP4,CBEQ,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnectrl", XLOCB(19,BOF,CBEQ,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnectrl-",XLOCB(19,BOF,CBEQ,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnectrl+",XLOCB(19,BOFP,CBEQ,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnectrl-",XLOCB(19,BOFM4,CBEQ,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnectrl+",XLOCB(19,BOFP4,CBEQ,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnsctr", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnsctr-", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnsctr+", XLOCB(19,BOFP,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnsctr-", XLOCB(19,BOFM4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnsctr+", XLOCB(19,BOFP4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnsctrl", XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnsctrl-",XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnsctrl+",XLOCB(19,BOFP,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnsctrl-",XLOCB(19,BOFM4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnsctrl+",XLOCB(19,BOFP4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnuctr", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnuctr-", XLOCB(19,BOF,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnuctr+", XLOCB(19,BOFP,CBSO,528,0), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnuctr-", XLOCB(19,BOFM4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnuctr+", XLOCB(19,BOFP4,CBSO,528,0), XLBOCBBB_MASK, POWER4, { CR } }, { "bnuctrl", XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, PPCCOM, { CR } }, { "bnuctrl-",XLOCB(19,BOF,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnuctrl+",XLOCB(19,BOFP,CBSO,528,1), XLBOCBBB_MASK, NOPOWER4, { CR } }, { "bnuctrl-",XLOCB(19,BOFM4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "bnuctrl+",XLOCB(19,BOFP4,CBSO,528,1), XLBOCBBB_MASK, POWER4, { CR } }, { "btctr", XLO(19,BOT,528,0), XLBOBB_MASK, PPCCOM, { BI } }, { "btctr-", XLO(19,BOT,528,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "btctr+", XLO(19,BOTP,528,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "btctr-", XLO(19,BOTM4,528,0), XLBOBB_MASK, POWER4, { BI } }, { "btctr+", XLO(19,BOTP4,528,0), XLBOBB_MASK, POWER4, { BI } }, { "btctrl", XLO(19,BOT,528,1), XLBOBB_MASK, PPCCOM, { BI } }, { "btctrl-", XLO(19,BOT,528,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "btctrl+", XLO(19,BOTP,528,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "btctrl-", XLO(19,BOTM4,528,1), XLBOBB_MASK, POWER4, { BI } }, { "btctrl+", XLO(19,BOTP4,528,1), XLBOBB_MASK, POWER4, { BI } }, { "bfctr", XLO(19,BOF,528,0), XLBOBB_MASK, PPCCOM, { BI } }, { "bfctr-", XLO(19,BOF,528,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "bfctr+", XLO(19,BOFP,528,0), XLBOBB_MASK, NOPOWER4, { BI } }, { "bfctr-", XLO(19,BOFM4,528,0), XLBOBB_MASK, POWER4, { BI } }, { "bfctr+", XLO(19,BOFP4,528,0), XLBOBB_MASK, POWER4, { BI } }, { "bfctrl", XLO(19,BOF,528,1), XLBOBB_MASK, PPCCOM, { BI } }, { "bfctrl-", XLO(19,BOF,528,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "bfctrl+", XLO(19,BOFP,528,1), XLBOBB_MASK, NOPOWER4, { BI } }, { "bfctrl-", XLO(19,BOFM4,528,1), XLBOBB_MASK, POWER4, { BI } }, { "bfctrl+", XLO(19,BOFP4,528,1), XLBOBB_MASK, POWER4, { BI } }, { "bcctr", XLLK(19,528,0), XLYBB_MASK, PPCCOM, { BO, BI } }, { "bcctr-", XLYLK(19,528,0,0), XLYBB_MASK, PPCCOM, { BOE, BI } }, { "bcctr+", XLYLK(19,528,1,0), XLYBB_MASK, PPCCOM, { BOE, BI } }, { "bcctrl", XLLK(19,528,1), XLYBB_MASK, PPCCOM, { BO, BI } }, { "bcctrl-", XLYLK(19,528,0,1), XLYBB_MASK, PPCCOM, { BOE, BI } }, { "bcctrl+", XLYLK(19,528,1,1), XLYBB_MASK, PPCCOM, { BOE, BI } }, { "bcc", XLLK(19,528,0), XLBB_MASK, PWRCOM, { BO, BI } }, { "bccl", XLLK(19,528,1), XLBB_MASK, PWRCOM, { BO, BI } }, { "bcctre", XLLK(19,529,0), XLYBB_MASK, BOOKE64, { BO, BI } }, { "bcctrel", XLLK(19,529,1), XLYBB_MASK, BOOKE64, { BO, BI } }, { "rlwimi", M(20,0), M_MASK, PPCCOM, { RA,RS,SH,MBE,ME } }, { "rlwimi.", M(20,1), M_MASK, PPCCOM, { RA,RS,SH,MBE,ME } }, { "rotlwi", MME(21,31,0), MMBME_MASK, PPCCOM, { RA, RS, SH } }, { "clrlwi", MME(21,31,0), MSHME_MASK, PPCCOM, { RA, RS, MB } }, { "slwi", M(21, 0), M_MASK, PPCCOM, { RA, RS, SH, MSLWI } }, { "srwi", M(21, 0), M_MASK, PPCCOM, { RA, RS, MB, MSRWI } }, { "rlwinm", M(21,0), M_MASK, PPCCOM, { RA,RS,SH,MBE,ME } }, { "rotlwi.", MME(21,31,1), MMBME_MASK, PPCCOM, { RA,RS,SH } }, { "clrlwi.", MME(21,31,1), MSHME_MASK, PPCCOM, { RA, RS, MB } }, { "slwi.", M(21,1), M_MASK, PPCCOM, { RA, RS, SH, MSLWI } }, { "srwi.", M(21,1), M_MASK, PPCCOM, { RA, RS, MB, MSRWI } }, { "rlwinm.", M(21,1), M_MASK, PPCCOM, { RA,RS,SH,MBE,ME } }, { "rotlw", MME(23,31,0), MMBME_MASK, PPCCOM, { RA, RS, RB } }, { "rlwnm", M(23,0), M_MASK, PPCCOM, { RA,RS,RB,MBE,ME } }, { "rotlw.", MME(23,31,1), MMBME_MASK, PPCCOM, { RA, RS, RB } }, { "rlwnm.", M(23,1), M_MASK, PPCCOM, { RA,RS,RB,MBE,ME } }, { "nop", OP(24), 0xffffffff, PPCCOM, { 0 } }, { "ori", OP(24), OP_MASK, PPCCOM, { RA, RS, UI } }, { "oris", OP(25), OP_MASK, PPCCOM, { RA, RS, UI } }, { "xori", OP(26), OP_MASK, PPCCOM, { RA, RS, UI } }, { "xoris", OP(27), OP_MASK, PPCCOM, { RA, RS, UI } }, { "andi.", OP(28), OP_MASK, PPCCOM, { RA, RS, UI } }, { "andis.", OP(29), OP_MASK, PPCCOM, { RA, RS, UI } }, { "rotldi", MD(30,0,0), MDMB_MASK, PPC64, { RA, RS, SH6 } }, { "clrldi", MD(30,0,0), MDSH_MASK, PPC64, { RA, RS, MB6 } }, { "rldicl", MD(30,0,0), MD_MASK, PPC64, { RA, RS, SH6, MB6 } }, { "rotldi.", MD(30,0,1), MDMB_MASK, PPC64, { RA, RS, SH6 } }, { "clrldi.", MD(30,0,1), MDSH_MASK, PPC64, { RA, RS, MB6 } }, { "rldicl.", MD(30,0,1), MD_MASK, PPC64, { RA, RS, SH6, MB6 } }, { "rldicr", MD(30,1,0), MD_MASK, PPC64, { RA, RS, SH6, ME6 } }, { "rldicr.", MD(30,1,1), MD_MASK, PPC64, { RA, RS, SH6, ME6 } }, { "rldic", MD(30,2,0), MD_MASK, PPC64, { RA, RS, SH6, MB6 } }, { "rldic.", MD(30,2,1), MD_MASK, PPC64, { RA, RS, SH6, MB6 } }, { "rldimi", MD(30,3,0), MD_MASK, PPC64, { RA, RS, SH6, MB6 } }, { "rldimi.", MD(30,3,1), MD_MASK, PPC64, { RA, RS, SH6, MB6 } }, { "rotld", MDS(30,8,0), MDSMB_MASK, PPC64, { RA, RS, RB } }, { "rldcl", MDS(30,8,0), MDS_MASK, PPC64, { RA, RS, RB, MB6 } }, { "rotld.", MDS(30,8,1), MDSMB_MASK, PPC64, { RA, RS, RB } }, { "rldcl.", MDS(30,8,1), MDS_MASK, PPC64, { RA, RS, RB, MB6 } }, { "rldcr", MDS(30,9,0), MDS_MASK, PPC64, { RA, RS, RB, ME6 } }, { "rldcr.", MDS(30,9,1), MDS_MASK, PPC64, { RA, RS, RB, ME6 } }, { "cmpw", XCMPL(31,0,0), XCMPL_MASK, PPCCOM, { OBF, RA, RB } }, { "cmpd", XOPL(31,0,1), XCMPL_MASK, PPC64, { OBF, RA, RB } }, { "cmp", X(31,0), XCMP_MASK, PPCONLY, { BF, L, RA, RB } }, { "twlgt", XTO(31,4,TOLGT), XTO_MASK, PPCCOM, { RA, RB } }, { "twllt", XTO(31,4,TOLLT), XTO_MASK, PPCCOM, { RA, RB } }, { "tweq", XTO(31,4,TOEQ), XTO_MASK, PPCCOM, { RA, RB } }, { "twlge", XTO(31,4,TOLGE), XTO_MASK, PPCCOM, { RA, RB } }, { "twlnl", XTO(31,4,TOLNL), XTO_MASK, PPCCOM, { RA, RB } }, { "twlle", XTO(31,4,TOLLE), XTO_MASK, PPCCOM, { RA, RB } }, { "twlng", XTO(31,4,TOLNG), XTO_MASK, PPCCOM, { RA, RB } }, { "twgt", XTO(31,4,TOGT), XTO_MASK, PPCCOM, { RA, RB } }, { "twge", XTO(31,4,TOGE), XTO_MASK, PPCCOM, { RA, RB } }, { "twnl", XTO(31,4,TONL), XTO_MASK, PPCCOM, { RA, RB } }, { "twlt", XTO(31,4,TOLT), XTO_MASK, PPCCOM, { RA, RB } }, { "twle", XTO(31,4,TOLE), XTO_MASK, PPCCOM, { RA, RB } }, { "twng", XTO(31,4,TONG), XTO_MASK, PPCCOM, { RA, RB } }, { "twne", XTO(31,4,TONE), XTO_MASK, PPCCOM, { RA, RB } }, { "trap", XTO(31,4,TOU), 0xffffffff, PPCCOM, { 0 } }, { "tw", X(31,4), X_MASK, PPCCOM, { TO, RA, RB } }, { "subfc", XO(31,8,0,0), XO_MASK, PPCCOM, { RT, RA, RB } }, { "subc", XO(31,8,0,0), XO_MASK, PPC, { RT, RB, RA } }, { "subfc.", XO(31,8,0,1), XO_MASK, PPCCOM, { RT, RA, RB } }, { "subc.", XO(31,8,0,1), XO_MASK, PPCCOM, { RT, RB, RA } }, { "subfco", XO(31,8,1,0), XO_MASK, PPCCOM, { RT, RA, RB } }, { "subco", XO(31,8,1,0), XO_MASK, PPC, { RT, RB, RA } }, { "subfco.", XO(31,8,1,1), XO_MASK, PPCCOM, { RT, RA, RB } }, { "subco.", XO(31,8,1,1), XO_MASK, PPC, { RT, RB, RA } }, { "mulhdu", XO(31,9,0,0), XO_MASK, PPC64, { RT, RA, RB } }, { "mulhdu.", XO(31,9,0,1), XO_MASK, PPC64, { RT, RA, RB } }, { "addc", XO(31,10,0,0), XO_MASK, PPCCOM, { RT, RA, RB } }, { "addc.", XO(31,10,0,1), XO_MASK, PPCCOM, { RT, RA, RB } }, { "addco", XO(31,10,1,0), XO_MASK, PPCCOM, { RT, RA, RB } }, { "addco.", XO(31,10,1,1), XO_MASK, PPCCOM, { RT, RA, RB } }, { "mulhwu", XO(31,11,0,0), XO_MASK, PPC, { RT, RA, RB } }, { "mulhwu.", XO(31,11,0,1), XO_MASK, PPC, { RT, RA, RB } }, { "mfcr", X(31,19), XRARB_MASK, COM, { RT } }, { "mfocrf", X(31,19), X_MASK, PPCVEC, { RT, FXM } }, { "lwarx", X(31,20), X_MASK, PPC, { RT, RA0, RB } }, { "ldx", X(31,21), X_MASK, PPC64, { RT, RA0, RB } }, { "lwzx", X(31,23), X_MASK, PPCCOM, { RT, RA0, RB } }, { "slw", XRC(31,24,0), X_MASK, PPCCOM, { RA, RS, RB } }, { "slw.", XRC(31,24,1), X_MASK, PPCCOM, { RA, RS, RB } }, { "cntlzw", XRC(31,26,0), XRB_MASK, PPCCOM, { RA, RS } }, { "cntlzw.", XRC(31,26,1), XRB_MASK, PPCCOM, { RA, RS } }, { "sld", XRC(31,27,0), X_MASK, PPC64, { RA, RS, RB } }, { "sld.", XRC(31,27,1), X_MASK, PPC64, { RA, RS, RB } }, { "and", XRC(31,28,0), X_MASK, COM, { RA, RS, RB } }, { "and.", XRC(31,28,1), X_MASK, COM, { RA, RS, RB } }, { "cmplw", XCMPL(31,32,0), XCMPL_MASK, PPCCOM, { OBF, RA, RB } }, { "cmpld", XOPL(31,32,1), XCMPL_MASK, PPC64, { OBF, RA, RB } }, { "cmpl", X(31,32), XCMP_MASK, PPCONLY, { BF, L, RA, RB } }, { "subf", XO(31,40,0,0), XO_MASK, PPC, { RT, RA, RB } }, { "sub", XO(31,40,0,0), XO_MASK, PPC, { RT, RB, RA } }, { "subf.", XO(31,40,0,1), XO_MASK, PPC, { RT, RA, RB } }, { "sub.", XO(31,40,0,1), XO_MASK, PPC, { RT, RB, RA } }, { "subfo", XO(31,40,1,0), XO_MASK, PPC, { RT, RA, RB } }, { "subo", XO(31,40,1,0), XO_MASK, PPC, { RT, RB, RA } }, { "subfo.", XO(31,40,1,1), XO_MASK, PPC, { RT, RA, RB } }, { "subo.", XO(31,40,1,1), XO_MASK, PPC, { RT, RB, RA } }, { "ldux", X(31,53), X_MASK, PPC64, { RT, RAL, RB } }, { "dcbst", X(31,54), XRT_MASK, PPC, { RA, RB } }, { "lwzux", X(31,55), X_MASK, PPCCOM, { RT, RAL, RB } }, { "cntlzd", XRC(31,58,0), XRB_MASK, PPC64, { RA, RS } }, { "cntlzd.", XRC(31,58,1), XRB_MASK, PPC64, { RA, RS } }, { "andc", XRC(31,60,0), X_MASK, COM, { RA, RS, RB } }, { "andc.", XRC(31,60,1), X_MASK, COM, { RA, RS, RB } }, { "tdlgt", XTO(31,68,TOLGT), XTO_MASK, PPC64, { RA, RB } }, { "tdllt", XTO(31,68,TOLLT), XTO_MASK, PPC64, { RA, RB } }, { "tdeq", XTO(31,68,TOEQ), XTO_MASK, PPC64, { RA, RB } }, { "tdlge", XTO(31,68,TOLGE), XTO_MASK, PPC64, { RA, RB } }, { "tdlnl", XTO(31,68,TOLNL), XTO_MASK, PPC64, { RA, RB } }, { "tdlle", XTO(31,68,TOLLE), XTO_MASK, PPC64, { RA, RB } }, { "tdlng", XTO(31,68,TOLNG), XTO_MASK, PPC64, { RA, RB } }, { "tdgt", XTO(31,68,TOGT), XTO_MASK, PPC64, { RA, RB } }, { "tdge", XTO(31,68,TOGE), XTO_MASK, PPC64, { RA, RB } }, { "tdnl", XTO(31,68,TONL), XTO_MASK, PPC64, { RA, RB } }, { "tdlt", XTO(31,68,TOLT), XTO_MASK, PPC64, { RA, RB } }, { "tdle", XTO(31,68,TOLE), XTO_MASK, PPC64, { RA, RB } }, { "tdng", XTO(31,68,TONG), XTO_MASK, PPC64, { RA, RB } }, { "tdne", XTO(31,68,TONE), XTO_MASK, PPC64, { RA, RB } }, { "td", X(31,68), X_MASK, PPC64, { TO, RA, RB } }, { "mulhd", XO(31,73,0,0), XO_MASK, PPC64, { RT, RA, RB } }, { "mulhd.", XO(31,73,0,1), XO_MASK, PPC64, { RT, RA, RB } }, { "mulhw", XO(31,75,0,0), XO_MASK, PPC, { RT, RA, RB } }, { "mulhw.", XO(31,75,0,1), XO_MASK, PPC, { RT, RA, RB } }, { "mtsrd", X(31,82), XRB_MASK|(1<<20), PPC64, { SR, RS } }, { "mfmsr", X(31,83), XRARB_MASK, COM, { RT } }, { "ldarx", X(31,84), X_MASK, PPC64, { RT, RA0, RB } }, { "dcbf", X(31,86), XRT_MASK, PPC, { RA, RB } }, { "lbzx", X(31,87), X_MASK, COM, { RT, RA0, RB } }, { "neg", XO(31,104,0,0), XORB_MASK, COM, { RT, RA } }, { "neg.", XO(31,104,0,1), XORB_MASK, COM, { RT, RA } }, { "nego", XO(31,104,1,0), XORB_MASK, COM, { RT, RA } }, { "nego.", XO(31,104,1,1), XORB_MASK, COM, { RT, RA } }, { "mtsrdin", X(31,114), XRA_MASK, PPC64, { RS, RB } }, { "lbzux", X(31,119), X_MASK, COM, { RT, RAL, RB } }, { "not", XRC(31,124,0), X_MASK, COM, { RA, RS, RBS } }, { "nor", XRC(31,124,0), X_MASK, COM, { RA, RS, RB } }, { "not.", XRC(31,124,1), X_MASK, COM, { RA, RS, RBS } }, { "nor.", XRC(31,124,1), X_MASK, COM, { RA, RS, RB } }, { "subfe", XO(31,136,0,0), XO_MASK, PPCCOM, { RT, RA, RB } }, { "subfe.", XO(31,136,0,1), XO_MASK, PPCCOM, { RT, RA, RB } }, { "subfeo", XO(31,136,1,0), XO_MASK, PPCCOM, { RT, RA, RB } }, { "subfeo.", XO(31,136,1,1), XO_MASK, PPCCOM, { RT, RA, RB } }, { "adde", XO(31,138,0,0), XO_MASK, PPCCOM, { RT, RA, RB } }, { "adde.", XO(31,138,0,1), XO_MASK, PPCCOM, { RT, RA, RB } }, { "addeo", XO(31,138,1,0), XO_MASK, PPCCOM, { RT, RA, RB } }, { "addeo.", XO(31,138,1,1), XO_MASK, PPCCOM, { RT, RA, RB } }, { "mtcr", XFXM(31,144,0xff), XFXFXM_MASK|FXM_MASK, COM, { RS }}, { "mtcrf", X(31,144), XFXFXM_MASK, COM, { FXM, RS } }, { "mtocrf", X(31,144)|(1<<20),XFXFXM_MASK2, COM, { FXM, RS } }, { "mtmsr", X(31,146), XRARB_MASK, COM, { RS } }, { "stdx", X(31,149), X_MASK, PPC64, { RS, RA0, RB } }, { "stwcx.", XRC(31,150,1), X_MASK, PPC, { RS, RA0, RB } }, { "stwx", X(31,151), X_MASK, PPCCOM, { RS, RA0, RB } }, { "prtyw", X(31,154), XRB_MASK, POWER6, { RA, RS } }, { "mtmsrd", X(31,178), XRLARB_MASK, PPC64, { RS, MTMSRD_L } }, { "stdux", X(31,181), X_MASK, PPC64, { RS, RAS, RB } }, { "stwux", X(31,183), X_MASK, PPCCOM, { RS, RAS, RB } }, { "prtyd", X(31,186), XRB_MASK, POWER6, { RA, RS } }, { "subfze", XO(31,200,0,0), XORB_MASK, PPCCOM, { RT, RA } }, { "subfze.", XO(31,200,0,1), XORB_MASK, PPCCOM, { RT, RA } }, { "subfzeo", XO(31,200,1,0), XORB_MASK, PPCCOM, { RT, RA } }, { "subfzeo.",XO(31,200,1,1), XORB_MASK, PPCCOM, { RT, RA } }, { "addze", XO(31,202,0,0), XORB_MASK, PPCCOM, { RT, RA } }, { "addze.", XO(31,202,0,1), XORB_MASK, PPCCOM, { RT, RA } }, { "addzeo", XO(31,202,1,0), XORB_MASK, PPCCOM, { RT, RA } }, { "addzeo.", XO(31,202,1,1), XORB_MASK, PPCCOM, { RT, RA } }, { "mtsr", X(31,210), XRB_MASK|(1<<20), COM32, { SR, RS } }, { "stdcx.", XRC(31,214,1), X_MASK, PPC64, { RS, RA0, RB } }, { "stbx", X(31,215), X_MASK, COM, { RS, RA0, RB } }, { "subfme", XO(31,232,0,0), XORB_MASK, PPCCOM, { RT, RA } }, { "subfme.", XO(31,232,0,1), XORB_MASK, PPCCOM, { RT, RA } }, { "subfmeo", XO(31,232,1,0), XORB_MASK, PPCCOM, { RT, RA } }, { "subfmeo.",XO(31,232,1,1), XORB_MASK, PPCCOM, { RT, RA } }, { "mulld", XO(31,233,0,0), XO_MASK, PPC64, { RT, RA, RB } }, { "mulld.", XO(31,233,0,1), XO_MASK, PPC64, { RT, RA, RB } }, { "mulldo", XO(31,233,1,0), XO_MASK, PPC64, { RT, RA, RB } }, { "mulldo.", XO(31,233,1,1), XO_MASK, PPC64, { RT, RA, RB } }, { "addme", XO(31,234,0,0), XORB_MASK, PPCCOM, { RT, RA } }, { "addme.", XO(31,234,0,1), XORB_MASK, PPCCOM, { RT, RA } }, { "addmeo", XO(31,234,1,0), XORB_MASK, PPCCOM, { RT, RA } }, { "addmeo.", XO(31,234,1,1), XORB_MASK, PPCCOM, { RT, RA } }, { "mullw", XO(31,235,0,0), XO_MASK, PPCCOM, { RT, RA, RB } }, { "mullw.", XO(31,235,0,1), XO_MASK, PPCCOM, { RT, RA, RB } }, { "mullwo", XO(31,235,1,0), XO_MASK, PPCCOM, { RT, RA, RB } }, { "mullwo.", XO(31,235,1,1), XO_MASK, PPCCOM, { RT, RA, RB } }, { "mtsrin", X(31,242), XRA_MASK, PPC32, { RS, RB } }, { "dcbtst", X(31,246), XRT_MASK, PPC, { RA, RB } }, { "stbux", X(31,247), X_MASK, COM, { RS, RAS, RB } }, { "add", XO(31,266,0,0), XO_MASK, PPCCOM, { RT, RA, RB } }, { "add.", XO(31,266,0,1), XO_MASK, PPCCOM, { RT, RA, RB } }, { "addo", XO(31,266,1,0), XO_MASK, PPCCOM, { RT, RA, RB } }, { "addo.", XO(31,266,1,1), XO_MASK, PPCCOM, { RT, RA, RB } }, { "tlbiel", X(31,274), XRTLRA_MASK, POWER4, { RB, L } }, { "xdcbt", X(31,278)|(1<<25), XRT_MASK, PPC, { RA, RB } }, { "dcbt", X(31,278), XRT_MASK, PPC, { RA, RB } }, { "lhzx", X(31,279), X_MASK, COM, { RT, RA0, RB } }, { "eqv", XRC(31,284,0), X_MASK, COM, { RA, RS, RB } }, { "eqv.", XRC(31,284,1), X_MASK, COM, { RA, RS, RB } }, { "tlbie", X(31,306), XRTLRA_MASK, PPC, { RB, L } }, { "eciwx", X(31,310), X_MASK, PPC, { RT, RA, RB } }, { "lhzux", X(31,311), X_MASK, COM, { RT, RAL, RB } }, { "xor", XRC(31,316,0), X_MASK, COM, { RA, RS, RB } }, { "xor.", XRC(31,316,1), X_MASK, COM, { RA, RS, RB } }, { "mfxer", XSPR(31,339,1), XSPR_MASK, COM, { RT } }, { "mfrtcu", XSPR(31,339,4), XSPR_MASK, COM, { RT } }, { "mfrtcl", XSPR(31,339,5), XSPR_MASK, COM, { RT } }, { "mfdec", XSPR(31,339,6), XSPR_MASK, MFDEC1, { RT } }, { "mflr", XSPR(31,339,8), XSPR_MASK, COM, { RT } }, { "mfctr", XSPR(31,339,9), XSPR_MASK, COM, { RT } }, { "mfdsisr", XSPR(31,339,18), XSPR_MASK, COM, { RT } }, { "mfdar", XSPR(31,339,19), XSPR_MASK, COM, { RT } }, { "mfdec", XSPR(31,339,22), XSPR_MASK, MFDEC2, { RT } }, { "mfsdr1", XSPR(31,339,25), XSPR_MASK, COM, { RT } }, { "mfsrr0", XSPR(31,339,26), XSPR_MASK, COM, { RT } }, { "mfsrr1", XSPR(31,339,27), XSPR_MASK, COM, { RT } }, { "mfcfar", XSPR(31,339,28), XSPR_MASK, POWER6, { RT } }, { "mfvrsave", XSPR(31,339,256), XSPR_MASK, PPCVEC, { RT } }, { "mfsprg", XSPR(31,339,272), XSPRG_MASK, PPC, { RT, SPRG } }, { "mfsprg0", XSPR(31,339,272), XSPR_MASK, PPC, { RT } }, { "mfsprg1", XSPR(31,339,273), XSPR_MASK, PPC, { RT } }, { "mfsprg2", XSPR(31,339,274), XSPR_MASK, PPC, { RT } }, { "mfsprg3", XSPR(31,339,275), XSPR_MASK, PPC, { RT } }, { "mfasr", XSPR(31,339,280), XSPR_MASK, PPC64, { RT } }, { "mfear", XSPR(31,339,282), XSPR_MASK, PPC, { RT } }, { "mfpvr", XSPR(31,339,287), XSPR_MASK, PPC, { RT } }, { "mfibatu", XSPR(31,339,528), XSPRBAT_MASK, PPC, { RT, SPRBAT } }, { "mfibatl", XSPR(31,339,529), XSPRBAT_MASK, PPC, { RT, SPRBAT } }, { "mfdbatu", XSPR(31,339,536), XSPRBAT_MASK, PPC, { RT, SPRBAT } }, { "mfdbatl", XSPR(31,339,537), XSPRBAT_MASK, PPC, { RT, SPRBAT } }, { "mfummcr0", XSPR(31,339,936), XSPR_MASK, PPC750, { RT } }, { "mfupmc1", XSPR(31,339,937), XSPR_MASK, PPC750, { RT } }, { "mfupmc2", XSPR(31,339,938), XSPR_MASK, PPC750, { RT } }, { "mfusia", XSPR(31,339,939), XSPR_MASK, PPC750, { RT } }, { "mfummcr1", XSPR(31,339,940), XSPR_MASK, PPC750, { RT } }, { "mfupmc3", XSPR(31,339,941), XSPR_MASK, PPC750, { RT } }, { "mfupmc4", XSPR(31,339,942), XSPR_MASK, PPC750, { RT } }, { "mfmmcr0", XSPR(31,339,952), XSPR_MASK, PPC750, { RT } }, { "mfpmc1", XSPR(31,339,953), XSPR_MASK, PPC750, { RT } }, { "mfpmc2", XSPR(31,339,954), XSPR_MASK, PPC750, { RT } }, { "mfsia", XSPR(31,339,955), XSPR_MASK, PPC750, { RT } }, { "mfmmcr1", XSPR(31,339,956), XSPR_MASK, PPC750, { RT } }, { "mfpmc3", XSPR(31,339,957), XSPR_MASK, PPC750, { RT } }, { "mfpmc4", XSPR(31,339,958), XSPR_MASK, PPC750, { RT } }, { "mfl2cr", XSPR(31,339,1017), XSPR_MASK, PPC750, { RT } }, { "mfictc", XSPR(31,339,1019), XSPR_MASK, PPC750, { RT } }, { "mfthrm1", XSPR(31,339,1020), XSPR_MASK, PPC750, { RT } }, { "mfthrm2", XSPR(31,339,1021), XSPR_MASK, PPC750, { RT } }, { "mfthrm3", XSPR(31,339,1022), XSPR_MASK, PPC750, { RT } }, { "mfspr", X(31,339), X_MASK, COM, { RT, SPR } }, { "lwax", X(31,341), X_MASK, PPC64, { RT, RA0, RB } }, { "dst", XDSS(31,342,0), XDSS_MASK, PPCVEC, { RA, RB, STRM } }, { "dstt", XDSS(31,342,1), XDSS_MASK, PPCVEC, { RA, RB, STRM } }, { "lhax", X(31,343), X_MASK, COM, { RT, RA0, RB } }, { "dstst", XDSS(31,374,0), XDSS_MASK, PPCVEC, { RA, RB, STRM } }, { "dststt", XDSS(31,374,1), XDSS_MASK, PPCVEC, { RA, RB, STRM } }, { "tlbia", X(31,370), 0xffffffff, PPC, { 0 } }, { "mftbl", XSPR(31,371,268), XSPR_MASK, CLASSIC, { RT } }, { "mftbu", XSPR(31,371,269), XSPR_MASK, CLASSIC, { RT } }, { "mftb", X(31,371), X_MASK, CLASSIC, { RT, TBR } }, { "lwaux", X(31,373), X_MASK, PPC64, { RT, RAL, RB } }, { "lhaux", X(31,375), X_MASK, COM, { RT, RAL, RB } }, { "slbmte", X(31,402), XRA_MASK, PPC64, { RS, RB } }, { "sthx", X(31,407), X_MASK, COM, { RS, RA0, RB } }, { "orc", XRC(31,412,0), X_MASK, COM, { RA, RS, RB } }, { "orc.", XRC(31,412,1), X_MASK, COM, { RA, RS, RB } }, { "sradi", XS(31,413,0), XS_MASK, PPC64, { RA, RS, SH6 } }, { "sradi.", XS(31,413,1), XS_MASK, PPC64, { RA, RS, SH6 } }, { "slbie", X(31,434), XRTRA_MASK, PPC64, { RB } }, { "ecowx", X(31,438), X_MASK, PPC, { RT, RA, RB } }, { "sthux", X(31,439), X_MASK, COM, { RS, RAS, RB } }, { "mr", XRC(31,444,0), X_MASK, COM, { RA, RS, RBS } }, { "or", XRC(31,444,0), X_MASK, COM, { RA, RS, RB } }, { "mr.", XRC(31,444,1), X_MASK, COM, { RA, RS, RBS } }, { "or.", XRC(31,444,1), X_MASK, COM, { RA, RS, RB } }, { "divdu", XO(31,457,0,0), XO_MASK, PPC64, { RT, RA, RB } }, { "divdu.", XO(31,457,0,1), XO_MASK, PPC64, { RT, RA, RB } }, { "divduo", XO(31,457,1,0), XO_MASK, PPC64, { RT, RA, RB } }, { "divduo.", XO(31,457,1,1), XO_MASK, PPC64, { RT, RA, RB } }, { "divwu", XO(31,459,0,0), XO_MASK, PPC, { RT, RA, RB } }, { "divwu.", XO(31,459,0,1), XO_MASK, PPC, { RT, RA, RB } }, { "divwuo", XO(31,459,1,0), XO_MASK, PPC, { RT, RA, RB } }, { "divwuo.", XO(31,459,1,1), XO_MASK, PPC, { RT, RA, RB } }, { "mtxer", XSPR(31,467,1), XSPR_MASK, COM, { RS } }, { "mtlr", XSPR(31,467,8), XSPR_MASK, COM, { RS } }, { "mtctr", XSPR(31,467,9), XSPR_MASK, COM, { RS } }, { "mtdsisr", XSPR(31,467,18), XSPR_MASK, COM, { RS } }, { "mtdar", XSPR(31,467,19), XSPR_MASK, COM, { RS } }, { "mtrtcu", XSPR(31,467,20), XSPR_MASK, COM, { RS } }, { "mtrtcl", XSPR(31,467,21), XSPR_MASK, COM, { RS } }, { "mtdec", XSPR(31,467,22), XSPR_MASK, COM, { RS } }, { "mtsdr1", XSPR(31,467,25), XSPR_MASK, COM, { RS } }, { "mtsrr0", XSPR(31,467,26), XSPR_MASK, COM, { RS } }, { "mtsrr1", XSPR(31,467,27), XSPR_MASK, COM, { RS } }, { "mtcfar", XSPR(31,467,28), XSPR_MASK, POWER6, { RS } }, { "mtvrsave", XSPR(31,467,256), XSPR_MASK, PPCVEC, { RT } }, { "mtsprg", XSPR(31,467,272), XSPRG_MASK,PPC, { SPRG, RS } }, { "mtsprg0", XSPR(31,467,272), XSPR_MASK, PPC, { RT } }, { "mtsprg1", XSPR(31,467,273), XSPR_MASK, PPC, { RT } }, { "mtsprg2", XSPR(31,467,274), XSPR_MASK, PPC, { RT } }, { "mtsprg3", XSPR(31,467,275), XSPR_MASK, PPC, { RT } }, { "mtasr", XSPR(31,467,280), XSPR_MASK, PPC64, { RS } }, { "mtear", XSPR(31,467,282), XSPR_MASK, PPC, { RS } }, { "mttbl", XSPR(31,467,284), XSPR_MASK, PPC, { RS } }, { "mttbu", XSPR(31,467,285), XSPR_MASK, PPC, { RS } }, { "mtibatu", XSPR(31,467,528), XSPRBAT_MASK, PPC, { SPRBAT, RS } }, { "mtibatl", XSPR(31,467,529), XSPRBAT_MASK, PPC, { SPRBAT, RS } }, { "mtdbatu", XSPR(31,467,536), XSPRBAT_MASK, PPC, { SPRBAT, RS } }, { "mtdbatl", XSPR(31,467,537), XSPRBAT_MASK, PPC, { SPRBAT, RS } }, { "mtummcr0", XSPR(31,467,936), XSPR_MASK, PPC750, { RT } }, { "mtupmc1", XSPR(31,467,937), XSPR_MASK, PPC750, { RT } }, { "mtupmc2", XSPR(31,467,938), XSPR_MASK, PPC750, { RT } }, { "mtusia", XSPR(31,467,939), XSPR_MASK, PPC750, { RT } }, { "mtummcr1", XSPR(31,467,940), XSPR_MASK, PPC750, { RT } }, { "mtupmc3", XSPR(31,467,941), XSPR_MASK, PPC750, { RT } }, { "mtupmc4", XSPR(31,467,942), XSPR_MASK, PPC750, { RT } }, { "mtmmcr0", XSPR(31,467,952), XSPR_MASK, PPC750, { RT } }, { "mtpmc1", XSPR(31,467,953), XSPR_MASK, PPC750, { RT } }, { "mtpmc2", XSPR(31,467,954), XSPR_MASK, PPC750, { RT } }, { "mtsia", XSPR(31,467,955), XSPR_MASK, PPC750, { RT } }, { "mtmmcr1", XSPR(31,467,956), XSPR_MASK, PPC750, { RT } }, { "mtpmc3", XSPR(31,467,957), XSPR_MASK, PPC750, { RT } }, { "mtpmc4", XSPR(31,467,958), XSPR_MASK, PPC750, { RT } }, { "mtl2cr", XSPR(31,467,1017), XSPR_MASK, PPC750, { RT } }, { "mtictc", XSPR(31,467,1019), XSPR_MASK, PPC750, { RT } }, { "mtthrm1", XSPR(31,467,1020), XSPR_MASK, PPC750, { RT } }, { "mtthrm2", XSPR(31,467,1021), XSPR_MASK, PPC750, { RT } }, { "mtthrm3", XSPR(31,467,1022), XSPR_MASK, PPC750, { RT } }, { "mtspr", X(31,467), X_MASK, COM, { SPR, RS } }, { "dcbi", X(31,470), XRT_MASK, PPC, { RA, RB } }, { "nand", XRC(31,476,0), X_MASK, COM, { RA, RS, RB } }, { "nand.", XRC(31,476,1), X_MASK, COM, { RA, RS, RB } }, { "divd", XO(31,489,0,0), XO_MASK, PPC64, { RT, RA, RB } }, { "divd.", XO(31,489,0,1), XO_MASK, PPC64, { RT, RA, RB } }, { "divdo", XO(31,489,1,0), XO_MASK, PPC64, { RT, RA, RB } }, { "divdo.", XO(31,489,1,1), XO_MASK, PPC64, { RT, RA, RB } }, { "divw", XO(31,491,0,0), XO_MASK, PPC, { RT, RA, RB } }, { "divw.", XO(31,491,0,1), XO_MASK, PPC, { RT, RA, RB } }, { "divwo", XO(31,491,1,0), XO_MASK, PPC, { RT, RA, RB } }, { "divwo.", XO(31,491,1,1), XO_MASK, PPC, { RT, RA, RB } }, { "slbia", X(31,498), 0xffffffff, PPC64, { 0 } }, { "cli", X(31,502), XRB_MASK, POWER, { RT, RA } }, { "cmpb", X(31,508), X_MASK, POWER6, { RA, RS, RB } }, { "mcrxr", X(31,512), XRARB_MASK|(3<<21), COM, { BF } }, { "ldbrx", X(31,532), X_MASK, CELL, { RT, RA0, RB } }, { "lswx", X(31,533), X_MASK, PPCCOM, { RT, RA0, RB } }, { "lwbrx", X(31,534), X_MASK, PPCCOM, { RT, RA0, RB } }, { "lfsx", X(31,535), X_MASK, COM, { FRT, RA0, RB } }, { "srw", XRC(31,536,0), X_MASK, PPCCOM, { RA, RS, RB } }, { "srw.", XRC(31,536,1), X_MASK, PPCCOM, { RA, RS, RB } }, { "srd", XRC(31,539,0), X_MASK, PPC64, { RA, RS, RB } }, { "srd.", XRC(31,539,1), X_MASK, PPC64, { RA, RS, RB } }, { "tlbsync", X(31,566), 0xffffffff, PPC, { 0 } }, { "lfsux", X(31,567), X_MASK, COM, { FRT, RAS, RB } }, { "mfsr", X(31,595), XRB_MASK|(1<<20), COM32, { RT, SR } }, { "lswi", X(31,597), X_MASK, PPCCOM, { RT, RA0, NB } }, { "lwsync", XSYNC(31,598,1), 0xffffffff, PPCONLY, { 0 } }, { "ptesync", XSYNC(31,598,2), 0xffffffff, PPC64, { 0 } }, { "sync", X(31,598), XSYNC_MASK, PPCCOM, { LS } }, { "lfdx", X(31,599), X_MASK, COM, { FRT, RA0, RB } }, { "mffgpr", XRC(31,607,0), XRA_MASK, POWER6, { FRT, RB } }, { "lfdux", X(31,631), X_MASK, COM, { FRT, RAS, RB } }, { "mfsrin", X(31,659), XRA_MASK, PPC32, { RT, RB } }, { "stdbrx", X(31,660), X_MASK, CELL, { RS, RA0, RB } }, { "stswx", X(31,661), X_MASK, PPCCOM, { RS, RA0, RB } }, { "stwbrx", X(31,662), X_MASK, PPCCOM, { RS, RA0, RB } }, { "stfsx", X(31,663), X_MASK, COM, { FRS, RA0, RB } }, { "stfsux", X(31,695), X_MASK, COM, { FRS, RAS, RB } }, { "stswi", X(31,725), X_MASK, PPCCOM, { RS, RA0, NB } }, { "stfdx", X(31,727), X_MASK, COM, { FRS, RA0, RB } }, { "mftgpr", XRC(31,735,0), XRA_MASK, POWER6, { RT, FRB } }, { "stfdux", X(31,759), X_MASK, COM, { FRS, RAS, RB } }, { "lwzcix", X(31,789), X_MASK, POWER6, { RT, RA0, RB } }, { "lhbrx", X(31,790), X_MASK, COM, { RT, RA0, RB } }, { "lfdpx", X(31,791), X_MASK, POWER6, { FRT, RA, RB } }, { "sraw", XRC(31,792,0), X_MASK, PPCCOM, { RA, RS, RB } }, { "sraw.", XRC(31,792,1), X_MASK, PPCCOM, { RA, RS, RB } }, { "srad", XRC(31,794,0), X_MASK, PPC64, { RA, RS, RB } }, { "srad.", XRC(31,794,1), X_MASK, PPC64, { RA, RS, RB } }, { "lhzcix", X(31,821), X_MASK, POWER6, { RT, RA0, RB } }, { "dss", XDSS(31,822,0), XDSS_MASK, PPCVEC, { STRM } }, { "dssall", XDSS(31,822,1), XDSS_MASK, PPCVEC, { 0 } }, { "srawi", XRC(31,824,0), X_MASK, PPCCOM, { RA, RS, SH } }, { "srawi.", XRC(31,824,1), X_MASK, PPCCOM, { RA, RS, SH } }, { "slbmfev", X(31,851), XRA_MASK, PPC64, { RT, RB } }, { "lbzcix", X(31,853), X_MASK, POWER6, { RT, RA0, RB } }, { "eieio", X(31,854), 0xffffffff, PPC, { 0 } }, { "lfiwax", X(31,855), X_MASK, POWER6, { FRT, RA0, RB } }, { "ldcix", X(31,885), X_MASK, POWER6, { RT, RA0, RB } }, { "slbmfee", X(31,915), XRA_MASK, PPC64, { RT, RB } }, { "stwcix", X(31,917), X_MASK, POWER6, { RS, RA0, RB } }, { "sthbrx", X(31,918), X_MASK, COM, { RS, RA0, RB } }, { "stfdpx", X(31,919), X_MASK, POWER6, { FRS, RA, RB } }, { "extsh", XRC(31,922,0), XRB_MASK, PPCCOM, { RA, RS } }, { "extsh.", XRC(31,922,1), XRB_MASK, PPCCOM, { RA, RS } }, { "sthcix", X(31,949), X_MASK, POWER6, { RS, RA0, RB } }, { "extsb", XRC(31,954,0), XRB_MASK, PPC, { RA, RS} }, { "extsb.", XRC(31,954,1), XRB_MASK, PPC, { RA, RS} }, { "tlbld", X(31,978), XRTRA_MASK, PPC, { RB } }, { "stbcix", X(31,981), X_MASK, POWER6, { RS, RA0, RB } }, { "icbi", X(31,982), XRT_MASK, PPC, { RA, RB } }, { "stfiwx", X(31,983), X_MASK, PPC, { FRS, RA0, RB } }, { "extsw", XRC(31,986,0), XRB_MASK, PPC64 | BOOKE64,{ RA, RS } }, { "extsw.", XRC(31,986,1), XRB_MASK, PPC64, { RA, RS } }, { "tlbli", X(31,1010), XRTRA_MASK, PPC, { RB } }, { "stdcix", X(31,1013), X_MASK, POWER6, { RS, RA0, RB } }, { "dcbzl", XOPL(31,1014,1), XRT_MASK, PPC, { RA, RB } }, { "dcbz", X(31,1014), XRT_MASK, PPC, { RA, RB } }, { "lvebx", X(31, 7), X_MASK, PPCVEC, { VD, RA0, RB } }, { "lvehx", X(31, 39), X_MASK, PPCVEC, { VD, RA0, RB } }, { "lvewx", X(31, 71), X_MASK, PPCVEC, { VD, RA0, RB } }, { "lvsl", X(31, 6), X_MASK, PPCVEC, { VD, RA0, RB } }, { "lvsr", X(31, 38), X_MASK, PPCVEC, { VD, RA0, RB } }, { "lvx", X(31, 103), X_MASK, PPCVEC, { VD, RA0, RB } }, { "lvxl", X(31, 359), X_MASK, PPCVEC, { VD, RA0, RB } }, { "stvebx", X(31, 135), X_MASK, PPCVEC, { VS, RA0, RB } }, { "stvehx", X(31, 167), X_MASK, PPCVEC, { VS, RA0, RB } }, { "stvewx", X(31, 199), X_MASK, PPCVEC, { VS, RA0, RB } }, { "stvx", X(31, 231), X_MASK, PPCVEC, { VS, RA0, RB } }, { "stvxl", X(31, 487), X_MASK, PPCVEC, { VS, RA0, RB } }, { "lvlx", X(31, 519), X_MASK, CELL, { VD, RA0, RB } }, { "lvlxl", X(31, 775), X_MASK, CELL, { VD, RA0, RB } }, { "lvrx", X(31, 551), X_MASK, CELL, { VD, RA0, RB } }, { "lvrxl", X(31, 807), X_MASK, CELL, { VD, RA0, RB } }, { "stvlx", X(31, 647), X_MASK, CELL, { VS, RA0, RB } }, { "stvlxl", X(31, 903), X_MASK, CELL, { VS, RA0, RB } }, { "stvrx", X(31, 679), X_MASK, CELL, { VS, RA0, RB } }, { "stvrxl", X(31, 935), X_MASK, CELL, { VS, RA0, RB } }, { "lwz", OP(32), OP_MASK, PPCCOM, { RT, D, RA0 } }, { "lwzu", OP(33), OP_MASK, PPCCOM, { RT, D, RAL } }, { "lbz", OP(34), OP_MASK, COM, { RT, D, RA0 } }, { "lbzu", OP(35), OP_MASK, COM, { RT, D, RAL } }, { "stw", OP(36), OP_MASK, PPCCOM, { RS, D, RA0 } }, { "stwu", OP(37), OP_MASK, PPCCOM, { RS, D, RAS } }, { "stb", OP(38), OP_MASK, COM, { RS, D, RA0 } }, { "stbu", OP(39), OP_MASK, COM, { RS, D, RAS } }, { "lhz", OP(40), OP_MASK, COM, { RT, D, RA0 } }, { "lhzu", OP(41), OP_MASK, COM, { RT, D, RAL } }, { "lha", OP(42), OP_MASK, COM, { RT, D, RA0 } }, { "lhau", OP(43), OP_MASK, COM, { RT, D, RAL } }, { "sth", OP(44), OP_MASK, COM, { RS, D, RA0 } }, { "sthu", OP(45), OP_MASK, COM, { RS, D, RAS } }, { "lmw", OP(46), OP_MASK, PPCCOM, { RT, D, RAM } }, { "stmw", OP(47), OP_MASK, PPCCOM, { RS, D, RA0 } }, { "lfs", OP(48), OP_MASK, COM, { FRT, D, RA0 } }, { "lfsu", OP(49), OP_MASK, COM, { FRT, D, RAS } }, { "lfd", OP(50), OP_MASK, COM, { FRT, D, RA0 } }, { "lfdu", OP(51), OP_MASK, COM, { FRT, D, RAS } }, { "stfs", OP(52), OP_MASK, COM, { FRS, D, RA0 } }, { "stfsu", OP(53), OP_MASK, COM, { FRS, D, RAS } }, { "stfd", OP(54), OP_MASK, COM, { FRS, D, RA0 } }, { "stfdu", OP(55), OP_MASK, COM, { FRS, D, RAS } }, { "lq", OP(56), OP_MASK, POWER4, { RTQ, DQ, RAQ } }, { "lfdp", OP(57), OP_MASK, POWER6, { FRT, D, RA0 } }, { "ld", DSO(58,0), DS_MASK, PPC64, { RT, DS, RA0 } }, { "ldu", DSO(58,1), DS_MASK, PPC64, { RT, DS, RAL } }, { "lwa", DSO(58,2), DS_MASK, PPC64, { RT, DS, RA0 } }, { "dadd", XRC(59,2,0), X_MASK, POWER6, { FRT, FRA, FRB } }, { "dadd.", XRC(59,2,1), X_MASK, POWER6, { FRT, FRA, FRB } }, { "dqua", ZRC(59,3,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, { "dqua.", ZRC(59,3,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, { "fdivs", A(59,18,0), AFRC_MASK, PPC, { FRT, FRA, FRB } }, { "fdivs.", A(59,18,1), AFRC_MASK, PPC, { FRT, FRA, FRB } }, { "fsubs", A(59,20,0), AFRC_MASK, PPC, { FRT, FRA, FRB } }, { "fsubs.", A(59,20,1), AFRC_MASK, PPC, { FRT, FRA, FRB } }, { "fadds", A(59,21,0), AFRC_MASK, PPC, { FRT, FRA, FRB } }, { "fadds.", A(59,21,1), AFRC_MASK, PPC, { FRT, FRA, FRB } }, { "fsqrts", A(59,22,0), AFRAFRC_MASK, PPC, { FRT, FRB } }, { "fsqrts.", A(59,22,1), AFRAFRC_MASK, PPC, { FRT, FRB } }, { "fres", A(59,24,0), AFRAFRC_MASK, PPC, { FRT, FRB } }, { "fres.", A(59,24,1), AFRAFRC_MASK, PPC, { FRT, FRB } }, { "fmuls", A(59,25,0), AFRB_MASK, PPC, { FRT, FRA, FRC } }, { "fmuls.", A(59,25,1), AFRB_MASK, PPC, { FRT, FRA, FRC } }, { "fmsubs", A(59,28,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, { "fmsubs.", A(59,28,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, { "fmadds", A(59,29,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, { "fmadds.", A(59,29,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, { "fnmsubs", A(59,30,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, { "fnmsubs.",A(59,30,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, { "fnmadds", A(59,31,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, { "fnmadds.",A(59,31,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, { "dmul", XRC(59,34,0), X_MASK, POWER6, { FRT, FRA, FRB } }, { "dmul.", XRC(59,34,1), X_MASK, POWER6, { FRT, FRA, FRB } }, { "drrnd", ZRC(59,35,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, { "drrnd.", ZRC(59,35,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, { "dscli", ZRC(59,66,0), Z_MASK, POWER6, { FRT, FRA, SH16 } }, { "dscli.", ZRC(59,66,1), Z_MASK, POWER6, { FRT, FRA, SH16 } }, { "dquai", ZRC(59,67,0), Z_MASK, POWER6, { TE, FRT, FRB, RMC } }, { "dquai.", ZRC(59,67,1), Z_MASK, POWER6, { TE, FRT, FRB, RMC } }, { "dscri", ZRC(59,98,0), Z_MASK, POWER6, { FRT, FRA, SH16 } }, { "dscri.", ZRC(59,98,1), Z_MASK, POWER6, { FRT, FRA, SH16 } }, { "drintx", ZRC(59,99,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, { "drintx.", ZRC(59,99,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, { "dcmpo", X(59,130), X_MASK, POWER6, { BF, FRA, FRB } }, { "dtstex", X(59,162), X_MASK, POWER6, { BF, FRA, FRB } }, { "dtstdc", Z(59,194), Z_MASK, POWER6, { BF, FRA, DCM } }, { "dtstdg", Z(59,226), Z_MASK, POWER6, { BF, FRA, DGM } }, { "drintn", ZRC(59,227,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, { "drintn.", ZRC(59,227,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, { "dctdp", XRC(59,258,0), X_MASK, POWER6, { FRT, FRB } }, { "dctdp.", XRC(59,258,1), X_MASK, POWER6, { FRT, FRB } }, { "dctfix", XRC(59,290,0), X_MASK, POWER6, { FRT, FRB } }, { "dctfix.", XRC(59,290,1), X_MASK, POWER6, { FRT, FRB } }, { "ddedpd", XRC(59,322,0), X_MASK, POWER6, { SP, FRT, FRB } }, { "ddedpd.", XRC(59,322,1), X_MASK, POWER6, { SP, FRT, FRB } }, { "dxex", XRC(59,354,0), X_MASK, POWER6, { FRT, FRB } }, { "dxex.", XRC(59,354,1), X_MASK, POWER6, { FRT, FRB } }, { "dsub", XRC(59,514,0), X_MASK, POWER6, { FRT, FRA, FRB } }, { "dsub.", XRC(59,514,1), X_MASK, POWER6, { FRT, FRA, FRB } }, { "ddiv", XRC(59,546,0), X_MASK, POWER6, { FRT, FRA, FRB } }, { "ddiv.", XRC(59,546,1), X_MASK, POWER6, { FRT, FRA, FRB } }, { "dcmpu", X(59,642), X_MASK, POWER6, { BF, FRA, FRB } }, { "dtstsf", X(59,674), X_MASK, POWER6, { BF, FRA, FRB } }, { "drsp", XRC(59,770,0), X_MASK, POWER6, { FRT, FRB } }, { "drsp.", XRC(59,770,1), X_MASK, POWER6, { FRT, FRB } }, { "dcffix", XRC(59,802,0), X_MASK, POWER6, { FRT, FRB } }, { "dcffix.", XRC(59,802,1), X_MASK, POWER6, { FRT, FRB } }, { "denbcd", XRC(59,834,0), X_MASK, POWER6, { S, FRT, FRB } }, { "denbcd.", XRC(59,834,1), X_MASK, POWER6, { S, FRT, FRB } }, { "diex", XRC(59,866,0), X_MASK, POWER6, { FRT, FRA, FRB } }, { "diex.", XRC(59,866,1), X_MASK, POWER6, { FRT, FRA, FRB } }, { "stfdp", OP(61), OP_MASK, POWER6, { FRT, D, RA0 } }, { "std", DSO(62,0), DS_MASK, PPC64, { RS, DS, RA0 } }, { "stdu", DSO(62,1), DS_MASK, PPC64, { RS, DS, RAS } }, { "stq", DSO(62,2), DS_MASK, POWER4, { RSQ, DS, RA0 } }, { "fcmpu", X(63,0), X_MASK|(3<<21), COM, { BF, FRA, FRB } }, { "daddq", XRC(63,2,0), X_MASK, POWER6, { FRT, FRA, FRB } }, { "daddq.", XRC(63,2,1), X_MASK, POWER6, { FRT, FRA, FRB } }, { "dquaq", ZRC(63,3,0), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, { "dquaq.", ZRC(63,3,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, { "fcpsgn", XRC(63,8,0), X_MASK, POWER6, { FRT, FRA, FRB } }, { "fcpsgn.", XRC(63,8,1), X_MASK, POWER6, { FRT, FRA, FRB } }, { "frsp", XRC(63,12,0), XRA_MASK, COM, { FRT, FRB } }, { "frsp.", XRC(63,12,1), XRA_MASK, COM, { FRT, FRB } }, { "fctiw", XRC(63,14,0), XRA_MASK, PPCCOM, { FRT, FRB } }, { "fctiw.", XRC(63,14,1), XRA_MASK, PPCCOM, { FRT, FRB } }, { "fctiwz", XRC(63,15,0), XRA_MASK, PPCCOM, { FRT, FRB } }, { "fctiwz.", XRC(63,15,1), XRA_MASK, PPCCOM, { FRT, FRB } }, { "fdiv", A(63,18,0), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } }, { "fdiv.", A(63,18,1), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } }, { "fsub", A(63,20,0), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } }, { "fsub.", A(63,20,1), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } }, { "fadd", A(63,21,0), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } }, { "fadd.", A(63,21,1), AFRC_MASK, PPCCOM, { FRT, FRA, FRB } }, { "fsqrt", A(63,22,0), AFRAFRC_MASK, PPCPWR2, { FRT, FRB } }, { "fsqrt.", A(63,22,1), AFRAFRC_MASK, PPCPWR2, { FRT, FRB } }, { "fsel", A(63,23,0), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, { "fsel.", A(63,23,1), A_MASK, PPC, { FRT,FRA,FRC,FRB } }, { "fmul", A(63,25,0), AFRB_MASK, PPCCOM, { FRT, FRA, FRC } }, { "fmul.", A(63,25,1), AFRB_MASK, PPCCOM, { FRT, FRA, FRC } }, { "frsqrte", A(63,26,0), AFRAFRC_MASK, PPC, { FRT, FRB } }, { "frsqrte.",A(63,26,1), AFRAFRC_MASK, PPC, { FRT, FRB } }, { "fmsub", A(63,28,0), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } }, { "fmsub.", A(63,28,1), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } }, { "fmadd", A(63,29,0), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } }, { "fmadd.", A(63,29,1), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } }, { "fnmsub", A(63,30,0), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } }, { "fnmsub.", A(63,30,1), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } }, { "fnmadd", A(63,31,0), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } }, { "fnmadd.", A(63,31,1), A_MASK, PPCCOM, { FRT,FRA,FRC,FRB } }, { "fcmpo", X(63,32), X_MASK|(3<<21), COM, { BF, FRA, FRB } }, { "mtfsb1", XRC(63,38,0), XRARB_MASK, COM, { BT } }, { "mtfsb1.", XRC(63,38,1), XRARB_MASK, COM, { BT } }, { "fneg", XRC(63,40,0), XRA_MASK, COM, { FRT, FRB } }, { "fneg.", XRC(63,40,1), XRA_MASK, COM, { FRT, FRB } }, { "mcrfs", X(63,64), XRB_MASK|(3<<21)|(3<<16), COM, { BF, BFA } }, { "dscliq", ZRC(63,66,0), Z_MASK, POWER6, { FRT, FRA, SH16 } }, { "dscliq.", ZRC(63,66,1), Z_MASK, POWER6, { FRT, FRA, SH16 } }, { "dquaiq", ZRC(63,67,0), Z_MASK, POWER6, { TE, FRT, FRB, RMC } }, { "dquaiq.", ZRC(63,67,1), Z_MASK, POWER6, { FRT, FRA, FRB, RMC } }, { "mtfsb0", XRC(63,70,0), XRARB_MASK, COM, { BT } }, { "mtfsb0.", XRC(63,70,1), XRARB_MASK, COM, { BT } }, { "fmr", XRC(63,72,0), XRA_MASK, COM, { FRT, FRB } }, { "fmr.", XRC(63,72,1), XRA_MASK, COM, { FRT, FRB } }, { "dscriq", ZRC(63,98,0), Z_MASK, POWER6, { FRT, FRA, SH16 } }, { "dscriq.", ZRC(63,98,1), Z_MASK, POWER6, { FRT, FRA, SH16 } }, { "drintxq", ZRC(63,99,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, { "drintxq.",ZRC(63,99,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, { "dcmpoq", X(63,130), X_MASK, POWER6, { BF, FRA, FRB } }, { "mtfsfi", XRC(63,134,0), XRA_MASK|(3<<21)|(1<<11), COM, { BF, U } }, { "mtfsfi.", XRC(63,134,1), XRA_MASK|(3<<21)|(1<<11), COM, { BF, U } }, { "fnabs", XRC(63,136,0), XRA_MASK, COM, { FRT, FRB } }, { "fnabs.", XRC(63,136,1), XRA_MASK, COM, { FRT, FRB } }, { "dtstexq", X(63,162), X_MASK, POWER6, { BF, FRA, FRB } }, { "dtstdcq", Z(63,194), Z_MASK, POWER6, { BF, FRA, DCM } }, { "dtstdgq", Z(63,226), Z_MASK, POWER6, { BF, FRA, DGM } }, { "drintnq", ZRC(63,227,0), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, { "drintnq.",ZRC(63,227,1), Z_MASK, POWER6, { R, FRT, FRB, RMC } }, { "dctqpq", XRC(63,258,0), X_MASK, POWER6, { FRT, FRB } }, { "dctqpq.", XRC(63,258,1), X_MASK, POWER6, { FRT, FRB } }, { "fabs", XRC(63,264,0), XRA_MASK, COM, { FRT, FRB } }, { "fabs.", XRC(63,264,1), XRA_MASK, COM, { FRT, FRB } }, { "dctfixq", XRC(63,290,0), X_MASK, POWER6, { FRT, FRB } }, { "dctfixq.",XRC(63,290,1), X_MASK, POWER6, { FRT, FRB } }, { "ddedpdq", XRC(63,322,0), X_MASK, POWER6, { SP, FRT, FRB } }, { "ddedpdq.",XRC(63,322,1), X_MASK, POWER6, { SP, FRT, FRB } }, { "dxexq", XRC(63,354,0), X_MASK, POWER6, { FRT, FRB } }, { "dxexq.", XRC(63,354,1), X_MASK, POWER6, { FRT, FRB } }, { "frin", XRC(63,392,0), XRA_MASK, POWER5, { FRT, FRB } }, { "frin.", XRC(63,392,1), XRA_MASK, POWER5, { FRT, FRB } }, { "friz", XRC(63,424,0), XRA_MASK, POWER5, { FRT, FRB } }, { "friz.", XRC(63,424,1), XRA_MASK, POWER5, { FRT, FRB } }, { "frip", XRC(63,456,0), XRA_MASK, POWER5, { FRT, FRB } }, { "frip.", XRC(63,456,1), XRA_MASK, POWER5, { FRT, FRB } }, { "frim", XRC(63,488,0), XRA_MASK, POWER5, { FRT, FRB } }, { "frim.", XRC(63,488,1), XRA_MASK, POWER5, { FRT, FRB } }, { "dsubq", XRC(63,514,0), X_MASK, POWER6, { FRT, FRA, FRB } }, { "dsubq.", XRC(63,514,1), X_MASK, POWER6, { FRT, FRA, FRB } }, { "ddivq", XRC(63,546,0), X_MASK, POWER6, { FRT, FRA, FRB } }, { "ddivq.", XRC(63,546,1), X_MASK, POWER6, { FRT, FRA, FRB } }, { "mffs", XRC(63,583,0), XRARB_MASK, COM, { FRT } }, { "mffs.", XRC(63,583,1), XRARB_MASK, COM, { FRT } }, { "dcmpuq", X(63,642), X_MASK, POWER6, { BF, FRA, FRB } }, { "dtstsfq", X(63,674), X_MASK, POWER6, { BF, FRA, FRB } }, { "mtfsf", XFL(63,711,0), XFL_MASK, COM, { FLM, FRB } }, { "mtfsf.", XFL(63,711,1), XFL_MASK, COM, { FLM, FRB } }, { "drdpq", XRC(63,770,0), X_MASK, POWER6, { FRT, FRB } }, { "drdpq.", XRC(63,770,1), X_MASK, POWER6, { FRT, FRB } }, { "dcffixq", XRC(63,802,0), X_MASK, POWER6, { FRT, FRB } }, { "dcffixq.",XRC(63,802,1), X_MASK, POWER6, { FRT, FRB } }, { "fctid", XRC(63,814,0), XRA_MASK, PPC64, { FRT, FRB } }, { "fctid.", XRC(63,814,1), XRA_MASK, PPC64, { FRT, FRB } }, { "fctidz", XRC(63,815,0), XRA_MASK, PPC64, { FRT, FRB } }, { "fctidz.", XRC(63,815,1), XRA_MASK, PPC64, { FRT, FRB } }, { "denbcdq", XRC(63,834,0), X_MASK, POWER6, { S, FRT, FRB } }, { "denbcdq.",XRC(63,834,1), X_MASK, POWER6, { S, FRT, FRB } }, { "fcfid", XRC(63,846,0), XRA_MASK, PPC64, { FRT, FRB } }, { "fcfid.", XRC(63,846,1), XRA_MASK, PPC64, { FRT, FRB } }, { "diexq", XRC(63,866,0), X_MASK, POWER6, { FRT, FRA, FRB } }, { "diexq.", XRC(63,866,1), X_MASK, POWER6, { FRT, FRA, FRB } }, }; const int powerpc_num_opcodes = sizeof (powerpc_opcodes) / sizeof (powerpc_opcodes[0]); ht-2.0.22/asm/arm.h0000644000175000001440000002140110615342570010636 00000000000000/* ARM assembler/disassembler support. Copyright 2004 Free Software Foundation, Inc. This file is part of GDB and GAS. GDB and GAS are free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. GDB and GAS are distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GDB or GAS; see the file COPYING. If not, write to the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ /* The following bitmasks control CPU extensions: */ #define ARM_EXT_V1 0x00000001 /* All processors (core set). */ #define ARM_EXT_V2 0x00000002 /* Multiply instructions. */ #define ARM_EXT_V2S 0x00000004 /* SWP instructions. */ #define ARM_EXT_V3 0x00000008 /* MSR MRS. */ #define ARM_EXT_V3M 0x00000010 /* Allow long multiplies. */ #define ARM_EXT_V4 0x00000020 /* Allow half word loads. */ #define ARM_EXT_V4T 0x00000040 /* Thumb. */ #define ARM_EXT_V5 0x00000080 /* Allow CLZ, etc. */ #define ARM_EXT_V5T 0x00000100 /* Improved interworking. */ #define ARM_EXT_V5ExP 0x00000200 /* DSP core set. */ #define ARM_EXT_V5E 0x00000400 /* DSP Double transfers. */ #define ARM_EXT_V5J 0x00000800 /* Jazelle extension. */ #define ARM_EXT_V6 0x00001000 /* ARM V6. */ #define ARM_EXT_V6K 0x00002000 /* ARM V6K. */ #define ARM_EXT_V6Z 0x00004000 /* ARM V6Z. */ #define ARM_EXT_V6T2 0x00008000 /* Thumb-2. */ #define ARM_EXT_DIV 0x00010000 /* Integer division. */ /* The 'M' in Arm V7M stands for Microcontroller. On earlier architecture variants it stands for Multiply. */ #define ARM_EXT_V5E_NOTM 0x00020000 /* Arm V5E but not Arm V7M. */ #define ARM_EXT_V6_NOTM 0x00040000 /* Arm V6 but not Arm V7M. */ #define ARM_EXT_V7 0x00080000 /* Arm V7. */ #define ARM_EXT_V7A 0x00100000 /* Arm V7A. */ #define ARM_EXT_V7R 0x00200000 /* Arm V7R. */ #define ARM_EXT_V7M 0x00400000 /* Arm V7M. */ /* Co-processor space extensions. */ #define ARM_CEXT_XSCALE 0x00000001 /* Allow MIA etc. */ #define ARM_CEXT_MAVERICK 0x00000002 /* Use Cirrus/DSP coprocessor. */ #define ARM_CEXT_IWMMXT 0x00000004 /* Intel Wireless MMX technology coprocessor. */ #define FPU_ENDIAN_PURE 0x80000000 /* Pure-endian doubles. */ #define FPU_ENDIAN_BIG 0 /* Double words-big-endian. */ #define FPU_FPA_EXT_V1 0x40000000 /* Base FPA instruction set. */ #define FPU_FPA_EXT_V2 0x20000000 /* LFM/SFM. */ #define FPU_MAVERICK 0x10000000 /* Cirrus Maverick. */ #define FPU_VFP_EXT_V1xD 0x08000000 /* Base VFP instruction set. */ #define FPU_VFP_EXT_V1 0x04000000 /* Double-precision insns. */ #define FPU_VFP_EXT_V2 0x02000000 /* ARM10E VFPr1. */ /* Architectures are the sum of the base and extensions. The ARM ARM (rev E) defines the following: ARMv3, ARMv3M, ARMv4xM, ARMv4, ARMv4TxM, ARMv4T, ARMv5xM, ARMv5, ARMv5TxM, ARMv5T, ARMv5TExP, ARMv5TE. To these we add three more to cover cores prior to ARM6. Finally, there are cores which implement further extensions in the co-processor space. */ #define ARM_AEXT_V1 ARM_EXT_V1 #define ARM_AEXT_V2 (ARM_AEXT_V1 | ARM_EXT_V2) #define ARM_AEXT_V2S (ARM_AEXT_V2 | ARM_EXT_V2S) #define ARM_AEXT_V3 (ARM_AEXT_V2S | ARM_EXT_V3) #define ARM_AEXT_V3M (ARM_AEXT_V3 | ARM_EXT_V3M) #define ARM_AEXT_V4xM (ARM_AEXT_V3 | ARM_EXT_V4) #define ARM_AEXT_V4 (ARM_AEXT_V3M | ARM_EXT_V4) #define ARM_AEXT_V4TxM (ARM_AEXT_V4xM | ARM_EXT_V4T) #define ARM_AEXT_V4T (ARM_AEXT_V4 | ARM_EXT_V4T) #define ARM_AEXT_V5xM (ARM_AEXT_V4xM | ARM_EXT_V5) #define ARM_AEXT_V5 (ARM_AEXT_V4 | ARM_EXT_V5) #define ARM_AEXT_V5TxM (ARM_AEXT_V5xM | ARM_EXT_V4T | ARM_EXT_V5T) #define ARM_AEXT_V5T (ARM_AEXT_V5 | ARM_EXT_V4T | ARM_EXT_V5T) #define ARM_AEXT_V5TExP (ARM_AEXT_V5T | ARM_EXT_V5ExP) #define ARM_AEXT_V5TE (ARM_AEXT_V5TExP | ARM_EXT_V5E) #define ARM_AEXT_V5TEJ (ARM_AEXT_V5TE | ARM_EXT_V5J) #define ARM_AEXT_V6 (ARM_AEXT_V5TEJ | ARM_EXT_V6) #define ARM_AEXT_V6K (ARM_AEXT_V6 | ARM_EXT_V6K) #define ARM_AEXT_V6Z (ARM_AEXT_V6 | ARM_EXT_V6Z) #define ARM_AEXT_V6ZK (ARM_AEXT_V6 | ARM_EXT_V6K | ARM_EXT_V6Z) #define ARM_AEXT_V6T2 (ARM_AEXT_V6 | ARM_EXT_V6T2 | ARM_EXT_V6_NOTM) #define ARM_AEXT_V6KT2 (ARM_AEXT_V6T2 | ARM_EXT_V6K) #define ARM_AEXT_V6ZT2 (ARM_AEXT_V6T2 | ARM_EXT_V6Z) #define ARM_AEXT_V6ZKT2 (ARM_AEXT_V6T2 | ARM_EXT_V6K | ARM_EXT_V6Z) #define ARM_AEXT_V7_ARM (ARM_AEXT_V6ZKT2 | ARM_EXT_V7) #define ARM_AEXT_V7A (ARM_AEXT_V7_ARM | ARM_EXT_V7A) #define ARM_AEXT_V7R (ARM_AEXT_V7_ARM | ARM_EXT_V7R | ARM_EXT_DIV) #define ARM_AEXT_NOTM \ (ARM_AEXT_V4 | ARM_EXT_V5ExP | ARM_EXT_V5J | ARM_EXT_V6_NOTM) #define ARM_AEXT_V7M \ ((ARM_AEXT_V7_ARM | ARM_EXT_V7M | ARM_EXT_DIV) & ~(ARM_AEXT_NOTM)) #define ARM_AEXT_V7 (ARM_AEXT_V7A & ARM_AEXT_V7R & ARM_AEXT_V7M) /* Processors with specific extensions in the co-processor space. */ #define ARM_ARCH_XSCALE ARM_FEATURE (ARM_AEXT_V5TE, ARM_CEXT_XSCALE) #define ARM_ARCH_IWMMXT \ ARM_FEATURE (ARM_AEXT_V5TE, ARM_CEXT_XSCALE | ARM_CEXT_IWMMXT) #define FPU_VFP_V1xD (FPU_VFP_EXT_V1xD | FPU_ENDIAN_PURE) #define FPU_VFP_V1 (FPU_VFP_V1xD | FPU_VFP_EXT_V1) #define FPU_VFP_V2 (FPU_VFP_V1 | FPU_VFP_EXT_V2) #define FPU_VFP_HARD (FPU_VFP_EXT_V1xD | FPU_VFP_EXT_V1 | FPU_VFP_EXT_V2) #define FPU_FPA (FPU_FPA_EXT_V1 | FPU_FPA_EXT_V2) /* Deprecated */ #define FPU_ARCH_VFP ARM_FEATURE (0, FPU_ENDIAN_PURE) #define FPU_ARCH_FPE ARM_FEATURE (0, FPU_FPA_EXT_V1) #define FPU_ARCH_FPA ARM_FEATURE (0, FPU_FPA) #define FPU_ARCH_VFP_V1xD ARM_FEATURE (0, FPU_VFP_V1xD) #define FPU_ARCH_VFP_V1 ARM_FEATURE (0, FPU_VFP_V1) #define FPU_ARCH_VFP_V2 ARM_FEATURE (0, FPU_VFP_V2) #define FPU_ARCH_VFP_HARD ARM_FEATURE (0, FPU_VFP_HARD) #define FPU_ARCH_ENDIAN_PURE ARM_FEATURE (0, FPU_ENDIAN_PURE) #define FPU_ARCH_MAVERICK ARM_FEATURE (0, FPU_MAVERICK) #define ARM_ARCH_V1 ARM_FEATURE (ARM_AEXT_V1, 0) #define ARM_ARCH_V2 ARM_FEATURE (ARM_AEXT_V2, 0) #define ARM_ARCH_V2S ARM_FEATURE (ARM_AEXT_V2S, 0) #define ARM_ARCH_V3 ARM_FEATURE (ARM_AEXT_V3, 0) #define ARM_ARCH_V3M ARM_FEATURE (ARM_AEXT_V3M, 0) #define ARM_ARCH_V4xM ARM_FEATURE (ARM_AEXT_V4xM, 0) #define ARM_ARCH_V4 ARM_FEATURE (ARM_AEXT_V4, 0) #define ARM_ARCH_V4TxM ARM_FEATURE (ARM_AEXT_V4TxM, 0) #define ARM_ARCH_V4T ARM_FEATURE (ARM_AEXT_V4T, 0) #define ARM_ARCH_V5xM ARM_FEATURE (ARM_AEXT_V5xM, 0) #define ARM_ARCH_V5 ARM_FEATURE (ARM_AEXT_V5, 0) #define ARM_ARCH_V5TxM ARM_FEATURE (ARM_AEXT_V5TxM, 0) #define ARM_ARCH_V5T ARM_FEATURE (ARM_AEXT_V5T, 0) #define ARM_ARCH_V5TExP ARM_FEATURE (ARM_AEXT_V5TExP, 0) #define ARM_ARCH_V5TE ARM_FEATURE (ARM_AEXT_V5TE, 0) #define ARM_ARCH_V5TEJ ARM_FEATURE (ARM_AEXT_V5TEJ, 0) #define ARM_ARCH_V6 ARM_FEATURE (ARM_AEXT_V6, 0) #define ARM_ARCH_V6K ARM_FEATURE (ARM_AEXT_V6K, 0) #define ARM_ARCH_V6Z ARM_FEATURE (ARM_AEXT_V6Z, 0) #define ARM_ARCH_V6ZK ARM_FEATURE (ARM_AEXT_V6ZK, 0) #define ARM_ARCH_V6T2 ARM_FEATURE (ARM_AEXT_V6T2, 0) #define ARM_ARCH_V6KT2 ARM_FEATURE (ARM_AEXT_V6KT2, 0) #define ARM_ARCH_V6ZT2 ARM_FEATURE (ARM_AEXT_V6ZT2, 0) #define ARM_ARCH_V6ZKT2 ARM_FEATURE (ARM_AEXT_V6ZKT2, 0) #define ARM_ARCH_V7 ARM_FEATURE (ARM_AEXT_V7, 0) #define ARM_ARCH_V7A ARM_FEATURE (ARM_AEXT_V7A, 0) #define ARM_ARCH_V7R ARM_FEATURE (ARM_AEXT_V7R, 0) #define ARM_ARCH_V7M ARM_FEATURE (ARM_AEXT_V7M, 0) /* Some useful combinations: */ #define ARM_ARCH_NONE ARM_FEATURE (0, 0) #define FPU_NONE ARM_FEATURE (0, 0) #define ARM_ANY ARM_FEATURE (-1, 0) /* Any basic core. */ #define FPU_ANY_HARD ARM_FEATURE (0, FPU_FPA | FPU_VFP_HARD | FPU_MAVERICK) #define ARM_ARCH_THUMB2 ARM_FEATURE (ARM_EXT_V6T2 | ARM_EXT_V7 | ARM_EXT_V7A | ARM_EXT_V7R | ARM_EXT_V7M | ARM_EXT_DIV, 0) /* There are too many feature bits to fit in a single word, so use a structure. For simplicity we put all core features in one word and everything else in the other. */ typedef struct { unsigned long core; unsigned long coproc; } arm_feature_set; #define ARM_CPU_HAS_FEATURE(CPU,FEAT) \ (((CPU).core & (FEAT).core) != 0 || ((CPU).coproc & (FEAT).coproc) != 0) #define ARM_MERGE_FEATURE_SETS(TARG,F1,F2) \ do { \ (TARG).core = (F1).core | (F2).core; \ (TARG).coproc = (F1).coproc | (F2).coproc; \ } while (0) #define ARM_CLEAR_FEATURE(TARG,F1,F2) \ do { \ (TARG).core = (F1).core &~ (F2).core; \ (TARG).coproc = (F1).coproc &~ (F2).coproc; \ } while (0) #define ARM_FEATURE(core, coproc) {(core), (coproc)} ht-2.0.22/asm/ildis.cc0000644000175000001440000002016110615342402011315 00000000000000/* * HT Editor * ildis.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "data.h" #include "endianess.h" #include "ildis.h" #include "ilopc.h" #include "snprintf.h" ILDisassembler::ILDisassembler(char* (*sf)(uint32 string_ofs, void *context), char* (*tf)(uint32 token, void *context), void *ctx) { initialize(sf, tf, ctx); } void ILDisassembler::initialize(char* (*sf)(uint32 string_ofs, void *context), char* (*tf)(uint32 token, void *context), void *ctx) { string_func = sf; token_func = tf; context = ctx; } dis_insn *ILDisassembler::decode(byte *code, int maxlen, CPU_ADDR addr) { insn.valid = false; insn.prefix = NULL; insn.size = 0; insn.data.ui = *code; if (!maxlen) { return (dis_insn *)&insn; } restart: insn.opcode = &il_opcode_table[*code]; insn.size = insn.opcode->size; if (insn.size > maxlen) { insn.size = 1; insn.valid = false; return (dis_insn *)&insn; } insn.op = insn.opcode->op; switch (insn.op) { case IL_OPCODE_ARGS_INVALID: return (dis_insn *)&insn; case IL_OPCODE_ARGS_NONE: break; case IL_OPCODE_ARGS_PREFIX: insn.opcode = NULL; code++; if (*code < MAX_IL_OPCODE_PREFIX) { insn.prefix = &il_prefix_opcode_table[*code]; code++; goto restart; } else { insn.size = 1; insn.valid = false; return (dis_insn *)&insn; } case IL_OPCODE_ARGS_SHORT_JUMP: { int c = ((char)code[1]); insn.data.ui = addr.addr32.offset+2+c; break; } case IL_OPCODE_ARGS_LONG_JUMP: { int c = createHostInt(code+1, 4, little_endian); insn.data.ui = addr.addr32.offset+5+c; break; } case IL_OPCODE_ARGS_UINT16: case IL_OPCODE_ARGS_LONG_ARG: case IL_OPCODE_ARGS_LONG_VAR: case IL_OPCODE_ARGS_ANN_ARG: case IL_OPCODE_ARGS_ANN_DEAD: case IL_OPCODE_ARGS_ANN_LIVE: { uint16 w = createHostInt(code+1, 2, little_endian); insn.data.ui = w; break; } case IL_OPCODE_ARGS_INT16: { uint16 w = createHostInt(code+1, 2, little_endian); insn.data.i = (int)((short)w); break; } case IL_OPCODE_ARGS_UINT8: insn.data.ui = (byte)code[1]; break; case IL_OPCODE_ARGS_INT8: case IL_OPCODE_ARGS_SHORT_VAR: case IL_OPCODE_ARGS_SHORT_ARG: case IL_OPCODE_ARGS_ANN_REF_S: { insn.data.i = (int)((char)code[1]); break; } case IL_OPCODE_ARGS_INT64: insn.data.q = createHostInt64(code+5, 8, little_endian); break; case IL_OPCODE_ARGS_TOKEN: case IL_OPCODE_ARGS_NEW: case IL_OPCODE_ARGS_CALL: case IL_OPCODE_ARGS_CALLVIRT: case IL_OPCODE_ARGS_INT32: case IL_OPCODE_ARGS_STRING: insn.data.ui = createHostInt(code+1, 4, little_endian); break; case IL_OPCODE_ARGS_FLOAT32: // FIXME: hack insn.data.ui = createHostInt(code+1, 4, little_endian); break; case IL_OPCODE_ARGS_FLOAT64: // FIXME: hack insn.data.q = createHostInt64(code+5, 8, little_endian); break; // variable length opcodes case IL_OPCODE_ARGS_SWITCH: { uint32 num = createHostInt(code+1, 4, little_endian); if (num > 10000) { insn.valid = false; insn.size = 1; return (dis_insn *)&insn; } insn.size += num * 4; break; } case IL_OPCODE_ARGS_ANN_DATA_S: { uint32 num = (byte)code[1]; insn.size += num; break; } case IL_OPCODE_ARGS_ANN_DATA: { uint32 num = createHostInt(code+1, 4, little_endian); insn.size += num; break; } case IL_OPCODE_ARGS_ANN_PHI: { uint32 num = createHostInt(code+1, 2, little_endian); insn.size += num * 2; break; } } insn.valid = true; return (dis_insn *)&insn; } dis_insn *ILDisassembler::duplicateInsn(dis_insn *disasm_insn) { ILDisInsn *insn = ht_malloc(sizeof (ILDisInsn)); *insn = *(ILDisInsn *)disasm_insn; return insn; } void ILDisassembler::getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align) { // FIXME min_length = 1; max_length = 10; min_look_ahead = 120; avg_look_ahead = 24; addr_align = 1; } byte ILDisassembler::getSize(dis_insn *disasm_insn) { return ((ILDisInsn*)disasm_insn)->size; } const char *ILDisassembler::getName() { return "IL/Disassembler"; } const char *ILDisassembler::str(dis_insn *disasm_insn, int style) { return strf(disasm_insn, style, ""); } const char *ILDisassembler::strf(dis_insn *disasm_insn, int style, const char *format) { if (style & DIS_STYLE_HIGHLIGHT) enable_highlighting(); // const char *cs_default = get_cs(e_cs_default); const char *cs_number = get_cs(e_cs_number); // const char *cs_symbol = get_cs(e_cs_symbol); const char *cs_string = get_cs(e_cs_string); ILDisInsn *dis_insn = (ILDisInsn *) disasm_insn; if (!dis_insn->valid) { // is_invalid: // assert(dis_insn->size==1); sprintf(insnstr, "db %s0x%02x", cs_number, dis_insn->data.ui); } else { switch (dis_insn->op) { case IL_OPCODE_ARGS_NONE: sprintf(insnstr, "%-15s", dis_insn->opcode->name); break; case IL_OPCODE_ARGS_UINT8: case IL_OPCODE_ARGS_UINT16: case IL_OPCODE_ARGS_LONG_ARG: case IL_OPCODE_ARGS_LONG_VAR: case IL_OPCODE_ARGS_ANN_ARG: case IL_OPCODE_ARGS_ANN_DEAD: case IL_OPCODE_ARGS_ANN_LIVE: { sprintf(insnstr, "%-15s %s%u", dis_insn->opcode->name, cs_number, dis_insn->data.ui); break; } case IL_OPCODE_ARGS_INT8: case IL_OPCODE_ARGS_INT16: case IL_OPCODE_ARGS_INT32: case IL_OPCODE_ARGS_SHORT_VAR: case IL_OPCODE_ARGS_SHORT_ARG: case IL_OPCODE_ARGS_ANN_REF_S: { sprintf(insnstr, "%-15s %s%d", dis_insn->opcode->name, cs_number, dis_insn->data.i); break; } case IL_OPCODE_ARGS_INT64: ht_snprintf(insnstr, 100, "%-15s %s%qd", dis_insn->opcode->name, cs_number, &dis_insn->data.q); break; case IL_OPCODE_ARGS_CALL: case IL_OPCODE_ARGS_CALLI: case IL_OPCODE_ARGS_CALLVIRT: case IL_OPCODE_ARGS_NEW: case IL_OPCODE_ARGS_TOKEN: { uint32 token = dis_insn->data.ui; char *tokenstr = NULL; if (token_func) { tokenstr = token_func(token, context); if (tokenstr) { sprintf(insnstr, "%-15s %s", dis_insn->opcode->name, tokenstr); break; } } sprintf(insnstr, "%-15s %s0x%08x", dis_insn->opcode->name, cs_number, token); break; } case IL_OPCODE_ARGS_STRING: { if ((dis_insn->data.ui & IL_META_TOKEN_MASK) == IL_META_TOKEN_STRING) { uint32 strofs = dis_insn->data.ui & (~IL_META_TOKEN_MASK); char *str = NULL; if (string_func) { str = string_func(strofs, context); } if (str) { sprintf(insnstr, "%-15s %s\"%s\"", dis_insn->opcode->name, cs_string, str); break; } } sprintf(insnstr, "%-15s %s0x%08x", dis_insn->opcode->name, cs_number, dis_insn->data.ui); break; } case IL_OPCODE_ARGS_LONG_JUMP: case IL_OPCODE_ARGS_SHORT_JUMP: { CPU_ADDR caddr; caddr.addr32.offset = dis_insn->data.ui; int slen; char *s = (addr_sym_func) ? addr_sym_func(caddr, &slen, addr_sym_func_context) : NULL; if (s) { char *p = insnstr + sprintf(insnstr, "%-15s ", dis_insn->opcode->name); memmove(p, s, slen); p[slen] = 0; } else { sprintf(insnstr, "%-15s %s0x%08x", dis_insn->opcode->name, cs_number, dis_insn->data.ui); } break; } case IL_OPCODE_ARGS_FLOAT32: { sprintf(insnstr, "%-15s %s%f", dis_insn->opcode->name, cs_number, dis_insn->data.f); break; } case IL_OPCODE_ARGS_FLOAT64: { sprintf(insnstr, "%-15s %s%f", dis_insn->opcode->name, cs_number, dis_insn->data.df); break; } default: sprintf(insnstr, "%-15s [unsupported paramtype]", dis_insn->opcode->name); } } disable_highlighting(); return insnstr; } ObjectID ILDisassembler::getObjectID() const { return ATOM_DISASM_IL; } bool ILDisassembler::validInsn(dis_insn *disasm_insn) { return ((ILDisInsn *)disasm_insn)->valid; } ht-2.0.22/asm/ilopc.h0000644000175000001440000001020710615342402011161 00000000000000/* * HT Editor * ilopc.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ILOPC_H #define ILOPC_H #include "io/types.h" #define MAX_IL_OPCODE 256 #define MAX_IL_OPCODE_PREFIX 36 #define IL_OPCODE_ARGS_INVALID 0 #define IL_OPCODE_ARGS_NONE 1 #define IL_OPCODE_ARGS_INT8 2 #define IL_OPCODE_ARGS_UINT8 3 #define IL_OPCODE_ARGS_INT16 4 #define IL_OPCODE_ARGS_UINT16 5 #define IL_OPCODE_ARGS_INT32 6 #define IL_OPCODE_ARGS_INT64 7 #define IL_OPCODE_ARGS_FLOAT32 8 #define IL_OPCODE_ARGS_FLOAT64 9 #define IL_OPCODE_ARGS_TOKEN 10 #define IL_OPCODE_ARGS_SHORT_VAR 11 #define IL_OPCODE_ARGS_LONG_VAR 12 #define IL_OPCODE_ARGS_SHORT_ARG 13 #define IL_OPCODE_ARGS_LONG_ARG 14 #define IL_OPCODE_ARGS_SHORT_JUMP 15 #define IL_OPCODE_ARGS_LONG_JUMP 16 #define IL_OPCODE_ARGS_CALL 17 #define IL_OPCODE_ARGS_CALLI 18 #define IL_OPCODE_ARGS_CALLVIRT 19 #define IL_OPCODE_ARGS_SWITCH 20 #define IL_OPCODE_ARGS_STRING 21 #define IL_OPCODE_ARGS_NEW 22 #define IL_OPCODE_ARGS_ANN_DATA 23 #define IL_OPCODE_ARGS_ANN_DATA_S 24 #define IL_OPCODE_ARGS_ANN_DEAD 25 #define IL_OPCODE_ARGS_ANN_REF 26 #define IL_OPCODE_ARGS_ANN_REF_S 27 #define IL_OPCODE_ARGS_ANN_PHI 28 #define IL_OPCODE_ARGS_ANN_LIVE 29 #define IL_OPCODE_ARGS_ANN_ARG 30 #define IL_OPCODE_ARGS_PREFIX 31 // meta #define IL_META_TOKEN_MASK 0xff000000 #define IL_META_TOKEN_MODULE 0x00000000 #define IL_META_TOKEN_TYPE_REF 0x01000000 #define IL_META_TOKEN_TYPE_DEF 0x02000000 #define IL_META_TOKEN_FIELD_DEF 0x04000000 #define IL_META_TOKEN_METHOD_DEF 0x06000000 #define IL_META_TOKEN_PARAM_DEF 0x08000000 #define IL_META_TOKEN_INTERFACE_IMPL 0x09000000 #define IL_META_TOKEN_MEMBER_REF 0x0a000000 #define IL_META_TOKEN_CONSTANT 0x0b000000 #define IL_META_TOKEN_CUSTOM_ATTRIBUTE 0x0c000000 #define IL_META_TOKEN_CUSTOM_VALUE IL_META_TOKEN_CUSTOM_ATTRIBUTE #define IL_META_TOKEN_FIELD_MARSHAL 0x0d000000 #define IL_META_TOKEN_DECL_SECURITY 0x0e000000 #define IL_META_TOKEN_CLASS_LAYOUT 0x0f000000 #define IL_META_TOKEN_FIELD_LAYOUT 0x10000000 #define IL_META_TOKEN_STAND_ALONE_SIG 0x11000000 #define IL_META_TOKEN_EVENT_MAP 0x12000000 #define IL_META_TOKEN_EVENT 0x14000000 #define IL_META_TOKEN_PROPERTY_MAP 0x15000000 #define IL_META_TOKEN_PROPERTY 0x17000000 #define IL_META_TOKEN_METHOD_SEMANTICS 0x18000000 #define IL_META_TOKEN_METHOD_IMPL 0x19000000 #define IL_META_TOKEN_MODULE_REF 0x1a000000 #define IL_META_TOKEN_TYPE_SPEC 0x1b000000 #define IL_META_TOKEN_IMPL_MAP 0x1c000000 #define IL_META_TOKEN_FIELD_RVA 0x1d000000 #define IL_META_TOKEN_ASSEMBLY 0x20000000 #define IL_META_TOKEN_PROCESSOR_DEF 0x21000000 #define IL_META_TOKEN_OS_DEF 0x22000000 #define IL_META_TOKEN_ASSEMBLY_REF 0x23000000 #define IL_META_TOKEN_PROCESSOR_REF 0x24000000 #define IL_META_TOKEN_OS_REF 0x25000000 #define IL_META_TOKEN_FILE 0x26000000 #define IL_META_TOKEN_EXPORTED_TYPE 0x27000000 #define IL_META_TOKEN_MANIFEST_RESOURCE 0x28000000 #define IL_META_TOKEN_NESTED_CLASS 0x29000000 #define IL_META_TOKEN_STRING 0x70000000 #define IL_META_TOKEN_NAME 0x71000000 #define IL_META_TOKEN_BASE_TYPE 0x72000000 struct ILOpcodeTabEntry { const char *name; byte op; byte size; }; extern ILOpcodeTabEntry il_opcode_table[MAX_IL_OPCODE]; extern ILOpcodeTabEntry il_prefix_opcode_table[MAX_IL_OPCODE_PREFIX]; #endif ht-2.0.22/asm/x86opc.cc0000644000175000017500000031326412127651420011360 00000000000000/* * HT Editor * x86opc.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * Copyright (C) 2005-2011 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "x86opc.h" x86opc_insn_op x86_op_type[] = { #define _0 0 {TYPE_0, 0, 0, SIZE_0}, #define _064 _0+1 {TYPE_0, 0, INFO_DEFAULT_64, SIZE_0}, #define Ap _064+1 {TYPE_A, 0, 0, SIZE_P}, #define Cd Ap+1 {TYPE_C, 0, INFO_DEFAULT_64, SIZE_D}, #define Dd Cd+1 {TYPE_D, 0, 0, SIZE_D}, #define Eb Dd+1 {TYPE_E, 0, 0, SIZE_B}, #define Ew Eb+1 {TYPE_E, 0, 0, SIZE_W}, #define Ed Ew+1 {TYPE_E, 0, 0, SIZE_D}, #define Eq Ed+1 {TYPE_E, 0, 0, SIZE_Q}, #define Er Eq+1 {TYPE_E, 0, 0, SIZE_R}, #define Ev Er+1 {TYPE_E, 0, 0, SIZE_V}, #define Ev64 Ev+1 {TYPE_E, 0, INFO_DEFAULT_64, SIZE_V}, #define Gb Ev64+1 {TYPE_G, 0, 0, SIZE_B}, #define Gw Gb+1 {TYPE_G, 0, 0, SIZE_W}, #define Gv Gw+1 {TYPE_G, 0, 0, SIZE_V}, #define Gv64 Gv+1 {TYPE_G, 0, INFO_DEFAULT_64, SIZE_V}, #define Gd Gv64+1 {TYPE_G, 0, 0, SIZE_D}, #define Gr Gd+1 {TYPE_G, 0, 0, SIZE_R}, #define Gq Gr+1 {TYPE_G, 0, 0, SIZE_Q}, #define Ib Gq+1 {TYPE_I, 0, 0, SIZE_B}, #define Iw Ib+1 {TYPE_I, 0, 0, SIZE_W}, #define Id Iw+1 {TYPE_I, 0, 0, SIZE_D}, #define Iv Id+1 {TYPE_I, 0, 0, SIZE_VV}, #define Iv64 Iv+1 {TYPE_I, 0, INFO_DEFAULT_64, SIZE_VV}, #define Ivq Iv64+1 {TYPE_I, 0, 0, SIZE_V}, #define Ibv Ivq+1 {TYPE_I, 0, 0, SIZE_BV}, #define sIbv Ibv+1 {TYPE_Is,0, 0, SIZE_BV}, #define sIbv64 sIbv+1 {TYPE_Is,0, INFO_DEFAULT_64, SIZE_BV}, #define I4 sIbv64+1 {TYPE_I4, 0, 0, SIZE_B}, #define Jb I4+1 {TYPE_J, 0, 0, SIZE_B}, #define Jv Jb+1 {TYPE_J, 0, 0, SIZE_VV}, #define M Jv+1 {TYPE_M, 0, 0, SIZE_0}, #define Mw M+1 {TYPE_M, 0, 0, SIZE_W}, #define Md Mw+1 {TYPE_M, 0, 0, SIZE_D}, #define Mp Md+1 {TYPE_M, 0, 0, SIZE_P}, #define Mq Mp+1 {TYPE_M, 0, 0, SIZE_Q}, #define Mv Mq+1 {TYPE_M, 0, 0, SIZE_V}, #define Mr Mv+1 {TYPE_M, 0, 0, SIZE_R}, #define Mo Mr+1 {TYPE_M, 0, 0, SIZE_O}, #define Ms Mo+1 {TYPE_M, 0, 0, SIZE_S}, #define Ml Ms+1 {TYPE_M, 0, 0, SIZE_L}, #define Mt Ml+1 {TYPE_M, 0, 0, SIZE_T}, #define Ma Mt+1 {TYPE_M, 0, 0, SIZE_A}, #define Mu Ma+1 {TYPE_M, 0, 0, SIZE_U}, #define My Mu+1 {TYPE_M, 0, 0, SIZE_Y}, #define MRbr My+1 {TYPE_MR, SIZE_R, 0, SIZE_B}, #define MRwr MRbr+1 {TYPE_MR, SIZE_R, 0, SIZE_W}, #define MRwv MRwr+1 {TYPE_MR, SIZE_V, 0, SIZE_W}, #define MRdr MRwv+1 {TYPE_MR, SIZE_R, 0, SIZE_D}, #define MRbd MRdr+1 {TYPE_MR, SIZE_D, 0, SIZE_B}, #define Ob MRbd+1 {TYPE_O, 0, 0, SIZE_B}, #define Ov Ob+1 {TYPE_O, 0, 0, SIZE_V}, #define Pd Ov+1 {TYPE_P, 0, 0, SIZE_D}, #define Pq Pd+1 {TYPE_P, 0, 0, SIZE_Q}, #define Pu Pq+1 {TYPE_P, 0, 0, SIZE_U}, #define PRq Pu+1 {TYPE_PR, 0, 0, SIZE_Q}, #define PRu PRq+1 {TYPE_PR, 0, 0, SIZE_U}, #define Qd PRu+1 {TYPE_Q, 0, 0, SIZE_D}, #define Qq Qd+1 {TYPE_Q, 0, 0, SIZE_Q}, #define Qu Qq+1 {TYPE_Q, 0, 0, SIZE_U}, #define Qz Qu+1 {TYPE_Q, 0, 0, SIZE_Z}, #define Rw Qz+1 {TYPE_R, 0, 0, SIZE_W}, #define Rd Rw+1 {TYPE_R, 0, 0, SIZE_D}, #define Rq Rd+1 {TYPE_R, 0, 0, SIZE_Q}, #define Rr Rq+1 {TYPE_R, 0, 0, SIZE_R}, #define Rr64 Rr+1 {TYPE_R, 0, INFO_DEFAULT_64, SIZE_R}, #define Rv Rr64+1 {TYPE_R, 0, 0, SIZE_V}, #define RVw Rv+1 {TYPE_RV, 0, 0, SIZE_W}, #define RVd RVw+1 {TYPE_RV, 0, 0, SIZE_D}, #define RVq RVd+1 {TYPE_RV, 0, 0, SIZE_Q}, #define Sw RVq+1 {TYPE_S, 0, 0, SIZE_W}, #define Vd Sw+1 {TYPE_V, 0, 0, SIZE_D}, #define Vq Vd+1 {TYPE_V, 0, 0, SIZE_Q}, #define Vo Vq+1 {TYPE_V, 0, 0, SIZE_O}, #define Vu Vo+1 {TYPE_V, 0, 0, SIZE_U}, #define Vz Vu+1 {TYPE_V, 0, 0, SIZE_Z}, #define VRq Vz+1 {TYPE_VR, 0, 0, SIZE_Q}, #define VRo VRq+1 {TYPE_VR, 0, 0, SIZE_O}, #define VVo VRo+1 {TYPE_VV, 0, 0, SIZE_O}, #define VIo VVo+1 {TYPE_VI, 0, 0, SIZE_O}, #define Wb VIo+1 {TYPE_W, 0, 0, SIZE_W}, #define Ww Wb+1 {TYPE_W, 0, 0, SIZE_W}, #define Wd Ww+1 {TYPE_W, 0, 0, SIZE_D}, #define Wq Wd+1 {TYPE_W, 0, 0, SIZE_Q}, #define Wo Wq+1 {TYPE_W, 0, 0, SIZE_O}, #define Wu Wo+1 {TYPE_W, 0, 0, SIZE_U}, #define Wz Wu+1 {TYPE_W, 0, 0, SIZE_Z}, #define Yy Wz+1 {TYPE_Y, 0, 0, SIZE_Y}, #define YVy Yy+1 {TYPE_YV, 0, 0, SIZE_Y}, #define YIy YVy+1 {TYPE_YI, 0, 0, SIZE_Y}, #define YRy YIy+1 {TYPE_YR, 0, 0, SIZE_Y}, #define Xy YRy+1 {TYPE_X, 0, 0, SIZE_Y}, #define Xd Xy+1 {TYPE_X, 0, 0, SIZE_D}, #define Xq Xd+1 {TYPE_X, 0, 0, SIZE_Q}, #define Xo Xq+1 {TYPE_X, 0, 0, SIZE_O}, #define VD Xo+1 {TYPE_VD, 0, 0, SIZE_O}, #define VS0d VD+1 {TYPE_VS, 0, 0, SIZE_D}, #define VS0q VS0d+1 {TYPE_VS, 0, 0, SIZE_Q}, #define VS0o VS0q+1 {TYPE_VS, 0, 0, SIZE_Q}, #define VS00d VS0o+1 {TYPE_VS, 0, 1, SIZE_Q}, #define VS00q VS00d+1 {TYPE_VS, 0, 1, SIZE_Q}, #define VS00o VS00q+1 {TYPE_VS, 0, 1, SIZE_O}, #define VS1d VS00o+1 {TYPE_VS, 1, 0, SIZE_D}, #define VS1q VS1d+1 {TYPE_VS, 1, 0, SIZE_Q}, #define VS1o VS1q+1 {TYPE_VS, 1, 0, SIZE_O}, #define Ft VS1o+1 {TYPE_F, 0, 0, SIZE_T}, #define __st Ft+1 {TYPE_Fx, 0, 0, SIZE_T}, #define __1 __st+1 {TYPE_Ix, 1, 0, SIZE_B}, #define __3 __1+1 {TYPE_Ix, 3, 0, SIZE_B}, #define X__al __3+1 {TYPE_RXx, 0, 0, SIZE_B}, #define X__cl X__al+1 {TYPE_RXx, 1, 0, SIZE_B}, #define __al X__cl+1 {TYPE_Rx, 0, 0, SIZE_B}, #define __cl __al+1 {TYPE_Rx, 1, 0, SIZE_B}, #define __dl __cl+1 {TYPE_Rx, 2, 0, SIZE_B}, #define __bl __dl+1 {TYPE_Rx, 3, 0, SIZE_B}, #define __ah __bl+1 {TYPE_Rx, 4, 0, SIZE_B}, #define __ch __ah+1 {TYPE_Rx, 5, 0, SIZE_B}, #define __dh __ch+1 {TYPE_Rx, 6, 0, SIZE_B}, #define __bh __dh+1 {TYPE_Rx, 7, 0, SIZE_B}, #define X__ax __bh+1 {TYPE_RXx, 0, 0, SIZE_V}, #define __ax X__ax+1 {TYPE_Rx, 0, 0, SIZE_V}, #define __cx __ax+1 {TYPE_Rx, 1, 0, SIZE_V}, #define __dx __cx+1 {TYPE_Rx, 2, 0, SIZE_V}, #define __bx __dx+1 {TYPE_Rx, 3, 0, SIZE_V}, #define __sp __bx+1 {TYPE_Rx, 4, 0, SIZE_V}, #define __bp __sp+1 {TYPE_Rx, 5, 0, SIZE_V}, #define __si __bp+1 {TYPE_Rx, 6, 0, SIZE_V}, #define __di __si+1 {TYPE_Rx, 7, 0, SIZE_V}, #define __ax64 __di+1 {TYPE_Rx, 0, INFO_DEFAULT_64, SIZE_V}, #define __cx64 __ax64+1 {TYPE_Rx, 1, INFO_DEFAULT_64, SIZE_V}, #define __dx64 __cx64+1 {TYPE_Rx, 2, INFO_DEFAULT_64, SIZE_V}, #define __bx64 __dx64+1 {TYPE_Rx, 3, INFO_DEFAULT_64, SIZE_V}, #define __sp64 __bx64+1 {TYPE_Rx, 4, INFO_DEFAULT_64, SIZE_V}, #define __bp64 __sp64+1 {TYPE_Rx, 5, INFO_DEFAULT_64, SIZE_V}, #define __si64 __bp64+1 {TYPE_Rx, 6, INFO_DEFAULT_64, SIZE_V}, #define __di64 __si64+1 {TYPE_Rx, 7, INFO_DEFAULT_64, SIZE_V}, #define X__axw __di64+1 {TYPE_RXx, 0, 0, SIZE_W}, #define X__dxw X__axw+1 {TYPE_RXx, 2, 0, SIZE_W}, #define __axdq X__dxw+1 {TYPE_Rx, 0, 0, SIZE_R}, #define __cxdq __axdq+1 {TYPE_Rx, 1, 0, SIZE_R}, #define __dxdq __cxdq+1 {TYPE_Rx, 2, 0, SIZE_R}, #define __bxdq __dxdq+1 {TYPE_Rx, 3, 0, SIZE_R}, #define __spdq __bxdq+1 {TYPE_Rx, 4, 0, SIZE_R}, #define __bpdq __spdq+1 {TYPE_Rx, 5, 0, SIZE_R}, #define __sidq __bpdq+1 {TYPE_Rx, 6, 0, SIZE_R}, #define __didq __sidq+1 {TYPE_Rx, 7, 0, SIZE_R}, #define __es __didq+1 {TYPE_Sx, 0, 0, SIZE_W}, #define __cs __es+1 {TYPE_Sx, 1, 0, SIZE_W}, #define __ss __cs+1 {TYPE_Sx, 2, 0, SIZE_W}, #define __ds __ss+1 {TYPE_Sx, 3, 0, SIZE_W}, #define __fs __ds+1 {TYPE_Sx, 4, 0, SIZE_W}, #define __gs __fs+1 {TYPE_Sx, 5, 0, SIZE_W}, #define __st0 __gs+1 {TYPE_F, 0, 0, SIZE_T}, #define __st1 __st0+1 {TYPE_F, 1, 0, SIZE_T}, #define __st2 __st1+1 {TYPE_F, 2, 0, SIZE_T}, #define __st3 __st2+1 {TYPE_F, 3, 0, SIZE_T}, #define __st4 __st3+1 {TYPE_F, 4, 0, SIZE_T}, #define __st5 __st4+1 {TYPE_F, 5, 0, SIZE_T}, #define __st6 __st5+1 {TYPE_F, 6, 0, SIZE_T}, #define __st7 __st6+1 {TYPE_F, 7, 0, SIZE_T}, #define XMM0 __st7+1 {TYPE_Vx, 0, 0, SIZE_O}, }; const char *x86_regs[4][8] = { {"al", "cl", "dl", "bl", "ah", "ch", "dh", "bh"}, {"ax", "cx", "dx", "bx", "sp", "bp", "si", "di"}, {"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"}, {"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi"}, }; const char *x86_64regs[4][16] = { {"al", "cl", "dl", "bl", "spl", "bpl", "sil", "dil", "r8b", "r9b", "r10b", "r11b", "r12b", "r13b", "r14b", "r15b"}, {"ax", "cx", "dx", "bx", "sp", "bp", "si", "di", "r8w", "r9w", "r10w", "r11w", "r12w", "r13w", "r14w", "r15w"}, {"eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi", "r8d", "r9d", "r10d", "r11d", "r12d", "r13d", "r14d", "r15d"}, {"rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"}, }; const char *x86_ipregs[4] = { "", "ip", "eip", "rip", }; const char *x86_segs[8] = { "es", "cs", "ss", "ds", "fs", "gs", 0, 0 }; #define GROUP_OPC_0F38 0 #define GROUP_OPC_660F38 1 #define GROUP_OPC_F20F38 2 #define GROUP_OPC_0F3A 3 #define GROUP_OPC_660F3A 4 #define GROUP_OPC_0F7A 5 #define GROUP_OPC_0F7B 6 #define GROUP_OPC_0F24 7 #define GROUP_OPC_0F25 8 #define GROUP_80 0 #define GROUP_81 1 #define GROUP_83 2 #define GROUP_8F 3 #define GROUP_C0 4 #define GROUP_C1 5 #define GROUP_C6 6 #define GROUP_C7 7 #define GROUP_D0 8 #define GROUP_D1 9 #define GROUP_D2 10 #define GROUP_D3 11 #define GROUP_F6 12 #define GROUP_F7 13 #define GROUP_FE 14 #define GROUP_FF 15 #define GROUP_EXT_00 16 #define GROUP_EXT_01 17 #define GROUP_EXT_18 18 #define GROUP_EXT_71 19 #define GROUP_EXT_72 20 #define GROUP_EXT_73 21 #define GROUP_EXT_AE 22 #define GROUP_EXT_F3_AE 23 #define GROUP_EXT_BA 24 #define GROUP_EXT_C7 25 #define GROUP_EXT_66_C7 26 #define GROUP_EXT_F3_C7 27 #define GROUP_SPECIAL_0F01_0 0 #define GROUP_SPECIAL_0F01_1 1 #define GROUP_SPECIAL_0F01_2 2 #define GROUP_SPECIAL_0F01_3 3 #define GROUP_SPECIAL_0F01_7 4 #define GROUP_SPECIAL_0FAE_0 5 #define GROUP_SPECIAL_0FAE_1 6 #define GROUP_SPECIAL_0FAE_2 7 #define GROUP_SPECIAL_0FAE_3 8 #define GROUP_SPECIAL_0FAE_4 9 #define GROUP_SPECIAL_0FAE_5 10 #define GROUP_SPECIAL_0FAE_6 11 #define GROUP_SPECIAL_0FAE_7 12 #define GROUP_SPECIAL_0FC7_6 13 #define GROUP_SPECIAL_0FC7_7 14 #define GROUP_0FAE 0 #define GROUP_660F71 1 #define GROUP_660F72 2 #define GROUP_660F73 3 #define GROUP_0F25_12 4 #define GROUP_0F25_12_L 5 #define GROUP_0F25_12_W 6 #define GROUP_0FA_12 7 #define GROUP_0FA_12_L 8 #define GROUP_0FA_12_W 9 #define GROUP_0F38_F3 10 #define GROUP_0F38_F3_W 11 /* Opcode name modifiers ~ ambigous size (need explicit "size ptr") first char after ~: | alternative mnemonics with same semantic (|je|jz) ? different name depending on opsize (?16bit|32bit|64bit) * different name depending on addrsize (*16bit|32bit|64bit) & same as '?' for disassembler and '|' for assembler */ x86opc_insn x86_les = {"les", {Gv, Mp}}; x86opc_insn x86_lds = {"lds", {Gv, Mp}}; x86opc_insn x86_pop_group = {0, {SPECIAL_TYPE_GROUP, GROUP_8F}}; x86opc_insn x86_32_insns[256] = { /* 00 */ {"add", {Eb, Gb}}, {"add", {Ev, Gv}}, {"add", {Gb, Eb}}, {"add", {Gv, Ev}}, {"add", {X__al, Ib}}, {"add", {X__ax, Iv}}, {"push", {__es}}, {"pop", {__es}}, /* 08 */ {"or", {Eb, Gb}}, {"or", {Ev, Gv}}, {"or", {Gb, Eb}}, {"or", {Gv, Ev}}, {"or", {X__al, Ib}}, {"or", {X__ax, Iv}}, {"push", {__cs}}, {0, {SPECIAL_TYPE_PREFIX}}, /* 10 */ {"adc", {Eb, Gb}}, {"adc", {Ev, Gv}}, {"adc", {Gb, Eb}}, {"adc", {Gv, Ev}}, {"adc", {X__al, Ib}}, {"adc", {X__ax, Iv}}, {"push", {__ss}}, {"pop", {__ss}}, /* 18 */ {"sbb", {Eb, Gb}}, {"sbb", {Ev, Gv}}, {"sbb", {Gb, Eb}}, {"sbb", {Gv, Ev}}, {"sbb", {X__al, Ib}}, {"sbb", {X__ax, Iv}}, {"push", {__ds}}, {"pop", {__ds}}, /* 20 */ {"and", {Eb, Gb}}, {"and", {Ev, Gv}}, {"and", {Gb, Eb}}, {"and", {Gv, Ev}}, {"and", {X__al, Ib}}, {"and", {X__ax, Iv}}, {0, {SPECIAL_TYPE_PREFIX}}, /* es-prefix */ {"daa"}, /* 28 */ {"sub", {Eb, Gb}}, {"sub", {Ev, Gv}}, {"sub", {Gb, Eb}}, {"sub", {Gv, Ev}}, {"sub", {X__al, Ib}}, {"sub", {X__ax, Iv}}, {0, {SPECIAL_TYPE_PREFIX}}, /* cs-prefix */ {"das"}, /* 30 */ {"xor", {Eb, Gb}}, {"xor", {Ev, Gv}}, {"xor", {Gb, Eb}}, {"xor", {Gv, Ev}}, {"xor", {X__al, Ib}}, {"xor", {X__ax, Iv}}, {0, {SPECIAL_TYPE_PREFIX}}, /* ss-prefix */ {"aaa"}, /* 38 */ {"cmp", {Eb, Gb}}, {"cmp", {Ev, Gv}}, {"cmp", {Gb, Eb}}, {"cmp", {Gv, Ev}}, {"cmp", {X__al, Ib}}, {"cmp", {X__ax, Iv}}, {0, {SPECIAL_TYPE_PREFIX}}, /* ds-prefix */ {"aas"}, /* 40 */ {"inc", {__ax}}, {"inc", {__cx}}, {"inc", {__dx}}, {"inc", {__bx}}, {"inc", {__sp}}, {"inc", {__bp}}, {"inc", {__si}}, {"inc", {__di}}, /* 48 */ {"dec", {__ax}}, {"dec", {__cx}}, {"dec", {__dx}}, {"dec", {__bx}}, {"dec", {__sp}}, {"dec", {__bp}}, {"dec", {__si}}, {"dec", {__di}}, /* 50 */ {"push", {__ax64}}, {"push", {__cx64}}, {"push", {__dx64}}, {"push", {__bx64}}, {"push", {__sp64}}, {"push", {__bp64}}, {"push", {__si64}}, {"push", {__di64}}, /* 58 */ {"pop", {__ax64}}, {"pop", {__cx64}}, {"pop", {__dx64}}, {"pop", {__bx64}}, {"pop", {__sp64}}, {"pop", {__bp64}}, {"pop", {__si64}}, {"pop", {__di64}}, /* 60 */ {"?pusha|pushad| x"}, {"?popa|popad| x"}, {"bound", {Gv, Mq}}, {"arpl", {Ew, Gw}}, //{"movsxd", {Gv, Ed}}, {0, {SPECIAL_TYPE_PREFIX}}, /* fs-prefix */ {0, {SPECIAL_TYPE_PREFIX}}, /* gs-prefix */ {0, {SPECIAL_TYPE_PREFIX}}, /* op-size prefix */ {0, {SPECIAL_TYPE_PREFIX}}, /* addr-size prefix */ /* 68 */ {"push", {Iv64}}, {"imul", {Gv, Ev, Iv}}, {"push", {sIbv64}}, {"imul", {Gv, Ev, sIbv}}, {"insb"}, {"?insw|insd|insd"}, {"outsb"}, {"?outsw|outsd|outsd"}, /* 70 */ {"jo", {Jb}}, {"jno", {Jb}}, {"|jc|jb|jnae", {Jb}}, {"|jnc|jnb|jae", {Jb}}, {"|jz|je", {Jb}}, {"|jnz|jne", {Jb}}, {"|jna|jbe", {Jb}}, {"|ja|jnbe", {Jb}}, /* 78 */ {"js", {Jb}}, {"jns", {Jb}}, {"|jp|jpe", {Jb}}, {"|jnp|jpo", {Jb}}, {"|jl|jnge", {Jb}}, {"|jnl|jge", {Jb}}, {"|jng|jle", {Jb}}, {"|jg|jnle", {Jb}}, /* 80 */ {0, {SPECIAL_TYPE_GROUP, GROUP_80}}, {0, {SPECIAL_TYPE_GROUP, GROUP_81}}, {0}, {0, {SPECIAL_TYPE_GROUP, GROUP_83}}, {"test", {Eb, Gb}}, {"test", {Ev, Gv}}, {"xchg", {Eb, Gb}}, {"xchg", {Ev, Gv}}, /* 88 */ {"mov", {Eb, Gb}}, {"mov", {Ev, Gv}}, {"mov", {Gb, Eb}}, {"mov", {Gv, Ev}}, {"mov", {MRwv, Sw}}, {"lea", {Gv, M}}, {"mov", {Sw, MRwv}}, {0, {SPECIAL_TYPE_PREFIX}}, // XOP prefix {0, {SPECIAL_TYPE_GROUP, GROUP_8F}}, /* 90 */ {"nop"}, /* same as xchg (e)ax, (e)ax */ {"xchg", {X__ax, __cx}}, {"xchg", {X__ax, __dx}}, {"xchg", {X__ax, __bx}}, {"xchg", {X__ax, __sp}}, {"xchg", {X__ax, __bp}}, {"xchg", {X__ax, __si}}, {"xchg", {X__ax, __di}}, /* 98 */ {"?cbw|cwde|cdqe"}, {"?cwd|cdq|cqo"}, {"~call", {Ap}}, {"fwait"}, {"?pushf|pushfd|pushfq", {_064}}, {"?popf|popfd|popfq", {_064}}, {"sahf"}, {"lahf"}, /* A0 */ {"mov", {X__al, Ob}}, {"mov", {X__ax, Ov}}, {"mov", {Ob, X__al}}, {"mov", {Ov, X__ax}}, {"movsb"}, {"?movsw|movsd|movsq"}, {"cmpsb"}, {"?cmpsw|cmpsd|cmpsq"}, /* A8 */ {"test", {X__al, Ib}}, {"test", {X__ax, Iv}}, {"stosb"}, {"?stosw|stosd|stosq"}, {"lodsb"}, {"?lodsw|lodsd|lodsq"}, {"scasb"}, {"?scasw|scasd|scasq"}, /* B0 */ {"mov", {__al, Ib}}, {"mov", {__cl, Ib}}, {"mov", {__dl, Ib}}, {"mov", {__bl, Ib}}, {"mov", {__ah, Ib}}, {"mov", {__ch, Ib}}, {"mov", {__dh, Ib}}, {"mov", {__bh, Ib}}, /* B8 */ {"mov", {__ax, Ivq}}, {"mov", {__cx, Ivq}}, {"mov", {__dx, Ivq}}, {"mov", {__bx, Ivq}}, {"mov", {__sp, Ivq}}, {"mov", {__bp, Ivq}}, {"mov", {__si, Ivq}}, {"mov", {__di, Ivq}}, /* C0 */ {0, {SPECIAL_TYPE_GROUP, GROUP_C0}}, {0, {SPECIAL_TYPE_GROUP, GROUP_C1}}, {"ret", {Iw}}, {"ret"}, {0, {SPECIAL_TYPE_PREFIX}}, // VEX prefix {"les", {Gv, Mp}} {0, {SPECIAL_TYPE_PREFIX}}, // VEX prefix {"lds", {Gv, Mp}} {0, {SPECIAL_TYPE_GROUP, GROUP_C6}}, {0, {SPECIAL_TYPE_GROUP, GROUP_C7}}, /* C8 */ {"enter", {Iw, Ib}}, {"leave"}, {"retf", {Iw}}, {"retf"}, {"int", {__3}}, {"int", {Ib}}, {"into"}, {"?iret|iretd|iretq"}, /* D0 */ {0, {SPECIAL_TYPE_GROUP, GROUP_D0}}, {0, {SPECIAL_TYPE_GROUP, GROUP_D1}}, {0, {SPECIAL_TYPE_GROUP, GROUP_D2}}, {0, {SPECIAL_TYPE_GROUP, GROUP_D3}}, {"aam", {Ib}}, {"aad", {Ib}}, {"setalc"}, {"xlat"}, /* D8 */ {0, {SPECIAL_TYPE_FGROUP, 0}}, {0, {SPECIAL_TYPE_FGROUP, 1}}, {0, {SPECIAL_TYPE_FGROUP, 2}}, {0, {SPECIAL_TYPE_FGROUP, 3}}, {0, {SPECIAL_TYPE_FGROUP, 4}}, {0, {SPECIAL_TYPE_FGROUP, 5}}, {0, {SPECIAL_TYPE_FGROUP, 6}}, {0, {SPECIAL_TYPE_FGROUP, 7}}, /* E0 */ {"|loopnz|loopne", {Jb}}, {"|loopz|loope", {Jb}}, {"loop", {Jb}}, {"*jcxz|jecxz|jrcxz", {Jb}}, {"in", {X__al, Ib}}, {"in", {X__ax, Ib}}, {"out", {Ib, X__al}}, {"out", {Ib, X__ax}}, /* E8 */ {"call", {Jv}}, {"jmp", {Jv}}, {"~jmp", {Ap}}, {"jmp", {Jb}}, {"in", {X__al, X__dxw}}, {"in", {X__ax, X__dxw}}, {"out", {X__dxw, X__al}}, {"out", {X__dxw, X__ax}}, /* F0 */ {0, {SPECIAL_TYPE_PREFIX}}, /* lock-prefix */ {"smi"}, {0, {SPECIAL_TYPE_PREFIX}}, /* repnz-prefix */ {0, {SPECIAL_TYPE_PREFIX}}, /* rep-prefix */ {"hlt"}, {"cmc"}, {0, {SPECIAL_TYPE_GROUP, GROUP_F6}}, {0, {SPECIAL_TYPE_GROUP, GROUP_F7}}, /* F8 */ {"clc"}, {"stc"}, {"cli"}, {"sti"}, {"cld"}, {"std"}, {0, {SPECIAL_TYPE_GROUP, GROUP_FE}}, {0, {SPECIAL_TYPE_GROUP, GROUP_FF}}, }; x86_64_insn_patch x86_64_insn_patches[] = { {0x06, {0}}, // push es {0x07, {0}}, // pop es {0x0e, {0}}, // push cs {0x16, {0}}, // push ss {0x17, {0}}, // pop ss {0x1e, {0}}, // push ds {0x1f, {0}}, // pop ds {0x27, {0}}, // daa {0x2f, {0}}, // das {0x37, {0}}, // aaa {0x3f, {0}}, // aas {0x40, {0}}, // REX prefixes {0x41, {0}}, {0x42, {0}}, {0x43, {0}}, {0x44, {0}}, {0x45, {0}}, {0x46, {0}}, {0x47, {0}}, {0x48, {0}}, {0x49, {0}}, {0x4a, {0}}, {0x4b, {0}}, {0x4c, {0}}, {0x4d, {0}}, {0x4e, {0}}, {0x4f, {0}}, // .. {0x60, {0}}, // pusha {0x61, {0}}, // popa {0x62, {0}}, // bound {0x63, {"movsxd", {Gv, Ed}}}, {0x9a, {0}}, // call Ap {0xce, {0}}, // into {0xd4, {0}}, // aam {0xd5, {0}}, // aad {0xd6, {0}}, // setalc {0xea, {0}}, // jmp Ap {-1, {0}}, }; x86opc_insn x86_insns_ext[256] = { /* 00 */ {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_00}}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_01}}, {"lar", {Gv, Ew}}, {"lsl", {Gv, Ew}}, {0}, {"syscall"}, {"clts"}, {"sysret"}, /* 08 */ {"invd"}, {"wbinvd"}, {0}, {"ud1"}, {0}, {"prefetch", {Eb}}, {"femms"}, {0, {SPECIAL_TYPE_PREFIX}}, /* 10 */ {"movups", {Vo, Wo}}, {"movups", {Wo, Vo}}, {"movlps", {Vq, Wq}}, {"movlps", {Mq, Vq}}, {"unpcklps", {Vo, Wq}}, {"unpckhps", {Vo, Wq}}, {"movhps", {Vq, Wq}}, {"movhps", {Mq, Vq}}, /* 18 */ {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_18}}, {"~nop", {Ev}}, {"~nop", {Ev}}, {"~nop", {Ev}}, {"~nop", {Ev}}, {"~nop", {Ev}}, {"~nop", {Ev}}, {"~nop", {Ev}}, /* 20 */ {"mov", {Rr64, Cd}}, {"mov", {Rr, Dd}}, {"mov", {Cd, Rr}}, {"mov", {Dd, Rr}}, {0, {SPECIAL_TYPE_OPC_GROUP, GROUP_OPC_0F24}}, {0, {SPECIAL_TYPE_OPC_GROUP, GROUP_OPC_0F25}}, {0}, {0}, /* 28 */ {"movaps", {Vo, Wo}}, {"movaps", {Wo, Vo}}, {"cvtpi2ps", {Vu, Qq}}, {"movntps", {Mo, Vo}}, {"cvttps2pi", {Pq, Wq}}, {"cvtps2pi", {Pq, Wq}}, {"ucomiss", {Vz, Wz}}, {"comiss", {Vz, Wz}}, /* 30 */ {"wrmsr"}, {"rdtsc"}, {"rdmsr"}, {"rdpmc"}, {"sysenter"}, {"sysexit"}, {0}, {"getsec"}, /* 38 */ {0, {SPECIAL_TYPE_OPC_GROUP, GROUP_OPC_0F38}}, {0}, {0, {SPECIAL_TYPE_OPC_GROUP, GROUP_OPC_0F3A}}, {0}, {0}, {0}, {0}, {0}, /* 40 */ {"cmovo", {Gv, Ev}}, {"cmovno", {Gv, Ev}}, {"|cmovc|cmovb", {Gv, Ev}}, {"|cmovnc|cmovnb", {Gv, Ev}}, {"|cmovz|cmove", {Gv, Ev}}, {"|cmovnz|cmovne", {Gv, Ev}}, {"|cmova|cmovnbe", {Gv, Ev}}, {"|cmovna|cmovbe", {Gv, Ev}}, /* 48 */ {"cmovs", {Gv, Ev}}, {"cmovns", {Gv, Ev}}, {"|cmovp|cmovpe", {Gv, Ev}}, {"|cmovnp|cmovpo", {Gv, Ev}}, {"|cmovl|cmovnge", {Gv, Ev}}, {"|cmovnl|cmovge", {Gv, Ev}}, {"|cmovng|cmovle", {Gv, Ev}}, {"|cmovg|cmovnle", {Gv, Ev}}, /* 50 */ {"movmskps", {Gd, VRo}}, {"sqrtps", {Vo, Wo}}, {"rsqrtps", {Vo, Wo}}, {"rcpps", {Vo, Wo}}, {"andps", {Vo, Wo}}, {"andnps", {Vo, Wo}}, {"orps", {Vo, Wo}}, {"xorps", {Vo, Wo}}, /* 58 */ {"addps", {Vo, Wo}}, {"mulps", {Vo, Wo}}, {"cvtps2pd", {Vo, Wq}}, {"cvtdq2ps", {Vo, Wo}}, {"subps", {Vo, Wo}}, {"minps", {Vo, Wo}}, {"divps", {Vo, Wo}}, {"maxps", {Vo, Wo}}, /* 60 */ {"punpcklbw", {Pu, Qz}}, {"punpcklwd", {Pu, Qz}}, {"punpckldq", {Pu, Qz}}, {"packsswb", {Pu, Qu}}, {"pcmpgtb", {Pu, Qu}}, {"pcmpgtw", {Pu, Qu}}, {"pcmpgtd", {Pu, Qu}}, {"packuswb", {Pu, Qu}}, /* 68 */ {"punpckhbw", {Pu, Qu}}, {"punpckhwd", {Pu, Qu}}, {"punpckhdq", {Pu, Qu}}, {"packssdw", {Pu, Qu}}, {0}, {0}, {"~movd", {Pu, Er}}, {"movq", {Pu, Qu}}, /* 70 */ {"pshufw", {Pu, Qu, Ib}}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_71}}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_72}}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_73}}, {"pcmpeqb", {Pu, Qu}}, {"pcmpeqw", {Pu, Qu}}, {"pcmpewd", {Pu, Qu}}, {"emms"}, /* 78 */ {"vmread", {Ev64, Gv64}}, {"vmwrite", {Gv64, Ev64}}, {0, {SPECIAL_TYPE_OPC_GROUP, GROUP_OPC_0F7A}}, {0, {SPECIAL_TYPE_OPC_GROUP, GROUP_OPC_0F7B}}, {0}, {0}, {"~movd", {Er, Pq}}, {"movq", {Qq, Pq}}, /* 80 */ {"jo", {Jv}}, {"jno", {Jv}}, {"|jc|jb|jnae", {Jv}}, {"|jnc|jnb|jae", {Jv}}, {"|jz|je", {Jv}}, {"|jnz|jne", {Jv}}, {"|jna|jbe", {Jv}}, {"|ja|jnbe", {Jv}}, /* 88 */ {"js", {Jv}}, {"jns", {Jv}}, {"|jp|jpe", {Jv}}, {"|jnp|jpo", {Jv}}, {"|jl|jnge", {Jv}}, {"|jnl|jge", {Jv}}, {"|jng|jle", {Jv}}, {"|jg|jnle", {Jv}}, /* 90 */ {"seto", {Eb}}, {"setno", {Eb}}, {"|setc|setb|setnae", {Eb}}, {"|setnc|setnb|setae", {Eb}}, {"|setz|sete", {Eb}}, {"|setnz|setne", {Eb}}, {"|setna|setbe", {Eb}}, {"|seta|setnbe", {Eb}}, /* 98 */ {"sets", {Eb}}, {"setns", {Eb}}, {"|setp|setpe", {Eb}}, {"|setnp|setpo", {Eb}}, {"|setl|setnge", {Eb}}, {"|setnl|setge", {Eb}}, {"|setng|setle", {Eb}}, {"|setg|setnle", {Eb}}, /* A0 */ {"push", {__fs}}, {"pop", {__fs}}, {"cpuid"}, {"bt", {Ev, Gv}}, {"shld", {Ev, Gv, Ib}}, {"shld", {Ev, Gv, X__cl}}, {0}, {0}, /* A8 */ {"push", {__gs}}, {"pop", {__gs}}, {"rsm"}, {"bts", {Ev, Gv}}, {"shrd", {Ev, Gv, Ib}}, {"shrd", {Ev, Gv, X__cl}}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_AE}}, {"imul", {Gv, Ev}}, /* B0 */ {"cmpxchg", {Eb, Gb}}, {"cmpxchg", {Ev, Gv}}, {"lss", {Gv, Mp}}, {"btr", {Ev, Gv}}, {"lfs", {Gv, Mp}}, {"lgs", {Gv, Mp}}, {"~movzx", {Gv, Eb}}, {"~movzx", {Gv, Ew}}, /* B8 */ {"jmpe", {Jv}}, {"ud2"}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_BA}}, {"btc", {Ev, Gv}}, {"bsf", {Gv, Ev}}, {"bsr", {Gv, Ev}}, {"~movsx", {Gv, Eb}}, {"~movsx", {Gv, Ew}}, /* C0 */ {"xadd", {Eb, Gb}}, {"xadd", {Ev, Gv}}, {"cmpCCps", {Vo, Wo, Ib}}, {"movnti", {Mr, Gr}}, {"pinsrw", {Pq, MRwr, Ib}}, {"pextrw", {Gr, PRq, Ib}}, {"shufps", {Vo, Wo, Ib}}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_C7}}, /* C8 */ {"bswap", {__axdq}}, {"bswap", {__cxdq}}, {"bswap", {__dxdq}}, {"bswap", {__bxdq}}, {"bswap", {__spdq}}, {"bswap", {__bpdq}}, {"bswap", {__sidq}}, {"bswap", {__didq}}, /* D0 */ {0}, {"psrlw", {Pu, Qu}}, {"psrld", {Pu, Qu}}, {"psrlq", {Pu, Qu}}, {"paddq", {Pu, Qu}}, {"pmullw", {Pu, Qu}}, {0}, {"pmovmskb", {Gd, PRu}}, /* D8 */ {"psubusb", {Pu, Qu}}, {"psubusw", {Pu, Qu}}, {"pminub", {Pu, Qu}}, {"pand", {Pu, Qu}}, {"paddusb", {Pu, Qu}}, {"paddusw", {Pu, Qu}}, {"pmaxub", {Pu, Qu}}, {"pandn", {Pu, Qu}}, /* E0 */ {"pavgb", {Pu, Qu}}, {"psraw", {Pu, Qu}}, {"psrad", {Pu, Qu}}, {"pavgw", {Pu, Qu}}, {"pmulhuw", {Pu, Qu}}, {"pmulhw", {Pu, Qu}}, {0}, {"movntq", {Mq, Pq}}, /* E8 */ {"psubsb", {Pu, Qu}}, {"psubsw", {Pu, Qu}}, {"pminsw", {Pu, Qu}}, {"por", {Pu, Qu}}, {"paddsb", {Pu, Qu}}, {"paddsw", {Pu, Qu}}, {"pmaxsw", {Pu, Qu}}, {"pxor", {Pu, Qu}}, /* F0 */ {0}, {"psllw", {Pu, Qu}}, {"pslld", {Pu, Qu}}, {"psllq", {Pu, Qu}}, {"pmuludq", {Pu, Qu}}, {"pmaddwd", {Pu, Qu}}, {"psadbw", {Pu, Qu}}, {"maskmovq", {Pq, PRq}}, /* F8 */ {"psubb", {Pu, Qu}}, {"psubw", {Pu, Qu}}, {"psubd", {Pu, Qu}}, {"psubq", {Pu, Qu}}, {"paddb", {Pu, Qu}}, {"paddw", {Pu, Qu}}, {"paddd", {Pu, Qu}}, {0}, }; x86opc_insn x86_insns_ext_66[256] = { /* 00 */ {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_00}}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_01}}, {"lar", {Gv, Ew}}, {"lsl", {Gv, Ew}}, {0}, {"syscall"}, {"clts"}, {"sysret"}, /* 08 */ {"invd"}, {"wbinvd"}, {0}, {"ud1"}, {0}, {"prefetch", {Eb}}, {"femms"}, {0, {SPECIAL_TYPE_PREFIX}}, /* 10 */ {"movupd", {Vo, Wo}}, {"movupd", {Wo, Vo}}, {"movlpd", {Vq, Wq}}, {"movlpd", {Mq, Vq}}, {"unpcklpd", {Vo, Wq}}, {"unpckhpd", {Vo, Wq}}, {"movhpd", {Vq, Wq}}, {"movhpd", {Mq, Vq}}, /* 18 */ {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_18}}, {"~nop", {Ev}}, {"~nop", {Ev}}, {"~nop", {Ev}}, {"~nop", {Ev}}, {"~nop", {Ev}}, {"~nop", {Ev}}, {"~nop", {Ev}}, /* 20 */ {"mov", {Rr64, Cd}}, // default 64 {"mov", {Rr, Dd}}, // default 32 {"mov", {Cd, Rr}}, // default 64 {"mov", {Dd, Rr}}, // default 32 {0}, {0}, {0}, {0}, /* 28 */ {"movapd", {Vo, Wo}}, {"movapd", {Wo, Vo}}, {"cvtpi2pd", {Vo, Qq}}, {"movntpd", {Mo, Vo}}, {"cvttpd2pi", {Pq, Wo}}, {"cvtpd2pi", {Pq, Wo}}, {"ucomisd", {Vz, Wz}}, {"comisd", {Vz, Wz}}, /* 30 */ {"wrmsr"}, {"rdtsc"}, {"rdmsr"}, {"rdpmc"}, {"sysenter"}, {"sysexit"}, {0}, {"getsec"}, /* 38 */ {0, {SPECIAL_TYPE_OPC_GROUP, GROUP_OPC_660F38}}, {0}, {0, {SPECIAL_TYPE_OPC_GROUP, GROUP_OPC_660F3A}}, {0}, {0}, {0}, {0}, {0}, /* 40 */ {"cmovo", {Gv, Ev}}, {"cmovno", {Gv, Ev}}, {"|cmovc|cmovb", {Gv, Ev}}, {"|cmovnc|cmovnb", {Gv, Ev}}, {"|cmovz|cmove", {Gv, Ev}}, {"|cmovnz|cmovne", {Gv, Ev}}, {"|cmova|cmovnbe", {Gv, Ev}}, {"|cmovna|cmovbe", {Gv, Ev}}, /* 48 */ {"cmovs", {Gv, Ev}}, {"cmovns", {Gv, Ev}}, {"|cmovp|cmovpe", {Gv, Ev}}, {"|cmovnp|cmovpo", {Gv, Ev}}, {"|cmovl|cmovnge", {Gv, Ev}}, {"|cmovnl|cmovge", {Gv, Ev}}, {"|cmovng|cmovle", {Gv, Ev}}, {"|cmovg|cmovnle", {Gv, Ev}}, /* 50 */ {"movmskpd", {Gd, VRo}}, {"sqrtpd", {Vo, Wo}}, {0}, // {"rsqrtpd", {Vo, Wo}}, {0}, // {"rcppd", {Vo, Wo}}, {"andpd", {Vo, Wo}}, {"andnpd", {Vo, Wo}}, {"orpd", {Vo, Wo}}, {"xorpd", {Vo, Wo}}, /* 58 */ {"addpd", {Vo, Wo}}, {"mulpd", {Vo, Wo}}, {"cvtpd2ps", {Vo, Wo}}, {"cvtps2dq", {Vo, Wo}}, {"subpd", {Vo, Wo}}, {"minpd", {Vo, Wo}}, {"divpd", {Vo, Wo}}, {"maxpd", {Vo, Wo}}, /* 60 */ {"punpcklbw", {Pu, Qz}}, {"punpcklwd", {Pu, Qz}}, {"punpckldq", {Pu, Qz}}, {"packsswb", {Pu, Qu}}, {"pcmpgtb", {Pu, Qu}}, {"pcmpgtw", {Pu, Qu}}, {"pcmpgtd", {Pu, Qu}}, {"packuswb", {Pu, Qu}}, /* 68 */ {"punpckhbw", {Pu, Qu}}, {"punpckhwd", {Pu, Qu}}, {"punpckhdq", {Pu, Qu}}, {"packssdw", {Pu, Qu}}, {"punpcklqdq", {Vo, Wo}}, {"punpckhqdq", {Vo, Wo}}, {"~movd", {Vo, Er}}, {"movdqa", {Pu, Qu}}, /* 70 */ {"pshufd", {Pu, Qu, Ib}}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_71}}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_72}}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_73}}, {"pcmpeqb", {Pu, Qu}}, {"pcmpeqw", {Pu, Qu}}, {"pcmpewd", {Pu, Qu}}, {0}, /* 78 */ {"extrq", {VRo, Ib, Ib}}, {"extrq", {Vo, VRo}}, {0}, {0}, {"haddpd", {Vo, Wo}}, {"hsubpd", {Vo, Wo}}, {"~movd", {Er, Vo}}, {"movdqa", {Wo, Vo}}, /* 80 */ {"jo", {Jv}}, {"jno", {Jv}}, {"|jc|jb|jnae", {Jv}}, {"|jnc|jnb|jae", {Jv}}, {"|jz|je", {Jv}}, {"|jnz|jne", {Jv}}, {"|jna|jbe", {Jv}}, {"|ja|jnbe", {Jv}}, /* 88 */ {"js", {Jv}}, {"jns", {Jv}}, {"|jp|jpe", {Jv}}, {"|jnp|jpo", {Jv}}, {"|jl|jnge", {Jv}}, {"|jnl|jge", {Jv}}, {"|jng|jle", {Jv}}, {"|jg|jnle", {Jv}}, /* 90 */ {"seto", {Eb}}, {"setno", {Eb}}, {"|setc|setb|setnae", {Eb}}, {"|setnc|setnb|setae", {Eb}}, {"|setz|sete", {Eb}}, {"|setnz|setne", {Eb}}, {"|setna|setbe", {Eb}}, {"|seta|setnbe", {Eb}}, /* 98 */ {"sets", {Eb}}, {"setns", {Eb}}, {"|setp|setpe", {Eb}}, {"|setnp|setpo", {Eb}}, {"|setl|setnge", {Eb}}, {"|setnl|setge", {Eb}}, {"|setng|setle", {Eb}}, {"|setg|setnle", {Eb}}, /* A0 */ {"push", {__fs}}, {"pop", {__fs}}, {"cpuid"}, {"bt", {Ev, Gv}}, {"shld", {Ev, Gv, Ib}}, {"shld", {Ev, Gv, X__cl}}, {0}, {0}, /* A8 */ {"push", {__gs}}, {"pop", {__gs}}, {"rsm"}, {"bts", {Ev, Gv}}, {"shrd", {Ev, Gv, Ib}}, {"shrd", {Ev, Gv, X__cl}}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_AE}}, {"imul", {Gv, Ev}}, /* B0 */ {"cmpxchg", {Eb, Gb}}, {"cmpxchg", {Ev, Gv}}, {"lss", {Gv, Mp}}, {"btr", {Ev, Gv}}, {"lfs", {Gv, Mp}}, {"lgs", {Gv, Mp}}, {"~movzx", {Gv, Eb}}, {"~movzx", {Gv, Ew}}, /* B8 */ {"jmpe", {Jv}}, {"ud2"}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_BA}}, {"btc", {Ev, Gv}}, {"bsf", {Gv, Ev}}, {"bsr", {Gv, Ev}}, {"~movsx", {Gv, Eb}}, {"~movsx", {Gv, Ew}}, /* C0 */ {"xadd", {Eb, Gb}}, {"xadd", {Ev, Gv}}, {"cmpCCpd", {Vo, Wo, Ib}}, {0}, {"pinsrw", {Vo, MRwr, Ib}}, {"pextrw", {Gr, VRo, Ib}}, {"shufpd", {Vo, Wo, Ib}}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_66_C7}}, /* C8 */ {"bswap", {__axdq}}, {"bswap", {__cxdq}}, {"bswap", {__dxdq}}, {"bswap", {__bxdq}}, {"bswap", {__spdq}}, {"bswap", {__bpdq}}, {"bswap", {__sidq}}, {"bswap", {__didq}}, /* D0 */ {"addsubpd", {Vo, Wo}}, {"psrlw", {Pu, Qu}}, {"psrld", {Pu, Qu}}, {"psrlq", {Pu, Qu}}, {"paddq", {Pu, Qu}}, {"pmullw", {Pu, Qu}}, {"movq", {Wq, Vq}}, {"pmovmskb", {Gr, PRu}}, /* D8 */ {"psubusb", {Pu, Qu}}, {"psubusw", {Pu, Qu}}, {"pminub", {Pu, Qu}}, {"pand", {Pu, Qu}}, {"paddusb", {Pu, Qu}}, {"paddusw", {Pu, Qu}}, {"pmaxub", {Pu, Qu}}, {"pandn", {Pu, Qu}}, /* E0 */ {"pavgb", {Pu, Qu}}, {"psraw", {Pu, Qu}}, {"psrad", {Pu, Qu}}, {"pavgw", {Pu, Qu}}, {"pmulhuw", {Pu, Qu}}, {"pmulhw", {Pu, Qu}}, {"cvttpd2dq", {Vo, Wo}}, {"movntdq", {Mo, Vo}}, /* E8 */ {"psubsb", {Pu, Qu}}, {"psubsw", {Pu, Qu}}, {"pminsw", {Pu, Qu}}, {"por", {Pu, Qu}}, {"paddsb", {Pu, Qu}}, {"paddsw", {Pu, Qu}}, {"pmaxsw", {Pu, Qu}}, {"pxor", {Pu, Qu}}, /* F0 */ {0}, {"psllw", {Pu, Qu}}, {"pslld", {Pu, Qu}}, {"psllq", {Pu, Qu}}, {"pmuludq", {Pu, Qu}}, {"pmaddwd", {Pu, Qu}}, {"psadbw", {Pu, Qu}}, {"maskmovdqu", {Vo, VRo}}, /* F8 */ {"psubb", {Pu, Qu}}, {"psubw", {Pu, Qu}}, {"psubd", {Pu, Qu}}, {"psubq", {Pu, Qu}}, {"paddb", {Pu, Qu}}, {"paddw", {Pu, Qu}}, {"paddd", {Pu, Qu}}, {0}, }; x86opc_insn x86_insns_ext_f2[256] = { /* 00 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 08 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 10 */ {"movsd", {Vq, Wq}}, {"movsd", {Wq, Vq}}, {"movddup", {Vo, Wq}}, {0}, {0}, {0}, {0}, {0}, /* 18 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 20 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 28 */ {0}, {0}, {"~cvtsi2sd", {Vq, Er}}, {"movntsd", {Mq, Vq}}, {"cvttsd2si", {Gr, Wq}}, {"cvtsd2si", {Gr, Wq}}, {0}, {0}, /* 30 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 38 */ {0, {SPECIAL_TYPE_OPC_GROUP, GROUP_OPC_F20F38}}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 40 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 48 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 50 */ {0}, {"sqrtsd", {Vq, Wq}}, {0}, {0}, {0}, {0}, {0}, {0}, /* 58 */ {"addsd", {Vq, Wq}}, {"mulsd", {Vq, Wq}}, {"cvtsd2ss", {Vd, Wq}}, {0}, {"subsd", {Vq, Wq}}, {"minsd", {Vq, Wq}}, {"divsd", {Vq, Wq}}, {"maxsd", {Vq, Wq}}, /* 60 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 68 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 70 */ {"pshuflw", {Vo, Wo, Ib}}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 78 */ {"insertq", {Vo, VRo, Iw}}, {"insertq", {Vo, VRo}}, {0}, {0}, {"haddps", {Vo, Wo}}, {"hsubps", {Vo, Wo}}, {0}, {0}, /* 80 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 88 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 90 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 98 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c0 */ {0}, {0}, {"cmpCCsd", {Vq, Wq, Ib}}, {0}, {0}, {0}, {0}, {0}, /* c8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d0 */ {"addsubps", {Vo, Wo}}, {0}, {0}, {0}, {0}, {0}, {"movdq2q", {Pq, VRq}}, {0}, /* d8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e0 */ {0}, {0}, {0}, {0}, {0}, {0}, {"cvtpd2dq", {Vo, Wo}}, {0}, /* e8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f0 */ {"lddqu", {Vo, Mo}}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, }; x86opc_insn x86_insns_ext_f3[256] = { /* 00 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 08 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 10 */ {"movss", {Vd, Wd}}, {"movss", {Wd, Vd}}, {"movsldup", {Vo, Wo}}, {0}, {0}, {0}, {"movshdup", {Vo, Wo}}, {0}, /* 18 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 20 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 28 */ {0}, {0}, {"~cvtsi2ss", {Vd, Er}}, {"movntss", {Md, Vd}}, {"cvttss2si", {Gr, Wd}}, {"cvtss2si", {Gr, Wd}}, {0}, {0}, /* 30 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 38 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 40 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 48 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 50 */ {0}, {"sqrtss", {Vd, Wd}}, {"rsqrtss", {Vd, Wd}}, {"rcpss", {Vd, Wd}}, {0}, {0}, {0}, {0}, /* 58 */ {"addss", {Vd, Wd}}, {"mulss", {Vd, Wd}}, {"cvtss2sd", {Vq, Wd}}, {"cvttps2dq", {Vo, Wo}}, {"subss", {Vd, Wd}}, {"minss", {Vd, Wd}}, {"divss", {Vd, Wd}}, {"maxss", {Vd, Wd}}, /* 60 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 68 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {"movdqu", {Vo, Wo}}, /* 70 */ {"pshufhw", {Vo, Wo, Ib}}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 78 */ {0}, {0}, {0}, {0}, {0}, {0}, {"movq", {Vo, Wq}}, {"movdqu", {Wo, Vo}}, /* 80 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 88 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 90 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 98 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_F3_AE}}, {0}, /* b0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b8 */ {"popcnt", {Gv, Ev}}, {0}, {0}, {0}, {"tzcnt", {Gv, Ev}}, {"lzcnt", {Gv, Ev}}, {0}, {0}, /* c0 */ {0}, {0}, {"cmpCCss", {Vd, Wd, Ib}}, {0}, {0}, {0}, {0}, {0, {SPECIAL_TYPE_GROUP, GROUP_EXT_F3_C7}}, /* c8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d0 */ {0}, {0}, {0}, {0}, {0}, {0}, {"movq2dq", {Vo, PRq}}, {0}, /* d8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e0 */ {0}, {0}, {0}, {0}, {0}, {0}, {"cvtdq2pd", {Vo, Wq}}, {0}, /* e8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, }; x86opc_insn x86_opc_group_insns[X86_OPC_GROUPS][256] = { /* 0 - GROUP_OPC_0F38 */ { /* 00 */ {"pshufb", {Pu, Qu}}, {"phaddw", {Pu, Qu}}, {"phaddd", {Pu, Qu}}, {"phaddsw", {Pu, Qu}}, {"pmaddubsw", {Pu, Qu}}, {"phsubw", {Pu, Qu}}, {"phsubd", {Pu, Qu}}, {"phsubsw", {Pu, Qu}}, /* 08 */ {"psignb", {Pu, Qu}}, {"psignw", {Pu, Qu}}, {"psignd", {Pu, Qu}}, {"pmulhrsw", {Pu, Qu}}, {0}, {0}, {0}, {0}, /* 10 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 18 */ {0}, {0}, {0}, {0}, {"pabsb", {Pu, Qu}}, {"pabsw", {Pu, Qu}}, {"pabsd", {Pu, Qu}}, {0}, /* 20 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 28 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 30 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 38 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 40 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 48 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 50 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 58 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 60 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 68 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 70 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 78 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 80 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 88 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 90 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 98 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f0 */ {"movbe", {Gv, Mv}}, {"movbe", {Mv, Gv}}, {0}, {0}, {0}, {0}, {"adox", {Gr, Er}}, {0}, /* f8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 1 - GROUP_OPC_660F38 */ { /* 00 */ {"pshufb", {Pu, Qu}}, {"phaddw", {Pu, Qu}}, {"phaddd", {Pu, Qu}}, {"phaddsw", {Pu, Qu}}, {"pmaddubsw", {Pu, Qu}}, {"phsubw", {Pu, Qu}}, {"phsubd", {Pu, Qu}}, {"phsubsw", {Pu, Qu}}, /* 08 */ {"psignb", {Pu, Qu}}, {"psignw", {Pu, Qu}}, {"psignd", {Pu, Qu}}, {"pmulhrsw", {Pu, Qu}}, {0}, {0}, {0}, {0}, /* 10 */ {"pblendvb", {Vo, Wo, XMM0}}, {0}, {0}, {0}, {"blendvps", {Vo, Wo, XMM0}}, {"blendvpd", {Vo, Wo, XMM0}}, {0}, {"ptest", {Vo, Wo}}, /* 18 */ {0}, {0}, {0}, {0}, {"pabsb", {Pu, Qu}}, {"pabsw", {Pu, Qu}}, {"pabsd", {Pu, Qu}}, {0}, /* 20 */ {"pmovsxbw", {Vo, Wq}}, {"pmovsxbd", {Vo, Wd}}, {"pmovsxbq", {Vo, Ww}}, {"pmovsxwd", {Vo, Wq}}, {"pmovsxwq", {Vo, Wd}}, {"pmovsxdq", {Vo, Wq}}, {0}, {0}, /* 28 */ {"pmuldq", {Vo, Wo}}, {"pcmpeqq", {Vo, Wo}}, {"movntdqa", {Vo, Mo}}, {"packusdw", {Vo, Wo}}, {0}, {0}, {0}, {0}, /* 30 */ {"pmovzxbw", {Vo, Wq}}, {"pmovzxbd", {Vo, Wd}}, {"pmovzxbq", {Vo, Ww}}, {"pmovzxwd", {Vo, Wq}}, {"pmovzxwq", {Vo, Wd}}, {"pmovzxdq", {Vo, Wq}}, {0}, {"pcmpgtq", {Vo, Wo}}, /* 38 */ {"pminsb", {Vo, Wo}}, {"pminsd", {Vo, Wo}}, {"pminuw", {Vo, Wo}}, {"pminud", {Vo, Wo}}, {"pmaxsb", {Vo, Wo}}, {"pmaxsd", {Vo, Wo}}, {"pmaxuw", {Vo, Wo}}, {"pmaxud", {Vo, Wo}}, /* 40 */ {"pmulld", {Vo, Wo}}, {"phminposuw", {Vo, Wo}}, {0}, {0}, {0}, {0}, {0}, {0}, /* 48 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 50 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 58 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 60 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 68 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 70 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 78 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 80 */ {"invept", {Gr, Mo}}, {"invvpid", {Gr, Mo}}, {"invpcid", {Gr, Mo}}, {0}, {0}, {0}, {0}, {0}, /* 88 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 90 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 98 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d8 */ {0}, {0}, {0}, {"aesimc", {Vo, Wo}}, {"aesenc", {Vo, Wo}}, {"aesenclast", {Vo, Wo}}, {"aesdec", {Vo, Wo}}, {"aesdeclast", {Vo, Wo}}, /* e0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f0 */ {"movbe", {Gv, Mv}}, {"movbe", {Mv, Gv}}, {0}, {0}, {0}, {0}, {"adcx", {Gr, Er}}, {0}, /* f8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 2 - GROUP_OPC_F20F38 */ { /* 00 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 08 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 10 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 18 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 20 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 28 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 30 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 38 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 40 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 48 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 50 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 58 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 60 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 68 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 70 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 78 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 80 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 88 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 90 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 98 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f0 */ {"~crc32", {Gr, Eb}}, {"~crc32", {Gr, Ev}}, {0}, {0}, {0}, {0}, {0}, {0}, /* f8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 3 - GROUP_OPC_0F3A */ { /* 00 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 08 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {"palignr", {Pu, Qu, Ib}}, /* 10 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 18 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 20 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 28 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 30 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 38 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 40 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 48 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 50 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 58 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 60 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 68 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 70 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 78 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 80 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 88 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 90 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 98 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 4 - GROUP_OPC_660F3A */ { /* 00 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 08 */ {"roundps", {Vo, Wo, Ib}}, {"roundpd", {Vo, Wo, Ib}}, {"roundss", {Vo, Wo, Ib}}, {"roundsd", {Vo, Wo, Ib}}, {"blendps", {Vo, Wo, Ib}}, {"blendpd", {Vo, Wo, Ib}}, {"pblendw", {Vo, Wo, Ib}}, {"palignr", {Vo, Wo, Ib}}, /* 10 */ {0}, {0}, {0}, {0}, {"pextrb", {MRbr, Vo, Ib}}, {"pextrw", {MRwr, Vo, Ib}}, {"&pextrd|pextrd|pextrq", {Er, Vo, Ib}}, {"extractps", {MRdr, Vo, Ib}}, /* 18 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 20 */ {"pinsrb", {Vo, MRbd, Ib}}, {"insertps", {Vo, Wd, Ib}}, {"&pinsrd|pinsrd|pinsrq", {Vo, Er, Ib}}, {0}, {0}, {0}, {0}, {0}, /* 28 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 30 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 38 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 40 */ {"dpps", {Vo, Wo, Ib}}, {"dppd", {Vo, Wo, Ib}}, {"mpsadbw", {Vo, Wo, Ib}}, {0}, {"pclmulqdq", {Vo, Wo, Ib}}, {0}, {0}, {0}, /* 48 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 50 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 58 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 60 */ {"pcmpestrm", {Vo, Wo, Ib}}, {"pcmpestri", {Vo, Wo, Ib}}, {"pcmpistrm", {Vo, Wo, Ib}}, {"pcmpistri", {Vo, Wo, Ib}}, {0}, {0}, {0}, {0}, /* 68 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 70 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 78 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 80 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 88 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 90 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 98 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {"aeskeygenassist", {Vo, Wo, Ib}}, /* e0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 5 - GROUP_OPC_0F7A */ { /* 00 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 08 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 10 */ {"frczps", {Vo, Wo}}, {"frczpd", {Vo, Wo}}, {"frczss", {Vo, Wd}}, {"frczsd", {Vo, Wq}}, {0}, {0}, {0}, {0}, /* 18 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 20 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 28 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 30 */ {"cvtph2ps", {Vo, Wq}}, {"cvtps2ph", {Wq, Vo}}, {0}, {0}, {0}, {0}, {0}, {0}, /* 38 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 40 */ {0}, {"phaddbw", {Vo, Wo}}, {"phaddbd", {Vo, Wo}}, {"phaddbq", {Vo, Wo}}, {0}, {0}, {"phaddwd", {Vo, Wo}}, {"phaddwq", {Vo, Wo}}, /* 48 */ {0}, {0}, {0}, {"phadddq", {Vo, Wo}}, {0}, {0}, {0}, {0}, /* 50 */ {0}, {"phaddubw", {Vo, Wo}}, {"phaddubd", {Vo, Wo}}, {"phaddubq", {Vo, Wo}}, {0}, {0}, {"phadduwd", {Vo, Wo}}, {"phadduwq", {Vo, Wo}}, /* 58 */ {0}, {0}, {0}, {"phaddudq", {Vo, Wo}}, {0}, {0}, {0}, {0}, /* 60 */ {0}, {"phsubbw", {Vo, Wo}}, {"phsubwd", {Vo, Wo}}, {"phsubdq", {Vo, Wo}}, {0}, {0}, {0}, {0}, /* 68 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 70 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 78 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 80 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 88 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 90 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 98 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 6 - GROUP_OPC_0F7B */ { /* 00 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 08 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 10 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 18 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 20 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 28 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 30 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 38 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 40 */ {"protb", {Vo, Wo, Ib}}, {"protw", {Vo, Wo, Ib}}, {"protd", {Vo, Wo, Ib}}, {"protq", {Vo, Wo, Ib}}, {0}, {0}, {0}, {0}, /* 48 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 50 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 58 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 60 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 68 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 70 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 78 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 80 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 88 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 90 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 98 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 6 - GROUP_OPC_0F24 */ { /* 00 */ {"fmaddps", {VD, VD, VS0o, VS1o}}, {"fmaddpd", {VD, VD, VS0o, VS1o}}, {"fmaddss", {VD, VD, VS0d, VS1d}}, {"fmaddsd", {VD, VD, VS0q, VS1q}}, {"fmaddps", {VD, VS0o, VS1o, VD}}, {"fmaddpd", {VD, VS0o, VS1o, VD}}, {"fmaddss", {VD, VS0d, VS1d, VD}}, {"fmaddsd", {VD, VS0q, VS1q, VD}}, /* 08 */ {"fmsubps", {VD, VD, VS0o, VS1o}}, {"fmsubpd", {VD, VD, VS0o, VS1o}}, {"fmsubss", {VD, VD, VS0d, VS1d}}, {"fmsubsd", {VD, VD, VS0q, VS1q}}, {"fmsubps", {VD, VS0o, VS1o, VD}}, {"fmsubpd", {VD, VS0o, VS1o, VD}}, {"fmsubss", {VD, VS0d, VS1d, VD}}, {"fmsubsd", {VD, VS0q, VS1q, VD}}, /* 10 */ {"fnmaddps", {VD, VD, VS0o, VS1o}}, {"fnmaddpd", {VD, VD, VS0o, VS1o}}, {"fnmaddss", {VD, VD, VS0d, VS1d}}, {"fnmaddsd", {VD, VD, VS0q, VS1q}}, {"fnmaddps", {VD, VS0o, VS1o, VD}}, {"fnmaddpd", {VD, VS0o, VS1o, VD}}, {"fnmaddss", {VD, VS0d, VS1d, VD}}, {"fnmaddsd", {VD, VS0q, VS1q, VD}}, /* 18 */ {"fnmsubps", {VD, VD, VS0o, VS1o}}, {"fnmsubpd", {VD, VD, VS0o, VS1o}}, {"fnmsubss", {VD, VD, VS0d, VS1d}}, {"fnmsubsd", {VD, VD, VS0q, VS1q}}, {"fnmsubps", {VD, VS0o, VS1o, VD}}, {"fnmsubpd", {VD, VS0o, VS1o, VD}}, {"fnmsubss", {VD, VS0d, VS1d, VD}}, {"fnmsubsd", {VD, VS0q, VS1q, VD}}, /* 20 */ {"permps", {VD, VD, VS0o, VS1o}}, {"permpd", {VD, VD, VS0o, VS1o}}, {"pcmov", {VD, VD, VS0o, VS1o}}, {"pperm", {VD, VD, VS0o, VS1o}}, {"permps", {VD, VS0o, VS1o, VD}}, {"permpd", {VD, VS0o, VS1o, VD}}, {"pcmov", {VD, VS0o, VS1o, VD}}, {"pperm", {VD, VS0o, VS1o, VD}}, /* 28 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 30 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 38 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 40 */ {"protb", {VD, VS0o, VS1o}}, {"protw", {VD, VS0o, VS1o}}, {"protd", {VD, VS0o, VS1o}}, {"protq", {VD, VS0o, VS1o}}, {"pshlb", {VD, VS0o, VS1o}}, {"pshlw", {VD, VS0o, VS1o}}, {"pshld", {VD, VS0o, VS1o}}, {"pshlq", {VD, VS0o, VS1o}}, /* 48 */ {"pshab", {VD, VS0o, VS1o}}, {"pshaw", {VD, VS0o, VS1o}}, {"pshad", {VD, VS0o, VS1o}}, {"pshaq", {VD, VS0o, VS1o}}, {0}, {0}, {0}, {0}, /* 50 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 58 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 60 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 68 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 70 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 78 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 80 */ {0}, {0}, {0}, {0}, {0}, {"pmacssww", {VD, VS00o, VS1o, VD}}, {"pmacsswd", {VD, VS00o, VS1o, VD}}, {"pmacssdql", {VD, VS00o, VS1o, VD}}, /* 88 */ {0}, {0}, {0}, {0}, {0}, {0}, {"pmacssdd", {VD, VS00o, VS1o, VD}}, {"pmacssdqh", {VD, VS00o, VS1o, VD}}, /* 90 */ {0}, {0}, {0}, {0}, {0}, {"pmacsww", {VD, VS00o, VS1o, VD}}, {"pmacswd", {VD, VS00o, VS1o, VD}}, {"pmacsdql", {VD, VS00o, VS1o, VD}}, /* 98 */ {0}, {0}, {0}, {0}, {0}, {0}, {"pmacsdd", {VD, VS00o, VS1o, VD}}, {"pmacsdqh", {VD, VS00o, VS1o, VD}}, /* a0 */ {0}, {0}, {0}, {0}, {0}, {0}, {"pmadcsswd", {VD, VS00o, VS1o, VD}}, {0}, /* a8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b0 */ {0}, {0}, {0}, {0}, {0}, {0}, {"pmadcswd", {VD, VS00o, VS1o, VD}}, {0}, /* b8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 7 - GROUP_OPC_0F25 */ { /* 00 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 08 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 10 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 18 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 20 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 28 */ {0}, {0}, {0}, {0}, {"comps", {VD, VS00o, VS1o, Ib}}, {"compd", {VD, VS00o, VS1o, Ib}}, {"comss", {VD, VS00d, VS1d, Ib}}, {"comsd", {VD, VS00q, VS1q, Ib}}, /* 30 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 38 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 40 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 48 */ {0}, {0}, {0}, {0}, {"pcomb", {VD, VS00o, VS1o, Ib}}, {"pcomw", {VD, VS00o, VS1o, Ib}}, {"pcomd", {VD, VS00o, VS1o, Ib}}, {"pcomq", {VD, VS00o, VS1o, Ib}}, /* 50 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 58 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 60 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 68 */ {0}, {0}, {0}, {0}, {"pcomub", {VD, VS00o, VS1o, Ib}}, {"pcomuw", {VD, VS00o, VS1o, Ib}}, {"pcomud", {VD, VS00o, VS1o, Ib}}, {"pcomuq", {VD, VS00o, VS1o, Ib}}, /* 70 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 78 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 80 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 88 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 90 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* 98 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* a8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* b8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* c8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* d8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* e8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f0 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, /* f8 */ {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, }, }; x86opc_insn x86_group_insns[][8] = { /* 0 - GROUP_80 */ { {"~add", {Eb, Ib}}, {"~or", {Eb, Ib}}, {"~adc", {Eb, Ib}}, {"~sbb", {Eb, Ib}}, {"~and", {Eb, Ib}}, {"~sub", {Eb, Ib}}, {"~xor", {Eb, Ib}}, {"~cmp", {Eb, Ib}}, }, /* 1 - GROUP_81 */ { {"~add", {Ev, Iv}}, {"~or", {Ev, Iv}}, {"~adc", {Ev, Iv}}, {"~sbb", {Ev, Iv}}, {"~and", {Ev, Iv}}, {"~sub", {Ev, Iv}}, {"~xor", {Ev, Iv}}, {"~cmp", {Ev, Iv}}, }, /* 2 - GROUP_83 */ { {"~add", {Ev, sIbv}}, {"~or", {Ev, sIbv}}, {"~adc", {Ev, sIbv}}, {"~sbb", {Ev, sIbv}}, {"~and", {Ev, sIbv}}, {"~sub", {Ev, sIbv}}, {"~xor", {Ev, sIbv}}, {"~cmp", {Ev, sIbv}}, }, /* 3 - GROUP_8F */ { {"~pop", {Ev64}}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 4 - GROUP_C0 */ { {"~rol", {Eb, Ib}}, {"~ror", {Eb, Ib}}, {"~rcl", {Eb, Ib}}, {"~rcr", {Eb, Ib}}, {"~shl", {Eb, Ib}}, {"~shr", {Eb, Ib}}, {"~sal", {Eb, Ib}}, {"~sar", {Eb, Ib}}, }, /* 5 - GROUP_C1 */ { {"~rol", {Ev, Ib}}, {"~ror", {Ev, Ib}}, {"~rcl", {Ev, Ib}}, {"~rcr", {Ev, Ib}}, {"~shl", {Ev, Ib}}, {"~shr", {Ev, Ib}}, {"~sal", {Ev, Ib}}, {"~sar", {Ev, Ib}}, }, /* 6 - GROUP_C6 */ { {"~mov", {Eb, Ib}}, {0}, {0}, {0}, {0}, {0}, {0}, {"xabort", {Ib}}, }, /* 7 - GROUP_C7 */ { {"~mov", {Ev, Iv}}, {0}, {0}, {0}, {0}, {0}, {0}, {"xbegin", {Jv}}, }, /* 8 - GROUP_D0 */ { {"~rol", {Eb, __1}}, {"~ror", {Eb, __1}}, {"~rcl", {Eb, __1}}, {"~rcr", {Eb, __1}}, {"~shl", {Eb, __1}}, {"~shr", {Eb, __1}}, {"~sal", {Eb, __1}}, {"~sar", {Eb, __1}}, }, /* 9 - GROUP_D1 */ { {"~rol", {Ev, __1}}, {"~ror", {Ev, __1}}, {"~rcl", {Ev, __1}}, {"~rcr", {Ev, __1}}, {"~shl", {Ev, __1}}, {"~shr", {Ev, __1}}, {"~sal", {Ev, __1}}, {"~sar", {Ev, __1}}, }, /* 10 - GROUP_D2 */ { {"~rol", {Eb, X__cl}}, {"~ror", {Eb, X__cl}}, {"~rcl", {Eb, X__cl}}, {"~rcr", {Eb, X__cl}}, {"~shl", {Eb, X__cl}}, {"~shr", {Eb, X__cl}}, {"~sal", {Eb, X__cl}}, {"~sar", {Eb, X__cl}}, }, /* 11 - GROUP_D3 */ { {"~rol", {Ev, X__cl}}, {"~ror", {Ev, X__cl}}, {"~rcl", {Ev, X__cl}}, {"~rcr", {Ev, X__cl}}, {"~shl", {Ev, X__cl}}, {"~shr", {Ev, X__cl}}, {"~sal", {Ev, X__cl}}, {"~sar", {Ev, X__cl}}, }, /* 12 - GROUP_F6 */ { {"~test", {Eb, Ib}}, {"~test", {Eb, Ib}}, {"~not", {Eb}}, {"~neg", {Eb}}, {"mul", {X__al, Eb}}, {"imul", {X__al, Eb}}, {"div", {X__al, Eb}}, {"idiv", {X__al, Eb}}, }, /* 13 - GROUP_F7 */ { {"~test", {Ev, Iv}}, {"~test", {Ev, Iv}}, {"~not", {Ev}}, {"~neg", {Ev}}, {"mul", {X__ax, Ev}}, {"imul", {X__ax, Ev}}, {"div", {X__ax, Ev}}, {"idiv", {X__ax, Ev}}, }, /* 14 - GROUP_FE */ { {"~inc", {Eb}}, {"~dec", {Eb}}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 15 - GROUP_FF */ { {"~inc", {Ev}}, {"~dec", {Ev}}, {"~call", {Ev64}}, {"~call", {Mp}}, {"~jmp", {Ev64}}, {"~jmp", {Mp}}, {"~push", {Ev64}}, {0}, }, /* 16 - GROUP_EXT_00 */ { {"sldt", {MRwv}}, {"str", {MRwv}}, {"lldt", {MRwv}}, {"ltr", {MRwv}}, {"verr", {MRwv}}, {"verw", {MRwv}}, {0}, {0}, }, /* 17 - GROUP_EXT_01 */ { {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0F01_0}}, {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0F01_1}}, {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0F01_2}}, {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0F01_3}}, {"smsw", {MRwv}}, {0}, {"lmsw", {MRwv}}, {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0F01_7}}, }, /* 18 - GROUP_EXT_18 */ { {"prefetchnta", {M}}, {"prefetch0", {M}}, {"prefetch1", {M}}, {"prefetch2", {M}}, {"~nop", {Ev}}, {"~nop", {Ev}}, {"~nop", {Ev}}, {"~nop", {Ev}}, }, /* 16 - GROUP_EXT_71 */ { {0}, {0}, {"psrlw", {PRu, Ib}}, {0}, {"psraw", {PRu, Ib}}, {0}, {"psllw", {PRu, Ib}}, {0}, }, /* 17 - GROUP_EXT_72 */ { {0}, {0}, {"psrld", {PRu, Ib}}, {0}, {"psrad", {PRu, Ib}}, {0}, {"pslld", {PRu, Ib}}, {0}, }, /* 18 - GROUP_EXT_73 */ { {0}, {0}, {"psrlq", {PRu, Ib}}, {"psrldq", {PRu, Ib}}, {0}, {0}, {"psllq", {PRu, Ib}}, {"pslldq", {PRu, Ib}}, }, /* 22 - GROUP_EXT_AE */ { {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0FAE_0}}, {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0FAE_1}}, {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0FAE_2}}, {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0FAE_3}}, {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0FAE_4}}, {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0FAE_5}}, {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0FAE_6}}, {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0FAE_7}}, }, /* 22 - GROUP_EXT_F3_AE */ { {"rdfsbase", {Rr}}, {"rdgsbase", {Rr}}, {"wrfsbase", {Rr}}, {"wrgsbase", {Rr}}, {0}, {0}, {0}, {0}, }, /* 23 - GROUP_EXT_BA */ { {0}, {0}, {0}, {0}, {"~bt", {Ev, Ib}}, {"~bts", {Ev, Ib}}, {"~btr", {Ev, Ib}}, {"~btc", {Ev, Ib}}, }, /* 24 - GROUP_EXT_C7 */ { {0}, {"? |cmpxchg8b|cmpxchg16b", {M}}, {0}, {0}, {0}, {0}, {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0FC7_6}}, {0, {SPECIAL_TYPE_SGROUP, GROUP_SPECIAL_0FC7_7}}, }, /* 25 - GROUP_EXT_66_C7 */ { {0}, {0}, {0}, {0}, {0}, {0}, {"vmclear", {Mq}}, {0}, }, /* 26 - GROUP_EXT_F3_C7 */ { {0}, {0}, {0}, {0}, {0}, {0}, {"vmxon", {Mq}}, {0}, }, }; x86opc_insn x86_special_group_insns[X86_SPECIAL_GROUPS][9] = { /* 0 - GROUP_SPECIAL_0F01_0 */ { {0}, {"vmcall"}, {"vmlaunch"}, {"vmresume"}, {"vmxoff"}, {0}, {0}, {0}, // with mod!=11: {"sgdt", {M}}, }, /* 1 - GROUP_SPECIAL_0F01_1 */ { {"monitor"}, {"mwait"}, {"clac"}, {"stac"}, {0}, {0}, {0}, {0}, // with mod!=11: {"sidt", {M}}, }, /* 2 - GROUP_SPECIAL_0F01_2 */ { {"xgetbv"}, {"xsetbv"}, {0}, {0}, {"vmfunc"}, {"xend"}, {"xtest"}, {0}, // with mod!=11: {"lgdt", {M}}, }, /* 3 - GROUP_SPECIAL_0F01_3 */ { {"vmrun"}, {"vmmcall"}, {"vmload"}, {"vmsave"}, {"stgi"}, {"clgi"}, {"skinit"}, {"invlpga"}, // with mod!=11: {"lidt", {M}}, }, /* 4 - GROUP_SPECIAL_0F01_7 */ { {"swapgs"}, {"rdtscp"}, {0}, {0}, {0}, {0}, {0}, {0}, // with mod!=11: {"invlpg", {M}}, }, /* 5 - GROUP_SPECIAL_0FAE_0 */ { {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, // with mod!=11: {"?fxsave|fxsave|fxsave64", {M}}, }, /* 6 - GROUP_SPECIAL_0FAE_1 */ { {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, // with mod!=11: {"?fxstor|fxstor|fxstor64", {M}}, }, /* 7 - GROUP_SPECIAL_0FAE_2 */ { {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, // with mod!=11: {"ldmxcsr", {Md}}, }, /* 8 - GROUP_SPECIAL_0FAE_3 */ { {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, // with mod!=11: {"stmxcsr", {Md}}, }, /* 9 - GROUP_SPECIAL_0FAE_4 */ { {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, // with mod!=11: {"?xsave|xsave|xsave64", {M}}, }, /* 10 - GROUP_SPECIAL_0FAE_5 */ { {"lfence"}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, // with mod!=11: {"?xrstor|xrstor|xrstor64", {M}}, }, /* 11 - GROUP_SPECIAL_0FAE_6 */ { {"mfence"}, {0}, {0}, {0}, {0}, {0}, {0}, {"?xsaveopt|xsaveopt|xsaveopt64", {M}}, // with mod!=11: {0}, }, /* 12 - GROUP_SPECIAL_0FAE_7 */ { {"sfence"}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, // with mod!=11: {"clflush", {M}}, }, /* 12 - GROUP_SPECIAL_0FC7_6 */ { {"rdrand", {Rv}}, {"rdrand", {Rv}}, {"rdrand", {Rv}}, {"rdrand", {Rv}}, {"rdrand", {Rv}}, {"rdrand", {Rv}}, {"rdrand", {Rv}}, {"rdrand", {Rv}}, // with mod!=11: {"vmptrld", {Mq}}, }, /* 13 - GROUP_SPECIAL_0FC7_7 */ { {"rdseed", {Rv}}, {"rdseed", {Rv}}, {"rdseed", {Rv}}, {"rdseed", {Rv}}, {"rdseed", {Rv}}, {"rdseed", {Rv}}, {"rdseed", {Rv}}, {"rdseed", {Rv}}, // with mod!=11: {"vmptrst", {Mq}}, }, }; /* * The ModR/M byte is < 0xC0 */ x86opc_insn x86_modfloat_group_insns[8][8] = { /* prefix D8 */ { {"~fadd", {Ms}}, {"~fmul", {Ms}}, {"~fcom", {Ms}}, {"~fcomp", {Ms}}, {"~fsub", {Ms}}, {"~fsubr", {Ms}}, {"~fdiv", {Ms}}, {"~fdivr", {Ms}}, }, /* prefix D9 */ { {"~fld", {Ms}}, {0}, {"~fst", {Ms}}, {"~fstp", {Ms}}, {"fldenv", {M}}, {"fldcw", {Mw}}, {"fstenv", {M}}, {"fstcw", {Mw}}, }, /* prefix DA */ { {"~fiadd", {Md}}, {"~fimul", {Md}}, {"~ficom", {Md}}, {"~ficomp", {Md}}, {"~fisub", {Md}}, {"~fisubr", {Md}}, {"~fidiv", {Md}}, {"~fidivr", {Md}}, }, /* prefix DB */ { {"~fild", {Md}}, {"~fisttp", {Md}}, {"~fist", {Md}}, {"~fistp", {Md}}, {0}, {"~fld", {Mt}}, {0}, {"~fstp", {Mt}}, }, /* prefix DC */ { {"~fadd", {Ml}}, {"~fmul", {Ml}}, {"~fcom", {Ml}}, {"~fcomp", {Ml}}, {"~fsub", {Ml}}, {"~fsubr", {Ml}}, {"~fdiv", {Ml}}, {"~fdivr", {Ml}}, }, /* prefix DD */ { {"~fld", {Ml}}, {"~fisttp", {Mq}}, {"~fst", {Ml}}, {"~fstp", {Ml}}, {"~frstor", {M}}, {0}, {"fsave", {M}}, {"fstsw", {Mw}}, }, /* prefix DE */ { {"~fiadd", {Mw}}, {"~fimul", {Mw}}, {"~ficom", {Mw}}, {"~ficomp", {Mw}}, {"~fisub", {Mw}}, {"~fisubr", {Mw}}, {"~fidiv", {Mw}}, {"~fidivr", {Mw}}, }, /* prefix DF */ { {"~fild", {Mw}}, {"~fisttp", {Mw}}, {"~fist", {Mw}}, {"~fistp", {Mw}}, {"~fbld", {Ma}}, {"~fild", {Mq}}, {"~fbstp", {Ma}}, {"~fistp", {Mq}}, } }; x86opc_insn fgroup_12[8] = { {"fnop"}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, }; x86opc_insn fgroup_14[8] = { {"fchs"}, {"fabs"}, {0}, {0}, {"ftst"}, {"fxam"}, {0}, {0}, }; x86opc_insn fgroup_15[8] = { {"fld1"}, {"fldl2t"}, {"fldl2e"}, {"fldpi"}, {"fldlg2"}, {"fldln2"}, {"fldz"}, {0}, }; x86opc_insn fgroup_16[8] = { {"f2xm1"}, {"fyl2x"}, {"fptan"}, {"fpatan"}, {"fxtract"}, {"fprem1"}, {"fdecstp"}, {"fincstp"}, }; x86opc_insn fgroup_17[8] = { {"fprem"}, {"fyl2xp1"}, {"fsqrt"}, {"fsincos"}, {"frndint"}, {"fscale"}, {"fsin"}, {"fcos"}, }; x86opc_insn fgroup_25[8] = { {0}, {"fucompp"}, {0}, {0}, {0}, {0}, {0}, {0}, }; x86opc_insn fgroup_34[8] = { {0}, {0}, {"fclex"}, {"finit"}, {0}, {0}, {0}, {0}, }; x86opc_insn fgroup_63[8] = { {0}, {"fcompp"}, {0}, {0}, {0}, {0}, {0}, {0}, }; x86opc_insn fgroup_74[8] = { {"fstsw", {X__axw}}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, }; /* * The ModR/M byte is >= 0xC0 */ x86opc_finsn x86_float_group_insns[8][8] = { /* prefix D8 */ { {0, {"fadd", {__st, Ft}}}, {0, {"fmul", {__st, Ft}}}, {0, {"fcom", {__st, Ft}}}, {0, {"fcomp", {__st, Ft}}}, {0, {"fsub", {__st, Ft}}}, {0, {"fsubr", {__st, Ft}}}, {0, {"fdiv", {__st, Ft}}}, {0, {"fdivr", {__st, Ft}}}, }, /* prefix D9 */ { {0, {"fld", {__st, Ft}}}, {0, {"fxch", {__st, Ft}}}, {(x86opc_insn *)&fgroup_12}, {0}, {(x86opc_insn *)&fgroup_14}, {(x86opc_insn *)&fgroup_15}, {(x86opc_insn *)&fgroup_16}, {(x86opc_insn *)&fgroup_17}, }, /* prefix DA */ { {0, {"fcmovb", {__st, Ft}}}, {0, {"fcmove", {__st, Ft}}}, {0, {"fcmovbe", {__st, Ft}}}, {0, {"fcmovu", {__st, Ft}}}, {0}, {(x86opc_insn *)&fgroup_25}, {0}, {0}, }, /* prefix DB */ { {0, {"fcmovnb", {__st, Ft}}}, {0, {"fcmovne", {__st, Ft}}}, {0, {"fcmovnbe", {__st, Ft}}}, {0, {"fcmovnu", {__st, Ft}}}, {(x86opc_insn*)&fgroup_34}, {0, {"fucomi", {__st, Ft}}}, {0, {"fcomi", {__st, Ft}}}, {0}, }, /* prefix DC */ { {0, {"fadd", {Ft, __st}}}, {0, {"fmul", {Ft, __st}}}, {0}, {0}, {0, {"fsubr", {Ft, __st}}}, {0, {"fsub", {Ft, __st}}}, {0, {"fdivr", {Ft, __st}}}, {0, {"fdiv", {Ft, __st}}}, }, /* prefix DD */ { {0, {"ffree", {Ft}}}, {0}, {0, {"fst", {Ft}}}, {0, {"fstp", {Ft}}}, {0, {"fucom", {Ft, __st}}}, {0, {"fucomp", {Ft}}}, {0}, {0}, }, /* prefix DE */ { {0, {"faddp", {Ft, __st}}}, {0, {"fmulp", {Ft, __st}}}, {0}, {(x86opc_insn*)&fgroup_63}, {0, {"fsubrp", {Ft, __st}}}, {0, {"fsubp", {Ft, __st}}}, {0, {"fdivrp", {Ft, __st}}}, {0, {"fdivp", {Ft, __st}}}, }, /* prefix DF */ { {0, {"ffreep", {Ft}}}, {0}, {0}, {0}, {(x86opc_insn*)&fgroup_74}, {0, {"fucomip", {__st, Ft}}}, {0, {"fcomip", {__st, Ft}}}, {0}, }, }; /* * The vex format insns */ #define E0(e) static x86opc_vex_insn v##e[] = { #define E(e) {0}}; static x86opc_vex_insn v##e[] = { #define Elast {0}}; E0(00) {"vpshufb", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpshufb", _256|_66|_0f38, {Yy, YVy, Xy}}, {"vpermq", _256|_66|_0f3a|W1, {Yy, Xy, Ib}}, E(01) {"pvhaddw", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vphaddw", _256|_66|_0f38, {Yy, YVy, Xy}}, {"vpermpd", _256|_66|_0f3a|W1, {Yy, Xy, Ib}}, E(02) {"vphaddd", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vphaddd", _256|_66|_0f38, {Yy, YVy, Xy}}, {"vpblendd", _128|_66|_0f3a|W0, {Vo, VVo, Wo, Ib}}, {"vpblendd", _256|_66|_0f3a|W0, {Yy, YVy, Xy, Ib}}, E(03) {"vphaddsw", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vphaddsw", _256|_66|_0f38, {Yy, YVy, Xy}}, E(04) {"vpermilps", _128|_66|_0f3a, {Vo, Wo, Ib}}, {"vpermilps", _256|_66|_0f3a, {Yy, Xy, Ib}}, {"vpmaddubsw", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpmaddubsw", _256|_66|_0f38, {Yy, YVy, Xy}}, E(05) {"vphsubw", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vphsubw", _256|_66|_0f38, {Yy, YVy, Xy}}, {"vpermilpd", _128|_66|_0f3a, {Vo, Wo, Ib}}, {"vpermilpd", _256|_66|_0f3a, {Yy, Xy, Ib}}, E(06) {"vphsubd", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vphsubd", _256|_66|_0f38, {Yy, YVy, Xy}}, {"vperm2f128", _256|_66|_0f3a, {Yy, YVy, Xy, Ib}}, E(07) {"vphsubsw", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vphsubsw", _256|_66|_0f38, {Yy, YVy, Xy}}, E(08) {"vpsignb", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpsignb", _256|_66|_0f38, {Yy, YVy, Xy}}, {"vroundps", _128|_66|_0f3a, {Vo, Wo, Ib}}, {"vroundps", _256|_66|_0f3a, {Yy, Xy, Ib}}, E(09) {"vpsignw", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpsignw", _256|_66|_0f38, {Yy, YVy, Xy}}, {"vroundpd", _128|_66|_0f3a, {Vo, Wo, Ib}}, {"vroundpd", _256|_66|_0f3a, {Yy, Xy, Ib}}, E(0a) {"vpsignd", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpsignd", _256|_66|_0f38, {Yy, YVy, Xy}}, {"vroundss", _128|_66|_0f3a, {Vo, Wo, Ib}}, E(0b) {"vpmulhrsw", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpmulhrsw", _256|_66|_0f38, {Yy, YVy, Xy}}, {"vroundsd", _128|_66|_0f3a, {Vo, Wo, Ib}}, E(0c) {"vblendps", _128|_66|_0f3a, {Vo, VVo, Wo, Ib}}, {"vblendps", _256|_66|_0f3a, {Yy, YVy, Xy, Ib}}, {"vpermilps", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpermilps", _256|_66|_0f38, {Yy, YVy, Xy}}, E(0d) {"vpermilpd", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpermilpd", _256|_66|_0f38, {Yy, YVy, Xy}}, {"vblendpd", _128|_66|_0f3a, {Vo, VVo, Wo, Ib}}, {"vblendpd", _256|_66|_0f3a, {Yy, YVy, Xy, Ib}}, E(0e) {"vpblendw", _128|_66|_0f3a, {Vo, VVo, Wo, Ib}}, {"vpblendw", _256|_66|_0f3a, {Yy, YVy, Xy, Ib}}, {"vptestps", _128|_66|_0f38, {Vo, Wo}}, {"vptestps", _256|_66|_0f38, {Yy, Xy}}, E(0f) {"vpalignr", _128|_66|_0f3a, {Vo, VVo, Wo, Ib}}, {"vpalignr", _256|_66|_0f3a, {Yy, YVy, Xy, Ib}}, {"vptestpd", _128|_66|_0f38, {Vo, Wo}}, {"vptestpd", _256|_66|_0f38, {Yy, Xy}}, E(10) //{"vmovss", _128|_f3|_0f, {Vo, VVo, VRo}}, {"vmovss", _128|_f3|_0f, {Vo, VVo, Wd}}, //{"vmovsd", _128|_f2|_0f, {Vo, VVo, VRo}}, {"vmovsd", _128|_f2|_0f, {Vo, VVo, Wq}}, {"vmovups", _128|_0f, {Vo, Wo}}, {"vmovups", _256|_0f, {Yy, Xy}}, {"vmovupd", _128|_66|_0f, {Vo, Wo}}, {"vmovupd", _256|_66|_0f, {Yy, Xy}}, E(11) //{"vmovss", _128|_f3|_0f, {VRo, VVo, Vo}}, {"vmovss", _128|_f3|_0f, {Wd, VVo, Vo}}, //{"vmovsd", _128|_f2|_0f, {VRo, VVo, Vo}}, {"vmovsd", _128|_f2|_0f, {Wq, VVo, Vo}}, {"vmovups", _128|_0f, {Wo, Vo}}, {"vmovups", _256|_0f, {Xy, Yy}}, {"vmovupd", _128|_66|_0f, {Wo, Vo}}, {"vmovupd", _256|_66|_0f, {Xy, Yy}}, E(12) {0, _128|_0f25|W0, {SPECIAL_TYPE_GROUP, GROUP_0F25_12}}, {0, _128|_0f25|W1, {SPECIAL_TYPE_GROUP, GROUP_0F25_12_W}}, {0, _256|_0f25|W0, {SPECIAL_TYPE_GROUP, GROUP_0F25_12_L}}, {0, _128|_0fA|W0, {SPECIAL_TYPE_GROUP, GROUP_0FA_12}}, {0, _128|_0fA|W1, {SPECIAL_TYPE_GROUP, GROUP_0FA_12_W}}, {0, _256|_0fA|W0, {SPECIAL_TYPE_GROUP, GROUP_0FA_12_L}}, {"vmovddup", _128|_f2|_0f, {Vo, Wq}}, {"vmovddup", _256|_f2|_0f, {Yy, Xy}}, {"vmovhlps", _128|_0f, {Vo, VVo, VRo}}, {"vmovlps", _128|_0f, {Vo, VVo, Mq}}, {"vmovlpd", _128|_66|_0f, {Vo, VVo, Mq}}, {"vmovsldup", _128|_f3|_0f, {Vo, Wo}}, {"vmovsldup", _256|_f3|_0f, {Yy, Xy}}, E(13) {"vmovlps", _128|_0f, {Mq, Vo}}, {"vmovlpd", _128|_66|_0f, {Mq, Vo}}, {"vcvtph2ps", _128|_0f, {Vo, Wq}}, {"vcvtph2ps", _256|_66|_0f38, {Yy, Wo}}, E(14) {"vpextrb", _128|_66|_0f3a, {MRbr, Vo, Ib}}, {"vunpcklps", _128|_0f, {Vo, VVo, Wo}}, {"vunpcklps", _256|_0f, {Yy, YVy, Xy}}, {"vunpcklpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vunpcklpd", _256|_66|_0f, {Yy, YVy, Xy}}, E(15) {"vpextrw", _128|_66|_0f3a, {MRwr, Vo, Ib}}, {"vunpckhps", _128|_0f, {Vo, VVo, Wo}}, {"vunpckhps", _256|_0f, {Yy, YVy, Xy}}, {"vunpckhpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vunpckhpd", _256|_66|_0f, {Yy, YVy, Xy}}, E(16) {"vpextrd", _128|_66|_0f3a|W0, {Ed, Vo, Ib}}, {"vpextrq", _128|_66|_0f3a|W1, {Eq, Vo, Ib}}, {"vmovhps", _128|_0f, {Vo, VVo, Mq}}, {"vmovhpd", _128|_66|_0f, {Vo, VVo, Mq}}, {"vmovlhps", _128|_0f, {Vo, VVo, VRo}}, {"vmovshdup", _128|_f3|_0f, {Vo, Wo}}, {"vmovshdup", _256|_f3|_0f, {Yy, Xy}}, {"vpermps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, E(17) {"vmovhps", _128|_0f, {Mq, Vo}}, {"vmovhpd", _128|_66|_0f, {Mq, Vo}}, {"vextractps", _128|_66|_0f3a, {Ed, Vo, Ib}}, {"vextractps", _128|_66|_0f3a|W1, {Eq, Vo, Ib}}, {"vptest", _128|_66|_0f38, {Vo, Wo}}, {"vptest", _256|_66|_0f38, {Yy, Xy}}, E(18) {"vbroadcastss", _128|_66|_0f38, {Vo, Wd}}, {"vbroadcastss", _256|_66|_0f38, {Yy, Wd}}, {"vinsertf128", _256|_66|_0f3a, {Yy, YVy, Xy, Ib}}, E(19) {"vbroadcastsd", _128|_66|_0f38, {Vo, Wq}}, {"vbroadcastsd", _256|_66|_0f38, {Yy, Wq}}, {"vextractf128", _256|_66|_0f3a, {Xy, Yy, Ib}}, E(1a) {"vbroadcastf128", _256|_66|_0f38, {Yy, Mo}}, E(1c) {"vpabsb", _128|_66|_0f38, {Vo, Wo}}, {"vpabsb", _256|_66|_0f38, {Yy, Xy}}, E(1d) {"vpabsw", _128|_66|_0f38, {Vo, Wo}}, {"vpabsw", _256|_66|_0f38, {Yy, Xy}}, {"vcvtps2ph", _128|_66|_0f3a, {Wq, Vo, Ib}}, {"vcvtps2ph", _256|_66|_0f3a, {Wo, Yy, Ib}}, E(1e) {"vpabsd", _128|_66|_0f38, {Vo, Wo}}, {"vpabsd", _256|_66|_0f38, {Yy, Xy}}, E(20) {"vpinsrb", _128|_66|_0f3a, {Vo, VVo, MRbd, Ib}}, {"vpmovsxbw", _128|_66|_0f38, {Vo, Wq}}, {"vpmovsxbw", _256|_66|_0f38, {Yy, Wo}}, E(21) {"vinsertps", _128|_66|_0f3a, {Vo, VVo, Wd, Ib}}, {"vpmovsxbd", _128|_66|_0f38, {Vo, Wd}}, {"vpmovsxbd", _256|_66|_0f38, {Yy, Wq}}, E(22) {"vpinsrd", _128|_66|_0f3a|W0, {Vo, VVo, Ed, Ib}}, {"vpinsrq", _128|_66|_0f3a|W1, {Vo, VVo, Eq, Ib}}, {"vpmovsxbq", _128|_66|_0f38, {Vo, Ww}}, {"vpmovsxbq", _256|_66|_0f38, {Yy, Wd}}, E(23) {"vpmovsxwd", _128|_66|_0f38, {Vo, Wq}}, {"vpmovsxwd", _256|_66|_0f38, {Yy, Wo}}, E(24) {"vpmovsxwq", _128|_66|_0f38, {Vo, Wd}}, {"vpmovsxwq", _256|_66|_0f38, {Yy, Wq}}, E(25) {"vpmovsxdq", _128|_66|_0f38, {Vo, Wq}}, {"vpmovsxdq", _256|_66|_0f38, {Yy, Wo}}, E(28) {"vmovapd", _128|_66|_0f, {Vo, Wo}}, {"vmovapd", _256|_66|_0f, {Yy, Xy}}, {"vpmuldq", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpmuldq", _256|_66|_0f38, {Yy, YVy, Xy}}, E(29) {"vmovapd", _128|_66|_0f, {Wo, Vo}}, {"vmovapd", _256|_66|_0f, {Xy, Yy}}, {"vpcmpeqq", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpcmpeqq", _256|_66|_0f38, {Yy, YVy, Xy}}, E(2a) {"vmovntdqa", _128|_66|_0f38, {Vo, Mo}}, {"vmovntdqa", _256|_66|_0f38, {Yy, My}}, {"vcvtsi2ss", _128|_f3|_0f|W0, {Vo, VVo, Ed}}, {"vcvtsi2ss", _128|_f3|_0f|W1, {Vo, VVo, Eq}}, {"vcvtsi2sd", _128|_f2|_0f|W0, {Vo, VVo, Ed}}, {"vcvtsi2sd", _128|_f2|_0f|W1, {Vo, VVo, Eq}}, E(2b) {"vmovntps", _128|_0f, {Mo, Vo}}, {"vmovntps", _256|_0f, {My, Xy}}, {"vmovntpd", _128|_66|_0f, {Mo, Vo}}, {"vmovntpd", _256|_66|_0f, {My, Xy}}, {"vpackusdw", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpackusdw", _256|_66|_0f38, {Yy, YVy, Xy}}, E(2c) {"vmaskmovps", _128|_66|_0f38, {Vo, VVo, Mo}}, {"vmaskmovps", _256|_66|_0f38, {Yy, YVy, My}}, {"vcvttss2si", _128|_f3|_0f|W0, {Gd, Wd}}, {"vcvttss2si", _128|_f3|_0f|W1, {Gq, Wd}}, {"vcvttsd2si", _128|_f2|_0f|W0, {Gd, Wq}}, {"vcvttsd2si", _128|_f2|_0f|W1, {Gq, Wq}}, E(2d) {"vcvtsd2si", _128|_f2|_0f|W0, {Gd, Wq}}, {"vcvtsd2si", _128|_f2|_0f|W1, {Gq, Wq}}, {"vcvtss2si", _128|_f3|_0f|W0, {Gd, Wd}}, {"vcvtss2si", _128|_f3|_0f|W1, {Gq, Wd}}, {"vmaskmovpd", _128|_66|_0f38, {Vo, VVo, Mo}}, {"vmaskmovpd", _256|_66|_0f38, {Yy, YVy, My}}, E(2e) {"vucomiss", _128|_0f, {Vo, Wd}}, {"vucomisd", _128|_66|_0f, {Vo, Wq}}, {"vmaskmovps", _128|_66|_0f38, {Mo, VVo, Vo}}, {"vmaskmovps", _256|_66|_0f38, {My, YVy, Yy}}, E(2f) {"vmaskmovpd", _128|_66|_0f38, {Mo, VVo, Vo}}, {"vmaskmovpd", _256|_66|_0f38, {My, YVy, Yy}}, {"vcomiss", _128|_0f, {Vo, Wd}}, {"vcomisd", _128|_66|_0f, {Vo, Wq}}, E(30) {"vpmovzxbw", _128|_66|_0f38, {Vo, Wq}}, {"vpmovzxbw", _256|_66|_0f38, {Yy, Wo}}, E(31) {"vpmovzxbd", _128|_66|_0f38, {Vo, Wd}}, {"vpmovzxbd", _256|_66|_0f38, {Yy, Wq}}, E(32) {"vpmovzxbq", _128|_66|_0f38, {Vo, Ww}}, {"vpmovzxbq", _256|_66|_0f38, {Yy, Wd}}, E(33) {"vpmovzxwd", _128|_66|_0f38, {Vo, Wq}}, {"vpmovzxwd", _256|_66|_0f38, {Yy, Wo}}, E(34) {"vpmovzxwq", _128|_66|_0f38, {Vo, Wd}}, {"vpmovzxwq", _256|_66|_0f38, {Yy, Wq}}, E(35) {"vpmovzxdq", _128|_66|_0f38, {Vo, Wq}}, {"vpmovzxdq", _256|_66|_0f38, {Yy, Wo}}, E(36) {"vpermd", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, E(37) {"vpcmpgtq", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpcmpgtq", _256|_66|_0f38, {Yy, YVy, Xy}}, E(38) {"vpminsb", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpminsb", _256|_66|_0f38, {Yy, YVy, Xy}}, {"vinserti128", _256|_66|_0f3a, {Yy, YVy, Wo, Ib}}, E(39) {"vpminsd", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpminsd", _256|_66|_0f38, {Yy, YVy, Xy}}, {"vextracti128", _256|_66|_0f3a, {Wo, Yy, Ib}}, E(3a) {"vpminuw", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpminuw", _256|_66|_0f38, {Yy, YVy, Xy}}, E(3b) {"vpminud", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpminud", _256|_66|_0f38, {Yy, YVy, Xy}}, E(3c) {"vpmaxsb", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpmaxsb", _256|_66|_0f38, {Yy, YVy, Xy}}, E(3d) {"vpmaxsd", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpmaxsd", _256|_66|_0f38, {Yy, YVy, Xy}}, E(3e) {"vpmaxuw", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpmaxuw", _256|_66|_0f38, {Yy, YVy, Xy}}, E(3f) {"vpmaxud", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpmaxud", _256|_66|_0f38, {Yy, YVy, Xy}}, E(40) {"vpmulld", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vpmulld", _256|_66|_0f38, {Yy, YVy, Xy}}, {"vdpps", _128|_66|_0f3a, {Vo, VVo, Wo, Ib}}, {"vdpps", _256|_66|_0f3a, {Yy, YVy, Xy, Ib}}, E(41) {"vdppd", _128|_66|_0f3a, {Vo, VVo, Wo, Ib}}, {"vphminposuw", _128|_66|_0f38, {Vo, Wo}}, E(42) {"vmpsadbw", _128|_66|_0f3a, {Vo, VVo, Wo, Ib}}, {"vmpsadbw", _256|_66|_0f3a, {Yy, YVy, Xy, Ib}}, E(44) {"vpclmulqdq", _128|_66|_0f3a, {Vo, VVo, Wo, Ib}}, E(45) {"vpsrlvd", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vpsrlvd", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vpsrlvq", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vpsrlvq", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, E(46) {"vpsravd", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vpsravd", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vperm2i128", _256|_66|_0f3a|W0, {Yy, YVy, Xy, Ib}}, E(47) {"vpsllvd", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vpsllvd", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vpsllvq", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vpsllvq", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, E(48) {"vpermil2ps", _128|_66|_0f3a|W0, {Vo, VVo, Wo, VIo, I4}}, {"vpermil2ps", _128|_66|_0f3a|W1, {Vo, VVo, VIo, Wo, I4}}, {"vpermil2ps", _256|_66|_0f3a|W0, {Yy, YVy, Xy, YIy, I4}}, {"vpermil2ps", _256|_66|_0f3a|W1, {Yy, YVy, YIy, Xy, I4}}, E(49) {"vpermil2pd", _128|_66|_0f3a|W0, {Vo, VVo, Wo, VIo, I4}}, {"vpermil2pd", _128|_66|_0f3a|W1, {Vo, VVo, VIo, Wo, I4}}, {"vpermil2pd", _256|_66|_0f3a|W0, {Yy, YVy, Xy, YIy, I4}}, {"vpermil2pd", _256|_66|_0f3a|W1, {Yy, YVy, YIy, Xy, I4}}, E(4a) {"vblendvps", _128|_66|_0f3a, {Vo, VVo, Wo, VIo}}, {"vblendvps", _256|_66|_0f3a, {Yy, YVy, Xy, YIy}}, E(4b) {"vblendvpd", _128|_66|_0f3a, {Vo, VVo, Wo, VIo}}, {"vblendvpd", _256|_66|_0f3a, {Yy, YVy, Xy, YIy}}, E(4c) {"vpblendvb", _128|_66|_0f3a, {Vo, VVo, Wo, VIo}}, {"vpblendvb", _256|_66|_0f3a, {Yy, YVy, Xy, VIo}}, E(50) {"vmovmskps", _128|_0f, {Gd, VRo}}, {"vmovmskps", _256|_0f, {Gd, YRy}}, {"vmovmskpd", _128|_66|_0f, {Gd, VRo}}, {"vmovmskpd", _256|_66|_0f, {Gd, YRy}}, E(51) {"vsqrtps", _128|_0f, {Vo, Wo}}, {"vsqrtps", _256|_0f, {Yy, Xy}}, {"vsqrtpd", _128|_66|_0f, {Vo, Wo}}, {"vsqrtpd", _256|_66|_0f, {Yy, Xy}}, {"vsqrtss", _128|_f3|_0f, {Vo, Wo}}, {"vsqrtsd", _128|_f2|_0f, {Vo, Wo}}, E(52) {"vrsqrtps", _128|_0f, {Vo, Wo}}, {"vrsqrtss", _128|_f3|_0f, {Vo, Wo}}, E(53) {"vrcpps", _128|_0f, {Vo, Wo}}, {"vrcpss", _128|_f3|_0f, {Vo, Wo}}, E(54) {"vandps", _128|_0f, {Vo, VVo, Wo}}, {"vandps", _256|_0f, {Yy, YVy, Xy}}, {"vandpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vandpd", _256|_66|_0f, {Yy, YVy, Xy}}, E(55) {"vandnps", _128|_0f, {Vo, VVo, Wo}}, {"vandnps", _256|_0f, {Yy, YVy, Xy}}, {"vandnpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vandnpd", _256|_66|_0f, {Yy, YVy, Xy}}, E(56) {"vorps", _128|_0f, {Vo, VVo, Wo}}, {"vorps", _256|_0f, {Yy, YVy, Xy}}, {"vorpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vorpd", _256|_66|_0f, {Yy, YVy, Xy}}, E(57) {"vxorps", _128|_0f, {Vo, VVo, Wo}}, {"vxorps", _256|_0f, {Yy, YVy, Xy}}, {"vxorpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vxorpd", _256|_66|_0f, {Yy, YVy, Xy}}, E(58) {"vaddps", _128|_0f, {Vo, VVo, Wo}}, {"vaddps", _256|_0f, {Yy, YVy, Xy}}, {"vaddpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vaddpd", _256|_66|_0f, {Yy, YVy, Xy}}, {"vaddss", _128|_f2|_0f, {Vo, VVo, Wo}}, {"vaddsd", _128|_f3|_0f, {Vo, VVo, Wo}}, {"vpbroadcastd", _128|_66|_0f38|W0, {Vo, Wd}}, {"vpbroadcastd", _256|_66|_0f38|W0, {Yy, Wd}}, E(59) {"vmulss", _128|_0f, {Vo, VVo, Wo}}, {"vmulps", _256|_0f, {Yy, YVy, Xy}}, {"vmulpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vmulpd", _256|_66|_0f, {Yy, YVy, Xy}}, {"vmulss", _128|_f2|_0f, {Vo, VVo, Wo}}, {"vmulsd", _128|_f3|_0f, {Vo, VVo, Wo}}, {"vpbroadcastq", _128|_66|_0f38|W0, {Vo, Wq}}, {"vpbroadcastq", _256|_66|_0f38|W0, {Yy, Wq}}, E(5a) {"vcvtps2pd", _128|_0f, {Vo, Wo}}, {"vcvtps2pd", _256|_0f, {Yy, Xy}}, {"vcvtpd2ps", _128|_66|_0f, {Vo, Wo}}, {"vcvtpd2ps", _256|_66|_0f, {Yy, Xy}}, {"vcvtss2sd", _128|_f3|_0f, {Vo, VVo, Wd}}, {"vcvtsd2ss", _128|_f2|_0f, {Vo, VVo, Wq}}, {"vbroadcasti128", _256|_66|_0f38, {Yy, Mo}}, E(5b) {"vcvtdq2ps", _128|_0f, {Vo, Wo}}, {"vcvtdq2ps", _256|_0f, {Yy, Xy}}, {"vcvtps2dq", _128|_66|_0f, {Vo, Wo}}, {"vcvtps2dq", _256|_66|_0f, {Yy, Xy}}, {"vcvttps2dq", _128|_f3|_0f, {Vo, Wo}}, {"vcvttps2dq", _256|_f3|_0f, {Yy, Xy}}, E(5c) {"vsubps", _128|_0f, {Vo, VVo, Wo}}, {"vsubps", _256|_0f, {Yy, YVy, Xy}}, {"vsubpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vsubpd", _256|_66|_0f, {Yy, YVy, Xy}}, {"vsubss", _128|_f2|_0f, {Vo, VVo, Wo}}, {"vsubsd", _128|_f3|_0f, {Vo, VVo, Wo}}, {"vfmaddsubps", _128|_66|_0f3a|W0, {Vo, VIo, Wo, VVo}}, {"vfmaddsubps", _128|_66|_0f3a|W1, {Vo, VIo, VVo, Wo}}, {"vfmaddsubps", _256|_66|_0f3a|W0, {Yy, YIy, Xy, YVy}}, {"vfmaddsubps", _256|_66|_0f3a|W1, {Yy, YIy, YVy, Xy}}, E(5d) {"vminps", _128|_0f, {Vo, VVo, Wo}}, {"vminps", _256|_0f, {Yy, YVy, Xy}}, {"vminpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vminpd", _256|_66|_0f, {Yy, YVy, Xy}}, {"vminss", _128|_f2|_0f, {Vo, VVo, Wo}}, {"vminsd", _128|_f3|_0f, {Vo, VVo, Wo}}, {"vfmaddsubpd", _128|_66|_0f3a|W0, {Vo, VIo, Wo, VVo}}, {"vfmaddsubpd", _128|_66|_0f3a|W1, {Vo, VIo, VVo, Wo}}, {"vfmaddsubpd", _256|_66|_0f3a|W0, {Yy, YIy, Xy, YVy}}, {"vfmaddsubpd", _256|_66|_0f3a|W1, {Yy, YIy, YVy, Xy}}, E(5e) {"vdivps", _128|_0f, {Vo, VVo, Wo}}, {"vdivps", _256|_0f, {Yy, YVy, Xy}}, {"vdivpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vdivpd", _256|_66|_0f, {Yy, YVy, Xy}}, {"vdivss", _128|_f2|_0f, {Vo, VVo, Wo}}, {"vdivsd", _128|_f3|_0f, {Vo, VVo, Wo}}, {"vfmsubaddps", _128|_66|_0f3a|W0, {Vo, VIo, Wo, VVo}}, {"vfmsubaddps", _128|_66|_0f3a|W1, {Vo, VIo, VVo, Wo}}, {"vfmsubaddps", _256|_66|_0f3a|W0, {Yy, YIy, Xy, YVy}}, {"vfmsubaddps", _256|_66|_0f3a|W1, {Yy, YIy, YVy, Xy}}, E(5f) {"vmaxps", _128|_0f, {Vo, VVo, Wo}}, {"vmaxps", _256|_0f, {Yy, YVy, Xy}}, {"vmaxpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vmaxpd", _256|_66|_0f, {Yy, YVy, Xy}}, {"vmaxss", _128|_f2|_0f, {Vo, VVo, Wo}}, {"vmaxsd", _128|_f3|_0f, {Vo, VVo, Wo}}, {"vfmsubaddpd", _128|_66|_0f3a|W0, {Vo, VIo, Wo, VVo}}, {"vfmsubaddpd", _128|_66|_0f3a|W1, {Vo, VIo, VVo, Wo}}, {"vfmsubaddpd", _256|_66|_0f3a|W0, {Yy, YIy, Xy, YVy}}, {"vfmsubaddpd", _256|_66|_0f3a|W1, {Yy, YIy, YVy, Xy}}, E(60) {"vpcmpestrm", _128|_66|_0f3a, {Vo, Wo, Ib}}, {"vpunpcklbw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpunpcklbw", _256|_66|_0f, {Yy, YVy, Xy}}, E(61) {"vpcmpestri", _128|_66|_0f3a, {Vo, Wo, Ib}}, {"vpunpcklwd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpunpcklwd", _256|_66|_0f, {Yy, YVy, Xy}}, E(62) {"vpcmpistrm", _128|_66|_0f3a, {Vo, Wo, Ib}}, {"vpunpckldq", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpunpckldq", _256|_66|_0f, {Yy, YVy, Xy}}, E(63) {"vpcmpistri", _128|_66|_0f3a, {Vo, Wo, Ib}}, {"vpacksswb", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpacksswb", _256|_66|_0f, {Yy, YVy, Xy}}, E(64) {"vpcmpgtb", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpcmpgtb", _256|_66|_0f, {Yy, YVy, Xy}}, E(65) {"vpcmpgtw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpcmpgtw", _256|_66|_0f, {Yy, YVy, Xy}}, E(66) {"vpcmpgtd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpcmpgtd", _256|_66|_0f, {Yy, YVy, Xy}}, E(67) {"vpackuswb", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpackuswb", _256|_66|_0f, {Yy, YVy, Xy}}, E(68) {"vpunpckhbw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpunpckhbw", _256|_66|_0f, {Yy, YVy, Xy}}, {"vfmaddps", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfmaddps", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, {"vfmaddps", _256|_66|_0f3a|W0, {Yy, YIy, YVy, Xy}}, {"vfmaddps", _256|_66|_0f3a|W1, {Yy, YIy, Xy, YVy}}, E(69) {"vpunpckhwd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpunpckhwd", _256|_66|_0f, {Yy, YVy, Xy}}, {"vfmaddpd", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfmaddpd", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, {"vfmaddpd", _256|_66|_0f3a|W0, {Yy, YIy, YVy, Xy}}, {"vfmaddpd", _256|_66|_0f3a|W1, {Yy, YIy, Xy, YVy}}, E(6a) {"vpunpckhdq", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpunpckhdq", _256|_66|_0f, {Yy, YVy, Xy}}, {"vfmaddss", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfmaddss", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, E(6b) {"vpackssdw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpackssdw", _256|_66|_0f, {Yy, YVy, Xy}}, {"vfmaddsd", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfmaddsd", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, E(6c) {"vpunpcklqdq", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpunpcklqdq", _256|_66|_0f, {Yy, YVy, Xy}}, {"vfmsubps", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfmsubps", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, {"vfmsubps", _256|_66|_0f3a|W0, {Yy, YIy, YVy, Xy}}, {"vfmsubps", _256|_66|_0f3a|W1, {Yy, YIy, Xy, YVy}}, E(6d) {"vpunpckhqdq", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpunpckhqdq", _256|_66|_0f, {Yy, YVy, Xy}}, {"vfmsubpd", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfmsubpd", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, {"vfmsubpd", _256|_66|_0f3a|W0, {Yy, YIy, YVy, Xy}}, {"vfmsubpd", _256|_66|_0f3a|W1, {Yy, YIy, Xy, YVy}}, E(6e) {"vmovd", _128|_66|_0f|W0, {Vo, Ed}}, {"vmovq", _128|_66|_0f|W1, {Vo, Eq}}, {"vfmsubss", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfmsubss", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, E(6f) {"vmovdqa", _128|_66|_0f, {Vo, Wo}}, {"vmovdqa", _256|_66|_0f, {Yy, Xy}}, {"vmovdqu", _128|_f3|_0f, {Vo, Wo}}, {"vmovdqu", _256|_f3|_0f, {Yy, Xy}}, {"vfmsubsd", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfmsubsd", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, E(70) {"vpshufd", _128|_66|_0f, {Vo, Wo, Ib}}, {"vpshufd", _256|_66|_0f, {Yy, Xy, Ib}}, {"vpshufhw", _128|_f3|_0f, {Vo, Wo, Ib}}, {"vpshufhw", _256|_f3|_0f, {Yy, Xy, Ib}}, {"vpshuflw", _128|_f2|_0f, {Vo, Wo, Ib}}, {"vpshuflw", _256|_f2|_0f, {Yy, Xy, Ib}}, E(71) {0, _128|_66|_0f, {SPECIAL_TYPE_GROUP, GROUP_660F71}}, E(72) {0, _128|_66|_0f, {SPECIAL_TYPE_GROUP, GROUP_660F72}}, E(73) {0, _128|_66|_0f, {SPECIAL_TYPE_GROUP, GROUP_660F73}}, E(74) {"vpcmpeqb", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpcmpeqb", _256|_66|_0f, {Yy, YVy, Xy}}, E(75) {"vpcmpeqw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpcmpeqw", _256|_66|_0f, {Yy, YVy, Xy}}, E(76) {"vpcmpeqd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpcmpeqd", _256|_66|_0f, {Yy, YVy, Xy}}, E(77) {"vzeroupper", _128|_0f}, {"vzeroall", _256|_0f}, E(78) {"vpbroadcastb", _128|_66|_0f38|W0, {Vo, Wb}}, {"vpbroadcastb", _256|_66|_0f38|W0, {Yy, Wb}}, {"vfnmaddps", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfnmaddps", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, {"vfnmaddps", _256|_66|_0f3a|W0, {Yy, YIy, YVy, Xy}}, {"vfnmaddps", _256|_66|_0f3a|W1, {Yy, YIy, Xy, YVy}}, E(79) {"vpbroadcastw", _128|_66|_0f38|W0, {Vo, Ww}}, {"vpbroadcastw", _256|_66|_0f38|W0, {Yy, Ww}}, {"vfnmaddpd", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfnmaddpd", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, {"vfnmaddpd", _256|_66|_0f3a|W0, {Yy, YIy, YVy, Xy}}, {"vfnmaddpd", _256|_66|_0f3a|W1, {Yy, YIy, Xy, YVy}}, E(7a) {"vfnmaddss", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfnmaddss", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, E(7b) {"vfnmaddsd", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfnmaddsd", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, E(7c) {"vhaddpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vhaddpd", _256|_66|_0f, {Yy, YVy, Xy}}, {"vhaddss", _128|_f2|_0f, {Vo, VVo, Wo}}, {"vhaddss", _256|_f2|_0f, {Yy, YVy, Xy}}, {"vfnmsubps", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfnmsubps", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, {"vfnmsubps", _256|_66|_0f3a|W0, {Yy, YIy, YVy, Xy}}, {"vfnmsubps", _256|_66|_0f3a|W1, {Yy, YIy, Xy, YVy}}, E(7d) {"vhsubpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vhsubpd", _256|_66|_0f, {Yy, YVy, Xy}}, {"vhsubss", _128|_f2|_0f, {Vo, VVo, Wo}}, {"vhsubss", _256|_f2|_0f, {Yy, YVy, Xy}}, {"vfnmsubpd", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfnmsubpd", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, {"vfnmsubpd", _256|_66|_0f3a|W0, {Yy, YIy, YVy, Xy}}, {"vfnmsubpd", _256|_66|_0f3a|W1, {Yy, YIy, Xy, YVy}}, E(7e) {"vmovd", _128|_66|_0f|W0, {Ed, Vo}}, {"vmovq", _128|_66|_0f|W1, {Eq, Vo}}, {"vmovq", _128|_f3|_0f, {Vo, Wq}}, {"vfnmsubss", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfnmsubss", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, E(7f) {"vmovdqa", _128|_66|_0f, {Wo, Vo}}, {"vmovdqa", _256|_66|_0f, {Xy, Yy}}, {"vmovdqu", _128|_f3|_0f, {Wo, Vo}}, {"vmovdqu", _256|_f3|_0f, {Xy, Yy}}, {"vfnmsubsd", _128|_66|_0f3a|W0, {Vo, VIo, VVo, Wo}}, {"vfnmsubsd", _128|_66|_0f3a|W1, {Vo, VIo, Wo, VVo}}, E(80) {"vfrczpd", _128|_0f25, {Vo, Wo}}, {"vfrczpd", _256|_0f25, {Yy, Xy}}, E(81) {"vfrczps", _128|_0f25, {Vo, Wo}}, {"vfrczps", _256|_0f25, {Yy, Xy}}, E(82) {"vfrczsd", _128|_0f25, {Vo, Wo}}, {"vfrczsd", _256|_0f25, {Yy, Xy}}, E(83) {"vfrczss", _128|_0f25, {Vo, Wo}}, {"vfrczss", _256|_0f25, {Yy, Xy}}, E(85) {"vpmacssww", _128|_0f24, {Vo, VVo, Wo, VIo}}, E(86) {"vpmacsswd", _128|_0f24, {Vo, VVo, Wo, VIo}}, E(87) {"vpmacssdql", _128|_0f24, {Vo, VVo, Wo, VIo}}, E(8c) {"vpmaskmovd", _128|_66|_0f38|W0, {Vo, VVo, Mo}}, {"vpmaskmovd", _256|_66|_0f38|W0, {Yy, YVy, My}}, {"vpmaskmovq", _128|_66|_0f38|W1, {Vo, VVo, Mo}}, {"vpmaskmovq", _256|_66|_0f38|W1, {Yy, YVy, My}}, E(8e) {"vpmacssdd", _128|_0f24, {Vo, VVo, Wo, VIo}}, {"vpmaskmovd", _128|_66|_0f38|W0, {Mo, VVo, Vo}}, {"vpmaskmovd", _256|_66|_0f38|W0, {My, YVy, Yy}}, {"vpmaskmovq", _128|_66|_0f38|W1, {Mo, VVo, Vo}}, {"vpmaskmovq", _256|_66|_0f38|W1, {My, YVy, Yy}}, E(8f) {"vpmacssdqh", _128|_0f24, {Vo, VVo, Wo, VIo}}, E(90) {"vprotb", _128|_0f25|W0, {Vo, Wo, VVo}}, {"vprotb", _128|_0f25|W1, {Vo, VVo, Wo}}, {"vpgatherdd", _128|_66|_0f38|W0, {Vo, Wd, VVo}}, {"vpgatherdd", _256|_66|_0f38|W0, {Yy, Xd, YVy}}, {"vpgatherdq", _128|_66|_0f38|W1, {Vo, Wd, VVo}}, {"vpgatherdq", _256|_66|_0f38|W1, {Yy, Xd, YVy}}, E(91) {"vprotw", _128|_0f25|W0, {Vo, Wo, VVo}}, {"vprotw", _128|_0f25|W1, {Vo, VVo, Wo}}, {"vpgatherqd", _128|_66|_0f38|W0, {Vo, Wq, VVo}}, {"vpgatherqd", _256|_66|_0f38|W0, {Yy, Xq, YVy}}, {"vpgatherqq", _128|_66|_0f38|W1, {Vo, Wq, VVo}}, {"vpgatherqq", _256|_66|_0f38|W1, {Yy, Xq, YVy}}, E(92) {"vprotd", _128|_0f25|W0, {Vo, Wo, VVo}}, {"vprotd", _128|_0f25|W1, {Vo, VVo, Wo}}, {"vgatherdps", _128|_66|_0f38|W0, {Vo, Wd, VVo}}, {"vgatherdps", _256|_66|_0f38|W0, {Yy, Xd, YVy}}, {"vgatherdpd", _128|_66|_0f38|W1, {Vo, Wd, VVo}}, {"vgatherdpd", _256|_66|_0f38|W1, {Yy, Xd, YVy}}, E(93) {"vprotq", _128|_0f25|W0, {Vo, Wo, VVo}}, {"vprotq", _128|_0f25|W1, {Vo, VVo, Wo}}, {"vgatherqps", _128|_66|_0f38|W0, {Vo, Wq, VVo}}, {"vgatherqps", _256|_66|_0f38|W0, {Yy, Xq, YVy}}, {"vgatherqpd", _128|_66|_0f38|W1, {Vo, Wq, VVo}}, {"vgatherqpd", _256|_66|_0f38|W1, {Yy, Xq, YVy}}, E(94) {"vpshlb", _128|_0f25|W0, {Vo, Wo, VVo}}, {"vpshlb", _128|_0f25|W1, {Vo, VVo, Wo}}, E(95) {"vpmacsww", _128|_0f24, {Vo, VVo, Wo, VIo}}, {"vpshlw", _128|_0f25|W0, {Vo, Wo, VVo}}, {"vpshlw", _128|_0f25|W1, {Vo, VVo, Wo}}, E(96) {"vfmaddsub132ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmaddsub132ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfmaddsub132pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfmaddsub132pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, {"vpmacswd", _128|_0f24, {Vo, VVo, Wo, VIo}}, {"vpshld", _128|_0f25|W0, {Vo, Wo, VVo}}, {"vpshld", _128|_0f25|W1, {Vo, VVo, Wo}}, E(97) {"vfmaddsub132ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmaddsub132sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vpmacsdql", _128|_0f24, {Vo, VVo, Wo, VIo}}, {"vpshlq", _128|_0f25|W0, {Vo, Wo, VVo}}, {"vpshlq", _128|_0f25|W1, {Vo, VVo, Wo}}, E(98) {"vfmadd132ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmadd132ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfmadd132pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfmadd132pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, {"vpshab", _128|_0f25|W0, {Vo, Wo, VVo}}, {"vpshab", _128|_0f25|W1, {Vo, VVo, Wo}}, E(99) {"vfmadd132ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmadd132sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vpshaw", _128|_0f25|W0, {Vo, Wo, VVo}}, {"vpshaw", _128|_0f25|W1, {Vo, VVo, Wo}}, E(9a) {"vfmsub132ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmsub132ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfmsub132pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfmsub132pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, {"vpshad", _128|_0f25|W0, {Vo, Wo, VVo}}, {"vpshad", _128|_0f25|W1, {Vo, VVo, Wo}}, E(9b) {"vfmsub132ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmsub132sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vpshaq", _128|_0f25|W0, {Vo, Wo, VVo}}, {"vpshaq", _128|_0f25|W1, {Vo, VVo, Wo}}, E(9c) {"vfnmadd132ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfnmadd132ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfnmadd132pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfnmadd132pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, E(9d) {"vfnmadd132ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfnmadd132sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, E(9e) {"vfnmsub132ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfnmsub132ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfnmsub132pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfnmsub132pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, {"vpmacsdd", _128|_0f24, {Vo, VVo, Wo, VIo}}, E(9f) {"vfnmsub132ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfnmsub132sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vpmacsdqh", _128|_0f24, {Vo, VVo, Wo, VIo}}, E(a0) {"vcvtph2ps", _128|_0f24, {Vo, Wq, Ib}}, {"vcvtph2ps", _256|_0f24, {Yy, Xo, Ib}}, E(a1) {"vcvtps2ph", _128|_0f25, {Wq, Vo}}, {"vcvtps2ph", _256|_0f25, {Xo, Yy}}, E(a2) {"vpcmov", _128|_0f24|W0, {Vo, VVo, Wo, VIo}}, {"vpcmov", _256|_0f24|W0, {Yy, YVy, Xy, YIy}}, {"vpcmov", _128|_0f24|W1, {Vo, VVo, VIo, Wo}}, {"vpcmov", _256|_0f24|W1, {Yy, YVy, YIy, Xy}}, E(a3) {"vpperm", _128|_0f24|W0, {Vo, VVo, Wo, VIo}}, {"vpperm", _128|_0f24|W1, {Vo, VVo, VIo, Wo}}, E(a6) {"vfmaddsub213ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmaddsub213ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfmaddsub213pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfmaddsub213pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, {"vpmadcsswd", _128|_0f24, {Vo, VVo, Wo, VIo}}, E(a7) {"vfmaddsub213ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmaddsub213sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, E(a8) {"vfmadd213ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmadd213ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfmadd213pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfmadd213pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, E(a9) {"vfmadd213ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmadd213sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, E(aa) {"vfmsub213ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmsub213ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfmsub213pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfmsub213pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, E(ab) {"vfmsub213ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmsub213sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, E(ac) {"vfnmadd213ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfnmadd213ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfnmadd213pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfnmadd213pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, E(ad) {"vfnmadd213ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfnmadd213sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, E(ae) {0, _0f, {SPECIAL_TYPE_GROUP, GROUP_0FAE}}, {"vfnmsub213ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfnmsub213ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfnmsub213pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfnmsub213pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, E(af) {"vfnmsub213ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfnmsub213sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, E(b6) {"vfmaddsub231ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmaddsub231ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfmaddsub231pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfmaddsub231pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, {"vpmadcswd", _128|_0f24, {Vo, VVo, Wo, VIo}}, E(b7) {"vfmaddsub231ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmaddsub231sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, E(b8) {"vfmadd231ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmadd231ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfmadd231pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfmadd231pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, E(b9) {"vfmadd231ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmadd231sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, E(ba) {"vfmsub231ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmsub231ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfmsub231pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfmsub231pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, E(bb) {"vfmsub231ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfmsub231sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, E(bc) {"vfnmadd231ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfnmadd231ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfnmadd231pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfnmadd231pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, E(bd) {"vfnmadd231ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfnmadd231sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, E(be) {"vfnmsub231ps", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfnmsub231ps", _256|_66|_0f38|W0, {Yy, YVy, Xy}}, {"vfnmsub231pd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, {"vfnmsub231pd", _256|_66|_0f38|W1, {Yy, YVy, Xy}}, E(bf) {"vfnmsub231ss", _128|_66|_0f38|W0, {Vo, VVo, Wo}}, {"vfnmsub231sd", _128|_66|_0f38|W1, {Vo, VVo, Wo}}, E(c0) {"vprotb", _128|_0f24, {Vo, Wo, Ib}}, E(c1) {"vprotw", _128|_0f24, {Vo, Wo, Ib}}, {"vphaddbw", _128|_0f25, {Vo, Wo}}, E(c2) {"vcmpps", _128|_0f, {Vo, VVo, Wo, Ib}}, {"vcmpps", _256|_0f, {Yy, YVy, Xy, Ib}}, {"vcmppd", _128|_66|_0f, {Vo, VVo, Wo, Ib}}, {"vcmppd", _256|_66|_0f, {Yy, YVy, Xy, Ib}}, {"vcmpss", _128|_f2|_0f, {Vo, VVo, Wo, Ib}}, {"vcmpsd", _128|_f3|_0f, {Vo, VVo, Wo, Ib}}, {"vprotd", _128|_0f24, {Vo, Wo, Ib}}, {"vphaddbd", _128|_0f25, {Vo, Wo}}, E(c3) {"vprotq", _128|_0f24, {Vo, Wo, Ib}}, {"vphaddbd", _128|_0f25, {Vo, Wo}}, E(c4) {"pinsrw", _128|_66|_0f, {Vo, MRwr, Ib}}, E(c5) {"vpextrw", _128|_66|_0f, {Gr, VRo, Ib}}, E(c6) {"vshufps", _128|_0f, {Vo, VVo, Wo, Ib}}, {"vshufps", _256|_0f, {Yy, YVy, Xy, Ib}}, {"vshufpd", _128|_66|_0f, {Vo, VVo, Wo, Ib}}, {"vshufpd", _256|_66|_0f, {Yy, YVy, Xy, Ib}}, {"vphadddwd", _128|_0f25, {Vo, Wo}}, E(c7) {"vphadddwq", _128|_0f25, {Vo, Wo}}, E(cb) {"vphadddq", _128|_0f25, {Vo, Wo}}, E(cc) {"vpcomb", _128|_0f24, {Vo, VVo, Wo, Ib}}, E(cd) {"vpcomw", _128|_0f24, {Vo, VVo, Wo, Ib}}, E(ce) {"vpcomd", _128|_0f24, {Vo, VVo, Wo, Ib}}, E(cf) {"vpcomq", _128|_0f24, {Vo, VVo, Wo, Ib}}, E(d0) {"vaddsubpd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vaddsubpd", _256|_66|_0f, {Yy, YVy, Xy}}, {"vaddsubss", _128|_f2|_0f, {Vo, VVo, Wo}}, {"vaddsubss", _256|_f2|_0f, {Yy, YVy, Xy}}, E(d1) {"vpsrlw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpsrlw", _256|_66|_0f, {Yy, YVy, Xy}}, {"vphaddubw", _128|_0f25, {Vo, Wo}}, E(d2) {"vpsrld", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpsrld", _256|_66|_0f, {Yy, YVy, Xy}}, {"vphaddubd", _128|_0f25, {Vo, Wo}}, E(d3) {"vpsrlq", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpsrlq", _256|_66|_0f, {Yy, YVy, Xy}}, {"vphaddubq", _128|_0f25, {Vo, Wo}}, E(d4) {"vpaddq", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpaddq", _256|_66|_0f, {Yy, YVy, Xy}}, E(d5) {"vpmullw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpmullw", _256|_66|_0f, {Yy, YVy, Xy}}, E(d6) {"vmovq", _128|_66|_0f, {Wq, Vo}}, {"vphadduwd", _128|_0f25, {Vo, Wo}}, E(d7) {"vpmovmskb", _128|_66|_0f, {Gd, VRo}}, {"vpmovmskb", _256|_66|_0f, {Gq, YRy}}, {"vphadduwq", _128|_0f25, {Vo, Wo}}, {"vphaddwq", _128|_0f25, {Vo, Wo}}, // FIXME E(d8) {"vpsubusb", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpsubusb", _256|_66|_0f, {Yy, YVy, Xy}}, E(d9) {"vpsubusw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpsubusw", _256|_66|_0f, {Yy, YVy, Xy}}, E(da) {"vpminub", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpminub", _256|_66|_0f, {Yy, YVy, Xy}}, E(db) {"vpand", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpand", _256|_66|_0f, {Yy, YVy, Xy}}, {"vaesimc", _128|_66|_0f38, {Vo, Wo}}, {"vphaddudq", _128|_0f25, {Vo, Wo}}, E(dc) {"vpaddusb", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpaddusb", _256|_66|_0f, {Yy, YVy, Xy}}, {"vaesenc", _128|_66|_0f38, {Vo, VVo, Wo}}, E(dd) {"vpaddusw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpaddusw", _256|_66|_0f, {Yy, YVy, Xy}}, {"vaesenclast", _128|_66|_0f38, {Vo, VVo, Wo}}, E(de) {"vpmaxub", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpmaxub", _256|_66|_0f, {Yy, YVy, Xy}}, {"vaesdec", _128|_66|_0f38, {Vo, VVo, Wo}}, E(df) {"vpandn", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpandn", _256|_66|_0f, {Yy, YVy, Xy}}, {"vaesdeclast", _128|_66|_0f38, {Vo, VVo, Wo}}, {"vaeskeygenassist", _128|_66|_0f3a, {Vo, Wo, Ib}}, E(e0) {"vpavgb", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpavgb", _256|_66|_0f, {Yy, YVy, Xy}}, E(e1) {"vpsraw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vphsubbw", _128|_0f25, {Vo, Wo}}, E(e2) {"vpsrad", _128|_66|_0f, {Vo, VVo, Wo}}, {"vphsubwd", _128|_0f25, {Vo, Wo}}, E(e3) {"vpavgw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpavgw", _256|_66|_0f, {Yy, YVy, Xy}}, {"vphsubdq", _128|_0f25, {Vo, Wo}}, E(e4) {"vpmulhuw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpmulhuw", _256|_66|_0f, {Yy, YVy, Xy}}, E(e5) {"vpmulhw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpmulhw", _256|_66|_0f, {Yy, YVy, Xy}}, E(e6) {"vcvtdq2pd", _128|_f3|_0f, {Vo, Wo}}, {"vcvtdq2pd", _256|_f3|_0f, {Yy, Xy}}, {"vcvtpd2dq", _128|_f2|_0f, {Vo, Wo}}, {"vcvtpd2dq", _256|_f2|_0f, {Yy, Xy}}, {"vcvttpd2dq", _128|_66|_0f, {Vo, Wo}}, {"vcvttpd2dq", _256|_66|_0f, {Yy, Xy}}, E(e7) {"vmovntdq", _128|_66|_0f, {Mo, Vo}}, {"vmovntdq", _256|_66|_0f, {My, Yy}}, E(e8) {"vpsubsb", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpsubsb", _256|_66|_0f, {Yy, YVy, Xy}}, E(e9) {"vpsubsw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpsubsw", _256|_66|_0f, {Yy, YVy, Xy}}, E(ea) {"vpminsw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpminsw", _256|_66|_0f, {Yy, YVy, Xy}}, E(eb) {"vpor", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpor", _256|_66|_0f, {Yy, YVy, Xy}}, E(ec) {"vpaddsb", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpaddsb", _256|_66|_0f, {Yy, YVy, Xy}}, {"vpcomub", _128|_0f24, {Vo, VVo, Wo, Ib}}, E(ed) {"vpaddsw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpaddsw", _256|_66|_0f, {Yy, YVy, Xy}}, {"vpcomuw", _128|_0f24, {Vo, VVo, Wo, Ib}}, E(ee) {"vpmaxsw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpmaxsw", _256|_66|_0f, {Yy, YVy, Xy}}, {"vpcomud", _128|_0f24, {Vo, VVo, Wo, Ib}}, E(ef) {"vpxor", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpxor", _256|_66|_0f, {Yy, YVy, Xy}}, {"vpcomuq", _128|_0f24, {Vo, VVo, Wo, Ib}}, E(f0) {"vlddqu", _128|_f2|_0f, {Vo, Mo}}, {"vlddqu", _256|_f2|_0f, {Yy, My}}, {"rorx", _128|_f2|_0f3a|W0, {Gd, Ed, Ib}}, {"rorx", _128|_f2|_0f3a|W1, {Gq, Eq, Ib}}, E(f1) {"vpsllw", _128|_66|_0f, {Vo, VVo, Wo}}, E(f2) {"vpslld", _128|_66|_0f, {Vo, VVo, Wo}}, {"andn", _128|_0f38|W0, {Gd, RVd, Ed}}, {"andn", _128|_0f38|W1, {Gq, RVq, Eq}}, E(f3) {0, _128|_0f38|W0, {SPECIAL_TYPE_GROUP, GROUP_0F38_F3}}, {0, _128|_0f38|W1, {SPECIAL_TYPE_GROUP, GROUP_0F38_F3_W}}, {"vpsllq", _128|_66|_0f, {Vo, VVo, Wo}}, E(f4) {"vpmuludq", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpmuludq", _256|_66|_0f, {Yy, YVy, Xy}}, E(f5) {"vpmaddwd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpmaddwd", _256|_66|_0f, {Yy, YVy, Xy}}, {"bzhi", _128|_0f38|W0, {Gd, RVd, Ed}}, {"bzhi", _128|_0f38|W1, {Gq, RVq, Eq}}, {"pdep", _128|_f2|_0f38|W0, {Gd, RVd, Ed}}, {"pdep", _128|_f2|_0f38|W1, {Gq, RVq, Eq}}, {"pext", _128|_f3|_0f38|W0, {Gd, RVd, Ed}}, {"pext", _128|_f3|_0f38|W1, {Gq, RVq, Eq}}, E(f6) {"vpsadbw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpsadbw", _256|_66|_0f, {Yy, YVy, Xy}}, {"mulx", _128|_f2|_0f38|W0, {Gd, RVd, Ed}}, {"mulx", _128|_f2|_0f38|W1, {Gq, RVq, Eq}}, E(f7) {"vmaskmovdqu", _128|_66|_0f, {Vo, VRo}}, {"bextr", _128|_0f38|W0, {Gd, RVd, Ed}}, {"bextr", _128|_0f38|W1, {Gq, RVq, Eq}}, {"sarx", _128|_f3|_0f38|W0, {Gd, RVd, Ed}}, {"sarx", _128|_f3|_0f38|W1, {Gq, RVq, Eq}}, {"shlx", _128|_66|_0f38|W0, {Gd, RVd, Ed}}, {"shlx", _128|_66|_0f38|W1, {Gq, RVq, Eq}}, {"shlx", _128|_f2|_0f38|W0, {Gd, RVd, Ed}}, {"shlx", _128|_f2|_0f38|W1, {Gq, RVq, Eq}}, E(f8) {"vpsubb", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpsubb", _256|_66|_0f, {Yy, YVy, Xy}}, E(f9) {"vpsubw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpsubw", _256|_66|_0f, {Yy, YVy, Xy}}, E(fa) {"vpsubd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpsubd", _256|_66|_0f, {Yy, YVy, Xy}}, E(fb) {"vpsubq", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpsubq", _256|_66|_0f, {Yy, YVy, Xy}}, E(fc) {"vpaddb", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpaddb", _256|_66|_0f, {Yy, YVy, Xy}}, E(fd) {"vpaddw", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpaddw", _256|_66|_0f, {Yy, YVy, Xy}}, E(fe) {"vpaddd", _128|_66|_0f, {Vo, VVo, Wo}}, {"vpaddd", _256|_66|_0f, {Yy, YVy, Xy}}, Elast x86opc_vex_insn x86_group_vex_insns[][8] = { /* 0 - GROUP_0FAE */ { {0}, {0}, {"vldmxcsr", _0f, {Md}}, {"vstmxcsr", _0f, {Md}}, {0}, {0}, {0}, {0}, }, /* 1 - GROUP_660F71 */ { {0}, {0}, {"vpsrlw", _128|_66|_0f, {VVo, VRo, Ib}}, {0}, {"vpsraw", _128|_66|_0f, {VVo, VRo, Ib}}, {0}, {"vpsllw", _128|_66|_0f, {VVo, VRo, Ib}}, {0}, }, /* 2 - GROUP_660F72 */ { {0}, {0}, {"vpsrld", _128|_66|_0f, {VVo, VRo, Ib}}, {0}, {"vpsrad", _128|_66|_0f, {VVo, VRo, Ib}}, {0}, {"vpslld", _128|_66|_0f, {VVo, VRo, Ib}}, {0}, }, /* 3 - GROUP_660F73 */ { {0}, {0}, {"vpsrlq", _128|_66|_0f, {VVo, VRo, Ib}}, {"vpsrldq", _128|_66|_0f, {VVo, VRo, Ib}}, {0}, {0}, {"vpsllq", _128|_66|_0f, {VVo, VRo, Ib}}, {"vpslldq", _128|_66|_0f, {VVo, VRo, Ib}}, }, /* 4 - GROUP_0F25_12 */ { {"llwpcb", _128|_0f25|W0, {Rw}}, {"slwpcb", _128|_0f25|W0, {Rw}}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 5 - GROUP_0F25_12_L */ { {"llwpcb", _256|_0f25|W0, {Rd}}, {"slwpcb", _256|_0f25|W0, {Rd}}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 6 - GROUP_0F25_12_W */ { {"llwpcb", _128|_0f25|W1, {Rq}}, {"slwpcb", _128|_0f25|W1, {Rq}}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 7 - GROUP_0FA_12 */ { {"lwpins", _128|_0fA, {RVw, Ed, Iw}}, {"lwpval", _128|_0fA, {RVw, Ed, Iw}}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 8 - GROUP_0FA_12_L */ { {"lwpins", _256|_0fA, {RVd, Ed, Id}}, {"lwpval", _256|_0fA, {RVd, Ed, Id}}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 9 - GROUP_0FA_12_W */ { {"lwpins", _128|_0fA|W1, {RVq, Ed, Id}}, {"lwpval", _128|_0fA|W1, {RVq, Ed, Id}}, {0}, {0}, {0}, {0}, {0}, {0}, }, /* 12 - GROUP_0F38_F3 */ { {0}, {"blsr", _128|_0f38|W0, {RVd, Ed}}, {"blsmsk", _128|_0f38|W0, {RVd, Ed}}, {"blsi", _128|_0f38|W0, {RVd, Ed}}, {0}, {0}, {0}, {0}, }, /* 11 - GROUP_0F38_F3_W */ { {0}, {"blsr", _128|_0f38|W1, {RVq, Eq}}, {"blsmsk", _128|_0f38|W1, {RVq, Eq}}, {"blsi", _128|_0f38|W1, {RVq, Eq}}, {0}, {0}, {0}, {0}, }, }; x86opc_vex_insn *x86_vex_insns[256] = { v00, v01, v02, v03, v04, v05, v06, v07, v08, v09, v0a, v0b, v0c, v0d, v0e, v0f, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v1a, 0, v1c, v1d, v1e, 0, v20, v21, v22, v23, v24, v25, 0, 0, v28, v29, v2a, v2b, v2c, v2d, v2e, v2f, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v3a, v3b, v3c, v3d, v3e, v3f, v40, v41, v42, 0, v44, v45, v46, v47, v48, v49, v4a, v4b, v4c, 0, 0, 0, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v5a, v5b, v5c, v5d, v5e, v5f, v60, v61, v62, v63, v64, v65, v66, v67, v68, v69, v6a, v6b, v6c, v6d, v6e, v6f, v70, v71, v72, v73, v74, v75, v76, v77, v78, v79, v7a, v7b, v7c, v7d, v7e, v7f, v80, v81, v82, v83, 0, v85, v86, v87, 0, 0, 0, 0, v8c, 0, v8e, v8f, v90, v91, v92, v93, v94, v95, v96, v97, v98, v99, v9a, v9b, v9c, v9d, v9e, v9f, va0, va1, va2, va3, 0, 0, va6, va7, va8, va9, vaa, vab, vac, vad, vae, vaf, 0, 0, 0, 0, 0, 0, vb6, vb7, vb8, vb9, vba, vbb, vbc, vbd, vbe, vbf, vc0, vc1, vc2, vc3, vc4, vc5, vc6, vc7, 0, 0, 0, vcb, vcc, vcd, vce, vcf, vd0, vd1, vd2, vd3, vd4, vd5, vd6, vd7, vd8, vd9, vda, vdb, vdc, vdd, vde, vdf, ve0, ve1, ve2, ve3, ve4, ve5, ve6, ve7, ve8, ve9, vea, veb, vec, ved, vee, vef, vf0, vf1, vf2, vf3, vf4, vf5, vf6, vf7, vf8, vf9, vfa, vfb, vfc, vfd, vfe, 0, }; ht-2.0.22/asm/ppcdis.h0000644000175000001440000000423110615342402011335 00000000000000/* * HT Editor * ppcdis.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __PPC_DIS_H__ #define __PPC_DIS_H__ #include "asm.h" #include "io/types.h" #include "ppcopc.h" struct ppcdis_operand { int flags; const powerpc_operand *op; union { int reg; // general register int freg; // float register int creg; // condition register int vreg; // vector register uint64 imm; struct { uint64 disp; int gr; } mem; struct { uint64 mem; } abs; struct { uint64 mem; } rel; }; }; struct ppcdis_insn { bool valid; int size; const char * name; uint32 data; int ops; ppcdis_operand op[8]; }; #define PPC_MODE_32 0 #define PPC_MODE_64 1 class PPCDisassembler: public Disassembler { protected: char insnstr[256]; ppcdis_insn insn; int mode; public: PPCDisassembler(int mode); PPCDisassembler(BuildCtorArg&a): Disassembler(a) {}; void load(ObjectStream &f); virtual dis_insn *decode(byte *code, int maxlen, CPU_ADDR addr); virtual dis_insn *duplicateInsn(dis_insn *disasm_insn); virtual void getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align); virtual byte getSize(dis_insn *disasm_insn); virtual const char *getName(); virtual const char *str(dis_insn *disasm_insn, int style); virtual const char *strf(dis_insn *disasm_insn, int style, const char *format); virtual ObjectID getObjectID() const; virtual bool validInsn(dis_insn *disasm_insn); virtual void store(ObjectStream &f) const; }; #endif ht-2.0.22/asm/ppcdis.cc0000644000175000001440000002126710615342402011503 00000000000000/* * HT Editor * ppcdis.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * Copyright 1994 Free Software Foundation, Inc. * Written by Ian Lance Taylor, Cygnus Support * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "endianess.h" #include "ppcdis.h" #include "ppcopc.h" #include "snprintf.h" #include "tools.h" PPCDisassembler::PPCDisassembler(int aMode) { mode = aMode; } void PPCDisassembler::load(ObjectStream &f) { Disassembler::load(f); GET_INT32X(f, mode); } dis_insn *PPCDisassembler::decode(byte *code, int maxlen, CPU_ADDR addr) { const struct powerpc_opcode *opcode; const struct powerpc_opcode *opcode_end; uint32 op; int dialect = -1; insn.data = createHostInt(code, 4, big_endian); if (maxlen < 4) { insn.valid = false; insn.size = maxlen; return &insn; } insn.size = 4; /* Get the major opcode of the instruction. */ op = PPC_OP(insn.data); /* Find the first match in the opcode table. We could speed this up a bit by doing a binary search on the major opcode. */ opcode_end = powerpc_opcodes + powerpc_num_opcodes; for (opcode = powerpc_opcodes; opcode < opcode_end; opcode++) { uint32 table_op; const byte *opindex; const struct powerpc_operand *operand; bool invalid; table_op = PPC_OP (opcode->opcode); if ((insn.data & opcode->mask) != opcode->opcode/* || (opcode->flags & dialect) == 0*/) { continue; } /* Make two passes over the operands. First see if any of them have extraction functions, and, if they do, make sure the instruction is valid. */ invalid = false; for (opindex = opcode->operands; *opindex != 0; opindex++) { operand = powerpc_operands + *opindex; if (operand->extract) (*operand->extract)(insn.data, &invalid); } if (invalid) continue; /* The instruction is valid. */ insn.name = opcode->name; /* Now extract and print the operands. */ int opidx = 0; for (opindex = opcode->operands; *opindex != 0; opindex++) { sint32 value; operand = powerpc_operands + *opindex; /* Operands that are marked FAKE are simply ignored. We already made sure that the extract function considered the instruction to be valid. */ if ((operand->flags & PPC_OPERAND_FAKE) != 0) continue; insn.op[opidx].op = operand; insn.op[opidx].flags = operand->flags; /* Extract the value from the instruction. */ if (operand->extract) { value = (*operand->extract)(insn.data, NULL); } else { value = (insn.data >> operand->shift) & ((1 << operand->bits) - 1); if ((operand->flags & PPC_OPERAND_SIGNED) != 0 && (value & (1 << (operand->bits - 1))) != 0) { value -= 1 << operand->bits; } } /* If the operand is optional, and the value is zero, don't print anything. */ if ((operand->flags & PPC_OPERAND_OPTIONAL) != 0 && (operand->flags & PPC_OPERAND_NEXT) == 0 && value == 0) { insn.op[opidx++].imm = 0; continue; } if (operand->flags & PPC_OPERAND_GPR_0) { if (value) { insn.op[opidx].flags |= PPC_OPERAND_GPR; insn.op[opidx++].reg = value; } else { insn.op[opidx].flags = 0; insn.op[opidx].imm = value; } } else if (operand->flags & PPC_OPERAND_GPR) { insn.op[opidx++].reg = value; } else if (operand->flags & PPC_OPERAND_FPR) { insn.op[opidx++].freg = value; } else if (operand->flags & PPC_OPERAND_VR) { insn.op[opidx++].vreg = value; } else if (operand->flags & PPC_OPERAND_RELATIVE) { if (mode == PPC_MODE_32) { insn.op[opidx++].rel.mem = addr.addr32.offset + value; } else { insn.op[opidx++].rel.mem = addr.flat64.addr + value; } } else if ((operand->flags & PPC_OPERAND_ABSOLUTE) != 0) { insn.op[opidx++].abs.mem = value; } else if ((operand->flags & PPC_OPERAND_CR) == 0 || (dialect & PPC_OPCODE_PPC) == 0) { insn.op[opidx++].imm = (sint64)value; } else { insn.op[opidx++].creg = value; } } insn.ops = opidx; /* We have found and printed an instruction; return. */ insn.valid = true; return &insn; } insn.valid = false; return &insn; } dis_insn *PPCDisassembler::duplicateInsn(dis_insn *disasm_insn) { ppcdis_insn *insn = ht_malloc(sizeof (ppcdis_insn)); *insn = *(ppcdis_insn *)disasm_insn; return insn; } void PPCDisassembler::getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align) { min_length = max_length = min_look_ahead = avg_look_ahead = addr_align = 4; } byte PPCDisassembler::getSize(dis_insn *disasm_insn) { return ((ppcdis_insn*)disasm_insn)->size; } const char *PPCDisassembler::getName() { return "PPC/Disassembler"; } const char *PPCDisassembler::str(dis_insn *disasm_insn, int style) { return strf(disasm_insn, style, ""); } const char *PPCDisassembler::strf(dis_insn *disasm_insn, int style, const char *format) { if (style & DIS_STYLE_HIGHLIGHT) enable_highlighting(); const char *cs_default = get_cs(e_cs_default); const char *cs_number = get_cs(e_cs_number); const char *cs_symbol = get_cs(e_cs_symbol); ppcdis_insn *ppc_insn = (ppcdis_insn *) disasm_insn; if (!ppc_insn->valid) { switch (ppc_insn->size) { case 1: strcpy(insnstr, "db ?"); break; case 2: strcpy(insnstr, "dw ?"); break; case 3: strcpy(insnstr, "db ? * 3"); break; case 4: sprintf(insnstr, "dd %s0x%08x", cs_number, ppc_insn->data); break; default: { /* braces for empty assert */ strcpy(insnstr, "?"); // assert(0); } } } else { char *is = insnstr+sprintf(insnstr, "%-13s", ppc_insn->name); int dialect=-1; bool need_comma = false; bool need_paren = false; for (int opidx = 0; opidx < ppc_insn->ops; opidx++) { int flags = ppc_insn->op[opidx].flags; /* if ((flags & PPC_OPERAND_OPTIONAL) != 0 && (flags & PPC_OPERAND_NEXT) == 0 && ppc_insn->op[opidx].imm == 0) { continue; }*/ if (need_comma) { is += sprintf(is, "%s, ", cs_symbol); need_comma = false; } if (flags & PPC_OPERAND_GPR) { is += sprintf(is, "%sr%d", cs_default, ppc_insn->op[opidx].reg); } else if ((flags & PPC_OPERAND_FPR) != 0) { is += sprintf(is, "%sf%d", cs_default, ppc_insn->op[opidx].freg); } else if ((flags & PPC_OPERAND_VR) != 0) { is += sprintf(is, "%svr%d", cs_default, ppc_insn->op[opidx].vreg); } else if ((flags & PPC_OPERAND_RELATIVE) != 0) { CPU_ADDR caddr; if (mode == PPC_MODE_32) { caddr.addr32.offset = (uint32)ppc_insn->op[opidx].mem.disp; } else { caddr.flat64.addr = ppc_insn->op[opidx].mem.disp; } int slen; char *s = (addr_sym_func) ? addr_sym_func(caddr, &slen, addr_sym_func_context) : 0; if (s) { is += sprintf(is, "%s", cs_default); memcpy(is, s, slen); is[slen] = 0; is += slen; } else { is += ht_snprintf(is, 100, "%s0x%qx", cs_number, ppc_insn->op[opidx].rel.mem); } } else if ((flags & PPC_OPERAND_ABSOLUTE) != 0) { is += ht_snprintf(is, 100, "%s0x%qx", cs_number, ppc_insn->op[opidx].abs.mem); } else if ((flags & PPC_OPERAND_CR) == 0 || (dialect & PPC_OPCODE_PPC) == 0) { is += ht_snprintf(is, 100, "%s%qd", cs_number, ppc_insn->op[opidx].imm); } else if (ppc_insn->op[opidx].op->bits == 3) { is += sprintf(is, "%scr%d", cs_default, ppc_insn->op[opidx].creg); } else { static const char *cbnames[4] = { "lt", "gt", "eq", "so" }; int cr; int cc; cr = ppc_insn->op[opidx].creg >> 2; if (cr != 0) is += sprintf(is, "%s4%s*%scr%d", cs_number, cs_symbol, cs_default, cr); cc = ppc_insn->op[opidx].creg & 3; if (cc != 0) { if (cr != 0) is += sprintf(is, "%s+", cs_symbol); is += sprintf(is, "%s%s", cs_default, cbnames[cc]); } } if (need_paren) { is += sprintf(is, "%s)", cs_symbol); need_paren = false; } if ((flags & PPC_OPERAND_PARENS) == 0) { need_comma = true; } else { is += sprintf(is, "%s(", cs_symbol); need_paren = true; } } } disable_highlighting(); return insnstr; } ObjectID PPCDisassembler::getObjectID() const { return ATOM_DISASM_PPC; } void PPCDisassembler::store(ObjectStream &f) const { PUT_INT32X(f, mode); } bool PPCDisassembler::validInsn(dis_insn *disasm_insn) { return ((ppcdis_insn*)disasm_insn)->valid; } ht-2.0.22/asm/alphaopc.cc0000644000175000001440000004732210615342401012007 00000000000000/* * HT Editor * alphaopc.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "alphaopc.h" const char *alpha_reg_names[] = { /* 0 */ "v0", /* 1- 8 */ "t0","t1","t2","t3","t4","t5","t6","t7", /* 9-15 */ "s0","s1","s2","s3","s4","s5","s6/fp", /* 16-21 */ "a0","a1","a2","a3","a4","a5", /* 22-25 */ "t8","t9","t10","t11", /* 26-31 */ "ra","t12/pv","at","gp","sp","zero", /* 32-39 */ "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", /* 40-47 */ "f8", "f9", "f10","f11","f12","f13","f14","f15", /* 48-55 */ "f16","f17","f18","f19","?", "?", "?", "?", /* 56-64 */ "?", "?", "?", "?", "?", "?", "?", "fzero", "lit" }; alpha_opcode_tab_entry alpha_instr_tbl[] = { {0x00,"call_pal", ALPHA_GROUP_PAL}, {0x01,"opcode01", ALPHA_ERROR}, {0x02,"opcode02", ALPHA_ERROR}, {0x03,"opcode03", ALPHA_ERROR}, {0x04,"opcode04", ALPHA_ERROR}, {0x05,"opcode05", ALPHA_ERROR}, {0x06,"opcode06", ALPHA_ERROR}, {0x07,"opcode07", ALPHA_ERROR}, {0x08,"lda", ALPHA_GROUP3}, {0x09,"ldah", ALPHA_GROUP3}, {0x0a,"ldbu", ALPHA_GROUP3}, {0x0b,"ldq_u", ALPHA_GROUP3}, {0x0c,"ldwu", ALPHA_GROUP3}, {0x0d,"stw", ALPHA_GROUP4}, {0x0e,"stb", ALPHA_GROUP4}, {0x0f,"stq_u", ALPHA_GROUP4}, {0x10,"opcode10", ALPHA_EXTENSION_10}, {0x11,"opcode11", ALPHA_EXTENSION_11}, {0x12,"opcode12", ALPHA_EXTENSION_12}, {0x13,"opcode13", ALPHA_EXTENSION_13}, {0x14,"opcode14", ALPHA_EXTENSION_14}, {0x15,"opcode15", ALPHA_EXTENSION_15}, {0x16,"opcode16", ALPHA_EXTENSION_16}, {0x17,"opcode17", ALPHA_EXTENSION_17}, {0x18,"opcode18", ALPHA_EXTENSION_18}, {0x19,"pal19", ALPHA_ERROR}, {0x1a,"opcode1a", ALPHA_EXTENSION_1A}, {0x1b,"pal1b", ALPHA_ERROR}, {0x1c,"opcode1c", ALPHA_EXTENSION_1C}, {0x1d,"pal1d", ALPHA_ERROR}, {0x1e,"pal1e", ALPHA_ERROR}, {0x1f,"pal1f", ALPHA_ERROR}, {0x20,"ldf", ALPHA_GROUP_FLD}, {0x21,"ldg", ALPHA_GROUP_FLD}, {0x22,"lds", ALPHA_GROUP_FLD}, {0x23,"ldt", ALPHA_GROUP_FLD}, {0x24,"stf", ALPHA_GROUP_FST}, {0x25,"stg", ALPHA_GROUP_FST}, {0x26,"sts", ALPHA_GROUP_FST}, {0x27,"stt", ALPHA_GROUP_FST}, {0x28,"ldl", ALPHA_GROUP3}, {0x29,"ldq", ALPHA_GROUP3}, {0x2a,"ldl_l", ALPHA_GROUP3}, {0x2b,"ldq_l", ALPHA_GROUP3}, {0x2c,"stl", ALPHA_GROUP4}, {0x2d,"stq", ALPHA_GROUP4}, {0x2e,"stl_c", ALPHA_GROUP4}, {0x2f,"stq_c", ALPHA_GROUP4}, {0x30,"br", ALPHA_GROUP_BRA}, {0x31,"fbeq", ALPHA_GROUP_FBR}, {0x32,"fblt", ALPHA_GROUP_FBR}, {0x33,"fble", ALPHA_GROUP_FBR}, {0x34,"bsr", ALPHA_GROUP_BRA}, {0x35,"fbne", ALPHA_GROUP_FBR}, {0x36,"fbge", ALPHA_GROUP_FBR}, {0x37,"fbgt", ALPHA_GROUP_FBR}, {0x38,"blbc", ALPHA_GROUP_BRA}, {0x39,"beq", ALPHA_GROUP_BRA}, {0x3a,"blt", ALPHA_GROUP_BRA}, {0x3b,"ble", ALPHA_GROUP_BRA}, {0x3c,"blbs", ALPHA_GROUP_BRA}, {0x3d,"bne", ALPHA_GROUP_BRA}, {0x3e,"bge", ALPHA_GROUP_BRA}, {0x3f,"bgt", ALPHA_GROUP_BRA} }; /* table10 */ alpha_opcode_tab_entry alpha_instr_tbl_ext10[] = { {0x00,"addl", ALPHA_GROUP1}, {0x02,"s4addl", ALPHA_GROUP1}, {0x09,"subl", ALPHA_GROUP1}, {0x0b,"s4subl", ALPHA_GROUP1}, {0x0f,"cmpbge", ALPHA_GROUP1}, {0x12,"s8addl", ALPHA_GROUP1}, {0x1b,"s8subl", ALPHA_GROUP1}, {0x1d,"cmpult", ALPHA_GROUP1}, {0x20,"addq", ALPHA_GROUP1}, {0x22,"s4addq", ALPHA_GROUP1}, {0x29,"subq", ALPHA_GROUP1}, {0x2b,"s4subq", ALPHA_GROUP1}, {0x2d,"cmpeq", ALPHA_GROUP1}, {0x32,"s8addq", ALPHA_GROUP1}, {0x3b,"s8subq", ALPHA_GROUP1}, {0x3d,"cmpule", ALPHA_GROUP1}, {0x40,"addl/v", ALPHA_GROUP1}, {0x49,"subl/v", ALPHA_GROUP1}, {0x4d,"cmplt", ALPHA_GROUP1}, {0x60,"addq/v", ALPHA_GROUP1}, {0x69,"subq/v", ALPHA_GROUP1}, {0x6d,"cmple", ALPHA_GROUP1}, {0xff,"", ALPHA_ERROR} }; /* table11 */ alpha_opcode_tab_entry alpha_instr_tbl_ext11[] = { {0x00,"and", ALPHA_GROUP1}, {0x08,"bic", ALPHA_GROUP1}, {0x14,"cmovlbs", ALPHA_GROUP1}, {0x16,"cmovlbc", ALPHA_GROUP1}, {0x20,"bis", ALPHA_GROUP1}, {0x24,"cmoveq", ALPHA_GROUP1}, {0x26,"cmovne", ALPHA_GROUP1}, {0x28,"ornot", ALPHA_GROUP1}, {0x40,"xor", ALPHA_GROUP1}, {0x44,"cmovlt", ALPHA_GROUP1}, {0x46,"cmovge", ALPHA_GROUP1}, {0x48,"eqv", ALPHA_GROUP1}, {0x61,"amask", ALPHA_GROUP3}, {0x64,"cmovle", ALPHA_GROUP1}, {0x66,"cmovgt", ALPHA_GROUP1}, {0x6c,"implver", ALPHA_GROUP3}, {0xff,"", ALPHA_ERROR} }; /* table12 */ alpha_opcode_tab_entry alpha_instr_tbl_ext12[] = { {0x00,"", ALPHA_ERROR}, {0x02,"mskbl", ALPHA_GROUP1}, {0x06,"extbl", ALPHA_GROUP1}, {0x0b,"insbl", ALPHA_GROUP1}, {0x12,"mskwl", ALPHA_GROUP1}, {0x16,"extwl", ALPHA_GROUP1}, {0x1b,"inswl", ALPHA_GROUP1}, {0x22,"mskll", ALPHA_GROUP1}, {0x26,"extll", ALPHA_GROUP1}, {0x2b,"insll", ALPHA_GROUP1}, {0x30,"zap", ALPHA_GROUP1}, {0x31,"zapnot", ALPHA_GROUP1}, {0x32,"mskql", ALPHA_GROUP1}, {0x34,"srl", ALPHA_GROUP1}, {0x36,"extql", ALPHA_GROUP1}, {0x39,"sll", ALPHA_GROUP1}, {0x3b,"insql", ALPHA_GROUP1}, {0x3c,"sra", ALPHA_GROUP1}, {0x52,"mskwh", ALPHA_GROUP1}, {0x57,"inswh", ALPHA_GROUP1}, {0x5a,"extwh", ALPHA_GROUP1}, {0x62,"msklh", ALPHA_GROUP1}, {0x67,"inslh", ALPHA_GROUP1}, {0x6a,"extlh", ALPHA_GROUP1}, {0x72,"mskqh", ALPHA_GROUP1}, {0x77,"insqh", ALPHA_GROUP1}, {0x7a,"extqh", ALPHA_GROUP1}, {0xff,"", ALPHA_ERROR} }; /* table13 */ alpha_opcode_tab_entry alpha_instr_tbl_ext13[] = { {0x00,"mull", ALPHA_GROUP1}, {0x20,"mulq", ALPHA_GROUP1}, {0x30,"umulh", ALPHA_GROUP1}, {0x40,"mull/v", ALPHA_GROUP1}, {0x60,"mulq/v", ALPHA_GROUP1}, {0xff,"", ALPHA_ERROR} }; /* table14 */ alpha_opcode_tab_entry alpha_instr_tbl_ext14[] = { {0x000,"", ALPHA_ERROR}, {0x004,"itofs", ALPHA_GROUP_I2F}, {0x00a,"sqrtf/c", ALPHA_ERROR}, {0x00b,"sqrts/c", ALPHA_ERROR}, {0x014,"itoff", ALPHA_GROUP_I2F}, {0x024,"itoft", ALPHA_GROUP_I2F}, {0x02a,"sqrtg/c", ALPHA_ERROR}, {0x02b,"sqrtt/c", ALPHA_ERROR}, {0x04b,"sqrts/m", ALPHA_ERROR}, {0x06b,"sqrtt/m", ALPHA_ERROR}, {0x08a,"sqrtf", ALPHA_ERROR}, {0x08b,"sqrts", ALPHA_ERROR}, {0x0aa,"sqrtg", ALPHA_ERROR}, {0x0ab,"sqrtt", ALPHA_ERROR}, {0x0cb,"sqrts/d", ALPHA_ERROR}, {0x0eb,"sqrtt/d", ALPHA_ERROR}, {0x10a,"sqrtf/uc", ALPHA_ERROR}, {0x10b,"sqrts/uc", ALPHA_ERROR}, {0x12a,"sqrtg/uc", ALPHA_ERROR}, {0x12b,"sqrtt/uc", ALPHA_ERROR}, {0x14b,"sqrts/um", ALPHA_ERROR}, {0x16b,"sqrtt/um", ALPHA_ERROR}, {0x18a,"sqrtf/u", ALPHA_ERROR}, {0x18b,"sqrts/u", ALPHA_ERROR}, {0x1aa,"sqrtg/u", ALPHA_ERROR}, {0x1ab,"sqrtt/u", ALPHA_ERROR}, {0x1cb,"sqrts/ud", ALPHA_ERROR}, {0x1eb,"sqrtt/ud", ALPHA_ERROR}, {0x40a,"sqrtf/sc", ALPHA_ERROR}, {0x42a,"sqrtg/sc", ALPHA_ERROR}, {0x48a,"sqrtf/s", ALPHA_ERROR}, {0x4aa,"sqrtg/s", ALPHA_ERROR}, {0x50a,"sqrtf/suc", ALPHA_ERROR}, {0x50b,"sqrts/suc", ALPHA_ERROR}, {0x52a,"sqrtg/suc", ALPHA_ERROR}, {0x52b,"sqrtt/suc", ALPHA_ERROR}, {0x54b,"sqrts/sum", ALPHA_ERROR}, {0x56b,"sqrtt/sum", ALPHA_ERROR}, {0x58a,"sqrtf/su", ALPHA_ERROR}, {0x58b,"sqrts/su", ALPHA_ERROR}, {0x5aa,"sqrtg/su", ALPHA_ERROR}, {0x5ab,"sqrtt/su", ALPHA_ERROR}, {0x5cb,"sqrts/sud", ALPHA_ERROR}, {0x5eb,"sqrtt/sud", ALPHA_ERROR}, {0x70b,"sqrts/suic",ALPHA_ERROR}, {0x72b,"sqrtt/suic",ALPHA_ERROR}, {0x74b,"sqrts/suim",ALPHA_ERROR}, {0x76b,"sqrtt/suim",ALPHA_ERROR}, {0x78b,"sqrts/sui", ALPHA_ERROR}, {0x7ab,"sqrtt/sui", ALPHA_ERROR}, {0x7cb,"sqrts/suid",ALPHA_ERROR}, {0x7eb,"sqrtt/suid",ALPHA_ERROR}, {0xfff,"", ALPHA_ERROR} }; /* table15 */ alpha_opcode_tab_entry alpha_instr_tbl_ext15[] = { {0x000,"addf/c", ALPHA_GROUP2}, {0x001,"subf/c", ALPHA_GROUP2}, {0x002,"mulf/c", ALPHA_GROUP2}, {0x003,"divf/c", ALPHA_GROUP2}, {0x01e,"cvtdg/c", ALPHA_GROUP2}, {0x020,"addg/c", ALPHA_GROUP2}, {0x021,"subg/c", ALPHA_GROUP2}, {0x022,"mulg/c", ALPHA_GROUP2}, {0x023,"divg/c", ALPHA_GROUP2}, {0x02c,"cvtgf/c", ALPHA_GROUP2}, {0x02d,"cvtgd/c", ALPHA_GROUP2}, {0x02f,"cvtgq/c", ALPHA_GROUP2}, {0x03c,"cvtqf/c", ALPHA_GROUP2}, {0x03e,"cvtqg/c", ALPHA_GROUP2}, {0x080,"addf", ALPHA_GROUP2}, {0x081,"subf", ALPHA_GROUP2}, {0x082,"mulf", ALPHA_GROUP2}, {0x083,"divf", ALPHA_GROUP2}, {0x09e,"cvtdg", ALPHA_GROUP2}, {0x0a0,"addg", ALPHA_GROUP2}, {0x0a1,"subg", ALPHA_GROUP2}, {0x0a2,"mulg", ALPHA_GROUP2}, {0x0a3,"divg", ALPHA_GROUP2}, {0x0a5,"cmpgeq", ALPHA_GROUP2}, {0x0a6,"cmpglt", ALPHA_GROUP2}, {0x0a7,"cmpgle", ALPHA_GROUP2}, {0x0ac,"cvtgf", ALPHA_GROUP2}, {0x0ad,"cvtgd", ALPHA_GROUP2}, {0x0af,"cvtgq", ALPHA_GROUP2}, {0x0bc,"cvtqf", ALPHA_GROUP2}, {0x0be,"cvtqg", ALPHA_GROUP2}, {0x100,"addf/uc", ALPHA_GROUP2}, {0x101,"subf/uc", ALPHA_GROUP2}, {0x102,"mulf/uc", ALPHA_GROUP2}, {0x103,"divf/uc", ALPHA_GROUP2}, {0x11e,"cvtdg/uc", ALPHA_GROUP2}, {0x120,"addg/uc", ALPHA_GROUP2}, {0x121,"subg/uc", ALPHA_GROUP2}, {0x122,"mulg/uc", ALPHA_GROUP2}, {0x123,"divg/uc", ALPHA_GROUP2}, {0x12c,"cvtgf/uc", ALPHA_GROUP2}, {0x12d,"cvtgd/uc", ALPHA_GROUP2}, {0x12f,"cvtgq/vc", ALPHA_GROUP2}, {0x180,"addf/u", ALPHA_GROUP2}, {0x181,"subf/u", ALPHA_GROUP2}, {0x182,"mulf/u", ALPHA_GROUP2}, {0x183,"divf/u", ALPHA_GROUP2}, {0x19e,"cvtdg/u", ALPHA_GROUP2}, {0x1a0,"addg/u", ALPHA_GROUP2}, {0x1a1,"subg/u", ALPHA_GROUP2}, {0x1a2,"mulg/u", ALPHA_GROUP2}, {0x1a3,"divg/u", ALPHA_GROUP2}, {0x1ac,"cvtgf/u", ALPHA_GROUP2}, {0x1ad,"cvtgd/u", ALPHA_GROUP2}, {0x1af,"cvtgq/v", ALPHA_GROUP2}, {0x400,"addf/sc", ALPHA_GROUP2}, {0x401,"subf/sc", ALPHA_GROUP2}, {0x402,"mulf/sc", ALPHA_GROUP2}, {0x403,"divf/sc", ALPHA_GROUP2}, {0x41e,"cvtdg/sc", ALPHA_GROUP2}, {0x420,"addg/sc", ALPHA_GROUP2}, {0x421,"subg/sc", ALPHA_GROUP2}, {0x422,"mulg/sc", ALPHA_GROUP2}, {0x423,"divg/sc", ALPHA_GROUP2}, {0x42c,"cvtgf/sc", ALPHA_GROUP2}, {0x42d,"cvtgd/sc", ALPHA_GROUP2}, {0x42f,"cvtgq/sc", ALPHA_GROUP2}, {0x480,"addf/s", ALPHA_GROUP2}, {0x481,"subf/s", ALPHA_GROUP2}, {0x482,"mulf/s", ALPHA_GROUP2}, {0x483,"divf/s", ALPHA_GROUP2}, {0x49e,"cvtdg/s", ALPHA_GROUP2}, {0x4a0,"addg/s", ALPHA_GROUP2}, {0x4a1,"subg/s", ALPHA_GROUP2}, {0x4a2,"mulg/s", ALPHA_GROUP2}, {0x4a3,"divg/s", ALPHA_GROUP2}, {0x4a5,"cmpgeq/s", ALPHA_GROUP2}, {0x4a6,"cmpglt/s", ALPHA_GROUP2}, {0x4a7,"cmpgle/s", ALPHA_GROUP2}, {0x4ac,"cvtgf/s", ALPHA_GROUP2}, {0x4ad,"cvtgd/s", ALPHA_GROUP2}, {0x4af,"cvtgq/s", ALPHA_GROUP2}, {0x500,"addf/suc", ALPHA_GROUP2}, {0x501,"subf/suc", ALPHA_GROUP2}, {0x502,"mulf/suc", ALPHA_GROUP2}, {0x503,"divf/suc", ALPHA_GROUP2}, {0x51e,"cvtdg/suc", ALPHA_GROUP2}, {0x520,"addg/suc", ALPHA_GROUP2}, {0x521,"subg/suc", ALPHA_GROUP2}, {0x522,"mulg/suc", ALPHA_GROUP2}, {0x523,"divg/suc", ALPHA_GROUP2}, {0x52c,"cvtgf/suc", ALPHA_GROUP2}, {0x52d,"cvtgd/suc", ALPHA_GROUP2}, {0x52f,"cvtgq/svc", ALPHA_GROUP2}, {0x580,"addf/su", ALPHA_GROUP2}, {0x581,"subf/su", ALPHA_GROUP2}, {0x582,"mulf/su", ALPHA_GROUP2}, {0x583,"divf/su", ALPHA_GROUP2}, {0x59e,"cvtdg/su", ALPHA_GROUP2}, {0x5a0,"addg/su", ALPHA_GROUP2}, {0x5a1,"subg/su", ALPHA_GROUP2}, {0x5a2,"mulg/su", ALPHA_GROUP2}, {0x5a3,"divg/su", ALPHA_GROUP2}, {0x5ac,"cvtgf/su", ALPHA_GROUP2}, {0x5ad,"cvtgd/su", ALPHA_GROUP2}, {0x5af,"cvtgq/sv", ALPHA_GROUP2}, {0xfff,"", ALPHA_ERROR} }; /* table16 */ alpha_opcode_tab_entry alpha_instr_tbl_ext16[] = { {0x000,"adds/c", ALPHA_GROUP2}, {0x001,"subs/c", ALPHA_GROUP2}, {0x002,"muls/c", ALPHA_GROUP2}, {0x003,"divs/c", ALPHA_GROUP2}, {0x020,"addt/c", ALPHA_GROUP2}, {0x021,"subt/c", ALPHA_GROUP2}, {0x022,"mult/c", ALPHA_GROUP2}, {0x023,"divt/c", ALPHA_GROUP2}, {0x02c,"cvtts/c", ALPHA_GROUP2}, {0x02f,"cvttq/c", ALPHA_GROUP2}, {0x03c,"cvtqs/c", ALPHA_GROUP2}, {0x03e,"cvtqt/c", ALPHA_GROUP2}, {0x040,"adds/m", ALPHA_GROUP2}, {0x041,"subs/m", ALPHA_GROUP2}, {0x042,"muls/m", ALPHA_GROUP2}, {0x043,"divs/m", ALPHA_GROUP2}, {0x060,"addt/m", ALPHA_GROUP2}, {0x061,"subt/m", ALPHA_GROUP2}, {0x062,"mult/m", ALPHA_GROUP2}, {0x063,"divt/m", ALPHA_GROUP2}, {0x06c,"cvtts/m", ALPHA_GROUP2}, {0x06f,"cvttq/m", ALPHA_GROUP2}, {0x07c,"cvtqs/m", ALPHA_GROUP2}, {0x07e,"cvtqt/m", ALPHA_GROUP2}, {0x080,"adds", ALPHA_GROUP2}, {0x081,"subs", ALPHA_GROUP2}, {0x082,"muls", ALPHA_GROUP2}, {0x083,"divs", ALPHA_GROUP2}, {0x0a0,"addt", ALPHA_GROUP2}, {0x0a1,"subt", ALPHA_GROUP2}, {0x0a2,"mult", ALPHA_GROUP2}, {0x0a3,"divt", ALPHA_GROUP2}, {0x0a4,"cmptun", ALPHA_GROUP2}, {0x0a5,"cmpteq", ALPHA_GROUP2}, {0x0a6,"cmptlt", ALPHA_GROUP2}, {0x0a7,"cmptle", ALPHA_GROUP2}, {0x0ac,"cvtts", ALPHA_GROUP2}, {0x0af,"cvttq", ALPHA_GROUP2}, {0x0bc,"cvtqs", ALPHA_GROUP2}, {0x0be,"cvtqt", ALPHA_GROUP2}, {0x0c0,"adds/d", ALPHA_GROUP2}, {0x0c1,"subs/d", ALPHA_GROUP2}, {0x0c2,"muls/d", ALPHA_GROUP2}, {0x0c3,"divs/d", ALPHA_GROUP2}, {0x0e0,"addt/d", ALPHA_GROUP2}, {0x0e1,"subt/d", ALPHA_GROUP2}, {0x0e2,"mult/d", ALPHA_GROUP2}, {0x0e3,"divt/d", ALPHA_GROUP2}, {0x0ec,"cvtts/d", ALPHA_GROUP2}, {0x0ef,"cvttq/d", ALPHA_GROUP2}, {0x0fc,"cvtqs/d", ALPHA_GROUP2}, {0x0fe,"cvtqt/d", ALPHA_GROUP2}, {0x100,"adds/uc", ALPHA_GROUP2}, {0x101,"subs/uc", ALPHA_GROUP2}, {0x102,"muls/uc", ALPHA_GROUP2}, {0x103,"divs/uc", ALPHA_GROUP2}, {0x120,"addt/uc", ALPHA_GROUP2}, {0x121,"subt/uc", ALPHA_GROUP2}, {0x122,"mult/uc", ALPHA_GROUP2}, {0x123,"divt/uc", ALPHA_GROUP2}, {0x12c,"cvtts/uc", ALPHA_GROUP2}, {0x12f,"cvttq/vc", ALPHA_GROUP2}, {0x140,"adds/um", ALPHA_GROUP2}, {0x141,"subs/um", ALPHA_GROUP2}, {0x142,"muls/um", ALPHA_GROUP2}, {0x143,"divs/um", ALPHA_GROUP2}, {0x160,"addt/um", ALPHA_GROUP2}, {0x161,"subt/um", ALPHA_GROUP2}, {0x162,"mult/um", ALPHA_GROUP2}, {0x163,"divt/um", ALPHA_GROUP2}, {0x16c,"cvtts/um", ALPHA_GROUP2}, {0x16f,"cvttq/vm", ALPHA_GROUP2}, {0x180,"adds/u", ALPHA_GROUP2}, {0x181,"subs/u", ALPHA_GROUP2}, {0x182,"muls/u", ALPHA_GROUP2}, {0x183,"divs/u", ALPHA_GROUP2}, {0x1a0,"addt/u", ALPHA_GROUP2}, {0x1a1,"subt/u", ALPHA_GROUP2}, {0x1a2,"mult/u", ALPHA_GROUP2}, {0x1a3,"divt/u", ALPHA_GROUP2}, {0x1ac,"cvtts/u", ALPHA_GROUP2}, {0x1af,"cvttq/v", ALPHA_GROUP2}, {0x1c0,"adds/ud", ALPHA_GROUP2}, {0x1c1,"subs/ud", ALPHA_GROUP2}, {0x1c2,"muls/ud", ALPHA_GROUP2}, {0x1c3,"divs/ud", ALPHA_GROUP2}, {0x1e0,"addt/ud", ALPHA_GROUP2}, {0x1e1,"subt/ud", ALPHA_GROUP2}, {0x1e2,"mult/ud", ALPHA_GROUP2}, {0x1e3,"divt/ud", ALPHA_GROUP2}, {0x1ec,"cvtts/ud", ALPHA_GROUP2}, {0x1ef,"cvttq/vd", ALPHA_GROUP2}, {0x2ac,"cvtst", ALPHA_GROUP2}, {0x500,"adds/suc", ALPHA_GROUP2}, {0x501,"subs/suc", ALPHA_GROUP2}, {0x502,"muls/suc", ALPHA_GROUP2}, {0x503,"divs/suc", ALPHA_GROUP2}, {0x520,"addt/suc", ALPHA_GROUP2}, {0x521,"subt/suc", ALPHA_GROUP2}, {0x522,"mult/suc", ALPHA_GROUP2}, {0x523,"divt/suc", ALPHA_GROUP2}, {0x52c,"cvtts/suc", ALPHA_GROUP2}, {0x52f,"cvttq/svc", ALPHA_GROUP2}, {0x540,"adds/sum", ALPHA_GROUP2}, {0x541,"subs/sum", ALPHA_GROUP2}, {0x542,"muls/sum", ALPHA_GROUP2}, {0x543,"divs/sum", ALPHA_GROUP2}, {0x560,"addt/sum", ALPHA_GROUP2}, {0x561,"subt/sum", ALPHA_GROUP2}, {0x562,"mult/sum", ALPHA_GROUP2}, {0x563,"divt/sum", ALPHA_GROUP2}, {0x56c,"cvtts/sum", ALPHA_GROUP2}, {0x56f,"cvttq/svm", ALPHA_GROUP2}, {0x580,"adds/su", ALPHA_GROUP2}, {0x581,"subs/su", ALPHA_GROUP2}, {0x582,"muls/su", ALPHA_GROUP2}, {0x583,"divs/su", ALPHA_GROUP2}, {0x5a0,"addt/su", ALPHA_GROUP2}, {0x5a1,"subt/su", ALPHA_GROUP2}, {0x5a2,"mult/su", ALPHA_GROUP2}, {0x5a3,"divt/su", ALPHA_GROUP2}, {0x5a4,"cmptun/su", ALPHA_GROUP2}, {0x5a5,"cmpteq/su", ALPHA_GROUP2}, {0x5a6,"cmptlt/su", ALPHA_GROUP2}, {0x5a7,"cmptle/su", ALPHA_GROUP2}, {0x5ac,"cvtts/su", ALPHA_GROUP2}, {0x5af,"cvttq/sv", ALPHA_GROUP2}, {0x5c0,"adds/sud", ALPHA_GROUP2}, {0x5c1,"subs/sud", ALPHA_GROUP2}, {0x5c2,"muls/sud", ALPHA_GROUP2}, {0x5c3,"divs/sud", ALPHA_GROUP2}, {0x5e0,"addt/sud", ALPHA_GROUP2}, {0x5e1,"subt/sud", ALPHA_GROUP2}, {0x5e2,"mult/sud", ALPHA_GROUP2}, {0x5e3,"divt/sud", ALPHA_GROUP2}, {0x5ec,"cvtts/sud", ALPHA_GROUP2}, {0x5ef,"cvttq/svd", ALPHA_GROUP2}, {0x6ac,"cvtst/s", ALPHA_GROUP2}, {0x700,"adds/suic", ALPHA_GROUP2}, {0x701,"subs/suic", ALPHA_GROUP2}, {0x702,"muls/suic", ALPHA_GROUP2}, {0x703,"divs/suic", ALPHA_GROUP2}, {0x720,"addt/suic", ALPHA_GROUP2}, {0x721,"subt/suic", ALPHA_GROUP2}, {0x722,"mult/suic", ALPHA_GROUP2}, {0x723,"divt/suic", ALPHA_GROUP2}, {0x72c,"cvtts/suic",ALPHA_GROUP2}, {0x72f,"cvttq/svic",ALPHA_GROUP2}, {0x73c,"cvtqs/suic",ALPHA_GROUP2}, {0x73e,"cvtqt/suic",ALPHA_GROUP2}, {0x740,"adds/suim", ALPHA_GROUP2}, {0x741,"subs/suim", ALPHA_GROUP2}, {0x742,"muls/suim", ALPHA_GROUP2}, {0x743,"divs/suim", ALPHA_GROUP2}, {0x760,"addt/suim", ALPHA_GROUP2}, {0x761,"subt/suim", ALPHA_GROUP2}, {0x762,"mult/suim", ALPHA_GROUP2}, {0x763,"divt/suim", ALPHA_GROUP2}, {0x76c,"cvtts/suim",ALPHA_GROUP2}, {0x76f,"cvttq/svim",ALPHA_GROUP2}, {0x77c,"cvtqs/suim",ALPHA_GROUP2}, {0x77e,"cvtqt/suim",ALPHA_GROUP2}, {0x780,"adds/sui", ALPHA_GROUP2}, {0x781,"subs/sui", ALPHA_GROUP2}, {0x782,"muls/sui", ALPHA_GROUP2}, {0x783,"divs/sui", ALPHA_GROUP2}, {0x7a0,"addt/sui", ALPHA_GROUP2}, {0x7a1,"subt/sui", ALPHA_GROUP2}, {0x7a2,"mult/sui", ALPHA_GROUP2}, {0x7a3,"divt/sui", ALPHA_GROUP2}, {0x7ac,"cvtts/sui", ALPHA_GROUP2}, {0x7af,"cvttq/svi", ALPHA_GROUP2}, {0x7bc,"cvtqs/sui", ALPHA_GROUP2}, {0x7be,"cvtqt/sui", ALPHA_GROUP2}, {0x7c0,"adds/suid", ALPHA_GROUP2}, {0x7c1,"subs/suid", ALPHA_GROUP2}, {0x7c2,"muls/suid", ALPHA_GROUP2}, {0x7c3,"divs/suid", ALPHA_GROUP2}, {0x7e0,"addt/suid", ALPHA_GROUP2}, {0x7e1,"subt/suid", ALPHA_GROUP2}, {0x7e2,"mult/suid", ALPHA_GROUP2}, {0x7e3,"divt/suid", ALPHA_GROUP2}, {0x7ec,"cvtts/suid",ALPHA_GROUP2}, {0x7ef,"cvttq/svid",ALPHA_GROUP2}, {0x7fc,"cvtqs/suid",ALPHA_GROUP2}, {0x7fe,"cvtqt/suid",ALPHA_GROUP2}, {0xfff,"", ALPHA_ERROR} }; /* table17 */ alpha_opcode_tab_entry alpha_instr_tbl_ext17[] = { {0x000,"", ALPHA_ERROR}, {0x010,"cvtlq", ALPHA_GROUP2}, {0x020,"cpys", ALPHA_GROUP2}, {0x021,"cpysn", ALPHA_GROUP2}, {0x022,"cpyse", ALPHA_GROUP2}, {0x024,"mt_fpcr", ALPHA_GROUP2}, {0x025,"mf_fpcr", ALPHA_GROUP2}, {0x02a,"fcmoveq", ALPHA_GROUP2}, {0x02b,"fcmovne", ALPHA_GROUP2}, {0x02c,"fcmovlt", ALPHA_GROUP2}, {0x02d,"fcmovge", ALPHA_GROUP2}, {0x02e,"fcmovle", ALPHA_GROUP2}, {0x02f,"fcmovgt", ALPHA_GROUP2}, {0x030,"cvtql", ALPHA_GROUP2}, {0x130,"cvtql/v", ALPHA_GROUP2}, {0x530,"cvtql/sv", ALPHA_GROUP2}, {0xfff,"", ALPHA_ERROR} }; /* table18 */ alpha_opcode_tab_entry alpha_instr_tbl_ext18[] = { {0x0000,"trapb", ALPHA_GROUP3}, {0x0400,"excb", ALPHA_GROUP3}, {0x4000,"mb", ALPHA_GROUP3}, {0x4400,"wmb", ALPHA_GROUP3}, {0x8000,"fetch", ALPHA_GROUP3}, {0xa000,"fetch_m", ALPHA_GROUP3}, {0xc000,"rpcc", ALPHA_GROUP3}, {0xe000,"rc", ALPHA_ERROR}, {0xe800,"ecb", ALPHA_ERROR}, {0xf000,"rs", ALPHA_ERROR}, {0xf800,"wh64", ALPHA_ERROR}, {0xffff,"", ALPHA_ERROR} }; /* table1a */ alpha_opcode_tab_entry alpha_instr_tbl_ext1a[] = { {0x0,"jmp", ALPHA_GROUP_JMP}, {0x1,"jsr", ALPHA_GROUP_JMP}, {0x2,"ret", ALPHA_GROUP_JMP}, {0x3,"jsr_co", ALPHA_GROUP_JMP}, {0xf,"", ALPHA_ERROR} }; /* table1c */ alpha_opcode_tab_entry alpha_instr_tbl_ext1c[] = { {0x00,"sextb", ALPHA_GROUP1}, {0x01,"sextw", ALPHA_GROUP1}, {0x30,"ctpop", ALPHA_GROUP1}, {0x31,"perr", ALPHA_GROUP1}, {0x32,"ctlz", ALPHA_GROUP1}, {0x33,"cttz", ALPHA_GROUP1}, {0x34,"unpkbw", ALPHA_GROUP1}, {0x35,"unpkbl", ALPHA_GROUP1}, {0x36,"pkwb", ALPHA_GROUP1}, {0x37,"pklb", ALPHA_GROUP1}, {0x38,"minsb8", ALPHA_GROUP1}, {0x39,"minsw4", ALPHA_GROUP1}, {0x3a,"minub8", ALPHA_GROUP1}, {0x3b,"minuw4", ALPHA_GROUP1}, {0x3c,"maxub8", ALPHA_GROUP1}, {0x3d,"maxuw4", ALPHA_GROUP1}, {0x3e,"maxsb8", ALPHA_GROUP1}, {0x3f,"maxsw4", ALPHA_GROUP1}, {0x70,"ftoit", ALPHA_GROUP_F2I}, {0x78,"ftois", ALPHA_GROUP_F2I}, {0xff,"", ALPHA_ERROR} }; ht-2.0.22/asm/ia64opc.cc0000644000175000001440000213577510615342401011501 00000000000000/* * HT Editor * ia64opc.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "io/types.h" #include "ia64opc.h" IA64Template IA64Templates[] = { {0, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT}}, {3, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT}}, {2, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT}}, // ? {2, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT}}, {0, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_L_UNIT|IA64_INST_ROLE_LONG, IA64_SLOT_X_UNIT|IA64_INST_ROLE_LONG}}, {3, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_L_UNIT|IA64_INST_ROLE_LONG, IA64_SLOT_X_UNIT|IA64_INST_ROLE_LONG}}, {0, {IA64_SLOT_INVALID}}, {0, {IA64_SLOT_INVALID}}, {0, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT}}, {3, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT}}, {1, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT}}, {1, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT}}, // ? {0, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_F_UNIT|IA64_INST_ROLE_FP, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT}}, {3, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_F_UNIT|IA64_INST_ROLE_FP, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT}}, {0, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_F_UNIT|IA64_INST_ROLE_FP}}, {3, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_F_UNIT|IA64_INST_ROLE_FP}}, {0, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT, IA64_SLOT_B_UNIT|IA64_INST_ROLE_BR}}, {3, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_I_UNIT|IA64_INST_ROLE_INT, IA64_SLOT_B_UNIT|IA64_INST_ROLE_BR}}, {0, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_B_UNIT|IA64_INST_ROLE_BR, IA64_SLOT_B_UNIT|IA64_INST_ROLE_BR}}, {3, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_B_UNIT|IA64_INST_ROLE_BR, IA64_SLOT_B_UNIT|IA64_INST_ROLE_BR}}, {0, {IA64_SLOT_INVALID}}, {0, {IA64_SLOT_INVALID}}, {0, {IA64_SLOT_B_UNIT|IA64_INST_ROLE_BR, IA64_SLOT_B_UNIT|IA64_INST_ROLE_BR, IA64_SLOT_B_UNIT|IA64_INST_ROLE_BR}}, {3, {IA64_SLOT_B_UNIT|IA64_INST_ROLE_BR, IA64_SLOT_B_UNIT|IA64_INST_ROLE_BR, IA64_SLOT_B_UNIT|IA64_INST_ROLE_BR}}, {0, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_B_UNIT}}, {3, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_B_UNIT}}, {0, {IA64_SLOT_INVALID}}, {0, {IA64_SLOT_INVALID}}, {0, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_F_UNIT|IA64_INST_ROLE_FP, IA64_SLOT_B_UNIT|IA64_INST_ROLE_BR}}, {3, {IA64_SLOT_M_UNIT|IA64_INST_ROLE_MEM, IA64_SLOT_F_UNIT|IA64_INST_ROLE_FP, IA64_SLOT_B_UNIT|IA64_INST_ROLE_BR}}, {0, {IA64_SLOT_INVALID}}, {0, {IA64_SLOT_INVALID}}, }; /***********************************************************************/ /*** This file is automaticaly generated by tree_builder */ /***********************************************************************/ IA64DecisionTreeEntry IA64DecisionTree[] = { /*00000*/ {80, 33, 3}, /*00001*/ {424, 33, 3}, /*00002*/ {476, 33, 1}, /*00003*/ {594, 27, 6}, /*00004*/ {850, 27, 9}, /*00005*/ {0, -1, -1}, /*00006*/ {1362, 33, 3}, /*00007*/ {1434, 33, 1}, /*00008*/ {1572, 32, 4}, /*00009*/ {0, -1, -1}, /*00010*/ {0, -1, -1}, /*00011*/ {0, -1, -1}, /*00012*/ {0, -1, -1}, /*00013*/ {1620, 27, 6}, /*00014*/ {0, -1, -1}, /*00015*/ {0, -1, -1}, /*00016*/ {0, -1, -1}, /*00017*/ {0, -1, -1}, /*00018*/ {1, -1, -1}, /*00019*/ {0, -1, -1}, /*00020*/ {173, -1, -1}, /*00021*/ {1828, 30, 7}, /*00022*/ {2628, 33, 4}, /*00023*/ {2676, 33, 3}, /*00024*/ {0, -1, -1}, /*00025*/ {2844, 33, 3}, /*00026*/ {2880, 28, 8}, /*00027*/ {3136, 12, 1}, /*00028*/ {3138, 33, 3}, /*00029*/ {0, -1, -1}, /*00030*/ {0, -1, -1}, /*00031*/ {3162, 30, 7}, /*00032*/ {0, -1, -1}, /*00033*/ {1, -1, -1}, /*00034*/ {3802, 20, 1}, /*00035*/ {3804, 32, 5}, /*00036*/ {4008, 28, 8}, /*00037*/ {0, -1, -1}, /*00038*/ {4264, 0, 6}, /*00039*/ {0, -1, -1}, /*00040*/ {4336, 33, 3}, /*00041*/ {4540, 33, 3}, /*00042*/ {4744, 34, 3}, /*00043*/ {0, -1, -1}, /*00044*/ {0, -1, -1}, /*00045*/ {20, -1, -1}, /*00046*/ {20, -1, -1}, /*00047*/ {4752, 34, 3}, /*00048*/ {0, -1, -1}, /*00049*/ {0, -1, -1}, /*00050*/ {0, -1, -1}, /*00051*/ {0, -1, -1}, /*00052*/ {4760, 34, 3}, /*00053*/ {0, -1, -1}, /*00054*/ {0, -1, -1}, /*00055*/ {0, -1, -1}, /*00056*/ {0, -1, -1}, /*00057*/ {4768, 34, 3}, /*00058*/ {0, -1, -1}, /*00059*/ {0, -1, -1}, /*00060*/ {4776, 33, 3}, /*00061*/ {4816, 33, 3}, /*00062*/ {4856, 34, 3}, /*00063*/ {0, -1, -1}, /*00064*/ {4864, 33, 3}, /*00065*/ {4952, 33, 3}, /*00066*/ {4992, 33, 3}, /*00067*/ {5032, 34, 3}, /*00068*/ {0, -1, -1}, /*00069*/ {5040, 33, 3}, /*00070*/ {5064, 33, 3}, /*00071*/ {5104, 33, 3}, /*00072*/ {5144, 36, 1}, /*00073*/ {0, -1, -1}, /*00074*/ {0, -1, -1}, /*00075*/ {0, -1, -1}, /*00076*/ {0, -1, -1}, /*00077*/ {0, -1, -1}, /*00078*/ {0, -1, -1}, /*00079*/ {0, -1, -1}, /*00080*/ {88, 27, 6}, /*00081*/ {192, -1, -1}, /*00082*/ {207, -1, -1}, /*00083*/ {206, -1, -1}, /*00084*/ {0, -1, -1}, /*00085*/ {0, -1, -1}, /*00086*/ {0, -1, -1}, /*00087*/ {152, 20, 4}, /*00088*/ {190, -1, -1}, /*00089*/ {191, -1, -1}, /*00090*/ {0, -1, -1}, /*00091*/ {0, -1, -1}, /*00092*/ {0, -1, -1}, /*00093*/ {0, -1, -1}, /*00094*/ {0, -1, -1}, /*00095*/ {0, -1, -1}, /*00096*/ {0, -1, -1}, /*00097*/ {0, -1, -1}, /*00098*/ {211, -1, -1}, /*00099*/ {0, -1, -1}, /*00100*/ {0, -1, -1}, /*00101*/ {0, -1, -1}, /*00102*/ {0, -1, -1}, /*00103*/ {0, -1, -1}, /*00104*/ {213, -1, -1}, /*00105*/ {214, -1, -1}, /*00106*/ {215, -1, -1}, /*00107*/ {0, -1, -1}, /*00108*/ {216, -1, -1}, /*00109*/ {217, -1, -1}, /*00110*/ {218, -1, -1}, /*00111*/ {0, -1, -1}, /*00112*/ {219, -1, -1}, /*00113*/ {220, -1, -1}, /*00114*/ {0, -1, -1}, /*00115*/ {0, -1, -1}, /*00116*/ {221, -1, -1}, /*00117*/ {222, -1, -1}, /*00118*/ {0, -1, -1}, /*00119*/ {0, -1, -1}, /*00120*/ {0, -1, -1}, /*00121*/ {0, -1, -1}, /*00122*/ {0, -1, -1}, /*00123*/ {0, -1, -1}, /*00124*/ {0, -1, -1}, /*00125*/ {0, -1, -1}, /*00126*/ {0, -1, -1}, /*00127*/ {0, -1, -1}, /*00128*/ {0, -1, -1}, /*00129*/ {0, -1, -1}, /*00130*/ {210, -1, -1}, /*00131*/ {0, -1, -1}, /*00132*/ {0, -1, -1}, /*00133*/ {0, -1, -1}, /*00134*/ {0, -1, -1}, /*00135*/ {0, -1, -1}, /*00136*/ {208, -1, -1}, /*00137*/ {205, -1, -1}, /*00138*/ {212, -1, -1}, /*00139*/ {209, -1, -1}, /*00140*/ {0, -1, -1}, /*00141*/ {0, -1, -1}, /*00142*/ {0, -1, -1}, /*00143*/ {0, -1, -1}, /*00144*/ {0, -1, -1}, /*00145*/ {0, -1, -1}, /*00146*/ {0, -1, -1}, /*00147*/ {0, -1, -1}, /*00148*/ {0, -1, -1}, /*00149*/ {0, -1, -1}, /*00150*/ {0, -1, -1}, /*00151*/ {0, -1, -1}, /*00152*/ {168, 9, 4}, /*00153*/ {184, 9, 4}, /*00154*/ {200, 9, 4}, /*00155*/ {216, 9, 4}, /*00156*/ {232, 9, 4}, /*00157*/ {248, 9, 4}, /*00158*/ {264, 9, 4}, /*00159*/ {280, 9, 4}, /*00160*/ {296, 9, 4}, /*00161*/ {312, 9, 4}, /*00162*/ {328, 9, 4}, /*00163*/ {344, 9, 4}, /*00164*/ {360, 9, 4}, /*00165*/ {376, 9, 4}, /*00166*/ {392, 9, 4}, /*00167*/ {408, 9, 4}, /*00168*/ {193, -1, -1}, /*00169*/ {0, -1, -1}, /*00170*/ {0, -1, -1}, /*00171*/ {0, -1, -1}, /*00172*/ {0, -1, -1}, /*00173*/ {0, -1, -1}, /*00174*/ {0, -1, -1}, /*00175*/ {0, -1, -1}, /*00176*/ {0, -1, -1}, /*00177*/ {0, -1, -1}, /*00178*/ {0, -1, -1}, /*00179*/ {0, -1, -1}, /*00180*/ {0, -1, -1}, /*00181*/ {0, -1, -1}, /*00182*/ {0, -1, -1}, /*00183*/ {0, -1, -1}, /*00184*/ {195, -1, -1}, /*00185*/ {0, -1, -1}, /*00186*/ {0, -1, -1}, /*00187*/ {0, -1, -1}, /*00188*/ {0, -1, -1}, /*00189*/ {0, -1, -1}, /*00190*/ {0, -1, -1}, /*00191*/ {0, -1, -1}, /*00192*/ {0, -1, -1}, /*00193*/ {0, -1, -1}, /*00194*/ {0, -1, -1}, /*00195*/ {0, -1, -1}, /*00196*/ {0, -1, -1}, /*00197*/ {0, -1, -1}, /*00198*/ {0, -1, -1}, /*00199*/ {0, -1, -1}, /*00200*/ {197, -1, -1}, /*00201*/ {0, -1, -1}, /*00202*/ {0, -1, -1}, /*00203*/ {0, -1, -1}, /*00204*/ {0, -1, -1}, /*00205*/ {0, -1, -1}, /*00206*/ {0, -1, -1}, /*00207*/ {0, -1, -1}, /*00208*/ {0, -1, -1}, /*00209*/ {0, -1, -1}, /*00210*/ {0, -1, -1}, /*00211*/ {0, -1, -1}, /*00212*/ {0, -1, -1}, /*00213*/ {0, -1, -1}, /*00214*/ {0, -1, -1}, /*00215*/ {0, -1, -1}, /*00216*/ {195, -1, -1}, /*00217*/ {0, -1, -1}, /*00218*/ {0, -1, -1}, /*00219*/ {0, -1, -1}, /*00220*/ {0, -1, -1}, /*00221*/ {0, -1, -1}, /*00222*/ {0, -1, -1}, /*00223*/ {0, -1, -1}, /*00224*/ {0, -1, -1}, /*00225*/ {0, -1, -1}, /*00226*/ {0, -1, -1}, /*00227*/ {0, -1, -1}, /*00228*/ {0, -1, -1}, /*00229*/ {0, -1, -1}, /*00230*/ {0, -1, -1}, /*00231*/ {0, -1, -1}, /*00232*/ {199, -1, -1}, /*00233*/ {0, -1, -1}, /*00234*/ {0, -1, -1}, /*00235*/ {0, -1, -1}, /*00236*/ {0, -1, -1}, /*00237*/ {0, -1, -1}, /*00238*/ {0, -1, -1}, /*00239*/ {0, -1, -1}, /*00240*/ {0, -1, -1}, /*00241*/ {0, -1, -1}, /*00242*/ {0, -1, -1}, /*00243*/ {0, -1, -1}, /*00244*/ {0, -1, -1}, /*00245*/ {0, -1, -1}, /*00246*/ {0, -1, -1}, /*00247*/ {0, -1, -1}, /*00248*/ {201, -1, -1}, /*00249*/ {0, -1, -1}, /*00250*/ {0, -1, -1}, /*00251*/ {0, -1, -1}, /*00252*/ {0, -1, -1}, /*00253*/ {0, -1, -1}, /*00254*/ {0, -1, -1}, /*00255*/ {0, -1, -1}, /*00256*/ {0, -1, -1}, /*00257*/ {0, -1, -1}, /*00258*/ {0, -1, -1}, /*00259*/ {0, -1, -1}, /*00260*/ {0, -1, -1}, /*00261*/ {0, -1, -1}, /*00262*/ {0, -1, -1}, /*00263*/ {0, -1, -1}, /*00264*/ {203, -1, -1}, /*00265*/ {0, -1, -1}, /*00266*/ {0, -1, -1}, /*00267*/ {0, -1, -1}, /*00268*/ {0, -1, -1}, /*00269*/ {0, -1, -1}, /*00270*/ {0, -1, -1}, /*00271*/ {0, -1, -1}, /*00272*/ {0, -1, -1}, /*00273*/ {0, -1, -1}, /*00274*/ {0, -1, -1}, /*00275*/ {0, -1, -1}, /*00276*/ {0, -1, -1}, /*00277*/ {0, -1, -1}, /*00278*/ {0, -1, -1}, /*00279*/ {0, -1, -1}, /*00280*/ {201, -1, -1}, /*00281*/ {0, -1, -1}, /*00282*/ {0, -1, -1}, /*00283*/ {0, -1, -1}, /*00284*/ {0, -1, -1}, /*00285*/ {0, -1, -1}, /*00286*/ {0, -1, -1}, /*00287*/ {0, -1, -1}, /*00288*/ {0, -1, -1}, /*00289*/ {0, -1, -1}, /*00290*/ {0, -1, -1}, /*00291*/ {0, -1, -1}, /*00292*/ {0, -1, -1}, /*00293*/ {0, -1, -1}, /*00294*/ {0, -1, -1}, /*00295*/ {0, -1, -1}, /*00296*/ {194, -1, -1}, /*00297*/ {0, -1, -1}, /*00298*/ {0, -1, -1}, /*00299*/ {0, -1, -1}, /*00300*/ {0, -1, -1}, /*00301*/ {0, -1, -1}, /*00302*/ {0, -1, -1}, /*00303*/ {0, -1, -1}, /*00304*/ {0, -1, -1}, /*00305*/ {0, -1, -1}, /*00306*/ {0, -1, -1}, /*00307*/ {0, -1, -1}, /*00308*/ {0, -1, -1}, /*00309*/ {0, -1, -1}, /*00310*/ {0, -1, -1}, /*00311*/ {0, -1, -1}, /*00312*/ {196, -1, -1}, /*00313*/ {0, -1, -1}, /*00314*/ {0, -1, -1}, /*00315*/ {0, -1, -1}, /*00316*/ {0, -1, -1}, /*00317*/ {0, -1, -1}, /*00318*/ {0, -1, -1}, /*00319*/ {0, -1, -1}, /*00320*/ {0, -1, -1}, /*00321*/ {0, -1, -1}, /*00322*/ {0, -1, -1}, /*00323*/ {0, -1, -1}, /*00324*/ {0, -1, -1}, /*00325*/ {0, -1, -1}, /*00326*/ {0, -1, -1}, /*00327*/ {0, -1, -1}, /*00328*/ {198, -1, -1}, /*00329*/ {0, -1, -1}, /*00330*/ {0, -1, -1}, /*00331*/ {0, -1, -1}, /*00332*/ {0, -1, -1}, /*00333*/ {0, -1, -1}, /*00334*/ {0, -1, -1}, /*00335*/ {0, -1, -1}, /*00336*/ {0, -1, -1}, /*00337*/ {0, -1, -1}, /*00338*/ {0, -1, -1}, /*00339*/ {0, -1, -1}, /*00340*/ {0, -1, -1}, /*00341*/ {0, -1, -1}, /*00342*/ {0, -1, -1}, /*00343*/ {0, -1, -1}, /*00344*/ {196, -1, -1}, /*00345*/ {0, -1, -1}, /*00346*/ {0, -1, -1}, /*00347*/ {0, -1, -1}, /*00348*/ {0, -1, -1}, /*00349*/ {0, -1, -1}, /*00350*/ {0, -1, -1}, /*00351*/ {0, -1, -1}, /*00352*/ {0, -1, -1}, /*00353*/ {0, -1, -1}, /*00354*/ {0, -1, -1}, /*00355*/ {0, -1, -1}, /*00356*/ {0, -1, -1}, /*00357*/ {0, -1, -1}, /*00358*/ {0, -1, -1}, /*00359*/ {0, -1, -1}, /*00360*/ {200, -1, -1}, /*00361*/ {0, -1, -1}, /*00362*/ {0, -1, -1}, /*00363*/ {0, -1, -1}, /*00364*/ {0, -1, -1}, /*00365*/ {0, -1, -1}, /*00366*/ {0, -1, -1}, /*00367*/ {0, -1, -1}, /*00368*/ {0, -1, -1}, /*00369*/ {0, -1, -1}, /*00370*/ {0, -1, -1}, /*00371*/ {0, -1, -1}, /*00372*/ {0, -1, -1}, /*00373*/ {0, -1, -1}, /*00374*/ {0, -1, -1}, /*00375*/ {0, -1, -1}, /*00376*/ {202, -1, -1}, /*00377*/ {0, -1, -1}, /*00378*/ {0, -1, -1}, /*00379*/ {0, -1, -1}, /*00380*/ {0, -1, -1}, /*00381*/ {0, -1, -1}, /*00382*/ {0, -1, -1}, /*00383*/ {0, -1, -1}, /*00384*/ {0, -1, -1}, /*00385*/ {0, -1, -1}, /*00386*/ {0, -1, -1}, /*00387*/ {0, -1, -1}, /*00388*/ {0, -1, -1}, /*00389*/ {0, -1, -1}, /*00390*/ {0, -1, -1}, /*00391*/ {0, -1, -1}, /*00392*/ {204, -1, -1}, /*00393*/ {0, -1, -1}, /*00394*/ {0, -1, -1}, /*00395*/ {0, -1, -1}, /*00396*/ {0, -1, -1}, /*00397*/ {0, -1, -1}, /*00398*/ {0, -1, -1}, /*00399*/ {0, -1, -1}, /*00400*/ {0, -1, -1}, /*00401*/ {0, -1, -1}, /*00402*/ {0, -1, -1}, /*00403*/ {0, -1, -1}, /*00404*/ {0, -1, -1}, /*00405*/ {0, -1, -1}, /*00406*/ {0, -1, -1}, /*00407*/ {0, -1, -1}, /*00408*/ {202, -1, -1}, /*00409*/ {0, -1, -1}, /*00410*/ {0, -1, -1}, /*00411*/ {0, -1, -1}, /*00412*/ {0, -1, -1}, /*00413*/ {0, -1, -1}, /*00414*/ {0, -1, -1}, /*00415*/ {0, -1, -1}, /*00416*/ {0, -1, -1}, /*00417*/ {0, -1, -1}, /*00418*/ {0, -1, -1}, /*00419*/ {0, -1, -1}, /*00420*/ {0, -1, -1}, /*00421*/ {0, -1, -1}, /*00422*/ {0, -1, -1}, /*00423*/ {0, -1, -1}, /*00424*/ {432, 27, 4}, /*00425*/ {0, -1, -1}, /*00426*/ {0, -1, -1}, /*00427*/ {0, -1, -1}, /*00428*/ {1051, -1, -1}, /*00429*/ {1052, -1, -1}, /*00430*/ {1053, -1, -1}, /*00431*/ {1054, -1, -1}, /*00432*/ {448, 31, 2}, /*00433*/ {452, 31, 2}, /*00434*/ {456, 31, 2}, /*00435*/ {460, 31, 2}, /*00436*/ {1106, -1, -1}, /*00437*/ {1107, -1, -1}, /*00438*/ {1108, -1, -1}, /*00439*/ {1109, -1, -1}, /*00440*/ {464, 31, 2}, /*00441*/ {0, -1, -1}, /*00442*/ {468, 31, 2}, /*00443*/ {0, -1, -1}, /*00444*/ {472, 31, 2}, /*00445*/ {0, -1, -1}, /*00446*/ {0, -1, -1}, /*00447*/ {0, -1, -1}, /*00448*/ {1078, -1, -1}, /*00449*/ {1055, -1, -1}, /*00450*/ {1056, -1, -1}, /*00451*/ {1059, -1, -1}, /*00452*/ {1079, -1, -1}, /*00453*/ {0, -1, -1}, /*00454*/ {0, -1, -1}, /*00455*/ {1060, -1, -1}, /*00456*/ {0, -1, -1}, /*00457*/ {1064, -1, -1}, /*00458*/ {1057, -1, -1}, /*00459*/ {0, -1, -1}, /*00460*/ {0, -1, -1}, /*00461*/ {1065, -1, -1}, /*00462*/ {1058, -1, -1}, /*00463*/ {1061, -1, -1}, /*00464*/ {0, -1, -1}, /*00465*/ {0, -1, -1}, /*00466*/ {1069, -1, -1}, /*00467*/ {0, -1, -1}, /*00468*/ {1063, -1, -1}, /*00469*/ {0, -1, -1}, /*00470*/ {0, -1, -1}, /*00471*/ {0, -1, -1}, /*00472*/ {1062, -1, -1}, /*00473*/ {0, -1, -1}, /*00474*/ {0, -1, -1}, /*00475*/ {0, -1, -1}, /*00476*/ {478, 27, 6}, /*00477*/ {586, 34, 3}, /*00478*/ {1552, -1, -1}, /*00479*/ {1553, -1, -1}, /*00480*/ {0, -1, -1}, /*00481*/ {0, -1, -1}, /*00482*/ {542, 34, 2}, /*00483*/ {546, 34, 2}, /*00484*/ {0, -1, -1}, /*00485*/ {0, -1, -1}, /*00486*/ {550, 34, 2}, /*00487*/ {0, -1, -1}, /*00488*/ {0, -1, -1}, /*00489*/ {0, -1, -1}, /*00490*/ {0, -1, -1}, /*00491*/ {0, -1, -1}, /*00492*/ {0, -1, -1}, /*00493*/ {0, -1, -1}, /*00494*/ {1488, -1, -1}, /*00495*/ {1489, -1, -1}, /*00496*/ {1490, -1, -1}, /*00497*/ {0, -1, -1}, /*00498*/ {554, 34, 2}, /*00499*/ {558, 34, 2}, /*00500*/ {562, 34, 2}, /*00501*/ {566, 34, 2}, /*00502*/ {570, 34, 2}, /*00503*/ {574, 34, 2}, /*00504*/ {578, 34, 2}, /*00505*/ {582, 34, 2}, /*00506*/ {1539, -1, -1}, /*00507*/ {0, -1, -1}, /*00508*/ {0, -1, -1}, /*00509*/ {0, -1, -1}, /*00510*/ {0, -1, -1}, /*00511*/ {0, -1, -1}, /*00512*/ {0, -1, -1}, /*00513*/ {0, -1, -1}, /*00514*/ {0, -1, -1}, /*00515*/ {0, -1, -1}, /*00516*/ {0, -1, -1}, /*00517*/ {0, -1, -1}, /*00518*/ {1496, -1, -1}, /*00519*/ {0, -1, -1}, /*00520*/ {0, -1, -1}, /*00521*/ {0, -1, -1}, /*00522*/ {1500, -1, -1}, /*00523*/ {1501, -1, -1}, /*00524*/ {1502, -1, -1}, /*00525*/ {1503, -1, -1}, /*00526*/ {0, -1, -1}, /*00527*/ {0, -1, -1}, /*00528*/ {0, -1, -1}, /*00529*/ {0, -1, -1}, /*00530*/ {1497, -1, -1}, /*00531*/ {1498, -1, -1}, /*00532*/ {1499, -1, -1}, /*00533*/ {0, -1, -1}, /*00534*/ {0, -1, -1}, /*00535*/ {1491, -1, -1}, /*00536*/ {1492, -1, -1}, /*00537*/ {1493, -1, -1}, /*00538*/ {1494, -1, -1}, /*00539*/ {1495, -1, -1}, /*00540*/ {0, -1, -1}, /*00541*/ {0, -1, -1}, /*00542*/ {1540, -1, -1}, /*00543*/ {1541, -1, -1}, /*00544*/ {1542, -1, -1}, /*00545*/ {1543, -1, -1}, /*00546*/ {1544, -1, -1}, /*00547*/ {1545, -1, -1}, /*00548*/ {1546, -1, -1}, /*00549*/ {1547, -1, -1}, /*00550*/ {1548, -1, -1}, /*00551*/ {1549, -1, -1}, /*00552*/ {1550, -1, -1}, /*00553*/ {1551, -1, -1}, /*00554*/ {1424, -1, -1}, /*00555*/ {1425, -1, -1}, /*00556*/ {1426, -1, -1}, /*00557*/ {1427, -1, -1}, /*00558*/ {1428, -1, -1}, /*00559*/ {1429, -1, -1}, /*00560*/ {1430, -1, -1}, /*00561*/ {1431, -1, -1}, /*00562*/ {1432, -1, -1}, /*00563*/ {1433, -1, -1}, /*00564*/ {1434, -1, -1}, /*00565*/ {1435, -1, -1}, /*00566*/ {1436, -1, -1}, /*00567*/ {1437, -1, -1}, /*00568*/ {1438, -1, -1}, /*00569*/ {1439, -1, -1}, /*00570*/ {1507, -1, -1}, /*00571*/ {1508, -1, -1}, /*00572*/ {1509, -1, -1}, /*00573*/ {1510, -1, -1}, /*00574*/ {1511, -1, -1}, /*00575*/ {1512, -1, -1}, /*00576*/ {1513, -1, -1}, /*00577*/ {1514, -1, -1}, /*00578*/ {1515, -1, -1}, /*00579*/ {1516, -1, -1}, /*00580*/ {1517, -1, -1}, /*00581*/ {1518, -1, -1}, /*00582*/ {1519, -1, -1}, /*00583*/ {1520, -1, -1}, /*00584*/ {1521, -1, -1}, /*00585*/ {1522, -1, -1}, /*00586*/ {1408, -1, -1}, /*00587*/ {1409, -1, -1}, /*00588*/ {1410, -1, -1}, /*00589*/ {1411, -1, -1}, /*00590*/ {1416, -1, -1}, /*00591*/ {1417, -1, -1}, /*00592*/ {1418, -1, -1}, /*00593*/ {1419, -1, -1}, /*00594*/ {1320, -1, -1}, /*00595*/ {0, -1, -1}, /*00596*/ {1312, -1, -1}, /*00597*/ {0, -1, -1}, /*00598*/ {1313, -1, -1}, /*00599*/ {1314, -1, -1}, /*00600*/ {0, -1, -1}, /*00601*/ {0, -1, -1}, /*00602*/ {1315, -1, -1}, /*00603*/ {1316, -1, -1}, /*00604*/ {0, -1, -1}, /*00605*/ {0, -1, -1}, /*00606*/ {1317, -1, -1}, /*00607*/ {1318, -1, -1}, /*00608*/ {0, -1, -1}, /*00609*/ {0, -1, -1}, /*00610*/ {1319, -1, -1}, /*00611*/ {0, -1, -1}, /*00612*/ {0, -1, -1}, /*00613*/ {0, -1, -1}, /*00614*/ {0, -1, -1}, /*00615*/ {0, -1, -1}, /*00616*/ {0, -1, -1}, /*00617*/ {0, -1, -1}, /*00618*/ {0, -1, -1}, /*00619*/ {0, -1, -1}, /*00620*/ {0, -1, -1}, /*00621*/ {0, -1, -1}, /*00622*/ {0, -1, -1}, /*00623*/ {0, -1, -1}, /*00624*/ {0, -1, -1}, /*00625*/ {0, -1, -1}, /*00626*/ {658, 33, 3}, /*00627*/ {762, 33, 3}, /*00628*/ {0, -1, -1}, /*00629*/ {0, -1, -1}, /*00630*/ {0, -1, -1}, /*00631*/ {0, -1, -1}, /*00632*/ {0, -1, -1}, /*00633*/ {0, -1, -1}, /*00634*/ {0, -1, -1}, /*00635*/ {0, -1, -1}, /*00636*/ {0, -1, -1}, /*00637*/ {0, -1, -1}, /*00638*/ {0, -1, -1}, /*00639*/ {0, -1, -1}, /*00640*/ {0, -1, -1}, /*00641*/ {0, -1, -1}, /*00642*/ {0, -1, -1}, /*00643*/ {0, -1, -1}, /*00644*/ {0, -1, -1}, /*00645*/ {0, -1, -1}, /*00646*/ {0, -1, -1}, /*00647*/ {0, -1, -1}, /*00648*/ {0, -1, -1}, /*00649*/ {0, -1, -1}, /*00650*/ {0, -1, -1}, /*00651*/ {0, -1, -1}, /*00652*/ {0, -1, -1}, /*00653*/ {0, -1, -1}, /*00654*/ {0, -1, -1}, /*00655*/ {0, -1, -1}, /*00656*/ {0, -1, -1}, /*00657*/ {0, -1, -1}, /*00658*/ {666, 6, 3}, /*00659*/ {678, 6, 3}, /*00660*/ {690, 6, 3}, /*00661*/ {702, 6, 3}, /*00662*/ {714, 6, 3}, /*00663*/ {726, 6, 3}, /*00664*/ {738, 6, 3}, /*00665*/ {750, 6, 3}, /*00666*/ {674, 12, 1}, /*00667*/ {676, 12, 1}, /*00668*/ {0, -1, -1}, /*00669*/ {0, -1, -1}, /*00670*/ {0, -1, -1}, /*00671*/ {0, -1, -1}, /*00672*/ {0, -1, -1}, /*00673*/ {0, -1, -1}, /*00674*/ {1232, -1, -1}, /*00675*/ {1233, -1, -1}, /*00676*/ {1248, -1, -1}, /*00677*/ {1249, -1, -1}, /*00678*/ {686, 12, 1}, /*00679*/ {688, 12, 1}, /*00680*/ {0, -1, -1}, /*00681*/ {0, -1, -1}, /*00682*/ {0, -1, -1}, /*00683*/ {0, -1, -1}, /*00684*/ {0, -1, -1}, /*00685*/ {0, -1, -1}, /*00686*/ {1234, -1, -1}, /*00687*/ {1235, -1, -1}, /*00688*/ {1250, -1, -1}, /*00689*/ {1251, -1, -1}, /*00690*/ {698, 12, 1}, /*00691*/ {700, 12, 1}, /*00692*/ {0, -1, -1}, /*00693*/ {0, -1, -1}, /*00694*/ {0, -1, -1}, /*00695*/ {0, -1, -1}, /*00696*/ {0, -1, -1}, /*00697*/ {0, -1, -1}, /*00698*/ {1236, -1, -1}, /*00699*/ {1237, -1, -1}, /*00700*/ {1252, -1, -1}, /*00701*/ {1253, -1, -1}, /*00702*/ {710, 12, 1}, /*00703*/ {712, 12, 1}, /*00704*/ {0, -1, -1}, /*00705*/ {0, -1, -1}, /*00706*/ {0, -1, -1}, /*00707*/ {0, -1, -1}, /*00708*/ {0, -1, -1}, /*00709*/ {0, -1, -1}, /*00710*/ {1238, -1, -1}, /*00711*/ {1239, -1, -1}, /*00712*/ {1254, -1, -1}, /*00713*/ {1255, -1, -1}, /*00714*/ {722, 12, 1}, /*00715*/ {724, 12, 1}, /*00716*/ {0, -1, -1}, /*00717*/ {0, -1, -1}, /*00718*/ {0, -1, -1}, /*00719*/ {0, -1, -1}, /*00720*/ {0, -1, -1}, /*00721*/ {0, -1, -1}, /*00722*/ {1240, -1, -1}, /*00723*/ {1241, -1, -1}, /*00724*/ {1256, -1, -1}, /*00725*/ {1257, -1, -1}, /*00726*/ {734, 12, 1}, /*00727*/ {736, 12, 1}, /*00728*/ {0, -1, -1}, /*00729*/ {0, -1, -1}, /*00730*/ {0, -1, -1}, /*00731*/ {0, -1, -1}, /*00732*/ {0, -1, -1}, /*00733*/ {0, -1, -1}, /*00734*/ {1242, -1, -1}, /*00735*/ {1243, -1, -1}, /*00736*/ {1258, -1, -1}, /*00737*/ {1259, -1, -1}, /*00738*/ {746, 12, 1}, /*00739*/ {748, 12, 1}, /*00740*/ {0, -1, -1}, /*00741*/ {0, -1, -1}, /*00742*/ {0, -1, -1}, /*00743*/ {0, -1, -1}, /*00744*/ {0, -1, -1}, /*00745*/ {0, -1, -1}, /*00746*/ {1244, -1, -1}, /*00747*/ {1245, -1, -1}, /*00748*/ {1260, -1, -1}, /*00749*/ {1261, -1, -1}, /*00750*/ {758, 12, 1}, /*00751*/ {760, 12, 1}, /*00752*/ {0, -1, -1}, /*00753*/ {0, -1, -1}, /*00754*/ {0, -1, -1}, /*00755*/ {0, -1, -1}, /*00756*/ {0, -1, -1}, /*00757*/ {0, -1, -1}, /*00758*/ {1246, -1, -1}, /*00759*/ {1247, -1, -1}, /*00760*/ {1262, -1, -1}, /*00761*/ {1263, -1, -1}, /*00762*/ {770, 6, 3}, /*00763*/ {780, 6, 3}, /*00764*/ {790, 6, 3}, /*00765*/ {800, 6, 3}, /*00766*/ {810, 6, 3}, /*00767*/ {820, 6, 3}, /*00768*/ {830, 6, 3}, /*00769*/ {840, 6, 3}, /*00770*/ {0, -1, -1}, /*00771*/ {0, -1, -1}, /*00772*/ {0, -1, -1}, /*00773*/ {0, -1, -1}, /*00774*/ {778, 12, 1}, /*00775*/ {0, -1, -1}, /*00776*/ {0, -1, -1}, /*00777*/ {0, -1, -1}, /*00778*/ {1264, -1, -1}, /*00779*/ {1265, -1, -1}, /*00780*/ {0, -1, -1}, /*00781*/ {0, -1, -1}, /*00782*/ {0, -1, -1}, /*00783*/ {0, -1, -1}, /*00784*/ {788, 12, 1}, /*00785*/ {0, -1, -1}, /*00786*/ {0, -1, -1}, /*00787*/ {0, -1, -1}, /*00788*/ {1266, -1, -1}, /*00789*/ {1267, -1, -1}, /*00790*/ {0, -1, -1}, /*00791*/ {0, -1, -1}, /*00792*/ {0, -1, -1}, /*00793*/ {0, -1, -1}, /*00794*/ {798, 12, 1}, /*00795*/ {0, -1, -1}, /*00796*/ {0, -1, -1}, /*00797*/ {0, -1, -1}, /*00798*/ {1268, -1, -1}, /*00799*/ {1269, -1, -1}, /*00800*/ {0, -1, -1}, /*00801*/ {0, -1, -1}, /*00802*/ {0, -1, -1}, /*00803*/ {0, -1, -1}, /*00804*/ {808, 12, 1}, /*00805*/ {0, -1, -1}, /*00806*/ {0, -1, -1}, /*00807*/ {0, -1, -1}, /*00808*/ {1270, -1, -1}, /*00809*/ {1271, -1, -1}, /*00810*/ {0, -1, -1}, /*00811*/ {0, -1, -1}, /*00812*/ {0, -1, -1}, /*00813*/ {0, -1, -1}, /*00814*/ {818, 12, 1}, /*00815*/ {0, -1, -1}, /*00816*/ {0, -1, -1}, /*00817*/ {0, -1, -1}, /*00818*/ {1272, -1, -1}, /*00819*/ {1273, -1, -1}, /*00820*/ {0, -1, -1}, /*00821*/ {0, -1, -1}, /*00822*/ {0, -1, -1}, /*00823*/ {0, -1, -1}, /*00824*/ {828, 12, 1}, /*00825*/ {0, -1, -1}, /*00826*/ {0, -1, -1}, /*00827*/ {0, -1, -1}, /*00828*/ {1274, -1, -1}, /*00829*/ {1275, -1, -1}, /*00830*/ {0, -1, -1}, /*00831*/ {0, -1, -1}, /*00832*/ {0, -1, -1}, /*00833*/ {0, -1, -1}, /*00834*/ {838, 12, 1}, /*00835*/ {0, -1, -1}, /*00836*/ {0, -1, -1}, /*00837*/ {0, -1, -1}, /*00838*/ {1276, -1, -1}, /*00839*/ {1277, -1, -1}, /*00840*/ {0, -1, -1}, /*00841*/ {0, -1, -1}, /*00842*/ {0, -1, -1}, /*00843*/ {0, -1, -1}, /*00844*/ {848, 12, 1}, /*00845*/ {0, -1, -1}, /*00846*/ {0, -1, -1}, /*00847*/ {0, -1, -1}, /*00848*/ {1278, -1, -1}, /*00849*/ {1279, -1, -1}, /*00850*/ {1554, -1, -1}, /*00851*/ {1555, -1, -1}, /*00852*/ {0, -1, -1}, /*00853*/ {0, -1, -1}, /*00854*/ {0, -1, -1}, /*00855*/ {0, -1, -1}, /*00856*/ {0, -1, -1}, /*00857*/ {0, -1, -1}, /*00858*/ {0, -1, -1}, /*00859*/ {0, -1, -1}, /*00860*/ {0, -1, -1}, /*00861*/ {0, -1, -1}, /*00862*/ {0, -1, -1}, /*00863*/ {0, -1, -1}, /*00864*/ {0, -1, -1}, /*00865*/ {0, -1, -1}, /*00866*/ {0, -1, -1}, /*00867*/ {0, -1, -1}, /*00868*/ {0, -1, -1}, /*00869*/ {0, -1, -1}, /*00870*/ {0, -1, -1}, /*00871*/ {0, -1, -1}, /*00872*/ {0, -1, -1}, /*00873*/ {0, -1, -1}, /*00874*/ {0, -1, -1}, /*00875*/ {0, -1, -1}, /*00876*/ {0, -1, -1}, /*00877*/ {0, -1, -1}, /*00878*/ {0, -1, -1}, /*00879*/ {0, -1, -1}, /*00880*/ {0, -1, -1}, /*00881*/ {0, -1, -1}, /*00882*/ {0, -1, -1}, /*00883*/ {0, -1, -1}, /*00884*/ {0, -1, -1}, /*00885*/ {0, -1, -1}, /*00886*/ {0, -1, -1}, /*00887*/ {0, -1, -1}, /*00888*/ {0, -1, -1}, /*00889*/ {0, -1, -1}, /*00890*/ {0, -1, -1}, /*00891*/ {0, -1, -1}, /*00892*/ {0, -1, -1}, /*00893*/ {0, -1, -1}, /*00894*/ {0, -1, -1}, /*00895*/ {0, -1, -1}, /*00896*/ {0, -1, -1}, /*00897*/ {0, -1, -1}, /*00898*/ {0, -1, -1}, /*00899*/ {0, -1, -1}, /*00900*/ {0, -1, -1}, /*00901*/ {0, -1, -1}, /*00902*/ {0, -1, -1}, /*00903*/ {0, -1, -1}, /*00904*/ {0, -1, -1}, /*00905*/ {0, -1, -1}, /*00906*/ {0, -1, -1}, /*00907*/ {0, -1, -1}, /*00908*/ {0, -1, -1}, /*00909*/ {0, -1, -1}, /*00910*/ {0, -1, -1}, /*00911*/ {0, -1, -1}, /*00912*/ {0, -1, -1}, /*00913*/ {0, -1, -1}, /*00914*/ {0, -1, -1}, /*00915*/ {0, -1, -1}, /*00916*/ {0, -1, -1}, /*00917*/ {0, -1, -1}, /*00918*/ {0, -1, -1}, /*00919*/ {0, -1, -1}, /*00920*/ {0, -1, -1}, /*00921*/ {0, -1, -1}, /*00922*/ {0, -1, -1}, /*00923*/ {0, -1, -1}, /*00924*/ {0, -1, -1}, /*00925*/ {0, -1, -1}, /*00926*/ {0, -1, -1}, /*00927*/ {0, -1, -1}, /*00928*/ {0, -1, -1}, /*00929*/ {0, -1, -1}, /*00930*/ {0, -1, -1}, /*00931*/ {0, -1, -1}, /*00932*/ {0, -1, -1}, /*00933*/ {0, -1, -1}, /*00934*/ {0, -1, -1}, /*00935*/ {0, -1, -1}, /*00936*/ {0, -1, -1}, /*00937*/ {0, -1, -1}, /*00938*/ {0, -1, -1}, /*00939*/ {0, -1, -1}, /*00940*/ {0, -1, -1}, /*00941*/ {0, -1, -1}, /*00942*/ {0, -1, -1}, /*00943*/ {0, -1, -1}, /*00944*/ {0, -1, -1}, /*00945*/ {0, -1, -1}, /*00946*/ {0, -1, -1}, /*00947*/ {0, -1, -1}, /*00948*/ {0, -1, -1}, /*00949*/ {0, -1, -1}, /*00950*/ {0, -1, -1}, /*00951*/ {0, -1, -1}, /*00952*/ {0, -1, -1}, /*00953*/ {0, -1, -1}, /*00954*/ {0, -1, -1}, /*00955*/ {0, -1, -1}, /*00956*/ {0, -1, -1}, /*00957*/ {0, -1, -1}, /*00958*/ {0, -1, -1}, /*00959*/ {0, -1, -1}, /*00960*/ {0, -1, -1}, /*00961*/ {0, -1, -1}, /*00962*/ {0, -1, -1}, /*00963*/ {0, -1, -1}, /*00964*/ {0, -1, -1}, /*00965*/ {0, -1, -1}, /*00966*/ {0, -1, -1}, /*00967*/ {0, -1, -1}, /*00968*/ {0, -1, -1}, /*00969*/ {0, -1, -1}, /*00970*/ {0, -1, -1}, /*00971*/ {0, -1, -1}, /*00972*/ {0, -1, -1}, /*00973*/ {0, -1, -1}, /*00974*/ {0, -1, -1}, /*00975*/ {0, -1, -1}, /*00976*/ {0, -1, -1}, /*00977*/ {0, -1, -1}, /*00978*/ {0, -1, -1}, /*00979*/ {0, -1, -1}, /*00980*/ {0, -1, -1}, /*00981*/ {0, -1, -1}, /*00982*/ {0, -1, -1}, /*00983*/ {0, -1, -1}, /*00984*/ {0, -1, -1}, /*00985*/ {0, -1, -1}, /*00986*/ {0, -1, -1}, /*00987*/ {0, -1, -1}, /*00988*/ {0, -1, -1}, /*00989*/ {0, -1, -1}, /*00990*/ {0, -1, -1}, /*00991*/ {0, -1, -1}, /*00992*/ {0, -1, -1}, /*00993*/ {0, -1, -1}, /*00994*/ {0, -1, -1}, /*00995*/ {0, -1, -1}, /*00996*/ {0, -1, -1}, /*00997*/ {0, -1, -1}, /*00998*/ {0, -1, -1}, /*00999*/ {0, -1, -1}, /*01000*/ {0, -1, -1}, /*01001*/ {0, -1, -1}, /*01002*/ {0, -1, -1}, /*01003*/ {0, -1, -1}, /*01004*/ {0, -1, -1}, /*01005*/ {0, -1, -1}, /*01006*/ {0, -1, -1}, /*01007*/ {0, -1, -1}, /*01008*/ {0, -1, -1}, /*01009*/ {0, -1, -1}, /*01010*/ {0, -1, -1}, /*01011*/ {0, -1, -1}, /*01012*/ {0, -1, -1}, /*01013*/ {0, -1, -1}, /*01014*/ {0, -1, -1}, /*01015*/ {0, -1, -1}, /*01016*/ {0, -1, -1}, /*01017*/ {0, -1, -1}, /*01018*/ {0, -1, -1}, /*01019*/ {0, -1, -1}, /*01020*/ {0, -1, -1}, /*01021*/ {0, -1, -1}, /*01022*/ {0, -1, -1}, /*01023*/ {0, -1, -1}, /*01024*/ {0, -1, -1}, /*01025*/ {0, -1, -1}, /*01026*/ {0, -1, -1}, /*01027*/ {0, -1, -1}, /*01028*/ {0, -1, -1}, /*01029*/ {0, -1, -1}, /*01030*/ {0, -1, -1}, /*01031*/ {0, -1, -1}, /*01032*/ {0, -1, -1}, /*01033*/ {0, -1, -1}, /*01034*/ {0, -1, -1}, /*01035*/ {0, -1, -1}, /*01036*/ {0, -1, -1}, /*01037*/ {0, -1, -1}, /*01038*/ {0, -1, -1}, /*01039*/ {0, -1, -1}, /*01040*/ {0, -1, -1}, /*01041*/ {0, -1, -1}, /*01042*/ {0, -1, -1}, /*01043*/ {0, -1, -1}, /*01044*/ {0, -1, -1}, /*01045*/ {0, -1, -1}, /*01046*/ {0, -1, -1}, /*01047*/ {0, -1, -1}, /*01048*/ {0, -1, -1}, /*01049*/ {0, -1, -1}, /*01050*/ {0, -1, -1}, /*01051*/ {0, -1, -1}, /*01052*/ {0, -1, -1}, /*01053*/ {0, -1, -1}, /*01054*/ {0, -1, -1}, /*01055*/ {0, -1, -1}, /*01056*/ {0, -1, -1}, /*01057*/ {0, -1, -1}, /*01058*/ {0, -1, -1}, /*01059*/ {0, -1, -1}, /*01060*/ {0, -1, -1}, /*01061*/ {0, -1, -1}, /*01062*/ {0, -1, -1}, /*01063*/ {0, -1, -1}, /*01064*/ {0, -1, -1}, /*01065*/ {0, -1, -1}, /*01066*/ {0, -1, -1}, /*01067*/ {0, -1, -1}, /*01068*/ {0, -1, -1}, /*01069*/ {0, -1, -1}, /*01070*/ {0, -1, -1}, /*01071*/ {0, -1, -1}, /*01072*/ {0, -1, -1}, /*01073*/ {0, -1, -1}, /*01074*/ {0, -1, -1}, /*01075*/ {0, -1, -1}, /*01076*/ {0, -1, -1}, /*01077*/ {0, -1, -1}, /*01078*/ {0, -1, -1}, /*01079*/ {0, -1, -1}, /*01080*/ {0, -1, -1}, /*01081*/ {0, -1, -1}, /*01082*/ {0, -1, -1}, /*01083*/ {0, -1, -1}, /*01084*/ {0, -1, -1}, /*01085*/ {0, -1, -1}, /*01086*/ {0, -1, -1}, /*01087*/ {0, -1, -1}, /*01088*/ {0, -1, -1}, /*01089*/ {0, -1, -1}, /*01090*/ {0, -1, -1}, /*01091*/ {0, -1, -1}, /*01092*/ {0, -1, -1}, /*01093*/ {0, -1, -1}, /*01094*/ {0, -1, -1}, /*01095*/ {0, -1, -1}, /*01096*/ {0, -1, -1}, /*01097*/ {0, -1, -1}, /*01098*/ {0, -1, -1}, /*01099*/ {0, -1, -1}, /*01100*/ {0, -1, -1}, /*01101*/ {0, -1, -1}, /*01102*/ {0, -1, -1}, /*01103*/ {0, -1, -1}, /*01104*/ {0, -1, -1}, /*01105*/ {0, -1, -1}, /*01106*/ {0, -1, -1}, /*01107*/ {0, -1, -1}, /*01108*/ {0, -1, -1}, /*01109*/ {0, -1, -1}, /*01110*/ {0, -1, -1}, /*01111*/ {0, -1, -1}, /*01112*/ {0, -1, -1}, /*01113*/ {0, -1, -1}, /*01114*/ {0, -1, -1}, /*01115*/ {0, -1, -1}, /*01116*/ {0, -1, -1}, /*01117*/ {0, -1, -1}, /*01118*/ {0, -1, -1}, /*01119*/ {0, -1, -1}, /*01120*/ {0, -1, -1}, /*01121*/ {0, -1, -1}, /*01122*/ {0, -1, -1}, /*01123*/ {0, -1, -1}, /*01124*/ {0, -1, -1}, /*01125*/ {0, -1, -1}, /*01126*/ {0, -1, -1}, /*01127*/ {0, -1, -1}, /*01128*/ {0, -1, -1}, /*01129*/ {0, -1, -1}, /*01130*/ {0, -1, -1}, /*01131*/ {0, -1, -1}, /*01132*/ {0, -1, -1}, /*01133*/ {0, -1, -1}, /*01134*/ {0, -1, -1}, /*01135*/ {0, -1, -1}, /*01136*/ {0, -1, -1}, /*01137*/ {0, -1, -1}, /*01138*/ {0, -1, -1}, /*01139*/ {0, -1, -1}, /*01140*/ {0, -1, -1}, /*01141*/ {0, -1, -1}, /*01142*/ {0, -1, -1}, /*01143*/ {0, -1, -1}, /*01144*/ {0, -1, -1}, /*01145*/ {0, -1, -1}, /*01146*/ {0, -1, -1}, /*01147*/ {0, -1, -1}, /*01148*/ {0, -1, -1}, /*01149*/ {0, -1, -1}, /*01150*/ {0, -1, -1}, /*01151*/ {0, -1, -1}, /*01152*/ {0, -1, -1}, /*01153*/ {0, -1, -1}, /*01154*/ {0, -1, -1}, /*01155*/ {0, -1, -1}, /*01156*/ {0, -1, -1}, /*01157*/ {0, -1, -1}, /*01158*/ {0, -1, -1}, /*01159*/ {0, -1, -1}, /*01160*/ {0, -1, -1}, /*01161*/ {0, -1, -1}, /*01162*/ {0, -1, -1}, /*01163*/ {0, -1, -1}, /*01164*/ {0, -1, -1}, /*01165*/ {0, -1, -1}, /*01166*/ {0, -1, -1}, /*01167*/ {0, -1, -1}, /*01168*/ {0, -1, -1}, /*01169*/ {0, -1, -1}, /*01170*/ {0, -1, -1}, /*01171*/ {0, -1, -1}, /*01172*/ {0, -1, -1}, /*01173*/ {0, -1, -1}, /*01174*/ {0, -1, -1}, /*01175*/ {0, -1, -1}, /*01176*/ {0, -1, -1}, /*01177*/ {0, -1, -1}, /*01178*/ {0, -1, -1}, /*01179*/ {0, -1, -1}, /*01180*/ {0, -1, -1}, /*01181*/ {0, -1, -1}, /*01182*/ {0, -1, -1}, /*01183*/ {0, -1, -1}, /*01184*/ {0, -1, -1}, /*01185*/ {0, -1, -1}, /*01186*/ {0, -1, -1}, /*01187*/ {0, -1, -1}, /*01188*/ {0, -1, -1}, /*01189*/ {0, -1, -1}, /*01190*/ {0, -1, -1}, /*01191*/ {0, -1, -1}, /*01192*/ {0, -1, -1}, /*01193*/ {0, -1, -1}, /*01194*/ {0, -1, -1}, /*01195*/ {0, -1, -1}, /*01196*/ {0, -1, -1}, /*01197*/ {0, -1, -1}, /*01198*/ {0, -1, -1}, /*01199*/ {0, -1, -1}, /*01200*/ {0, -1, -1}, /*01201*/ {0, -1, -1}, /*01202*/ {0, -1, -1}, /*01203*/ {0, -1, -1}, /*01204*/ {0, -1, -1}, /*01205*/ {0, -1, -1}, /*01206*/ {0, -1, -1}, /*01207*/ {0, -1, -1}, /*01208*/ {0, -1, -1}, /*01209*/ {0, -1, -1}, /*01210*/ {0, -1, -1}, /*01211*/ {0, -1, -1}, /*01212*/ {0, -1, -1}, /*01213*/ {0, -1, -1}, /*01214*/ {0, -1, -1}, /*01215*/ {0, -1, -1}, /*01216*/ {0, -1, -1}, /*01217*/ {0, -1, -1}, /*01218*/ {0, -1, -1}, /*01219*/ {0, -1, -1}, /*01220*/ {0, -1, -1}, /*01221*/ {0, -1, -1}, /*01222*/ {0, -1, -1}, /*01223*/ {0, -1, -1}, /*01224*/ {0, -1, -1}, /*01225*/ {0, -1, -1}, /*01226*/ {0, -1, -1}, /*01227*/ {0, -1, -1}, /*01228*/ {0, -1, -1}, /*01229*/ {0, -1, -1}, /*01230*/ {0, -1, -1}, /*01231*/ {0, -1, -1}, /*01232*/ {0, -1, -1}, /*01233*/ {0, -1, -1}, /*01234*/ {0, -1, -1}, /*01235*/ {0, -1, -1}, /*01236*/ {0, -1, -1}, /*01237*/ {0, -1, -1}, /*01238*/ {0, -1, -1}, /*01239*/ {0, -1, -1}, /*01240*/ {0, -1, -1}, /*01241*/ {0, -1, -1}, /*01242*/ {0, -1, -1}, /*01243*/ {0, -1, -1}, /*01244*/ {0, -1, -1}, /*01245*/ {0, -1, -1}, /*01246*/ {0, -1, -1}, /*01247*/ {0, -1, -1}, /*01248*/ {0, -1, -1}, /*01249*/ {0, -1, -1}, /*01250*/ {0, -1, -1}, /*01251*/ {0, -1, -1}, /*01252*/ {0, -1, -1}, /*01253*/ {0, -1, -1}, /*01254*/ {0, -1, -1}, /*01255*/ {0, -1, -1}, /*01256*/ {0, -1, -1}, /*01257*/ {0, -1, -1}, /*01258*/ {0, -1, -1}, /*01259*/ {0, -1, -1}, /*01260*/ {0, -1, -1}, /*01261*/ {0, -1, -1}, /*01262*/ {0, -1, -1}, /*01263*/ {0, -1, -1}, /*01264*/ {0, -1, -1}, /*01265*/ {0, -1, -1}, /*01266*/ {0, -1, -1}, /*01267*/ {0, -1, -1}, /*01268*/ {0, -1, -1}, /*01269*/ {0, -1, -1}, /*01270*/ {0, -1, -1}, /*01271*/ {0, -1, -1}, /*01272*/ {0, -1, -1}, /*01273*/ {0, -1, -1}, /*01274*/ {0, -1, -1}, /*01275*/ {0, -1, -1}, /*01276*/ {0, -1, -1}, /*01277*/ {0, -1, -1}, /*01278*/ {0, -1, -1}, /*01279*/ {0, -1, -1}, /*01280*/ {0, -1, -1}, /*01281*/ {0, -1, -1}, /*01282*/ {0, -1, -1}, /*01283*/ {0, -1, -1}, /*01284*/ {0, -1, -1}, /*01285*/ {0, -1, -1}, /*01286*/ {0, -1, -1}, /*01287*/ {0, -1, -1}, /*01288*/ {0, -1, -1}, /*01289*/ {0, -1, -1}, /*01290*/ {0, -1, -1}, /*01291*/ {0, -1, -1}, /*01292*/ {0, -1, -1}, /*01293*/ {0, -1, -1}, /*01294*/ {0, -1, -1}, /*01295*/ {0, -1, -1}, /*01296*/ {0, -1, -1}, /*01297*/ {0, -1, -1}, /*01298*/ {0, -1, -1}, /*01299*/ {0, -1, -1}, /*01300*/ {0, -1, -1}, /*01301*/ {0, -1, -1}, /*01302*/ {0, -1, -1}, /*01303*/ {0, -1, -1}, /*01304*/ {0, -1, -1}, /*01305*/ {0, -1, -1}, /*01306*/ {0, -1, -1}, /*01307*/ {0, -1, -1}, /*01308*/ {0, -1, -1}, /*01309*/ {0, -1, -1}, /*01310*/ {0, -1, -1}, /*01311*/ {0, -1, -1}, /*01312*/ {0, -1, -1}, /*01313*/ {0, -1, -1}, /*01314*/ {0, -1, -1}, /*01315*/ {0, -1, -1}, /*01316*/ {0, -1, -1}, /*01317*/ {0, -1, -1}, /*01318*/ {0, -1, -1}, /*01319*/ {0, -1, -1}, /*01320*/ {0, -1, -1}, /*01321*/ {0, -1, -1}, /*01322*/ {0, -1, -1}, /*01323*/ {0, -1, -1}, /*01324*/ {0, -1, -1}, /*01325*/ {0, -1, -1}, /*01326*/ {0, -1, -1}, /*01327*/ {0, -1, -1}, /*01328*/ {0, -1, -1}, /*01329*/ {0, -1, -1}, /*01330*/ {0, -1, -1}, /*01331*/ {0, -1, -1}, /*01332*/ {0, -1, -1}, /*01333*/ {0, -1, -1}, /*01334*/ {0, -1, -1}, /*01335*/ {0, -1, -1}, /*01336*/ {0, -1, -1}, /*01337*/ {0, -1, -1}, /*01338*/ {0, -1, -1}, /*01339*/ {0, -1, -1}, /*01340*/ {0, -1, -1}, /*01341*/ {0, -1, -1}, /*01342*/ {0, -1, -1}, /*01343*/ {0, -1, -1}, /*01344*/ {0, -1, -1}, /*01345*/ {0, -1, -1}, /*01346*/ {0, -1, -1}, /*01347*/ {0, -1, -1}, /*01348*/ {0, -1, -1}, /*01349*/ {0, -1, -1}, /*01350*/ {0, -1, -1}, /*01351*/ {0, -1, -1}, /*01352*/ {0, -1, -1}, /*01353*/ {0, -1, -1}, /*01354*/ {0, -1, -1}, /*01355*/ {0, -1, -1}, /*01356*/ {0, -1, -1}, /*01357*/ {0, -1, -1}, /*01358*/ {0, -1, -1}, /*01359*/ {0, -1, -1}, /*01360*/ {0, -1, -1}, /*01361*/ {0, -1, -1}, /*01362*/ {1370, 27, 6}, /*01363*/ {1049, -1, -1}, /*01364*/ {0, -1, -1}, /*01365*/ {1050, -1, -1}, /*01366*/ {0, -1, -1}, /*01367*/ {0, -1, -1}, /*01368*/ {1073, -1, -1}, /*01369*/ {0, -1, -1}, /*01370*/ {1089, -1, -1}, /*01371*/ {1090, -1, -1}, /*01372*/ {1091, -1, -1}, /*01373*/ {1092, -1, -1}, /*01374*/ {1093, -1, -1}, /*01375*/ {1094, -1, -1}, /*01376*/ {1095, -1, -1}, /*01377*/ {0, -1, -1}, /*01378*/ {0, -1, -1}, /*01379*/ {1110, -1, -1}, /*01380*/ {1111, -1, -1}, /*01381*/ {1112, -1, -1}, /*01382*/ {1113, -1, -1}, /*01383*/ {1114, -1, -1}, /*01384*/ {1096, -1, -1}, /*01385*/ {1097, -1, -1}, /*01386*/ {1098, -1, -1}, /*01387*/ {1099, -1, -1}, /*01388*/ {1100, -1, -1}, /*01389*/ {1101, -1, -1}, /*01390*/ {1102, -1, -1}, /*01391*/ {1104, -1, -1}, /*01392*/ {1103, -1, -1}, /*01393*/ {1105, -1, -1}, /*01394*/ {1082, -1, -1}, /*01395*/ {1083, -1, -1}, /*01396*/ {1115, -1, -1}, /*01397*/ {1116, -1, -1}, /*01398*/ {0, -1, -1}, /*01399*/ {0, -1, -1}, /*01400*/ {1117, -1, -1}, /*01401*/ {1118, -1, -1}, /*01402*/ {0, -1, -1}, /*01403*/ {1077, -1, -1}, /*01404*/ {1070, -1, -1}, /*01405*/ {0, -1, -1}, /*01406*/ {1072, -1, -1}, /*01407*/ {1076, -1, -1}, /*01408*/ {0, -1, -1}, /*01409*/ {0, -1, -1}, /*01410*/ {0, -1, -1}, /*01411*/ {1075, -1, -1}, /*01412*/ {1068, -1, -1}, /*01413*/ {0, -1, -1}, /*01414*/ {1071, -1, -1}, /*01415*/ {1074, -1, -1}, /*01416*/ {1087, -1, -1}, /*01417*/ {1088, -1, -1}, /*01418*/ {1066, -1, -1}, /*01419*/ {1084, -1, -1}, /*01420*/ {1085, -1, -1}, /*01421*/ {1086, -1, -1}, /*01422*/ {1067, -1, -1}, /*01423*/ {0, -1, -1}, /*01424*/ {0, -1, -1}, /*01425*/ {0, -1, -1}, /*01426*/ {1080, -1, -1}, /*01427*/ {1081, -1, -1}, /*01428*/ {0, -1, -1}, /*01429*/ {0, -1, -1}, /*01430*/ {1119, -1, -1}, /*01431*/ {0, -1, -1}, /*01432*/ {0, -1, -1}, /*01433*/ {0, -1, -1}, /*01434*/ {1436, 27, 6}, /*01435*/ {1564, 34, 3}, /*01436*/ {0, -1, -1}, /*01437*/ {0, -1, -1}, /*01438*/ {0, -1, -1}, /*01439*/ {0, -1, -1}, /*01440*/ {0, -1, -1}, /*01441*/ {0, -1, -1}, /*01442*/ {0, -1, -1}, /*01443*/ {0, -1, -1}, /*01444*/ {0, -1, -1}, /*01445*/ {0, -1, -1}, /*01446*/ {0, -1, -1}, /*01447*/ {0, -1, -1}, /*01448*/ {0, -1, -1}, /*01449*/ {0, -1, -1}, /*01450*/ {0, -1, -1}, /*01451*/ {0, -1, -1}, /*01452*/ {1504, -1, -1}, /*01453*/ {1505, -1, -1}, /*01454*/ {1506, -1, -1}, /*01455*/ {0, -1, -1}, /*01456*/ {1500, 34, 2}, /*01457*/ {1504, 34, 2}, /*01458*/ {1508, 34, 2}, /*01459*/ {1512, 34, 2}, /*01460*/ {1516, 34, 2}, /*01461*/ {1520, 34, 2}, /*01462*/ {1524, 34, 2}, /*01463*/ {1528, 34, 2}, /*01464*/ {0, -1, -1}, /*01465*/ {0, -1, -1}, /*01466*/ {0, -1, -1}, /*01467*/ {0, -1, -1}, /*01468*/ {0, -1, -1}, /*01469*/ {0, -1, -1}, /*01470*/ {0, -1, -1}, /*01471*/ {0, -1, -1}, /*01472*/ {0, -1, -1}, /*01473*/ {0, -1, -1}, /*01474*/ {0, -1, -1}, /*01475*/ {0, -1, -1}, /*01476*/ {0, -1, -1}, /*01477*/ {0, -1, -1}, /*01478*/ {0, -1, -1}, /*01479*/ {0, -1, -1}, /*01480*/ {0, -1, -1}, /*01481*/ {0, -1, -1}, /*01482*/ {0, -1, -1}, /*01483*/ {0, -1, -1}, /*01484*/ {1532, 34, 2}, /*01485*/ {1536, 34, 2}, /*01486*/ {1540, 34, 2}, /*01487*/ {1544, 34, 2}, /*01488*/ {1548, 34, 2}, /*01489*/ {1552, 34, 2}, /*01490*/ {1556, 34, 2}, /*01491*/ {1560, 34, 2}, /*01492*/ {0, -1, -1}, /*01493*/ {0, -1, -1}, /*01494*/ {0, -1, -1}, /*01495*/ {0, -1, -1}, /*01496*/ {0, -1, -1}, /*01497*/ {0, -1, -1}, /*01498*/ {0, -1, -1}, /*01499*/ {0, -1, -1}, /*01500*/ {1440, -1, -1}, /*01501*/ {1441, -1, -1}, /*01502*/ {1442, -1, -1}, /*01503*/ {1443, -1, -1}, /*01504*/ {1444, -1, -1}, /*01505*/ {1445, -1, -1}, /*01506*/ {1446, -1, -1}, /*01507*/ {1447, -1, -1}, /*01508*/ {1448, -1, -1}, /*01509*/ {1449, -1, -1}, /*01510*/ {1450, -1, -1}, /*01511*/ {1451, -1, -1}, /*01512*/ {1452, -1, -1}, /*01513*/ {1453, -1, -1}, /*01514*/ {1454, -1, -1}, /*01515*/ {1455, -1, -1}, /*01516*/ {1523, -1, -1}, /*01517*/ {1524, -1, -1}, /*01518*/ {1525, -1, -1}, /*01519*/ {1526, -1, -1}, /*01520*/ {1527, -1, -1}, /*01521*/ {1528, -1, -1}, /*01522*/ {1529, -1, -1}, /*01523*/ {1530, -1, -1}, /*01524*/ {1531, -1, -1}, /*01525*/ {1532, -1, -1}, /*01526*/ {1533, -1, -1}, /*01527*/ {1534, -1, -1}, /*01528*/ {1535, -1, -1}, /*01529*/ {1536, -1, -1}, /*01530*/ {1537, -1, -1}, /*01531*/ {1538, -1, -1}, /*01532*/ {1456, -1, -1}, /*01533*/ {1457, -1, -1}, /*01534*/ {1458, -1, -1}, /*01535*/ {1459, -1, -1}, /*01536*/ {1460, -1, -1}, /*01537*/ {1461, -1, -1}, /*01538*/ {1462, -1, -1}, /*01539*/ {1463, -1, -1}, /*01540*/ {1464, -1, -1}, /*01541*/ {1465, -1, -1}, /*01542*/ {1466, -1, -1}, /*01543*/ {1467, -1, -1}, /*01544*/ {1468, -1, -1}, /*01545*/ {1469, -1, -1}, /*01546*/ {1470, -1, -1}, /*01547*/ {1471, -1, -1}, /*01548*/ {1472, -1, -1}, /*01549*/ {1473, -1, -1}, /*01550*/ {1474, -1, -1}, /*01551*/ {1475, -1, -1}, /*01552*/ {1476, -1, -1}, /*01553*/ {1477, -1, -1}, /*01554*/ {1478, -1, -1}, /*01555*/ {1479, -1, -1}, /*01556*/ {1480, -1, -1}, /*01557*/ {1481, -1, -1}, /*01558*/ {1482, -1, -1}, /*01559*/ {1483, -1, -1}, /*01560*/ {1484, -1, -1}, /*01561*/ {1485, -1, -1}, /*01562*/ {1486, -1, -1}, /*01563*/ {1487, -1, -1}, /*01564*/ {1412, -1, -1}, /*01565*/ {1413, -1, -1}, /*01566*/ {1414, -1, -1}, /*01567*/ {1415, -1, -1}, /*01568*/ {1420, -1, -1}, /*01569*/ {1421, -1, -1}, /*01570*/ {1422, -1, -1}, /*01571*/ {1423, -1, -1}, /*01572*/ {1588, 12, 1}, /*01573*/ {1590, 12, 1}, /*01574*/ {1592, 12, 1}, /*01575*/ {1594, 12, 1}, /*01576*/ {1596, 12, 1}, /*01577*/ {1598, 12, 1}, /*01578*/ {1600, 12, 1}, /*01579*/ {1602, 12, 1}, /*01580*/ {1604, 12, 1}, /*01581*/ {1606, 12, 1}, /*01582*/ {1608, 12, 1}, /*01583*/ {1610, 12, 1}, /*01584*/ {1612, 12, 1}, /*01585*/ {1614, 12, 1}, /*01586*/ {1616, 12, 1}, /*01587*/ {1618, 12, 1}, /*01588*/ {1280, -1, -1}, /*01589*/ {1281, -1, -1}, /*01590*/ {1280, -1, -1}, /*01591*/ {1281, -1, -1}, /*01592*/ {1280, -1, -1}, /*01593*/ {1281, -1, -1}, /*01594*/ {1282, -1, -1}, /*01595*/ {1283, -1, -1}, /*01596*/ {1280, -1, -1}, /*01597*/ {1281, -1, -1}, /*01598*/ {1284, -1, -1}, /*01599*/ {1285, -1, -1}, /*01600*/ {1280, -1, -1}, /*01601*/ {1281, -1, -1}, /*01602*/ {1286, -1, -1}, /*01603*/ {1287, -1, -1}, /*01604*/ {1288, -1, -1}, /*01605*/ {1289, -1, -1}, /*01606*/ {1288, -1, -1}, /*01607*/ {1289, -1, -1}, /*01608*/ {1288, -1, -1}, /*01609*/ {1289, -1, -1}, /*01610*/ {1290, -1, -1}, /*01611*/ {1291, -1, -1}, /*01612*/ {1288, -1, -1}, /*01613*/ {1289, -1, -1}, /*01614*/ {1292, -1, -1}, /*01615*/ {1293, -1, -1}, /*01616*/ {1288, -1, -1}, /*01617*/ {1289, -1, -1}, /*01618*/ {1294, -1, -1}, /*01619*/ {1295, -1, -1}, /*01620*/ {1321, -1, -1}, /*01621*/ {0, -1, -1}, /*01622*/ {0, -1, -1}, /*01623*/ {0, -1, -1}, /*01624*/ {0, -1, -1}, /*01625*/ {0, -1, -1}, /*01626*/ {0, -1, -1}, /*01627*/ {0, -1, -1}, /*01628*/ {0, -1, -1}, /*01629*/ {0, -1, -1}, /*01630*/ {0, -1, -1}, /*01631*/ {0, -1, -1}, /*01632*/ {0, -1, -1}, /*01633*/ {0, -1, -1}, /*01634*/ {0, -1, -1}, /*01635*/ {0, -1, -1}, /*01636*/ {1684, 0, 6}, /*01637*/ {1756, 0, 6}, /*01638*/ {0, -1, -1}, /*01639*/ {0, -1, -1}, /*01640*/ {0, -1, -1}, /*01641*/ {0, -1, -1}, /*01642*/ {0, -1, -1}, /*01643*/ {0, -1, -1}, /*01644*/ {0, -1, -1}, /*01645*/ {0, -1, -1}, /*01646*/ {0, -1, -1}, /*01647*/ {0, -1, -1}, /*01648*/ {0, -1, -1}, /*01649*/ {0, -1, -1}, /*01650*/ {0, -1, -1}, /*01651*/ {0, -1, -1}, /*01652*/ {0, -1, -1}, /*01653*/ {0, -1, -1}, /*01654*/ {0, -1, -1}, /*01655*/ {0, -1, -1}, /*01656*/ {0, -1, -1}, /*01657*/ {0, -1, -1}, /*01658*/ {0, -1, -1}, /*01659*/ {0, -1, -1}, /*01660*/ {0, -1, -1}, /*01661*/ {0, -1, -1}, /*01662*/ {0, -1, -1}, /*01663*/ {0, -1, -1}, /*01664*/ {0, -1, -1}, /*01665*/ {0, -1, -1}, /*01666*/ {0, -1, -1}, /*01667*/ {0, -1, -1}, /*01668*/ {0, -1, -1}, /*01669*/ {0, -1, -1}, /*01670*/ {0, -1, -1}, /*01671*/ {0, -1, -1}, /*01672*/ {0, -1, -1}, /*01673*/ {0, -1, -1}, /*01674*/ {0, -1, -1}, /*01675*/ {0, -1, -1}, /*01676*/ {0, -1, -1}, /*01677*/ {0, -1, -1}, /*01678*/ {0, -1, -1}, /*01679*/ {0, -1, -1}, /*01680*/ {0, -1, -1}, /*01681*/ {0, -1, -1}, /*01682*/ {0, -1, -1}, /*01683*/ {0, -1, -1}, /*01684*/ {1748, 35, 1}, /*01685*/ {0, -1, -1}, /*01686*/ {0, -1, -1}, /*01687*/ {0, -1, -1}, /*01688*/ {0, -1, -1}, /*01689*/ {0, -1, -1}, /*01690*/ {0, -1, -1}, /*01691*/ {0, -1, -1}, /*01692*/ {1750, 35, 1}, /*01693*/ {0, -1, -1}, /*01694*/ {0, -1, -1}, /*01695*/ {0, -1, -1}, /*01696*/ {0, -1, -1}, /*01697*/ {0, -1, -1}, /*01698*/ {0, -1, -1}, /*01699*/ {0, -1, -1}, /*01700*/ {1752, 35, 1}, /*01701*/ {0, -1, -1}, /*01702*/ {0, -1, -1}, /*01703*/ {0, -1, -1}, /*01704*/ {0, -1, -1}, /*01705*/ {0, -1, -1}, /*01706*/ {0, -1, -1}, /*01707*/ {0, -1, -1}, /*01708*/ {1754, 35, 1}, /*01709*/ {0, -1, -1}, /*01710*/ {0, -1, -1}, /*01711*/ {0, -1, -1}, /*01712*/ {0, -1, -1}, /*01713*/ {0, -1, -1}, /*01714*/ {0, -1, -1}, /*01715*/ {0, -1, -1}, /*01716*/ {0, -1, -1}, /*01717*/ {0, -1, -1}, /*01718*/ {0, -1, -1}, /*01719*/ {0, -1, -1}, /*01720*/ {0, -1, -1}, /*01721*/ {0, -1, -1}, /*01722*/ {0, -1, -1}, /*01723*/ {0, -1, -1}, /*01724*/ {0, -1, -1}, /*01725*/ {0, -1, -1}, /*01726*/ {0, -1, -1}, /*01727*/ {0, -1, -1}, /*01728*/ {0, -1, -1}, /*01729*/ {0, -1, -1}, /*01730*/ {0, -1, -1}, /*01731*/ {0, -1, -1}, /*01732*/ {0, -1, -1}, /*01733*/ {0, -1, -1}, /*01734*/ {0, -1, -1}, /*01735*/ {0, -1, -1}, /*01736*/ {0, -1, -1}, /*01737*/ {0, -1, -1}, /*01738*/ {0, -1, -1}, /*01739*/ {0, -1, -1}, /*01740*/ {0, -1, -1}, /*01741*/ {0, -1, -1}, /*01742*/ {0, -1, -1}, /*01743*/ {0, -1, -1}, /*01744*/ {0, -1, -1}, /*01745*/ {0, -1, -1}, /*01746*/ {0, -1, -1}, /*01747*/ {0, -1, -1}, /*01748*/ {1304, -1, -1}, /*01749*/ {1305, -1, -1}, /*01750*/ {1304, -1, -1}, /*01751*/ {1305, -1, -1}, /*01752*/ {1306, -1, -1}, /*01753*/ {1307, -1, -1}, /*01754*/ {1304, -1, -1}, /*01755*/ {1305, -1, -1}, /*01756*/ {1820, 35, 1}, /*01757*/ {0, -1, -1}, /*01758*/ {0, -1, -1}, /*01759*/ {0, -1, -1}, /*01760*/ {0, -1, -1}, /*01761*/ {0, -1, -1}, /*01762*/ {0, -1, -1}, /*01763*/ {0, -1, -1}, /*01764*/ {1822, 35, 1}, /*01765*/ {0, -1, -1}, /*01766*/ {0, -1, -1}, /*01767*/ {0, -1, -1}, /*01768*/ {0, -1, -1}, /*01769*/ {0, -1, -1}, /*01770*/ {0, -1, -1}, /*01771*/ {0, -1, -1}, /*01772*/ {1824, 35, 1}, /*01773*/ {0, -1, -1}, /*01774*/ {0, -1, -1}, /*01775*/ {0, -1, -1}, /*01776*/ {0, -1, -1}, /*01777*/ {0, -1, -1}, /*01778*/ {0, -1, -1}, /*01779*/ {0, -1, -1}, /*01780*/ {1826, 35, 1}, /*01781*/ {0, -1, -1}, /*01782*/ {0, -1, -1}, /*01783*/ {0, -1, -1}, /*01784*/ {0, -1, -1}, /*01785*/ {0, -1, -1}, /*01786*/ {0, -1, -1}, /*01787*/ {0, -1, -1}, /*01788*/ {0, -1, -1}, /*01789*/ {0, -1, -1}, /*01790*/ {0, -1, -1}, /*01791*/ {0, -1, -1}, /*01792*/ {0, -1, -1}, /*01793*/ {0, -1, -1}, /*01794*/ {0, -1, -1}, /*01795*/ {0, -1, -1}, /*01796*/ {0, -1, -1}, /*01797*/ {0, -1, -1}, /*01798*/ {0, -1, -1}, /*01799*/ {0, -1, -1}, /*01800*/ {0, -1, -1}, /*01801*/ {0, -1, -1}, /*01802*/ {0, -1, -1}, /*01803*/ {0, -1, -1}, /*01804*/ {0, -1, -1}, /*01805*/ {0, -1, -1}, /*01806*/ {0, -1, -1}, /*01807*/ {0, -1, -1}, /*01808*/ {0, -1, -1}, /*01809*/ {0, -1, -1}, /*01810*/ {0, -1, -1}, /*01811*/ {0, -1, -1}, /*01812*/ {0, -1, -1}, /*01813*/ {0, -1, -1}, /*01814*/ {0, -1, -1}, /*01815*/ {0, -1, -1}, /*01816*/ {0, -1, -1}, /*01817*/ {0, -1, -1}, /*01818*/ {0, -1, -1}, /*01819*/ {0, -1, -1}, /*01820*/ {1308, -1, -1}, /*01821*/ {1309, -1, -1}, /*01822*/ {1308, -1, -1}, /*01823*/ {1309, -1, -1}, /*01824*/ {1310, -1, -1}, /*01825*/ {1311, -1, -1}, /*01826*/ {1308, -1, -1}, /*01827*/ {1309, -1, -1}, /*01828*/ {1956, 27, 3}, /*01829*/ {1964, 27, 3}, /*01830*/ {1972, 27, 3}, /*01831*/ {1980, 27, 3}, /*01832*/ {1988, 27, 3}, /*01833*/ {1996, 27, 3}, /*01834*/ {2004, 27, 3}, /*01835*/ {2012, 27, 3}, /*01836*/ {2020, 27, 3}, /*01837*/ {2028, 27, 3}, /*01838*/ {2036, 27, 3}, /*01839*/ {2044, 27, 3}, /*01840*/ {2052, 27, 3}, /*01841*/ {2060, 27, 3}, /*01842*/ {2068, 27, 3}, /*01843*/ {2076, 27, 3}, /*01844*/ {2084, 27, 3}, /*01845*/ {2092, 27, 3}, /*01846*/ {2100, 27, 3}, /*01847*/ {2108, 27, 3}, /*01848*/ {2116, 27, 3}, /*01849*/ {2124, 27, 3}, /*01850*/ {2132, 27, 3}, /*01851*/ {2140, 27, 3}, /*01852*/ {0, -1, -1}, /*01853*/ {0, -1, -1}, /*01854*/ {0, -1, -1}, /*01855*/ {2148, 27, 3}, /*01856*/ {2156, 27, 1}, /*01857*/ {2158, 27, 1}, /*01858*/ {2160, 27, 1}, /*01859*/ {2162, 27, 1}, /*01860*/ {2164, 27, 3}, /*01861*/ {2172, 27, 3}, /*01862*/ {2180, 27, 3}, /*01863*/ {2188, 27, 3}, /*01864*/ {2196, 27, 3}, /*01865*/ {2204, 27, 3}, /*01866*/ {2212, 27, 3}, /*01867*/ {2220, 27, 3}, /*01868*/ {2228, 27, 3}, /*01869*/ {2236, 27, 3}, /*01870*/ {2244, 27, 3}, /*01871*/ {2252, 27, 3}, /*01872*/ {0, -1, -1}, /*01873*/ {0, -1, -1}, /*01874*/ {0, -1, -1}, /*01875*/ {0, -1, -1}, /*01876*/ {2260, 27, 3}, /*01877*/ {2268, 27, 3}, /*01878*/ {2276, 27, 3}, /*01879*/ {2284, 27, 3}, /*01880*/ {2292, 27, 3}, /*01881*/ {2300, 27, 3}, /*01882*/ {2308, 27, 3}, /*01883*/ {2316, 27, 3}, /*01884*/ {0, -1, -1}, /*01885*/ {0, -1, -1}, /*01886*/ {0, -1, -1}, /*01887*/ {2324, 27, 3}, /*01888*/ {0, -1, -1}, /*01889*/ {0, -1, -1}, /*01890*/ {0, -1, -1}, /*01891*/ {0, -1, -1}, /*01892*/ {2332, 27, 3}, /*01893*/ {2340, 27, 3}, /*01894*/ {2348, 27, 3}, /*01895*/ {2356, 27, 3}, /*01896*/ {2364, 27, 3}, /*01897*/ {2372, 27, 3}, /*01898*/ {2380, 27, 3}, /*01899*/ {2388, 27, 3}, /*01900*/ {2396, 27, 3}, /*01901*/ {2404, 27, 3}, /*01902*/ {2412, 27, 3}, /*01903*/ {2420, 27, 3}, /*01904*/ {2428, 27, 3}, /*01905*/ {2436, 27, 3}, /*01906*/ {2444, 27, 3}, /*01907*/ {2452, 27, 3}, /*01908*/ {2460, 27, 3}, /*01909*/ {2468, 27, 3}, /*01910*/ {2476, 27, 3}, /*01911*/ {2484, 27, 3}, /*01912*/ {2492, 27, 3}, /*01913*/ {2500, 27, 3}, /*01914*/ {2508, 27, 3}, /*01915*/ {2516, 27, 3}, /*01916*/ {0, -1, -1}, /*01917*/ {0, -1, -1}, /*01918*/ {0, -1, -1}, /*01919*/ {2524, 27, 3}, /*01920*/ {0, -1, -1}, /*01921*/ {0, -1, -1}, /*01922*/ {0, -1, -1}, /*01923*/ {0, -1, -1}, /*01924*/ {2532, 27, 3}, /*01925*/ {2540, 27, 3}, /*01926*/ {2548, 27, 3}, /*01927*/ {2556, 27, 3}, /*01928*/ {2564, 27, 3}, /*01929*/ {2572, 27, 3}, /*01930*/ {2580, 27, 3}, /*01931*/ {2588, 27, 3}, /*01932*/ {2596, 27, 3}, /*01933*/ {2604, 27, 3}, /*01934*/ {2612, 27, 3}, /*01935*/ {2620, 27, 3}, /*01936*/ {0, -1, -1}, /*01937*/ {0, -1, -1}, /*01938*/ {0, -1, -1}, /*01939*/ {0, -1, -1}, /*01940*/ {0, -1, -1}, /*01941*/ {0, -1, -1}, /*01942*/ {0, -1, -1}, /*01943*/ {0, -1, -1}, /*01944*/ {0, -1, -1}, /*01945*/ {0, -1, -1}, /*01946*/ {0, -1, -1}, /*01947*/ {0, -1, -1}, /*01948*/ {0, -1, -1}, /*01949*/ {0, -1, -1}, /*01950*/ {0, -1, -1}, /*01951*/ {0, -1, -1}, /*01952*/ {0, -1, -1}, /*01953*/ {0, -1, -1}, /*01954*/ {0, -1, -1}, /*01955*/ {0, -1, -1}, /*01956*/ {223, -1, -1}, /*01957*/ {993, -1, -1}, /*01958*/ {224, -1, -1}, /*01959*/ {994, -1, -1}, /*01960*/ {223, -1, -1}, /*01961*/ {993, -1, -1}, /*01962*/ {225, -1, -1}, /*01963*/ {995, -1, -1}, /*01964*/ {226, -1, -1}, /*01965*/ {996, -1, -1}, /*01966*/ {227, -1, -1}, /*01967*/ {997, -1, -1}, /*01968*/ {226, -1, -1}, /*01969*/ {996, -1, -1}, /*01970*/ {228, -1, -1}, /*01971*/ {998, -1, -1}, /*01972*/ {229, -1, -1}, /*01973*/ {999, -1, -1}, /*01974*/ {230, -1, -1}, /*01975*/ {1000, -1, -1}, /*01976*/ {229, -1, -1}, /*01977*/ {999, -1, -1}, /*01978*/ {231, -1, -1}, /*01979*/ {1001, -1, -1}, /*01980*/ {232, -1, -1}, /*01981*/ {1002, -1, -1}, /*01982*/ {233, -1, -1}, /*01983*/ {1003, -1, -1}, /*01984*/ {232, -1, -1}, /*01985*/ {1002, -1, -1}, /*01986*/ {234, -1, -1}, /*01987*/ {1004, -1, -1}, /*01988*/ {235, -1, -1}, /*01989*/ {1005, -1, -1}, /*01990*/ {236, -1, -1}, /*01991*/ {1006, -1, -1}, /*01992*/ {235, -1, -1}, /*01993*/ {1005, -1, -1}, /*01994*/ {237, -1, -1}, /*01995*/ {1007, -1, -1}, /*01996*/ {238, -1, -1}, /*01997*/ {1008, -1, -1}, /*01998*/ {239, -1, -1}, /*01999*/ {1009, -1, -1}, /*02000*/ {238, -1, -1}, /*02001*/ {1008, -1, -1}, /*02002*/ {240, -1, -1}, /*02003*/ {1010, -1, -1}, /*02004*/ {241, -1, -1}, /*02005*/ {1011, -1, -1}, /*02006*/ {242, -1, -1}, /*02007*/ {1012, -1, -1}, /*02008*/ {241, -1, -1}, /*02009*/ {1011, -1, -1}, /*02010*/ {243, -1, -1}, /*02011*/ {1013, -1, -1}, /*02012*/ {244, -1, -1}, /*02013*/ {1014, -1, -1}, /*02014*/ {245, -1, -1}, /*02015*/ {1015, -1, -1}, /*02016*/ {244, -1, -1}, /*02017*/ {1014, -1, -1}, /*02018*/ {246, -1, -1}, /*02019*/ {1016, -1, -1}, /*02020*/ {247, -1, -1}, /*02021*/ {1017, -1, -1}, /*02022*/ {248, -1, -1}, /*02023*/ {1018, -1, -1}, /*02024*/ {247, -1, -1}, /*02025*/ {1017, -1, -1}, /*02026*/ {249, -1, -1}, /*02027*/ {1019, -1, -1}, /*02028*/ {250, -1, -1}, /*02029*/ {1020, -1, -1}, /*02030*/ {251, -1, -1}, /*02031*/ {1021, -1, -1}, /*02032*/ {250, -1, -1}, /*02033*/ {1020, -1, -1}, /*02034*/ {252, -1, -1}, /*02035*/ {1022, -1, -1}, /*02036*/ {253, -1, -1}, /*02037*/ {1023, -1, -1}, /*02038*/ {254, -1, -1}, /*02039*/ {1024, -1, -1}, /*02040*/ {253, -1, -1}, /*02041*/ {1023, -1, -1}, /*02042*/ {255, -1, -1}, /*02043*/ {1025, -1, -1}, /*02044*/ {256, -1, -1}, /*02045*/ {1026, -1, -1}, /*02046*/ {257, -1, -1}, /*02047*/ {1027, -1, -1}, /*02048*/ {256, -1, -1}, /*02049*/ {1026, -1, -1}, /*02050*/ {258, -1, -1}, /*02051*/ {1028, -1, -1}, /*02052*/ {259, -1, -1}, /*02053*/ {0, -1, -1}, /*02054*/ {260, -1, -1}, /*02055*/ {0, -1, -1}, /*02056*/ {259, -1, -1}, /*02057*/ {0, -1, -1}, /*02058*/ {261, -1, -1}, /*02059*/ {0, -1, -1}, /*02060*/ {262, -1, -1}, /*02061*/ {0, -1, -1}, /*02062*/ {263, -1, -1}, /*02063*/ {0, -1, -1}, /*02064*/ {262, -1, -1}, /*02065*/ {0, -1, -1}, /*02066*/ {264, -1, -1}, /*02067*/ {0, -1, -1}, /*02068*/ {265, -1, -1}, /*02069*/ {0, -1, -1}, /*02070*/ {266, -1, -1}, /*02071*/ {0, -1, -1}, /*02072*/ {265, -1, -1}, /*02073*/ {0, -1, -1}, /*02074*/ {267, -1, -1}, /*02075*/ {0, -1, -1}, /*02076*/ {268, -1, -1}, /*02077*/ {0, -1, -1}, /*02078*/ {269, -1, -1}, /*02079*/ {0, -1, -1}, /*02080*/ {268, -1, -1}, /*02081*/ {0, -1, -1}, /*02082*/ {270, -1, -1}, /*02083*/ {0, -1, -1}, /*02084*/ {271, -1, -1}, /*02085*/ {0, -1, -1}, /*02086*/ {272, -1, -1}, /*02087*/ {0, -1, -1}, /*02088*/ {271, -1, -1}, /*02089*/ {0, -1, -1}, /*02090*/ {273, -1, -1}, /*02091*/ {0, -1, -1}, /*02092*/ {274, -1, -1}, /*02093*/ {0, -1, -1}, /*02094*/ {275, -1, -1}, /*02095*/ {0, -1, -1}, /*02096*/ {274, -1, -1}, /*02097*/ {0, -1, -1}, /*02098*/ {276, -1, -1}, /*02099*/ {0, -1, -1}, /*02100*/ {277, -1, -1}, /*02101*/ {1029, -1, -1}, /*02102*/ {278, -1, -1}, /*02103*/ {1030, -1, -1}, /*02104*/ {277, -1, -1}, /*02105*/ {1029, -1, -1}, /*02106*/ {279, -1, -1}, /*02107*/ {1031, -1, -1}, /*02108*/ {280, -1, -1}, /*02109*/ {1032, -1, -1}, /*02110*/ {281, -1, -1}, /*02111*/ {1033, -1, -1}, /*02112*/ {280, -1, -1}, /*02113*/ {1032, -1, -1}, /*02114*/ {282, -1, -1}, /*02115*/ {1034, -1, -1}, /*02116*/ {283, -1, -1}, /*02117*/ {0, -1, -1}, /*02118*/ {284, -1, -1}, /*02119*/ {0, -1, -1}, /*02120*/ {283, -1, -1}, /*02121*/ {0, -1, -1}, /*02122*/ {285, -1, -1}, /*02123*/ {0, -1, -1}, /*02124*/ {286, -1, -1}, /*02125*/ {0, -1, -1}, /*02126*/ {287, -1, -1}, /*02127*/ {0, -1, -1}, /*02128*/ {286, -1, -1}, /*02129*/ {0, -1, -1}, /*02130*/ {288, -1, -1}, /*02131*/ {0, -1, -1}, /*02132*/ {289, -1, -1}, /*02133*/ {1035, -1, -1}, /*02134*/ {290, -1, -1}, /*02135*/ {1036, -1, -1}, /*02136*/ {289, -1, -1}, /*02137*/ {1035, -1, -1}, /*02138*/ {291, -1, -1}, /*02139*/ {1037, -1, -1}, /*02140*/ {292, -1, -1}, /*02141*/ {1038, -1, -1}, /*02142*/ {293, -1, -1}, /*02143*/ {1039, -1, -1}, /*02144*/ {292, -1, -1}, /*02145*/ {1038, -1, -1}, /*02146*/ {294, -1, -1}, /*02147*/ {1040, -1, -1}, /*02148*/ {295, -1, -1}, /*02149*/ {0, -1, -1}, /*02150*/ {296, -1, -1}, /*02151*/ {0, -1, -1}, /*02152*/ {295, -1, -1}, /*02153*/ {0, -1, -1}, /*02154*/ {297, -1, -1}, /*02155*/ {0, -1, -1}, /*02156*/ {0, -1, -1}, /*02157*/ {1045, -1, -1}, /*02158*/ {0, -1, -1}, /*02159*/ {1046, -1, -1}, /*02160*/ {0, -1, -1}, /*02161*/ {1047, -1, -1}, /*02162*/ {0, -1, -1}, /*02163*/ {1048, -1, -1}, /*02164*/ {298, -1, -1}, /*02165*/ {0, -1, -1}, /*02166*/ {299, -1, -1}, /*02167*/ {0, -1, -1}, /*02168*/ {298, -1, -1}, /*02169*/ {0, -1, -1}, /*02170*/ {300, -1, -1}, /*02171*/ {0, -1, -1}, /*02172*/ {301, -1, -1}, /*02173*/ {0, -1, -1}, /*02174*/ {302, -1, -1}, /*02175*/ {0, -1, -1}, /*02176*/ {301, -1, -1}, /*02177*/ {0, -1, -1}, /*02178*/ {303, -1, -1}, /*02179*/ {0, -1, -1}, /*02180*/ {304, -1, -1}, /*02181*/ {0, -1, -1}, /*02182*/ {305, -1, -1}, /*02183*/ {0, -1, -1}, /*02184*/ {304, -1, -1}, /*02185*/ {0, -1, -1}, /*02186*/ {306, -1, -1}, /*02187*/ {0, -1, -1}, /*02188*/ {307, -1, -1}, /*02189*/ {0, -1, -1}, /*02190*/ {308, -1, -1}, /*02191*/ {0, -1, -1}, /*02192*/ {307, -1, -1}, /*02193*/ {0, -1, -1}, /*02194*/ {309, -1, -1}, /*02195*/ {0, -1, -1}, /*02196*/ {310, -1, -1}, /*02197*/ {0, -1, -1}, /*02198*/ {311, -1, -1}, /*02199*/ {0, -1, -1}, /*02200*/ {310, -1, -1}, /*02201*/ {0, -1, -1}, /*02202*/ {312, -1, -1}, /*02203*/ {0, -1, -1}, /*02204*/ {313, -1, -1}, /*02205*/ {0, -1, -1}, /*02206*/ {314, -1, -1}, /*02207*/ {0, -1, -1}, /*02208*/ {313, -1, -1}, /*02209*/ {0, -1, -1}, /*02210*/ {315, -1, -1}, /*02211*/ {0, -1, -1}, /*02212*/ {316, -1, -1}, /*02213*/ {0, -1, -1}, /*02214*/ {317, -1, -1}, /*02215*/ {0, -1, -1}, /*02216*/ {316, -1, -1}, /*02217*/ {0, -1, -1}, /*02218*/ {318, -1, -1}, /*02219*/ {0, -1, -1}, /*02220*/ {319, -1, -1}, /*02221*/ {0, -1, -1}, /*02222*/ {320, -1, -1}, /*02223*/ {0, -1, -1}, /*02224*/ {319, -1, -1}, /*02225*/ {0, -1, -1}, /*02226*/ {321, -1, -1}, /*02227*/ {0, -1, -1}, /*02228*/ {322, -1, -1}, /*02229*/ {0, -1, -1}, /*02230*/ {323, -1, -1}, /*02231*/ {0, -1, -1}, /*02232*/ {322, -1, -1}, /*02233*/ {0, -1, -1}, /*02234*/ {324, -1, -1}, /*02235*/ {0, -1, -1}, /*02236*/ {325, -1, -1}, /*02237*/ {0, -1, -1}, /*02238*/ {326, -1, -1}, /*02239*/ {0, -1, -1}, /*02240*/ {325, -1, -1}, /*02241*/ {0, -1, -1}, /*02242*/ {327, -1, -1}, /*02243*/ {0, -1, -1}, /*02244*/ {328, -1, -1}, /*02245*/ {0, -1, -1}, /*02246*/ {329, -1, -1}, /*02247*/ {0, -1, -1}, /*02248*/ {328, -1, -1}, /*02249*/ {0, -1, -1}, /*02250*/ {330, -1, -1}, /*02251*/ {0, -1, -1}, /*02252*/ {331, -1, -1}, /*02253*/ {0, -1, -1}, /*02254*/ {332, -1, -1}, /*02255*/ {0, -1, -1}, /*02256*/ {331, -1, -1}, /*02257*/ {0, -1, -1}, /*02258*/ {333, -1, -1}, /*02259*/ {0, -1, -1}, /*02260*/ {556, -1, -1}, /*02261*/ {0, -1, -1}, /*02262*/ {556, -1, -1}, /*02263*/ {0, -1, -1}, /*02264*/ {556, -1, -1}, /*02265*/ {0, -1, -1}, /*02266*/ {557, -1, -1}, /*02267*/ {0, -1, -1}, /*02268*/ {558, -1, -1}, /*02269*/ {0, -1, -1}, /*02270*/ {558, -1, -1}, /*02271*/ {0, -1, -1}, /*02272*/ {558, -1, -1}, /*02273*/ {0, -1, -1}, /*02274*/ {559, -1, -1}, /*02275*/ {0, -1, -1}, /*02276*/ {560, -1, -1}, /*02277*/ {0, -1, -1}, /*02278*/ {560, -1, -1}, /*02279*/ {0, -1, -1}, /*02280*/ {560, -1, -1}, /*02281*/ {0, -1, -1}, /*02282*/ {561, -1, -1}, /*02283*/ {0, -1, -1}, /*02284*/ {562, -1, -1}, /*02285*/ {0, -1, -1}, /*02286*/ {562, -1, -1}, /*02287*/ {0, -1, -1}, /*02288*/ {562, -1, -1}, /*02289*/ {0, -1, -1}, /*02290*/ {563, -1, -1}, /*02291*/ {0, -1, -1}, /*02292*/ {564, -1, -1}, /*02293*/ {0, -1, -1}, /*02294*/ {564, -1, -1}, /*02295*/ {0, -1, -1}, /*02296*/ {564, -1, -1}, /*02297*/ {0, -1, -1}, /*02298*/ {565, -1, -1}, /*02299*/ {0, -1, -1}, /*02300*/ {566, -1, -1}, /*02301*/ {0, -1, -1}, /*02302*/ {566, -1, -1}, /*02303*/ {0, -1, -1}, /*02304*/ {566, -1, -1}, /*02305*/ {0, -1, -1}, /*02306*/ {567, -1, -1}, /*02307*/ {0, -1, -1}, /*02308*/ {568, -1, -1}, /*02309*/ {0, -1, -1}, /*02310*/ {568, -1, -1}, /*02311*/ {0, -1, -1}, /*02312*/ {568, -1, -1}, /*02313*/ {0, -1, -1}, /*02314*/ {569, -1, -1}, /*02315*/ {0, -1, -1}, /*02316*/ {570, -1, -1}, /*02317*/ {0, -1, -1}, /*02318*/ {570, -1, -1}, /*02319*/ {0, -1, -1}, /*02320*/ {570, -1, -1}, /*02321*/ {0, -1, -1}, /*02322*/ {571, -1, -1}, /*02323*/ {0, -1, -1}, /*02324*/ {572, -1, -1}, /*02325*/ {0, -1, -1}, /*02326*/ {572, -1, -1}, /*02327*/ {0, -1, -1}, /*02328*/ {572, -1, -1}, /*02329*/ {0, -1, -1}, /*02330*/ {573, -1, -1}, /*02331*/ {0, -1, -1}, /*02332*/ {334, -1, -1}, /*02333*/ {0, -1, -1}, /*02334*/ {335, -1, -1}, /*02335*/ {0, -1, -1}, /*02336*/ {334, -1, -1}, /*02337*/ {0, -1, -1}, /*02338*/ {336, -1, -1}, /*02339*/ {0, -1, -1}, /*02340*/ {337, -1, -1}, /*02341*/ {0, -1, -1}, /*02342*/ {338, -1, -1}, /*02343*/ {0, -1, -1}, /*02344*/ {337, -1, -1}, /*02345*/ {0, -1, -1}, /*02346*/ {339, -1, -1}, /*02347*/ {0, -1, -1}, /*02348*/ {340, -1, -1}, /*02349*/ {0, -1, -1}, /*02350*/ {341, -1, -1}, /*02351*/ {0, -1, -1}, /*02352*/ {340, -1, -1}, /*02353*/ {0, -1, -1}, /*02354*/ {342, -1, -1}, /*02355*/ {0, -1, -1}, /*02356*/ {343, -1, -1}, /*02357*/ {0, -1, -1}, /*02358*/ {344, -1, -1}, /*02359*/ {0, -1, -1}, /*02360*/ {343, -1, -1}, /*02361*/ {0, -1, -1}, /*02362*/ {345, -1, -1}, /*02363*/ {0, -1, -1}, /*02364*/ {346, -1, -1}, /*02365*/ {0, -1, -1}, /*02366*/ {347, -1, -1}, /*02367*/ {0, -1, -1}, /*02368*/ {346, -1, -1}, /*02369*/ {0, -1, -1}, /*02370*/ {348, -1, -1}, /*02371*/ {0, -1, -1}, /*02372*/ {349, -1, -1}, /*02373*/ {0, -1, -1}, /*02374*/ {350, -1, -1}, /*02375*/ {0, -1, -1}, /*02376*/ {349, -1, -1}, /*02377*/ {0, -1, -1}, /*02378*/ {351, -1, -1}, /*02379*/ {0, -1, -1}, /*02380*/ {352, -1, -1}, /*02381*/ {0, -1, -1}, /*02382*/ {353, -1, -1}, /*02383*/ {0, -1, -1}, /*02384*/ {352, -1, -1}, /*02385*/ {0, -1, -1}, /*02386*/ {354, -1, -1}, /*02387*/ {0, -1, -1}, /*02388*/ {355, -1, -1}, /*02389*/ {0, -1, -1}, /*02390*/ {356, -1, -1}, /*02391*/ {0, -1, -1}, /*02392*/ {355, -1, -1}, /*02393*/ {0, -1, -1}, /*02394*/ {357, -1, -1}, /*02395*/ {0, -1, -1}, /*02396*/ {358, -1, -1}, /*02397*/ {0, -1, -1}, /*02398*/ {359, -1, -1}, /*02399*/ {0, -1, -1}, /*02400*/ {358, -1, -1}, /*02401*/ {0, -1, -1}, /*02402*/ {360, -1, -1}, /*02403*/ {0, -1, -1}, /*02404*/ {361, -1, -1}, /*02405*/ {0, -1, -1}, /*02406*/ {362, -1, -1}, /*02407*/ {0, -1, -1}, /*02408*/ {361, -1, -1}, /*02409*/ {0, -1, -1}, /*02410*/ {363, -1, -1}, /*02411*/ {0, -1, -1}, /*02412*/ {364, -1, -1}, /*02413*/ {0, -1, -1}, /*02414*/ {365, -1, -1}, /*02415*/ {0, -1, -1}, /*02416*/ {364, -1, -1}, /*02417*/ {0, -1, -1}, /*02418*/ {366, -1, -1}, /*02419*/ {0, -1, -1}, /*02420*/ {367, -1, -1}, /*02421*/ {0, -1, -1}, /*02422*/ {368, -1, -1}, /*02423*/ {0, -1, -1}, /*02424*/ {367, -1, -1}, /*02425*/ {0, -1, -1}, /*02426*/ {369, -1, -1}, /*02427*/ {0, -1, -1}, /*02428*/ {370, -1, -1}, /*02429*/ {0, -1, -1}, /*02430*/ {371, -1, -1}, /*02431*/ {0, -1, -1}, /*02432*/ {370, -1, -1}, /*02433*/ {0, -1, -1}, /*02434*/ {372, -1, -1}, /*02435*/ {0, -1, -1}, /*02436*/ {373, -1, -1}, /*02437*/ {0, -1, -1}, /*02438*/ {374, -1, -1}, /*02439*/ {0, -1, -1}, /*02440*/ {373, -1, -1}, /*02441*/ {0, -1, -1}, /*02442*/ {375, -1, -1}, /*02443*/ {0, -1, -1}, /*02444*/ {376, -1, -1}, /*02445*/ {0, -1, -1}, /*02446*/ {377, -1, -1}, /*02447*/ {0, -1, -1}, /*02448*/ {376, -1, -1}, /*02449*/ {0, -1, -1}, /*02450*/ {378, -1, -1}, /*02451*/ {0, -1, -1}, /*02452*/ {379, -1, -1}, /*02453*/ {0, -1, -1}, /*02454*/ {380, -1, -1}, /*02455*/ {0, -1, -1}, /*02456*/ {379, -1, -1}, /*02457*/ {0, -1, -1}, /*02458*/ {381, -1, -1}, /*02459*/ {0, -1, -1}, /*02460*/ {382, -1, -1}, /*02461*/ {0, -1, -1}, /*02462*/ {383, -1, -1}, /*02463*/ {0, -1, -1}, /*02464*/ {382, -1, -1}, /*02465*/ {0, -1, -1}, /*02466*/ {384, -1, -1}, /*02467*/ {0, -1, -1}, /*02468*/ {385, -1, -1}, /*02469*/ {0, -1, -1}, /*02470*/ {386, -1, -1}, /*02471*/ {0, -1, -1}, /*02472*/ {385, -1, -1}, /*02473*/ {0, -1, -1}, /*02474*/ {387, -1, -1}, /*02475*/ {0, -1, -1}, /*02476*/ {388, -1, -1}, /*02477*/ {0, -1, -1}, /*02478*/ {389, -1, -1}, /*02479*/ {0, -1, -1}, /*02480*/ {388, -1, -1}, /*02481*/ {0, -1, -1}, /*02482*/ {390, -1, -1}, /*02483*/ {0, -1, -1}, /*02484*/ {391, -1, -1}, /*02485*/ {0, -1, -1}, /*02486*/ {392, -1, -1}, /*02487*/ {0, -1, -1}, /*02488*/ {391, -1, -1}, /*02489*/ {0, -1, -1}, /*02490*/ {393, -1, -1}, /*02491*/ {0, -1, -1}, /*02492*/ {394, -1, -1}, /*02493*/ {0, -1, -1}, /*02494*/ {395, -1, -1}, /*02495*/ {0, -1, -1}, /*02496*/ {394, -1, -1}, /*02497*/ {0, -1, -1}, /*02498*/ {396, -1, -1}, /*02499*/ {0, -1, -1}, /*02500*/ {397, -1, -1}, /*02501*/ {0, -1, -1}, /*02502*/ {398, -1, -1}, /*02503*/ {0, -1, -1}, /*02504*/ {397, -1, -1}, /*02505*/ {0, -1, -1}, /*02506*/ {399, -1, -1}, /*02507*/ {0, -1, -1}, /*02508*/ {400, -1, -1}, /*02509*/ {0, -1, -1}, /*02510*/ {401, -1, -1}, /*02511*/ {0, -1, -1}, /*02512*/ {400, -1, -1}, /*02513*/ {0, -1, -1}, /*02514*/ {402, -1, -1}, /*02515*/ {0, -1, -1}, /*02516*/ {403, -1, -1}, /*02517*/ {0, -1, -1}, /*02518*/ {404, -1, -1}, /*02519*/ {0, -1, -1}, /*02520*/ {403, -1, -1}, /*02521*/ {0, -1, -1}, /*02522*/ {405, -1, -1}, /*02523*/ {0, -1, -1}, /*02524*/ {406, -1, -1}, /*02525*/ {0, -1, -1}, /*02526*/ {407, -1, -1}, /*02527*/ {0, -1, -1}, /*02528*/ {406, -1, -1}, /*02529*/ {0, -1, -1}, /*02530*/ {408, -1, -1}, /*02531*/ {0, -1, -1}, /*02532*/ {409, -1, -1}, /*02533*/ {0, -1, -1}, /*02534*/ {410, -1, -1}, /*02535*/ {0, -1, -1}, /*02536*/ {409, -1, -1}, /*02537*/ {0, -1, -1}, /*02538*/ {411, -1, -1}, /*02539*/ {0, -1, -1}, /*02540*/ {412, -1, -1}, /*02541*/ {0, -1, -1}, /*02542*/ {413, -1, -1}, /*02543*/ {0, -1, -1}, /*02544*/ {412, -1, -1}, /*02545*/ {0, -1, -1}, /*02546*/ {414, -1, -1}, /*02547*/ {0, -1, -1}, /*02548*/ {415, -1, -1}, /*02549*/ {0, -1, -1}, /*02550*/ {416, -1, -1}, /*02551*/ {0, -1, -1}, /*02552*/ {415, -1, -1}, /*02553*/ {0, -1, -1}, /*02554*/ {417, -1, -1}, /*02555*/ {0, -1, -1}, /*02556*/ {418, -1, -1}, /*02557*/ {0, -1, -1}, /*02558*/ {419, -1, -1}, /*02559*/ {0, -1, -1}, /*02560*/ {418, -1, -1}, /*02561*/ {0, -1, -1}, /*02562*/ {420, -1, -1}, /*02563*/ {0, -1, -1}, /*02564*/ {421, -1, -1}, /*02565*/ {0, -1, -1}, /*02566*/ {422, -1, -1}, /*02567*/ {0, -1, -1}, /*02568*/ {421, -1, -1}, /*02569*/ {0, -1, -1}, /*02570*/ {423, -1, -1}, /*02571*/ {0, -1, -1}, /*02572*/ {424, -1, -1}, /*02573*/ {0, -1, -1}, /*02574*/ {425, -1, -1}, /*02575*/ {0, -1, -1}, /*02576*/ {424, -1, -1}, /*02577*/ {0, -1, -1}, /*02578*/ {426, -1, -1}, /*02579*/ {0, -1, -1}, /*02580*/ {427, -1, -1}, /*02581*/ {0, -1, -1}, /*02582*/ {428, -1, -1}, /*02583*/ {0, -1, -1}, /*02584*/ {427, -1, -1}, /*02585*/ {0, -1, -1}, /*02586*/ {429, -1, -1}, /*02587*/ {0, -1, -1}, /*02588*/ {430, -1, -1}, /*02589*/ {0, -1, -1}, /*02590*/ {431, -1, -1}, /*02591*/ {0, -1, -1}, /*02592*/ {430, -1, -1}, /*02593*/ {0, -1, -1}, /*02594*/ {432, -1, -1}, /*02595*/ {0, -1, -1}, /*02596*/ {433, -1, -1}, /*02597*/ {0, -1, -1}, /*02598*/ {434, -1, -1}, /*02599*/ {0, -1, -1}, /*02600*/ {433, -1, -1}, /*02601*/ {0, -1, -1}, /*02602*/ {435, -1, -1}, /*02603*/ {0, -1, -1}, /*02604*/ {436, -1, -1}, /*02605*/ {0, -1, -1}, /*02606*/ {437, -1, -1}, /*02607*/ {0, -1, -1}, /*02608*/ {436, -1, -1}, /*02609*/ {0, -1, -1}, /*02610*/ {438, -1, -1}, /*02611*/ {0, -1, -1}, /*02612*/ {439, -1, -1}, /*02613*/ {0, -1, -1}, /*02614*/ {440, -1, -1}, /*02615*/ {0, -1, -1}, /*02616*/ {439, -1, -1}, /*02617*/ {0, -1, -1}, /*02618*/ {441, -1, -1}, /*02619*/ {0, -1, -1}, /*02620*/ {442, -1, -1}, /*02621*/ {0, -1, -1}, /*02622*/ {443, -1, -1}, /*02623*/ {0, -1, -1}, /*02624*/ {442, -1, -1}, /*02625*/ {0, -1, -1}, /*02626*/ {444, -1, -1}, /*02627*/ {0, -1, -1}, /*02628*/ {2644, 12, 1}, /*02629*/ {2646, 12, 1}, /*02630*/ {2648, 12, 1}, /*02631*/ {2650, 12, 1}, /*02632*/ {2652, 12, 1}, /*02633*/ {2654, 12, 1}, /*02634*/ {2656, 12, 1}, /*02635*/ {2658, 12, 1}, /*02636*/ {2660, 12, 1}, /*02637*/ {2662, 12, 1}, /*02638*/ {2664, 12, 1}, /*02639*/ {2666, 12, 1}, /*02640*/ {2668, 12, 1}, /*02641*/ {2670, 12, 1}, /*02642*/ {2672, 12, 1}, /*02643*/ {2674, 12, 1}, /*02644*/ {1374, -1, -1}, /*02645*/ {1390, -1, -1}, /*02646*/ {1382, -1, -1}, /*02647*/ {1398, -1, -1}, /*02648*/ {1375, -1, -1}, /*02649*/ {1391, -1, -1}, /*02650*/ {1383, -1, -1}, /*02651*/ {1399, -1, -1}, /*02652*/ {1376, -1, -1}, /*02653*/ {1392, -1, -1}, /*02654*/ {1384, -1, -1}, /*02655*/ {1400, -1, -1}, /*02656*/ {1377, -1, -1}, /*02657*/ {1393, -1, -1}, /*02658*/ {1385, -1, -1}, /*02659*/ {1401, -1, -1}, /*02660*/ {1378, -1, -1}, /*02661*/ {1394, -1, -1}, /*02662*/ {1386, -1, -1}, /*02663*/ {1402, -1, -1}, /*02664*/ {1379, -1, -1}, /*02665*/ {1395, -1, -1}, /*02666*/ {1387, -1, -1}, /*02667*/ {1403, -1, -1}, /*02668*/ {1380, -1, -1}, /*02669*/ {1396, -1, -1}, /*02670*/ {1388, -1, -1}, /*02671*/ {1404, -1, -1}, /*02672*/ {1381, -1, -1}, /*02673*/ {1397, -1, -1}, /*02674*/ {1389, -1, -1}, /*02675*/ {1405, -1, -1}, /*02676*/ {2684, 6, 3}, /*02677*/ {2704, 6, 3}, /*02678*/ {2724, 6, 3}, /*02679*/ {2744, 6, 3}, /*02680*/ {2764, 6, 3}, /*02681*/ {2784, 6, 3}, /*02682*/ {2804, 6, 3}, /*02683*/ {2824, 6, 3}, /*02684*/ {2692, 12, 1}, /*02685*/ {0, -1, -1}, /*02686*/ {2694, 12, 1}, /*02687*/ {2696, 12, 1}, /*02688*/ {0, -1, -1}, /*02689*/ {2698, 12, 1}, /*02690*/ {2700, 12, 1}, /*02691*/ {2702, 12, 1}, /*02692*/ {1120, -1, -1}, /*02693*/ {1121, -1, -1}, /*02694*/ {1136, -1, -1}, /*02695*/ {1137, -1, -1}, /*02696*/ {1152, -1, -1}, /*02697*/ {1153, -1, -1}, /*02698*/ {1168, -1, -1}, /*02699*/ {1169, -1, -1}, /*02700*/ {1184, -1, -1}, /*02701*/ {1185, -1, -1}, /*02702*/ {1200, -1, -1}, /*02703*/ {1201, -1, -1}, /*02704*/ {2712, 12, 1}, /*02705*/ {0, -1, -1}, /*02706*/ {2714, 12, 1}, /*02707*/ {2716, 12, 1}, /*02708*/ {0, -1, -1}, /*02709*/ {2718, 12, 1}, /*02710*/ {2720, 12, 1}, /*02711*/ {2722, 12, 1}, /*02712*/ {1122, -1, -1}, /*02713*/ {1123, -1, -1}, /*02714*/ {1138, -1, -1}, /*02715*/ {1139, -1, -1}, /*02716*/ {1154, -1, -1}, /*02717*/ {1155, -1, -1}, /*02718*/ {1170, -1, -1}, /*02719*/ {1171, -1, -1}, /*02720*/ {1186, -1, -1}, /*02721*/ {1187, -1, -1}, /*02722*/ {1202, -1, -1}, /*02723*/ {1203, -1, -1}, /*02724*/ {2732, 12, 1}, /*02725*/ {0, -1, -1}, /*02726*/ {2734, 12, 1}, /*02727*/ {2736, 12, 1}, /*02728*/ {0, -1, -1}, /*02729*/ {2738, 12, 1}, /*02730*/ {2740, 12, 1}, /*02731*/ {2742, 12, 1}, /*02732*/ {1124, -1, -1}, /*02733*/ {1125, -1, -1}, /*02734*/ {1140, -1, -1}, /*02735*/ {1141, -1, -1}, /*02736*/ {1156, -1, -1}, /*02737*/ {1157, -1, -1}, /*02738*/ {1172, -1, -1}, /*02739*/ {1173, -1, -1}, /*02740*/ {1188, -1, -1}, /*02741*/ {1189, -1, -1}, /*02742*/ {1204, -1, -1}, /*02743*/ {1205, -1, -1}, /*02744*/ {2752, 12, 1}, /*02745*/ {0, -1, -1}, /*02746*/ {2754, 12, 1}, /*02747*/ {2756, 12, 1}, /*02748*/ {0, -1, -1}, /*02749*/ {2758, 12, 1}, /*02750*/ {2760, 12, 1}, /*02751*/ {2762, 12, 1}, /*02752*/ {1126, -1, -1}, /*02753*/ {1127, -1, -1}, /*02754*/ {1142, -1, -1}, /*02755*/ {1143, -1, -1}, /*02756*/ {1158, -1, -1}, /*02757*/ {1159, -1, -1}, /*02758*/ {1174, -1, -1}, /*02759*/ {1175, -1, -1}, /*02760*/ {1190, -1, -1}, /*02761*/ {1191, -1, -1}, /*02762*/ {1206, -1, -1}, /*02763*/ {1207, -1, -1}, /*02764*/ {2772, 12, 1}, /*02765*/ {0, -1, -1}, /*02766*/ {2774, 12, 1}, /*02767*/ {2776, 12, 1}, /*02768*/ {0, -1, -1}, /*02769*/ {2778, 12, 1}, /*02770*/ {2780, 12, 1}, /*02771*/ {2782, 12, 1}, /*02772*/ {1128, -1, -1}, /*02773*/ {1129, -1, -1}, /*02774*/ {1144, -1, -1}, /*02775*/ {1145, -1, -1}, /*02776*/ {1160, -1, -1}, /*02777*/ {1161, -1, -1}, /*02778*/ {1176, -1, -1}, /*02779*/ {1177, -1, -1}, /*02780*/ {1192, -1, -1}, /*02781*/ {1193, -1, -1}, /*02782*/ {1208, -1, -1}, /*02783*/ {1209, -1, -1}, /*02784*/ {2792, 12, 1}, /*02785*/ {0, -1, -1}, /*02786*/ {2794, 12, 1}, /*02787*/ {2796, 12, 1}, /*02788*/ {0, -1, -1}, /*02789*/ {2798, 12, 1}, /*02790*/ {2800, 12, 1}, /*02791*/ {2802, 12, 1}, /*02792*/ {1130, -1, -1}, /*02793*/ {1131, -1, -1}, /*02794*/ {1146, -1, -1}, /*02795*/ {1147, -1, -1}, /*02796*/ {1162, -1, -1}, /*02797*/ {1163, -1, -1}, /*02798*/ {1178, -1, -1}, /*02799*/ {1179, -1, -1}, /*02800*/ {1194, -1, -1}, /*02801*/ {1195, -1, -1}, /*02802*/ {1210, -1, -1}, /*02803*/ {1211, -1, -1}, /*02804*/ {2812, 12, 1}, /*02805*/ {0, -1, -1}, /*02806*/ {2814, 12, 1}, /*02807*/ {2816, 12, 1}, /*02808*/ {0, -1, -1}, /*02809*/ {2818, 12, 1}, /*02810*/ {2820, 12, 1}, /*02811*/ {2822, 12, 1}, /*02812*/ {1132, -1, -1}, /*02813*/ {1133, -1, -1}, /*02814*/ {1148, -1, -1}, /*02815*/ {1149, -1, -1}, /*02816*/ {1164, -1, -1}, /*02817*/ {1165, -1, -1}, /*02818*/ {1180, -1, -1}, /*02819*/ {1181, -1, -1}, /*02820*/ {1196, -1, -1}, /*02821*/ {1197, -1, -1}, /*02822*/ {1212, -1, -1}, /*02823*/ {1213, -1, -1}, /*02824*/ {2832, 12, 1}, /*02825*/ {0, -1, -1}, /*02826*/ {2834, 12, 1}, /*02827*/ {2836, 12, 1}, /*02828*/ {0, -1, -1}, /*02829*/ {2838, 12, 1}, /*02830*/ {2840, 12, 1}, /*02831*/ {2842, 12, 1}, /*02832*/ {1134, -1, -1}, /*02833*/ {1135, -1, -1}, /*02834*/ {1150, -1, -1}, /*02835*/ {1151, -1, -1}, /*02836*/ {1166, -1, -1}, /*02837*/ {1167, -1, -1}, /*02838*/ {1182, -1, -1}, /*02839*/ {1183, -1, -1}, /*02840*/ {1198, -1, -1}, /*02841*/ {1199, -1, -1}, /*02842*/ {1214, -1, -1}, /*02843*/ {1215, -1, -1}, /*02844*/ {2852, 12, 2}, /*02845*/ {2864, 12, 2}, /*02846*/ {2876, 13, 1}, /*02847*/ {2878, 26, 1}, /*02848*/ {0, -1, -1}, /*02849*/ {0, -1, -1}, /*02850*/ {167, -1, -1}, /*02851*/ {172, -1, -1}, /*02852*/ {2856, 36, 1}, /*02853*/ {2858, 36, 1}, /*02854*/ {2860, 36, 1}, /*02855*/ {2862, 36, 1}, /*02856*/ {174, -1, -1}, /*02857*/ {176, -1, -1}, /*02858*/ {175, -1, -1}, /*02859*/ {177, -1, -1}, /*02860*/ {182, -1, -1}, /*02861*/ {184, -1, -1}, /*02862*/ {183, -1, -1}, /*02863*/ {185, -1, -1}, /*02864*/ {2868, 36, 1}, /*02865*/ {2870, 36, 1}, /*02866*/ {2872, 36, 1}, /*02867*/ {2874, 36, 1}, /*02868*/ {178, -1, -1}, /*02869*/ {180, -1, -1}, /*02870*/ {179, -1, -1}, /*02871*/ {181, -1, -1}, /*02872*/ {186, -1, -1}, /*02873*/ {188, -1, -1}, /*02874*/ {187, -1, -1}, /*02875*/ {189, -1, -1}, /*02876*/ {168, -1, -1}, /*02877*/ {169, -1, -1}, /*02878*/ {170, -1, -1}, /*02879*/ {171, -1, -1}, /*02880*/ {445, -1, -1}, /*02881*/ {446, -1, -1}, /*02882*/ {445, -1, -1}, /*02883*/ {447, -1, -1}, /*02884*/ {448, -1, -1}, /*02885*/ {449, -1, -1}, /*02886*/ {448, -1, -1}, /*02887*/ {450, -1, -1}, /*02888*/ {451, -1, -1}, /*02889*/ {452, -1, -1}, /*02890*/ {451, -1, -1}, /*02891*/ {453, -1, -1}, /*02892*/ {454, -1, -1}, /*02893*/ {455, -1, -1}, /*02894*/ {454, -1, -1}, /*02895*/ {456, -1, -1}, /*02896*/ {457, -1, -1}, /*02897*/ {458, -1, -1}, /*02898*/ {457, -1, -1}, /*02899*/ {459, -1, -1}, /*02900*/ {460, -1, -1}, /*02901*/ {461, -1, -1}, /*02902*/ {460, -1, -1}, /*02903*/ {462, -1, -1}, /*02904*/ {463, -1, -1}, /*02905*/ {464, -1, -1}, /*02906*/ {463, -1, -1}, /*02907*/ {465, -1, -1}, /*02908*/ {466, -1, -1}, /*02909*/ {467, -1, -1}, /*02910*/ {466, -1, -1}, /*02911*/ {468, -1, -1}, /*02912*/ {469, -1, -1}, /*02913*/ {470, -1, -1}, /*02914*/ {469, -1, -1}, /*02915*/ {471, -1, -1}, /*02916*/ {472, -1, -1}, /*02917*/ {473, -1, -1}, /*02918*/ {472, -1, -1}, /*02919*/ {474, -1, -1}, /*02920*/ {475, -1, -1}, /*02921*/ {476, -1, -1}, /*02922*/ {475, -1, -1}, /*02923*/ {477, -1, -1}, /*02924*/ {478, -1, -1}, /*02925*/ {479, -1, -1}, /*02926*/ {478, -1, -1}, /*02927*/ {480, -1, -1}, /*02928*/ {481, -1, -1}, /*02929*/ {482, -1, -1}, /*02930*/ {481, -1, -1}, /*02931*/ {483, -1, -1}, /*02932*/ {484, -1, -1}, /*02933*/ {485, -1, -1}, /*02934*/ {484, -1, -1}, /*02935*/ {486, -1, -1}, /*02936*/ {487, -1, -1}, /*02937*/ {488, -1, -1}, /*02938*/ {487, -1, -1}, /*02939*/ {489, -1, -1}, /*02940*/ {490, -1, -1}, /*02941*/ {491, -1, -1}, /*02942*/ {490, -1, -1}, /*02943*/ {492, -1, -1}, /*02944*/ {493, -1, -1}, /*02945*/ {494, -1, -1}, /*02946*/ {493, -1, -1}, /*02947*/ {495, -1, -1}, /*02948*/ {496, -1, -1}, /*02949*/ {497, -1, -1}, /*02950*/ {496, -1, -1}, /*02951*/ {498, -1, -1}, /*02952*/ {499, -1, -1}, /*02953*/ {500, -1, -1}, /*02954*/ {499, -1, -1}, /*02955*/ {501, -1, -1}, /*02956*/ {502, -1, -1}, /*02957*/ {503, -1, -1}, /*02958*/ {502, -1, -1}, /*02959*/ {504, -1, -1}, /*02960*/ {505, -1, -1}, /*02961*/ {506, -1, -1}, /*02962*/ {505, -1, -1}, /*02963*/ {507, -1, -1}, /*02964*/ {508, -1, -1}, /*02965*/ {509, -1, -1}, /*02966*/ {508, -1, -1}, /*02967*/ {510, -1, -1}, /*02968*/ {511, -1, -1}, /*02969*/ {512, -1, -1}, /*02970*/ {511, -1, -1}, /*02971*/ {513, -1, -1}, /*02972*/ {514, -1, -1}, /*02973*/ {515, -1, -1}, /*02974*/ {514, -1, -1}, /*02975*/ {516, -1, -1}, /*02976*/ {0, -1, -1}, /*02977*/ {0, -1, -1}, /*02978*/ {0, -1, -1}, /*02979*/ {0, -1, -1}, /*02980*/ {0, -1, -1}, /*02981*/ {0, -1, -1}, /*02982*/ {0, -1, -1}, /*02983*/ {0, -1, -1}, /*02984*/ {0, -1, -1}, /*02985*/ {0, -1, -1}, /*02986*/ {0, -1, -1}, /*02987*/ {0, -1, -1}, /*02988*/ {517, -1, -1}, /*02989*/ {518, -1, -1}, /*02990*/ {517, -1, -1}, /*02991*/ {519, -1, -1}, /*02992*/ {0, -1, -1}, /*02993*/ {0, -1, -1}, /*02994*/ {0, -1, -1}, /*02995*/ {0, -1, -1}, /*02996*/ {0, -1, -1}, /*02997*/ {0, -1, -1}, /*02998*/ {0, -1, -1}, /*02999*/ {0, -1, -1}, /*03000*/ {0, -1, -1}, /*03001*/ {0, -1, -1}, /*03002*/ {0, -1, -1}, /*03003*/ {0, -1, -1}, /*03004*/ {0, -1, -1}, /*03005*/ {0, -1, -1}, /*03006*/ {0, -1, -1}, /*03007*/ {0, -1, -1}, /*03008*/ {520, -1, -1}, /*03009*/ {521, -1, -1}, /*03010*/ {520, -1, -1}, /*03011*/ {522, -1, -1}, /*03012*/ {523, -1, -1}, /*03013*/ {524, -1, -1}, /*03014*/ {523, -1, -1}, /*03015*/ {525, -1, -1}, /*03016*/ {526, -1, -1}, /*03017*/ {527, -1, -1}, /*03018*/ {526, -1, -1}, /*03019*/ {528, -1, -1}, /*03020*/ {529, -1, -1}, /*03021*/ {530, -1, -1}, /*03022*/ {529, -1, -1}, /*03023*/ {531, -1, -1}, /*03024*/ {532, -1, -1}, /*03025*/ {533, -1, -1}, /*03026*/ {532, -1, -1}, /*03027*/ {534, -1, -1}, /*03028*/ {535, -1, -1}, /*03029*/ {536, -1, -1}, /*03030*/ {535, -1, -1}, /*03031*/ {537, -1, -1}, /*03032*/ {538, -1, -1}, /*03033*/ {539, -1, -1}, /*03034*/ {538, -1, -1}, /*03035*/ {540, -1, -1}, /*03036*/ {541, -1, -1}, /*03037*/ {542, -1, -1}, /*03038*/ {541, -1, -1}, /*03039*/ {543, -1, -1}, /*03040*/ {544, -1, -1}, /*03041*/ {545, -1, -1}, /*03042*/ {544, -1, -1}, /*03043*/ {546, -1, -1}, /*03044*/ {547, -1, -1}, /*03045*/ {548, -1, -1}, /*03046*/ {547, -1, -1}, /*03047*/ {549, -1, -1}, /*03048*/ {550, -1, -1}, /*03049*/ {551, -1, -1}, /*03050*/ {550, -1, -1}, /*03051*/ {552, -1, -1}, /*03052*/ {553, -1, -1}, /*03053*/ {554, -1, -1}, /*03054*/ {553, -1, -1}, /*03055*/ {555, -1, -1}, /*03056*/ {0, -1, -1}, /*03057*/ {0, -1, -1}, /*03058*/ {0, -1, -1}, /*03059*/ {0, -1, -1}, /*03060*/ {0, -1, -1}, /*03061*/ {0, -1, -1}, /*03062*/ {0, -1, -1}, /*03063*/ {0, -1, -1}, /*03064*/ {0, -1, -1}, /*03065*/ {0, -1, -1}, /*03066*/ {0, -1, -1}, /*03067*/ {0, -1, -1}, /*03068*/ {0, -1, -1}, /*03069*/ {0, -1, -1}, /*03070*/ {0, -1, -1}, /*03071*/ {0, -1, -1}, /*03072*/ {574, -1, -1}, /*03073*/ {574, -1, -1}, /*03074*/ {574, -1, -1}, /*03075*/ {575, -1, -1}, /*03076*/ {576, -1, -1}, /*03077*/ {576, -1, -1}, /*03078*/ {576, -1, -1}, /*03079*/ {577, -1, -1}, /*03080*/ {578, -1, -1}, /*03081*/ {578, -1, -1}, /*03082*/ {578, -1, -1}, /*03083*/ {579, -1, -1}, /*03084*/ {580, -1, -1}, /*03085*/ {580, -1, -1}, /*03086*/ {580, -1, -1}, /*03087*/ {581, -1, -1}, /*03088*/ {582, -1, -1}, /*03089*/ {582, -1, -1}, /*03090*/ {582, -1, -1}, /*03091*/ {583, -1, -1}, /*03092*/ {584, -1, -1}, /*03093*/ {584, -1, -1}, /*03094*/ {584, -1, -1}, /*03095*/ {585, -1, -1}, /*03096*/ {586, -1, -1}, /*03097*/ {586, -1, -1}, /*03098*/ {586, -1, -1}, /*03099*/ {587, -1, -1}, /*03100*/ {588, -1, -1}, /*03101*/ {588, -1, -1}, /*03102*/ {588, -1, -1}, /*03103*/ {589, -1, -1}, /*03104*/ {0, -1, -1}, /*03105*/ {0, -1, -1}, /*03106*/ {0, -1, -1}, /*03107*/ {0, -1, -1}, /*03108*/ {0, -1, -1}, /*03109*/ {0, -1, -1}, /*03110*/ {0, -1, -1}, /*03111*/ {0, -1, -1}, /*03112*/ {0, -1, -1}, /*03113*/ {0, -1, -1}, /*03114*/ {0, -1, -1}, /*03115*/ {0, -1, -1}, /*03116*/ {590, -1, -1}, /*03117*/ {590, -1, -1}, /*03118*/ {590, -1, -1}, /*03119*/ {591, -1, -1}, /*03120*/ {0, -1, -1}, /*03121*/ {0, -1, -1}, /*03122*/ {0, -1, -1}, /*03123*/ {0, -1, -1}, /*03124*/ {0, -1, -1}, /*03125*/ {0, -1, -1}, /*03126*/ {0, -1, -1}, /*03127*/ {0, -1, -1}, /*03128*/ {0, -1, -1}, /*03129*/ {0, -1, -1}, /*03130*/ {0, -1, -1}, /*03131*/ {0, -1, -1}, /*03132*/ {0, -1, -1}, /*03133*/ {0, -1, -1}, /*03134*/ {0, -1, -1}, /*03135*/ {0, -1, -1}, /*03136*/ {1406, -1, -1}, /*03137*/ {1407, -1, -1}, /*03138*/ {3146, 12, 1}, /*03139*/ {3148, 12, 1}, /*03140*/ {3150, 12, 1}, /*03141*/ {3152, 12, 1}, /*03142*/ {3154, 12, 1}, /*03143*/ {3156, 12, 1}, /*03144*/ {3158, 12, 1}, /*03145*/ {3160, 12, 1}, /*03146*/ {1216, -1, -1}, /*03147*/ {1217, -1, -1}, /*03148*/ {1218, -1, -1}, /*03149*/ {1219, -1, -1}, /*03150*/ {1220, -1, -1}, /*03151*/ {1221, -1, -1}, /*03152*/ {1222, -1, -1}, /*03153*/ {1223, -1, -1}, /*03154*/ {1224, -1, -1}, /*03155*/ {1225, -1, -1}, /*03156*/ {1226, -1, -1}, /*03157*/ {1227, -1, -1}, /*03158*/ {1228, -1, -1}, /*03159*/ {1229, -1, -1}, /*03160*/ {1230, -1, -1}, /*03161*/ {1231, -1, -1}, /*03162*/ {3290, 27, 3}, /*03163*/ {3298, 27, 3}, /*03164*/ {3306, 27, 3}, /*03165*/ {3314, 27, 3}, /*03166*/ {3322, 27, 3}, /*03167*/ {3330, 27, 3}, /*03168*/ {3338, 27, 3}, /*03169*/ {3346, 27, 3}, /*03170*/ {3354, 27, 3}, /*03171*/ {3362, 27, 3}, /*03172*/ {3370, 27, 3}, /*03173*/ {3378, 27, 3}, /*03174*/ {3386, 27, 3}, /*03175*/ {3394, 27, 3}, /*03176*/ {3402, 27, 3}, /*03177*/ {3410, 27, 3}, /*03178*/ {0, -1, -1}, /*03179*/ {0, -1, -1}, /*03180*/ {0, -1, -1}, /*03181*/ {0, -1, -1}, /*03182*/ {0, -1, -1}, /*03183*/ {0, -1, -1}, /*03184*/ {0, -1, -1}, /*03185*/ {0, -1, -1}, /*03186*/ {0, -1, -1}, /*03187*/ {0, -1, -1}, /*03188*/ {0, -1, -1}, /*03189*/ {3418, 27, 3}, /*03190*/ {3426, 27, 1}, /*03191*/ {3428, 27, 1}, /*03192*/ {3430, 27, 1}, /*03193*/ {3432, 27, 1}, /*03194*/ {3434, 27, 3}, /*03195*/ {3442, 27, 3}, /*03196*/ {3450, 27, 3}, /*03197*/ {3458, 27, 3}, /*03198*/ {3466, 27, 3}, /*03199*/ {3474, 27, 3}, /*03200*/ {3482, 27, 3}, /*03201*/ {3490, 27, 3}, /*03202*/ {0, -1, -1}, /*03203*/ {0, -1, -1}, /*03204*/ {0, -1, -1}, /*03205*/ {0, -1, -1}, /*03206*/ {3498, 27, 3}, /*03207*/ {3506, 27, 3}, /*03208*/ {3514, 27, 3}, /*03209*/ {3522, 27, 3}, /*03210*/ {3530, 27, 3}, /*03211*/ {3538, 27, 3}, /*03212*/ {3546, 27, 3}, /*03213*/ {3554, 27, 3}, /*03214*/ {0, -1, -1}, /*03215*/ {0, -1, -1}, /*03216*/ {0, -1, -1}, /*03217*/ {0, -1, -1}, /*03218*/ {0, -1, -1}, /*03219*/ {0, -1, -1}, /*03220*/ {0, -1, -1}, /*03221*/ {3562, 27, 3}, /*03222*/ {0, -1, -1}, /*03223*/ {0, -1, -1}, /*03224*/ {0, -1, -1}, /*03225*/ {0, -1, -1}, /*03226*/ {3570, 27, 3}, /*03227*/ {3578, 27, 3}, /*03228*/ {3586, 27, 3}, /*03229*/ {3594, 27, 3}, /*03230*/ {3602, 27, 3}, /*03231*/ {3610, 27, 3}, /*03232*/ {3618, 27, 3}, /*03233*/ {3626, 27, 3}, /*03234*/ {3634, 27, 3}, /*03235*/ {3642, 27, 3}, /*03236*/ {3650, 27, 3}, /*03237*/ {3658, 27, 3}, /*03238*/ {3666, 27, 3}, /*03239*/ {3674, 27, 3}, /*03240*/ {3682, 27, 3}, /*03241*/ {3690, 27, 3}, /*03242*/ {0, -1, -1}, /*03243*/ {0, -1, -1}, /*03244*/ {0, -1, -1}, /*03245*/ {0, -1, -1}, /*03246*/ {0, -1, -1}, /*03247*/ {0, -1, -1}, /*03248*/ {0, -1, -1}, /*03249*/ {0, -1, -1}, /*03250*/ {0, -1, -1}, /*03251*/ {0, -1, -1}, /*03252*/ {0, -1, -1}, /*03253*/ {3698, 27, 3}, /*03254*/ {0, -1, -1}, /*03255*/ {0, -1, -1}, /*03256*/ {0, -1, -1}, /*03257*/ {0, -1, -1}, /*03258*/ {3706, 27, 3}, /*03259*/ {3714, 27, 3}, /*03260*/ {3722, 27, 3}, /*03261*/ {3730, 27, 3}, /*03262*/ {3738, 27, 3}, /*03263*/ {3746, 27, 3}, /*03264*/ {3754, 27, 3}, /*03265*/ {3762, 27, 3}, /*03266*/ {0, -1, -1}, /*03267*/ {0, -1, -1}, /*03268*/ {0, -1, -1}, /*03269*/ {0, -1, -1}, /*03270*/ {3770, 27, 3}, /*03271*/ {3778, 27, 3}, /*03272*/ {3786, 27, 3}, /*03273*/ {3794, 27, 3}, /*03274*/ {0, -1, -1}, /*03275*/ {0, -1, -1}, /*03276*/ {0, -1, -1}, /*03277*/ {0, -1, -1}, /*03278*/ {0, -1, -1}, /*03279*/ {0, -1, -1}, /*03280*/ {0, -1, -1}, /*03281*/ {0, -1, -1}, /*03282*/ {0, -1, -1}, /*03283*/ {0, -1, -1}, /*03284*/ {0, -1, -1}, /*03285*/ {0, -1, -1}, /*03286*/ {0, -1, -1}, /*03287*/ {0, -1, -1}, /*03288*/ {0, -1, -1}, /*03289*/ {0, -1, -1}, /*03290*/ {601, -1, -1}, /*03291*/ {0, -1, -1}, /*03292*/ {602, -1, -1}, /*03293*/ {0, -1, -1}, /*03294*/ {601, -1, -1}, /*03295*/ {0, -1, -1}, /*03296*/ {603, -1, -1}, /*03297*/ {0, -1, -1}, /*03298*/ {598, -1, -1}, /*03299*/ {843, -1, -1}, /*03300*/ {599, -1, -1}, /*03301*/ {844, -1, -1}, /*03302*/ {598, -1, -1}, /*03303*/ {843, -1, -1}, /*03304*/ {600, -1, -1}, /*03305*/ {845, -1, -1}, /*03306*/ {592, -1, -1}, /*03307*/ {837, -1, -1}, /*03308*/ {593, -1, -1}, /*03309*/ {838, -1, -1}, /*03310*/ {592, -1, -1}, /*03311*/ {837, -1, -1}, /*03312*/ {594, -1, -1}, /*03313*/ {839, -1, -1}, /*03314*/ {595, -1, -1}, /*03315*/ {840, -1, -1}, /*03316*/ {596, -1, -1}, /*03317*/ {841, -1, -1}, /*03318*/ {595, -1, -1}, /*03319*/ {840, -1, -1}, /*03320*/ {597, -1, -1}, /*03321*/ {842, -1, -1}, /*03322*/ {613, -1, -1}, /*03323*/ {0, -1, -1}, /*03324*/ {614, -1, -1}, /*03325*/ {0, -1, -1}, /*03326*/ {613, -1, -1}, /*03327*/ {0, -1, -1}, /*03328*/ {615, -1, -1}, /*03329*/ {0, -1, -1}, /*03330*/ {610, -1, -1}, /*03331*/ {852, -1, -1}, /*03332*/ {611, -1, -1}, /*03333*/ {853, -1, -1}, /*03334*/ {610, -1, -1}, /*03335*/ {852, -1, -1}, /*03336*/ {612, -1, -1}, /*03337*/ {854, -1, -1}, /*03338*/ {604, -1, -1}, /*03339*/ {846, -1, -1}, /*03340*/ {605, -1, -1}, /*03341*/ {847, -1, -1}, /*03342*/ {604, -1, -1}, /*03343*/ {846, -1, -1}, /*03344*/ {606, -1, -1}, /*03345*/ {848, -1, -1}, /*03346*/ {607, -1, -1}, /*03347*/ {849, -1, -1}, /*03348*/ {608, -1, -1}, /*03349*/ {850, -1, -1}, /*03350*/ {607, -1, -1}, /*03351*/ {849, -1, -1}, /*03352*/ {609, -1, -1}, /*03353*/ {851, -1, -1}, /*03354*/ {625, -1, -1}, /*03355*/ {0, -1, -1}, /*03356*/ {626, -1, -1}, /*03357*/ {0, -1, -1}, /*03358*/ {625, -1, -1}, /*03359*/ {0, -1, -1}, /*03360*/ {627, -1, -1}, /*03361*/ {0, -1, -1}, /*03362*/ {622, -1, -1}, /*03363*/ {861, -1, -1}, /*03364*/ {623, -1, -1}, /*03365*/ {862, -1, -1}, /*03366*/ {622, -1, -1}, /*03367*/ {861, -1, -1}, /*03368*/ {624, -1, -1}, /*03369*/ {863, -1, -1}, /*03370*/ {616, -1, -1}, /*03371*/ {855, -1, -1}, /*03372*/ {617, -1, -1}, /*03373*/ {856, -1, -1}, /*03374*/ {616, -1, -1}, /*03375*/ {855, -1, -1}, /*03376*/ {618, -1, -1}, /*03377*/ {857, -1, -1}, /*03378*/ {619, -1, -1}, /*03379*/ {858, -1, -1}, /*03380*/ {620, -1, -1}, /*03381*/ {859, -1, -1}, /*03382*/ {619, -1, -1}, /*03383*/ {858, -1, -1}, /*03384*/ {621, -1, -1}, /*03385*/ {860, -1, -1}, /*03386*/ {637, -1, -1}, /*03387*/ {0, -1, -1}, /*03388*/ {638, -1, -1}, /*03389*/ {0, -1, -1}, /*03390*/ {637, -1, -1}, /*03391*/ {0, -1, -1}, /*03392*/ {639, -1, -1}, /*03393*/ {0, -1, -1}, /*03394*/ {634, -1, -1}, /*03395*/ {870, -1, -1}, /*03396*/ {635, -1, -1}, /*03397*/ {871, -1, -1}, /*03398*/ {634, -1, -1}, /*03399*/ {870, -1, -1}, /*03400*/ {636, -1, -1}, /*03401*/ {872, -1, -1}, /*03402*/ {628, -1, -1}, /*03403*/ {864, -1, -1}, /*03404*/ {629, -1, -1}, /*03405*/ {865, -1, -1}, /*03406*/ {628, -1, -1}, /*03407*/ {864, -1, -1}, /*03408*/ {630, -1, -1}, /*03409*/ {866, -1, -1}, /*03410*/ {631, -1, -1}, /*03411*/ {867, -1, -1}, /*03412*/ {632, -1, -1}, /*03413*/ {868, -1, -1}, /*03414*/ {631, -1, -1}, /*03415*/ {867, -1, -1}, /*03416*/ {633, -1, -1}, /*03417*/ {869, -1, -1}, /*03418*/ {640, -1, -1}, /*03419*/ {0, -1, -1}, /*03420*/ {641, -1, -1}, /*03421*/ {0, -1, -1}, /*03422*/ {640, -1, -1}, /*03423*/ {0, -1, -1}, /*03424*/ {642, -1, -1}, /*03425*/ {0, -1, -1}, /*03426*/ {0, -1, -1}, /*03427*/ {1041, -1, -1}, /*03428*/ {0, -1, -1}, /*03429*/ {1042, -1, -1}, /*03430*/ {0, -1, -1}, /*03431*/ {1043, -1, -1}, /*03432*/ {0, -1, -1}, /*03433*/ {1044, -1, -1}, /*03434*/ {652, -1, -1}, /*03435*/ {0, -1, -1}, /*03436*/ {653, -1, -1}, /*03437*/ {0, -1, -1}, /*03438*/ {652, -1, -1}, /*03439*/ {0, -1, -1}, /*03440*/ {654, -1, -1}, /*03441*/ {0, -1, -1}, /*03442*/ {649, -1, -1}, /*03443*/ {879, -1, -1}, /*03444*/ {650, -1, -1}, /*03445*/ {880, -1, -1}, /*03446*/ {649, -1, -1}, /*03447*/ {879, -1, -1}, /*03448*/ {651, -1, -1}, /*03449*/ {881, -1, -1}, /*03450*/ {643, -1, -1}, /*03451*/ {873, -1, -1}, /*03452*/ {644, -1, -1}, /*03453*/ {874, -1, -1}, /*03454*/ {643, -1, -1}, /*03455*/ {873, -1, -1}, /*03456*/ {645, -1, -1}, /*03457*/ {875, -1, -1}, /*03458*/ {646, -1, -1}, /*03459*/ {876, -1, -1}, /*03460*/ {647, -1, -1}, /*03461*/ {877, -1, -1}, /*03462*/ {646, -1, -1}, /*03463*/ {876, -1, -1}, /*03464*/ {648, -1, -1}, /*03465*/ {878, -1, -1}, /*03466*/ {664, -1, -1}, /*03467*/ {0, -1, -1}, /*03468*/ {665, -1, -1}, /*03469*/ {0, -1, -1}, /*03470*/ {664, -1, -1}, /*03471*/ {0, -1, -1}, /*03472*/ {666, -1, -1}, /*03473*/ {0, -1, -1}, /*03474*/ {661, -1, -1}, /*03475*/ {888, -1, -1}, /*03476*/ {662, -1, -1}, /*03477*/ {889, -1, -1}, /*03478*/ {661, -1, -1}, /*03479*/ {888, -1, -1}, /*03480*/ {663, -1, -1}, /*03481*/ {890, -1, -1}, /*03482*/ {655, -1, -1}, /*03483*/ {882, -1, -1}, /*03484*/ {656, -1, -1}, /*03485*/ {883, -1, -1}, /*03486*/ {655, -1, -1}, /*03487*/ {882, -1, -1}, /*03488*/ {657, -1, -1}, /*03489*/ {884, -1, -1}, /*03490*/ {658, -1, -1}, /*03491*/ {885, -1, -1}, /*03492*/ {659, -1, -1}, /*03493*/ {886, -1, -1}, /*03494*/ {658, -1, -1}, /*03495*/ {885, -1, -1}, /*03496*/ {660, -1, -1}, /*03497*/ {887, -1, -1}, /*03498*/ {945, -1, -1}, /*03499*/ {0, -1, -1}, /*03500*/ {946, -1, -1}, /*03501*/ {0, -1, -1}, /*03502*/ {947, -1, -1}, /*03503*/ {0, -1, -1}, /*03504*/ {948, -1, -1}, /*03505*/ {0, -1, -1}, /*03506*/ {949, -1, -1}, /*03507*/ {0, -1, -1}, /*03508*/ {950, -1, -1}, /*03509*/ {0, -1, -1}, /*03510*/ {951, -1, -1}, /*03511*/ {0, -1, -1}, /*03512*/ {952, -1, -1}, /*03513*/ {0, -1, -1}, /*03514*/ {953, -1, -1}, /*03515*/ {0, -1, -1}, /*03516*/ {954, -1, -1}, /*03517*/ {0, -1, -1}, /*03518*/ {955, -1, -1}, /*03519*/ {0, -1, -1}, /*03520*/ {956, -1, -1}, /*03521*/ {0, -1, -1}, /*03522*/ {957, -1, -1}, /*03523*/ {0, -1, -1}, /*03524*/ {958, -1, -1}, /*03525*/ {0, -1, -1}, /*03526*/ {959, -1, -1}, /*03527*/ {0, -1, -1}, /*03528*/ {960, -1, -1}, /*03529*/ {0, -1, -1}, /*03530*/ {823, -1, -1}, /*03531*/ {0, -1, -1}, /*03532*/ {823, -1, -1}, /*03533*/ {0, -1, -1}, /*03534*/ {823, -1, -1}, /*03535*/ {0, -1, -1}, /*03536*/ {824, -1, -1}, /*03537*/ {0, -1, -1}, /*03538*/ {821, -1, -1}, /*03539*/ {0, -1, -1}, /*03540*/ {821, -1, -1}, /*03541*/ {0, -1, -1}, /*03542*/ {821, -1, -1}, /*03543*/ {0, -1, -1}, /*03544*/ {822, -1, -1}, /*03545*/ {0, -1, -1}, /*03546*/ {817, -1, -1}, /*03547*/ {0, -1, -1}, /*03548*/ {817, -1, -1}, /*03549*/ {0, -1, -1}, /*03550*/ {817, -1, -1}, /*03551*/ {0, -1, -1}, /*03552*/ {818, -1, -1}, /*03553*/ {0, -1, -1}, /*03554*/ {819, -1, -1}, /*03555*/ {0, -1, -1}, /*03556*/ {819, -1, -1}, /*03557*/ {0, -1, -1}, /*03558*/ {819, -1, -1}, /*03559*/ {0, -1, -1}, /*03560*/ {820, -1, -1}, /*03561*/ {0, -1, -1}, /*03562*/ {825, -1, -1}, /*03563*/ {0, -1, -1}, /*03564*/ {825, -1, -1}, /*03565*/ {0, -1, -1}, /*03566*/ {825, -1, -1}, /*03567*/ {0, -1, -1}, /*03568*/ {826, -1, -1}, /*03569*/ {0, -1, -1}, /*03570*/ {676, -1, -1}, /*03571*/ {0, -1, -1}, /*03572*/ {677, -1, -1}, /*03573*/ {0, -1, -1}, /*03574*/ {676, -1, -1}, /*03575*/ {0, -1, -1}, /*03576*/ {678, -1, -1}, /*03577*/ {0, -1, -1}, /*03578*/ {673, -1, -1}, /*03579*/ {897, -1, -1}, /*03580*/ {674, -1, -1}, /*03581*/ {898, -1, -1}, /*03582*/ {673, -1, -1}, /*03583*/ {897, -1, -1}, /*03584*/ {675, -1, -1}, /*03585*/ {899, -1, -1}, /*03586*/ {667, -1, -1}, /*03587*/ {891, -1, -1}, /*03588*/ {668, -1, -1}, /*03589*/ {892, -1, -1}, /*03590*/ {667, -1, -1}, /*03591*/ {891, -1, -1}, /*03592*/ {669, -1, -1}, /*03593*/ {893, -1, -1}, /*03594*/ {670, -1, -1}, /*03595*/ {894, -1, -1}, /*03596*/ {671, -1, -1}, /*03597*/ {895, -1, -1}, /*03598*/ {670, -1, -1}, /*03599*/ {894, -1, -1}, /*03600*/ {672, -1, -1}, /*03601*/ {896, -1, -1}, /*03602*/ {688, -1, -1}, /*03603*/ {0, -1, -1}, /*03604*/ {689, -1, -1}, /*03605*/ {0, -1, -1}, /*03606*/ {688, -1, -1}, /*03607*/ {0, -1, -1}, /*03608*/ {690, -1, -1}, /*03609*/ {0, -1, -1}, /*03610*/ {685, -1, -1}, /*03611*/ {906, -1, -1}, /*03612*/ {686, -1, -1}, /*03613*/ {907, -1, -1}, /*03614*/ {685, -1, -1}, /*03615*/ {906, -1, -1}, /*03616*/ {687, -1, -1}, /*03617*/ {908, -1, -1}, /*03618*/ {679, -1, -1}, /*03619*/ {900, -1, -1}, /*03620*/ {680, -1, -1}, /*03621*/ {901, -1, -1}, /*03622*/ {679, -1, -1}, /*03623*/ {900, -1, -1}, /*03624*/ {681, -1, -1}, /*03625*/ {902, -1, -1}, /*03626*/ {682, -1, -1}, /*03627*/ {903, -1, -1}, /*03628*/ {683, -1, -1}, /*03629*/ {904, -1, -1}, /*03630*/ {682, -1, -1}, /*03631*/ {903, -1, -1}, /*03632*/ {684, -1, -1}, /*03633*/ {905, -1, -1}, /*03634*/ {700, -1, -1}, /*03635*/ {0, -1, -1}, /*03636*/ {701, -1, -1}, /*03637*/ {0, -1, -1}, /*03638*/ {700, -1, -1}, /*03639*/ {0, -1, -1}, /*03640*/ {702, -1, -1}, /*03641*/ {0, -1, -1}, /*03642*/ {697, -1, -1}, /*03643*/ {915, -1, -1}, /*03644*/ {698, -1, -1}, /*03645*/ {916, -1, -1}, /*03646*/ {697, -1, -1}, /*03647*/ {915, -1, -1}, /*03648*/ {699, -1, -1}, /*03649*/ {917, -1, -1}, /*03650*/ {691, -1, -1}, /*03651*/ {909, -1, -1}, /*03652*/ {692, -1, -1}, /*03653*/ {910, -1, -1}, /*03654*/ {691, -1, -1}, /*03655*/ {909, -1, -1}, /*03656*/ {693, -1, -1}, /*03657*/ {911, -1, -1}, /*03658*/ {694, -1, -1}, /*03659*/ {912, -1, -1}, /*03660*/ {695, -1, -1}, /*03661*/ {913, -1, -1}, /*03662*/ {694, -1, -1}, /*03663*/ {912, -1, -1}, /*03664*/ {696, -1, -1}, /*03665*/ {914, -1, -1}, /*03666*/ {712, -1, -1}, /*03667*/ {0, -1, -1}, /*03668*/ {713, -1, -1}, /*03669*/ {0, -1, -1}, /*03670*/ {712, -1, -1}, /*03671*/ {0, -1, -1}, /*03672*/ {714, -1, -1}, /*03673*/ {0, -1, -1}, /*03674*/ {709, -1, -1}, /*03675*/ {924, -1, -1}, /*03676*/ {710, -1, -1}, /*03677*/ {925, -1, -1}, /*03678*/ {709, -1, -1}, /*03679*/ {924, -1, -1}, /*03680*/ {711, -1, -1}, /*03681*/ {926, -1, -1}, /*03682*/ {703, -1, -1}, /*03683*/ {918, -1, -1}, /*03684*/ {704, -1, -1}, /*03685*/ {919, -1, -1}, /*03686*/ {703, -1, -1}, /*03687*/ {918, -1, -1}, /*03688*/ {705, -1, -1}, /*03689*/ {920, -1, -1}, /*03690*/ {706, -1, -1}, /*03691*/ {921, -1, -1}, /*03692*/ {707, -1, -1}, /*03693*/ {922, -1, -1}, /*03694*/ {706, -1, -1}, /*03695*/ {921, -1, -1}, /*03696*/ {708, -1, -1}, /*03697*/ {923, -1, -1}, /*03698*/ {715, -1, -1}, /*03699*/ {0, -1, -1}, /*03700*/ {716, -1, -1}, /*03701*/ {0, -1, -1}, /*03702*/ {715, -1, -1}, /*03703*/ {0, -1, -1}, /*03704*/ {717, -1, -1}, /*03705*/ {0, -1, -1}, /*03706*/ {727, -1, -1}, /*03707*/ {0, -1, -1}, /*03708*/ {728, -1, -1}, /*03709*/ {0, -1, -1}, /*03710*/ {727, -1, -1}, /*03711*/ {0, -1, -1}, /*03712*/ {729, -1, -1}, /*03713*/ {0, -1, -1}, /*03714*/ {724, -1, -1}, /*03715*/ {933, -1, -1}, /*03716*/ {725, -1, -1}, /*03717*/ {934, -1, -1}, /*03718*/ {724, -1, -1}, /*03719*/ {933, -1, -1}, /*03720*/ {726, -1, -1}, /*03721*/ {935, -1, -1}, /*03722*/ {718, -1, -1}, /*03723*/ {927, -1, -1}, /*03724*/ {719, -1, -1}, /*03725*/ {928, -1, -1}, /*03726*/ {718, -1, -1}, /*03727*/ {927, -1, -1}, /*03728*/ {720, -1, -1}, /*03729*/ {929, -1, -1}, /*03730*/ {721, -1, -1}, /*03731*/ {930, -1, -1}, /*03732*/ {722, -1, -1}, /*03733*/ {931, -1, -1}, /*03734*/ {721, -1, -1}, /*03735*/ {930, -1, -1}, /*03736*/ {723, -1, -1}, /*03737*/ {932, -1, -1}, /*03738*/ {739, -1, -1}, /*03739*/ {0, -1, -1}, /*03740*/ {740, -1, -1}, /*03741*/ {0, -1, -1}, /*03742*/ {739, -1, -1}, /*03743*/ {0, -1, -1}, /*03744*/ {741, -1, -1}, /*03745*/ {0, -1, -1}, /*03746*/ {736, -1, -1}, /*03747*/ {942, -1, -1}, /*03748*/ {737, -1, -1}, /*03749*/ {943, -1, -1}, /*03750*/ {736, -1, -1}, /*03751*/ {942, -1, -1}, /*03752*/ {738, -1, -1}, /*03753*/ {944, -1, -1}, /*03754*/ {730, -1, -1}, /*03755*/ {936, -1, -1}, /*03756*/ {731, -1, -1}, /*03757*/ {937, -1, -1}, /*03758*/ {730, -1, -1}, /*03759*/ {936, -1, -1}, /*03760*/ {732, -1, -1}, /*03761*/ {938, -1, -1}, /*03762*/ {733, -1, -1}, /*03763*/ {939, -1, -1}, /*03764*/ {734, -1, -1}, /*03765*/ {940, -1, -1}, /*03766*/ {733, -1, -1}, /*03767*/ {939, -1, -1}, /*03768*/ {735, -1, -1}, /*03769*/ {941, -1, -1}, /*03770*/ {961, -1, -1}, /*03771*/ {0, -1, -1}, /*03772*/ {962, -1, -1}, /*03773*/ {0, -1, -1}, /*03774*/ {963, -1, -1}, /*03775*/ {0, -1, -1}, /*03776*/ {964, -1, -1}, /*03777*/ {0, -1, -1}, /*03778*/ {965, -1, -1}, /*03779*/ {0, -1, -1}, /*03780*/ {966, -1, -1}, /*03781*/ {0, -1, -1}, /*03782*/ {967, -1, -1}, /*03783*/ {0, -1, -1}, /*03784*/ {968, -1, -1}, /*03785*/ {0, -1, -1}, /*03786*/ {969, -1, -1}, /*03787*/ {0, -1, -1}, /*03788*/ {970, -1, -1}, /*03789*/ {0, -1, -1}, /*03790*/ {971, -1, -1}, /*03791*/ {0, -1, -1}, /*03792*/ {972, -1, -1}, /*03793*/ {0, -1, -1}, /*03794*/ {973, -1, -1}, /*03795*/ {0, -1, -1}, /*03796*/ {974, -1, -1}, /*03797*/ {0, -1, -1}, /*03798*/ {975, -1, -1}, /*03799*/ {0, -1, -1}, /*03800*/ {976, -1, -1}, /*03801*/ {0, -1, -1}, /*03802*/ {1556, -1, -1}, /*03803*/ {0, -1, -1}, /*03804*/ {0, -1, -1}, /*03805*/ {0, -1, -1}, /*03806*/ {3836, 28, 2}, /*03807*/ {0, -1, -1}, /*03808*/ {0, -1, -1}, /*03809*/ {0, -1, -1}, /*03810*/ {3848, 28, 4}, /*03811*/ {0, -1, -1}, /*03812*/ {3864, 28, 4}, /*03813*/ {0, -1, -1}, /*03814*/ {3880, 28, 4}, /*03815*/ {0, -1, -1}, /*03816*/ {3896, 28, 4}, /*03817*/ {0, -1, -1}, /*03818*/ {3912, 28, 4}, /*03819*/ {0, -1, -1}, /*03820*/ {3928, 28, 4}, /*03821*/ {0, -1, -1}, /*03822*/ {3944, 28, 4}, /*03823*/ {0, -1, -1}, /*03824*/ {3960, 28, 4}, /*03825*/ {0, -1, -1}, /*03826*/ {0, -1, -1}, /*03827*/ {0, -1, -1}, /*03828*/ {3976, 28, 4}, /*03829*/ {0, -1, -1}, /*03830*/ {0, -1, -1}, /*03831*/ {0, -1, -1}, /*03832*/ {3992, 28, 4}, /*03833*/ {0, -1, -1}, /*03834*/ {0, -1, -1}, /*03835*/ {0, -1, -1}, /*03836*/ {3840, 30, 2}, /*03837*/ {126, -1, -1}, /*03838*/ {3844, 30, 2}, /*03839*/ {125, -1, -1}, /*03840*/ {154, -1, -1}, /*03841*/ {161, -1, -1}, /*03842*/ {0, -1, -1}, /*03843*/ {0, -1, -1}, /*03844*/ {151, -1, -1}, /*03845*/ {0, -1, -1}, /*03846*/ {0, -1, -1}, /*03847*/ {0, -1, -1}, /*03848*/ {0, -1, -1}, /*03849*/ {159, -1, -1}, /*03850*/ {0, -1, -1}, /*03851*/ {157, -1, -1}, /*03852*/ {0, -1, -1}, /*03853*/ {0, -1, -1}, /*03854*/ {0, -1, -1}, /*03855*/ {0, -1, -1}, /*03856*/ {0, -1, -1}, /*03857*/ {166, -1, -1}, /*03858*/ {0, -1, -1}, /*03859*/ {0, -1, -1}, /*03860*/ {0, -1, -1}, /*03861*/ {0, -1, -1}, /*03862*/ {0, -1, -1}, /*03863*/ {0, -1, -1}, /*03864*/ {0, -1, -1}, /*03865*/ {144, -1, -1}, /*03866*/ {0, -1, -1}, /*03867*/ {0, -1, -1}, /*03868*/ {138, -1, -1}, /*03869*/ {145, -1, -1}, /*03870*/ {141, -1, -1}, /*03871*/ {0, -1, -1}, /*03872*/ {129, -1, -1}, /*03873*/ {0, -1, -1}, /*03874*/ {132, -1, -1}, /*03875*/ {148, -1, -1}, /*03876*/ {0, -1, -1}, /*03877*/ {0, -1, -1}, /*03878*/ {0, -1, -1}, /*03879*/ {0, -1, -1}, /*03880*/ {135, -1, -1}, /*03881*/ {0, -1, -1}, /*03882*/ {136, -1, -1}, /*03883*/ {146, -1, -1}, /*03884*/ {139, -1, -1}, /*03885*/ {0, -1, -1}, /*03886*/ {142, -1, -1}, /*03887*/ {147, -1, -1}, /*03888*/ {130, -1, -1}, /*03889*/ {0, -1, -1}, /*03890*/ {133, -1, -1}, /*03891*/ {0, -1, -1}, /*03892*/ {0, -1, -1}, /*03893*/ {127, -1, -1}, /*03894*/ {0, -1, -1}, /*03895*/ {128, -1, -1}, /*03896*/ {0, -1, -1}, /*03897*/ {0, -1, -1}, /*03898*/ {0, -1, -1}, /*03899*/ {0, -1, -1}, /*03900*/ {0, -1, -1}, /*03901*/ {0, -1, -1}, /*03902*/ {0, -1, -1}, /*03903*/ {0, -1, -1}, /*03904*/ {0, -1, -1}, /*03905*/ {0, -1, -1}, /*03906*/ {149, -1, -1}, /*03907*/ {0, -1, -1}, /*03908*/ {0, -1, -1}, /*03909*/ {0, -1, -1}, /*03910*/ {0, -1, -1}, /*03911*/ {0, -1, -1}, /*03912*/ {0, -1, -1}, /*03913*/ {0, -1, -1}, /*03914*/ {0, -1, -1}, /*03915*/ {0, -1, -1}, /*03916*/ {0, -1, -1}, /*03917*/ {164, -1, -1}, /*03918*/ {0, -1, -1}, /*03919*/ {0, -1, -1}, /*03920*/ {0, -1, -1}, /*03921*/ {0, -1, -1}, /*03922*/ {150, -1, -1}, /*03923*/ {0, -1, -1}, /*03924*/ {0, -1, -1}, /*03925*/ {0, -1, -1}, /*03926*/ {0, -1, -1}, /*03927*/ {0, -1, -1}, /*03928*/ {155, -1, -1}, /*03929*/ {0, -1, -1}, /*03930*/ {152, -1, -1}, /*03931*/ {0, -1, -1}, /*03932*/ {162, -1, -1}, /*03933*/ {0, -1, -1}, /*03934*/ {0, -1, -1}, /*03935*/ {0, -1, -1}, /*03936*/ {0, -1, -1}, /*03937*/ {0, -1, -1}, /*03938*/ {0, -1, -1}, /*03939*/ {0, -1, -1}, /*03940*/ {0, -1, -1}, /*03941*/ {0, -1, -1}, /*03942*/ {0, -1, -1}, /*03943*/ {0, -1, -1}, /*03944*/ {156, -1, -1}, /*03945*/ {0, -1, -1}, /*03946*/ {153, -1, -1}, /*03947*/ {0, -1, -1}, /*03948*/ {163, -1, -1}, /*03949*/ {0, -1, -1}, /*03950*/ {0, -1, -1}, /*03951*/ {0, -1, -1}, /*03952*/ {0, -1, -1}, /*03953*/ {0, -1, -1}, /*03954*/ {0, -1, -1}, /*03955*/ {0, -1, -1}, /*03956*/ {0, -1, -1}, /*03957*/ {0, -1, -1}, /*03958*/ {0, -1, -1}, /*03959*/ {0, -1, -1}, /*03960*/ {0, -1, -1}, /*03961*/ {160, -1, -1}, /*03962*/ {0, -1, -1}, /*03963*/ {158, -1, -1}, /*03964*/ {0, -1, -1}, /*03965*/ {0, -1, -1}, /*03966*/ {0, -1, -1}, /*03967*/ {0, -1, -1}, /*03968*/ {0, -1, -1}, /*03969*/ {0, -1, -1}, /*03970*/ {0, -1, -1}, /*03971*/ {0, -1, -1}, /*03972*/ {0, -1, -1}, /*03973*/ {0, -1, -1}, /*03974*/ {0, -1, -1}, /*03975*/ {0, -1, -1}, /*03976*/ {0, -1, -1}, /*03977*/ {0, -1, -1}, /*03978*/ {137, -1, -1}, /*03979*/ {0, -1, -1}, /*03980*/ {140, -1, -1}, /*03981*/ {0, -1, -1}, /*03982*/ {143, -1, -1}, /*03983*/ {0, -1, -1}, /*03984*/ {131, -1, -1}, /*03985*/ {0, -1, -1}, /*03986*/ {134, -1, -1}, /*03987*/ {0, -1, -1}, /*03988*/ {0, -1, -1}, /*03989*/ {0, -1, -1}, /*03990*/ {0, -1, -1}, /*03991*/ {0, -1, -1}, /*03992*/ {0, -1, -1}, /*03993*/ {0, -1, -1}, /*03994*/ {0, -1, -1}, /*03995*/ {0, -1, -1}, /*03996*/ {0, -1, -1}, /*03997*/ {165, -1, -1}, /*03998*/ {0, -1, -1}, /*03999*/ {0, -1, -1}, /*04000*/ {0, -1, -1}, /*04001*/ {0, -1, -1}, /*04002*/ {0, -1, -1}, /*04003*/ {0, -1, -1}, /*04004*/ {0, -1, -1}, /*04005*/ {0, -1, -1}, /*04006*/ {0, -1, -1}, /*04007*/ {0, -1, -1}, /*04008*/ {751, -1, -1}, /*04009*/ {752, -1, -1}, /*04010*/ {751, -1, -1}, /*04011*/ {753, -1, -1}, /*04012*/ {748, -1, -1}, /*04013*/ {749, -1, -1}, /*04014*/ {748, -1, -1}, /*04015*/ {750, -1, -1}, /*04016*/ {742, -1, -1}, /*04017*/ {743, -1, -1}, /*04018*/ {742, -1, -1}, /*04019*/ {744, -1, -1}, /*04020*/ {745, -1, -1}, /*04021*/ {746, -1, -1}, /*04022*/ {745, -1, -1}, /*04023*/ {747, -1, -1}, /*04024*/ {763, -1, -1}, /*04025*/ {764, -1, -1}, /*04026*/ {763, -1, -1}, /*04027*/ {765, -1, -1}, /*04028*/ {760, -1, -1}, /*04029*/ {761, -1, -1}, /*04030*/ {760, -1, -1}, /*04031*/ {762, -1, -1}, /*04032*/ {754, -1, -1}, /*04033*/ {755, -1, -1}, /*04034*/ {754, -1, -1}, /*04035*/ {756, -1, -1}, /*04036*/ {757, -1, -1}, /*04037*/ {758, -1, -1}, /*04038*/ {757, -1, -1}, /*04039*/ {759, -1, -1}, /*04040*/ {775, -1, -1}, /*04041*/ {776, -1, -1}, /*04042*/ {775, -1, -1}, /*04043*/ {777, -1, -1}, /*04044*/ {772, -1, -1}, /*04045*/ {773, -1, -1}, /*04046*/ {772, -1, -1}, /*04047*/ {774, -1, -1}, /*04048*/ {766, -1, -1}, /*04049*/ {767, -1, -1}, /*04050*/ {766, -1, -1}, /*04051*/ {768, -1, -1}, /*04052*/ {769, -1, -1}, /*04053*/ {770, -1, -1}, /*04054*/ {769, -1, -1}, /*04055*/ {771, -1, -1}, /*04056*/ {787, -1, -1}, /*04057*/ {788, -1, -1}, /*04058*/ {787, -1, -1}, /*04059*/ {789, -1, -1}, /*04060*/ {784, -1, -1}, /*04061*/ {785, -1, -1}, /*04062*/ {784, -1, -1}, /*04063*/ {786, -1, -1}, /*04064*/ {778, -1, -1}, /*04065*/ {779, -1, -1}, /*04066*/ {778, -1, -1}, /*04067*/ {780, -1, -1}, /*04068*/ {781, -1, -1}, /*04069*/ {782, -1, -1}, /*04070*/ {781, -1, -1}, /*04071*/ {783, -1, -1}, /*04072*/ {0, -1, -1}, /*04073*/ {0, -1, -1}, /*04074*/ {0, -1, -1}, /*04075*/ {0, -1, -1}, /*04076*/ {0, -1, -1}, /*04077*/ {0, -1, -1}, /*04078*/ {0, -1, -1}, /*04079*/ {0, -1, -1}, /*04080*/ {0, -1, -1}, /*04081*/ {0, -1, -1}, /*04082*/ {0, -1, -1}, /*04083*/ {0, -1, -1}, /*04084*/ {0, -1, -1}, /*04085*/ {0, -1, -1}, /*04086*/ {0, -1, -1}, /*04087*/ {0, -1, -1}, /*04088*/ {0, -1, -1}, /*04089*/ {0, -1, -1}, /*04090*/ {0, -1, -1}, /*04091*/ {0, -1, -1}, /*04092*/ {0, -1, -1}, /*04093*/ {0, -1, -1}, /*04094*/ {0, -1, -1}, /*04095*/ {0, -1, -1}, /*04096*/ {0, -1, -1}, /*04097*/ {0, -1, -1}, /*04098*/ {0, -1, -1}, /*04099*/ {0, -1, -1}, /*04100*/ {0, -1, -1}, /*04101*/ {0, -1, -1}, /*04102*/ {0, -1, -1}, /*04103*/ {0, -1, -1}, /*04104*/ {0, -1, -1}, /*04105*/ {0, -1, -1}, /*04106*/ {0, -1, -1}, /*04107*/ {0, -1, -1}, /*04108*/ {0, -1, -1}, /*04109*/ {0, -1, -1}, /*04110*/ {0, -1, -1}, /*04111*/ {0, -1, -1}, /*04112*/ {0, -1, -1}, /*04113*/ {0, -1, -1}, /*04114*/ {0, -1, -1}, /*04115*/ {0, -1, -1}, /*04116*/ {790, -1, -1}, /*04117*/ {791, -1, -1}, /*04118*/ {790, -1, -1}, /*04119*/ {792, -1, -1}, /*04120*/ {0, -1, -1}, /*04121*/ {0, -1, -1}, /*04122*/ {0, -1, -1}, /*04123*/ {0, -1, -1}, /*04124*/ {0, -1, -1}, /*04125*/ {0, -1, -1}, /*04126*/ {0, -1, -1}, /*04127*/ {0, -1, -1}, /*04128*/ {0, -1, -1}, /*04129*/ {0, -1, -1}, /*04130*/ {0, -1, -1}, /*04131*/ {0, -1, -1}, /*04132*/ {0, -1, -1}, /*04133*/ {0, -1, -1}, /*04134*/ {0, -1, -1}, /*04135*/ {0, -1, -1}, /*04136*/ {802, -1, -1}, /*04137*/ {803, -1, -1}, /*04138*/ {802, -1, -1}, /*04139*/ {804, -1, -1}, /*04140*/ {799, -1, -1}, /*04141*/ {800, -1, -1}, /*04142*/ {799, -1, -1}, /*04143*/ {801, -1, -1}, /*04144*/ {793, -1, -1}, /*04145*/ {794, -1, -1}, /*04146*/ {793, -1, -1}, /*04147*/ {795, -1, -1}, /*04148*/ {796, -1, -1}, /*04149*/ {797, -1, -1}, /*04150*/ {796, -1, -1}, /*04151*/ {798, -1, -1}, /*04152*/ {814, -1, -1}, /*04153*/ {815, -1, -1}, /*04154*/ {814, -1, -1}, /*04155*/ {816, -1, -1}, /*04156*/ {811, -1, -1}, /*04157*/ {812, -1, -1}, /*04158*/ {811, -1, -1}, /*04159*/ {813, -1, -1}, /*04160*/ {805, -1, -1}, /*04161*/ {806, -1, -1}, /*04162*/ {805, -1, -1}, /*04163*/ {807, -1, -1}, /*04164*/ {808, -1, -1}, /*04165*/ {809, -1, -1}, /*04166*/ {808, -1, -1}, /*04167*/ {810, -1, -1}, /*04168*/ {0, -1, -1}, /*04169*/ {0, -1, -1}, /*04170*/ {0, -1, -1}, /*04171*/ {0, -1, -1}, /*04172*/ {0, -1, -1}, /*04173*/ {0, -1, -1}, /*04174*/ {0, -1, -1}, /*04175*/ {0, -1, -1}, /*04176*/ {0, -1, -1}, /*04177*/ {0, -1, -1}, /*04178*/ {0, -1, -1}, /*04179*/ {0, -1, -1}, /*04180*/ {0, -1, -1}, /*04181*/ {0, -1, -1}, /*04182*/ {0, -1, -1}, /*04183*/ {0, -1, -1}, /*04184*/ {977, -1, -1}, /*04185*/ {978, -1, -1}, /*04186*/ {979, -1, -1}, /*04187*/ {980, -1, -1}, /*04188*/ {981, -1, -1}, /*04189*/ {982, -1, -1}, /*04190*/ {983, -1, -1}, /*04191*/ {984, -1, -1}, /*04192*/ {985, -1, -1}, /*04193*/ {986, -1, -1}, /*04194*/ {987, -1, -1}, /*04195*/ {988, -1, -1}, /*04196*/ {989, -1, -1}, /*04197*/ {990, -1, -1}, /*04198*/ {991, -1, -1}, /*04199*/ {992, -1, -1}, /*04200*/ {833, -1, -1}, /*04201*/ {833, -1, -1}, /*04202*/ {833, -1, -1}, /*04203*/ {834, -1, -1}, /*04204*/ {831, -1, -1}, /*04205*/ {831, -1, -1}, /*04206*/ {831, -1, -1}, /*04207*/ {832, -1, -1}, /*04208*/ {827, -1, -1}, /*04209*/ {827, -1, -1}, /*04210*/ {827, -1, -1}, /*04211*/ {828, -1, -1}, /*04212*/ {829, -1, -1}, /*04213*/ {829, -1, -1}, /*04214*/ {829, -1, -1}, /*04215*/ {830, -1, -1}, /*04216*/ {0, -1, -1}, /*04217*/ {0, -1, -1}, /*04218*/ {0, -1, -1}, /*04219*/ {0, -1, -1}, /*04220*/ {0, -1, -1}, /*04221*/ {0, -1, -1}, /*04222*/ {0, -1, -1}, /*04223*/ {0, -1, -1}, /*04224*/ {0, -1, -1}, /*04225*/ {0, -1, -1}, /*04226*/ {0, -1, -1}, /*04227*/ {0, -1, -1}, /*04228*/ {0, -1, -1}, /*04229*/ {0, -1, -1}, /*04230*/ {0, -1, -1}, /*04231*/ {0, -1, -1}, /*04232*/ {0, -1, -1}, /*04233*/ {0, -1, -1}, /*04234*/ {0, -1, -1}, /*04235*/ {0, -1, -1}, /*04236*/ {0, -1, -1}, /*04237*/ {0, -1, -1}, /*04238*/ {0, -1, -1}, /*04239*/ {0, -1, -1}, /*04240*/ {0, -1, -1}, /*04241*/ {0, -1, -1}, /*04242*/ {0, -1, -1}, /*04243*/ {0, -1, -1}, /*04244*/ {835, -1, -1}, /*04245*/ {835, -1, -1}, /*04246*/ {835, -1, -1}, /*04247*/ {836, -1, -1}, /*04248*/ {0, -1, -1}, /*04249*/ {0, -1, -1}, /*04250*/ {0, -1, -1}, /*04251*/ {0, -1, -1}, /*04252*/ {0, -1, -1}, /*04253*/ {0, -1, -1}, /*04254*/ {0, -1, -1}, /*04255*/ {0, -1, -1}, /*04256*/ {0, -1, -1}, /*04257*/ {0, -1, -1}, /*04258*/ {0, -1, -1}, /*04259*/ {0, -1, -1}, /*04260*/ {0, -1, -1}, /*04261*/ {0, -1, -1}, /*04262*/ {0, -1, -1}, /*04263*/ {0, -1, -1}, /*04264*/ {4328, 35, 1}, /*04265*/ {0, -1, -1}, /*04266*/ {0, -1, -1}, /*04267*/ {0, -1, -1}, /*04268*/ {0, -1, -1}, /*04269*/ {0, -1, -1}, /*04270*/ {0, -1, -1}, /*04271*/ {0, -1, -1}, /*04272*/ {4330, 35, 1}, /*04273*/ {0, -1, -1}, /*04274*/ {0, -1, -1}, /*04275*/ {0, -1, -1}, /*04276*/ {0, -1, -1}, /*04277*/ {0, -1, -1}, /*04278*/ {0, -1, -1}, /*04279*/ {0, -1, -1}, /*04280*/ {4332, 35, 1}, /*04281*/ {0, -1, -1}, /*04282*/ {0, -1, -1}, /*04283*/ {0, -1, -1}, /*04284*/ {0, -1, -1}, /*04285*/ {0, -1, -1}, /*04286*/ {0, -1, -1}, /*04287*/ {0, -1, -1}, /*04288*/ {4334, 35, 1}, /*04289*/ {0, -1, -1}, /*04290*/ {0, -1, -1}, /*04291*/ {0, -1, -1}, /*04292*/ {0, -1, -1}, /*04293*/ {0, -1, -1}, /*04294*/ {0, -1, -1}, /*04295*/ {0, -1, -1}, /*04296*/ {0, -1, -1}, /*04297*/ {0, -1, -1}, /*04298*/ {0, -1, -1}, /*04299*/ {0, -1, -1}, /*04300*/ {0, -1, -1}, /*04301*/ {0, -1, -1}, /*04302*/ {0, -1, -1}, /*04303*/ {0, -1, -1}, /*04304*/ {0, -1, -1}, /*04305*/ {0, -1, -1}, /*04306*/ {0, -1, -1}, /*04307*/ {0, -1, -1}, /*04308*/ {0, -1, -1}, /*04309*/ {0, -1, -1}, /*04310*/ {0, -1, -1}, /*04311*/ {0, -1, -1}, /*04312*/ {0, -1, -1}, /*04313*/ {0, -1, -1}, /*04314*/ {0, -1, -1}, /*04315*/ {0, -1, -1}, /*04316*/ {0, -1, -1}, /*04317*/ {0, -1, -1}, /*04318*/ {0, -1, -1}, /*04319*/ {0, -1, -1}, /*04320*/ {0, -1, -1}, /*04321*/ {0, -1, -1}, /*04322*/ {0, -1, -1}, /*04323*/ {0, -1, -1}, /*04324*/ {0, -1, -1}, /*04325*/ {0, -1, -1}, /*04326*/ {0, -1, -1}, /*04327*/ {0, -1, -1}, /*04328*/ {1296, -1, -1}, /*04329*/ {1297, -1, -1}, /*04330*/ {1298, -1, -1}, /*04331*/ {1299, -1, -1}, /*04332*/ {1300, -1, -1}, /*04333*/ {1301, -1, -1}, /*04334*/ {1302, -1, -1}, /*04335*/ {1303, -1, -1}, /*04336*/ {4344, 29, 4}, /*04337*/ {0, -1, -1}, /*04338*/ {4384, 27, 6}, /*04339*/ {4474, 29, 4}, /*04340*/ {18, -1, -1}, /*04341*/ {0, -1, -1}, /*04342*/ {19, -1, -1}, /*04343*/ {0, -1, -1}, /*04344*/ {4360, 27, 2}, /*04345*/ {4364, 27, 2}, /*04346*/ {4368, 27, 2}, /*04347*/ {4372, 27, 2}, /*04348*/ {11, -1, -1}, /*04349*/ {0, -1, -1}, /*04350*/ {12, -1, -1}, /*04351*/ {0, -1, -1}, /*04352*/ {0, -1, -1}, /*04353*/ {4376, 27, 2}, /*04354*/ {0, -1, -1}, /*04355*/ {4380, 27, 2}, /*04356*/ {0, -1, -1}, /*04357*/ {0, -1, -1}, /*04358*/ {0, -1, -1}, /*04359*/ {0, -1, -1}, /*04360*/ {2, -1, -1}, /*04361*/ {3, -1, -1}, /*04362*/ {0, -1, -1}, /*04363*/ {0, -1, -1}, /*04364*/ {5, -1, -1}, /*04365*/ {4, -1, -1}, /*04366*/ {0, -1, -1}, /*04367*/ {0, -1, -1}, /*04368*/ {6, -1, -1}, /*04369*/ {0, -1, -1}, /*04370*/ {0, -1, -1}, /*04371*/ {0, -1, -1}, /*04372*/ {7, -1, -1}, /*04373*/ {8, -1, -1}, /*04374*/ {9, -1, -1}, /*04375*/ {10, -1, -1}, /*04376*/ {0, -1, -1}, /*04377*/ {13, -1, -1}, /*04378*/ {0, -1, -1}, /*04379*/ {0, -1, -1}, /*04380*/ {14, -1, -1}, /*04381*/ {15, -1, -1}, /*04382*/ {16, -1, -1}, /*04383*/ {17, -1, -1}, /*04384*/ {4448, 36, 1}, /*04385*/ {4450, 36, 1}, /*04386*/ {4452, 36, 1}, /*04387*/ {4454, 36, 1}, /*04388*/ {4456, 36, 1}, /*04389*/ {4458, 36, 1}, /*04390*/ {4460, 36, 1}, /*04391*/ {4462, 36, 1}, /*04392*/ {0, -1, -1}, /*04393*/ {0, -1, -1}, /*04394*/ {4464, 36, 1}, /*04395*/ {4466, 36, 1}, /*04396*/ {0, -1, -1}, /*04397*/ {0, -1, -1}, /*04398*/ {4468, 36, 1}, /*04399*/ {0, -1, -1}, /*04400*/ {0, -1, -1}, /*04401*/ {0, -1, -1}, /*04402*/ {0, -1, -1}, /*04403*/ {0, -1, -1}, /*04404*/ {0, -1, -1}, /*04405*/ {0, -1, -1}, /*04406*/ {0, -1, -1}, /*04407*/ {0, -1, -1}, /*04408*/ {0, -1, -1}, /*04409*/ {0, -1, -1}, /*04410*/ {0, -1, -1}, /*04411*/ {0, -1, -1}, /*04412*/ {0, -1, -1}, /*04413*/ {0, -1, -1}, /*04414*/ {0, -1, -1}, /*04415*/ {0, -1, -1}, /*04416*/ {0, -1, -1}, /*04417*/ {0, -1, -1}, /*04418*/ {0, -1, -1}, /*04419*/ {0, -1, -1}, /*04420*/ {4470, 36, 1}, /*04421*/ {4472, 36, 1}, /*04422*/ {0, -1, -1}, /*04423*/ {0, -1, -1}, /*04424*/ {0, -1, -1}, /*04425*/ {0, -1, -1}, /*04426*/ {0, -1, -1}, /*04427*/ {0, -1, -1}, /*04428*/ {0, -1, -1}, /*04429*/ {0, -1, -1}, /*04430*/ {0, -1, -1}, /*04431*/ {0, -1, -1}, /*04432*/ {0, -1, -1}, /*04433*/ {0, -1, -1}, /*04434*/ {0, -1, -1}, /*04435*/ {0, -1, -1}, /*04436*/ {0, -1, -1}, /*04437*/ {0, -1, -1}, /*04438*/ {0, -1, -1}, /*04439*/ {0, -1, -1}, /*04440*/ {0, -1, -1}, /*04441*/ {0, -1, -1}, /*04442*/ {0, -1, -1}, /*04443*/ {0, -1, -1}, /*04444*/ {0, -1, -1}, /*04445*/ {0, -1, -1}, /*04446*/ {0, -1, -1}, /*04447*/ {0, -1, -1}, /*04448*/ {93, -1, -1}, /*04449*/ {95, -1, -1}, /*04450*/ {96, -1, -1}, /*04451*/ {0, -1, -1}, /*04452*/ {98, -1, -1}, /*04453*/ {0, -1, -1}, /*04454*/ {100, -1, -1}, /*04455*/ {0, -1, -1}, /*04456*/ {102, -1, -1}, /*04457*/ {104, -1, -1}, /*04458*/ {105, -1, -1}, /*04459*/ {0, -1, -1}, /*04460*/ {107, -1, -1}, /*04461*/ {0, -1, -1}, /*04462*/ {109, -1, -1}, /*04463*/ {0, -1, -1}, /*04464*/ {111, -1, -1}, /*04465*/ {0, -1, -1}, /*04466*/ {113, -1, -1}, /*04467*/ {0, -1, -1}, /*04468*/ {115, -1, -1}, /*04469*/ {0, -1, -1}, /*04470*/ {117, -1, -1}, /*04471*/ {119, -1, -1}, /*04472*/ {120, -1, -1}, /*04473*/ {122, -1, -1}, /*04474*/ {4490, 27, 2}, /*04475*/ {4502, 27, 2}, /*04476*/ {4514, 27, 2}, /*04477*/ {4522, 27, 2}, /*04478*/ {4528, 36, 1}, /*04479*/ {0, -1, -1}, /*04480*/ {4530, 36, 1}, /*04481*/ {0, -1, -1}, /*04482*/ {0, -1, -1}, /*04483*/ {4532, 27, 2}, /*04484*/ {0, -1, -1}, /*04485*/ {0, -1, -1}, /*04486*/ {0, -1, -1}, /*04487*/ {0, -1, -1}, /*04488*/ {0, -1, -1}, /*04489*/ {0, -1, -1}, /*04490*/ {4494, 36, 1}, /*04491*/ {4496, 36, 1}, /*04492*/ {4498, 36, 1}, /*04493*/ {4500, 36, 1}, /*04494*/ {94, -1, -1}, /*04495*/ {0, -1, -1}, /*04496*/ {97, -1, -1}, /*04497*/ {0, -1, -1}, /*04498*/ {99, -1, -1}, /*04499*/ {0, -1, -1}, /*04500*/ {101, -1, -1}, /*04501*/ {0, -1, -1}, /*04502*/ {4506, 36, 1}, /*04503*/ {4508, 36, 1}, /*04504*/ {4510, 36, 1}, /*04505*/ {4512, 36, 1}, /*04506*/ {103, -1, -1}, /*04507*/ {0, -1, -1}, /*04508*/ {106, -1, -1}, /*04509*/ {0, -1, -1}, /*04510*/ {108, -1, -1}, /*04511*/ {0, -1, -1}, /*04512*/ {110, -1, -1}, /*04513*/ {0, -1, -1}, /*04514*/ {0, -1, -1}, /*04515*/ {0, -1, -1}, /*04516*/ {4518, 36, 1}, /*04517*/ {4520, 36, 1}, /*04518*/ {112, -1, -1}, /*04519*/ {0, -1, -1}, /*04520*/ {114, -1, -1}, /*04521*/ {0, -1, -1}, /*04522*/ {0, -1, -1}, /*04523*/ {0, -1, -1}, /*04524*/ {4526, 36, 1}, /*04525*/ {0, -1, -1}, /*04526*/ {116, -1, -1}, /*04527*/ {0, -1, -1}, /*04528*/ {123, -1, -1}, /*04529*/ {0, -1, -1}, /*04530*/ {124, -1, -1}, /*04531*/ {0, -1, -1}, /*04532*/ {4536, 36, 1}, /*04533*/ {4538, 36, 1}, /*04534*/ {0, -1, -1}, /*04535*/ {0, -1, -1}, /*04536*/ {118, -1, -1}, /*04537*/ {0, -1, -1}, /*04538*/ {121, -1, -1}, /*04539*/ {0, -1, -1}, /*04540*/ {4548, 29, 4}, /*04541*/ {0, -1, -1}, /*04542*/ {4588, 27, 6}, /*04543*/ {4678, 29, 4}, /*04544*/ {18, -1, -1}, /*04545*/ {0, -1, -1}, /*04546*/ {19, -1, -1}, /*04547*/ {0, -1, -1}, /*04548*/ {4564, 27, 2}, /*04549*/ {4568, 27, 2}, /*04550*/ {4572, 27, 2}, /*04551*/ {4576, 27, 2}, /*04552*/ {11, -1, -1}, /*04553*/ {0, -1, -1}, /*04554*/ {12, -1, -1}, /*04555*/ {0, -1, -1}, /*04556*/ {0, -1, -1}, /*04557*/ {4580, 27, 2}, /*04558*/ {0, -1, -1}, /*04559*/ {4584, 27, 2}, /*04560*/ {0, -1, -1}, /*04561*/ {0, -1, -1}, /*04562*/ {0, -1, -1}, /*04563*/ {0, -1, -1}, /*04564*/ {2, -1, -1}, /*04565*/ {3, -1, -1}, /*04566*/ {0, -1, -1}, /*04567*/ {0, -1, -1}, /*04568*/ {5, -1, -1}, /*04569*/ {4, -1, -1}, /*04570*/ {0, -1, -1}, /*04571*/ {0, -1, -1}, /*04572*/ {6, -1, -1}, /*04573*/ {0, -1, -1}, /*04574*/ {0, -1, -1}, /*04575*/ {0, -1, -1}, /*04576*/ {7, -1, -1}, /*04577*/ {8, -1, -1}, /*04578*/ {9, -1, -1}, /*04579*/ {10, -1, -1}, /*04580*/ {0, -1, -1}, /*04581*/ {13, -1, -1}, /*04582*/ {0, -1, -1}, /*04583*/ {0, -1, -1}, /*04584*/ {14, -1, -1}, /*04585*/ {15, -1, -1}, /*04586*/ {16, -1, -1}, /*04587*/ {17, -1, -1}, /*04588*/ {4652, 36, 1}, /*04589*/ {4654, 36, 1}, /*04590*/ {4656, 36, 1}, /*04591*/ {4658, 36, 1}, /*04592*/ {4660, 36, 1}, /*04593*/ {4662, 36, 1}, /*04594*/ {4664, 36, 1}, /*04595*/ {4666, 36, 1}, /*04596*/ {0, -1, -1}, /*04597*/ {0, -1, -1}, /*04598*/ {4668, 36, 1}, /*04599*/ {4670, 36, 1}, /*04600*/ {0, -1, -1}, /*04601*/ {0, -1, -1}, /*04602*/ {4672, 36, 1}, /*04603*/ {0, -1, -1}, /*04604*/ {0, -1, -1}, /*04605*/ {0, -1, -1}, /*04606*/ {0, -1, -1}, /*04607*/ {0, -1, -1}, /*04608*/ {0, -1, -1}, /*04609*/ {0, -1, -1}, /*04610*/ {0, -1, -1}, /*04611*/ {0, -1, -1}, /*04612*/ {0, -1, -1}, /*04613*/ {0, -1, -1}, /*04614*/ {0, -1, -1}, /*04615*/ {0, -1, -1}, /*04616*/ {0, -1, -1}, /*04617*/ {0, -1, -1}, /*04618*/ {0, -1, -1}, /*04619*/ {0, -1, -1}, /*04620*/ {0, -1, -1}, /*04621*/ {0, -1, -1}, /*04622*/ {0, -1, -1}, /*04623*/ {0, -1, -1}, /*04624*/ {4674, 36, 1}, /*04625*/ {4676, 36, 1}, /*04626*/ {0, -1, -1}, /*04627*/ {0, -1, -1}, /*04628*/ {0, -1, -1}, /*04629*/ {0, -1, -1}, /*04630*/ {0, -1, -1}, /*04631*/ {0, -1, -1}, /*04632*/ {0, -1, -1}, /*04633*/ {0, -1, -1}, /*04634*/ {0, -1, -1}, /*04635*/ {0, -1, -1}, /*04636*/ {0, -1, -1}, /*04637*/ {0, -1, -1}, /*04638*/ {0, -1, -1}, /*04639*/ {0, -1, -1}, /*04640*/ {0, -1, -1}, /*04641*/ {0, -1, -1}, /*04642*/ {0, -1, -1}, /*04643*/ {0, -1, -1}, /*04644*/ {0, -1, -1}, /*04645*/ {0, -1, -1}, /*04646*/ {0, -1, -1}, /*04647*/ {0, -1, -1}, /*04648*/ {0, -1, -1}, /*04649*/ {0, -1, -1}, /*04650*/ {0, -1, -1}, /*04651*/ {0, -1, -1}, /*04652*/ {93, -1, -1}, /*04653*/ {95, -1, -1}, /*04654*/ {96, -1, -1}, /*04655*/ {0, -1, -1}, /*04656*/ {98, -1, -1}, /*04657*/ {0, -1, -1}, /*04658*/ {100, -1, -1}, /*04659*/ {0, -1, -1}, /*04660*/ {102, -1, -1}, /*04661*/ {104, -1, -1}, /*04662*/ {105, -1, -1}, /*04663*/ {0, -1, -1}, /*04664*/ {107, -1, -1}, /*04665*/ {0, -1, -1}, /*04666*/ {109, -1, -1}, /*04667*/ {0, -1, -1}, /*04668*/ {111, -1, -1}, /*04669*/ {0, -1, -1}, /*04670*/ {113, -1, -1}, /*04671*/ {0, -1, -1}, /*04672*/ {115, -1, -1}, /*04673*/ {0, -1, -1}, /*04674*/ {117, -1, -1}, /*04675*/ {119, -1, -1}, /*04676*/ {120, -1, -1}, /*04677*/ {122, -1, -1}, /*04678*/ {4694, 27, 2}, /*04679*/ {4706, 27, 2}, /*04680*/ {4718, 27, 2}, /*04681*/ {4726, 27, 2}, /*04682*/ {4732, 36, 1}, /*04683*/ {0, -1, -1}, /*04684*/ {4734, 36, 1}, /*04685*/ {0, -1, -1}, /*04686*/ {0, -1, -1}, /*04687*/ {4736, 27, 2}, /*04688*/ {0, -1, -1}, /*04689*/ {0, -1, -1}, /*04690*/ {0, -1, -1}, /*04691*/ {0, -1, -1}, /*04692*/ {0, -1, -1}, /*04693*/ {0, -1, -1}, /*04694*/ {4698, 36, 1}, /*04695*/ {4700, 36, 1}, /*04696*/ {4702, 36, 1}, /*04697*/ {4704, 36, 1}, /*04698*/ {94, -1, -1}, /*04699*/ {0, -1, -1}, /*04700*/ {97, -1, -1}, /*04701*/ {0, -1, -1}, /*04702*/ {99, -1, -1}, /*04703*/ {0, -1, -1}, /*04704*/ {101, -1, -1}, /*04705*/ {0, -1, -1}, /*04706*/ {4710, 36, 1}, /*04707*/ {4712, 36, 1}, /*04708*/ {4714, 36, 1}, /*04709*/ {4716, 36, 1}, /*04710*/ {103, -1, -1}, /*04711*/ {0, -1, -1}, /*04712*/ {106, -1, -1}, /*04713*/ {0, -1, -1}, /*04714*/ {108, -1, -1}, /*04715*/ {0, -1, -1}, /*04716*/ {110, -1, -1}, /*04717*/ {0, -1, -1}, /*04718*/ {0, -1, -1}, /*04719*/ {0, -1, -1}, /*04720*/ {4722, 36, 1}, /*04721*/ {4724, 36, 1}, /*04722*/ {112, -1, -1}, /*04723*/ {0, -1, -1}, /*04724*/ {114, -1, -1}, /*04725*/ {0, -1, -1}, /*04726*/ {0, -1, -1}, /*04727*/ {0, -1, -1}, /*04728*/ {4730, 36, 1}, /*04729*/ {0, -1, -1}, /*04730*/ {116, -1, -1}, /*04731*/ {0, -1, -1}, /*04732*/ {123, -1, -1}, /*04733*/ {0, -1, -1}, /*04734*/ {124, -1, -1}, /*04735*/ {0, -1, -1}, /*04736*/ {4740, 36, 1}, /*04737*/ {4742, 36, 1}, /*04738*/ {0, -1, -1}, /*04739*/ {0, -1, -1}, /*04740*/ {118, -1, -1}, /*04741*/ {0, -1, -1}, /*04742*/ {121, -1, -1}, /*04743*/ {0, -1, -1}, /*04744*/ {1322, -1, -1}, /*04745*/ {1323, -1, -1}, /*04746*/ {1324, -1, -1}, /*04747*/ {1325, -1, -1}, /*04748*/ {1326, -1, -1}, /*04749*/ {1327, -1, -1}, /*04750*/ {1328, -1, -1}, /*04751*/ {1329, -1, -1}, /*04752*/ {1330, -1, -1}, /*04753*/ {1331, -1, -1}, /*04754*/ {1332, -1, -1}, /*04755*/ {1333, -1, -1}, /*04756*/ {1334, -1, -1}, /*04757*/ {1335, -1, -1}, /*04758*/ {1336, -1, -1}, /*04759*/ {1337, -1, -1}, /*04760*/ {1338, -1, -1}, /*04761*/ {1339, -1, -1}, /*04762*/ {1340, -1, -1}, /*04763*/ {1341, -1, -1}, /*04764*/ {1342, -1, -1}, /*04765*/ {1343, -1, -1}, /*04766*/ {1344, -1, -1}, /*04767*/ {1345, -1, -1}, /*04768*/ {1346, -1, -1}, /*04769*/ {1347, -1, -1}, /*04770*/ {1348, -1, -1}, /*04771*/ {1349, -1, -1}, /*04772*/ {1350, -1, -1}, /*04773*/ {1351, -1, -1}, /*04774*/ {1352, -1, -1}, /*04775*/ {1353, -1, -1}, /*04776*/ {4784, 36, 1}, /*04777*/ {4790, 36, 1}, /*04778*/ {4796, 36, 1}, /*04779*/ {4802, 36, 1}, /*04780*/ {4808, 12, 1}, /*04781*/ {4810, 12, 1}, /*04782*/ {4812, 12, 1}, /*04783*/ {4814, 12, 1}, /*04784*/ {4786, 12, 1}, /*04785*/ {4788, 12, 1}, /*04786*/ {21, -1, -1}, /*04787*/ {24, -1, -1}, /*04788*/ {45, -1, -1}, /*04789*/ {48, -1, -1}, /*04790*/ {4792, 12, 1}, /*04791*/ {4794, 12, 1}, /*04792*/ {27, -1, -1}, /*04793*/ {30, -1, -1}, /*04794*/ {51, -1, -1}, /*04795*/ {54, -1, -1}, /*04796*/ {4798, 12, 1}, /*04797*/ {4800, 12, 1}, /*04798*/ {33, -1, -1}, /*04799*/ {36, -1, -1}, /*04800*/ {57, -1, -1}, /*04801*/ {60, -1, -1}, /*04802*/ {4804, 12, 1}, /*04803*/ {4806, 12, 1}, /*04804*/ {39, -1, -1}, /*04805*/ {42, -1, -1}, /*04806*/ {63, -1, -1}, /*04807*/ {66, -1, -1}, /*04808*/ {69, -1, -1}, /*04809*/ {72, -1, -1}, /*04810*/ {75, -1, -1}, /*04811*/ {78, -1, -1}, /*04812*/ {81, -1, -1}, /*04813*/ {84, -1, -1}, /*04814*/ {87, -1, -1}, /*04815*/ {90, -1, -1}, /*04816*/ {4824, 36, 1}, /*04817*/ {4830, 36, 1}, /*04818*/ {4836, 36, 1}, /*04819*/ {4842, 36, 1}, /*04820*/ {4848, 12, 1}, /*04821*/ {4850, 12, 1}, /*04822*/ {4852, 12, 1}, /*04823*/ {4854, 12, 1}, /*04824*/ {4826, 12, 1}, /*04825*/ {4828, 12, 1}, /*04826*/ {21, -1, -1}, /*04827*/ {24, -1, -1}, /*04828*/ {45, -1, -1}, /*04829*/ {48, -1, -1}, /*04830*/ {4832, 12, 1}, /*04831*/ {4834, 12, 1}, /*04832*/ {27, -1, -1}, /*04833*/ {30, -1, -1}, /*04834*/ {51, -1, -1}, /*04835*/ {54, -1, -1}, /*04836*/ {4838, 12, 1}, /*04837*/ {4840, 12, 1}, /*04838*/ {33, -1, -1}, /*04839*/ {36, -1, -1}, /*04840*/ {57, -1, -1}, /*04841*/ {60, -1, -1}, /*04842*/ {4844, 12, 1}, /*04843*/ {4846, 12, 1}, /*04844*/ {39, -1, -1}, /*04845*/ {42, -1, -1}, /*04846*/ {63, -1, -1}, /*04847*/ {66, -1, -1}, /*04848*/ {69, -1, -1}, /*04849*/ {72, -1, -1}, /*04850*/ {75, -1, -1}, /*04851*/ {78, -1, -1}, /*04852*/ {81, -1, -1}, /*04853*/ {84, -1, -1}, /*04854*/ {87, -1, -1}, /*04855*/ {90, -1, -1}, /*04856*/ {1354, -1, -1}, /*04857*/ {1355, -1, -1}, /*04858*/ {1356, -1, -1}, /*04859*/ {1357, -1, -1}, /*04860*/ {1358, -1, -1}, /*04861*/ {1359, -1, -1}, /*04862*/ {1360, -1, -1}, /*04863*/ {1361, -1, -1}, /*04864*/ {4872, 6, 3}, /*04865*/ {4882, 6, 3}, /*04866*/ {4892, 6, 3}, /*04867*/ {4902, 6, 3}, /*04868*/ {4912, 6, 3}, /*04869*/ {4922, 6, 3}, /*04870*/ {4932, 6, 3}, /*04871*/ {4942, 6, 3}, /*04872*/ {4880, 12, 1}, /*04873*/ {0, -1, -1}, /*04874*/ {0, -1, -1}, /*04875*/ {0, -1, -1}, /*04876*/ {0, -1, -1}, /*04877*/ {0, -1, -1}, /*04878*/ {0, -1, -1}, /*04879*/ {0, -1, -1}, /*04880*/ {1557, -1, -1}, /*04881*/ {1558, -1, -1}, /*04882*/ {4890, 12, 1}, /*04883*/ {0, -1, -1}, /*04884*/ {0, -1, -1}, /*04885*/ {0, -1, -1}, /*04886*/ {0, -1, -1}, /*04887*/ {0, -1, -1}, /*04888*/ {0, -1, -1}, /*04889*/ {0, -1, -1}, /*04890*/ {1559, -1, -1}, /*04891*/ {1560, -1, -1}, /*04892*/ {4900, 12, 1}, /*04893*/ {0, -1, -1}, /*04894*/ {0, -1, -1}, /*04895*/ {0, -1, -1}, /*04896*/ {0, -1, -1}, /*04897*/ {0, -1, -1}, /*04898*/ {0, -1, -1}, /*04899*/ {0, -1, -1}, /*04900*/ {1561, -1, -1}, /*04901*/ {1562, -1, -1}, /*04902*/ {4910, 12, 1}, /*04903*/ {0, -1, -1}, /*04904*/ {0, -1, -1}, /*04905*/ {0, -1, -1}, /*04906*/ {0, -1, -1}, /*04907*/ {0, -1, -1}, /*04908*/ {0, -1, -1}, /*04909*/ {0, -1, -1}, /*04910*/ {1563, -1, -1}, /*04911*/ {1564, -1, -1}, /*04912*/ {4920, 12, 1}, /*04913*/ {0, -1, -1}, /*04914*/ {0, -1, -1}, /*04915*/ {0, -1, -1}, /*04916*/ {0, -1, -1}, /*04917*/ {0, -1, -1}, /*04918*/ {0, -1, -1}, /*04919*/ {0, -1, -1}, /*04920*/ {1565, -1, -1}, /*04921*/ {1566, -1, -1}, /*04922*/ {4930, 12, 1}, /*04923*/ {0, -1, -1}, /*04924*/ {0, -1, -1}, /*04925*/ {0, -1, -1}, /*04926*/ {0, -1, -1}, /*04927*/ {0, -1, -1}, /*04928*/ {0, -1, -1}, /*04929*/ {0, -1, -1}, /*04930*/ {1567, -1, -1}, /*04931*/ {1568, -1, -1}, /*04932*/ {4940, 12, 1}, /*04933*/ {0, -1, -1}, /*04934*/ {0, -1, -1}, /*04935*/ {0, -1, -1}, /*04936*/ {0, -1, -1}, /*04937*/ {0, -1, -1}, /*04938*/ {0, -1, -1}, /*04939*/ {0, -1, -1}, /*04940*/ {1569, -1, -1}, /*04941*/ {1570, -1, -1}, /*04942*/ {4950, 12, 1}, /*04943*/ {0, -1, -1}, /*04944*/ {0, -1, -1}, /*04945*/ {0, -1, -1}, /*04946*/ {0, -1, -1}, /*04947*/ {0, -1, -1}, /*04948*/ {0, -1, -1}, /*04949*/ {0, -1, -1}, /*04950*/ {1571, -1, -1}, /*04951*/ {1572, -1, -1}, /*04952*/ {4960, 36, 1}, /*04953*/ {4966, 36, 1}, /*04954*/ {4972, 36, 1}, /*04955*/ {4978, 36, 1}, /*04956*/ {4984, 12, 1}, /*04957*/ {4986, 12, 1}, /*04958*/ {4988, 12, 1}, /*04959*/ {4990, 12, 1}, /*04960*/ {4962, 12, 1}, /*04961*/ {4964, 12, 1}, /*04962*/ {22, -1, -1}, /*04963*/ {25, -1, -1}, /*04964*/ {46, -1, -1}, /*04965*/ {49, -1, -1}, /*04966*/ {4968, 12, 1}, /*04967*/ {4970, 12, 1}, /*04968*/ {28, -1, -1}, /*04969*/ {31, -1, -1}, /*04970*/ {52, -1, -1}, /*04971*/ {55, -1, -1}, /*04972*/ {4974, 12, 1}, /*04973*/ {4976, 12, 1}, /*04974*/ {34, -1, -1}, /*04975*/ {37, -1, -1}, /*04976*/ {58, -1, -1}, /*04977*/ {61, -1, -1}, /*04978*/ {4980, 12, 1}, /*04979*/ {4982, 12, 1}, /*04980*/ {40, -1, -1}, /*04981*/ {43, -1, -1}, /*04982*/ {64, -1, -1}, /*04983*/ {67, -1, -1}, /*04984*/ {70, -1, -1}, /*04985*/ {73, -1, -1}, /*04986*/ {76, -1, -1}, /*04987*/ {79, -1, -1}, /*04988*/ {82, -1, -1}, /*04989*/ {85, -1, -1}, /*04990*/ {88, -1, -1}, /*04991*/ {91, -1, -1}, /*04992*/ {5000, 36, 1}, /*04993*/ {5006, 36, 1}, /*04994*/ {5012, 36, 1}, /*04995*/ {5018, 36, 1}, /*04996*/ {5024, 12, 1}, /*04997*/ {5026, 12, 1}, /*04998*/ {5028, 12, 1}, /*04999*/ {5030, 12, 1}, /*05000*/ {5002, 12, 1}, /*05001*/ {5004, 12, 1}, /*05002*/ {22, -1, -1}, /*05003*/ {25, -1, -1}, /*05004*/ {46, -1, -1}, /*05005*/ {49, -1, -1}, /*05006*/ {5008, 12, 1}, /*05007*/ {5010, 12, 1}, /*05008*/ {28, -1, -1}, /*05009*/ {31, -1, -1}, /*05010*/ {52, -1, -1}, /*05011*/ {55, -1, -1}, /*05012*/ {5014, 12, 1}, /*05013*/ {5016, 12, 1}, /*05014*/ {34, -1, -1}, /*05015*/ {37, -1, -1}, /*05016*/ {58, -1, -1}, /*05017*/ {61, -1, -1}, /*05018*/ {5020, 12, 1}, /*05019*/ {5022, 12, 1}, /*05020*/ {40, -1, -1}, /*05021*/ {43, -1, -1}, /*05022*/ {64, -1, -1}, /*05023*/ {67, -1, -1}, /*05024*/ {70, -1, -1}, /*05025*/ {73, -1, -1}, /*05026*/ {76, -1, -1}, /*05027*/ {79, -1, -1}, /*05028*/ {82, -1, -1}, /*05029*/ {85, -1, -1}, /*05030*/ {88, -1, -1}, /*05031*/ {91, -1, -1}, /*05032*/ {1362, -1, -1}, /*05033*/ {1363, -1, -1}, /*05034*/ {1364, -1, -1}, /*05035*/ {1365, -1, -1}, /*05036*/ {1366, -1, -1}, /*05037*/ {1367, -1, -1}, /*05038*/ {1368, -1, -1}, /*05039*/ {1369, -1, -1}, /*05040*/ {5048, 12, 1}, /*05041*/ {5050, 12, 1}, /*05042*/ {5052, 12, 1}, /*05043*/ {5054, 12, 1}, /*05044*/ {5056, 12, 1}, /*05045*/ {5058, 12, 1}, /*05046*/ {5060, 12, 1}, /*05047*/ {5062, 12, 1}, /*05048*/ {1573, -1, -1}, /*05049*/ {1574, -1, -1}, /*05050*/ {1575, -1, -1}, /*05051*/ {1576, -1, -1}, /*05052*/ {1577, -1, -1}, /*05053*/ {1578, -1, -1}, /*05054*/ {1579, -1, -1}, /*05055*/ {1580, -1, -1}, /*05056*/ {1581, -1, -1}, /*05057*/ {1582, -1, -1}, /*05058*/ {1583, -1, -1}, /*05059*/ {1584, -1, -1}, /*05060*/ {1585, -1, -1}, /*05061*/ {1586, -1, -1}, /*05062*/ {1587, -1, -1}, /*05063*/ {1588, -1, -1}, /*05064*/ {5072, 36, 1}, /*05065*/ {5078, 36, 1}, /*05066*/ {5084, 36, 1}, /*05067*/ {5090, 36, 1}, /*05068*/ {5096, 12, 1}, /*05069*/ {5098, 12, 1}, /*05070*/ {5100, 12, 1}, /*05071*/ {5102, 12, 1}, /*05072*/ {5074, 12, 1}, /*05073*/ {5076, 12, 1}, /*05074*/ {23, -1, -1}, /*05075*/ {26, -1, -1}, /*05076*/ {47, -1, -1}, /*05077*/ {50, -1, -1}, /*05078*/ {5080, 12, 1}, /*05079*/ {5082, 12, 1}, /*05080*/ {29, -1, -1}, /*05081*/ {32, -1, -1}, /*05082*/ {53, -1, -1}, /*05083*/ {56, -1, -1}, /*05084*/ {5086, 12, 1}, /*05085*/ {5088, 12, 1}, /*05086*/ {35, -1, -1}, /*05087*/ {38, -1, -1}, /*05088*/ {59, -1, -1}, /*05089*/ {62, -1, -1}, /*05090*/ {5092, 12, 1}, /*05091*/ {5094, 12, 1}, /*05092*/ {41, -1, -1}, /*05093*/ {44, -1, -1}, /*05094*/ {65, -1, -1}, /*05095*/ {68, -1, -1}, /*05096*/ {71, -1, -1}, /*05097*/ {74, -1, -1}, /*05098*/ {77, -1, -1}, /*05099*/ {80, -1, -1}, /*05100*/ {83, -1, -1}, /*05101*/ {86, -1, -1}, /*05102*/ {89, -1, -1}, /*05103*/ {92, -1, -1}, /*05104*/ {5112, 36, 1}, /*05105*/ {5118, 36, 1}, /*05106*/ {5124, 36, 1}, /*05107*/ {5130, 36, 1}, /*05108*/ {5136, 12, 1}, /*05109*/ {5138, 12, 1}, /*05110*/ {5140, 12, 1}, /*05111*/ {5142, 12, 1}, /*05112*/ {5114, 12, 1}, /*05113*/ {5116, 12, 1}, /*05114*/ {23, -1, -1}, /*05115*/ {26, -1, -1}, /*05116*/ {47, -1, -1}, /*05117*/ {50, -1, -1}, /*05118*/ {5120, 12, 1}, /*05119*/ {5122, 12, 1}, /*05120*/ {29, -1, -1}, /*05121*/ {32, -1, -1}, /*05122*/ {53, -1, -1}, /*05123*/ {56, -1, -1}, /*05124*/ {5126, 12, 1}, /*05125*/ {5128, 12, 1}, /*05126*/ {35, -1, -1}, /*05127*/ {38, -1, -1}, /*05128*/ {59, -1, -1}, /*05129*/ {62, -1, -1}, /*05130*/ {5132, 12, 1}, /*05131*/ {5134, 12, 1}, /*05132*/ {41, -1, -1}, /*05133*/ {44, -1, -1}, /*05134*/ {65, -1, -1}, /*05135*/ {68, -1, -1}, /*05136*/ {71, -1, -1}, /*05137*/ {74, -1, -1}, /*05138*/ {77, -1, -1}, /*05139*/ {80, -1, -1}, /*05140*/ {83, -1, -1}, /*05141*/ {86, -1, -1}, /*05142*/ {89, -1, -1}, /*05143*/ {92, -1, -1}, /*05144*/ {1373, -1, -1}, /*05145*/ {5146, 34, 2}, /*05146*/ {1370, -1, -1}, /*05147*/ {0, -1, -1}, /*05148*/ {1372, -1, -1}, /*05149*/ {1371, -1, -1} }; #define ArchRev0 0 #define Impl_Itanium 1 #define Impl_Brl 2 IA64OpcodeEntry IA64OpcodeTable[] = { {NULL,IA64_FORMAT_NONE,IA64_TROLE_NONE,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ignored",IA64_FORMAT_NONE,IA64_TROLE_NONE,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"add",IA64_FORMAT_A1,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"add",IA64_FORMAT_A1,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_ONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"sub",IA64_FORMAT_A1,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"sub",IA64_FORMAT_A1,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_ONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"addp4",IA64_FORMAT_A1,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"and",IA64_FORMAT_A1,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"andcm",IA64_FORMAT_A1,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"or",IA64_FORMAT_A1,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xor",IA64_FORMAT_A1,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"shladd",IA64_FORMAT_A2,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UDEC},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"shladdp4",IA64_FORMAT_A2,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UDEC},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"sub",IA64_FORMAT_A3,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"and",IA64_FORMAT_A3,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"andcm",IA64_FORMAT_A3,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"or",IA64_FORMAT_A3,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xor",IA64_FORMAT_A3,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"adds",IA64_FORMAT_A4,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"addp4",IA64_FORMAT_A4,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"addl",IA64_FORMAT_A5,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0_3},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.lt",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.ltu",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.eq",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.lt.unc",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.ltu.unc",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.eq.unc",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.eq.and",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.eq.or",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.eq.or.andcm",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.ne.and",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.ne.or",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.ne.or.andcm",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.lt",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.ltu",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.eq",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.lt.unc",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.ltu.unc",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.eq.unc",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.eq.and",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.eq.or",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.eq.or.andcm",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.ne.and",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.ne.or",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.ne.or.andcm",IA64_FORMAT_A6,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.gt.and",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.gt.or",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.gt.or.andcm",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.le.and",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.le.or",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.le.or.andcm",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.ge.and",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.ge.or",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.ge.or.andcm",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.lt.and",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.lt.or",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.lt.or.andcm",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.gt.and",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.gt.or",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.gt.or.andcm",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.le.and",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.le.or",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.le.or.andcm",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.ge.and",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.ge.or",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.ge.or.andcm",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.lt.and",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.lt.or",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.lt.or.andcm",IA64_FORMAT_A7,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_R0},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.lt",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.ltu",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_CMP_UIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.eq",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.lt.unc",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.ltu.unc",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_CMP_UIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.eq.unc",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.eq.and",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.eq.or",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.eq.or.andcm",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.ne.and",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.ne.or",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp.ne.or.andcm",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.lt",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.ltu",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_CMP4_UIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.eq",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.lt.unc",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.ltu.unc",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_CMP4_UIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.eq.unc",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.eq.and",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.eq.or",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.eq.or.andcm",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.ne.and",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.ne.or",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmp4.ne.or.andcm",IA64_FORMAT_A8,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"padd1",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"padd2",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"padd4",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"padd1.sss",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"padd2.sss",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"padd1.uuu",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"padd2.uuu",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"padd1.uus",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"padd2.uus",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"psub1",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"psub2",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"psub4",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"psub1.sss",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"psub2.sss",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"psub1.uuu",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"psub2.uuu",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"psub1.uus",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"psub2.uus",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pavg1",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pavg2",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pavg1.raz",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pavg2.raz",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pavgsub1",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pavgsub2",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pcmp1.eq",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pcmp2.eq",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pcmp4.eq",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pcmp1.gt",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pcmp2.gt",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pcmp4.gt",IA64_FORMAT_A9,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pshladd2",IA64_FORMAT_A10,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_COUNT_123},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pshradd2",IA64_FORMAT_A10,IA64_TROLE_ALU,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_COUNT_123},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pmpyshr2",IA64_FORMAT_I1,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_COUNT_PACK},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pmpyshr2.u",IA64_FORMAT_I1,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_COUNT_PACK},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pmpy2.r",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pmpy2.l",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mix1.r",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mix2.r",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mix4.r",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mix1.l",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mix2.l",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mix4.l",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pack2.uss",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pack2.sss",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pack4.sss",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"unpack1.h",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"unpack2.h",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"unpack4.h",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"unpack1.l",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"unpack2.l",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"unpack4.l",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pmin1.u",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pmax1.u",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pmin2",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pmax2",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"psad1",IA64_FORMAT_I2,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mux1",IA64_FORMAT_I3,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_MUX1},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mux2",IA64_FORMAT_I4,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pshr2",IA64_FORMAT_I5,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pshr4",IA64_FORMAT_I5,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"shr",IA64_FORMAT_I5,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pshr2.u",IA64_FORMAT_I5,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pshr4.u",IA64_FORMAT_I5,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"shr.u",IA64_FORMAT_I5,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pshr2",IA64_FORMAT_I6,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pshr4",IA64_FORMAT_I6,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pshr2.u",IA64_FORMAT_I6,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pshr4.u",IA64_FORMAT_I6,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pshl2",IA64_FORMAT_I7,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pshl4",IA64_FORMAT_I7,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"shl",IA64_FORMAT_I7,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pshl2",IA64_FORMAT_I8,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_CCOUNT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"pshl4",IA64_FORMAT_I8,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_CCOUNT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"popcnt",IA64_FORMAT_I9,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"shrp",IA64_FORMAT_I10,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"extr.u",IA64_FORMAT_I11,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_UDEC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"extr",IA64_FORMAT_I11,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_UDEC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"dep.z",IA64_FORMAT_I12,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_CPOS},{IA64_OPROLE_SRC,IA64_OPTYPE_UDEC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"dep.z",IA64_FORMAT_I13,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_CPOS},{IA64_OPROLE_SRC,IA64_OPTYPE_UDEC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"dep",IA64_FORMAT_I14,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_CPOS},{IA64_OPROLE_SRC,IA64_OPTYPE_UDEC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"dep",IA64_FORMAT_I15,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_CPOS},{IA64_OPROLE_SRC,IA64_OPTYPE_UDEC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tbit.z",IA64_FORMAT_I16,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tbit.z.unc",IA64_FORMAT_I16,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tbit.z.and",IA64_FORMAT_I16,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tbit.nz.and",IA64_FORMAT_I16,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tbit.z.or",IA64_FORMAT_I16,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tbit.nz.or",IA64_FORMAT_I16,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tbit.z.or.andcm",IA64_FORMAT_I16,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tbit.nz.or.andcm",IA64_FORMAT_I16,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tnat.z",IA64_FORMAT_I17,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tnat.z.unc",IA64_FORMAT_I17,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tnat.z.and",IA64_FORMAT_I17,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tnat.nz.and",IA64_FORMAT_I17,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tnat.z.or",IA64_FORMAT_I17,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tnat.nz.or",IA64_FORMAT_I17,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tnat.z.or.andcm",IA64_FORMAT_I17,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tnat.nz.or.andcm",IA64_FORMAT_I17,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"break.i",IA64_FORMAT_I19,IA64_TROLE_INT,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"nop.i",IA64_FORMAT_I19,IA64_TROLE_INT,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"chk.s.i",IA64_FORMAT_I20,IA64_TROLE_INT,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.sptk",IA64_FORMAT_I21,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.sptk.imp",IA64_FORMAT_I21,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_I21,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.imp",IA64_FORMAT_I21,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.dptk",IA64_FORMAT_I21,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.dptk.imp",IA64_FORMAT_I21,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.ret.sptk",IA64_FORMAT_I21,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.ret.sptk.imp",IA64_FORMAT_I21,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.ret",IA64_FORMAT_I21,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.ret.imp",IA64_FORMAT_I21,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.ret.dptk",IA64_FORMAT_I21,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.ret.dptk.imp",IA64_FORMAT_I21,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_I22,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_I23,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREGS_ALL},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_1},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_I24,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_PREGS_ROT},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_16},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_I25,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IP},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_I25,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_PREGS_ALL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.i",IA64_FORMAT_I26,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_APP_REG_GRP_HIGH},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.i",IA64_FORMAT_I27,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_APP_REG_GRP_HIGH},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.i",IA64_FORMAT_I28,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_REG_GRP_HIGH},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"zxt1",IA64_FORMAT_I29,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"zxt2",IA64_FORMAT_I29,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"zxt4",IA64_FORMAT_I29,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"sxt1",IA64_FORMAT_I29,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"sxt2",IA64_FORMAT_I29,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"sxt4",IA64_FORMAT_I29,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"czx1.l",IA64_FORMAT_I29,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"czx2.l",IA64_FORMAT_I29,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"czx1.r",IA64_FORMAT_I29,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"czx2.r",IA64_FORMAT_I29,IA64_TROLE_INT,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.s",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.s.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.s.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.s",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.s.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.s.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.s",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.s.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.s.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.s",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.s.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.s.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.a",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.a.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.a.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.a",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.a.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.a.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.a",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.a.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.a.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.a",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.a.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.a.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.sa",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.sa.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.sa.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.sa",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.sa.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.sa.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.sa",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.sa.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.sa.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.sa",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.sa.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.sa.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.bias",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.bias.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.bias.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.bias",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.bias.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.bias.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.bias",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.bias.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.bias.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.bias",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.bias.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.bias.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.acq",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.acq.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.acq.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.acq",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.acq.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.acq.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.acq",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.acq.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.acq.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.acq",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.acq.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.acq.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.fill",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.fill.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.fill.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.nc",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.nc.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.nc.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.nc",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.nc.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.nc.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.nc",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.nc.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.nc.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.nc",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.nc.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.nc.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.acq",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.acq.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.acq.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.acq",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.acq.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.acq.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.acq",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.acq.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.acq.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.acq",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.acq.nt1",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.acq.nta",IA64_FORMAT_M1,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.s",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.s.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.s.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.s",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.s.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.s.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.s",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.s.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.s.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.s",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.s.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.s.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.a",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.a.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.a.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.a",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.a.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.a.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.a",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.a.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.a.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.a",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.a.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.a.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.sa",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.sa.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.sa.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.sa",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.sa.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.sa.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.sa",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.sa.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.sa.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.sa",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.sa.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.sa.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.bias",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.bias.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.bias.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.bias",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.bias.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.bias.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.bias",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.bias.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.bias.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.bias",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.bias.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.bias.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.acq",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.acq.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.acq.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.acq",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.acq.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.acq.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.acq",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.acq.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.acq.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.acq",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.acq.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.acq.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.fill",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.fill.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.fill.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.nc",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.nc.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.nc.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.nc",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.nc.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.nc.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.nc",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.nc.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.nc.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.nc",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.nc.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.nc.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.acq",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.acq.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.acq.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.acq",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.acq.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.acq.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.acq",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.acq.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.acq.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.acq",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.acq.nt1",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.acq.nta",IA64_FORMAT_M2,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.s",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.s.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.s.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.s",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.s.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.s.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.s",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.s.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.s.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.s",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.s.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.s.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.a",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.a.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.a.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.a",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.a.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.a.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.a",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.a.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.a.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.a",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.a.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.a.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.sa",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.sa.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.sa.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.sa",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.sa.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.sa.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.sa",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.sa.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.sa.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.sa",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.sa.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.sa.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.bias",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.bias.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.bias.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.bias",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.bias.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.bias.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.bias",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.bias.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.bias.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.bias",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.bias.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.bias.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.acq",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.acq.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.acq.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.acq",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.acq.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.acq.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.acq",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.acq.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.acq.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.acq",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.acq.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.acq.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.fill",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.fill.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.fill.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.nc",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.nc.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.nc.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.nc",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.nc.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.nc.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.nc",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.nc.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.nc.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.nc",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.nc.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.nc.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.acq",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.acq.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld1.c.clr.acq.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.acq",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.acq.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld2.c.clr.acq.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.acq",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.acq.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld4.c.clr.acq.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.acq",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.acq.nt1",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ld8.c.clr.acq.nta",IA64_FORMAT_M3,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st1",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st1.nta",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st2",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st2.nta",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st4",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st4.nta",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st8",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st8.nta",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st1.rel",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st1.rel.nta",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st2.rel",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st2.rel.nta",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st4.rel",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st4.rel.nta",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st8.rel",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st8.rel.nta",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st8.spill",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st8.spill.nta",IA64_FORMAT_M4,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st1",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st1.nta",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st2",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st2.nta",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st4",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st4.nta",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st8",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st8.nta",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st1.rel",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st1.rel.nta",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st2.rel",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st2.rel.nta",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st4.rel",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st4.rel.nta",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st8.rel",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st8.rel.nta",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st8.spill",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"st8.spill.nta",IA64_FORMAT_M5,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.s",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.s.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.s.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.s",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.s.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.s.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.s",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.s.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.s.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.s",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.s.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.s.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.a",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.a.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.a.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.a",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.a.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.a.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.a",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.a.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.a.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.a",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.a.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.a.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.sa",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.sa.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.sa.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.sa",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.sa.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.sa.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.sa",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.sa.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.sa.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.sa",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.sa.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.sa.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf.fill",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf.fill.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf.fill.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.clr",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.clr.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.clr.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.clr",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.clr.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.clr.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.clr",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.clr.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.clr.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.clr",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.clr.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.clr.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.nc",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.nc.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.nc.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.nc",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.nc.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.nc.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.nc",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.nc.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.nc.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.nc",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.nc.nt1",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.nc.nta",IA64_FORMAT_M6,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.s",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.s.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.s.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.s",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.s.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.s.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.s",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.s.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.s.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.s",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.s.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.s.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.a",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.a.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.a.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.a",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.a.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.a.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.a",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.a.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.a.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.a",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.a.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.a.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.sa",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.sa.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.sa.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.sa",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.sa.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.sa.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.sa",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.sa.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.sa.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.sa",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.sa.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.sa.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf.fill",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf.fill.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf.fill.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.clr",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.clr.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.clr.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.clr",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.clr.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.clr.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.clr",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.clr.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.clr.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.clr",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.clr.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.clr.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.nc",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.nc.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.nc.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.nc",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.nc.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.nc.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.nc",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.nc.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.nc.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.nc",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.nc.nt1",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.nc.nta",IA64_FORMAT_M7,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.s",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.s.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.s.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.s",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.s.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.s.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.s",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.s.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.s.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.s",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.s.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.s.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.a",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.a.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.a.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.a",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.a.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.a.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.a",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.a.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.a.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.a",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.a.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.a.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.sa",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.sa.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.sa.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.sa",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.sa.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.sa.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.sa",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.sa.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.sa.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.sa",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.sa.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.sa.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf.fill",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf.fill.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf.fill.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.clr",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.clr.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.clr.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.clr",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.clr.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.clr.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.clr",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.clr.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.clr.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.clr",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.clr.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.clr.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.nc",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.nc.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfs.c.nc.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.nc",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.nc.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfd.c.nc.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.nc",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.nc.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldf8.c.nc.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.nc",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.nc.nt1",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfe.c.nc.nta",IA64_FORMAT_M8,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stfs",IA64_FORMAT_M9,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stfs.nta",IA64_FORMAT_M9,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stfd",IA64_FORMAT_M9,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stfd.nta",IA64_FORMAT_M9,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stf8",IA64_FORMAT_M9,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stf8.nta",IA64_FORMAT_M9,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stfe",IA64_FORMAT_M9,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stfe.nta",IA64_FORMAT_M9,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stf.spill",IA64_FORMAT_M9,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stf.spill.nta",IA64_FORMAT_M9,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stfs",IA64_FORMAT_M10,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stfs.nta",IA64_FORMAT_M10,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stfd",IA64_FORMAT_M10,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stfd.nta",IA64_FORMAT_M10,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stf8",IA64_FORMAT_M10,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stf8.nta",IA64_FORMAT_M10,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stfe",IA64_FORMAT_M10,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stfe.nta",IA64_FORMAT_M10,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stf.spill",IA64_FORMAT_M10,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"stf.spill.nta",IA64_FORMAT_M10,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.s",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.s.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.s.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.s",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.s.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.s.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.s",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.s.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.s.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.a",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.a.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.a.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.a",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.a.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.a.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.a",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.a.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.a.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.sa",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.sa.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.sa.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.sa",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.sa.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.sa.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.sa",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.sa.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.sa.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.c.clr",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.c.clr.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.c.clr.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.c.clr",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.c.clr.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.c.clr.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.c.clr",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.c.clr.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.c.clr.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.c.nc",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.c.nc.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.c.nc.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.c.nc",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.c.nc.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.c.nc.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.c.nc",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.c.nc.nt1",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.c.nc.nta",IA64_FORMAT_M11,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.s",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.s.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.s.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.s",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.s.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.s.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.s",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.s.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.s.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.a",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.a.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.a.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.a",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.a.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.a.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.a",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.a.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.a.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.sa",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.sa.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.sa.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.sa",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.sa.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.sa.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.sa",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.sa.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.sa.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.c.clr",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.c.clr.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.c.clr.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.c.clr",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.c.clr.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.c.clr.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.c.clr",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.c.clr.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.c.clr.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.c.nc",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.c.nc.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfps.c.nc.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_EIGHT},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.c.nc",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.c.nc.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfpd.c.nc.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.c.nc",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.c.nc.nt1",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ldfp8.c.nc.nta",IA64_FORMAT_M12,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIXTEEN},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.nt1",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.nt2",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.nta",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.excl",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.excl.nt1",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.excl.nt2",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.excl.nta",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.nt1",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.nt2",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.nta",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.excl",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.excl.nt1",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.excl.nt2",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.excl.nta",IA64_FORMAT_M13,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.nt1",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.nt2",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.nta",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.excl",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.excl.nt1",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.excl.nt2",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.excl.nta",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.nt1",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.nt2",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.nta",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.excl",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.excl.nt1",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.excl.nt2",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.excl.nta",IA64_FORMAT_M14,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.nt1",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.nt2",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.nta",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.excl",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.excl.nt1",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.excl.nt2",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.excl.nta",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.nt1",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.nt2",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.nta",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.excl",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.excl.nt1",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.excl.nt2",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"lfetch.fault.excl.nta",IA64_FORMAT_M15,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg1.acq",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg1.acq.nt1",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg1.acq.nta",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg2.acq",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg2.acq.nt1",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg2.acq.nta",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg4.acq",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg4.acq.nt1",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg4.acq.nta",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg8.acq",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg8.acq.nt1",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg8.acq.nta",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg1.rel",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg1.rel.nt1",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg1.rel.nta",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg2.rel",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg2.rel.nt1",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg2.rel.nta",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg4.rel",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg4.rel.nt1",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg4.rel.nta",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg8.rel",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg8.rel.nt1",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cmpxchg8.rel.nta",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_CCV},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xchg1",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xchg1.nt1",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xchg1.nta",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xchg2",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xchg2.nt1",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xchg2.nta",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xchg4",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xchg4.nt1",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xchg4.nta",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xchg8",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xchg8.nt1",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xchg8.nta",IA64_FORMAT_M16,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fetchadd4.acq",IA64_FORMAT_M17,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SEMAPHORE_INC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fetchadd4.acq.nt1",IA64_FORMAT_M17,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SEMAPHORE_INC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fetchadd4.acq.nta",IA64_FORMAT_M17,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SEMAPHORE_INC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fetchadd8.acq",IA64_FORMAT_M17,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SEMAPHORE_INC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fetchadd8.acq.nt1",IA64_FORMAT_M17,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SEMAPHORE_INC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fetchadd8.acq.nta",IA64_FORMAT_M17,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SEMAPHORE_INC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fetchadd4.rel",IA64_FORMAT_M17,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SEMAPHORE_INC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fetchadd4.rel.nt1",IA64_FORMAT_M17,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SEMAPHORE_INC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fetchadd4.rel.nta",IA64_FORMAT_M17,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SEMAPHORE_INC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fetchadd8.rel",IA64_FORMAT_M17,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SEMAPHORE_INC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fetchadd8.rel.nt1",IA64_FORMAT_M17,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SEMAPHORE_INC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fetchadd8.rel.nta",IA64_FORMAT_M17,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MEM},{IA64_OPROLE_SRC,IA64_OPTYPE_SEMAPHORE_INC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"setf.sig",IA64_FORMAT_M18,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"setf.exp",IA64_FORMAT_M18,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"setf.s",IA64_FORMAT_M18,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"setf.d",IA64_FORMAT_M18,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"getf.sig",IA64_FORMAT_M19,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"getf.exp",IA64_FORMAT_M19,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"getf.s",IA64_FORMAT_M19,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"getf.d",IA64_FORMAT_M19,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"chk.s.m",IA64_FORMAT_M20,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"chk.s",IA64_FORMAT_M21,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"chk.a.nc",IA64_FORMAT_M22,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_NUM},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"chk.a.clr",IA64_FORMAT_M22,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_NUM},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"chk.a.nc",IA64_FORMAT_M23,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_FREG_NUM},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"chk.a.clr",IA64_FORMAT_M23,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_FREG_NUM},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"invala",IA64_FORMAT_M24,IA64_TROLE_MEM,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fwb",IA64_FORMAT_M24,IA64_TROLE_MEM,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mf",IA64_FORMAT_M24,IA64_TROLE_MEM,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mf.a",IA64_FORMAT_M24,IA64_TROLE_MEM,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"srlz.d",IA64_FORMAT_M24,IA64_TROLE_MEM,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"srlz.i",IA64_FORMAT_M24,IA64_TROLE_MEM,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"sync.i",IA64_FORMAT_M24,IA64_TROLE_MEM,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"flushrs",IA64_FORMAT_M25,IA64_TROLE_MEM,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"loadrs",IA64_FORMAT_M25,IA64_TROLE_MEM,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"invala.e",IA64_FORMAT_M26,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG_NUM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"invala.e",IA64_FORMAT_M27,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_FREG_NUM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fc",IA64_FORMAT_M28,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ptc.e",IA64_FORMAT_M28,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.m",IA64_FORMAT_M29,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_APP_REG_GRP_LOW},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.m",IA64_FORMAT_M30,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_APP_REG_GRP_LOW},{IA64_OPROLE_SRC,IA64_OPTYPE_SIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov.m",IA64_FORMAT_M31,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_REG_GRP_LOW},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M32,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_CR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M33,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_CR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"alloc",IA64_FORMAT_M34,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_APP_PFS},{IA64_OPROLE_SRC,IA64_OPTYPE_ALLOC_IOL},{IA64_OPROLE_SRC,IA64_OPTYPE_ALLOC_IOL},{IA64_OPROLE_SRC,IA64_OPTYPE_ALLOC_IOL},{IA64_OPROLE_SRC,IA64_OPTYPE_ALLOC_ROT}}, {"mov",IA64_FORMAT_M35,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_PSR_L},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M35,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_PSR_UM},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M36,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_PSR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M36,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_PSR_UM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"break.m",IA64_FORMAT_M37,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"nop.m",IA64_FORMAT_M37,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"probe.r",IA64_FORMAT_M38,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"probe.w",IA64_FORMAT_M38,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"probe.r",IA64_FORMAT_M39,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"probe.w",IA64_FORMAT_M39,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"probe.rw.fault",IA64_FORMAT_M40,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"probe.r.fault",IA64_FORMAT_M40,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"probe.w.fault",IA64_FORMAT_M40,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"itc.d",IA64_FORMAT_M41,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"itc.i",IA64_FORMAT_M41,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M42,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_RR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M42,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_DBR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M42,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IBR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M42,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_PKR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M42,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_PMC},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M42,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_PMD},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M42,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_MSR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"itr.d",IA64_FORMAT_M42,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_DTR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"itr.i",IA64_FORMAT_M42,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_ITR},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M43,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_RR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M43,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_DBR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M43,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IBR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M43,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_PKR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M43,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_PMC},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M43,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_MSR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M43,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_PMD},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"mov",IA64_FORMAT_M43,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_CPUID},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"sum",IA64_FORMAT_M44,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"rum",IA64_FORMAT_M44,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ssm",IA64_FORMAT_M44,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"rsm",IA64_FORMAT_M44,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ptc.l",IA64_FORMAT_M45,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ptc.g",IA64_FORMAT_M45,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ptc.ga",IA64_FORMAT_M45,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ptr.d",IA64_FORMAT_M45,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ptr.i",IA64_FORMAT_M45,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"thash",IA64_FORMAT_M46,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"ttag",IA64_FORMAT_M46,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tpa",IA64_FORMAT_M46,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"tak",IA64_FORMAT_M46,IA64_TROLE_MEM,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"halt",IA64_FORMAT_M1001,IA64_TROLE_MEM,{IA64_OPROLE_SRC,IA64_OPTYPE_IREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.sptk.few",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.sptk.many",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.spnt.few",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.spnt.many",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dptk.few",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dptk.many",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dpnt.few",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dpnt.many",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.sptk.few.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.sptk.many.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.spnt.few.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.spnt.many.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dptk.few.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dptk.many.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dpnt.few.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dpnt.many.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.sptk.few",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.sptk.many",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.spnt.few",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.spnt.many",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.dptk.few",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.dptk.many",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.dpnt.few",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.dpnt.many",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.sptk.few.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.sptk.many.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.spnt.few.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.spnt.many.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.dptk.few.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.dptk.many.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.dpnt.few.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wexit.dpnt.many.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.sptk.few",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.sptk.many",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.spnt.few",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.spnt.many",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.dptk.few",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.dptk.many",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.dpnt.few",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.dpnt.many",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.sptk.few.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.sptk.many.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.spnt.few.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.spnt.many.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.dptk.few.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.dptk.many.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.dpnt.few.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.wtop.dpnt.many.clr",IA64_FORMAT_B1,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.sptk.few",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.sptk.many",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.spnt.few",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.spnt.many",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.dptk.few",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.dptk.many",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.dpnt.few",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.dpnt.many",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.sptk.few.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.sptk.many.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.spnt.few.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.spnt.many.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.dptk.few.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.dptk.many.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.dpnt.few.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cloop.dpnt.many.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.sptk.few",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.sptk.many",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.spnt.few",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.spnt.many",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.dptk.few",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.dptk.many",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.dpnt.few",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.dpnt.many",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.sptk.few.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.sptk.many.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.spnt.few.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.spnt.many.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.dptk.few.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.dptk.many.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.dpnt.few.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cexit.dpnt.many.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.sptk.few",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.sptk.many",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.spnt.few",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.spnt.many",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.dptk.few",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.dptk.many",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.dpnt.few",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.dpnt.many",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.sptk.few.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.sptk.many.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.spnt.few.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.spnt.many.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.dptk.few.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.dptk.many.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.dpnt.few.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ctop.dpnt.many.clr",IA64_FORMAT_B2,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.sptk.few",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.sptk.many",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.spnt.few",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.spnt.many",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dptk.few",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dptk.many",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dpnt.few",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dpnt.many",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.sptk.few.clr",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.sptk.many.clr",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.spnt.few.clr",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.spnt.many.clr",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dptk.few.clr",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dptk.many.clr",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dpnt.few.clr",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dpnt.many.clr",IA64_FORMAT_B3,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.sptk.few",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.sptk.many",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.spnt.few",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.spnt.many",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dptk.few",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dptk.many",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dpnt.few",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dpnt.many",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.sptk.few.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.sptk.many.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.spnt.few.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.spnt.many.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dptk.few.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dptk.many.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dpnt.few.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.cond.dpnt.many.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.sptk.few",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.sptk.many",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.spnt.few",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.spnt.many",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.dptk.few",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.dptk.many",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.dpnt.few",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.dpnt.many",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.sptk.few.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.sptk.many.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.spnt.few.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.spnt.many.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.dptk.few.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.dptk.many.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.dpnt.few.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ia.dpnt.many.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.sptk.few",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.sptk.many",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.spnt.few",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.spnt.many",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.dptk.few",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.dptk.many",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.dpnt.few",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.dpnt.many",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.sptk.few.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.sptk.many.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.spnt.few.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.spnt.many.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.dptk.few.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.dptk.many.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.dpnt.few.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.ret.dpnt.many.clr",IA64_FORMAT_B4,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.sptk.few",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.sptk.many",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.spnt.few",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.spnt.many",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dptk.few",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dptk.many",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dpnt.few",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dpnt.many",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.sptk.few.clr",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.sptk.many.clr",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.spnt.few.clr",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.spnt.many.clr",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dptk.few.clr",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dptk.many.clr",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dpnt.few.clr",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"br.call.dpnt.many.clr",IA64_FORMAT_B5,IA64_TROLE_BR,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.sptk",IA64_FORMAT_B6,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.sptk.imp",IA64_FORMAT_B6,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.loop",IA64_FORMAT_B6,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.loop.imp",IA64_FORMAT_B6,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.dptk",IA64_FORMAT_B6,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.dptk.imp",IA64_FORMAT_B6,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.exit",IA64_FORMAT_B6,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.exit.imp",IA64_FORMAT_B6,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.sptk",IA64_FORMAT_B7,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.sptk.imp",IA64_FORMAT_B7,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.dptk",IA64_FORMAT_B7,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.dptk.imp",IA64_FORMAT_B7,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.ret.sptk",IA64_FORMAT_B7,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.ret.sptk.imp",IA64_FORMAT_B7,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.ret.dptk",IA64_FORMAT_B7,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brp.ret.dptk.imp",IA64_FORMAT_B7,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"cover",IA64_FORMAT_B8,IA64_TROLE_BR,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"clrrrb",IA64_FORMAT_B8,IA64_TROLE_BR,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"clrrrb.pr",IA64_FORMAT_B8,IA64_TROLE_BR,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"rfi",IA64_FORMAT_B8,IA64_TROLE_BR,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"rfi.x",IA64_FORMAT_B8,IA64_TROLE_BR,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"bsw.0",IA64_FORMAT_B8,IA64_TROLE_BR,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"bsw.1",IA64_FORMAT_B8,IA64_TROLE_BR,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"epc",IA64_FORMAT_B8,IA64_TROLE_BR,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"break.b",IA64_FORMAT_B9,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"nop.b",IA64_FORMAT_B9,IA64_TROLE_BR,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fma.s0",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fma.s1",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fma.s2",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fma.s3",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fma.s.s0",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fma.s.s1",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fma.s.s2",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fma.s.s3",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fma.d.s0",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fma.d.s1",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fma.d.s2",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fma.d.s3",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpma.s0",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpma.s1",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpma.s2",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpma.s3",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fms.s0",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fms.s1",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fms.s2",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fms.s3",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fms.s.s0",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fms.s.s1",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fms.s.s2",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fms.s.s3",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fms.d.s0",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fms.d.s1",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fms.d.s2",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fms.d.s3",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpms.s0",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpms.s1",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpms.s2",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpms.s3",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fnma.s0",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fnma.s1",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fnma.s2",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fnma.s3",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fnma.s.s0",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fnma.s.s1",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fnma.s.s2",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fnma.s.s3",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fnma.d.s0",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fnma.d.s1",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fnma.d.s2",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fnma.d.s3",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpnma.s0",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpnma.s1",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpnma.s2",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpnma.s3",IA64_FORMAT_F1,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xma.l",IA64_FORMAT_F2,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xma.h",IA64_FORMAT_F2,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"xma.hu",IA64_FORMAT_F2,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fselect",IA64_FORMAT_F3,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.eq.s0",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.eq.s1",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.eq.s2",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.eq.s3",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.lt.s0",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.lt.s1",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.lt.s2",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.lt.s3",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.le.s0",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.le.s1",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.le.s2",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.le.s3",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.unord.s0",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.unord.s1",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.unord.s2",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.unord.s3",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.eq.unc.s0",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.eq.unc.s1",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.eq.unc.s2",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.eq.unc.s3",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.lt.unc.s0",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.lt.unc.s1",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.lt.unc.s2",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.lt.unc.s3",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.le.unc.s0",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.le.unc.s1",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.le.unc.s2",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.le.unc.s3",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.unord.unc.s0",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.unord.unc.s1",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.unord.unc.s2",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcmp.unord.unc.s3",IA64_FORMAT_F4,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fclass.m",IA64_FORMAT_F5,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FCLASS},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fclass.m.unc",IA64_FORMAT_F5,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FCLASS},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"frcpa.s0",IA64_FORMAT_F6,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"frcpa.s1",IA64_FORMAT_F6,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"frcpa.s2",IA64_FORMAT_F6,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"frcpa.s3",IA64_FORMAT_F6,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fprcpa.s0",IA64_FORMAT_F6,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fprcpa.s1",IA64_FORMAT_F6,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fprcpa.s2",IA64_FORMAT_F6,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fprcpa.s3",IA64_FORMAT_F6,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"frsqrta.s0",IA64_FORMAT_F7,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"frsqrta.s1",IA64_FORMAT_F7,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"frsqrta.s2",IA64_FORMAT_F7,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"frsqrta.s3",IA64_FORMAT_F7,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fprsqrta.s0",IA64_FORMAT_F7,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fprsqrta.s1",IA64_FORMAT_F7,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fprsqrta.s2",IA64_FORMAT_F7,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fprsqrta.s3",IA64_FORMAT_F7,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_DST,IA64_OPTYPE_PREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fmin.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fmin.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fmin.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fmin.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fmax.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fmax.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fmax.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fmax.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"famin.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"famin.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"famin.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"famin.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"famax.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"famax.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"famax.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"famax.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpmin.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpmin.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpmin.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpmin.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpmax.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpmax.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpmax.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpmax.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpamin.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpamin.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpamin.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpamin.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpamax.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpamax.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpamax.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpamax.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.eq.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.eq.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.eq.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.eq.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.lt.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.lt.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.lt.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.lt.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.le.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.le.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.le.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.le.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.unord.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.unord.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.unord.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.unord.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.neq.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.neq.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.neq.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.neq.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.nlt.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.nlt.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.nlt.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.nlt.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.nle.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.nle.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.nle.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.nle.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.ord.s0",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.ord.s1",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.ord.s2",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcmp.ord.s3",IA64_FORMAT_F8,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fmerge.s",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fmerge.ns",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fmerge.se",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fmix.lr",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fmix.r",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fmix.l",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fsxt.r",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fsxt.l",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpack",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fswap",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fswap.nl",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fswap.nr",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fand",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fandcm",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"for",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fxor",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpmerge.s",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpmerge.ns",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpmerge.se",IA64_FORMAT_F9,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fx.s0",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fx.s1",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fx.s2",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fx.s3",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fxu.s0",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fxu.s1",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fxu.s2",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fxu.s3",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fx.trunc.s0",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fx.trunc.s1",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fx.trunc.s2",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fx.trunc.s3",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fxu.trunc.s0",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fxu.trunc.s1",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fxu.trunc.s2",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.fxu.trunc.s3",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fx.s0",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fx.s1",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fx.s2",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fx.s3",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fxu.s0",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fxu.s1",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fxu.s2",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fxu.s3",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fx.trunc.s0",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fx.trunc.s1",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fx.trunc.s2",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fx.trunc.s3",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fxu.trunc.s0",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fxu.trunc.s1",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fxu.trunc.s2",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fpcvt.fxu.trunc.s3",IA64_FORMAT_F10,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fcvt.xf",IA64_FORMAT_F11,IA64_TROLE_FP,{IA64_OPROLE_DST,IA64_OPTYPE_FREG_F2_127},{IA64_OPROLE_SRC,IA64_OPTYPE_FREG},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fsetc.s0",IA64_FORMAT_F12,IA64_TROLE_FP,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fsetc.s1",IA64_FORMAT_F12,IA64_TROLE_FP,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fsetc.s2",IA64_FORMAT_F12,IA64_TROLE_FP,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fsetc.s3",IA64_FORMAT_F12,IA64_TROLE_FP,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fclrf.s0",IA64_FORMAT_F13,IA64_TROLE_FP,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fclrf.s1",IA64_FORMAT_F13,IA64_TROLE_FP,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fclrf.s2",IA64_FORMAT_F13,IA64_TROLE_FP,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fclrf.s3",IA64_FORMAT_F13,IA64_TROLE_FP,{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fchkf.s0",IA64_FORMAT_F14,IA64_TROLE_FP,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fchkf.s1",IA64_FORMAT_F14,IA64_TROLE_FP,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fchkf.s2",IA64_FORMAT_F14,IA64_TROLE_FP,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"fchkf.s3",IA64_FORMAT_F14,IA64_TROLE_FP,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"break.f",IA64_FORMAT_F15,IA64_TROLE_FP,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"nop.f",IA64_FORMAT_F15,IA64_TROLE_FP,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"break.x",IA64_FORMAT_X1,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"nop.x",IA64_FORMAT_X1,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"movl",IA64_FORMAT_X2,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_IREG_R1_127},{IA64_OPROLE_SRC,IA64_OPTYPE_UIMM},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.sptk.few",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.sptk.many",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.spnt.few",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.spnt.many",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.dptk.few",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.dptk.many",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.dpnt.few",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.dpnt.many",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.sptk.few.clr",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.sptk.many.clr",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.spnt.few.clr",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.spnt.many.clr",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.dptk.few.clr",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.dptk.many.clr",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.dpnt.few.clr",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.cond.dpnt.many.clr",IA64_FORMAT_X3,IA64_TROLE_LONG,{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.sptk.few",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.sptk.many",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.spnt.few",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.spnt.many",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.dptk.few",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.dptk.many",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.dpnt.few",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.dpnt.many",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.sptk.few.clr",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.sptk.many.clr",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.spnt.few.clr",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.spnt.many.clr",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.dptk.few.clr",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.dptk.many.clr",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.dpnt.few.clr",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, {"brl.call.dpnt.many.clr",IA64_FORMAT_X4,IA64_TROLE_LONG,{IA64_OPROLE_DST,IA64_OPTYPE_BR},{IA64_OPROLE_SRC,IA64_OPTYPE_SSHIFT_REL},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE},{IA64_OPROLE_NONE,IA64_OPTYPE_NONE}}, }; ht-2.0.22/asm/x86dis.cc0000644000175000017500000012010012127651420011337 00000000000000/* * HT Editor * x86dis.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * Copyright (C) 2005-2009 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "htdebug.h" #include "stream.h" #include "snprintf.h" #include "strtools.h" #include "tools.h" #include "vxd.h" #include "x86dis.h" #define mkscale mkmod #define mkbase mkrm #define rexw(rex) ((rex)&0x08) #define rexr(rex) ((rex)&0x04) #define rexx(rex) ((rex)&0x02) #define rexb(rex) ((rex)&0x01) #define drexdest(drex) ((drex)>>4) #define oc0(drex) (!!((drex)&8)) #define vexw(vex) (!!((vex)&0x80)) #define vexr(vex) (!((vex)&0x80)) #define vexx(vex) (!((vex)&0x40)) #define vexb(vex) (!((vex)&0x20)) #define vexl(vex) (!!((vex)&0x04)) #define vexmmmmm(vex) ((vex)&0x1f) #define vexvvvv(vex) (((~(vex))>>3)&0xf) #define vexpp(vex) ((vex)&0x3) static int modrm16_1[8] = { X86_REG_BX, X86_REG_BX, X86_REG_BP, X86_REG_BP, X86_REG_SI, X86_REG_DI, X86_REG_BP, X86_REG_BX}; static int modrm16_2[8] = { X86_REG_SI, X86_REG_DI, X86_REG_SI, X86_REG_DI, X86_REG_NO, X86_REG_NO, X86_REG_NO, X86_REG_NO}; static int sibscale[4] = {1, 2, 4, 8}; /* * CLASS x86dis */ x86dis::x86dis(X86OpSize aOpsize, X86AddrSize aAddrsize) { opsize = aOpsize; addrsize = aAddrsize; insn.invalid = true; x86_insns = &x86_32_insns; } void x86dis::checkInfo(x86opc_insn *xinsn) { } dis_insn *x86dis::decode(byte *code, int Maxlen, CPU_ADDR Addr) { ocodep = code; codep = ocodep; maxlen = Maxlen; addr = Addr; modrm = -1; sib = -1; drex = -1; special_imm = -1; have_disp = false; memset(&insn, 0, sizeof insn); insn.invalid = false; insn.eopsize = opsize; insn.eaddrsize = addrsize; prefixes(); fixdisp = false; insn.opcode = c; decode_insn(&(*x86_insns)[insn.opcode]); if (insn.invalid) { insn.name = "db"; insn.size = 1; insn.op[0].type = X86_OPTYPE_IMM; insn.op[0].size = 1; insn.op[0].imm = *code; insn.opsizeprefix = X86_PREFIX_NO; insn.lockprefix = X86_PREFIX_NO; insn.repprefix = X86_PREFIX_NO; insn.segprefix = X86_PREFIX_NO; insn.rexprefix = 0; for (int i = 1; i < 5; i++) insn.op[i].type = X86_OPTYPE_EMPTY; } else { insn.size = codep - ocodep; if (fixdisp) { // ip-relativ addressing in PM64 for (int i = 0; i < 2; i++) { if (insn.op[i].type == X86_OPTYPE_MEM && insn.op[i].mem.hasdisp) { insn.op[i].mem.disp += getoffset() + insn.size; } } } } return &insn; } uint x86dis::mkmod(uint modrm) { return modrm>>6 & 0x03; } uint x86dis::mkreg(uint modrm) { return (modrm>>3 & 0x07) | !!rexr(insn.rexprefix) << 3; } uint x86dis::mkindex(uint sib) { return (sib>>3 & 0x07) | !!rexx(insn.rexprefix) << 3; } uint x86dis::mkrm(uint modrm) { return (modrm & 0x07) | !!rexb(insn.rexprefix) << 3; } static bool is_xmm_op(x86dis_insn *insn, char size) { if (insn->opsizeprefix == X86_PREFIX_OPSIZE && (size == SIZE_U || size == SIZE_Z)) { return true; } else { return false; } } void x86dis::decode_modrm(x86_insn_op *op, char size, bool allow_reg, bool allow_mem, bool mmx, bool xmm, bool ymm) { int modrm = getmodrm(); getdisp(); int mod = mkmod(modrm); int rm = mkrm(modrm); if (mod == 3) { /* reg */ if (!allow_reg) { invalidate(); return; } if (xmm || (mmx && is_xmm_op(&insn, size))) { op->type = X86_OPTYPE_XMM; op->xmm = rm; } else if (mmx) { op->type = X86_OPTYPE_MMX; op->mmx = rm; } else if (ymm) { op->type = X86_OPTYPE_YMM; op->xmm = rm; } else { op->type = X86_OPTYPE_REG; op->reg = rm; } op->size = esizeop(size); } else { /* mem */ if (!allow_mem) { invalidate(); return; } op->mem.addrsize = insn.eaddrsize; op->type = X86_OPTYPE_MEM; op->size = esizeop(size); op->mem.floatptr = isfloat(size); op->mem.addrptr = isaddr(size); if (insn.eaddrsize == X86_ADDRSIZE16) { if (mod == 0 && rm == 6) { op->mem.hasdisp = true; op->mem.disp = disp; op->mem.base = X86_REG_NO; op->mem.index = X86_REG_NO; op->mem.scale = 0; } else { op->mem.base = modrm16_1[rm]; op->mem.index = modrm16_2[rm]; op->mem.scale = 1; switch (mod) { case 0: op->mem.hasdisp = false; op->mem.disp = 0; break; case 1: op->mem.hasdisp = true; op->mem.disp = sint64(sint8(disp)); break; case 2: op->mem.hasdisp = true; op->mem.disp = sint64(sint16(disp)); break; } } } else { if (mod == 0 && (rm & 7) == 5) { op->mem.hasdisp = true; op->mem.disp = disp; op->mem.base = X86_REG_NO; op->mem.index = X86_REG_NO; op->mem.scale = 0; } else if ((rm & 7) == 4) { decode_sib(op, mod); } else { op->mem.base = rm; op->mem.index = X86_REG_NO; op->mem.scale = 1; switch (mod) { case 0: op->mem.hasdisp = false; op->mem.disp = 0; break; case 1: op->mem.hasdisp = true; op->mem.disp = sint64(sint8(disp)); break; case 2: op->mem.hasdisp = true; op->mem.disp = sint64(sint32(disp)); break; } } } } } void x86dis::decode_sib(x86_insn_op *op, int mod) { int sib = getsib(); int scale = mkscale(sib); int index = mkindex(sib); int base = mkbase(sib); int sdisp = mod; if ((base & 0x7) == 5 && mod == 0) { base = X86_REG_NO; sdisp = 2; } if (index == 4) { index = X86_REG_NO; } op->mem.base = base; op->mem.index = index; op->mem.scale = sibscale[scale]; switch (sdisp) { case 0: op->mem.hasdisp = false; op->mem.disp = 0; break; case 1: op->mem.hasdisp = true; op->mem.disp = sint64(sint8(disp)); break; case 2: op->mem.hasdisp = true; op->mem.disp = sint64(sint32(disp)); break; } } void x86dis::decode_vex_insn(x86opc_vex_insn *xinsn) { if (xinsn) { byte vex = (insn.vexprefix.w << 7) | (insn.vexprefix.l << 6) | (insn.vexprefix.mmmm << 2) | insn.vexprefix.pp; while (!xinsn->name && xinsn->op[0] == SPECIAL_TYPE_GROUP) { if (xinsn->vex == vex) { getdisp(); int m = mkreg(getmodrm()) & 0x7; xinsn = &x86_group_vex_insns[xinsn->op[1]][m]; if (!xinsn->name) { invalidate(); } else { insn.name = xinsn->name; for (int i = 0; i < 5; i++) { decode_op(&insn.op[i], &x86_op_type[xinsn->op[i]]); } return; } } xinsn++; } while (xinsn->name) { if (xinsn->vex == vex) { insn.name = xinsn->name; for (int i = 0; i < 5; i++) { x86opc_insn_op *op = &x86_op_type[xinsn->op[i]]; switch (op->type) { case TYPE_E: case TYPE_M: case TYPE_W: case TYPE_X: /* get whole modrm/sib/disp stuff first * (otherwise a TYPE_VI immediate might * get fetched fetched before the modrm stuff) */ getdisp(); } } for (int i = 0; i < 5; i++) { decode_op(&insn.op[i], &x86_op_type[xinsn->op[i]]); } return; } xinsn++; } } invalidate(); } void x86dis::decode_insn(x86opc_insn *xinsn) { if (!xinsn->name) { byte specialtype = xinsn->op[0]; byte specialdata = xinsn->op[1]; switch (specialtype) { case SPECIAL_TYPE_INVALID: invalidate(); break; case SPECIAL_TYPE_PREFIX: switch (c) { case 0x0f: if (insn.opcodeclass == X86DIS_OPCODE_CLASS_STD) { insn.opcode = getbyte(); switch (insn.repprefix) { case X86_PREFIX_REPNZ: if (insn.opsizeprefix == X86_PREFIX_OPSIZE) { invalidate(); } else { insn.repprefix = X86_PREFIX_NO; insn.opcodeclass = X86DIS_OPCODE_CLASS_EXT_F2; decode_insn(&x86_insns_ext_f2[insn.opcode]); } break; case X86_PREFIX_REPZ: if (insn.opsizeprefix == X86_PREFIX_OPSIZE) { invalidate(); } else { insn.repprefix = X86_PREFIX_NO; insn.opcodeclass = X86DIS_OPCODE_CLASS_EXT_F3; decode_insn(&x86_insns_ext_f3[insn.opcode]); } break; default: if (insn.opsizeprefix == X86_PREFIX_NO) { insn.opcodeclass = X86DIS_OPCODE_CLASS_EXT; decode_insn(&x86_insns_ext[insn.opcode]); } else { insn.opcodeclass = X86DIS_OPCODE_CLASS_EXT_66; decode_insn(&x86_insns_ext_66[insn.opcode]); } } break; } invalidate(); break; case 0x8f: case 0xc4: case 0xc5: { byte vex = getbyte(); if (c == 0x8f) { if ((vex & 0x38) == 0) { modrm = vex; decode_insn(&x86_pop_group); break; } } else { if (addrsize != X86_ADDRSIZE64 && (vex & 0xc0) != 0xc0) { modrm = vex; decode_insn(c == 0xc4 ? &x86_les : &x86_lds); break; } } if (insn.opsizeprefix != X86_PREFIX_NO || insn.lockprefix != X86_PREFIX_NO || insn.repprefix != X86_PREFIX_NO || insn.rexprefix != 0) { invalidate(); break; } insn.rexprefix = 0x40; insn.rexprefix |= vexr(vex) << 2; if (c == 0xc5) { // 2 byte vex insn.vexprefix.mmmm = 1; insn.vexprefix.w = 0; } else { // 3 byte vex / xop insn.rexprefix |= vexx(vex) << 1; insn.rexprefix |= vexb(vex); insn.vexprefix.mmmm = vexmmmmm(vex); if (c == 0x8f) { if (insn.vexprefix.mmmm > 10) { // insn.vexprefix.mmmm >= 8 is implied invalidate(); break; } } else { if (insn.vexprefix.mmmm == 0 || insn.vexprefix.mmmm > 3) { invalidate(); break; } } vex = getbyte(); insn.vexprefix.w = vexw(vex); } insn.vexprefix.vvvv = vexvvvv(vex); insn.vexprefix.l = vexl(vex); insn.vexprefix.pp = vexpp(vex); if (addrsize != X86_ADDRSIZE64) { insn.rexprefix = 0; } insn.opcode = getbyte(); decode_vex_insn(x86_vex_insns[insn.opcode]); break; } default: invalidate(); break; } break; case SPECIAL_TYPE_OPC_GROUP: { insn.opcodeclass = X86DIS_OPCODE_CLASS_EXT; insn.opcode = getbyte(); decode_insn(&x86_opc_group_insns[specialdata][insn.opcode]); break; } case SPECIAL_TYPE_GROUP: { int m = mkreg(getmodrm()) & 0x7; decode_insn(&x86_group_insns[specialdata][m]); break; } case SPECIAL_TYPE_SGROUP: { int m = getmodrm(); if (mkmod(m) != 3) { m = 8; } else { m = mkrm(m) & 0x7; } decode_insn(&x86_special_group_insns[specialdata][m]); break; } case SPECIAL_TYPE_FGROUP: { int m = getmodrm(); if (mkmod(m) == 3) { x86opc_finsn f = x86_float_group_insns[specialdata][mkreg(m) & 0x7]; /* fprintf(stderr, "special.data=%d, m=%d, mkreg(m)=%d, mkrm(m)=%d\n", special.data, m, mkreg(m), mkrm(m));*/ if (f.group) { decode_insn(&f.group[mkrm(m) & 0x7]); } else if (f.insn.name) { decode_insn(&f.insn); } else invalidate(); } else { decode_insn(&x86_modfloat_group_insns[specialdata][mkreg(m) & 0x7]); } break; } } } else { checkInfo(xinsn); insn.name = xinsn->name; for (int i = 0; i < 4; i++) { decode_op(&insn.op[i], &x86_op_type[xinsn->op[i]]); } } } void x86dis::decode_op(x86_insn_op *op, x86opc_insn_op *xop) { switch (xop->type) { case TYPE_0: return; case TYPE_A: { /* direct address without ModR/M */ op->type = X86_OPTYPE_FARPTR; op->size = esizeop(xop->size); switch (op->size) { case 4: op->farptr.offset = getword(); op->farptr.seg = getword(); break; case 6: op->farptr.offset = getdword(); op->farptr.seg = getword(); break; } break; } case TYPE_C: { /* reg of ModR/M picks control register */ op->type = X86_OPTYPE_CRX; op->size = esizeop(xop->size); op->crx = mkreg(getmodrm()); break; } case TYPE_D: { /* reg of ModR/M picks debug register */ op->type = X86_OPTYPE_DRX; op->size = esizeop(xop->size); op->drx = mkreg(getmodrm()); break; } case TYPE_E: { /* ModR/M (general reg or memory) */ decode_modrm(op, xop->size, (xop->size != SIZE_P), true, false, false, false); break; } case TYPE_F: { /* r/m of ModR/M picks a fpu register */ op->type = X86_OPTYPE_STX; op->size = 10; op->stx = mkrm(getmodrm()); break; } case TYPE_Fx: { /* extra picks a fpu register */ op->type = X86_OPTYPE_STX; op->size = 10; op->stx = xop->extra; break; } case TYPE_G: { /* reg of ModR/M picks general register */ op->type = X86_OPTYPE_REG; op->size = esizeop(xop->size); op->reg = mkreg(getmodrm()); break; } case TYPE_Is: { /* signed immediate */ op->type = X86_OPTYPE_IMM; op->size = esizeop(xop->size); int s = esizeop_ex(xop->size); switch (s) { case 1: op->imm = sint64(sint8(getbyte())); break; case 2: op->imm = sint64(sint16(getword())); break; case 4: op->imm = sint64(sint32(getdword())); break; case 8: op->imm = getqword(); break; } switch (op->size) { case 1: op->imm &= 0xff; break; case 2: op->imm &= 0xffff; break; case 4: op->imm &= 0xffffffff; break; } break; } case TYPE_I: { /* unsigned immediate */ op->type = X86_OPTYPE_IMM; op->size = esizeop(xop->size); int s = esizeop_ex(xop->size); switch (s) { case 1: op->imm = getbyte(); break; case 2: op->imm = getword(); break; case 4: op->imm = sint64(sint32(getdword())); break; case 8: op->imm = getqword(); break; } switch (op->size) { case 1: op->imm &= 0xff; break; case 2: op->imm &= 0xffff; break; case 4: op->imm &= 0xffffffff; break; } break; } case TYPE_Ix: { /* fixed immediate */ op->type = X86_OPTYPE_IMM; op->size = esizeop(xop->size); op->imm = xop->extra; break; } case TYPE_I4: { /* 4 bit immediate (see TYPE_VI, TYPE_YI) */ op->type = X86_OPTYPE_IMM; op->size = 1; op->imm = getspecialimm() & 0xf; break; } case TYPE_J: { /* relative branch offset */ op->type = X86_OPTYPE_IMM; switch (addrsize) { case X86_ADDRSIZE16: op->size = 2; break; case X86_ADDRSIZE32: op->size = 4; break; case X86_ADDRSIZE64: op->size = 8; break; default: {assert(0);} } int s = esizeop(xop->size); sint64 addr = getoffset() + (codep - ocodep); switch (s) { case 1: op->imm = sint8(getbyte()) + addr + 1; break; case 2: op->imm = sint16(getword()) + addr + 2; break; case 4: case 8: op->imm = sint32(getdword()) + addr + 4; break; } if (insn.eopsize == X86_OPSIZE16) { op->imm &= 0xffff; } break; } case TYPE_M: { /* ModR/M (memory only) */ decode_modrm(op, xop->size, false, true, false, false, false); break; } case TYPE_MR: { /* ModR/M (memory only) */ int modrm = getmodrm(); int mod = mkmod(modrm); byte xopsize = xop->size; if (mod == 3) { xopsize = xop->extra; } decode_modrm(op, xopsize, (xopsize != SIZE_P), true, false, false, false); break; } case TYPE_O: { /* direct memory without ModR/M */ op->type = X86_OPTYPE_MEM; op->size = esizeop(xop->size); op->mem.floatptr = isfloat(xop->size); op->mem.addrptr = isaddr(xop->size); op->mem.addrsize = insn.eaddrsize; op->mem.hasdisp = true; switch (insn.eaddrsize) { case X86_ADDRSIZE16: op->mem.disp = getword(); break; case X86_ADDRSIZE32: op->mem.disp = getdword(); break; case X86_ADDRSIZE64: op->mem.disp = getqword(); break; default: {assert(0);} } op->mem.base = X86_REG_NO; op->mem.index = X86_REG_NO; op->mem.scale = 1; break; } case TYPE_P: { /* reg of ModR/M picks MMX register */ if (is_xmm_op(&insn, xop->size)) { op->type = X86_OPTYPE_XMM; op->xmm = mkreg(getmodrm()); } else { op->type = X86_OPTYPE_MMX; op->mmx = mkreg(getmodrm()); } op->size = esizeop(xop->size); break; } case TYPE_PR: { /* rm of ModR/M picks MMX register */ if (mkmod(getmodrm()) == 3) { if (is_xmm_op(&insn, xop->size)) { op->type = X86_OPTYPE_XMM; op->xmm = mkrm(getmodrm()); } else { op->type = X86_OPTYPE_MMX; op->mmx = mkrm(getmodrm()); } op->size = esizeop(xop->size); } else { invalidate(); } break; } case TYPE_Q: { /* ModR/M (MMX reg or memory) */ decode_modrm(op, xop->size, true, true, true, false, false); break; } case TYPE_R: { /* rm of ModR/M picks general register */ if (mkmod(getmodrm()) == 3) { op->type = X86_OPTYPE_REG; op->size = esizeop(xop->size); op->reg = mkrm(getmodrm()); } else { invalidate(); } break; } case TYPE_Rx: { /* extra picks register */ op->type = X86_OPTYPE_REG; op->size = esizeop(xop->size); op->reg = xop->extra | !!rexb(insn.rexprefix) << 3; break; } case TYPE_RXx: { /* extra picks register */ op->type = X86_OPTYPE_REG; op->size = esizeop(xop->size); op->reg = xop->extra; break; } case TYPE_RV: { /* VEX.vvvv picks general register */ op->type = X86_OPTYPE_REG; op->size = esizeop(xop->size); op->reg = insn.vexprefix.vvvv; break; } case TYPE_S: { /* reg of ModR/M picks segment register */ op->type = X86_OPTYPE_SEG; op->size = esizeop(xop->size); op->seg = mkreg(getmodrm()) & 0x7; if (op->seg > 5) invalidate(); break; } case TYPE_Sx: { /* extra picks segment register */ op->type = X86_OPTYPE_SEG; op->size = esizeop(xop->size); op->seg = xop->extra; if (op->seg > 5) invalidate(); break; } case TYPE_V: { /* reg of ModR/M picks XMM register */ op->type = X86_OPTYPE_XMM; op->size = 16; op->xmm = mkreg(getmodrm()); break; } case TYPE_VI: { /* bits 7-4 of imm picks XMM register */ op->type = X86_OPTYPE_XMM; op->size = 16; op->xmm = getspecialimm() >> 4; break; } case TYPE_VV: { /* VEX.vvvv picks XMM register */ op->type = X86_OPTYPE_XMM; op->size = 16; op->xmm = insn.vexprefix.vvvv; break; } case TYPE_Vx: { /* extra picks XMM register */ op->type = X86_OPTYPE_XMM; op->size = 16; op->reg = xop->extra; break; } case TYPE_VR: /* rm of ModR/M picks XMM register */ if (mkmod(getmodrm()) == 3) { op->type = X86_OPTYPE_XMM; op->size = esizeop(xop->size); op->xmm = mkrm(getmodrm()); } else { invalidate(); } break; case TYPE_W: /* ModR/M (XMM reg or memory) */ decode_modrm(op, xop->size, true, true, false, true, false); break; case TYPE_VD: op->type = X86_OPTYPE_XMM; op->size = 16; op->reg = drexdest(getdrex()); break; case TYPE_VS: if (xop->info && oc0(getdrex())) { invalidate(); } if (oc0(getdrex()) ^ xop->extra) { decode_modrm(op, xop->size, true, true, false, true, false); } else { op->type = X86_OPTYPE_XMM; op->size = 16; op->xmm = mkreg(getmodrm()); } break; case TYPE_Y: /* reg of ModR/M picks XMM register */ op->type = X86_OPTYPE_YMM; op->size = 32; op->ymm = mkreg(getmodrm()); break; case TYPE_YV: { /* VEX.vvvv picks YMM register */ op->type = X86_OPTYPE_YMM; op->size = 32; op->ymm = insn.vexprefix.vvvv; break; } case TYPE_YI: /* bits 7-4 of imm picks YMM register */ op->type = X86_OPTYPE_YMM; op->size = 32; op->ymm = getspecialimm() >> 4; break; case TYPE_X: /* ModR/M (XMM reg or memory) */ decode_modrm(op, xop->size, true, true, false, false, true); break; } } dis_insn *x86dis::duplicateInsn(dis_insn *disasm_insn) { x86dis_insn *insn = ht_malloc(sizeof (x86dis_insn)); *insn = *(x86dis_insn *)disasm_insn; return insn; } int x86dis::esizeop(uint c) { switch (c) { case SIZE_B: return 1; case SIZE_W: return 2; case SIZE_D: case SIZE_S: return 4; case SIZE_Q: case SIZE_L: return 8; case SIZE_O: return 16; case SIZE_Y: return 32; case SIZE_T: return 10; case SIZE_V: case SIZE_BV: case SIZE_VV: switch (insn.eopsize) { case X86_OPSIZE16: return 2; case X86_OPSIZE32: return 4; case X86_OPSIZE64: return 8; default: {assert(0);} } case SIZE_R: if (insn.eopsize == X86_OPSIZE64) return 8; else return 4; case SIZE_U: if (insn.opsizeprefix == X86_PREFIX_OPSIZE) return 16; else return 8; case SIZE_Z: if (insn.opsizeprefix == X86_PREFIX_OPSIZE) return 8; else return 4; case SIZE_P: if (insn.eopsize == X86_OPSIZE16) return 4; else return 6; } return 0; } int x86dis::esizeop_ex(uint c) { switch (c) { case SIZE_BV: return 1; case SIZE_VV: switch (insn.eopsize) { case X86_OPSIZE16: return 2; case X86_OPSIZE32: case X86_OPSIZE64: return 4; default: {assert(0);} } } return esizeop(c); } byte x86dis::getbyte() { if (codep-ocodep+1 <= maxlen) { return *(codep++); } else { invalidate(); return 0; } } uint16 x86dis::getword() { if (codep-ocodep+2 <= maxlen) { uint16 w; w = codep[0] | (codep[1]<<8); codep += 2; return w; } else { invalidate(); return 0; } } uint32 x86dis::getdword() { if (codep-ocodep+4 <= maxlen) { uint32 w; w = codep[0] | codep[1]<<8 | codep[2]<<16 | codep[3]<<24; codep += 4; return w; } else { invalidate(); return 0; } } uint64 x86dis::getqword() { if (codep-ocodep+8 <= maxlen) { uint64 w; w = uint64(codep[0])<< 0 | uint64(codep[1])<< 8 | uint64(codep[2])<<16 | uint64(codep[3])<<24 | uint64(codep[4])<<32 | uint64(codep[5])<<40 | uint64(codep[6])<<48 | uint64(codep[7])<<56; codep += 8; return w; } else { invalidate(); return 0; } } void x86dis::getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align) { min_length = 1; max_length = 15; min_look_ahead = 120; // 1/2/3/4/5/6/8/10/12/15 avg_look_ahead = 24; // 1/2/3/4/6/8/12/24 addr_align = 1; } uint64 x86dis::getoffset() { return addr.addr32.offset; } void x86dis::filloffset(CPU_ADDR &addr, uint64 offset) { addr.addr32.offset = offset; } uint32 x86dis::getdisp() { if (have_disp) return disp; disp = 0; have_disp = true; int modrm = getmodrm(); int mod = mkmod(modrm); if (mod == 3) return 0; int rm = mkrm(modrm); if (insn.eaddrsize == X86_ADDRSIZE16) { if (mod == 0 && rm == 6) { disp = getword(); } else { switch (mod) { case 1: disp = getbyte(); break; case 2: disp = getword(); break; } } } else { rm &= 7; if (mod == 0 && rm == 5) { mod = 2; } else if (rm == 4) { int base = mkbase(getsib()) & 7; if (mod == 0 && base == 5) { mod = 2; } } switch (mod) { case 1: disp = getbyte(); break; case 2: disp = getdword(); break; } } return disp; } int x86dis::getmodrm() { if (modrm == -1) modrm = getbyte(); return modrm; } int x86dis::getdrex() { if (drex == -1) { getmodrm(); int modrm = getmodrm(); int mod = mkmod(modrm); int rm = mkrm(modrm); if (mod != 3 && (rm & 7) == 4) { getsib(); } drex = getbyte(); if (addrsize != X86_ADDRSIZE64) { drex &= 0x78; } insn.rexprefix = drex & 0x7; } return drex; } int x86dis::getspecialimm() { if (special_imm == -1) special_imm = getbyte(); return special_imm; } const char *x86dis::getName() { return "x86/Disassembler"; } int x86dis::getsib() { if (sib == -1) sib = getbyte(); return sib; } byte x86dis::getSize(dis_insn *disasm_insn) { return ((x86dis_insn*)disasm_insn)->size; } void x86dis::invalidate() { insn.invalid = true; } bool x86dis::isfloat(char c) { switch (c) { case SIZE_S: case SIZE_L: case SIZE_T: return true; } return false; } bool x86dis::isaddr(char c) { switch (c) { case SIZE_P: return true; } return false; } void x86dis::load(ObjectStream &f) { Disassembler::load(f); opsize = (X86OpSize)GETX_INT32(f, "opsize"); addrsize = (X86AddrSize)GETX_INT32(f, "addrsize"); x86_insns = &x86_32_insns; } ObjectID x86dis::getObjectID() const { return ATOM_DISASM_X86; } void x86dis::prefixes() { insn.opsizeprefix = X86_PREFIX_NO; insn.lockprefix = X86_PREFIX_NO; insn.repprefix = X86_PREFIX_NO; insn.segprefix = X86_PREFIX_NO; insn.rexprefix = 0; while (codep - ocodep < 15) { c = getbyte(); switch (c) { case 0x26: insn.segprefix = X86_PREFIX_ES; continue; case 0x2e: insn.segprefix = X86_PREFIX_CS; continue; case 0x36: insn.segprefix = X86_PREFIX_SS; continue; case 0x3e: insn.segprefix = X86_PREFIX_DS; continue; case 0x64: insn.segprefix = X86_PREFIX_FS; continue; case 0x65: insn.segprefix = X86_PREFIX_GS; continue; case 0x66: insn.opsizeprefix = X86_PREFIX_OPSIZE; insn.eopsize = (opsize == X86_OPSIZE16) ? X86_OPSIZE32 : X86_OPSIZE16; continue; case 0x67: insn.eaddrsize = (addrsize == X86_ADDRSIZE16) ? X86_ADDRSIZE32 : X86_ADDRSIZE16; continue; case 0xf0: insn.lockprefix = X86_PREFIX_LOCK; continue; case 0xf2: insn.repprefix = X86_PREFIX_REPNZ; continue; case 0xf3: insn.repprefix = X86_PREFIX_REPZ; continue; } /* no prefix found -> exit loop */ break; } } static const char *regs(x86dis_insn *insn, int mode, int nr) { if (insn->rexprefix) { return x86_64regs[mode][nr]; } else { return x86_regs[mode][nr]; } } void x86dis::str_op(char *opstr, int *opstrlen, x86dis_insn *insn, x86_insn_op *op, bool explicit_params) { const char *cs_default = get_cs(e_cs_default); const char *cs_number = get_cs(e_cs_number); const char *cs_symbol = get_cs(e_cs_symbol); *opstrlen=0; switch (op->type) { case X86_OPTYPE_IMM: { CPU_ADDR a; filloffset(a, op->imm); int slen; char *s=(addr_sym_func) ? addr_sym_func(a, &slen, addr_sym_func_context) : NULL; if (s) { memcpy(opstr, s, slen); opstr[slen] = 0; *opstrlen = slen; } else { char *g = opstr; strcpy(g, cs_number); g += strlen(cs_number); switch (op->size) { case 1: hexd(&g, 2, options, op->imm); break; case 2: hexd(&g, 4, options, op->imm); break; case 4: hexd(&g, 8, options, op->imm); break; case 8: hexq(&g, 16, options, op->imm); break; } strcpy(g, cs_default); g += strlen(cs_default); } break; } case X86_OPTYPE_REG: { int j = -1; switch (op->size) { case 1: j = 0; break; case 2: j = 1; break; case 4: j = 2; break; case 8: j = 3; break; default: {assert(0);} } if (!insn->rexprefix) { sprintf(opstr, x86_regs[j][op->reg]); } else { sprintf(opstr, x86_64regs[j][op->reg]); } break; } case X86_OPTYPE_SEG: if (x86_segs[op->seg]) { sprintf(opstr, x86_segs[op->seg]); } break; case X86_OPTYPE_CRX: sprintf(opstr, "cr%d", op->crx); break; case X86_OPTYPE_DRX: sprintf(opstr, "dr%d", op->drx); break; case X86_OPTYPE_STX: if (op->stx) { sprintf(opstr, "st%s(%s%d%s)%s", cs_symbol, cs_number, op->stx, cs_symbol, cs_default); } else { strcpy(opstr, "st"); } break; case X86_OPTYPE_MMX: sprintf(opstr, "mm%d", op->mmx); break; case X86_OPTYPE_XMM: sprintf(opstr, "xmm%d", op->xmm); break; case X86_OPTYPE_YMM: sprintf(opstr, "ymm%d", op->ymm); break; case X86_OPTYPE_MEM: { char *d=opstr; if (explicit_params) { if (op->mem.floatptr) { switch (op->size) { case 4: d += sprintf(d, "single ptr "); break; case 8: d += sprintf(d, "double ptr "); break; case 10: d += sprintf(d, "extended ptr "); break; } } else if (op->mem.addrptr) { switch (op->size) { case 4: case 6: d += sprintf(d, "far ptr "); break; } } else { switch (op->size) { case 1: d += sprintf(d, "byte ptr "); break; case 2: d += sprintf(d, "word ptr "); break; case 4: d += sprintf(d, "dword ptr "); break; case 6: d += sprintf(d, "pword ptr "); break; case 8: d += sprintf(d, "qword ptr "); break; case 16: d += sprintf(d, "oword ptr "); break; case 32: d += sprintf(d, "ymmword ptr "); break; } } } if (insn->segprefix != X86_PREFIX_NO) { d += sprintf(d, "%s%s:%s", x86_segs[insn->segprefix], cs_symbol, cs_default); } strcpy(d, cs_symbol); d += strlen(cs_symbol); *(d++)='['; strcpy(d, cs_default); d += strlen(cs_default); bool first = true; int reg = 0; switch (insn->eaddrsize) { case X86_ADDRSIZE16: reg = 1; break; case X86_ADDRSIZE32: reg = 2; break; case X86_ADDRSIZE64: reg = 3; break; default: {assert(0);} } bool optimize_addr = options & X86DIS_STYLE_OPTIMIZE_ADDR; if (optimize_addr && op->mem.base != X86_REG_NO && op->mem.base == op->mem.index) { d += sprintf(d, "%s%s*%s%d%s", regs(insn, reg, op->mem.index), cs_symbol, cs_number, op->mem.scale+1, cs_default); first = false; } else { if (op->mem.base != X86_REG_NO) { if (op->mem.base == X86_REG_IP) { d += sprintf(d, "%s", x86_ipregs[reg]); } else { d += sprintf(d, "%s", regs(insn, reg, op->mem.base)); } first = false; } if (op->mem.index != X86_REG_NO) { if (!first) { strcpy(d, cs_symbol); d += strlen(cs_symbol); *(d++) = '+'; strcpy(d, cs_default); d += strlen(cs_default); } if (op->mem.scale == 1) { d += sprintf(d, "%s", regs(insn, reg, op->mem.index)); } else { d += sprintf(d, "%s%s*%s%d%s", regs(insn, reg, op->mem.index), cs_symbol, cs_number, op->mem.scale, cs_default); } first = false; } } if ((!optimize_addr && op->mem.hasdisp) || (optimize_addr && op->mem.disp) || first) { CPU_ADDR a; filloffset(a, op->mem.disp); int slen; char *s=(addr_sym_func) ? addr_sym_func(a, &slen, addr_sym_func_context) : 0; if (s) { if (!first) { strcpy(d, cs_symbol); d += strlen(cs_symbol); *(d++)='+'; strcpy(d, cs_default); d += strlen(cs_default); } memcpy(d, s, slen); d+=slen; *opstrlen=d-opstr; } else { uint32 q; switch (op->mem.addrsize) { case X86_ADDRSIZE16: q = sint32(sint16(op->mem.disp)); if (!first) { strcpy(d, cs_symbol); d += strlen(cs_symbol); if (op->mem.disp & 0x8000) { *(d++) = '-'; q = -q; } else *(d++) = '+'; } strcpy(d, cs_number); d += strlen(cs_number); hexd(&d, 4, options, q); strcpy(d, cs_default); d += strlen(cs_default); break; case X86_ADDRSIZE32: case X86_ADDRSIZE64: q = op->mem.disp; if (!first) { strcpy(d, cs_symbol); d += strlen(cs_symbol); if (op->mem.disp & 0x80000000) { *(d++)='-'; q=-q; } else *(d++)='+'; } strcpy(d, cs_number); d += strlen(cs_number); hexd(&d, 8, options, q); strcpy(d, cs_default); d += strlen(cs_default); break; } } } strcpy(d, cs_symbol); d += strlen(cs_symbol); *(d++)=']'; strcpy(d, cs_default); d += strlen(cs_default); if (*opstrlen) *opstrlen += strlen(cs_symbol) + 1 + strlen(cs_default); *d=0; break; } case X86_OPTYPE_FARPTR: { CPU_ADDR a; a.addr32.seg = op->farptr.seg; a.addr32.offset = op->farptr.offset; int slen; char *s=(addr_sym_func) ? addr_sym_func(a, &slen, addr_sym_func_context) : 0; if (s) { memcpy(opstr, s, slen); opstr[slen]=0; *opstrlen=slen; } else { char *g=opstr; hexd(&g, 4, options, op->farptr.seg); strcpy(g, cs_symbol); g += strlen(cs_symbol); *(g++)=':'; strcpy(g, cs_default); g += strlen(cs_default); switch (op->size) { case 4: hexd(&g, 4, options, op->farptr.offset); break; case 6: hexd(&g, 8, options, op->farptr.offset); break; } } break; } default: opstr[0]=0; } } void x86dis::str_format(char **str, const char **format, char *p, char *n, char *op[5], int oplen[5], char stopchar, int print) { const char *cs_default = get_cs(e_cs_default); const char *cs_symbol = get_cs(e_cs_symbol); const char *f = *format; char *s = *str; while (*f) { if (*f == stopchar) break; switch (*f) { case '\t': if (print) do *(s++)=' '; while ((s-insnstr) % DIS_STYLE_TABSIZE); break; case DISASM_STRF_VAR: f++; if (print) { char *t = NULL; int tl = 0; switch (*f) { case DISASM_STRF_PREFIX: t=p; break; case DISASM_STRF_NAME: t=n; break; case DISASM_STRF_FIRST: t=op[0]; tl=oplen[0]; break; case DISASM_STRF_SECOND: t=op[1]; tl=oplen[1]; break; case DISASM_STRF_THIRD: t=op[2]; tl=oplen[2]; break; case DISASM_STRF_FORTH: t=op[3]; tl=oplen[3]; break; case DISASM_STRF_FIFTH: t=op[4]; tl=oplen[4]; break; } if (tl) { memcpy(s, t, tl); s+=tl; *s=0; } else { strcpy(s, t); s += strlen(s); } } break; case DISASM_STRF_COND: { char *t = NULL; f++; switch (*f) { case DISASM_STRF_PREFIX: t=p; break; case DISASM_STRF_NAME: t=n; break; case DISASM_STRF_FIRST: t=op[0]; break; case DISASM_STRF_SECOND: t=op[1]; break; case DISASM_STRF_THIRD: t=op[2]; break; case DISASM_STRF_FORTH: t=op[3]; break; case DISASM_STRF_FIFTH: t=op[4]; break; } f += 2; if (t && t[0]) { str_format(&s, &f, p, n, op, oplen, *(f-1), 1); } else { str_format(&s, &f, p, n, op, oplen, *(f-1), 0); } break; } default: if (print) { bool x = (strchr(",.-=+-*/[]()", *f) != NULL) && *f; if (x) { strcpy(s, cs_symbol); s += strlen(cs_symbol); } *(s++) = *f; if (x) { strcpy(s, cs_default); s += strlen(cs_default); } } } f++; } *s=0; *format=f; *str=s; } const char *x86dis::str(dis_insn *disasm_insn, int options) { return strf(disasm_insn, options, DISASM_STRF_DEFAULT_FORMAT); } static void pickname(char *result, const char *name, int n) { const char *s = name; do { name = s+1; s = strchr(name, '|'); if (!s) { strcpy(result, name); return; } } while (n--); ht_strlcpy(result, name, s-name+1); } const char *x86dis::strf(dis_insn *disasm_insn, int opt, const char *format) { x86dis_insn *insn = (x86dis_insn*)disasm_insn; char prefix[64]; char *p = prefix; options = opt; *p = 0; if (insn->lockprefix == X86_PREFIX_LOCK) p += sprintf(p, "lock "); if (insn->repprefix == X86_PREFIX_REPZ) { p += sprintf(p, "repz "); } else if (insn->repprefix == X86_PREFIX_REPNZ) { p += sprintf(p, "repnz "); } if (p != prefix && p[-1] == ' ') { p--; *p = 0; } const char *iname = insn->name; bool explicit_params = (options & X86DIS_STYLE_EXPLICIT_MEMSIZE) || iname[0] == '~'; char ops[5][512]; /* FIXME: possible buffer overflow ! */ char *op[5]; int oplen[5]; if (options & DIS_STYLE_HIGHLIGHT) enable_highlighting(); for (int i=0; i < 5; i++) { op[i] = (char*)&ops[i]; str_op(op[i], &oplen[i], insn, &insn->op[i], explicit_params); } char *s=insnstr; if (iname[0] == '~') iname++; char n[32]; switch (iname[0]) { case '|': pickname(n, iname, 0); break; case '?': case '&': switch (insn->eopsize) { case X86_OPSIZE16: pickname(n, iname, 0); break; case X86_OPSIZE32: pickname(n, iname, 1); break; case X86_OPSIZE64: pickname(n, iname, 2); break; default: {assert(0);} } break; case '*': switch (insn->eaddrsize) { case X86_ADDRSIZE16: pickname(n, iname, 0); break; case X86_ADDRSIZE32: pickname(n, iname, 1); break; case X86_ADDRSIZE64: pickname(n, iname, 2); break; default: {assert(0);} } break; default: strcpy(n, iname); } str_format(&s, &format, prefix, n, op, oplen, 0, 1); disable_highlighting(); return insnstr; } void x86dis::store(ObjectStream &f) const { PUT_INT32X(f, opsize); PUT_INT32X(f, addrsize); } bool x86dis::validInsn(dis_insn *disasm_insn) { return !((x86dis_insn *)disasm_insn)->invalid; } /* * CLASS x86_64dis */ x86opc_insn (*x86_64dis::x86_64_insns)[256]; x86_64dis::x86_64dis() : x86dis(X86_OPSIZE32, X86_ADDRSIZE64) { prepInsns(); } void x86_64dis::prepInsns() { if (!x86_64_insns) { x86_64_insns = ht_malloc(sizeof *x86_64_insns); memcpy(x86_64_insns, x86_32_insns, sizeof x86_32_insns); int i = 0; while (x86_64_insn_patches[i].opc != -1) { (*x86_64_insns)[x86_64_insn_patches[i].opc] = x86_64_insn_patches[i].insn; i++; } } x86_insns = x86_64_insns; } void x86_64dis::decode_modrm(x86_insn_op *op, char size, bool allow_reg, bool allow_mem, bool mmx, bool xmm, bool ymm) { int modrm = getmodrm(); getdisp(); int mod = mkmod(modrm); int rm = mkrm(modrm); if (mod == 3) { if (!allow_reg) { invalidate(); return; } if (xmm || (mmx && is_xmm_op(&insn, size))) { op->type = X86_OPTYPE_XMM; op->xmm = rm; } else if (mmx) { op->type = X86_OPTYPE_MMX; op->mmx = rm & 0x7; // no rex-extension } else if (ymm) { op->type = X86_OPTYPE_YMM; op->mmx = rm; } else { op->type = X86_OPTYPE_REG; op->reg = rm; } op->size = esizeop(size); } else { if (!allow_mem) { invalidate(); return; } op->mem.addrsize = insn.eaddrsize; op->type = X86_OPTYPE_MEM; op->size = esizeop(size); op->mem.floatptr = isfloat(size); op->mem.addrptr = isaddr(size); if (mod == 0 && (rm & 0x7) == 5) { op->mem.hasdisp = true; op->mem.disp = sint32(disp); fixdisp = true; // op->mem.base = X86_REG_IP; op->mem.base = X86_REG_NO; op->mem.index = X86_REG_NO; op->mem.scale = 0; } else if ((rm & 0x7) == 4) { decode_sib(op, mod); } else { op->mem.base = rm; op->mem.index = X86_REG_NO; op->mem.scale = 1; switch (mod) { case 0: op->mem.hasdisp = false; op->mem.disp = 0; break; case 1: op->mem.hasdisp = true; op->mem.disp = sint64(sint8(disp)); break; case 2: op->mem.hasdisp = true; op->mem.disp = sint64(sint32(disp)); break; } } } } void x86_64dis::prefixes() { insn.opsizeprefix = X86_PREFIX_NO; insn.lockprefix = X86_PREFIX_NO; insn.repprefix = X86_PREFIX_NO; insn.segprefix = X86_PREFIX_NO; insn.rexprefix = 0; while (codep - ocodep < 15) { c = getbyte(); switch (c) { case 0x26: case 0x2e: case 0x36: case 0x3e: continue; // cs, ds, es, ss prefix ignored case 0x64: insn.segprefix = X86_PREFIX_FS; continue; case 0x65: insn.segprefix = X86_PREFIX_GS; continue; case 0x66: insn.opsizeprefix = X86_PREFIX_OPSIZE; insn.eopsize = X86_OPSIZE16; continue; case 0x67: insn.eaddrsize = X86_ADDRSIZE32; continue; case 0xf0: insn.lockprefix = X86_PREFIX_LOCK; continue; case 0xf2: insn.repprefix = X86_PREFIX_REPNZ; continue; case 0xf3: insn.repprefix = X86_PREFIX_REPZ; continue; } if ((c & 0xf0) == 0x40) { insn.rexprefix = c; if (rexw(c)) { insn.eopsize = X86_OPSIZE64; } c = getbyte(); } break; } } void x86_64dis::checkInfo(x86opc_insn *xinsn) { if (insn.opsizeprefix != X86_PREFIX_OPSIZE && (x86_op_type[xinsn->op[0]].info & INFO_DEFAULT_64)) { // instruction defaults to 64 bit opsize insn.eopsize = X86_OPSIZE64; } } uint64 x86_64dis::getoffset() { return addr.flat64.addr; } void x86_64dis::filloffset(CPU_ADDR &addr, uint64 offset) { addr.flat64.addr = offset; } void x86_64dis::load(ObjectStream &f) { x86dis::load(f); prepInsns(); } ObjectID x86_64dis::getObjectID() const { return ATOM_DISASM_X86_64; } /* * CLASS x86dis_vxd */ x86dis_vxd::x86dis_vxd(X86OpSize opsize, X86AddrSize addrsize) : x86dis(opsize, addrsize) { } dis_insn *x86dis_vxd::decode(byte *code, int maxlen, CPU_ADDR addr) { if ((maxlen >= 6) && (code[0] == 0xcd) && (code[1] == 0x20)) { insn.name = "VxDCall"; insn.size = 6; vxd_t *v = find_vxd(vxds, *(uint16*)(code+4)); if (v) { insn.op[0].type = X86_OPTYPE_USER; insn.op[0].user[0].i = *(uint16*)(code+4); insn.op[0].user[1].p = (void*)v->name; const char *vs = NULL; if (v->services) vs = find_vxd_service(v->services, *(uint16*)(code+2) & 0x7fff); if (vs) { insn.op[1].type = X86_OPTYPE_USER; insn.op[1].user[0].i = *(uint16*)(code+2); insn.op[1].user[1].p = (void*)vs; } else { insn.op[1].type = X86_OPTYPE_IMM; insn.op[1].size = 2; insn.op[1].imm = *(uint16*)(code+2); } } else { insn.op[0].type = X86_OPTYPE_IMM; insn.op[0].size = 2; insn.op[0].imm = *(uint16*)(code+4); insn.op[1].type = X86_OPTYPE_IMM; insn.op[1].size = 2; insn.op[1].imm = *(uint16*)(code+2); } insn.op[2].type = X86_OPTYPE_EMPTY; insn.lockprefix = X86_PREFIX_NO; insn.repprefix = X86_PREFIX_NO; insn.segprefix = X86_PREFIX_NO; return &insn; } return x86dis::decode(code, maxlen, addr); } ObjectID x86dis_vxd::getObjectID() const { return ATOM_DISASM_X86_VXD; } void x86dis_vxd::str_op(char *opstr, int *opstrlen, x86dis_insn *insn, x86_insn_op *op, bool explicit_params) { if (op->type == X86_OPTYPE_USER) { *opstrlen = 0; strcpy(opstr, (char*)op->user[1].p); } else { x86dis::str_op(opstr, opstrlen, insn, op, explicit_params); } } ht-2.0.22/asm/x86asm.h0000644000175000001440000001257011055251400011202 00000000000000/* * The HT Editor * x86asm.h * * Copyright (C) 1999-2002 Stefan Weyergraf * Copyright (C) 2005-2007 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __X86ASM_H__ #define __X86ASM_H__ #include "asm.h" #include "x86opc.h" #include "x86dis.h" struct x86asm_insn { char lockprefix; char repprefix; char segprefix; char opsizeprefix; char n[32]; char *name; x86_insn_op op[5]; }; struct x86addrcoding { int reg1; int reg2; int dispsize; }; /* * CLASS x86asm */ #define X86ASM_NULL 0x00000000 #define X86ASM_ALLOW_AMBIGUOUS 0x00000001 /* IF SET: allow "mov [0], 1" ELSE: deny "mov [0], 1" (ambiguous) */ class x86asm: public Assembler { public: X86OpSize opsize; X86AddrSize addrsize; protected: int esizes[5]; int modrmv; int sibv; int vexvvvv; uint64 disp; int dispsize; int disppos; uint64 imm; int imm2; int immsize; uint8 rexprefix; // 0 = no, 0x80 = forbid, 0x40 = yes int drexdest; int drexoc0; uint64 address; bool ambiguous; bool namefound; static x86opc_insn (*x86_32a_insns)[256]; x86opc_insn (*x86_insns)[256]; void prepInsns(); virtual x86dis *createCompatibleDisassembler(); void delete_nonsense(CPU_ADDR addr); bool delete_nonsense_insn(asm_code *c, x86dis *dis, CPU_ADDR addr); void emitdisp(uint64 disp, int size); void emitfarptr(uint32 s, uint32 o, bool big); void emitimm(uint64 imm, int size); void emitmodrm(int modrm); void emitmodrm_mod(int mod); void emitmodrm_reg(int reg); void emitmodrm_rm(int rm); void emitsib_base(int base); void emitsib_index(int index); void emitsib_scale(int scale); bool encode_insn(x86asm_insn *insn, x86opc_insn *opcode, int opcodeb, int additional_opcode, int prefix, int eopsize, int eaddrsize); bool encode_vex_insn(x86asm_insn *insn, x86opc_vex_insn *opcode, int opcodeb, int additional_opcode, int opsize, int addrsize); bool encode_modrm(x86_insn_op *op, char size, bool allow_reg, bool allow_mem, int eopsize, int eaddrsize); bool encode_modrm_v(const x86addrcoding (*modrmc)[3][8], x86_insn_op *op, int mindispsize, int *mod, int *rm, int *dispsize); bool encode_op(x86_insn_op *op, x86opc_insn_op *xop, int *esize, int eopsize, int eaddrsize); bool encode_sib_v(x86_insn_op *op, int mindispsize, int *ss, int *index, int *base, int *mod, int *dispsize, int *disp); int esizeop(uint c, int size); int esizeop_ex(uint c, int size); char flsz2hsz(int size); const char *immlsz2hsz(int size, int opsize); const char *lsz2hsz(int size, int opsize); int match_allops(x86asm_insn *insn, byte *xop, int maxops, int opsize, int addrsize); void match_fopcodes(x86asm_insn *insn); void match_opcode(x86opc_insn *opcode, x86asm_insn *insn, int prefix, byte opcodebyte, int additional_opcode, int def_match); void match_vex_opcode(x86opc_vex_insn *opcode, x86asm_insn *insn, byte opcodebyte, int additional_opcode); int match_opcode_name(const char *input_name, const char *opcodelist_name, int def_match); int match_opcode_final(x86opc_insn *opcode, x86asm_insn *insn, int prefix, byte opcodebyte, int additional_opcode, int opsize, int addrsize, int match); int match_vex_opcode_final(x86opc_vex_insn *opcode, x86asm_insn *insn, byte opcodebyte, int additional_opcode, int opsize, int addrsize); void match_opcodes(x86opc_insn *opcodes, x86asm_insn *insn, int prefix, int def_match); void match_vex_opcodes(x86asm_insn *insn); bool match_size(x86_insn_op *op, x86opc_insn_op *xop, int opsize); int match_type(x86_insn_op *op, x86opc_insn_op *xop, int addrsize); bool opfarptr(x86_insn_op *op, const char *xop); bool opimm(x86_insn_op *op, const char *xop); bool opplugimm(x86_insn_op *op, const char *xop); bool opmem(x86asm_insn *insn, x86_insn_op *op, const char *xop); virtual bool opreg(x86_insn_op *op, const char *xop); bool opmmx(x86_insn_op *op, const char *xop); virtual bool opxmm(x86_insn_op *op, const char *xop); virtual bool opymm(x86_insn_op *op, const char *xop); bool opseg(x86_insn_op *op, const char *xop); bool opspecialregs(x86_insn_op *op, const char *xop); int simmsize(uint64 imm, int immsize); void splitstr(const char *s, char *name, int size, char *op[5], int opsize); void tok(const char **s, char *res, int reslen, const char *sep); public: x86asm(X86OpSize opsize, X86AddrSize addrsize); virtual asm_insn *alloc_insn(); virtual asm_code *encode(asm_insn *asm_insn, int options, CPU_ADDR cur_address); virtual const char *get_name(); virtual bool translate_str(asm_insn *asm_insn, const char *s); }; class x86_64asm: public x86asm { static x86opc_insn (*x86_64_insns)[256]; public: x86_64asm(); virtual bool opreg(x86_insn_op *op, const char *xop); virtual bool opxmm(x86_insn_op *op, const char *xop); virtual bool opymm(x86_insn_op *op, const char *xop); void prepInsns(); protected: virtual x86dis *createCompatibleDisassembler(); }; #endif /* __X86ASM_H__ */ ht-2.0.22/asm/javaopc.cc0000644000175000001440000001174710615342402011646 00000000000000/* * HT Editor * javaopc.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "javaopc.h" #include #define A JOPC_TYPE_ATYPE | JOPC_SIZE_SMALL #define B JOPC_TYPE_CHAR | JOPC_SIZE_SMALL #define U JOPC_TYPE_BYTE | JOPC_SIZE_SMALL #define S JOPC_TYPE_SHORT | JOPC_SIZE_SMALL #define Sw JOPC_TYPE_SIMM | JOPC_SIZE_VAR #define Cs JOPC_TYPE_CONST | JOPC_SIZE_SMALL #define Cw JOPC_TYPE_CONST | JOPC_SIZE_WIDE #define O JOPC_TYPE_LOCAL | JOPC_SIZE_VAR #define Ls JOPC_TYPE_LABEL | JOPC_SIZE_SMALL #define Lw JOPC_TYPE_LABEL | JOPC_SIZE_WIDE javaopc_insn java_insns[256] = { // 0x0 - 0xf {"nop"}, {"aconst_null"}, {"iconst_m1"}, {"iconst_0"}, {"iconst_1"}, {"iconst_2"}, {"iconst_3"}, {"iconst_4"}, {"iconst_5"}, {"lconst_0"}, {"lconst_1"}, {"fconst_0"}, {"fconst_1"}, {"fconst_2"}, {"dconst_0"}, {"dconst_1"}, // 0x10-0x1f {"bipush", {B}}, {"sipush", {S}}, {"ldc", {Cs}}, {"ldc_w", {Cw}}, {"ldc2_w", {Cw}}, {"iload", {O}}, {"lload", {O}}, {"fload", {O}}, {"dload", {O}}, {"aload", {O}}, {"iload_0"}, {"iload_1"}, {"iload_2"}, {"iload_3"}, {"lload_0"}, {"lload_1"}, // 0x20-0x2f {"lload_2"}, {"lload_3"}, {"fload_0"}, {"fload_1"}, {"fload_2"}, {"fload_3"}, {"dload_0"}, {"dload_1"}, {"dload_2"}, {"dload_3"}, {"aload_0"}, {"aload_1"}, {"aload_2"}, {"aload_3"}, {"iaload"}, {"laload"}, // 0x30-0x3f {"faload"}, {"daload"}, {"aaload"}, {"baload"}, {"caload"}, {"saload"}, {"istore", {O}}, {"lstore", {O}}, {"fstore", {O}}, {"dstore", {O}}, {"astore", {O}}, {"istore_0"}, {"istore_1"}, {"istore_2"}, {"istore_3"}, {"lstore_0"}, // 0x40-0x4f {"lstore_1"}, {"lstore_2"}, {"lstore_3"}, {"fstore_0"}, {"fstore_1"}, {"fstore_2"}, {"fstore_3"}, {"dstore_0"}, {"dstore_1"}, {"dstore_2"}, {"dstore_3"}, {"astore_0"}, {"astore_1"}, {"astore_2"}, {"astore_3"}, {"iastore"}, // 0x50-0x5f {"lastore"}, {"fastore"}, {"dastore"}, {"aastore"}, {"bastore"}, {"castore"}, {"sastore"}, {"pop"}, {"pop2"}, {"dup"}, {"dup_x1"}, {"dup_x2"}, {"dup2"}, {"dup2_x1"}, {"dup2_x2"}, {"swap"}, // 0x60-0x6f {"iadd"}, {"ladd"}, {"fadd"}, {"dadd"}, {"isub"}, {"lsub"}, {"fsub"}, {"dsub"}, {"imul"}, {"lmul"}, {"fmul"}, {"dmul"}, {"idiv"}, {"ldiv"}, {"fdiv"}, {"ddiv"}, // 0x70-0x7f {"irem"}, {"lrem"}, {"frem"}, {"drem"}, {"ineg"}, {"lneg"}, {"fneg"}, {"dneg"}, {"ishl"}, {"lshl"}, {"ishr"}, {"lshr"}, {"iushr"}, {"lushr"}, {"iand"}, {"land"}, // 0x80-0x8f {"ior"}, {"lor"}, {"ixor"}, {"lxor"}, {"iinc", {O, Sw}}, {"i2l"}, {"i2f"}, {"i2d"}, {"l2i"}, {"l2f"}, {"l2d"}, {"f2i"}, {"f2l"}, {"f2d"}, {"d2i"}, {"d2l"}, // 0x90-0x9f {"d2f"}, {"i2b"}, {"i2c"}, {"i2s"}, {"lcmp"}, {"fcmpl"}, {"fcmpg"}, {"dcmpl"}, {"dcmpg"}, {"ifeq", {Ls}}, {"ifne", {Ls}}, {"iflt", {Ls}}, {"ifge", {Ls}}, {"ifgt", {Ls}}, {"ifle", {Ls}}, {"if_icmpeq", {Ls}}, // 0xa0-0xaf {"if_icmpne", {Ls}}, {"if_icmplt", {Ls}}, {"if_icmpge", {Ls}}, {"if_icmpgt", {Ls}}, {"if_icmple", {Ls}}, {"if_acmpeq", {Ls}}, {"if_acmpne", {Ls}}, {"goto", {Ls}}, {"jsr", {Ls}}, {"ret", {O}}, {"tableswitch"}, {"lookupswitch"}, {"ireturn"}, {"lreturn"}, {"freturn"}, {"dreturn"}, // 0xb0-0xbf {"areturn"}, {"return"}, {"getstatic", {Cw}}, {"putstatic", {Cw}}, {"getfield", {Cw}}, {"putfield", {Cw}}, {"invokevirtual", {Cw}}, {"invokespecial", {Cw}}, {"invokestatic", {Cw}}, {"invokeinterface", {Cw, B}}, {"xxxunusedxxx"}, {"new", {Cw}}, {"newarray", {A}}, {"anewarray", {Cw}}, {"arraylength"}, {"athrow"}, // 0xc0-0xcf {"checkcast", {Cw}}, {"instanceof", {Cw}}, {"monitorenter"}, {"monitorexit"}, {"wide"}, {"multianewarray", {Cw, B}}, //? {"ifnull", {Ls}}, {"ifnonnull", {Ls}}, {"goto_w", {Lw}}, {"jsr_w", {Lw}}, {"breakpoint"}, {"ldc_quick"}, {"ldc_w_quick"}, {"ldc2_w_quick"}, {"getfield_quick"}, {"putfield_quick"}, // 0xd0-0xdf {"getfield2_quick"}, {"putfield2_quick"}, {"getstatic_quick"}, {"putstatic_quick"}, {"getstatic2_quick"}, {"putstatic2_quick"}, {"invokevirtual_quick"}, {"invokenonvirtual_quick"}, {"invokesuper_quick"}, {"invokestatic_quick"}, {"invokeinterface_quick"}, {"invokevirtualobject_quick"}, {NULL}, {"new_quick"}, {"anewarray_quick"}, {"multianewarray_quick"}, // 0xe0-0xef // e0-e3 {"checkcast_quick"}, {"instanceof_quick"}, {"invokevirtual_quick_w"}, {"getfield_quick_w"}, // e4-e7 {"putfield_quick_w"}, {NULL}, {NULL}, {NULL}, // e8-eb {NULL}, {NULL}, {NULL}, {NULL}, // ec-ef {NULL}, {NULL}, {NULL}, {NULL}, // f0-f3 {NULL}, {NULL}, {NULL}, {NULL}, // f4-f7 {NULL}, {NULL}, {NULL}, {NULL}, // f8-fb {NULL}, {NULL}, {NULL}, {NULL}, // fc-ff {NULL}, {NULL}, {"impdep1"}, {"impdep2"} }; ht-2.0.22/asm/ia64opc.h0000644000175000001440000017577510615342402011346 00000000000000/* * HT Editor * ia64opc.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef IA64OPC_H #define IA64OPC_H #include "io/types.h" #define IA64_SLOT_INVALID 0x00 #define IA64_SLOT_M_UNIT 0x01 #define IA64_SLOT_I_UNIT 0x02 #define IA64_SLOT_L_UNIT 0x03 #define IA64_SLOT_X_UNIT 0x04 #define IA64_SLOT_F_UNIT 0x05 #define IA64_SLOT_B_UNIT 0x06 #define IA64_INST_ROLE_INT 0x00 #define IA64_INST_ROLE_MEM 0x10 #define IA64_INST_ROLE_FP 0x20 #define IA64_INST_ROLE_BR 0x30 #define IA64_INST_ROLE_LONG 0x40 #define IA64_INST_ROLE_COUNT 5 enum IA64EnumOpcode1 { IA64_OPCODE_INST_NONE = 0, IA64_OPCODE_ILLOP = IA64_OPCODE_INST_NONE, IA64_OPCODE_IGNOP, IA64_OPCODE_ADD_R1_R2_R3, IA64_OPCODE_ADD_R1_R2_R3_1, IA64_OPCODE_SUB_R1_R2_R3, IA64_OPCODE_SUB_R1_R2_R3_1, IA64_OPCODE_ADDP4_R1_R2_R3, IA64_OPCODE_AND_R1_R2_R3, IA64_OPCODE_ANDCM_R1_R2_R3, IA64_OPCODE_OR_R1_R2_R3, IA64_OPCODE_XOR_R1_R2_R3, IA64_OPCODE_SHLADD_R1_R2_COUNT2_R3, IA64_OPCODE_SHLADDP4_R1_R2_COUNT2_R3, IA64_OPCODE_SUB_R1_IMM8_R3, IA64_OPCODE_AND_R1_IMM8_R3, IA64_OPCODE_ANDCM_R1_IMM8_R3, IA64_OPCODE_OR_R1_IMM8_R3, IA64_OPCODE_XOR_R1_IMM8_R3, IA64_OPCODE_ADDS_R1_IMM14_R3, IA64_OPCODE_ADDP4_R1_IMM14_R3, IA64_OPCODE_ADDL_R1_IMM22_R3, IA64_OPCODE_CMP_LT_P1_P2_R2_R3, IA64_OPCODE_CMP_LTU_P1_P2_R2_R3, IA64_OPCODE_CMP_EQ_P1_P2_R2_R3, IA64_OPCODE_CMP_LT_UNC_P1_P2_R2_R3, IA64_OPCODE_CMP_LTU_UNC_P1_P2_R2_R3, IA64_OPCODE_CMP_EQ_UNC_P1_P2_R2_R3, IA64_OPCODE_CMP_EQ_AND_P1_P2_R2_R3, IA64_OPCODE_CMP_EQ_OR_P1_P2_R2_R3, IA64_OPCODE_CMP_EQ_OR_ANDCM_P1_P2_R2_R3, IA64_OPCODE_CMP_NE_AND_P1_P2_R2_R3, IA64_OPCODE_CMP_NE_OR_P1_P2_R2_R3, IA64_OPCODE_CMP_NE_OR_ANDCM_P1_P2_R2_R3, IA64_OPCODE_CMP4_LT_P1_P2_R2_R3, IA64_OPCODE_CMP4_LTU_P1_P2_R2_R3, IA64_OPCODE_CMP4_EQ_P1_P2_R2_R3, IA64_OPCODE_CMP4_LT_UNC_P1_P2_R2_R3, IA64_OPCODE_CMP4_LTU_UNC_P1_P2_R2_R3, IA64_OPCODE_CMP4_EQ_UNC_P1_P2_R2_R3, IA64_OPCODE_CMP4_EQ_AND_P1_P2_R2_R3, IA64_OPCODE_CMP4_EQ_OR_P1_P2_R2_R3, IA64_OPCODE_CMP4_EQ_OR_ANDCM_P1_P2_R2_R3, IA64_OPCODE_CMP4_NE_AND_P1_P2_R2_R3, IA64_OPCODE_CMP4_NE_OR_P1_P2_R2_R3, IA64_OPCODE_CMP4_NE_OR_ANDCM_P1_P2_R2_R3, IA64_OPCODE_CMP_GT_AND_P1_P2_R0_R3, IA64_OPCODE_CMP_GT_OR_P1_P2_R0_R3, IA64_OPCODE_CMP_GT_OR_ANDCM_P1_P2_R0_R3, IA64_OPCODE_CMP_LE_AND_P1_P2_R0_R3, IA64_OPCODE_CMP_LE_OR_P1_P2_R0_R3, IA64_OPCODE_CMP_LE_OR_ANDCM_P1_P2_R0_R3, IA64_OPCODE_CMP_GE_AND_P1_P2_R0_R3, IA64_OPCODE_CMP_GE_OR_P1_P2_R0_R3, IA64_OPCODE_CMP_GE_OR_ANDCM_P1_P2_R0_R3, IA64_OPCODE_CMP_LT_AND_P1_P2_R0_R3, IA64_OPCODE_CMP_LT_OR_P1_P2_R0_R3, IA64_OPCODE_CMP_LT_OR_ANDCM_P1_P2_R0_R3, IA64_OPCODE_CMP4_GT_AND_P1_P2_R0_R3, IA64_OPCODE_CMP4_GT_OR_P1_P2_R0_R3, IA64_OPCODE_CMP4_GT_OR_ANDCM_P1_P2_R0_R3, IA64_OPCODE_CMP4_LE_AND_P1_P2_R0_R3, IA64_OPCODE_CMP4_LE_OR_P1_P2_R0_R3, IA64_OPCODE_CMP4_LE_OR_ANDCM_P1_P2_R0_R3, IA64_OPCODE_CMP4_GE_AND_P1_P2_R0_R3, IA64_OPCODE_CMP4_GE_OR_P1_P2_R0_R3, IA64_OPCODE_CMP4_GE_OR_ANDCM_P1_P2_R0_R3, IA64_OPCODE_CMP4_LT_AND_P1_P2_R0_R3, IA64_OPCODE_CMP4_LT_OR_P1_P2_R0_R3, IA64_OPCODE_CMP4_LT_OR_ANDCM_P1_P2_R0_R3, IA64_OPCODE_CMP_LT_P1_P2_IMM8_R3, IA64_OPCODE_CMP_LTU_P1_P2_IMM8_R3, IA64_OPCODE_CMP_EQ_P1_P2_IMM8_R3, IA64_OPCODE_CMP_LT_UNC_P1_P2_IMM8_R3, IA64_OPCODE_CMP_LTU_UNC_P1_P2_IMM8_R3, IA64_OPCODE_CMP_EQ_UNC_P1_P2_IMM8_R3, IA64_OPCODE_CMP_EQ_AND_P1_P2_IMM8_R3, IA64_OPCODE_CMP_EQ_OR_P1_P2_IMM8_R3, IA64_OPCODE_CMP_EQ_OR_ANDCM_P1_P2_IMM8_R3, IA64_OPCODE_CMP_NE_AND_P1_P2_IMM8_R3, IA64_OPCODE_CMP_NE_OR_P1_P2_IMM8_R3, IA64_OPCODE_CMP_NE_OR_ANDCM_P1_P2_IMM8_R3, IA64_OPCODE_CMP4_LT_P1_P2_IMM8_R3, IA64_OPCODE_CMP4_LTU_P1_P2_IMM8_R3, IA64_OPCODE_CMP4_EQ_P1_P2_IMM8_R3, IA64_OPCODE_CMP4_LT_UNC_P1_P2_IMM8_R3, IA64_OPCODE_CMP4_LTU_UNC_P1_P2_IMM8_R3, IA64_OPCODE_CMP4_EQ_UNC_P1_P2_IMM8_R3, IA64_OPCODE_CMP4_EQ_AND_P1_P2_IMM8_R3, IA64_OPCODE_CMP4_EQ_OR_P1_P2_IMM8_R3, IA64_OPCODE_CMP4_EQ_OR_ANDCM_P1_P2_IMM8_R3, IA64_OPCODE_CMP4_NE_AND_P1_P2_IMM8_R3, IA64_OPCODE_CMP4_NE_OR_P1_P2_IMM8_R3, IA64_OPCODE_CMP4_NE_OR_ANDCM_P1_P2_IMM8_R3, IA64_OPCODE_PADD1_R1_R2_R3, IA64_OPCODE_PADD2_R1_R2_R3, IA64_OPCODE_PADD4_R1_R2_R3, IA64_OPCODE_PADD1_SSS_R1_R2_R3, IA64_OPCODE_PADD2_SSS_R1_R2_R3, IA64_OPCODE_PADD1_UUU_R1_R2_R3, IA64_OPCODE_PADD2_UUU_R1_R2_R3, IA64_OPCODE_PADD1_UUS_R1_R2_R3, IA64_OPCODE_PADD2_UUS_R1_R2_R3, IA64_OPCODE_PSUB1_R1_R2_R3, IA64_OPCODE_PSUB2_R1_R2_R3, IA64_OPCODE_PSUB4_R1_R2_R3, IA64_OPCODE_PSUB1_SSS_R1_R2_R3, IA64_OPCODE_PSUB2_SSS_R1_R2_R3, IA64_OPCODE_PSUB1_UUU_R1_R2_R3, IA64_OPCODE_PSUB2_UUU_R1_R2_R3, IA64_OPCODE_PSUB1_UUS_R1_R2_R3, IA64_OPCODE_PSUB2_UUS_R1_R2_R3, IA64_OPCODE_PAVG1_R1_R2_R3, IA64_OPCODE_PAVG2_R1_R2_R3, IA64_OPCODE_PAVG1_RAZ_R1_R2_R3, IA64_OPCODE_PAVG2_RAZ_R1_R2_R3, IA64_OPCODE_PAVGSUB1_R1_R2_R3, IA64_OPCODE_PAVGSUB2_R1_R2_R3, IA64_OPCODE_PCMP1_EQ_R1_R2_R3, IA64_OPCODE_PCMP2_EQ_R1_R2_R3, IA64_OPCODE_PCMP4_EQ_R1_R2_R3, IA64_OPCODE_PCMP1_GT_R1_R2_R3, IA64_OPCODE_PCMP2_GT_R1_R2_R3, IA64_OPCODE_PCMP4_GT_R1_R2_R3, IA64_OPCODE_PSHLADD2_R1_R2_COUNT2_R3, IA64_OPCODE_PSHRADD2_R1_R2_COUNT2_R3, IA64_OPCODE_PMPYSHR2_R1_R2_R3_COUNT2, IA64_OPCODE_PMPYSHR2_U_R1_R2_R3_COUNT2, IA64_OPCODE_PMPY2_R_R1_R2_R3, IA64_OPCODE_PMPY2_L_R1_R2_R3, IA64_OPCODE_MIX1_R_R1_R2_R3, IA64_OPCODE_MIX2_R_R1_R2_R3, IA64_OPCODE_MIX4_R_R1_R2_R3, IA64_OPCODE_MIX1_L_R1_R2_R3, IA64_OPCODE_MIX2_L_R1_R2_R3, IA64_OPCODE_MIX4_L_R1_R2_R3, IA64_OPCODE_PACK2_USS_R1_R2_R3, IA64_OPCODE_PACK2_SSS_R1_R2_R3, IA64_OPCODE_PACK4_SSS_R1_R2_R3, IA64_OPCODE_UNPACK1_H_R1_R2_R3, IA64_OPCODE_UNPACK2_H_R1_R2_R3, IA64_OPCODE_UNPACK4_H_R1_R2_R3, IA64_OPCODE_UNPACK1_L_R1_R2_R3, IA64_OPCODE_UNPACK2_L_R1_R2_R3, IA64_OPCODE_UNPACK4_L_R1_R2_R3, IA64_OPCODE_PMIN1_U_R1_R2_R3, IA64_OPCODE_PMAX1_U_R1_R2_R3, IA64_OPCODE_PMIN2_R1_R2_R3, IA64_OPCODE_PMAX2_R1_R2_R3, IA64_OPCODE_PSAD1_R1_R2_R3, IA64_OPCODE_MUX1_R1_R2_MBTYPE4, IA64_OPCODE_MUX2_R1_R2_MHTYPE8, IA64_OPCODE_PSHR2_R1_R3_R2, IA64_OPCODE_PSHR4_R1_R3_R2, IA64_OPCODE_SHR_R1_R3_R2, IA64_OPCODE_PSHR2_U_R1_R3_R2, IA64_OPCODE_PSHR4_U_R1_R3_R2, IA64_OPCODE_SHR_U_R1_R3_R2, IA64_OPCODE_PSHR2_R1_R3_COUNT5, IA64_OPCODE_PSHR4_R1_R3_COUNT5, IA64_OPCODE_PSHR2_U_R1_R3_COUNT5, IA64_OPCODE_PSHR4_U_R1_R3_COUNT5, IA64_OPCODE_PSHL2_R1_R2_R3, IA64_OPCODE_PSHL4_R1_R2_R3, IA64_OPCODE_SHL_R1_R2_R3, IA64_OPCODE_PSHL2_R1_R2_COUNT5, IA64_OPCODE_PSHL4_R1_R2_COUNT5, IA64_OPCODE_POPCNT_R1_R3, IA64_OPCODE_SHRP_R1_R2_R3_COUNT6, IA64_OPCODE_EXTR_U_R1_R3_POS6_LEN6, IA64_OPCODE_EXTR_R1_R3_POS6_LEN6, IA64_OPCODE_DEP_Z_R1_R2_POS6_LEN6, IA64_OPCODE_DEP_Z_R1_IMM8_POS6_LEN6, IA64_OPCODE_DEP_R1_IMM1_R3_POS6_LEN6, IA64_OPCODE_DEP_R1_R2_R3_POS6_LEN4, IA64_OPCODE_TBIT_Z_P1_P2_R3_POS6, IA64_OPCODE_TBIT_Z_UNC_P1_P2_R3_POS6, IA64_OPCODE_TBIT_Z_AND_P1_P2_R3_POS6, IA64_OPCODE_TBIT_NZ_AND_P1_P2_R3_POS6, IA64_OPCODE_TBIT_Z_OR_P1_P2_R3_POS6, IA64_OPCODE_TBIT_NZ_OR_P1_P2_R3_POS6, IA64_OPCODE_TBIT_Z_OR_ANDCM_P1_P2_R3_POS6, IA64_OPCODE_TBIT_NZ_OR_ANDCM_P1_P2_R3_POS6, IA64_OPCODE_TNAT_Z_P1_P2_R3, IA64_OPCODE_TNAT_Z_UNC_P1_P2_R3, IA64_OPCODE_TNAT_Z_AND_P1_P2_R3, IA64_OPCODE_TNAT_NZ_AND_P1_P2_R3, IA64_OPCODE_TNAT_Z_OR_P1_P2_R3, IA64_OPCODE_TNAT_NZ_OR_P1_P2_R3, IA64_OPCODE_TNAT_Z_OR_ANDCM_P1_P2_R3, IA64_OPCODE_TNAT_NZ_OR_ANDCM_P1_P2_R3, IA64_OPCODE_BREAK_I_IMM21, IA64_OPCODE_NOP_I_IMM21, IA64_OPCODE_CHK_S_I_R2_TARGET25, IA64_OPCODE_MOV_SPTK_B1_R2_TAG13, IA64_OPCODE_MOV_SPTK_IMP_B1_R2_TAG13, IA64_OPCODE_MOV_B1_R2_TAG13, IA64_OPCODE_MOV_IMP_B1_R2_TAG13, IA64_OPCODE_MOV_DPTK_B1_R2_TAG13, IA64_OPCODE_MOV_DPTK_IMP_B1_R2_TAG13, IA64_OPCODE_MOV_RET_SPTK_B1_R2_TAG13, IA64_OPCODE_MOV_RET_SPTK_IMP_B1_R2_TAG13, IA64_OPCODE_MOV_RET_B1_R2_TAG13, IA64_OPCODE_MOV_RET_IMP_B1_R2_TAG13, IA64_OPCODE_MOV_RET_DPTK_B1_R2_TAG13, IA64_OPCODE_MOV_RET_DPTK_IMP_B1_R2_TAG13, IA64_OPCODE_MOV_R1_B2, IA64_OPCODE_MOV_PR_R2_MASK17, IA64_OPCODE_MOV_PR_ROT_IMM44, IA64_OPCODE_MOV_R1_IP, IA64_OPCODE_MOV_R1_PR, IA64_OPCODE_MOV_I_AR3_R2, IA64_OPCODE_MOV_I_AR3_IMM8, IA64_OPCODE_MOV_I_R1_AR3, IA64_OPCODE_ZXT1_R1_R3, IA64_OPCODE_ZXT2_R1_R3, IA64_OPCODE_ZXT4_R1_R3, IA64_OPCODE_SXT1_R1_R3, IA64_OPCODE_SXT2_R1_R3, IA64_OPCODE_SXT4_R1_R3, IA64_OPCODE_CZX1_L_R1_R3, IA64_OPCODE_CZX2_L_R1_R3, IA64_OPCODE_CZX1_R_R1_R3, IA64_OPCODE_CZX2_R_R1_R3, IA64_OPCODE_LD1_R1_R3, IA64_OPCODE_LD1_NT1_R1_R3, IA64_OPCODE_LD1_NTA_R1_R3, IA64_OPCODE_LD2_R1_R3, IA64_OPCODE_LD2_NT1_R1_R3, IA64_OPCODE_LD2_NTA_R1_R3, IA64_OPCODE_LD4_R1_R3, IA64_OPCODE_LD4_NT1_R1_R3, IA64_OPCODE_LD4_NTA_R1_R3, IA64_OPCODE_LD8_R1_R3, IA64_OPCODE_LD8_NT1_R1_R3, IA64_OPCODE_LD8_NTA_R1_R3, IA64_OPCODE_LD1_S_R1_R3, IA64_OPCODE_LD1_S_NT1_R1_R3, IA64_OPCODE_LD1_S_NTA_R1_R3, IA64_OPCODE_LD2_S_R1_R3, IA64_OPCODE_LD2_S_NT1_R1_R3, IA64_OPCODE_LD2_S_NTA_R1_R3, IA64_OPCODE_LD4_S_R1_R3, IA64_OPCODE_LD4_S_NT1_R1_R3, IA64_OPCODE_LD4_S_NTA_R1_R3, IA64_OPCODE_LD8_S_R1_R3, IA64_OPCODE_LD8_S_NT1_R1_R3, IA64_OPCODE_LD8_S_NTA_R1_R3, IA64_OPCODE_LD1_A_R1_R3, IA64_OPCODE_LD1_A_NT1_R1_R3, IA64_OPCODE_LD1_A_NTA_R1_R3, IA64_OPCODE_LD2_A_R1_R3, IA64_OPCODE_LD2_A_NT1_R1_R3, IA64_OPCODE_LD2_A_NTA_R1_R3, IA64_OPCODE_LD4_A_R1_R3, IA64_OPCODE_LD4_A_NT1_R1_R3, IA64_OPCODE_LD4_A_NTA_R1_R3, IA64_OPCODE_LD8_A_R1_R3, IA64_OPCODE_LD8_A_NT1_R1_R3, IA64_OPCODE_LD8_A_NTA_R1_R3, IA64_OPCODE_LD1_SA_R1_R3, IA64_OPCODE_LD1_SA_NT1_R1_R3, IA64_OPCODE_LD1_SA_NTA_R1_R3, IA64_OPCODE_LD2_SA_R1_R3, IA64_OPCODE_LD2_SA_NT1_R1_R3, IA64_OPCODE_LD2_SA_NTA_R1_R3, IA64_OPCODE_LD4_SA_R1_R3, IA64_OPCODE_LD4_SA_NT1_R1_R3, IA64_OPCODE_LD4_SA_NTA_R1_R3, IA64_OPCODE_LD8_SA_R1_R3, IA64_OPCODE_LD8_SA_NT1_R1_R3, IA64_OPCODE_LD8_SA_NTA_R1_R3, IA64_OPCODE_LD1_BIAS_R1_R3, IA64_OPCODE_LD1_BIAS_NT1_R1_R3, IA64_OPCODE_LD1_BIAS_NTA_R1_R3, IA64_OPCODE_LD2_BIAS_R1_R3, IA64_OPCODE_LD2_BIAS_NT1_R1_R3, IA64_OPCODE_LD2_BIAS_NTA_R1_R3, IA64_OPCODE_LD4_BIAS_R1_R3, IA64_OPCODE_LD4_BIAS_NT1_R1_R3, IA64_OPCODE_LD4_BIAS_NTA_R1_R3, IA64_OPCODE_LD8_BIAS_R1_R3, IA64_OPCODE_LD8_BIAS_NT1_R1_R3, IA64_OPCODE_LD8_BIAS_NTA_R1_R3, IA64_OPCODE_LD1_ACQ_R1_R3, IA64_OPCODE_LD1_ACQ_NT1_R1_R3, IA64_OPCODE_LD1_ACQ_NTA_R1_R3, IA64_OPCODE_LD2_ACQ_R1_R3, IA64_OPCODE_LD2_ACQ_NT1_R1_R3, IA64_OPCODE_LD2_ACQ_NTA_R1_R3, IA64_OPCODE_LD4_ACQ_R1_R3, IA64_OPCODE_LD4_ACQ_NT1_R1_R3, IA64_OPCODE_LD4_ACQ_NTA_R1_R3, IA64_OPCODE_LD8_ACQ_R1_R3, IA64_OPCODE_LD8_ACQ_NT1_R1_R3, IA64_OPCODE_LD8_ACQ_NTA_R1_R3, IA64_OPCODE_LD8_FILL_R1_R3, IA64_OPCODE_LD8_FILL_NT1_R1_R3, IA64_OPCODE_LD8_FILL_NTA_R1_R3, IA64_OPCODE_LD1_C_CLR_R1_R3, IA64_OPCODE_LD1_C_CLR_NT1_R1_R3, IA64_OPCODE_LD1_C_CLR_NTA_R1_R3, IA64_OPCODE_LD2_C_CLR_R1_R3, IA64_OPCODE_LD2_C_CLR_NT1_R1_R3, IA64_OPCODE_LD2_C_CLR_NTA_R1_R3, IA64_OPCODE_LD4_C_CLR_R1_R3, IA64_OPCODE_LD4_C_CLR_NT1_R1_R3, IA64_OPCODE_LD4_C_CLR_NTA_R1_R3, IA64_OPCODE_LD8_C_CLR_R1_R3, IA64_OPCODE_LD8_C_CLR_NT1_R1_R3, IA64_OPCODE_LD8_C_CLR_NTA_R1_R3, IA64_OPCODE_LD1_C_NC_R1_R3, IA64_OPCODE_LD1_C_NC_NT1_R1_R3, IA64_OPCODE_LD1_C_NC_NTA_R1_R3, IA64_OPCODE_LD2_C_NC_R1_R3, IA64_OPCODE_LD2_C_NC_NT1_R1_R3, IA64_OPCODE_LD2_C_NC_NTA_R1_R3, IA64_OPCODE_LD4_C_NC_R1_R3, IA64_OPCODE_LD4_C_NC_NT1_R1_R3, IA64_OPCODE_LD4_C_NC_NTA_R1_R3, IA64_OPCODE_LD8_C_NC_R1_R3, IA64_OPCODE_LD8_C_NC_NT1_R1_R3, IA64_OPCODE_LD8_C_NC_NTA_R1_R3, IA64_OPCODE_LD1_C_CLR_ACQ_R1_R3, IA64_OPCODE_LD1_C_CLR_ACQ_NT1_R1_R3, IA64_OPCODE_LD1_C_CLR_ACQ_NTA_R1_R3, IA64_OPCODE_LD2_C_CLR_ACQ_R1_R3, IA64_OPCODE_LD2_C_CLR_ACQ_NT1_R1_R3, IA64_OPCODE_LD2_C_CLR_ACQ_NTA_R1_R3, IA64_OPCODE_LD4_C_CLR_ACQ_R1_R3, IA64_OPCODE_LD4_C_CLR_ACQ_NT1_R1_R3, IA64_OPCODE_LD4_C_CLR_ACQ_NTA_R1_R3, IA64_OPCODE_LD8_C_CLR_ACQ_R1_R3, IA64_OPCODE_LD8_C_CLR_ACQ_NT1_R1_R3, IA64_OPCODE_LD8_C_CLR_ACQ_NTA_R1_R3, IA64_OPCODE_LD1_R1_R3_R2, IA64_OPCODE_LD1_NT1_R1_R3_R2, IA64_OPCODE_LD1_NTA_R1_R3_R2, IA64_OPCODE_LD2_R1_R3_R2, IA64_OPCODE_LD2_NT1_R1_R3_R2, IA64_OPCODE_LD2_NTA_R1_R3_R2, IA64_OPCODE_LD4_R1_R3_R2, IA64_OPCODE_LD4_NT1_R1_R3_R2, IA64_OPCODE_LD4_NTA_R1_R3_R2, IA64_OPCODE_LD8_R1_R3_R2, IA64_OPCODE_LD8_NT1_R1_R3_R2, IA64_OPCODE_LD8_NTA_R1_R3_R2, IA64_OPCODE_LD1_S_R1_R3_R2, IA64_OPCODE_LD1_S_NT1_R1_R3_R2, IA64_OPCODE_LD1_S_NTA_R1_R3_R2, IA64_OPCODE_LD2_S_R1_R3_R2, IA64_OPCODE_LD2_S_NT1_R1_R3_R2, IA64_OPCODE_LD2_S_NTA_R1_R3_R2, IA64_OPCODE_LD4_S_R1_R3_R2, IA64_OPCODE_LD4_S_NT1_R1_R3_R2, IA64_OPCODE_LD4_S_NTA_R1_R3_R2, IA64_OPCODE_LD8_S_R1_R3_R2, IA64_OPCODE_LD8_S_NT1_R1_R3_R2, IA64_OPCODE_LD8_S_NTA_R1_R3_R2, IA64_OPCODE_LD1_A_R1_R3_R2, IA64_OPCODE_LD1_A_NT1_R1_R3_R2, IA64_OPCODE_LD1_A_NTA_R1_R3_R2, IA64_OPCODE_LD2_A_R1_R3_R2, IA64_OPCODE_LD2_A_NT1_R1_R3_R2, IA64_OPCODE_LD2_A_NTA_R1_R3_R2, IA64_OPCODE_LD4_A_R1_R3_R2, IA64_OPCODE_LD4_A_NT1_R1_R3_R2, IA64_OPCODE_LD4_A_NTA_R1_R3_R2, IA64_OPCODE_LD8_A_R1_R3_R2, IA64_OPCODE_LD8_A_NT1_R1_R3_R2, IA64_OPCODE_LD8_A_NTA_R1_R3_R2, IA64_OPCODE_LD1_SA_R1_R3_R2, IA64_OPCODE_LD1_SA_NT1_R1_R3_R2, IA64_OPCODE_LD1_SA_NTA_R1_R3_R2, IA64_OPCODE_LD2_SA_R1_R3_R2, IA64_OPCODE_LD2_SA_NT1_R1_R3_R2, IA64_OPCODE_LD2_SA_NTA_R1_R3_R2, IA64_OPCODE_LD4_SA_R1_R3_R2, IA64_OPCODE_LD4_SA_NT1_R1_R3_R2, IA64_OPCODE_LD4_SA_NTA_R1_R3_R2, IA64_OPCODE_LD8_SA_R1_R3_R2, IA64_OPCODE_LD8_SA_NT1_R1_R3_R2, IA64_OPCODE_LD8_SA_NTA_R1_R3_R2, IA64_OPCODE_LD1_BIAS_R1_R3_R2, IA64_OPCODE_LD1_BIAS_NT1_R1_R3_R2, IA64_OPCODE_LD1_BIAS_NTA_R1_R3_R2, IA64_OPCODE_LD2_BIAS_R1_R3_R2, IA64_OPCODE_LD2_BIAS_NT1_R1_R3_R2, IA64_OPCODE_LD2_BIAS_NTA_R1_R3_R2, IA64_OPCODE_LD4_BIAS_R1_R3_R2, IA64_OPCODE_LD4_BIAS_NT1_R1_R3_R2, IA64_OPCODE_LD4_BIAS_NTA_R1_R3_R2, IA64_OPCODE_LD8_BIAS_R1_R3_R2, IA64_OPCODE_LD8_BIAS_NT1_R1_R3_R2, IA64_OPCODE_LD8_BIAS_NTA_R1_R3_R2, IA64_OPCODE_LD1_ACQ_R1_R3_R2, IA64_OPCODE_LD1_ACQ_NT1_R1_R3_R2, IA64_OPCODE_LD1_ACQ_NTA_R1_R3_R2, IA64_OPCODE_LD2_ACQ_R1_R3_R2, IA64_OPCODE_LD2_ACQ_NT1_R1_R3_R2, IA64_OPCODE_LD2_ACQ_NTA_R1_R3_R2, IA64_OPCODE_LD4_ACQ_R1_R3_R2, IA64_OPCODE_LD4_ACQ_NT1_R1_R3_R2, IA64_OPCODE_LD4_ACQ_NTA_R1_R3_R2, IA64_OPCODE_LD8_ACQ_R1_R3_R2, IA64_OPCODE_LD8_ACQ_NT1_R1_R3_R2, IA64_OPCODE_LD8_ACQ_NTA_R1_R3_R2, IA64_OPCODE_LD8_FILL_R1_R3_R2, IA64_OPCODE_LD8_FILL_NT1_R1_R3_R2, IA64_OPCODE_LD8_FILL_NTA_R1_R3_R2, IA64_OPCODE_LD1_C_CLR_R1_R3_R2, IA64_OPCODE_LD1_C_CLR_NT1_R1_R3_R2, IA64_OPCODE_LD1_C_CLR_NTA_R1_R3_R2, IA64_OPCODE_LD2_C_CLR_R1_R3_R2, IA64_OPCODE_LD2_C_CLR_NT1_R1_R3_R2, IA64_OPCODE_LD2_C_CLR_NTA_R1_R3_R2, IA64_OPCODE_LD4_C_CLR_R1_R3_R2, IA64_OPCODE_LD4_C_CLR_NT1_R1_R3_R2, IA64_OPCODE_LD4_C_CLR_NTA_R1_R3_R2, IA64_OPCODE_LD8_C_CLR_R1_R3_R2, IA64_OPCODE_LD8_C_CLR_NT1_R1_R3_R2, IA64_OPCODE_LD8_C_CLR_NTA_R1_R3_R2, IA64_OPCODE_LD1_C_NC_R1_R3_R2, IA64_OPCODE_LD1_C_NC_NT1_R1_R3_R2, IA64_OPCODE_LD1_C_NC_NTA_R1_R3_R2, IA64_OPCODE_LD2_C_NC_R1_R3_R2, IA64_OPCODE_LD2_C_NC_NT1_R1_R3_R2, IA64_OPCODE_LD2_C_NC_NTA_R1_R3_R2, IA64_OPCODE_LD4_C_NC_R1_R3_R2, IA64_OPCODE_LD4_C_NC_NT1_R1_R3_R2, IA64_OPCODE_LD4_C_NC_NTA_R1_R3_R2, IA64_OPCODE_LD8_C_NC_R1_R3_R2, IA64_OPCODE_LD8_C_NC_NT1_R1_R3_R2, IA64_OPCODE_LD8_C_NC_NTA_R1_R3_R2, IA64_OPCODE_LD1_C_CLR_ACQ_R1_R3_R2, IA64_OPCODE_LD1_C_CLR_ACQ_NT1_R1_R3_R2, IA64_OPCODE_LD1_C_CLR_ACQ_NTA_R1_R3_R2, IA64_OPCODE_LD2_C_CLR_ACQ_R1_R3_R2, IA64_OPCODE_LD2_C_CLR_ACQ_NT1_R1_R3_R2, IA64_OPCODE_LD2_C_CLR_ACQ_NTA_R1_R3_R2, IA64_OPCODE_LD4_C_CLR_ACQ_R1_R3_R2, IA64_OPCODE_LD4_C_CLR_ACQ_NT1_R1_R3_R2, IA64_OPCODE_LD4_C_CLR_ACQ_NTA_R1_R3_R2, IA64_OPCODE_LD8_C_CLR_ACQ_R1_R3_R2, IA64_OPCODE_LD8_C_CLR_ACQ_NT1_R1_R3_R2, IA64_OPCODE_LD8_C_CLR_ACQ_NTA_R1_R3_R2, IA64_OPCODE_LD1_R1_R3_IMM9, IA64_OPCODE_LD1_NT1_R1_R3_IMM9, IA64_OPCODE_LD1_NTA_R1_R3_IMM9, IA64_OPCODE_LD2_R1_R3_IMM9, IA64_OPCODE_LD2_NT1_R1_R3_IMM9, IA64_OPCODE_LD2_NTA_R1_R3_IMM9, IA64_OPCODE_LD4_R1_R3_IMM9, IA64_OPCODE_LD4_NT1_R1_R3_IMM9, IA64_OPCODE_LD4_NTA_R1_R3_IMM9, IA64_OPCODE_LD8_R1_R3_IMM9, IA64_OPCODE_LD8_NT1_R1_R3_IMM9, IA64_OPCODE_LD8_NTA_R1_R3_IMM9, IA64_OPCODE_LD1_S_R1_R3_IMM9, IA64_OPCODE_LD1_S_NT1_R1_R3_IMM9, IA64_OPCODE_LD1_S_NTA_R1_R3_IMM9, IA64_OPCODE_LD2_S_R1_R3_IMM9, IA64_OPCODE_LD2_S_NT1_R1_R3_IMM9, IA64_OPCODE_LD2_S_NTA_R1_R3_IMM9, IA64_OPCODE_LD4_S_R1_R3_IMM9, IA64_OPCODE_LD4_S_NT1_R1_R3_IMM9, IA64_OPCODE_LD4_S_NTA_R1_R3_IMM9, IA64_OPCODE_LD8_S_R1_R3_IMM9, IA64_OPCODE_LD8_S_NT1_R1_R3_IMM9, IA64_OPCODE_LD8_S_NTA_R1_R3_IMM9, IA64_OPCODE_LD1_A_R1_R3_IMM9, IA64_OPCODE_LD1_A_NT1_R1_R3_IMM9, IA64_OPCODE_LD1_A_NTA_R1_R3_IMM9, IA64_OPCODE_LD2_A_R1_R3_IMM9, IA64_OPCODE_LD2_A_NT1_R1_R3_IMM9, IA64_OPCODE_LD2_A_NTA_R1_R3_IMM9, IA64_OPCODE_LD4_A_R1_R3_IMM9, IA64_OPCODE_LD4_A_NT1_R1_R3_IMM9, IA64_OPCODE_LD4_A_NTA_R1_R3_IMM9, IA64_OPCODE_LD8_A_R1_R3_IMM9, IA64_OPCODE_LD8_A_NT1_R1_R3_IMM9, IA64_OPCODE_LD8_A_NTA_R1_R3_IMM9, IA64_OPCODE_LD1_SA_R1_R3_IMM9, IA64_OPCODE_LD1_SA_NT1_R1_R3_IMM9, IA64_OPCODE_LD1_SA_NTA_R1_R3_IMM9, IA64_OPCODE_LD2_SA_R1_R3_IMM9, IA64_OPCODE_LD2_SA_NT1_R1_R3_IMM9, IA64_OPCODE_LD2_SA_NTA_R1_R3_IMM9, IA64_OPCODE_LD4_SA_R1_R3_IMM9, IA64_OPCODE_LD4_SA_NT1_R1_R3_IMM9, IA64_OPCODE_LD4_SA_NTA_R1_R3_IMM9, IA64_OPCODE_LD8_SA_R1_R3_IMM9, IA64_OPCODE_LD8_SA_NT1_R1_R3_IMM9, IA64_OPCODE_LD8_SA_NTA_R1_R3_IMM9, IA64_OPCODE_LD1_BIAS_R1_R3_IMM9, IA64_OPCODE_LD1_BIAS_NT1_R1_R3_IMM9, IA64_OPCODE_LD1_BIAS_NTA_R1_R3_IMM9, IA64_OPCODE_LD2_BIAS_R1_R3_IMM9, IA64_OPCODE_LD2_BIAS_NT1_R1_R3_IMM9, IA64_OPCODE_LD2_BIAS_NTA_R1_R3_IMM9, IA64_OPCODE_LD4_BIAS_R1_R3_IMM9, IA64_OPCODE_LD4_BIAS_NT1_R1_R3_IMM9, IA64_OPCODE_LD4_BIAS_NTA_R1_R3_IMM9, IA64_OPCODE_LD8_BIAS_R1_R3_IMM9, IA64_OPCODE_LD8_BIAS_NT1_R1_R3_IMM9, IA64_OPCODE_LD8_BIAS_NTA_R1_R3_IMM9, IA64_OPCODE_LD1_ACQ_R1_R3_IMM9, IA64_OPCODE_LD1_ACQ_NT1_R1_R3_IMM9, IA64_OPCODE_LD1_ACQ_NTA_R1_R3_IMM9, IA64_OPCODE_LD2_ACQ_R1_R3_IMM9, IA64_OPCODE_LD2_ACQ_NT1_R1_R3_IMM9, IA64_OPCODE_LD2_ACQ_NTA_R1_R3_IMM9, IA64_OPCODE_LD4_ACQ_R1_R3_IMM9, IA64_OPCODE_LD4_ACQ_NT1_R1_R3_IMM9, IA64_OPCODE_LD4_ACQ_NTA_R1_R3_IMM9, IA64_OPCODE_LD8_ACQ_R1_R3_IMM9, IA64_OPCODE_LD8_ACQ_NT1_R1_R3_IMM9, IA64_OPCODE_LD8_ACQ_NTA_R1_R3_IMM9, IA64_OPCODE_LD8_FILL_R1_R3_IMM9, IA64_OPCODE_LD8_FILL_NT1_R1_R3_IMM9, IA64_OPCODE_LD8_FILL_NTA_R1_R3_IMM9, IA64_OPCODE_LD1_C_CLR_R1_R3_IMM9, IA64_OPCODE_LD1_C_CLR_NT1_R1_R3_IMM9, IA64_OPCODE_LD1_C_CLR_NTA_R1_R3_IMM9, IA64_OPCODE_LD2_C_CLR_R1_R3_IMM9, IA64_OPCODE_LD2_C_CLR_NT1_R1_R3_IMM9, IA64_OPCODE_LD2_C_CLR_NTA_R1_R3_IMM9, IA64_OPCODE_LD4_C_CLR_R1_R3_IMM9, IA64_OPCODE_LD4_C_CLR_NT1_R1_R3_IMM9, IA64_OPCODE_LD4_C_CLR_NTA_R1_R3_IMM9, IA64_OPCODE_LD8_C_CLR_R1_R3_IMM9, IA64_OPCODE_LD8_C_CLR_NT1_R1_R3_IMM9, IA64_OPCODE_LD8_C_CLR_NTA_R1_R3_IMM9, IA64_OPCODE_LD1_C_NC_R1_R3_IMM9, IA64_OPCODE_LD1_C_NC_NT1_R1_R3_IMM9, IA64_OPCODE_LD1_C_NC_NTA_R1_R3_IMM9, IA64_OPCODE_LD2_C_NC_R1_R3_IMM9, IA64_OPCODE_LD2_C_NC_NT1_R1_R3_IMM9, IA64_OPCODE_LD2_C_NC_NTA_R1_R3_IMM9, IA64_OPCODE_LD4_C_NC_R1_R3_IMM9, IA64_OPCODE_LD4_C_NC_NT1_R1_R3_IMM9, IA64_OPCODE_LD4_C_NC_NTA_R1_R3_IMM9, IA64_OPCODE_LD8_C_NC_R1_R3_IMM9, IA64_OPCODE_LD8_C_NC_NT1_R1_R3_IMM9, IA64_OPCODE_LD8_C_NC_NTA_R1_R3_IMM9, IA64_OPCODE_LD1_C_CLR_ACQ_R1_R3_IMM9, IA64_OPCODE_LD1_C_CLR_ACQ_NT1_R1_R3_IMM9, IA64_OPCODE_LD1_C_CLR_ACQ_NTA_R1_R3_IMM9, IA64_OPCODE_LD2_C_CLR_ACQ_R1_R3_IMM9, IA64_OPCODE_LD2_C_CLR_ACQ_NT1_R1_R3_IMM9, IA64_OPCODE_LD2_C_CLR_ACQ_NTA_R1_R3_IMM9, IA64_OPCODE_LD4_C_CLR_ACQ_R1_R3_IMM9, IA64_OPCODE_LD4_C_CLR_ACQ_NT1_R1_R3_IMM9, IA64_OPCODE_LD4_C_CLR_ACQ_NTA_R1_R3_IMM9, IA64_OPCODE_LD8_C_CLR_ACQ_R1_R3_IMM9, IA64_OPCODE_LD8_C_CLR_ACQ_NT1_R1_R3_IMM9, IA64_OPCODE_LD8_C_CLR_ACQ_NTA_R1_R3_IMM9, IA64_OPCODE_ST1_R3_R2, IA64_OPCODE_ST1_NTA_R3_R2, IA64_OPCODE_ST2_R3_R2, IA64_OPCODE_ST2_NTA_R3_R2, IA64_OPCODE_ST4_R3_R2, IA64_OPCODE_ST4_NTA_R3_R2, IA64_OPCODE_ST8_R3_R2, IA64_OPCODE_ST8_NTA_R3_R2, IA64_OPCODE_ST1_REL_R3_R2, IA64_OPCODE_ST1_REL_NTA_R3_R2, IA64_OPCODE_ST2_REL_R3_R2, IA64_OPCODE_ST2_REL_NTA_R3_R2, IA64_OPCODE_ST4_REL_R3_R2, IA64_OPCODE_ST4_REL_NTA_R3_R2, IA64_OPCODE_ST8_REL_R3_R2, IA64_OPCODE_ST8_REL_NTA_R3_R2, IA64_OPCODE_ST8_SPILL_R3_R2, IA64_OPCODE_ST8_SPILL_NTA_R3_R2, IA64_OPCODE_ST1_R3_R2_IMM9, IA64_OPCODE_ST1_NTA_R3_R2_IMM9, IA64_OPCODE_ST2_R3_R2_IMM9, IA64_OPCODE_ST2_NTA_R3_R2_IMM9, IA64_OPCODE_ST4_R3_R2_IMM9, IA64_OPCODE_ST4_NTA_R3_R2_IMM9, IA64_OPCODE_ST8_R3_R2_IMM9, IA64_OPCODE_ST8_NTA_R3_R2_IMM9, IA64_OPCODE_ST1_REL_R3_R2_IMM9, IA64_OPCODE_ST1_REL_NTA_R3_R2_IMM9, IA64_OPCODE_ST2_REL_R3_R2_IMM9, IA64_OPCODE_ST2_REL_NTA_R3_R2_IMM9, IA64_OPCODE_ST4_REL_R3_R2_IMM9, IA64_OPCODE_ST4_REL_NTA_R3_R2_IMM9, IA64_OPCODE_ST8_REL_R3_R2_IMM9, IA64_OPCODE_ST8_REL_NTA_R3_R2_IMM9, IA64_OPCODE_ST8_SPILL_R3_R2_IMM9, IA64_OPCODE_ST8_SPILL_NTA_R3_R2_IMM9, IA64_OPCODE_LDFS_F1_R3, IA64_OPCODE_LDFS_NT1_F1_R3, IA64_OPCODE_LDFS_NTA_F1_R3, IA64_OPCODE_LDFD_F1_R3, IA64_OPCODE_LDFD_NT1_F1_R3, IA64_OPCODE_LDFD_NTA_F1_R3, IA64_OPCODE_LDF8_F1_R3, IA64_OPCODE_LDF8_NT1_F1_R3, IA64_OPCODE_LDF8_NTA_F1_R3, IA64_OPCODE_LDFE_F1_R3, IA64_OPCODE_LDFE_NT1_F1_R3, IA64_OPCODE_LDFE_NTA_F1_R3, IA64_OPCODE_LDFS_S_F1_R3, IA64_OPCODE_LDFS_S_NT1_F1_R3, IA64_OPCODE_LDFS_S_NTA_F1_R3, IA64_OPCODE_LDFD_S_F1_R3, IA64_OPCODE_LDFD_S_NT1_F1_R3, IA64_OPCODE_LDFD_S_NTA_F1_R3, IA64_OPCODE_LDF8_S_F1_R3, IA64_OPCODE_LDF8_S_NT1_F1_R3, IA64_OPCODE_LDF8_S_NTA_F1_R3, IA64_OPCODE_LDFE_S_F1_R3, IA64_OPCODE_LDFE_S_NT1_F1_R3, IA64_OPCODE_LDFE_S_NTA_F1_R3, IA64_OPCODE_LDFS_A_F1_R3, IA64_OPCODE_LDFS_A_NT1_F1_R3, IA64_OPCODE_LDFS_A_NTA_F1_R3, IA64_OPCODE_LDFD_A_F1_R3, IA64_OPCODE_LDFD_A_NT1_F1_R3, IA64_OPCODE_LDFD_A_NTA_F1_R3, IA64_OPCODE_LDF8_A_F1_R3, IA64_OPCODE_LDF8_A_NT1_F1_R3, IA64_OPCODE_LDF8_A_NTA_F1_R3, IA64_OPCODE_LDFE_A_F1_R3, IA64_OPCODE_LDFE_A_NT1_F1_R3, IA64_OPCODE_LDFE_A_NTA_F1_R3, IA64_OPCODE_LDFS_SA_F1_R3, IA64_OPCODE_LDFS_SA_NT1_F1_R3, IA64_OPCODE_LDFS_SA_NTA_F1_R3, IA64_OPCODE_LDFD_SA_F1_R3, IA64_OPCODE_LDFD_SA_NT1_F1_R3, IA64_OPCODE_LDFD_SA_NTA_F1_R3, IA64_OPCODE_LDF8_SA_F1_R3, IA64_OPCODE_LDF8_SA_NT1_F1_R3, IA64_OPCODE_LDF8_SA_NTA_F1_R3, IA64_OPCODE_LDFE_SA_F1_R3, IA64_OPCODE_LDFE_SA_NT1_F1_R3, IA64_OPCODE_LDFE_SA_NTA_F1_R3, IA64_OPCODE_LDF_FILL_F1_R3, IA64_OPCODE_LDF_FILL_NT1_F1_R3, IA64_OPCODE_LDF_FILL_NTA_F1_R3, IA64_OPCODE_LDFS_C_CLR_F1_R3, IA64_OPCODE_LDFS_C_CLR_NT1_F1_R3, IA64_OPCODE_LDFS_C_CLR_NTA_F1_R3, IA64_OPCODE_LDFD_C_CLR_F1_R3, IA64_OPCODE_LDFD_C_CLR_NT1_F1_R3, IA64_OPCODE_LDFD_C_CLR_NTA_F1_R3, IA64_OPCODE_LDF8_C_CLR_F1_R3, IA64_OPCODE_LDF8_C_CLR_NT1_F1_R3, IA64_OPCODE_LDF8_C_CLR_NTA_F1_R3, IA64_OPCODE_LDFE_C_CLR_F1_R3, IA64_OPCODE_LDFE_C_CLR_NT1_F1_R3, IA64_OPCODE_LDFE_C_CLR_NTA_F1_R3, IA64_OPCODE_LDFS_C_NC_F1_R3, IA64_OPCODE_LDFS_C_NC_NT1_F1_R3, IA64_OPCODE_LDFS_C_NC_NTA_F1_R3, IA64_OPCODE_LDFD_C_NC_F1_R3, IA64_OPCODE_LDFD_C_NC_NT1_F1_R3, IA64_OPCODE_LDFD_C_NC_NTA_F1_R3, IA64_OPCODE_LDF8_C_NC_F1_R3, IA64_OPCODE_LDF8_C_NC_NT1_F1_R3, IA64_OPCODE_LDF8_C_NC_NTA_F1_R3, IA64_OPCODE_LDFE_C_NC_F1_R3, IA64_OPCODE_LDFE_C_NC_NT1_F1_R3, IA64_OPCODE_LDFE_C_NC_NTA_F1_R3, IA64_OPCODE_LDFS_F1_R3_R2, IA64_OPCODE_LDFS_NT1_F1_R3_R2, IA64_OPCODE_LDFS_NTA_F1_R3_R2, IA64_OPCODE_LDFD_F1_R3_R2, IA64_OPCODE_LDFD_NT1_F1_R3_R2, IA64_OPCODE_LDFD_NTA_F1_R3_R2, IA64_OPCODE_LDF8_F1_R3_R2, IA64_OPCODE_LDF8_NT1_F1_R3_R2, IA64_OPCODE_LDF8_NTA_F1_R3_R2, IA64_OPCODE_LDFE_F1_R3_R2, IA64_OPCODE_LDFE_NT1_F1_R3_R2, IA64_OPCODE_LDFE_NTA_F1_R3_R2, IA64_OPCODE_LDFS_S_F1_R3_R2, IA64_OPCODE_LDFS_S_NT1_F1_R3_R2, IA64_OPCODE_LDFS_S_NTA_F1_R3_R2, IA64_OPCODE_LDFD_S_F1_R3_R2, IA64_OPCODE_LDFD_S_NT1_F1_R3_R2, IA64_OPCODE_LDFD_S_NTA_F1_R3_R2, IA64_OPCODE_LDF8_S_F1_R3_R2, IA64_OPCODE_LDF8_S_NT1_F1_R3_R2, IA64_OPCODE_LDF8_S_NTA_F1_R3_R2, IA64_OPCODE_LDFE_S_F1_R3_R2, IA64_OPCODE_LDFE_S_NT1_F1_R3_R2, IA64_OPCODE_LDFE_S_NTA_F1_R3_R2, IA64_OPCODE_LDFS_A_F1_R3_R2, IA64_OPCODE_LDFS_A_NT1_F1_R3_R2, IA64_OPCODE_LDFS_A_NTA_F1_R3_R2, IA64_OPCODE_LDFD_A_F1_R3_R2, IA64_OPCODE_LDFD_A_NT1_F1_R3_R2, IA64_OPCODE_LDFD_A_NTA_F1_R3_R2, IA64_OPCODE_LDF8_A_F1_R3_R2, IA64_OPCODE_LDF8_A_NT1_F1_R3_R2, IA64_OPCODE_LDF8_A_NTA_F1_R3_R2, IA64_OPCODE_LDFE_A_F1_R3_R2, IA64_OPCODE_LDFE_A_NT1_F1_R3_R2, IA64_OPCODE_LDFE_A_NTA_F1_R3_R2, IA64_OPCODE_LDFS_SA_F1_R3_R2, IA64_OPCODE_LDFS_SA_NT1_F1_R3_R2, IA64_OPCODE_LDFS_SA_NTA_F1_R3_R2, IA64_OPCODE_LDFD_SA_F1_R3_R2, IA64_OPCODE_LDFD_SA_NT1_F1_R3_R2, IA64_OPCODE_LDFD_SA_NTA_F1_R3_R2, IA64_OPCODE_LDF8_SA_F1_R3_R2, IA64_OPCODE_LDF8_SA_NT1_F1_R3_R2, IA64_OPCODE_LDF8_SA_NTA_F1_R3_R2, IA64_OPCODE_LDFE_SA_F1_R3_R2, IA64_OPCODE_LDFE_SA_NT1_F1_R3_R2, IA64_OPCODE_LDFE_SA_NTA_F1_R3_R2, IA64_OPCODE_LDF_FILL_F1_R3_R2, IA64_OPCODE_LDF_FILL_NT1_F1_R3_R2, IA64_OPCODE_LDF_FILL_NTA_F1_R3_R2, IA64_OPCODE_LDFS_C_CLR_F1_R3_R2, IA64_OPCODE_LDFS_C_CLR_NT1_F1_R3_R2, IA64_OPCODE_LDFS_C_CLR_NTA_F1_R3_R2, IA64_OPCODE_LDFD_C_CLR_F1_R3_R2, IA64_OPCODE_LDFD_C_CLR_NT1_F1_R3_R2, IA64_OPCODE_LDFD_C_CLR_NTA_F1_R3_R2, IA64_OPCODE_LDF8_C_CLR_F1_R3_R2, IA64_OPCODE_LDF8_C_CLR_NT1_F1_R3_R2, IA64_OPCODE_LDF8_C_CLR_NTA_F1_R3_R2, IA64_OPCODE_LDFE_C_CLR_F1_R3_R2, IA64_OPCODE_LDFE_C_CLR_NT1_F1_R3_R2, IA64_OPCODE_LDFE_C_CLR_NTA_F1_R3_R2, IA64_OPCODE_LDFS_C_NC_F1_R3_R2, IA64_OPCODE_LDFS_C_NC_NT1_F1_R3_R2, IA64_OPCODE_LDFS_C_NC_NTA_F1_R3_R2, IA64_OPCODE_LDFD_C_NC_F1_R3_R2, IA64_OPCODE_LDFD_C_NC_NT1_F1_R3_R2, IA64_OPCODE_LDFD_C_NC_NTA_F1_R3_R2, IA64_OPCODE_LDF8_C_NC_F1_R3_R2, IA64_OPCODE_LDF8_C_NC_NT1_F1_R3_R2, IA64_OPCODE_LDF8_C_NC_NTA_F1_R3_R2, IA64_OPCODE_LDFE_C_NC_F1_R3_R2, IA64_OPCODE_LDFE_C_NC_NT1_F1_R3_R2, IA64_OPCODE_LDFE_C_NC_NTA_F1_R3_R2, IA64_OPCODE_LDFS_F1_R3_IMM9, IA64_OPCODE_LDFS_NT1_F1_R3_IMM9, IA64_OPCODE_LDFS_NTA_F1_R3_IMM9, IA64_OPCODE_LDFD_F1_R3_IMM9, IA64_OPCODE_LDFD_NT1_F1_R3_IMM9, IA64_OPCODE_LDFD_NTA_F1_R3_IMM9, IA64_OPCODE_LDF8_F1_R3_IMM9, IA64_OPCODE_LDF8_NT1_F1_R3_IMM9, IA64_OPCODE_LDF8_NTA_F1_R3_IMM9, IA64_OPCODE_LDFE_F1_R3_IMM9, IA64_OPCODE_LDFE_NT1_F1_R3_IMM9, IA64_OPCODE_LDFE_NTA_F1_R3_IMM9, IA64_OPCODE_LDFS_S_F1_R3_IMM9, IA64_OPCODE_LDFS_S_NT1_F1_R3_IMM9, IA64_OPCODE_LDFS_S_NTA_F1_R3_IMM9, IA64_OPCODE_LDFD_S_F1_R3_IMM9, IA64_OPCODE_LDFD_S_NT1_F1_R3_IMM9, IA64_OPCODE_LDFD_S_NTA_F1_R3_IMM9, IA64_OPCODE_LDF8_S_F1_R3_IMM9, IA64_OPCODE_LDF8_S_NT1_F1_R3_IMM9, IA64_OPCODE_LDF8_S_NTA_F1_R3_IMM9, IA64_OPCODE_LDFE_S_F1_R3_IMM9, IA64_OPCODE_LDFE_S_NT1_F1_R3_IMM9, IA64_OPCODE_LDFE_S_NTA_F1_R3_IMM9, IA64_OPCODE_LDFS_A_F1_R3_IMM9, IA64_OPCODE_LDFS_A_NT1_F1_R3_IMM9, IA64_OPCODE_LDFS_A_NTA_F1_R3_IMM9, IA64_OPCODE_LDFD_A_F1_R3_IMM9, IA64_OPCODE_LDFD_A_NT1_F1_R3_IMM9, IA64_OPCODE_LDFD_A_NTA_F1_R3_IMM9, IA64_OPCODE_LDF8_A_F1_R3_IMM9, IA64_OPCODE_LDF8_A_NT1_F1_R3_IMM9, IA64_OPCODE_LDF8_A_NTA_F1_R3_IMM9, IA64_OPCODE_LDFE_A_F1_R3_IMM9, IA64_OPCODE_LDFE_A_NT1_F1_R3_IMM9, IA64_OPCODE_LDFE_A_NTA_F1_R3_IMM9, IA64_OPCODE_LDFS_SA_F1_R3_IMM9, IA64_OPCODE_LDFS_SA_NT1_F1_R3_IMM9, IA64_OPCODE_LDFS_SA_NTA_F1_R3_IMM9, IA64_OPCODE_LDFD_SA_F1_R3_IMM9, IA64_OPCODE_LDFD_SA_NT1_F1_R3_IMM9, IA64_OPCODE_LDFD_SA_NTA_F1_R3_IMM9, IA64_OPCODE_LDF8_SA_F1_R3_IMM9, IA64_OPCODE_LDF8_SA_NT1_F1_R3_IMM9, IA64_OPCODE_LDF8_SA_NTA_F1_R3_IMM9, IA64_OPCODE_LDFE_SA_F1_R3_IMM9, IA64_OPCODE_LDFE_SA_NT1_F1_R3_IMM9, IA64_OPCODE_LDFE_SA_NTA_F1_R3_IMM9, IA64_OPCODE_LDF_FILL_F1_R3_IMM9, IA64_OPCODE_LDF_FILL_NT1_F1_R3_IMM9, IA64_OPCODE_LDF_FILL_NTA_F1_R3_IMM9, IA64_OPCODE_LDFS_C_CLR_F1_R3_IMM9, IA64_OPCODE_INST1_LAST }; enum IA64EnumOpcode2 { IA64_OPCODE_LDFS_C_CLR_NT1_F1_R3_IMM9 = IA64_OPCODE_INST1_LAST, IA64_OPCODE_LDFS_C_CLR_NTA_F1_R3_IMM9, IA64_OPCODE_LDFD_C_CLR_F1_R3_IMM9, IA64_OPCODE_LDFD_C_CLR_NT1_F1_R3_IMM9, IA64_OPCODE_LDFD_C_CLR_NTA_F1_R3_IMM9, IA64_OPCODE_LDF8_C_CLR_F1_R3_IMM9, IA64_OPCODE_LDF8_C_CLR_NT1_F1_R3_IMM9, IA64_OPCODE_LDF8_C_CLR_NTA_F1_R3_IMM9, IA64_OPCODE_LDFE_C_CLR_F1_R3_IMM9, IA64_OPCODE_LDFE_C_CLR_NT1_F1_R3_IMM9, IA64_OPCODE_LDFE_C_CLR_NTA_F1_R3_IMM9, IA64_OPCODE_LDFS_C_NC_F1_R3_IMM9, IA64_OPCODE_LDFS_C_NC_NT1_F1_R3_IMM9, IA64_OPCODE_LDFS_C_NC_NTA_F1_R3_IMM9, IA64_OPCODE_LDFD_C_NC_F1_R3_IMM9, IA64_OPCODE_LDFD_C_NC_NT1_F1_R3_IMM9, IA64_OPCODE_LDFD_C_NC_NTA_F1_R3_IMM9, IA64_OPCODE_LDF8_C_NC_F1_R3_IMM9, IA64_OPCODE_LDF8_C_NC_NT1_F1_R3_IMM9, IA64_OPCODE_LDF8_C_NC_NTA_F1_R3_IMM9, IA64_OPCODE_LDFE_C_NC_F1_R3_IMM9, IA64_OPCODE_LDFE_C_NC_NT1_F1_R3_IMM9, IA64_OPCODE_LDFE_C_NC_NTA_F1_R3_IMM9, IA64_OPCODE_STFS_R3_F2, IA64_OPCODE_STFS_NTA_R3_F2, IA64_OPCODE_STFD_R3_F2, IA64_OPCODE_STFD_NTA_R3_F2, IA64_OPCODE_STF8_R3_F2, IA64_OPCODE_STF8_NTA_R3_F2, IA64_OPCODE_STFE_R3_F2, IA64_OPCODE_STFE_NTA_R3_F2, IA64_OPCODE_STF_SPILL_R3_F2, IA64_OPCODE_STF_SPILL_NTA_R3_F2, IA64_OPCODE_STFS_R3_F2_IMM9, IA64_OPCODE_STFS_NTA_R3_F2_IMM9, IA64_OPCODE_STFD_R3_F2_IMM9, IA64_OPCODE_STFD_NTA_R3_F2_IMM9, IA64_OPCODE_STF8_R3_F2_IMM9, IA64_OPCODE_STF8_NTA_R3_F2_IMM9, IA64_OPCODE_STFE_R3_F2_IMM9, IA64_OPCODE_STFE_NTA_R3_F2_IMM9, IA64_OPCODE_STF_SPILL_R3_F2_IMM9, IA64_OPCODE_STF_SPILL_NTA_R3_F2_IMM9, IA64_OPCODE_LDFPS_F1_F2_R3, IA64_OPCODE_LDFPS_NT1_F1_F2_R3, IA64_OPCODE_LDFPS_NTA_F1_F2_R3, IA64_OPCODE_LDFPD_F1_F2_R3, IA64_OPCODE_LDFPD_NT1_F1_F2_R3, IA64_OPCODE_LDFPD_NTA_F1_F2_R3, IA64_OPCODE_LDFP8_F1_F2_R3, IA64_OPCODE_LDFP8_NT1_F1_F2_R3, IA64_OPCODE_LDFP8_NTA_F1_F2_R3, IA64_OPCODE_LDFPS_S_F1_F2_R3, IA64_OPCODE_LDFPS_S_NT1_F1_F2_R3, IA64_OPCODE_LDFPS_S_NTA_F1_F2_R3, IA64_OPCODE_LDFPD_S_F1_F2_R3, IA64_OPCODE_LDFPD_S_NT1_F1_F2_R3, IA64_OPCODE_LDFPD_S_NTA_F1_F2_R3, IA64_OPCODE_LDFP8_S_F1_F2_R3, IA64_OPCODE_LDFP8_S_NT1_F1_F2_R3, IA64_OPCODE_LDFP8_S_NTA_F1_F2_R3, IA64_OPCODE_LDFPS_A_F1_F2_R3, IA64_OPCODE_LDFPS_A_NT1_F1_F2_R3, IA64_OPCODE_LDFPS_A_NTA_F1_F2_R3, IA64_OPCODE_LDFPD_A_F1_F2_R3, IA64_OPCODE_LDFPD_A_NT1_F1_F2_R3, IA64_OPCODE_LDFPD_A_NTA_F1_F2_R3, IA64_OPCODE_LDFP8_A_F1_F2_R3, IA64_OPCODE_LDFP8_A_NT1_F1_F2_R3, IA64_OPCODE_LDFP8_A_NTA_F1_F2_R3, IA64_OPCODE_LDFPS_SA_F1_F2_R3, IA64_OPCODE_LDFPS_SA_NT1_F1_F2_R3, IA64_OPCODE_LDFPS_SA_NTA_F1_F2_R3, IA64_OPCODE_LDFPD_SA_F1_F2_R3, IA64_OPCODE_LDFPD_SA_NT1_F1_F2_R3, IA64_OPCODE_LDFPD_SA_NTA_F1_F2_R3, IA64_OPCODE_LDFP8_SA_F1_F2_R3, IA64_OPCODE_LDFP8_SA_NT1_F1_F2_R3, IA64_OPCODE_LDFP8_SA_NTA_F1_F2_R3, IA64_OPCODE_LDFPS_C_CLR_F1_F2_R3, IA64_OPCODE_LDFPS_C_CLR_NT1_F1_F2_R3, IA64_OPCODE_LDFPS_C_CLR_NTA_F1_F2_R3, IA64_OPCODE_LDFPD_C_CLR_F1_F2_R3, IA64_OPCODE_LDFPD_C_CLR_NT1_F1_F2_R3, IA64_OPCODE_LDFPD_C_CLR_NTA_F1_F2_R3, IA64_OPCODE_LDFP8_C_CLR_F1_F2_R3, IA64_OPCODE_LDFP8_C_CLR_NT1_F1_F2_R3, IA64_OPCODE_LDFP8_C_CLR_NTA_F1_F2_R3, IA64_OPCODE_LDFPS_C_NC_F1_F2_R3, IA64_OPCODE_LDFPS_C_NC_NT1_F1_F2_R3, IA64_OPCODE_LDFPS_C_NC_NTA_F1_F2_R3, IA64_OPCODE_LDFPD_C_NC_F1_F2_R3, IA64_OPCODE_LDFPD_C_NC_NT1_F1_F2_R3, IA64_OPCODE_LDFPD_C_NC_NTA_F1_F2_R3, IA64_OPCODE_LDFP8_C_NC_F1_F2_R3, IA64_OPCODE_LDFP8_C_NC_NT1_F1_F2_R3, IA64_OPCODE_LDFP8_C_NC_NTA_F1_F2_R3, IA64_OPCODE_LDFPS_F1_F2_R3_8, IA64_OPCODE_LDFPS_NT1_F1_F2_R3_8, IA64_OPCODE_LDFPS_NTA_F1_F2_R3_8, IA64_OPCODE_LDFPD_F1_F2_R3_16, IA64_OPCODE_LDFPD_NT1_F1_F2_R3_16, IA64_OPCODE_LDFPD_NTA_F1_F2_R3_16, IA64_OPCODE_LDFP8_F1_F2_R3_16, IA64_OPCODE_LDFP8_NT1_F1_F2_R3_16, IA64_OPCODE_LDFP8_NTA_F1_F2_R3_16, IA64_OPCODE_LDFPS_S_F1_F2_R3_8, IA64_OPCODE_LDFPS_S_NT1_F1_F2_R3_8, IA64_OPCODE_LDFPS_S_NTA_F1_F2_R3_8, IA64_OPCODE_LDFPD_S_F1_F2_R3_16, IA64_OPCODE_LDFPD_S_NT1_F1_F2_R3_16, IA64_OPCODE_LDFPD_S_NTA_F1_F2_R3_16, IA64_OPCODE_LDFP8_S_F1_F2_R3_16, IA64_OPCODE_LDFP8_S_NT1_F1_F2_R3_16, IA64_OPCODE_LDFP8_S_NTA_F1_F2_R3_16, IA64_OPCODE_LDFPS_A_F1_F2_R3_8, IA64_OPCODE_LDFPS_A_NT1_F1_F2_R3_8, IA64_OPCODE_LDFPS_A_NTA_F1_F2_R3_8, IA64_OPCODE_LDFPD_A_F1_F2_R3_16, IA64_OPCODE_LDFPD_A_NT1_F1_F2_R3_16, IA64_OPCODE_LDFPD_A_NTA_F1_F2_R3_16, IA64_OPCODE_LDFP8_A_F1_F2_R3_16, IA64_OPCODE_LDFP8_A_NT1_F1_F2_R3_16, IA64_OPCODE_LDFP8_A_NTA_F1_F2_R3_16, IA64_OPCODE_LDFPS_SA_F1_F2_R3_8, IA64_OPCODE_LDFPS_SA_NT1_F1_F2_R3_8, IA64_OPCODE_LDFPS_SA_NTA_F1_F2_R3_8, IA64_OPCODE_LDFPD_SA_F1_F2_R3_16, IA64_OPCODE_LDFPD_SA_NT1_F1_F2_R3_16, IA64_OPCODE_LDFPD_SA_NTA_F1_F2_R3_16, IA64_OPCODE_LDFP8_SA_F1_F2_R3_16, IA64_OPCODE_LDFP8_SA_NT1_F1_F2_R3_16, IA64_OPCODE_LDFP8_SA_NTA_F1_F2_R3_16, IA64_OPCODE_LDFPS_C_CLR_F1_F2_R3_8, IA64_OPCODE_LDFPS_C_CLR_NT1_F1_F2_R3_8, IA64_OPCODE_LDFPS_C_CLR_NTA_F1_F2_R3_8, IA64_OPCODE_LDFPD_C_CLR_F1_F2_R3_16, IA64_OPCODE_LDFPD_C_CLR_NT1_F1_F2_R3_16, IA64_OPCODE_LDFPD_C_CLR_NTA_F1_F2_R3_16, IA64_OPCODE_LDFP8_C_CLR_F1_F2_R3_16, IA64_OPCODE_LDFP8_C_CLR_NT1_F1_F2_R3_16, IA64_OPCODE_LDFP8_C_CLR_NTA_F1_F2_R3_16, IA64_OPCODE_LDFPS_C_NC_F1_F2_R3_8, IA64_OPCODE_LDFPS_C_NC_NT1_F1_F2_R3_8, IA64_OPCODE_LDFPS_C_NC_NTA_F1_F2_R3_8, IA64_OPCODE_LDFPD_C_NC_F1_F2_R3_16, IA64_OPCODE_LDFPD_C_NC_NT1_F1_F2_R3_16, IA64_OPCODE_LDFPD_C_NC_NTA_F1_F2_R3_16, IA64_OPCODE_LDFP8_C_NC_F1_F2_R3_16, IA64_OPCODE_LDFP8_C_NC_NT1_F1_F2_R3_16, IA64_OPCODE_LDFP8_C_NC_NTA_F1_F2_R3_16, IA64_OPCODE_LFETCH_R3, IA64_OPCODE_LFETCH_NT1_R3, IA64_OPCODE_LFETCH_NT2_R3, IA64_OPCODE_LFETCH_NTA_R3, IA64_OPCODE_LFETCH_EXCL_R3, IA64_OPCODE_LFETCH_EXCL_NT1_R3, IA64_OPCODE_LFETCH_EXCL_NT2_R3, IA64_OPCODE_LFETCH_EXCL_NTA_R3, IA64_OPCODE_LFETCH_FAULT_R3, IA64_OPCODE_LFETCH_FAULT_NT1_R3, IA64_OPCODE_LFETCH_FAULT_NT2_R3, IA64_OPCODE_LFETCH_FAULT_NTA_R3, IA64_OPCODE_LFETCH_FAULT_EXCL_R3, IA64_OPCODE_LFETCH_FAULT_EXCL_NT1_R3, IA64_OPCODE_LFETCH_FAULT_EXCL_NT2_R3, IA64_OPCODE_LFETCH_FAULT_EXCL_NTA_R3, IA64_OPCODE_LFETCH_R3_R2, IA64_OPCODE_LFETCH_NT1_R3_R2, IA64_OPCODE_LFETCH_NT2_R3_R2, IA64_OPCODE_LFETCH_NTA_R3_R2, IA64_OPCODE_LFETCH_EXCL_R3_R2, IA64_OPCODE_LFETCH_EXCL_NT1_R3_R2, IA64_OPCODE_LFETCH_EXCL_NT2_R3_R2, IA64_OPCODE_LFETCH_EXCL_NTA_R3_R2, IA64_OPCODE_LFETCH_FAULT_R3_R2, IA64_OPCODE_LFETCH_FAULT_NT1_R3_R2, IA64_OPCODE_LFETCH_FAULT_NT2_R3_R2, IA64_OPCODE_LFETCH_FAULT_NTA_R3_R2, IA64_OPCODE_LFETCH_FAULT_EXCL_R3_R2, IA64_OPCODE_LFETCH_FAULT_EXCL_NT1_R3_R2, IA64_OPCODE_LFETCH_FAULT_EXCL_NT2_R3_R2, IA64_OPCODE_LFETCH_FAULT_EXCL_NTA_R3_R2, IA64_OPCODE_LFETCH_R3_IMM9, IA64_OPCODE_LFETCH_NT1_R3_IMM9, IA64_OPCODE_LFETCH_NT2_R3_IMM9, IA64_OPCODE_LFETCH_NTA_R3_IMM9, IA64_OPCODE_LFETCH_EXCL_R3_IMM9, IA64_OPCODE_LFETCH_EXCL_NT1_R3_IMM9, IA64_OPCODE_LFETCH_EXCL_NT2_R3_IMM9, IA64_OPCODE_LFETCH_EXCL_NTA_R3_IMM9, IA64_OPCODE_LFETCH_FAULT_R3_IMM9, IA64_OPCODE_LFETCH_FAULT_NT1_R3_IMM9, IA64_OPCODE_LFETCH_FAULT_NT2_R3_IMM9, IA64_OPCODE_LFETCH_FAULT_NTA_R3_IMM9, IA64_OPCODE_LFETCH_FAULT_EXCL_R3_IMM9, IA64_OPCODE_LFETCH_FAULT_EXCL_NT1_R3_IMM9, IA64_OPCODE_LFETCH_FAULT_EXCL_NT2_R3_IMM9, IA64_OPCODE_LFETCH_FAULT_EXCL_NTA_R3_IMM9, IA64_OPCODE_CMPXCHG1_ACQ_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG1_ACQ_NT1_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG1_ACQ_NTA_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG2_ACQ_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG2_ACQ_NT1_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG2_ACQ_NTA_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG4_ACQ_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG4_ACQ_NT1_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG4_ACQ_NTA_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG8_ACQ_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG8_ACQ_NT1_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG8_ACQ_NTA_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG1_REL_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG1_REL_NT1_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG1_REL_NTA_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG2_REL_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG2_REL_NT1_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG2_REL_NTA_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG4_REL_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG4_REL_NT1_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG4_REL_NTA_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG8_REL_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG8_REL_NT1_R1_R3_R2_AR_CCV, IA64_OPCODE_CMPXCHG8_REL_NTA_R1_R3_R2_AR_CCV, IA64_OPCODE_XCHG1_R1_R3_R2, IA64_OPCODE_XCHG1_NT1_R1_R3_R2, IA64_OPCODE_XCHG1_NTA_R1_R3_R2, IA64_OPCODE_XCHG2_R1_R3_R2, IA64_OPCODE_XCHG2_NT1_R1_R3_R2, IA64_OPCODE_XCHG2_NTA_R1_R3_R2, IA64_OPCODE_XCHG4_R1_R3_R2, IA64_OPCODE_XCHG4_NT1_R1_R3_R2, IA64_OPCODE_XCHG4_NTA_R1_R3_R2, IA64_OPCODE_XCHG8_R1_R3_R2, IA64_OPCODE_XCHG8_NT1_R1_R3_R2, IA64_OPCODE_XCHG8_NTA_R1_R3_R2, IA64_OPCODE_FETCHADD4_ACQ_R1_R3_INC3, IA64_OPCODE_FETCHADD4_ACQ_NT1_R1_R3_INC3, IA64_OPCODE_FETCHADD4_ACQ_NTA_R1_R3_INC3, IA64_OPCODE_FETCHADD8_ACQ_R1_R3_INC3, IA64_OPCODE_FETCHADD8_ACQ_NT1_R1_R3_INC3, IA64_OPCODE_FETCHADD8_ACQ_NTA_R1_R3_INC3, IA64_OPCODE_FETCHADD4_REL_R1_R3_INC3, IA64_OPCODE_FETCHADD4_REL_NT1_R1_R3_INC3, IA64_OPCODE_FETCHADD4_REL_NTA_R1_R3_INC3, IA64_OPCODE_FETCHADD8_REL_R1_R3_INC3, IA64_OPCODE_FETCHADD8_REL_NT1_R1_R3_INC3, IA64_OPCODE_FETCHADD8_REL_NTA_R1_R3_INC3, IA64_OPCODE_SETF_SIG_F1_R2, IA64_OPCODE_SETF_EXP_F1_R2, IA64_OPCODE_SETF_S_F1_R2, IA64_OPCODE_SETF_D_F1_R2, IA64_OPCODE_GETF_SIG_R1_F2, IA64_OPCODE_GETF_EXP_R1_F2, IA64_OPCODE_GETF_S_R1_F2, IA64_OPCODE_GETF_D_R1_F2, IA64_OPCODE_CHK_S_M_R2_TARGET25, IA64_OPCODE_CHK_S_F2_TARGET25, IA64_OPCODE_CHK_A_NC_R1_TARGET25, IA64_OPCODE_CHK_A_CLR_R1_TARGET25, IA64_OPCODE_CHK_A_NC_F1_TARGET25, IA64_OPCODE_CHK_A_CLR_F1_TARGET25, IA64_OPCODE_INVALA, IA64_OPCODE_FWB, IA64_OPCODE_MF, IA64_OPCODE_MF_A, IA64_OPCODE_SRLZ_D, IA64_OPCODE_SRLZ_I, IA64_OPCODE_SYNC_I, IA64_OPCODE_FLUSHRS, IA64_OPCODE_LOADRS, IA64_OPCODE_INVALA_E_R1, IA64_OPCODE_INVALA_E_F1, IA64_OPCODE_FC_R3, IA64_OPCODE_PTC_E_R3, IA64_OPCODE_MOV_M_AR3_R2, IA64_OPCODE_MOV_M_AR3_IMM8, IA64_OPCODE_MOV_M_R1_AR3, IA64_OPCODE_MOV_CR3_R2, IA64_OPCODE_MOV_R1_CR3, IA64_OPCODE_ALLOC_R1_AR_PFS_I_L_O_R, IA64_OPCODE_MOV_PSR_L_R2, IA64_OPCODE_MOV_PSR_UM_R2, IA64_OPCODE_MOV_R1_PSR, IA64_OPCODE_MOV_R1_PSR_UM, IA64_OPCODE_BREAK_M_IMM21, IA64_OPCODE_NOP_M_IMM21, IA64_OPCODE_PROBE_R_R1_R3_R2, IA64_OPCODE_PROBE_W_R1_R3_R2, IA64_OPCODE_PROBE_R_R1_R3_IMM2, IA64_OPCODE_PROBE_W_R1_R3_IMM2, IA64_OPCODE_PROBE_RW_FAULT_R3_IMM2, IA64_OPCODE_PROBE_R_FAULT_R3_IMM2, IA64_OPCODE_PROBE_W_FAULT_R3_IMM2, IA64_OPCODE_ITC_D_R2, IA64_OPCODE_ITC_I_R2, IA64_OPCODE_MOV_RR_R3_R2, IA64_OPCODE_MOV_DBR_R3_R2, IA64_OPCODE_MOV_IBR_R3_R2, IA64_OPCODE_MOV_PKR_R3_R2, IA64_OPCODE_MOV_PMC_R3_R2, IA64_OPCODE_MOV_PMD_R3_R2, IA64_OPCODE_MOV_MSR_R3_R2, IA64_OPCODE_ITR_D_DTR_R3_R2, IA64_OPCODE_ITR_I_ITR_R3_R2, IA64_OPCODE_MOV_R1_RR_R3, IA64_OPCODE_MOV_R1_DBR_R3, IA64_OPCODE_MOV_R1_IBR_R3, IA64_OPCODE_MOV_R1_PKR_R3, IA64_OPCODE_MOV_R1_PMC_R3, IA64_OPCODE_MOV_R1_MSR_R3, IA64_OPCODE_MOV_R1_PMD_R3, IA64_OPCODE_MOV_R1_CPUID_R3, IA64_OPCODE_SUM_IMM24, IA64_OPCODE_RUM_IMM24, IA64_OPCODE_SSM_IMM24, IA64_OPCODE_RSM_IMM24, IA64_OPCODE_PTC_L_R3_R2, IA64_OPCODE_PTC_G_R3_R2, IA64_OPCODE_PTC_GA_R3_R2, IA64_OPCODE_PTR_D_R3_R2, IA64_OPCODE_PTR_I_R3_R2, IA64_OPCODE_THASH_R1_R3, IA64_OPCODE_TTAG_R1_R3, IA64_OPCODE_TPA_R1_R3, IA64_OPCODE_TAK_R1_R3, IA64_OPCODE_HALT_R3, IA64_OPCODE_BR_COND_SPTK_FEW_TARGET25, IA64_OPCODE_BR_COND_SPTK_MANY_TARGET25, IA64_OPCODE_BR_COND_SPNT_FEW_TARGET25, IA64_OPCODE_BR_COND_SPNT_MANY_TARGET25, IA64_OPCODE_BR_COND_DPTK_FEW_TARGET25, IA64_OPCODE_BR_COND_DPTK_MANY_TARGET25, IA64_OPCODE_BR_COND_DPNT_FEW_TARGET25, IA64_OPCODE_BR_COND_DPNT_MANY_TARGET25, IA64_OPCODE_BR_COND_SPTK_FEW_CLR_TARGET25, IA64_OPCODE_BR_COND_SPTK_MANY_CLR_TARGET25, IA64_OPCODE_BR_COND_SPNT_FEW_CLR_TARGET25, IA64_OPCODE_BR_COND_SPNT_MANY_CLR_TARGET25, IA64_OPCODE_BR_COND_DPTK_FEW_CLR_TARGET25, IA64_OPCODE_BR_COND_DPTK_MANY_CLR_TARGET25, IA64_OPCODE_BR_COND_DPNT_FEW_CLR_TARGET25, IA64_OPCODE_BR_COND_DPNT_MANY_CLR_TARGET25, IA64_OPCODE_BR_WEXIT_SPTK_FEW_TARGET25, IA64_OPCODE_BR_WEXIT_SPTK_MANY_TARGET25, IA64_OPCODE_BR_WEXIT_SPNT_FEW_TARGET25, IA64_OPCODE_BR_WEXIT_SPNT_MANY_TARGET25, IA64_OPCODE_BR_WEXIT_DPTK_FEW_TARGET25, IA64_OPCODE_BR_WEXIT_DPTK_MANY_TARGET25, IA64_OPCODE_BR_WEXIT_DPNT_FEW_TARGET25, IA64_OPCODE_BR_WEXIT_DPNT_MANY_TARGET25, IA64_OPCODE_BR_WEXIT_SPTK_FEW_CLR_TARGET25, IA64_OPCODE_BR_WEXIT_SPTK_MANY_CLR_TARGET25, IA64_OPCODE_BR_WEXIT_SPNT_FEW_CLR_TARGET25, IA64_OPCODE_BR_WEXIT_SPNT_MANY_CLR_TARGET25, IA64_OPCODE_BR_WEXIT_DPTK_FEW_CLR_TARGET25, IA64_OPCODE_BR_WEXIT_DPTK_MANY_CLR_TARGET25, IA64_OPCODE_BR_WEXIT_DPNT_FEW_CLR_TARGET25, IA64_OPCODE_BR_WEXIT_DPNT_MANY_CLR_TARGET25, IA64_OPCODE_BR_WTOP_SPTK_FEW_TARGET25, IA64_OPCODE_BR_WTOP_SPTK_MANY_TARGET25, IA64_OPCODE_BR_WTOP_SPNT_FEW_TARGET25, IA64_OPCODE_BR_WTOP_SPNT_MANY_TARGET25, IA64_OPCODE_BR_WTOP_DPTK_FEW_TARGET25, IA64_OPCODE_BR_WTOP_DPTK_MANY_TARGET25, IA64_OPCODE_BR_WTOP_DPNT_FEW_TARGET25, IA64_OPCODE_BR_WTOP_DPNT_MANY_TARGET25, IA64_OPCODE_BR_WTOP_SPTK_FEW_CLR_TARGET25, IA64_OPCODE_BR_WTOP_SPTK_MANY_CLR_TARGET25, IA64_OPCODE_BR_WTOP_SPNT_FEW_CLR_TARGET25, IA64_OPCODE_BR_WTOP_SPNT_MANY_CLR_TARGET25, IA64_OPCODE_BR_WTOP_DPTK_FEW_CLR_TARGET25, IA64_OPCODE_BR_WTOP_DPTK_MANY_CLR_TARGET25, IA64_OPCODE_BR_WTOP_DPNT_FEW_CLR_TARGET25, IA64_OPCODE_BR_WTOP_DPNT_MANY_CLR_TARGET25, IA64_OPCODE_BR_CLOOP_SPTK_FEW_TARGET25, IA64_OPCODE_BR_CLOOP_SPTK_MANY_TARGET25, IA64_OPCODE_BR_CLOOP_SPNT_FEW_TARGET25, IA64_OPCODE_BR_CLOOP_SPNT_MANY_TARGET25, IA64_OPCODE_BR_CLOOP_DPTK_FEW_TARGET25, IA64_OPCODE_BR_CLOOP_DPTK_MANY_TARGET25, IA64_OPCODE_BR_CLOOP_DPNT_FEW_TARGET25, IA64_OPCODE_BR_CLOOP_DPNT_MANY_TARGET25, IA64_OPCODE_BR_CLOOP_SPTK_FEW_CLR_TARGET25, IA64_OPCODE_BR_CLOOP_SPTK_MANY_CLR_TARGET25, IA64_OPCODE_BR_CLOOP_SPNT_FEW_CLR_TARGET25, IA64_OPCODE_BR_CLOOP_SPNT_MANY_CLR_TARGET25, IA64_OPCODE_BR_CLOOP_DPTK_FEW_CLR_TARGET25, IA64_OPCODE_BR_CLOOP_DPTK_MANY_CLR_TARGET25, IA64_OPCODE_BR_CLOOP_DPNT_FEW_CLR_TARGET25, IA64_OPCODE_BR_CLOOP_DPNT_MANY_CLR_TARGET25, IA64_OPCODE_BR_CEXIT_SPTK_FEW_TARGET25, IA64_OPCODE_BR_CEXIT_SPTK_MANY_TARGET25, IA64_OPCODE_BR_CEXIT_SPNT_FEW_TARGET25, IA64_OPCODE_BR_CEXIT_SPNT_MANY_TARGET25, IA64_OPCODE_BR_CEXIT_DPTK_FEW_TARGET25, IA64_OPCODE_BR_CEXIT_DPTK_MANY_TARGET25, IA64_OPCODE_BR_CEXIT_DPNT_FEW_TARGET25, IA64_OPCODE_BR_CEXIT_DPNT_MANY_TARGET25, IA64_OPCODE_BR_CEXIT_SPTK_FEW_CLR_TARGET25, IA64_OPCODE_BR_CEXIT_SPTK_MANY_CLR_TARGET25, IA64_OPCODE_BR_CEXIT_SPNT_FEW_CLR_TARGET25, IA64_OPCODE_BR_CEXIT_SPNT_MANY_CLR_TARGET25, IA64_OPCODE_BR_CEXIT_DPTK_FEW_CLR_TARGET25, IA64_OPCODE_BR_CEXIT_DPTK_MANY_CLR_TARGET25, IA64_OPCODE_BR_CEXIT_DPNT_FEW_CLR_TARGET25, IA64_OPCODE_BR_CEXIT_DPNT_MANY_CLR_TARGET25, IA64_OPCODE_BR_CTOP_SPTK_FEW_TARGET25, IA64_OPCODE_BR_CTOP_SPTK_MANY_TARGET25, IA64_OPCODE_BR_CTOP_SPNT_FEW_TARGET25, IA64_OPCODE_BR_CTOP_SPNT_MANY_TARGET25, IA64_OPCODE_BR_CTOP_DPTK_FEW_TARGET25, IA64_OPCODE_BR_CTOP_DPTK_MANY_TARGET25, IA64_OPCODE_BR_CTOP_DPNT_FEW_TARGET25, IA64_OPCODE_BR_CTOP_DPNT_MANY_TARGET25, IA64_OPCODE_BR_CTOP_SPTK_FEW_CLR_TARGET25, IA64_OPCODE_BR_CTOP_SPTK_MANY_CLR_TARGET25, IA64_OPCODE_BR_CTOP_SPNT_FEW_CLR_TARGET25, IA64_OPCODE_BR_CTOP_SPNT_MANY_CLR_TARGET25, IA64_OPCODE_BR_CTOP_DPTK_FEW_CLR_TARGET25, IA64_OPCODE_BR_CTOP_DPTK_MANY_CLR_TARGET25, IA64_OPCODE_BR_CTOP_DPNT_FEW_CLR_TARGET25, IA64_OPCODE_BR_CTOP_DPNT_MANY_CLR_TARGET25, IA64_OPCODE_BR_CALL_SPTK_FEW_B1_TARGET25, IA64_OPCODE_BR_CALL_SPTK_MANY_B1_TARGET25, IA64_OPCODE_BR_CALL_SPNT_FEW_B1_TARGET25, IA64_OPCODE_BR_CALL_SPNT_MANY_B1_TARGET25, IA64_OPCODE_BR_CALL_DPTK_FEW_B1_TARGET25, IA64_OPCODE_BR_CALL_DPTK_MANY_B1_TARGET25, IA64_OPCODE_BR_CALL_DPNT_FEW_B1_TARGET25, IA64_OPCODE_BR_CALL_DPNT_MANY_B1_TARGET25, IA64_OPCODE_BR_CALL_SPTK_FEW_CLR_B1_TARGET25, IA64_OPCODE_BR_CALL_SPTK_MANY_CLR_B1_TARGET25, IA64_OPCODE_BR_CALL_SPNT_FEW_CLR_B1_TARGET25, IA64_OPCODE_BR_CALL_SPNT_MANY_CLR_B1_TARGET25, IA64_OPCODE_BR_CALL_DPTK_FEW_CLR_B1_TARGET25, IA64_OPCODE_BR_CALL_DPTK_MANY_CLR_B1_TARGET25, IA64_OPCODE_BR_CALL_DPNT_FEW_CLR_B1_TARGET25, IA64_OPCODE_BR_CALL_DPNT_MANY_CLR_B1_TARGET25, IA64_OPCODE_BR_COND_SPTK_FEW_B2, IA64_OPCODE_BR_COND_SPTK_MANY_B2, IA64_OPCODE_BR_COND_SPNT_FEW_B2, IA64_OPCODE_BR_COND_SPNT_MANY_B2, IA64_OPCODE_BR_COND_DPTK_FEW_B2, IA64_OPCODE_BR_COND_DPTK_MANY_B2, IA64_OPCODE_BR_COND_DPNT_FEW_B2, IA64_OPCODE_BR_COND_DPNT_MANY_B2, IA64_OPCODE_BR_COND_SPTK_FEW_CLR_B2, IA64_OPCODE_BR_COND_SPTK_MANY_CLR_B2, IA64_OPCODE_BR_COND_SPNT_FEW_CLR_B2, IA64_OPCODE_BR_COND_SPNT_MANY_CLR_B2, IA64_OPCODE_BR_COND_DPTK_FEW_CLR_B2, IA64_OPCODE_BR_COND_DPTK_MANY_CLR_B2, IA64_OPCODE_BR_COND_DPNT_FEW_CLR_B2, IA64_OPCODE_BR_COND_DPNT_MANY_CLR_B2, IA64_OPCODE_BR_IA_SPTK_FEW_B2, IA64_OPCODE_BR_IA_SPTK_MANY_B2, IA64_OPCODE_BR_IA_SPNT_FEW_B2, IA64_OPCODE_BR_IA_SPNT_MANY_B2, IA64_OPCODE_BR_IA_DPTK_FEW_B2, IA64_OPCODE_BR_IA_DPTK_MANY_B2, IA64_OPCODE_BR_IA_DPNT_FEW_B2, IA64_OPCODE_BR_IA_DPNT_MANY_B2, IA64_OPCODE_BR_IA_SPTK_FEW_CLR_B2, IA64_OPCODE_BR_IA_SPTK_MANY_CLR_B2, IA64_OPCODE_BR_IA_SPNT_FEW_CLR_B2, IA64_OPCODE_BR_IA_SPNT_MANY_CLR_B2, IA64_OPCODE_BR_IA_DPTK_FEW_CLR_B2, IA64_OPCODE_BR_IA_DPTK_MANY_CLR_B2, IA64_OPCODE_BR_IA_DPNT_FEW_CLR_B2, IA64_OPCODE_BR_IA_DPNT_MANY_CLR_B2, IA64_OPCODE_BR_RET_SPTK_FEW_B2, IA64_OPCODE_BR_RET_SPTK_MANY_B2, IA64_OPCODE_BR_RET_SPNT_FEW_B2, IA64_OPCODE_BR_RET_SPNT_MANY_B2, IA64_OPCODE_BR_RET_DPTK_FEW_B2, IA64_OPCODE_BR_RET_DPTK_MANY_B2, IA64_OPCODE_BR_RET_DPNT_FEW_B2, IA64_OPCODE_BR_RET_DPNT_MANY_B2, IA64_OPCODE_BR_RET_SPTK_FEW_CLR_B2, IA64_OPCODE_BR_RET_SPTK_MANY_CLR_B2, IA64_OPCODE_BR_RET_SPNT_FEW_CLR_B2, IA64_OPCODE_BR_RET_SPNT_MANY_CLR_B2, IA64_OPCODE_BR_RET_DPTK_FEW_CLR_B2, IA64_OPCODE_BR_RET_DPTK_MANY_CLR_B2, IA64_OPCODE_BR_RET_DPNT_FEW_CLR_B2, IA64_OPCODE_BR_RET_DPNT_MANY_CLR_B2, IA64_OPCODE_BR_CALL_SPTK_FEW_B1_B2, IA64_OPCODE_BR_CALL_SPTK_MANY_B1_B2, IA64_OPCODE_BR_CALL_SPNT_FEW_B1_B2, IA64_OPCODE_BR_CALL_SPNT_MANY_B1_B2, IA64_OPCODE_BR_CALL_DPTK_FEW_B1_B2, IA64_OPCODE_BR_CALL_DPTK_MANY_B1_B2, IA64_OPCODE_BR_CALL_DPNT_FEW_B1_B2, IA64_OPCODE_BR_CALL_DPNT_MANY_B1_B2, IA64_OPCODE_BR_CALL_SPTK_FEW_CLR_B1_B2, IA64_OPCODE_BR_CALL_SPTK_MANY_CLR_B1_B2, IA64_OPCODE_BR_CALL_SPNT_FEW_CLR_B1_B2, IA64_OPCODE_BR_CALL_SPNT_MANY_CLR_B1_B2, IA64_OPCODE_BR_CALL_DPTK_FEW_CLR_B1_B2, IA64_OPCODE_BR_CALL_DPTK_MANY_CLR_B1_B2, IA64_OPCODE_BR_CALL_DPNT_FEW_CLR_B1_B2, IA64_OPCODE_BR_CALL_DPNT_MANY_CLR_B1_B2, IA64_OPCODE_BRP_SPTK_TARGET25_TAG13, IA64_OPCODE_BRP_SPTK_IMP_TARGET25_TAG13, IA64_OPCODE_BRP_LOOP_TARGET25_TAG13, IA64_OPCODE_BRP_LOOP_IMP_TARGET25_TAG13, IA64_OPCODE_BRP_DPTK_TARGET25_TAG13, IA64_OPCODE_BRP_DPTK_IMP_TARGET25_TAG13, IA64_OPCODE_BRP_EXIT_TARGET25_TAG13, IA64_OPCODE_BRP_EXIT_IMP_TARGET25_TAG13, IA64_OPCODE_BRP_SPTK_B2_TAG13, IA64_OPCODE_BRP_SPTK_IMP_B2_TAG13, IA64_OPCODE_BRP_DPTK_B2_TAG13, IA64_OPCODE_BRP_DPTK_IMP_B2_TAG13, IA64_OPCODE_BRP_RET_SPTK_B2_TAG13, IA64_OPCODE_BRP_RET_SPTK_IMP_B2_TAG13, IA64_OPCODE_BRP_RET_DPTK_B2_TAG13, IA64_OPCODE_BRP_RET_DPTK_IMP_B2_TAG13, IA64_OPCODE_COVER, IA64_OPCODE_CLRRRB, IA64_OPCODE_CLRRRB_PR, IA64_OPCODE_RFI, IA64_OPCODE_RFI_X, IA64_OPCODE_BSW_0, IA64_OPCODE_BSW_1, IA64_OPCODE_EPC, IA64_OPCODE_BREAK_B_IMM21, IA64_OPCODE_NOP_B_IMM21, IA64_OPCODE_FMA_S0_F1_F3_F4_F2, IA64_OPCODE_FMA_S1_F1_F3_F4_F2, IA64_OPCODE_FMA_S2_F1_F3_F4_F2, IA64_OPCODE_FMA_S3_F1_F3_F4_F2, IA64_OPCODE_FMA_S_S0_F1_F3_F4_F2, IA64_OPCODE_FMA_S_S1_F1_F3_F4_F2, IA64_OPCODE_FMA_S_S2_F1_F3_F4_F2, IA64_OPCODE_FMA_S_S3_F1_F3_F4_F2, IA64_OPCODE_FMA_D_S0_F1_F3_F4_F2, IA64_OPCODE_FMA_D_S1_F1_F3_F4_F2, IA64_OPCODE_FMA_D_S2_F1_F3_F4_F2, IA64_OPCODE_FMA_D_S3_F1_F3_F4_F2, IA64_OPCODE_FPMA_S0_F1_F3_F4_F2, IA64_OPCODE_FPMA_S1_F1_F3_F4_F2, IA64_OPCODE_FPMA_S2_F1_F3_F4_F2, IA64_OPCODE_FPMA_S3_F1_F3_F4_F2, IA64_OPCODE_FMS_S0_F1_F3_F4_F2, IA64_OPCODE_FMS_S1_F1_F3_F4_F2, IA64_OPCODE_FMS_S2_F1_F3_F4_F2, IA64_OPCODE_FMS_S3_F1_F3_F4_F2, IA64_OPCODE_FMS_S_S0_F1_F3_F4_F2, IA64_OPCODE_FMS_S_S1_F1_F3_F4_F2, IA64_OPCODE_FMS_S_S2_F1_F3_F4_F2, IA64_OPCODE_FMS_S_S3_F1_F3_F4_F2, IA64_OPCODE_FMS_D_S0_F1_F3_F4_F2, IA64_OPCODE_FMS_D_S1_F1_F3_F4_F2, IA64_OPCODE_FMS_D_S2_F1_F3_F4_F2, IA64_OPCODE_FMS_D_S3_F1_F3_F4_F2, IA64_OPCODE_FPMS_S0_F1_F3_F4_F2, IA64_OPCODE_FPMS_S1_F1_F3_F4_F2, IA64_OPCODE_FPMS_S2_F1_F3_F4_F2, IA64_OPCODE_FPMS_S3_F1_F3_F4_F2, IA64_OPCODE_FNMA_S0_F1_F3_F4_F2, IA64_OPCODE_FNMA_S1_F1_F3_F4_F2, IA64_OPCODE_FNMA_S2_F1_F3_F4_F2, IA64_OPCODE_FNMA_S3_F1_F3_F4_F2, IA64_OPCODE_FNMA_S_S0_F1_F3_F4_F2, IA64_OPCODE_FNMA_S_S1_F1_F3_F4_F2, IA64_OPCODE_FNMA_S_S2_F1_F3_F4_F2, IA64_OPCODE_FNMA_S_S3_F1_F3_F4_F2, IA64_OPCODE_FNMA_D_S0_F1_F3_F4_F2, IA64_OPCODE_FNMA_D_S1_F1_F3_F4_F2, IA64_OPCODE_FNMA_D_S2_F1_F3_F4_F2, IA64_OPCODE_FNMA_D_S3_F1_F3_F4_F2, IA64_OPCODE_FPNMA_S0_F1_F3_F4_F2, IA64_OPCODE_FPNMA_S1_F1_F3_F4_F2, IA64_OPCODE_FPNMA_S2_F1_F3_F4_F2, IA64_OPCODE_FPNMA_S3_F1_F3_F4_F2, IA64_OPCODE_XMA_L_F1_F3_F4_F2, IA64_OPCODE_XMA_H_F1_F3_F4_F2, IA64_OPCODE_XMA_HU_F1_F3_F4_F2, IA64_OPCODE_FSELECT_F1_F3_F4_F2, IA64_OPCODE_FCMP_EQ_S0_P1_P2_F2_F3, IA64_OPCODE_FCMP_EQ_S1_P1_P2_F2_F3, IA64_OPCODE_FCMP_EQ_S2_P1_P2_F2_F3, IA64_OPCODE_FCMP_EQ_S3_P1_P2_F2_F3, IA64_OPCODE_FCMP_LT_S0_P1_P2_F2_F3, IA64_OPCODE_FCMP_LT_S1_P1_P2_F2_F3, IA64_OPCODE_FCMP_LT_S2_P1_P2_F2_F3, IA64_OPCODE_FCMP_LT_S3_P1_P2_F2_F3, IA64_OPCODE_FCMP_LE_S0_P1_P2_F2_F3, IA64_OPCODE_FCMP_LE_S1_P1_P2_F2_F3, IA64_OPCODE_FCMP_LE_S2_P1_P2_F2_F3, IA64_OPCODE_FCMP_LE_S3_P1_P2_F2_F3, IA64_OPCODE_FCMP_UNORD_S0_P1_P2_F2_F3, IA64_OPCODE_FCMP_UNORD_S1_P1_P2_F2_F3, IA64_OPCODE_FCMP_UNORD_S2_P1_P2_F2_F3, IA64_OPCODE_FCMP_UNORD_S3_P1_P2_F2_F3, IA64_OPCODE_FCMP_EQ_UNC_S0_P1_P2_F2_F3, IA64_OPCODE_FCMP_EQ_UNC_S1_P1_P2_F2_F3, IA64_OPCODE_FCMP_EQ_UNC_S2_P1_P2_F2_F3, IA64_OPCODE_FCMP_EQ_UNC_S3_P1_P2_F2_F3, IA64_OPCODE_FCMP_LT_UNC_S0_P1_P2_F2_F3, IA64_OPCODE_FCMP_LT_UNC_S1_P1_P2_F2_F3, IA64_OPCODE_FCMP_LT_UNC_S2_P1_P2_F2_F3, IA64_OPCODE_FCMP_LT_UNC_S3_P1_P2_F2_F3, IA64_OPCODE_FCMP_LE_UNC_S0_P1_P2_F2_F3, IA64_OPCODE_FCMP_LE_UNC_S1_P1_P2_F2_F3, IA64_OPCODE_FCMP_LE_UNC_S2_P1_P2_F2_F3, IA64_OPCODE_FCMP_LE_UNC_S3_P1_P2_F2_F3, IA64_OPCODE_FCMP_UNORD_UNC_S0_P1_P2_F2_F3, IA64_OPCODE_FCMP_UNORD_UNC_S1_P1_P2_F2_F3, IA64_OPCODE_FCMP_UNORD_UNC_S2_P1_P2_F2_F3, IA64_OPCODE_FCMP_UNORD_UNC_S3_P1_P2_F2_F3, IA64_OPCODE_FCLASS_M_P1_P2_F2_FCLASS9, IA64_OPCODE_FCLASS_M_UNC_P1_P2_F2_FCLASS9, IA64_OPCODE_FRCPA_S0_F1_P2_F2_F3, IA64_OPCODE_FRCPA_S1_F1_P2_F2_F3, IA64_OPCODE_FRCPA_S2_F1_P2_F2_F3, IA64_OPCODE_FRCPA_S3_F1_P2_F2_F3, IA64_OPCODE_FPRCPA_S0_F1_P2_F2_F3, IA64_OPCODE_FPRCPA_S1_F1_P2_F2_F3, IA64_OPCODE_FPRCPA_S2_F1_P2_F2_F3, IA64_OPCODE_FPRCPA_S3_F1_P2_F2_F3, IA64_OPCODE_FRSQRTA_S0_F1_P2_F3, IA64_OPCODE_FRSQRTA_S1_F1_P2_F3, IA64_OPCODE_FRSQRTA_S2_F1_P2_F3, IA64_OPCODE_FRSQRTA_S3_F1_P2_F3, IA64_OPCODE_FPRSQRTA_S0_F1_P2_F3, IA64_OPCODE_FPRSQRTA_S1_F1_P2_F3, IA64_OPCODE_FPRSQRTA_S2_F1_P2_F3, IA64_OPCODE_FPRSQRTA_S3_F1_P2_F3, IA64_OPCODE_FMIN_S0_F1_F2_F3, IA64_OPCODE_FMIN_S1_F1_F2_F3, IA64_OPCODE_FMIN_S2_F1_F2_F3, IA64_OPCODE_FMIN_S3_F1_F2_F3, IA64_OPCODE_FMAX_S0_F1_F2_F3, IA64_OPCODE_FMAX_S1_F1_F2_F3, IA64_OPCODE_FMAX_S2_F1_F2_F3, IA64_OPCODE_FMAX_S3_F1_F2_F3, IA64_OPCODE_FAMIN_S0_F1_F2_F3, IA64_OPCODE_FAMIN_S1_F1_F2_F3, IA64_OPCODE_FAMIN_S2_F1_F2_F3, IA64_OPCODE_FAMIN_S3_F1_F2_F3, IA64_OPCODE_FAMAX_S0_F1_F2_F3, IA64_OPCODE_FAMAX_S1_F1_F2_F3, IA64_OPCODE_FAMAX_S2_F1_F2_F3, IA64_OPCODE_FAMAX_S3_F1_F2_F3, IA64_OPCODE_FPMIN_S0_F1_F2_F3, IA64_OPCODE_FPMIN_S1_F1_F2_F3, IA64_OPCODE_FPMIN_S2_F1_F2_F3, IA64_OPCODE_FPMIN_S3_F1_F2_F3, IA64_OPCODE_FPMAX_S0_F1_F2_F3, IA64_OPCODE_FPMAX_S1_F1_F2_F3, IA64_OPCODE_FPMAX_S2_F1_F2_F3, IA64_OPCODE_FPMAX_S3_F1_F2_F3, IA64_OPCODE_FPAMIN_S0_F1_F2_F3, IA64_OPCODE_FPAMIN_S1_F1_F2_F3, IA64_OPCODE_FPAMIN_S2_F1_F2_F3, IA64_OPCODE_FPAMIN_S3_F1_F2_F3, IA64_OPCODE_FPAMAX_S0_F1_F2_F3, IA64_OPCODE_FPAMAX_S1_F1_F2_F3, IA64_OPCODE_FPAMAX_S2_F1_F2_F3, IA64_OPCODE_FPAMAX_S3_F1_F2_F3, IA64_OPCODE_FPCMP_EQ_S0_F1_F2_F3, IA64_OPCODE_FPCMP_EQ_S1_F1_F2_F3, IA64_OPCODE_FPCMP_EQ_S2_F1_F2_F3, IA64_OPCODE_FPCMP_EQ_S3_F1_F2_F3, IA64_OPCODE_FPCMP_LT_S0_F1_F2_F3, IA64_OPCODE_FPCMP_LT_S1_F1_F2_F3, IA64_OPCODE_FPCMP_LT_S2_F1_F2_F3, IA64_OPCODE_FPCMP_LT_S3_F1_F2_F3, IA64_OPCODE_FPCMP_LE_S0_F1_F2_F3, IA64_OPCODE_FPCMP_LE_S1_F1_F2_F3, IA64_OPCODE_FPCMP_LE_S2_F1_F2_F3, IA64_OPCODE_FPCMP_LE_S3_F1_F2_F3, IA64_OPCODE_FPCMP_UNORD_S0_F1_F2_F3, IA64_OPCODE_FPCMP_UNORD_S1_F1_F2_F3, IA64_OPCODE_FPCMP_UNORD_S2_F1_F2_F3, IA64_OPCODE_FPCMP_UNORD_S3_F1_F2_F3, IA64_OPCODE_FPCMP_NEQ_S0_F1_F2_F3, IA64_OPCODE_FPCMP_NEQ_S1_F1_F2_F3, IA64_OPCODE_FPCMP_NEQ_S2_F1_F2_F3, IA64_OPCODE_FPCMP_NEQ_S3_F1_F2_F3, IA64_OPCODE_FPCMP_NLT_S0_F1_F2_F3, IA64_OPCODE_FPCMP_NLT_S1_F1_F2_F3, IA64_OPCODE_FPCMP_NLT_S2_F1_F2_F3, IA64_OPCODE_FPCMP_NLT_S3_F1_F2_F3, IA64_OPCODE_FPCMP_NLE_S0_F1_F2_F3, IA64_OPCODE_FPCMP_NLE_S1_F1_F2_F3, IA64_OPCODE_FPCMP_NLE_S2_F1_F2_F3, IA64_OPCODE_FPCMP_NLE_S3_F1_F2_F3, IA64_OPCODE_FPCMP_ORD_S0_F1_F2_F3, IA64_OPCODE_FPCMP_ORD_S1_F1_F2_F3, IA64_OPCODE_FPCMP_ORD_S2_F1_F2_F3, IA64_OPCODE_FPCMP_ORD_S3_F1_F2_F3, IA64_OPCODE_FMERGE_S_F1_F2_F3, IA64_OPCODE_FMERGE_NS_F1_F2_F3, IA64_OPCODE_FMERGE_SE_F1_F2_F3, IA64_OPCODE_FMIX_LR_F1_F2_F3, IA64_OPCODE_FMIX_R_F1_F2_F3, IA64_OPCODE_FMIX_L_F1_F2_F3, IA64_OPCODE_FSXT_R_F1_F2_F3, IA64_OPCODE_FSXT_L_F1_F2_F3, IA64_OPCODE_FPACK_F1_F2_F3, IA64_OPCODE_FSWAP_F1_F2_F3, IA64_OPCODE_FSWAP_NL_F1_F2_F3, IA64_OPCODE_FSWAP_NR_F1_F2_F3, IA64_OPCODE_FAND_F1_F2_F3, IA64_OPCODE_FANDCM_F1_F2_F3, IA64_OPCODE_FOR_F1_F2_F3, IA64_OPCODE_FXOR_F1_F2_F3, IA64_OPCODE_FPMERGE_S_F1_F2_F3, IA64_OPCODE_FPMERGE_NS_F1_F2_F3, IA64_OPCODE_FPMERGE_SE_F1_F2_F3, IA64_OPCODE_FCVT_FX_S0_F1_F2, IA64_OPCODE_FCVT_FX_S1_F1_F2, IA64_OPCODE_FCVT_FX_S2_F1_F2, IA64_OPCODE_FCVT_FX_S3_F1_F2, IA64_OPCODE_FCVT_FXU_S0_F1_F2, IA64_OPCODE_FCVT_FXU_S1_F1_F2, IA64_OPCODE_FCVT_FXU_S2_F1_F2, IA64_OPCODE_FCVT_FXU_S3_F1_F2, IA64_OPCODE_FCVT_FX_TRUNC_S0_F1_F2, IA64_OPCODE_FCVT_FX_TRUNC_S1_F1_F2, IA64_OPCODE_FCVT_FX_TRUNC_S2_F1_F2, IA64_OPCODE_FCVT_FX_TRUNC_S3_F1_F2, IA64_OPCODE_FCVT_FXU_TRUNC_S0_F1_F2, IA64_OPCODE_FCVT_FXU_TRUNC_S1_F1_F2, IA64_OPCODE_FCVT_FXU_TRUNC_S2_F1_F2, IA64_OPCODE_FCVT_FXU_TRUNC_S3_F1_F2, IA64_OPCODE_FPCVT_FX_S0_F1_F2, IA64_OPCODE_FPCVT_FX_S1_F1_F2, IA64_OPCODE_FPCVT_FX_S2_F1_F2, IA64_OPCODE_FPCVT_FX_S3_F1_F2, IA64_OPCODE_FPCVT_FXU_S0_F1_F2, IA64_OPCODE_FPCVT_FXU_S1_F1_F2, IA64_OPCODE_FPCVT_FXU_S2_F1_F2, IA64_OPCODE_FPCVT_FXU_S3_F1_F2, IA64_OPCODE_FPCVT_FX_TRUNC_S0_F1_F2, IA64_OPCODE_FPCVT_FX_TRUNC_S1_F1_F2, IA64_OPCODE_FPCVT_FX_TRUNC_S2_F1_F2, IA64_OPCODE_FPCVT_FX_TRUNC_S3_F1_F2, IA64_OPCODE_FPCVT_FXU_TRUNC_S0_F1_F2, IA64_OPCODE_FPCVT_FXU_TRUNC_S1_F1_F2, IA64_OPCODE_FPCVT_FXU_TRUNC_S2_F1_F2, IA64_OPCODE_FPCVT_FXU_TRUNC_S3_F1_F2, IA64_OPCODE_FCVT_XF_F1_F2, IA64_OPCODE_FSETC_S0_AMASK7_OMASK7, IA64_OPCODE_FSETC_S1_AMASK7_OMASK7, IA64_OPCODE_FSETC_S2_AMASK7_OMASK7, IA64_OPCODE_FSETC_S3_AMASK7_OMASK7, IA64_OPCODE_FCLRF_S0, IA64_OPCODE_FCLRF_S1, IA64_OPCODE_FCLRF_S2, IA64_OPCODE_FCLRF_S3, IA64_OPCODE_FCHKF_S0_TARGET25, IA64_OPCODE_FCHKF_S1_TARGET25, IA64_OPCODE_FCHKF_S2_TARGET25, IA64_OPCODE_FCHKF_S3_TARGET25, IA64_OPCODE_BREAK_F_IMM21, IA64_OPCODE_NOP_F_IMM21, IA64_OPCODE_BREAK_X_IMM62, IA64_OPCODE_NOP_X_IMM62, IA64_OPCODE_MOVL_R1_IMM64, IA64_OPCODE_BRL_COND_SPTK_FEW_TARGET64, IA64_OPCODE_BRL_COND_SPTK_MANY_TARGET64, IA64_OPCODE_BRL_COND_SPNT_FEW_TARGET64, IA64_OPCODE_BRL_COND_SPNT_MANY_TARGET64, IA64_OPCODE_BRL_COND_DPTK_FEW_TARGET64, IA64_OPCODE_BRL_COND_DPTK_MANY_TARGET64, IA64_OPCODE_BRL_COND_DPNT_FEW_TARGET64, IA64_OPCODE_BRL_COND_DPNT_MANY_TARGET64, IA64_OPCODE_BRL_COND_SPTK_FEW_CLR_TARGET64, IA64_OPCODE_BRL_COND_SPTK_MANY_CLR_TARGET64, IA64_OPCODE_BRL_COND_SPNT_FEW_CLR_TARGET64, IA64_OPCODE_BRL_COND_SPNT_MANY_CLR_TARGET64, IA64_OPCODE_BRL_COND_DPTK_FEW_CLR_TARGET64, IA64_OPCODE_BRL_COND_DPTK_MANY_CLR_TARGET64, IA64_OPCODE_BRL_COND_DPNT_FEW_CLR_TARGET64, IA64_OPCODE_BRL_COND_DPNT_MANY_CLR_TARGET64, IA64_OPCODE_BRL_CALL_SPTK_FEW_B1_TARGET64, IA64_OPCODE_BRL_CALL_SPTK_MANY_B1_TARGET64, IA64_OPCODE_BRL_CALL_SPNT_FEW_B1_TARGET64, IA64_OPCODE_BRL_CALL_SPNT_MANY_B1_TARGET64, IA64_OPCODE_BRL_CALL_DPTK_FEW_B1_TARGET64, IA64_OPCODE_BRL_CALL_DPTK_MANY_B1_TARGET64, IA64_OPCODE_BRL_CALL_DPNT_FEW_B1_TARGET64, IA64_OPCODE_BRL_CALL_DPNT_MANY_B1_TARGET64, IA64_OPCODE_BRL_CALL_SPTK_FEW_CLR_B1_TARGET64, IA64_OPCODE_BRL_CALL_SPTK_MANY_CLR_B1_TARGET64, IA64_OPCODE_BRL_CALL_SPNT_FEW_CLR_B1_TARGET64, IA64_OPCODE_BRL_CALL_SPNT_MANY_CLR_B1_TARGET64, IA64_OPCODE_BRL_CALL_DPTK_FEW_CLR_B1_TARGET64, IA64_OPCODE_BRL_CALL_DPTK_MANY_CLR_B1_TARGET64, IA64_OPCODE_BRL_CALL_DPNT_FEW_CLR_B1_TARGET64, IA64_OPCODE_BRL_CALL_DPNT_MANY_CLR_B1_TARGET64, IA64_OPCODE_INST_LAST }; enum IA64EnumOperandRole { IA64_OPROLE_NONE = 0, IA64_OPROLE_SRC, IA64_OPROLE_DST, IA64_OPROLE_SRC_DST, IA64_OPROLE_DST_SRC, OPROLE_LAST }; enum IA64EnumOperandType { IA64_OPTYPE_NONE = 0, IA64_OPTYPE_REG_FIRST, /* The following types are registers */ IA64_OPTYPE_IREG, /* Integer register */ IA64_OPTYPE_IREG_R0_3, /* r0-r3 */ IA64_OPTYPE_IREG_R0, /* Integer register R0 */ IA64_OPTYPE_IREG_R1_127, /* r1-r127 */ IA64_OPTYPE_FREG, /* FP register */ IA64_OPTYPE_FREG_F2_127, /* f2-f127 */ IA64_OPTYPE_BR, /* branch register */ IA64_OPTYPE_IP, /* instruction pointer, not encoded */ IA64_OPTYPE_PREG, /* predicate */ IA64_OPTYPE_PREGS_ALL, /* the predicate register */ IA64_OPTYPE_PREGS_ROT, /* rotating predicates */ IA64_OPTYPE_APP_REG_GRP_LOW, /* application registers 0-63*/ IA64_OPTYPE_APP_REG_GRP_HIGH, /* application registers 64-127*/ IA64_OPTYPE_APP_CCV, /* ar.ccv */ IA64_OPTYPE_APP_PFS, /* ar.pfs */ IA64_OPTYPE_CR, /* control registers */ IA64_OPTYPE_PSR_L, /* psr.l */ IA64_OPTYPE_PSR_UM, /* psr.um */ IA64_OPTYPE_FPSR, /* decoder operand types */ IA64_OPTYPE_CFM, IA64_OPTYPE_PSR, IA64_OPTYPE_IFM, IA64_OPTYPE_REG_LAST, /* End of register - types */ IA64_OPTYPE_REGFILE_FIRST, /* The following types are register-files */ IA64_OPTYPE_PMC, IA64_OPTYPE_PMD, IA64_OPTYPE_PKR, IA64_OPTYPE_RR, IA64_OPTYPE_IBR, IA64_OPTYPE_DBR, IA64_OPTYPE_ITR, IA64_OPTYPE_DTR, IA64_OPTYPE_MSR, IA64_OPTYPE_CPUID, IA64_OPTYPE_REGFILE_LAST, /* End of register-file types */ IA64_OPTYPE_IMM_FIRST, /* The following types are immediates */ IA64_OPTYPE_UIMM, /* unsigned immediate */ IA64_OPTYPE_SIMM, /* signed immediate */ IA64_OPTYPE_IREG_NUM, /* ireg in syntax and imm7 in encodings */ IA64_OPTYPE_FREG_NUM, /* freg in syntax and imm7 in encodings */ IA64_OPTYPE_SSHIFT_REL, /* pc relative signed immediate which is shifted by 4 */ IA64_OPTYPE_SSHIFT_1, /* unsigned immediate which has to be shifted 1 bit */ IA64_OPTYPE_SSHIFT_16, /* unsigned immediate which has to be shifted 16 bits */ IA64_OPTYPE_COUNT_123, /* immediate which can have the values of 1, 2, 3 only */ IA64_OPTYPE_COUNT_PACK, /* immediate which can have the values of 0, 7, 15, 16 only */ IA64_OPTYPE_UDEC, /* unsigned immediate which has to be decremented by 1 by the assembler */ IA64_OPTYPE_SDEC, /* signed immediate which has to be decremented by 1 by the assembler */ IA64_OPTYPE_CCOUNT, /* in pshl[24] - uimm5 in syntax, but encoded as its 2's complement */ IA64_OPTYPE_CPOS, /* in dep fixed form - uimm6 in syntax, but encoded as its 2's complement */ IA64_OPTYPE_SEMAPHORE_INC, /* immediate which is a semaphore increment amount can have the values of -16,-8,-4,-1, 1,4,8,16 */ IA64_OPTYPE_ONE, /* the number 1 */ IA64_OPTYPE_FCLASS, /* immediate of the fclass instruction */ IA64_OPTYPE_CMP_UIMM, /* unsigned immediate of cmp geu and ltu */ IA64_OPTYPE_CMP_UIMM_DEC, /* unsigned immediate of cmp gtu and leu */ IA64_OPTYPE_CMP4_UIMM, /* unsigned immediate of cmp4 geu and ltu */ IA64_OPTYPE_CMP4_UIMM_DEC, /* unsigned immediate of cmp4 gtu and leu */ IA64_OPTYPE_ALLOC_IOL, /* for alloc : input, local, and output can be 0-96 */ IA64_OPTYPE_ALLOC_ROT, /* for alloc : rotating, can be 0-96 */ IA64_OPTYPE_MUX1, /* immediate of the mux1 instruction */ IA64_OPTYPE_EIGHT, /* immediate for ldfps base update form can have value 8 */ IA64_OPTYPE_SIXTEEN, /* immediate for ldfp8 and ldfpd base update form can have value 16 */ IA64_OPTYPE_IMM_LAST, /* End of immediate types */ IA64_OPTYPE_MEM, /* memory address */ IA64_OPTYPE_LAST }; enum IA64EnumOpcodeFormat { IA64_FORMAT_NONE = 0, IA64_FORMAT_A1, IA64_FORMAT_A2, IA64_FORMAT_A3, IA64_FORMAT_A4, IA64_FORMAT_A4_1, IA64_FORMAT_A5, IA64_FORMAT_A6, IA64_FORMAT_A6_1, IA64_FORMAT_A6_2, IA64_FORMAT_A6_3, IA64_FORMAT_A6_4, IA64_FORMAT_A6_5, IA64_FORMAT_A6_6, IA64_FORMAT_A6_7, IA64_FORMAT_A7, IA64_FORMAT_A7_1, IA64_FORMAT_A7_2, IA64_FORMAT_A7_3, IA64_FORMAT_A7_4, IA64_FORMAT_A7_5, IA64_FORMAT_A7_6, IA64_FORMAT_A7_7, IA64_FORMAT_A8, IA64_FORMAT_A8_1, IA64_FORMAT_A8_2, IA64_FORMAT_A8_3, IA64_FORMAT_A9, IA64_FORMAT_A10, IA64_FORMAT_I1, IA64_FORMAT_I2, IA64_FORMAT_I3, IA64_FORMAT_I4, IA64_FORMAT_I5, IA64_FORMAT_I6, IA64_FORMAT_I7, IA64_FORMAT_I8, IA64_FORMAT_I9, IA64_FORMAT_I10, IA64_FORMAT_I11, IA64_FORMAT_I12, IA64_FORMAT_I13, IA64_FORMAT_I14, IA64_FORMAT_I15, IA64_FORMAT_I16, IA64_FORMAT_I16_1, IA64_FORMAT_I16_2, IA64_FORMAT_I16_3, IA64_FORMAT_I17, IA64_FORMAT_I17_1, IA64_FORMAT_I17_2, IA64_FORMAT_I17_3, IA64_FORMAT_I19, IA64_FORMAT_I20, IA64_FORMAT_I21, IA64_FORMAT_I22, IA64_FORMAT_I23, IA64_FORMAT_I24, IA64_FORMAT_I25, IA64_FORMAT_I26, IA64_FORMAT_I27, IA64_FORMAT_I28, IA64_FORMAT_I29, IA64_FORMAT_M1, IA64_FORMAT_M2, IA64_FORMAT_M3, IA64_FORMAT_M4, IA64_FORMAT_M5, IA64_FORMAT_M6, IA64_FORMAT_M7, IA64_FORMAT_M8, IA64_FORMAT_M9, IA64_FORMAT_M10, IA64_FORMAT_M11, IA64_FORMAT_M12, IA64_FORMAT_M13, IA64_FORMAT_M14, IA64_FORMAT_M15, IA64_FORMAT_M16, IA64_FORMAT_M17, IA64_FORMAT_M18, IA64_FORMAT_M19, IA64_FORMAT_M20, IA64_FORMAT_M21, IA64_FORMAT_M22, IA64_FORMAT_M23, IA64_FORMAT_M24, IA64_FORMAT_M25, IA64_FORMAT_M26, IA64_FORMAT_M27, IA64_FORMAT_M28, IA64_FORMAT_M29, IA64_FORMAT_M30, IA64_FORMAT_M31, IA64_FORMAT_M32, IA64_FORMAT_M33, IA64_FORMAT_M34, IA64_FORMAT_M34_1, IA64_FORMAT_M35, IA64_FORMAT_M36, IA64_FORMAT_M37, IA64_FORMAT_M38, IA64_FORMAT_M39, IA64_FORMAT_M40, IA64_FORMAT_M41, IA64_FORMAT_M42, IA64_FORMAT_M43, IA64_FORMAT_M44, IA64_FORMAT_M45, IA64_FORMAT_M46, IA64_FORMAT_M1001, IA64_FORMAT_B1, IA64_FORMAT_B2, IA64_FORMAT_B3, IA64_FORMAT_B4, IA64_FORMAT_B5, IA64_FORMAT_B6, IA64_FORMAT_B7, IA64_FORMAT_B8, IA64_FORMAT_B9, IA64_FORMAT_F1, IA64_FORMAT_F1_1, IA64_FORMAT_F2, IA64_FORMAT_F3, IA64_FORMAT_F4, IA64_FORMAT_F4_1, IA64_FORMAT_F4_2, IA64_FORMAT_F4_3, IA64_FORMAT_F4_4, IA64_FORMAT_F4_5, IA64_FORMAT_F4_6, IA64_FORMAT_F4_7, IA64_FORMAT_F5, IA64_FORMAT_F5_1, IA64_FORMAT_F5_2, IA64_FORMAT_F5_3, IA64_FORMAT_F6, IA64_FORMAT_F7, IA64_FORMAT_F8, IA64_FORMAT_F8_4, IA64_FORMAT_F9, IA64_FORMAT_F9_1, IA64_FORMAT_F10, IA64_FORMAT_F11, IA64_FORMAT_F12, IA64_FORMAT_F13, IA64_FORMAT_F14, IA64_FORMAT_F15, IA64_FORMAT_X1, IA64_FORMAT_X2, IA64_FORMAT_X3, IA64_FORMAT_X4, IA64_FORMAT_X41, IA64_FORMAT_LAST }; enum IA64EnumOpcodeTemplateRole { IA64_TROLE_NONE = 0, IA64_TROLE_ALU, IA64_TROLE_BR, IA64_TROLE_FP, IA64_TROLE_INT, IA64_TROLE_LONG, IA64_TROLE_MEM, IA64_TROLE_MIBF, IA64_TROLE_LAST }; #define IA64_DECISION_TREE_LEAF_NODE(node) ((byte)((node).pos) == 0xff) struct IA64Template { byte stop; byte slot[3]; }; struct IA64DecisionTreeEntry { uint16 next_node; char pos; char size; }; struct IA64Operand { IA64EnumOperandRole role; IA64EnumOperandType type; }; struct IA64OpcodeEntry { const char *name; IA64EnumOpcodeFormat format; IA64EnumOpcodeTemplateRole role; IA64Operand op1; // FIXME make array IA64Operand op2; IA64Operand op3; IA64Operand op4; IA64Operand op5; IA64Operand op6; }; extern IA64Template IA64Templates[]; extern IA64DecisionTreeEntry IA64DecisionTree[]; extern IA64OpcodeEntry IA64OpcodeTable[]; #endif ht-2.0.22/asm/Makefile.in0000644000175000017500000003443312127657374012003 00000000000000# Makefile.in generated by automake 1.10.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = asm DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in TODO ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru libasm_a_AR = $(AR) $(ARFLAGS) libasm_a_LIBADD = am_libasm_a_OBJECTS = alphadis.$(OBJEXT) alphaopc.$(OBJEXT) \ asm.$(OBJEXT) x86asm.$(OBJEXT) x86dis.$(OBJEXT) \ x86opc.$(OBJEXT) javadis.$(OBJEXT) javaopc.$(OBJEXT) \ ildis.$(OBJEXT) ilopc.$(OBJEXT) ia64dis.$(OBJEXT) \ ia64opc.$(OBJEXT) ppcopc.$(OBJEXT) ppcdis.$(OBJEXT) \ armdis.$(OBJEXT) arm-dis.$(OBJEXT) libasm_a_OBJECTS = $(am_libasm_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libasm_a_SOURCES) DIST_SOURCES = $(libasm_a_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ HT_LDFLAGS = @HT_LDFLAGS@ HT_LIBS = @HT_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IO_DIR = @IO_DIR@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ LZO_LIBS = @LZO_LIBS@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ curses_CPPFLAGS = @curses_CPPFLAGS@ curses_LIBS = @curses_LIBS@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ ncurses_config = @ncurses_config@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/io/${IO_DIR} \ -I$(top_srcdir)/io AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_LIBRARIES = libasm.a libasm_a_SOURCES = alphadis.cc alphadis.h alphaopc.cc alphaopc.h\ asm.cc asm.h x86asm.cc x86asm.h x86dis.cc x86dis.h x86opc.cc x86opc.h\ javadis.cc javadis.h javaopc.cc javaopc.h ildis.cc ildis.h \ ilopc.cc ilopc.h ia64dis.cc ia64dis.h ia64opc.cc ia64opc.h \ ppcopc.cc ppcopc.h ppcdis.cc ppcdis.h armdis.cc armdis.h \ arm-dis.cc dis-asm.h arm.h all: all-am .SUFFIXES: .SUFFIXES: .cc .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign asm/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign asm/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libasm.a: $(libasm_a_OBJECTS) $(libasm_a_DEPENDENCIES) -rm -f libasm.a $(libasm_a_AR) libasm.a $(libasm_a_OBJECTS) $(libasm_a_LIBADD) $(RANLIB) libasm.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alphadis.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/alphaopc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arm-dis.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/armdis.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ia64dis.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ia64opc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ildis.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ilopc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/javadis.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/javaopc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcdis.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ppcopc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x86asm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x86dis.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/x86opc.Po@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ht-2.0.22/asm/TODO0000644000175000001440000000000010237143554010367 00000000000000ht-2.0.22/asm/x86asm.cc0000644000175000017500000015653212127651420011362 00000000000000/* * HT Editor * x86asm.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * Copyright (C) 2005-2007 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "x86asm.h" #include "snprintf.h" #include "strtools.h" enum { X86ASM_PREFIX_NO, X86ASM_PREFIX_0F, X86ASM_PREFIX_F20F, X86ASM_PREFIX_F30F, X86ASM_PREFIX_0F0F, X86ASM_PREFIX_0F38, X86ASM_PREFIX_660F38, X86ASM_PREFIX_F20F38, X86ASM_PREFIX_0F3A, X86ASM_PREFIX_660F3A, X86ASM_PREFIX_0F7A, X86ASM_PREFIX_0F7B, X86ASM_PREFIX_0F24, X86ASM_PREFIX_0F25, X86ASM_PREFIX_D8, X86ASM_PREFIX_D9, X86ASM_PREFIX_DA, X86ASM_PREFIX_DB, X86ASM_PREFIX_DC, X86ASM_PREFIX_DD, X86ASM_PREFIX_DE, X86ASM_PREFIX_DF, }; #define X86ASM_ERRMSG_AMBIGUOUS "ambiguous command" #define X86ASM_ERRMSG_UNKNOWN_COMMAND "unknown command '%s'" #define X86ASM_ERRMSG_INVALID_PREFIX "invalid prefix" #define X86ASM_ERRMSG_UNKNOWN_SYMBOL "unknown symbol '%s'" #define X86ASM_ERRMSG_INVALID_OPERANDS "invalid operand(s)" #define X86ASM_ERRMSG_INTERNAL "internal error: " #define rexw 0x48 #define rexr 0x44 #define rexx 0x42 #define rexb 0x41 static const x86addrcoding modrm16[3][8] = { /* mod = 0 */ { {X86_REG_BX, X86_REG_SI, 0}, {X86_REG_BX, X86_REG_DI, 0}, {X86_REG_BP, X86_REG_SI, 0}, {X86_REG_BP, X86_REG_DI, 0}, {X86_REG_SI, X86_REG_NO, 0}, {X86_REG_DI, X86_REG_NO, 0}, {X86_REG_NO, X86_REG_NO, 2}, {X86_REG_BX, X86_REG_NO, 0} }, /* mod = 1 */ { {X86_REG_BX, X86_REG_SI, 1}, {X86_REG_BX, X86_REG_DI, 1}, {X86_REG_BP, X86_REG_SI, 1}, {X86_REG_BP, X86_REG_DI, 1}, {X86_REG_SI, X86_REG_NO, 1}, {X86_REG_DI, X86_REG_NO, 1}, {X86_REG_BP, X86_REG_NO, 1}, {X86_REG_BX, X86_REG_NO, 1} }, /* mod = 2 */ { {X86_REG_BX, X86_REG_SI, 2}, {X86_REG_BX, X86_REG_DI, 2}, {X86_REG_BP, X86_REG_SI, 2}, {X86_REG_BP, X86_REG_DI, 2}, {X86_REG_SI, X86_REG_NO, 2}, {X86_REG_DI, X86_REG_NO, 2}, {X86_REG_BP, X86_REG_NO, 2}, {X86_REG_BX, X86_REG_NO, 2} } }; static const x86addrcoding modrm32[3][8] = { /* mod = 0 */ { {X86_REG_AX, X86_REG_NO, 0}, {X86_REG_CX, X86_REG_NO, 0}, {X86_REG_DX, X86_REG_NO, 0}, {X86_REG_BX, X86_REG_NO, 0}, {X86_REG_INVALID, X86_REG_INVALID, -1}, /* special: SIB */ {X86_REG_NO, X86_REG_NO, 4}, {X86_REG_SI, X86_REG_NO, 0}, {X86_REG_DI, X86_REG_NO, 0} }, /* mod = 1 */ { {X86_REG_AX, X86_REG_NO, 1}, {X86_REG_CX, X86_REG_NO, 1}, {X86_REG_DX, X86_REG_NO, 1}, {X86_REG_BX, X86_REG_NO, 1}, {X86_REG_INVALID, X86_REG_INVALID, -1}, /* special: SIB + disp8 */ {X86_REG_BP, X86_REG_NO, 1}, {X86_REG_SI, X86_REG_NO, 1}, {X86_REG_DI, X86_REG_NO, 1} }, /* mod = 2 */ { {X86_REG_AX, X86_REG_NO, 4}, {X86_REG_CX, X86_REG_NO, 4}, {X86_REG_DX, X86_REG_NO, 4}, {X86_REG_BX, X86_REG_NO, 4}, {X86_REG_INVALID, X86_REG_INVALID, -1}, /* special: SIB + disp32 */ {X86_REG_BP, X86_REG_NO, 4}, {X86_REG_SI, X86_REG_NO, 4}, {X86_REG_DI, X86_REG_NO, 4} } }; /* convert logical operand types to hardware operand types */ static const byte lop2hop[12][9] = { /* X86_OPTYPE_EMPTY */ {}, /* X86_OPTYPE_IMM */ {TYPE_I, TYPE_Is, TYPE_J, TYPE_A, TYPE_Ix, TYPE_I4}, /* X86_OPTYPE_REG */ {TYPE_R, TYPE_Rx, TYPE_RXx, TYPE_G, TYPE_E, TYPE_MR, TYPE_RV}, /* X86_OPTYPE_SEG */ {TYPE_S, TYPE_Sx}, /* X86_OPTYPE_MEM */ {TYPE_E, TYPE_M, TYPE_MR, TYPE_O, TYPE_Q, TYPE_W, TYPE_VS, TYPE_X}, /* X86_OPTYPE_CRX */ {TYPE_C}, /* X86_OPTYPE_DRX */ {TYPE_D}, /* X86_OPTYPE_STX */ {TYPE_F, TYPE_Fx}, /* X86_OPTYPE_MMX */ {TYPE_P, TYPE_Q, TYPE_PR}, /* X86_OPTYPE_XMM */ {TYPE_V, TYPE_W, TYPE_VR, TYPE_Vx, TYPE_VV, TYPE_VI, TYPE_VS, TYPE_VD}, /* X86_OPTYPE_YMM */ {TYPE_Y, TYPE_X, TYPE_YR, TYPE_YV, TYPE_YI}, /* X86_OPTYPE_FARPTR */ {}, }; static const char immhsz8_16[] = { SIZE_B, SIZE_BV, SIZE_W, SIZE_V, SIZE_VV, 0 }; static const char immhsz16_16[] = { SIZE_W, SIZE_V, SIZE_VV, 0 }; static const char immhsz32_16[] = { 0 }; static const char immhsz64_16[] = { 0 }; static const char immhsz8_32[] = { SIZE_B, SIZE_BV, SIZE_W, SIZE_V, SIZE_VV, 0 }; static const char immhsz16_32[] = { SIZE_W, SIZE_V, SIZE_VV, 0 }; static const char immhsz32_32[] = { SIZE_V, SIZE_VV, 0 }; static const char immhsz64_32[] = { 0 }; static const char immhsz8_64[] = { SIZE_B, SIZE_BV, SIZE_W, SIZE_V, SIZE_VV, 0 }; static const char immhsz16_64[] = { SIZE_W, SIZE_V, SIZE_VV, 0 }; static const char immhsz32_64[] = { SIZE_V, SIZE_VV, 0 }; static const char immhsz64_64[] = { SIZE_V, 0 }; static const char hsz8_16[] = { SIZE_B, 0 }; static const char hsz16_16[] = { SIZE_W, SIZE_V, SIZE_VV, 0 }; static const char hsz32_16[] = { SIZE_D, SIZE_P, SIZE_Z, SIZE_R, 0 }; static const char hsz48_16[] = { 0 }; static const char hsz64_16[] = { SIZE_Q, SIZE_U, SIZE_Z, 0}; static const char hsz128_16[] = { SIZE_O, SIZE_U, 0}; static const char hsz256_16[] = { SIZE_Y, 0}; static const char hsz8_32[] = { SIZE_B, 0 }; static const char hsz16_32[] = { SIZE_W, 0 }; static const char hsz32_32[] = { SIZE_D, SIZE_V, SIZE_VV, SIZE_R, SIZE_Z, 0 }; static const char hsz48_32[] = { SIZE_P, 0 }; static const char hsz64_32[] = { SIZE_Q, SIZE_U, SIZE_Z, 0}; static const char hsz128_32[] = { SIZE_O, SIZE_U, 0}; static const char hsz256_32[] = { SIZE_Y, 0}; static const char hsz8_64[] = { SIZE_B, 0 }; static const char hsz16_64[] = { SIZE_W, 0 }; static const char hsz32_64[] = { SIZE_D, SIZE_Z, 0 }; static const char hsz48_64[] = { 0 }; static const char hsz64_64[] = { SIZE_Q, SIZE_U, SIZE_V, SIZE_VV, SIZE_R, SIZE_Z, 0}; static const char hsz128_64[] = { SIZE_O, SIZE_U, 0}; static const char hsz256_64[] = { SIZE_Y, 0}; static const int reg2size[4] = {1, 2, 4, 8}; static const int addr2size[4] = {-1, 2, 4, 8}; /* * CLASS x86asm */ x86asm::x86asm(X86OpSize o, X86AddrSize a) : Assembler(false) { opsize = o; addrsize = a; if (a != X86_ADDRSIZE64) { prepInsns(); } } x86opc_insn (*x86asm::x86_32a_insns)[256]; void x86asm::prepInsns() { if (!x86_32a_insns) { x86_32a_insns = ht_malloc(sizeof *x86_32a_insns); memcpy(x86_32a_insns, x86_32_insns, sizeof x86_32_insns); (*x86_32a_insns)[0xc4] = x86_les; (*x86_32a_insns)[0xc5] = x86_lds; } x86_insns = x86_32a_insns; } asm_insn *x86asm::alloc_insn() { return ht_malloc(sizeof (x86asm_insn)); } x86dis *x86asm::createCompatibleDisassembler() { return new x86dis(opsize, addrsize); } void x86asm::delete_nonsense(CPU_ADDR addr) { x86dis *dis = createCompatibleDisassembler(); restart: asm_code *c=codes; while (c) { if (delete_nonsense_insn(c, dis, addr)) goto restart; c = c->next; } delete dis; } static void skip_prefixes(byte **p, int &sizep, int addrsize) { while (sizep > 0) { if (**p == 0x66 || **p == 0x67 || **p == 0xf2 || **p == 0xf3 || (addrsize == X86_ADDRSIZE64 && (**p & 0xf0) == 0x40)) { sizep--; (*p)++; } else { break; } } } static bool cmp_insn_normal(byte *p, int sizep, byte *q, int sizeq, int addrsize, x86dis *dis, CPU_ADDR addr) { // UGLY: compare disassembly char s[200]; dis_insn *d = dis->decode(p, sizep, addr); ht_strlcpy(s, dis->str(d, X86DIS_STYLE_EXPLICIT_MEMSIZE), sizeof s); d = dis->decode(q, sizeq, addr); if (strcmp(s, dis->str(d, X86DIS_STYLE_EXPLICIT_MEMSIZE))) return false; // different disassembly --> not the same // compare opcodes (w/o prefixes) skip_prefixes(&p, sizep, addrsize); skip_prefixes(&q, sizeq, addrsize); if (sizep != sizeq) return false; // -> different raw opcodes --> not the same return memcmp(p, q, sizep) == 0; } bool x86asm::delete_nonsense_insn(asm_code *code, x86dis *dis, CPU_ADDR addr) { asm_code *c = codes; while (c) { if (c != code && code->size <= c->size) { if (cmp_insn_normal(c->data, c->size, code->data, code->size, addrsize, dis, addr)) { deletecode(c); return true; } } c = c->next; } return false; } void x86asm::emitdisp(uint64 d, int size) { dispsize = size; disp = d; } void x86asm::emitimm(uint64 i, int size) { immsize = size; imm = i; } void x86asm::emitfarptr(uint32 s, uint32 o, bool big) { if (big) { immsize = 6; imm = o; imm2 = s; } else { immsize = 4; imm = (s<<16) | (o & 0xffff); } } void x86asm::emitmodrm(int modrm) { modrmv = modrm; } void x86asm::emitmodrm_mod(int mod) { if (modrmv == -1) modrmv = 0; modrmv = (modrmv & ~(3<<6)) | ((mod & 3)<<6); } void x86asm::emitmodrm_reg(int reg) { if (modrmv == -1) modrmv = 0; modrmv = (modrmv & ~(7<<3)) | ((reg & 7)<<3); } void x86asm::emitmodrm_rm(int rm) { if (modrmv == -1) modrmv = 0; modrmv = (modrmv & ~7) | (rm & 7); } void x86asm::emitsib_base(int base) { if (sibv == -1) sibv = 0; sibv = (sibv & ~7) | (base & 7); } void x86asm::emitsib_index(int index) { if (sibv == -1) sibv = 0; sibv = (sibv & ~(7<<3)) | ((index & 7)<<3); } void x86asm::emitsib_scale(int scale) { if (sibv == -1) sibv = 0; sibv = (sibv & ~(3<<6)) | ((scale & 3)<<6); } #define MATCHOPNAME_NOMATCH 0 #define MATCHOPNAME_MATCH 1 #define MATCHOPNAME_MATCH_IF_OPSIZE16 2 #define MATCHOPNAME_MATCH_IF_OPSIZE32 3 #define MATCHOPNAME_MATCH_IF_OPSIZE64 4 #define MATCHOPNAME_MATCH_IF_ADDRSIZE16 5 #define MATCHOPNAME_MATCH_IF_ADDRSIZE32 6 #define MATCHOPNAME_MATCH_IF_ADDRSIZE64 7 #define MATCHOPNAME_MATCH_IF_OPPREFIX 8 #define MATCHOPNAME_MATCH_IF_NOOPPREFIX 9 asm_code *x86asm::encode(asm_insn *asm_insn, int options, CPU_ADDR cur_address) { Assembler::encode(asm_insn, options, cur_address); x86asm_insn *insn = (x86asm_insn*)asm_insn; newcode(); namefound = false; if (addrsize == X86_ADDRSIZE64) { address = cur_address.flat64.addr; } else { address = cur_address.addr32.offset; } esizes[0] = 0; esizes[1] = 0; esizes[2] = 0; esizes[3] = 0; esizes[4] = 0; ambiguous = false; match_opcodes(*x86_insns, insn, X86ASM_PREFIX_NO, MATCHOPNAME_MATCH); if (!namefound && insn->repprefix != X86_PREFIX_NO) { set_error_msg(X86ASM_ERRMSG_INVALID_PREFIX); } else { match_fopcodes(insn); match_opcodes(x86_insns_ext, insn, X86ASM_PREFIX_0F, MATCHOPNAME_MATCH_IF_NOOPPREFIX); match_opcodes(x86_insns_ext_66, insn, X86ASM_PREFIX_0F, MATCHOPNAME_MATCH_IF_OPPREFIX); match_opcodes(x86_insns_ext_f2, insn, X86ASM_PREFIX_F20F, MATCHOPNAME_MATCH_IF_NOOPPREFIX); match_opcodes(x86_insns_ext_f3, insn, X86ASM_PREFIX_F30F, MATCHOPNAME_MATCH_IF_NOOPPREFIX); match_opcodes(x86_opc_group_insns[0], insn, X86ASM_PREFIX_0F38, MATCHOPNAME_MATCH_IF_NOOPPREFIX); match_opcodes(x86_opc_group_insns[1], insn, X86ASM_PREFIX_660F38, MATCHOPNAME_MATCH_IF_OPPREFIX); match_opcodes(x86_opc_group_insns[2], insn, X86ASM_PREFIX_F20F38, MATCHOPNAME_MATCH_IF_NOOPPREFIX); match_opcodes(x86_opc_group_insns[3], insn, X86ASM_PREFIX_0F3A, MATCHOPNAME_MATCH_IF_NOOPPREFIX); match_opcodes(x86_opc_group_insns[4], insn, X86ASM_PREFIX_660F3A, MATCHOPNAME_MATCH_IF_OPPREFIX); match_opcodes(x86_opc_group_insns[5], insn, X86ASM_PREFIX_0F7A, MATCHOPNAME_MATCH_IF_NOOPPREFIX); match_opcodes(x86_opc_group_insns[6], insn, X86ASM_PREFIX_0F7B, MATCHOPNAME_MATCH_IF_NOOPPREFIX); match_opcodes(x86_opc_group_insns[7], insn, X86ASM_PREFIX_0F24, MATCHOPNAME_MATCH_IF_NOOPPREFIX); match_opcodes(x86_opc_group_insns[8], insn, X86ASM_PREFIX_0F25, MATCHOPNAME_MATCH_IF_NOOPPREFIX); match_vex_opcodes(insn); } if (error) { free_asm_codes(); } else if (!codes) { if (namefound) { set_error_msg(X86ASM_ERRMSG_INVALID_OPERANDS); } else { set_error_msg(X86ASM_ERRMSG_UNKNOWN_COMMAND, insn->name); } } else { delete_nonsense(cur_address); } return codes; } bool x86asm::encode_insn(x86asm_insn *insn, x86opc_insn *opcode, int opcodeb, int additional_opcode, int prefix, int eopsize, int eaddrsize) { rexprefix = 0; disppos = 0; bool opsize_depend = false; for (int i = 0; i < 4; i++) { switch (x86_op_type[opcode->op[i]].size) { case SIZE_BV: case SIZE_V: case SIZE_VV: case SIZE_P: opsize_depend = true; break; } } code.context = (void*)opsize_depend; /* test rex thingies */ for (int i=0; i < 4; i++) { if (insn->op[i].need_rex) { rexprefix |= 0x40; } if (insn->op[i].forbid_rex) { rexprefix |= 0x80; } } modrmv = -1; sibv = -1; drexdest = -1; drexoc0 = -1; dispsize = 0; immsize = 0; if (additional_opcode != -1) { if (additional_opcode & 0x800) { emitmodrm_mod(3); emitmodrm_reg(additional_opcode & 0x7); emitmodrm_rm((additional_opcode >> 3) & 0x7); } else { emitmodrm_reg(additional_opcode); } } if (addrsize == X86_ADDRSIZE64) { if (eopsize == X86_ADDRSIZE64) { if (insn->opsizeprefix == X86_PREFIX_OPSIZE) emitbyte(0x66); if (!(x86_op_type[opcode->op[0]].info & INFO_DEFAULT_64)) { // instruction doesn't default to 64 bit opsize rexprefix |= rexw; } } else if (eopsize == X86_ADDRSIZE32) { if (x86_op_type[opcode->op[0]].info & INFO_DEFAULT_64) { // instruction defaults to 64 bit opsize // it's not possible to switch to 32 bit return false; } if (insn->opsizeprefix == X86_PREFIX_OPSIZE) emitbyte(0x66); } else if (eopsize == X86_ADDRSIZE16) { if (insn->opsizeprefix == X86_PREFIX_NOOPSIZE) return false; emitbyte(0x66); } if (eaddrsize == X86_ADDRSIZE16) return false; if (eaddrsize == X86_ADDRSIZE32) emitbyte(0x67); } else { if (eopsize != opsize || insn->opsizeprefix == X86_PREFIX_OPSIZE) { if (insn->opsizeprefix == X86_PREFIX_NOOPSIZE) return false; emitbyte(0x66); } if (eaddrsize != addrsize) emitbyte(0x67); } if ((rexprefix & 0xc0) == 0xc0) { // can't combine insns which simultaneously need REX and forbid REX clearcode(); return false; } /* write lock, rep and/or seg prefixes if needed */ switch (insn->lockprefix) { case X86_PREFIX_LOCK: emitbyte(0xf0); break; } switch (insn->repprefix) { case X86_PREFIX_REPNZ: emitbyte(0xf2); break; case X86_PREFIX_REPZ: emitbyte(0xf3); break; } switch (insn->segprefix) { case X86_PREFIX_ES: emitbyte(0x26); break; case X86_PREFIX_CS: emitbyte(0x2e); break; case X86_PREFIX_SS: emitbyte(0x36); break; case X86_PREFIX_DS: emitbyte(0x3e); break; case X86_PREFIX_FS: emitbyte(0x64); break; case X86_PREFIX_GS: emitbyte(0x65); break; } switch (prefix) { case X86ASM_PREFIX_F20F: case X86ASM_PREFIX_F20F38: emitbyte(0xf2); break; case X86ASM_PREFIX_F30F: emitbyte(0xf3); break; } int rexpos = code.size; if ((rexprefix & 0x40) && prefix != X86ASM_PREFIX_0F24 && prefix != X86ASM_PREFIX_0F25) { emitbyte(0xff); // dummy value } /* write opcodeprefixes and opcode */ switch (prefix) { case X86ASM_PREFIX_0F0F: emitbyte(0x0f); case X86ASM_PREFIX_F20F: case X86ASM_PREFIX_F30F: case X86ASM_PREFIX_0F: emitbyte(0x0f); case X86ASM_PREFIX_NO: break; case X86ASM_PREFIX_0F38: case X86ASM_PREFIX_660F38: case X86ASM_PREFIX_F20F38: emitbyte(0x0f); emitbyte(0x38); break; case X86ASM_PREFIX_0F3A: case X86ASM_PREFIX_660F3A: emitbyte(0x0f); emitbyte(0x3a); break; case X86ASM_PREFIX_0F24: emitbyte(0x0f); emitbyte(0x24); break; case X86ASM_PREFIX_0F25: emitbyte(0x0f); emitbyte(0x25); break; case X86ASM_PREFIX_0F7A: emitbyte(0x0f); emitbyte(0x7a); break; case X86ASM_PREFIX_0F7B: emitbyte(0x0f); emitbyte(0x7b); break; case X86ASM_PREFIX_DF: case X86ASM_PREFIX_DE: case X86ASM_PREFIX_DD: case X86ASM_PREFIX_DC: case X86ASM_PREFIX_DB: case X86ASM_PREFIX_DA: case X86ASM_PREFIX_D9: case X86ASM_PREFIX_D8: opcodeb = 0xd8 + prefix - X86ASM_PREFIX_D8; break; } emitbyte(opcodeb); /* encode the ops */ for (int i=0; i < 4; i++) { if (!encode_op(&insn->op[i], &x86_op_type[opcode->op[i]], &esizes[i], eopsize, eaddrsize)) { clearcode(); return false; } } /* write the rest */ if (modrmv != -1) emitbyte(modrmv); if (sibv != -1) emitbyte(sibv); if (drexdest != -1) { byte oc0 = 0; if (drexoc0 != -1) { oc0 = drexoc0; } byte drex = (drexdest << 4) | (oc0 << 3) | (rexprefix & 7); rexprefix = 0; emitbyte(drex); } if (disppos && addrsize == X86_ADDRSIZE64) { // fix ip-relative disp in PM64 mode dispsize = 4; disp -= address + code.size + dispsize + immsize; if (simmsize(disp, 4) > 4) { clearcode(); return false; } } switch (dispsize) { case 1: emitbyte(disp); break; case 2: emitword(disp); break; case 4: emitdword(disp); break; case 8: emitqword(disp); break; } switch (immsize) { case 1: emitbyte(imm); break; case 2: emitword(imm); break; case 4: emitdword(imm); break; case 6: emitdword(imm); emitword(imm2); break; case 8: emitqword(imm); break; } // fix rex code if (rexprefix & 0x40) { code.data[rexpos] = rexprefix; } return true; } bool x86asm::encode_vex_insn(x86asm_insn *insn, x86opc_vex_insn *opcode, int opcodeb, int additional_opcode, int eopsize, int eaddrsize) { rexprefix = 0; disppos = 0; immsize = 0; dispsize = 0; vexvvvv = 0; modrmv = -1; sibv = -1; if (additional_opcode != -1) { emitmodrm_reg(additional_opcode); } switch (insn->lockprefix) { case X86_PREFIX_LOCK: clearcode(); return false; } switch (insn->repprefix) { case X86_PREFIX_REPNZ: case X86_PREFIX_REPZ: clearcode(); return false; } if (addrsize == X86_ADDRSIZE64) { if (eaddrsize == X86_ADDRSIZE16) return false; if (eaddrsize == X86_ADDRSIZE32) emitbyte(0x67); } else { if (eaddrsize != addrsize) emitbyte(0x67); } switch (insn->segprefix) { case X86_PREFIX_ES: emitbyte(0x26); break; case X86_PREFIX_CS: emitbyte(0x2e); break; case X86_PREFIX_SS: emitbyte(0x36); break; case X86_PREFIX_DS: emitbyte(0x3e); break; case X86_PREFIX_FS: emitbyte(0x64); break; case X86_PREFIX_GS: emitbyte(0x65); break; } for (int i=0; i < 5; i++) { if (!encode_op(&insn->op[i], &x86_op_type[opcode->op[i]], &esizes[i], eopsize, eaddrsize)) { clearcode(); return false; } } if ((opcode->vex & 0x3c) == 0x4 // 0x0f-opcode && !(rexprefix & 3) // no rexb/rexx && !(opcode->vex & W1)) { // use short vex prefix emitbyte(0xc5); byte vex = (~rexprefix & 4) << 5 | ((~vexvvvv & 0xf) << 3) | (opcode->vex & _256) >> 4 | (opcode->vex & 0x3); emitbyte(vex); } else { // use long vex/xop prefix if (opcode->vex & _0f24) { emitbyte(0x8f); } else { emitbyte(0xc4); } byte vex = (~rexprefix & 7) << 5 | ((opcode->vex & 0x3c) >> 2); emitbyte(vex); vex = (opcode->vex & W1) | ((~vexvvvv & 0xf) << 3) | (opcode->vex & _256) >> 4 | (opcode->vex & 0x3); emitbyte(vex); } emitbyte(opcodeb); if (modrmv != -1) emitbyte(modrmv); if (sibv != -1) emitbyte(sibv); if (disppos && addrsize == X86_ADDRSIZE64) { // fix ip-relative disp in PM64 mode dispsize = 4; disp -= address + code.size + dispsize + immsize; if (simmsize(disp, 4) > 4) { clearcode(); return false; } } switch (dispsize) { case 1: emitbyte(disp); break; case 2: emitword(disp); break; case 4: emitdword(disp); break; } switch (immsize) { case 1: emitbyte(imm); break; } return true; } bool x86asm::encode_modrm(x86_insn_op *op, char size, bool allow_reg, bool allow_mem, int eopsize, int eaddrsize) { switch (op->type) { case X86_OPTYPE_REG: if (!allow_reg) return false; emitmodrm_mod(3); emitmodrm_rm(op->reg); if (op->reg > 7) rexprefix |= rexb; break; case X86_OPTYPE_MEM: { if (!allow_mem) return false; int addrsize = op->mem.addrsize; int mindispsize = addr2size[addrsize+1]; if (addrsize == X86_ADDRSIZEUNKNOWN) { addrsize = eaddrsize; if (this->addrsize == X86_ADDRSIZE64) { // ip-relative, we check this later mindispsize = 4; } else { mindispsize = op->mem.disp ? simmsize(op->mem.disp, 8) : 0; } } else { mindispsize = op->mem.disp ? simmsize(op->mem.disp, mindispsize) : 0; if (mindispsize > 4) return false; } if (addrsize == X86_ADDRSIZE16) { int mod, rm, dispsize; if (!encode_modrm_v(&modrm16, op, mindispsize, &mod, &rm, &dispsize)) return 0; emitmodrm_mod(mod); emitmodrm_rm(rm); emitdisp(op->mem.disp, dispsize); } else { int mod, rm, dispsize; if (!encode_modrm_v(&modrm32, op, mindispsize, &mod, &rm, &dispsize)) { int scale, index, base, disp=op->mem.disp; if (encode_sib_v(op, mindispsize, &scale, &index, &base, &mod, &dispsize, &disp)) { emitmodrm_mod(mod); emitmodrm_rm(4); /* SIB */ emitsib_scale(scale); emitsib_index(index); emitsib_base(base); emitdisp(disp, dispsize); } else return false; } else { emitmodrm_mod(mod); emitmodrm_rm(rm); emitdisp(op->mem.disp, dispsize); } } break; } case X86_OPTYPE_MMX: if (!allow_reg) return false; emitmodrm_mod(3); emitmodrm_rm(op->mmx); break; case X86_OPTYPE_XMM: if (!allow_reg) return false; emitmodrm_mod(3); emitmodrm_rm(op->xmm); if (op->xmm > 7) rexprefix |= rexb; break; case X86_OPTYPE_YMM: if (!allow_reg) return false; emitmodrm_mod(3); emitmodrm_rm(op->ymm); if (op->ymm > 7) rexprefix |= rexb; break; default: return false; } return true; } bool x86asm::encode_modrm_v(const x86addrcoding (*modrmc)[3][8], x86_insn_op *op, int mindispsize, int *_mod, int *_rm, int *_dispsize) { if (op->mem.scale > 1) return false; for (int mod=0; mod < 3; mod++) { for (int rm=0; rm < 8; rm++) { const x86addrcoding *c = &(*modrmc)[mod][rm]; int r1 = c->reg1; int r2 = c->reg2; if (r2 == (op->mem.base & ~8)) { int t = r1; r1 = r2; r2 = t; } if (r1==(op->mem.base&~8) && r2==(op->mem.index&~8) && c->dispsize>=mindispsize) { *_mod=mod; *_rm=rm; *_dispsize=c->dispsize; if (this->addrsize == X86_ADDRSIZE64 && mod == 0 && rm == 5) { // ip-relative addressing disppos = 1; } if (op->mem.base & 8) rexprefix |= rexb; return true; } } } return false; } bool x86asm::encode_op(x86_insn_op *op, x86opc_insn_op *xop, int *esize, int eopsize, int eaddrsize) { int psize = op->size; switch (xop->type) { case TYPE_0: return true; case TYPE_A: /* direct address without ModR/M */ if (op->type == X86_OPTYPE_FARPTR) { int size = esizeop_ex(xop->size, eopsize); emitfarptr(op->farptr.seg, op->farptr.offset, size == 6); } else { emitimm(op->imm, op->size); } break; case TYPE_C: /* reg of ModR/M picks control register */ emitmodrm_reg(op->crx); if (op->crx > 7) rexprefix |= rexr; break; case TYPE_D: /* reg of ModR/M picks debug register */ emitmodrm_reg(op->drx); if (op->drx > 7) rexprefix |= rexr; break; case TYPE_E: /* ModR/M (general reg or memory) */ if (!encode_modrm(op, xop->size, true, true, eopsize, eaddrsize)) return false; //XXX psize = esizeop(xop->size, eopsize); //XXX break; case TYPE_F: /* r/m of ModR/M picks a fpu register */ emitmodrm_rm(op->stx); break; case TYPE_Fx: /* extra picks a fpu register */ return true; case TYPE_G: /* reg of ModR/M picks general register */ emitmodrm_reg(op->reg); if (op->reg > 7) rexprefix |= rexr; break; case TYPE_Is: { /* signed immediate */ int size = esizeop_ex(xop->size, eopsize); emitimm(op->imm, size); break; } case TYPE_I: { /* unsigned immediate */ int size = esizeop_ex(xop->size, eopsize); emitimm(op->imm, size); break; } case TYPE_Ix: /* fixed immediate */ return true; case TYPE_I4: { /* 4 bit immediate (see TYPE_VI, TYPE_YI) */ if (op->imm > 15) return false; if (immsize == 0) { immsize = 1; imm = 0; } imm |= op->imm; break; } case TYPE_J: { /* relative branch offset */ int size = esizeop_ex(xop->size, eopsize); emitimm(uint32(op->imm - address - code.size - size), size); break; } case TYPE_M: /* ModR/M (memory only) */ if (!encode_modrm(op, xop->size, false, true, eopsize, eaddrsize)) return false; // XXX psize = esizeop(xop->size, eopsize); //XXX break; case TYPE_MR: { /* Same as E, but extra picks reg size */ byte xopsize = xop->size; if (op->type == X86_OPTYPE_REG) { xopsize = xop->extra; } if (!encode_modrm(op, xopsize, true, true, eopsize, eaddrsize)) return false; //XXX psize = esizeop(xopsize, eopsize); //XXX break; } case TYPE_O: { /* direct memory without ModR/M */ if (op->mem.base != X86_REG_NO) return false; if (op->mem.index != X86_REG_NO) return false; psize = esizeop(xop->size, eopsize); // XXX switch (eaddrsize) { case X86_ADDRSIZE16: if (op->mem.disp > 0xffff) return false; emitdisp(op->mem.disp, 2); break; case X86_ADDRSIZE32: if (op->mem.disp > 0xffffffff) return false; emitdisp(op->mem.disp, 4); break; case X86_ADDRSIZE64: emitdisp(op->mem.disp, 8); break; } break; } case TYPE_P: /* reg of ModR/M picks MMX register */ emitmodrm_reg(op->mmx); break; case TYPE_PR: /* rm of ModR/M picks MMX register */ emitmodrm_mod(3); emitmodrm_rm(op->mmx); break; case TYPE_Q: /* ModR/M (MMX reg or memory) */ if (!encode_modrm(op, xop->size, true, true, eopsize, eaddrsize)) return false; //XXX psize = esizeop(xop->size, eopsize); //XXX break; case TYPE_R: /* rm of ModR/M picks general register */ emitmodrm_mod(3); emitmodrm_rm(op->reg); // fall throu case TYPE_Rx: if (op->reg > 7) rexprefix |= rexb; return true; case TYPE_RXx: /* extra picks register, no REX */ return true; case TYPE_RV: /* VEX.vvvv picks general register */ vexvvvv = op->reg; return true; case TYPE_S: /* reg of ModR/M picks segment register */ emitmodrm_reg(op->seg); break; case TYPE_Sx: /* extra picks segment register */ return true; case TYPE_V: /* reg of ModR/M picks XMM register */ emitmodrm_reg(op->xmm); if (op->xmm > 7) rexprefix |= rexr; break; case TYPE_VR: /* rm of ModR/M picks XMM register */ emitmodrm_mod(3); emitmodrm_rm(op->xmm); if (op->xmm > 7) rexprefix |= rexb; break; case TYPE_Vx: break; case TYPE_VV: vexvvvv = op->xmm; break; case TYPE_VI: { /* bits 7-4 of imm pick XMM register */ if (immsize == 0) { immsize = 1; imm = 0; } imm |= op->xmm << 4; break; } case TYPE_VD: if (drexdest == -1) { drexdest = op->xmm; } else { if (drexdest != op->xmm) { return false; } } break; case TYPE_VS: if (op->type == X86_OPTYPE_XMM) { if (drexoc0 == 0) { emitmodrm_mod(3); emitmodrm_rm(op->xmm); if (op->xmm > 7) rexprefix |= rexb; } else { emitmodrm_reg(op->xmm); if (op->xmm > 7) rexprefix |= rexr; if (drexoc0 == -1) drexoc0 = 0; } } else { if (drexoc0 == 1) return false; if (drexoc0 == -1) { if (xop->info) return false; drexoc0 = 1; } if (!encode_modrm(op, xop->size, true, true, eopsize, eaddrsize)) return false; //XXX psize = esizeop(xop->size, eopsize); //XXX } break; case TYPE_W: case TYPE_X: /* ModR/M (XMM/YMM reg or memory) */ if (!encode_modrm(op, xop->size, true, true, eopsize, eaddrsize)) return false; //XXX psize = esizeop(xop->size, eopsize); //XXX break; case TYPE_Y: /* reg of ModR/M picks YMM register */ emitmodrm_reg(op->ymm); if (op->ymm > 7) rexprefix |= rexr; break; case TYPE_YI: { /* bits 7-4 of imm pick YMM register */ if (immsize == 0) { immsize = 1; imm = 0; } imm |= op->xmm << 4; break; } case TYPE_YV: vexvvvv = op->ymm; break; case TYPE_YR: /* rm of ModR/M picks YMM register */ emitmodrm_mod(3); emitmodrm_rm(op->ymm); if (op->ymm > 7) rexprefix |= rexb; break; } if (!psize) { // set_error_msg(X86ASM_ERRMSG_INTERNAL"FIXME: size ??? %s, %d\n", __FILE__, __LINE__); } if (!*esize) *esize = psize; /* if (!(options & X86ASM_ALLOW_AMBIGUOUS) && *esize != psize) { ambiguous = 1; set_error_msg(X86ASM_ERRMSG_AMBIGUOUS); return 0; }*/ return true; } bool x86asm::encode_sib_v(x86_insn_op *op, int mindispsize, int *_ss, int *_index, int *_base, int *_mod, int *_dispsize, int *disp) { int ss, scale=op->mem.scale, index=op->mem.index, base=op->mem.base, mod, dispsize; if (base == X86_REG_NO && index != X86_REG_NO) { switch (scale) { case 1: case 4: case 8: break; case 2: case 3: case 5: case 9: scale--; base = index; break; default: return false; } } if (index == X86_REG_SP) { if (scale > 1) return false; if (scale == 1) { if (base == X86_REG_SP) return false; int temp = index; index = base; base = temp; } } if (index != X86_REG_NO) { switch (scale) { case 1: ss = 0; break; case 2: ss = 1; break; case 4: ss = 2; break; case 8: ss = 3; break; default: return 0; } } else { ss = 0; index = 4; } switch (mindispsize) { case 0: mod = 0; dispsize = 0; break; case 1: mod = 1; dispsize = 1; break; case 2: case 4: case 8: mod = 2; dispsize = 4; break; default: return false; } if (base == X86_REG_NO) { base = 5; mod = 0; dispsize = 4; if (!mindispsize) *disp = 0; } else { if ((base & 7) == X86_REG_BP && mod == 0) { mod = 1; dispsize = 1; if (!mindispsize) *disp = 0; } } *_mod = mod; *_ss = ss; *_index = index; *_base = base; if (index & 8) rexprefix |= rexx; if (base & 8) rexprefix |= rexb; *_dispsize = dispsize; return 1; } int x86asm::esizeop(uint c, int size) { switch (c) { case SIZE_B: return 1; case SIZE_W: return 2; case SIZE_D: case SIZE_S: return 4; case SIZE_Q: case SIZE_L: return 8; case SIZE_O: return 16; case SIZE_T: return 10; case SIZE_V: case SIZE_BV: case SIZE_VV: switch (size) { case X86_OPSIZE16: return 2; case X86_OPSIZE32: return 4; case X86_OPSIZE64: return 8; } /* case SIZE_R: if (rexw(insn.rexprefix)) return 8; else return 4; case SIZE_U: if (insn.opsizeprefix == X86_PREFIX_OPSIZE) return 16; else return 8; case SIZE_Z: if (insn.opsizeprefix == X86_PREFIX_OPSIZE) return 8; else return 4; */ case SIZE_P: if (size == X86_OPSIZE16) return 4; else return 6; } return 0; } int x86asm::esizeop_ex(uint c, int size) { switch (c) { case SIZE_BV: return 1; case SIZE_VV: switch (size) { case X86_OPSIZE16: return 2; case X86_OPSIZE32: case X86_OPSIZE64: return 4; } } return esizeop(c, size); } char x86asm::flsz2hsz(int size) { switch (size) { case 4: return SIZE_S; case 8: return SIZE_L; case 10: return SIZE_T; } return 0; } const char *x86asm::get_name() { return "x86asm"; } const char *x86asm::immlsz2hsz(int size, int opsize) { if (opsize == X86_OPSIZE16) { switch (size) { case 1: return immhsz8_16; case 2: return immhsz16_16; case 4: return immhsz32_16; case 8: return immhsz64_16; } } else if (opsize == X86_OPSIZE32) { switch (size) { case 1: return immhsz8_32; case 2: return immhsz16_32; case 4: return immhsz32_32; case 8: return immhsz64_32; } } else { switch (size) { case 1: return immhsz8_64; case 2: return immhsz16_64; case 4: return immhsz32_64; case 8: return immhsz64_64; } } return 0; } const char *x86asm::lsz2hsz(int size, int opsize) { if (opsize == X86_OPSIZE16) { switch (size) { case 1: return hsz8_16; case 2: return hsz16_16; case 4: return hsz32_16; case 6: return hsz48_16; case 8: return hsz64_16; case 16: return hsz128_16; case 32: return hsz256_16; } } else if (opsize == X86_OPSIZE32) { switch (size) { case 1: return hsz8_32; case 2: return hsz16_32; case 4: return hsz32_32; case 6: return hsz48_32; case 8: return hsz64_32; case 16: return hsz128_32; case 32: return hsz256_32; } } else { switch (size) { case 1: return hsz8_64; case 2: return hsz16_64; case 4: return hsz32_64; case 6: return hsz48_64; case 8: return hsz64_64; case 16: return hsz128_64; case 32: return hsz256_64; } } return 0; } #define MATCHTYPE_NOMATCH 0 #define MATCHTYPE_MATCH 1 #define MATCHTYPE_NOOPPREFIX 2 #define MATCHTYPE_OPPREFIX 3 int x86asm::match_type(x86_insn_op *op, x86opc_insn_op *xop, int addrsize) { if (op->type == X86_OPTYPE_EMPTY && xop->type == TYPE_0) return MATCHTYPE_MATCH; int r = MATCHTYPE_MATCH; if (op->type == X86_OPTYPE_MMX) { if ((xop->type == TYPE_P || xop->type == TYPE_PR || xop->type == TYPE_Q) && (xop->size == SIZE_U || xop->size == SIZE_Z)) { r = MATCHTYPE_NOOPPREFIX; } } const byte *hop = lop2hop[op->type]; while (*hop) { if (*hop == xop->type) { if (xop->type == TYPE_Rx) { if (xop->extra == (op->reg & 7)) return r; } else if (xop->type == TYPE_RXx) { if (xop->extra == op->reg) return r; } else if (xop->type == TYPE_Sx) { if (xop->extra == op->seg) return r; } else if (xop->type == TYPE_Ix) { if ((unsigned)xop->extra == op->imm) return r; } else if (xop->type == TYPE_Fx) { if (xop->extra == op->stx) return r; } else if (xop->type == TYPE_Vx) { if (xop->extra == op->xmm) return r; } else if (op->type == X86_OPTYPE_MEM) { if (op->mem.addrsize == addrsize || op->mem.addrsize == X86_ADDRSIZEUNKNOWN) return r; } else return r; } hop++; } // special xmm match of mmx operands if (op->type == X86_OPTYPE_XMM) { if ((xop->type == TYPE_P || xop->type == TYPE_PR || xop->type == TYPE_Q) && (xop->size == SIZE_U || xop->size == SIZE_Z)) { return MATCHTYPE_OPPREFIX; } } return MATCHTYPE_NOMATCH; } bool x86asm::match_size(x86_insn_op *op, x86opc_insn_op *xop, int opsize) { if (op->type == X86_OPTYPE_EMPTY && xop->type == TYPE_0) return true; if (!op->size && xop->type != TYPE_0) return true; const char *hsz = NULL; byte xopsize = xop->size; if (op->type == X86_OPTYPE_REG && xop->type == TYPE_MR) { xopsize = xop->extra; } if ((op->type == X86_OPTYPE_MEM && op->mem.floatptr) || op->type == X86_OPTYPE_STX) { return xop->size == flsz2hsz(op->size); } else if (op->type == X86_OPTYPE_IMM) { if (xop->type == TYPE_Is) { hsz = immlsz2hsz(simmsize(op->imm, esizeop(xop->size, opsize)), opsize); //XXX } else if (xop->type == TYPE_J) { int ssize = esizeop_ex(xop->size, opsize); int size = esizeop(xop->size, opsize); // FIXME: ?! hsz = immlsz2hsz(simmsize(op->imm - address - code.size - ssize, size), opsize); } else { hsz = immlsz2hsz(simmsize(op->imm, esizeop(xop->size, opsize)), opsize); //XXX } } else if (op->type == X86_OPTYPE_YMM || op->type == X86_OPTYPE_XMM || op->type == X86_OPTYPE_MMX) { return true; } else { hsz = lsz2hsz(op->size, opsize); } if (hsz) { while (*hsz) { if (*hsz == xopsize) return true; hsz++; } } return false; } int x86asm::match_allops(x86asm_insn *insn, byte *xop, int maxop, int opsize, int addrsize) { int m = 0; for (int i = 0; i < maxop; i++) { int m2 = match_type(&insn->op[i], &x86_op_type[xop[i]], addrsize); if (!m2 || (m && m != MATCHTYPE_MATCH && m2 != MATCHTYPE_MATCH && m != m2)) { return MATCHTYPE_NOMATCH; } else { if (m2 > m) m = m2; } if (!match_size(&insn->op[i], &x86_op_type[xop[i]], opsize)) return MATCHTYPE_NOMATCH; } return m; } static void pickname(char *result, const char *name, int n) { const char *s = name; do { name = s+1; s = strchr(name, '|'); if (!s) { strcpy(result, name); return; } } while (n--); ht_strlcpy(result, name, s-name+1); } int x86asm::match_opcode_name(const char *input_name, const char *opcodelist_name, int def_match) { if (opcodelist_name) { if (*opcodelist_name == '~') opcodelist_name++; char n1[32], n2[32], n3[32]; pickname(n1, opcodelist_name, 0); pickname(n2, opcodelist_name, 1); pickname(n3, opcodelist_name, 2); switch (opcodelist_name[0]) { case '|': case '&': if (strcmp(n1, input_name)==0) return def_match; if (strcmp(n2, input_name)==0) return def_match; if (strcmp(n3, input_name)==0) return def_match; break; case '?': if (strcmp(n1, input_name)==0) return MATCHOPNAME_MATCH_IF_OPSIZE16; if (strcmp(n2, input_name)==0) return MATCHOPNAME_MATCH_IF_OPSIZE32; if (strcmp(n3, input_name)==0) return MATCHOPNAME_MATCH_IF_OPSIZE64; break; case '*': if (strcmp(n1, input_name)==0) return MATCHOPNAME_MATCH_IF_ADDRSIZE16; if (strcmp(n2, input_name)==0) return MATCHOPNAME_MATCH_IF_ADDRSIZE32; if (strcmp(n3, input_name)==0) return MATCHOPNAME_MATCH_IF_ADDRSIZE64; break; default: if (strcmp(opcodelist_name, input_name)==0) return def_match; } } return MATCHOPNAME_NOMATCH; } static void swap(char &a, char &b) { char tmp = a; a = b; b = tmp; } void x86asm::match_opcode(x86opc_insn *opcode, x86asm_insn *insn, int prefix, byte opcodebyte, int additional_opcode, int def_match) { int n = match_opcode_name(insn->name, opcode->name, def_match); namefound |= n; if (n == MATCHOPNAME_NOMATCH) return; insn->opsizeprefix = X86_PREFIX_NO; char opsizes[] = {X86_OPSIZE16, X86_OPSIZE32, X86_OPSIZE64}; char addrsizes[] = {X86_ADDRSIZE16, X86_ADDRSIZE32, X86_ADDRSIZE64}; switch (addrsize) { case X86_ADDRSIZE32: swap(addrsizes[0], addrsizes[1]); break; case X86_ADDRSIZE64: swap(addrsizes[0], addrsizes[2]); break; case X86_ADDRSIZE16: case X86_ADDRSIZEUNKNOWN:; } bool done1 = false; int o = 0; /* * check all permutations of opsize and addrsize * if possible and necessary */ switch (n) { case MATCHOPNAME_MATCH_IF_OPSIZE16: done1 = true; break; case MATCHOPNAME_MATCH_IF_OPSIZE32: o = 1; done1 = true; break; case MATCHOPNAME_MATCH_IF_OPSIZE64: o = 2; done1 = true; break; } for (; o < 3; o++) { if (o == 2 && addrsize != X86_ADDRSIZE64) break; switch (def_match) { case MATCHOPNAME_MATCH_IF_OPPREFIX: if (opsize == X86_OPSIZE16 && o == 0) continue; if (opsize == X86_OPSIZE32 && o == 1) continue; break; case MATCHOPNAME_MATCH_IF_NOOPPREFIX: if (opsize == X86_OPSIZE16 && o == 1) continue; if (opsize == X86_OPSIZE32 && o == 0) continue; break; } for (int a=0; a < 2; a++) { char as = addrsizes[a]; bool done2 = false; switch (n) { case MATCHOPNAME_MATCH_IF_ADDRSIZE16: as = X86_ADDRSIZE16; done2 = true; break; case MATCHOPNAME_MATCH_IF_ADDRSIZE32: as = X86_ADDRSIZE32; done2 = true; break; case MATCHOPNAME_MATCH_IF_ADDRSIZE64: as = X86_ADDRSIZE64; done2 = true; break; } match_opcode_final(opcode, insn, prefix, opcodebyte, additional_opcode, opsizes[o], as, n); if (done2) break; } if (done1) break; } } void x86asm::match_vex_opcode(x86opc_vex_insn *opcode, x86asm_insn *insn, byte opcodebyte, int additional_opcode) { int n = match_opcode_name(insn->name, opcode->name, MATCHOPNAME_MATCH_IF_NOOPPREFIX); namefound |= n; if (n == MATCHOPNAME_NOMATCH) return; char addrsizes[] = {X86_ADDRSIZE16, X86_ADDRSIZE32, X86_ADDRSIZE64}; switch (addrsize) { case X86_ADDRSIZE32: swap(addrsizes[0], addrsizes[1]); break; case X86_ADDRSIZE64: swap(addrsizes[0], addrsizes[2]); break; case X86_ADDRSIZE16: case X86_ADDRSIZEUNKNOWN:; } for (int a=0; a < 2; a++) { char as = addrsizes[a]; match_vex_opcode_final(opcode, insn, opcodebyte, additional_opcode, opsize, as); } } int x86asm::match_opcode_final(x86opc_insn *opcode, x86asm_insn *insn, int prefix, byte opcodebyte, int additional_opcode, int opsize, int addrsize, int match) { switch (match_allops(insn, opcode->op, 4, opsize, addrsize)) { case MATCHTYPE_NOMATCH: return false; case MATCHTYPE_MATCH: if (match == MATCHOPNAME_MATCH_IF_OPPREFIX) { insn->opsizeprefix = X86_PREFIX_OPSIZE; } else if (match == MATCHOPNAME_MATCH_IF_NOOPPREFIX) { insn->opsizeprefix = X86_PREFIX_NOOPSIZE; } break; case MATCHTYPE_NOOPPREFIX: if (match == MATCHOPNAME_MATCH_IF_OPPREFIX) return false; insn->opsizeprefix = X86_PREFIX_NOOPSIZE; break; case MATCHTYPE_OPPREFIX: if (match == MATCHOPNAME_MATCH_IF_NOOPPREFIX) return false; insn->opsizeprefix = X86_PREFIX_OPSIZE; break; } if (encode_insn(insn, opcode, opcodebyte, additional_opcode, prefix, opsize, addrsize)) { pushcode(); newcode(); } return true; } int x86asm::match_vex_opcode_final(x86opc_vex_insn *opcode, x86asm_insn *insn, byte opcodebyte, int additional_opcode, int opsize, int addrsize) { if (match_allops(insn, opcode->op, 5, opsize, addrsize) == MATCHTYPE_NOMATCH) { return false; } if (encode_vex_insn(insn, opcode, opcodebyte, additional_opcode, opsize, addrsize)) { pushcode(); newcode(); } return true; } void x86asm::match_opcodes(x86opc_insn *opcodes, x86asm_insn *insn, int prefix, int def_match) { for (int i=0; i < 256; i++) { if (!opcodes[i].name) { byte specialtype = opcodes[i].op[0]; if (specialtype == SPECIAL_TYPE_GROUP) { byte specialdata = opcodes[i].op[1]; x86opc_insn *group = x86_group_insns[specialdata]; for (int g=0; g < 8; g++) { if (!group[g].name) { byte special2type = group[g].op[0]; if (special2type == SPECIAL_TYPE_SGROUP) { byte special2data = group[g].op[1]; x86opc_insn *group = x86_special_group_insns[special2data]; for (int h=0; h < 8; h++) { match_opcode(&group[h], insn, prefix, i, (h<<3) + g + 0x800, def_match); } match_opcode(&group[8], insn, prefix, i, -1, def_match); } } else { match_opcode(&group[g], insn, prefix, i, g, def_match); } } } } else { match_opcode(&opcodes[i], insn, prefix, i, -1, def_match); } } } void x86asm::match_vex_opcodes(x86asm_insn *insn) { for (int i=0; i < 256; i++) { x86opc_vex_insn *opcodes = x86_vex_insns[i]; if (!opcodes) continue; while (!opcodes->name && opcodes->op[0] == SPECIAL_TYPE_GROUP) { for (int j=0; j < 8; j++) { x86opc_vex_insn *group = &x86_group_vex_insns[opcodes->op[1]][j]; if (group->name) match_vex_opcode(group, insn, i, j); } opcodes++; } while (opcodes->name) { match_vex_opcode(opcodes, insn, i, -1); opcodes++; } } } void x86asm::match_fopcodes(x86asm_insn *insn) { /* try modrm fopcodes */ for (int i=0; i < 8; i++) { for (int j=0; j < 8; j++) { int n = match_opcode_name(insn->name, x86_modfloat_group_insns[i][j].name, MATCHOPNAME_MATCH); namefound |= n; if (n != MATCHOPNAME_NOMATCH) { int eaddrsize = addrsize; for (int k=0; k < 2; k++) { if (match_allops(insn, x86_modfloat_group_insns[i][j].op, 4, opsize, eaddrsize)) { if (encode_insn(insn, &x86_modfloat_group_insns[i][j], -1, j, X86ASM_PREFIX_D8+i, opsize, eaddrsize)) { pushcode(); newcode(); } } switch (eaddrsize) { case X86_ADDRSIZE64: case X86_ADDRSIZE16: eaddrsize = X86_ADDRSIZE32; break; case X86_ADDRSIZE32: eaddrsize = X86_ADDRSIZE16; break; } } } } } /* try the rest */ for (int i=0; i<8; i++) { for (int j=0; j<8; j++) { if (x86_float_group_insns[i][j].group == 0) { int n = match_opcode_name(insn->name, x86_float_group_insns[i][j].insn.name, MATCHOPNAME_MATCH); namefound |= n; if (n != MATCHOPNAME_NOMATCH) { if (match_allops(insn, x86_float_group_insns[i][j].insn.op, 4, opsize, addrsize)) { if (encode_insn(insn, &x86_float_group_insns[i][j].insn, -1, 0x800 | j, X86ASM_PREFIX_D8+i, opsize, addrsize)) { pushcode(); newcode(); } if (error) return; } } } else { x86opc_insn *group=x86_float_group_insns[i][j].group; for (int k=0; k < 8; k++) { int n = match_opcode_name(insn->name, group[k].name, MATCHOPNAME_MATCH); namefound |= n; if (n != MATCHOPNAME_NOMATCH) { int eaddrsize = addrsize; for (int l=0; l < 2; l++) { if (match_allops(insn, group[k].op, 4, opsize, eaddrsize)) { if (encode_insn(insn, &group[k], -1, 0x800 | k<<3 | j, X86ASM_PREFIX_D8+i, opsize, eaddrsize)) { pushcode(); newcode(); } } switch (eaddrsize) { case X86_ADDRSIZE64: case X86_ADDRSIZE16: eaddrsize = X86_ADDRSIZE32; break; case X86_ADDRSIZE32: eaddrsize = X86_ADDRSIZE16; break; } } } } } } } } bool x86asm::opreg(x86_insn_op *op, const char *xop) { for (int i=0; i<3; i++) { for (int j=0; j<8; j++) { if (x86_regs[i][j] && strcmp(xop, x86_regs[i][j])==0) { op->type = X86_OPTYPE_REG; op->size = reg2size[i]; op->reg = j; return true; } } } return false; } bool x86asm::opmmx(x86_insn_op *op, const char *xop) { if (strlen(xop) == 3 && xop[0] == 'm' && xop[1] == 'm' && xop[2] >= '0' && xop[2] <= '7') { op->type = X86_OPTYPE_MMX; op->size = 8; op->mmx = xop[2] - '0'; return true; } else { return false; } } bool x86asm::opxmm(x86_insn_op *op, const char *xop) { if (strlen(xop) == 4 && xop[0] == 'x' && xop[1] == 'm' && xop[2] == 'm' && xop[3] >= '0' && xop[3] <= '7') { op->type = X86_OPTYPE_XMM; op->size = 16; op->xmm = xop[3] - '0'; return true; } else { return false; } } bool x86asm::opymm(x86_insn_op *op, const char *xop) { if (strlen(xop) == 4 && xop[0] == 'y' && xop[1] == 'm' && xop[2] == 'm' && xop[3] >= '0' && xop[3] <= '7') { op->type = X86_OPTYPE_YMM; op->size = 32; op->xmm = xop[3] - '0'; return true; } else { return false; } } bool x86asm::opseg(x86_insn_op *op, const char *xop) { for (int i=0; i<8; i++) { if (x86_segs[i] && strcmp(xop, x86_segs[i])==0) { op->type = X86_OPTYPE_SEG; op->size = 2; op->seg = i; return true; } } return false; } bool x86asm::opfarptr(x86_insn_op *op, const char *xop) { return false; /* FIXME: uint64 seg, offset; char *x = xop; if (!fetch_number(&x, &seg)) return false; if (*x != ':') return false; x++; if (!fetch_number(&x, &offset)) return false; if (*x) return false; op->type = X86_OPTYPE_FARPTR; if (offset > 0xffff) op->size=6; else op->size=4; op->farptr.seg = seg; op->farptr.offset = offset; return true; */ } bool x86asm::opimm(x86_insn_op *op, const char *xop) { uint64 i; if (!str2int(xop, i)) return false; op->type = X86_OPTYPE_IMM; if (i > 0xffffffffULL) { op->size = 8; } else if (i > 0xffff) { op->size = 4; } else if (i > 0xff) { op->size = 2; } else { op->size = 1; } op->imm = i; return true; } bool x86asm::opplugimm(x86_insn_op *op, const char *xop) { uint64 d; if (imm_eval_proc && imm_eval_proc(imm_eval_context, xop, d)) { op->type = X86_OPTYPE_IMM; if (d > 0xffffffff) { op->size = 8; } else if (d > 0xffff) { op->size = 4; } else if (d > 0xff) { op->size = 2; } else { op->size = 1; } op->imm = d; return true; } return false; } bool x86asm::opmem(x86asm_insn *asm_insn, x86_insn_op *op, const char *s) { /* FIXME: dirty implementation! */ int opsize = 0, hsize = 0; bool floatptr = false; char token[256]; const char *sep = "[]()*+-:"; tok(&s, token, sizeof token, sep); static const char *types[] = {"byte", "word", "dword", "pword", "qword", "oword", "xmmword", "ymmword", "single", "double", "extended"}; static byte type_size[] = {1, 2, 4, 6, 8, 16, 16, 32, 4, 8, 10}; // typecast for (uint i=0; i < sizeof types / sizeof types[0]; i++) { if (strcmp(token, types[i]) == 0) { hsize = type_size[i]; if (i >= 8) floatptr = true; break; } } if (hsize) { tok(&s, token, sizeof token, sep); if (!(strcmp(token, "ptr") == 0)) return false; opsize = hsize; tok(&s, token, sizeof token, sep); } // segprefixes (e.g. fs:) for (int i = 0; i < 8; i++) { if (x86_segs[i]) { if (strcmp(x86_segs[i], token)==0) { tok(&s, token, sizeof token, sep); if (!(strcmp(token, ":") == 0)) return false; static const int c2p[8] = {X86_PREFIX_ES, X86_PREFIX_CS, X86_PREFIX_SS, X86_PREFIX_DS, X86_PREFIX_FS, X86_PREFIX_GS, 0, 0}; asm_insn->segprefix = c2p[i]; tok(&s, token, sizeof token, sep); break; } } } if (!(strcmp(token, "[") == 0)) return false; int scale = 0, index = X86_REG_NO, base = X86_REG_NO; uint64 disp = 0; int addrsize = X86_ADDRSIZEUNKNOWN; int lasttokenreg = X86_REG_NO; bool need_rex = false; int sign = 1; sep = "[]()*+-"; while (1) { cont: tok(&s, token, sizeof token, sep); if (strcmp(token, "+") == 0) { if (!sign) sign = 1; continue; } if (strcmp(token, "-") == 0) { if (sign) { sign = -sign; } else { sign = -1; } continue; } if (strcmp(token, "]") == 0) { if (sign) return false; break; } if (strcmp(token, "*") == 0) { tok(&s, token, sizeof token, sep); if (lasttokenreg == X86_REG_NO) { /* FIXME: case "imm*reg" not yet supported! cleaner implementation needed! */ return false; } else { uint64 v; if (!str2int(token, v)) return false; if (v > 1) { if (index == lasttokenreg) { scale += v-1; } else if (base == lasttokenreg) { if (index != X86_REG_NO) return false; index = base; base = X86_REG_NO; scale = v; } } } lasttokenreg = X86_REG_NO; sign = 0; continue; } /* test if reg */ for (int i=1; i < 4; i++) { for (int j=0; j < 16; j++) { if (x86_64regs[i][j] && strcmp(token, x86_64regs[i][j])==0) { if (j > 7 || i == 3) { if (this->addrsize != X86_ADDRSIZE64) break; if (j > 7) need_rex = true; } if (sign < 0) return false; static const byte sizer[] = {X86_ADDRSIZE16, X86_ADDRSIZE32, X86_ADDRSIZE64}; int caddrsize = sizer[i-1]; if (addrsize == X86_ADDRSIZEUNKNOWN) { addrsize = caddrsize; } else if (addrsize != caddrsize) { return false; } if (index == j) { scale++; } else if (base == X86_REG_NO) { base = j; } else if (index == X86_REG_NO) { index = j; scale = 1; } else if (base == j && scale == 1) { int t = index; index = base; base = t; scale = 2; } else return false; lasttokenreg = j; sign = 0; goto cont; } } } lasttokenreg = X86_REG_NO; /* test if number */ uint64 v; if ((imm_eval_proc && imm_eval_proc(imm_eval_context, token, v)) || str2int(token, v)) { if (!sign) return false; if (sign < 0) disp -= v; else disp += v; sign = 0; continue; } return false; } op->type = X86_OPTYPE_MEM; op->size = opsize; op->mem.base = base; op->mem.index = index; op->mem.scale = scale; op->mem.addrsize = addrsize; op->mem.disp = disp; op->mem.floatptr = floatptr; op->need_rex = need_rex; return true; } bool x86asm::opspecialregs(x86_insn_op *op, const char *xop) { char *e; if (strcmp(xop, "st")==0) { op->type=X86_OPTYPE_STX; op->size=10; op->stx=0; return true; } else if (ht_strncmp(xop, "st", 2)==0 && xop[2]=='(' && xop[4]==')') { int w = strtol(xop+3, &e, 10); if (e != xop+4 || w > 7) return false; op->type = X86_OPTYPE_STX; op->size = 10; op->stx = w; return 1; } /* FIXME: do we need this? * strtol sets e to next untranslatable char, * this case is caught below... */ if (strlen(xop) != 3) return 0; int w = strtol(xop+2, &e, 10); if (*e || w > 7) return 0; if (ht_strncmp(xop, "cr", 2) == 0) { op->type = X86_OPTYPE_CRX; op->size = 4; op->crx = w; return true; } else if (ht_strncmp(xop, "dr", 2) == 0) { op->type = X86_OPTYPE_DRX; op->size = 4; op->drx = w; return true; } return false; } bool x86asm::translate_str(asm_insn *asm_insn, const char *s) { x86asm_insn *insn=(x86asm_insn*)asm_insn; char *opp[5], op[5][256]; opp[0]=op[0]; opp[1]=op[1]; opp[2]=op[2]; opp[3]=op[3]; opp[4]=op[4]; for (int i=0; i<5; i++) { insn->op[i].need_rex = insn->op[i].forbid_rex = false; insn->op[i].type = X86_OPTYPE_EMPTY; } insn->lockprefix = X86_PREFIX_NO; insn->repprefix = X86_PREFIX_NO; insn->segprefix = X86_PREFIX_NO; insn->opsizeprefix = X86_PREFIX_NO; const char *p = s, *a, *b; /* prefixes */ whitespaces(p); a=p; non_whitespaces(p); b=p; if (ht_strncmp(a, "rep", b-a) == 0 || ht_strncmp(a, "repe", b-a) == 0 || ht_strncmp(a, "repz", b-a) == 0) { insn->repprefix=X86_PREFIX_REPZ; s = p; } else if (ht_strncmp(a, "repne", b-a) == 0 || ht_strncmp(a, "repnz", b-a) == 0) { insn->repprefix=X86_PREFIX_REPNZ; s = p; } else if (ht_strncmp(a, "lock", b-a) == 0) { insn->lockprefix=X86_PREFIX_LOCK; s = p; } /**/ splitstr(s, insn->n, sizeof insn->n, (char**)opp, 256); insn->name = insn->n; for (int i=0; i<5; i++) { if (!*op[i]) break; if (!(opplugimm(&insn->op[i], op[i]) || opreg(&insn->op[i], op[i]) || opmmx(&insn->op[i], op[i]) || opxmm(&insn->op[i], op[i]) || opymm(&insn->op[i], op[i]) || opfarptr(&insn->op[i], op[i]) || opimm(&insn->op[i], op[i]) || opseg(&insn->op[i], op[i]) || opmem(insn, &insn->op[i], op[i]) || opspecialregs(&insn->op[i], op[i]))) { set_error_msg(X86ASM_ERRMSG_UNKNOWN_SYMBOL, op[i]); return false; } } return true; } int x86asm::simmsize(uint64 imm, int immsize) { switch (immsize) { case 1: if (imm <= 0xff) return 1; break; case 2: if (imm <= 0xffff) imm = sint64(sint16(imm)); break; case 4: if (imm <= 0xffffffff) imm = sint64(sint32(imm)); break; } if (imm >= 0xffffffffffffff80ULL || imm < 0x80) return 1; if (imm >= 0xffffffffffff8000ULL || imm < 0x8000) return 2; if (imm >= 0xffffffff80000000ULL || imm < 0x80000000) return 4; return 8; } void x86asm::splitstr(const char *s, char *name, int size, char **op, int opsize) { const char *a, *b; bool wantbreak = false; *name=0; *op[0]=0; *op[1]=0; *op[2]=0; *op[3]=0; *op[4]=0; /* find name */ whitespaces(s); a = s; non_whitespaces(s); b = s; ht_strlcpy(name, a, MIN(b-a+1, size)); /* find ops */ for (int i = 0; i < 5; i++) { whitespaces(s); if (!*s) break; a = s; waitforchar(s, ','); while (is_whitespace(s[-1])) s--; if (!*s) wantbreak = true; b = s; whitespaces(s); if (!*s) wantbreak = true; ht_strlcpy(op[i], a, MIN(b-a+1, opsize)); whitespaces(s); if (wantbreak || *s != ',') break; s++; } } void x86asm::tok(const char **s, char *res, int reslen, const char *sep) { if (reslen <= 0) return; whitespaces(*s); if (strchr(sep, **s)) { if (reslen > 0) *res++ = *((*s)++); } else { while (reslen > 1) { *res++ = *((*s)++); reslen--; if (**s == ' ' || **s == '\t') break; if (strchr(sep, **s)) break; } } *res = 0; } /************************************************************************ * */ x86opc_insn (*x86_64asm::x86_64_insns)[256]; x86_64asm::x86_64asm() : x86asm(X86_OPSIZE32, X86_ADDRSIZE64) { prepInsns(); } void x86_64asm::prepInsns() { if (!x86_64_insns) { x86_64_insns = ht_malloc(sizeof *x86_64_insns); memcpy(x86_64_insns, x86_32_insns, sizeof x86_32_insns); int i = 0; while (x86_64_insn_patches[i].opc != -1) { (*x86_64_insns)[x86_64_insn_patches[i].opc] = x86_64_insn_patches[i].insn; i++; } } x86_insns = x86_64_insns; } x86dis *x86_64asm::createCompatibleDisassembler() { return new x86_64dis(); } bool x86_64asm::opreg(x86_insn_op *op, const char *xop) { for (int i=0; i < 4; i++) { for (int j=0; j < 16; j++) { if (x86_64regs[i][j] && strcmp(xop, x86_64regs[i][j])==0) { op->type = X86_OPTYPE_REG; op->size = reg2size[i]; op->reg = j; if (j > 7 || (i == 0 && j > 3)) { op->need_rex = true; } return true; } } } // check for legacy ah, ch, dh, bh for (int j=4; j < 8; j++) { if (x86_regs[0][j] && strcmp(xop, x86_regs[0][j])==0) { op->type = X86_OPTYPE_REG; op->size = reg2size[0]; op->reg = j; op->forbid_rex = true; return true; } } return false; } bool x86_64asm::opxmm(x86_insn_op *op, const char *xop) { int slen = strlen(xop); if ((slen == 4 || slen == 5) && xop[0] == 'x' && xop[1] == 'm' && xop[2] == 'm' && xop[3] >= '0' && xop[3] <= '9') { int x = xop[3] - '0'; if (slen == 5) { if (xop[4] < '0' || xop[4] > '9') return false; x *= 10; x += xop[4] - '0'; if (x > 15) return false; } op->type = X86_OPTYPE_XMM; op->size = 16; op->xmm = x; if (x > 7) op->need_rex = true; return true; } else { return false; } } bool x86_64asm::opymm(x86_insn_op *op, const char *xop) { int slen = strlen(xop); if ((slen == 4 || slen == 5) && xop[0] == 'y' && xop[1] == 'm' && xop[2] == 'm' && xop[3] >= '0' && xop[3] <= '9') { int x = xop[3] - '0'; if (slen == 5) { if (xop[4] < '0' || xop[4] > '9') return false; x *= 10; x += xop[4] - '0'; if (x > 15) return false; } op->type = X86_OPTYPE_YMM; op->size = 32; op->xmm = x; if (x > 7) op->need_rex = true; return true; } else { return false; } } ht-2.0.22/asm/ia64dis.h0000644000175000001440000000523010615342401011315 00000000000000/* * HT Editor * ia64dis.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef IA64DIS_H #define IA64DIS_H #include "asm.h" #include "io/types.h" #include "ia64opc.h" #define IA64_OPERAND_NO 0 #define IA64_OPERAND_EQUALS 1 #define IA64_OPERAND_1 2 #define IA64_OPERAND_REG 3 #define IA64_OPERAND_AREG 4 #define IA64_OPERAND_BREG 5 #define IA64_OPERAND_FREG 6 #define IA64_OPERAND_PREG 7 #define IA64_OPERAND_AR_PFS 8 #define IA64_OPERAND_AR_CCV 9 #define IA64_OPERAND_MEM_REG 10 #define IA64_OPERAND_IMM 11 #define IA64_OPERAND_ADDRESS 12 #define IA64_OPERAND_REG_FILE 13 #define IA64_OPERAND_PRALL 14 #define IA64_OPERAND_PRROT 15 #define IA64_OPERAND_IP 16 struct IA64Op { int type; union { int reg; uint64 imm; uint64 ofs; struct { int db; int idx; } regfile; }; }; struct IA64SlotDisInsn { bool valid; int next; uint64 data; uint32 qp; IA64OpcodeEntry * opcode; IA64Op op[7]; }; struct IA64DisInsn { bool valid; int size; byte data[16]; IA64Template *tmplt; byte tmplt_idx; /* template bits */ int selected; IA64SlotDisInsn slot[3]; }; /* * CLASS alphadis */ class IA64Disassembler: public Disassembler { protected: CPU_ADDR cpu_addr; char insnstr[256]; IA64DisInsn insn; public: IA64Disassembler() {}; IA64Disassembler(BuildCtorArg&a): Disassembler(a) {}; virtual dis_insn *decode(byte *code, int maxlen, CPU_ADDR addr); virtual dis_insn *duplicateInsn(dis_insn *disasm_insn); virtual void getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align); virtual byte getSize(dis_insn *disasm_insn); virtual const char *getName(); virtual bool selectNext(dis_insn *disasm_insn); virtual const char *str(dis_insn *disasm_insn, int style); virtual const char *strf(dis_insn *disasm_insn, int style, const char *format); virtual ObjectID getObjectID() const; virtual bool validInsn(dis_insn *disasm_insn); private: void decodeSlot(int slot_nb); uint64 signExtend(uint64 a, int length); }; #endif ht-2.0.22/asm/x86dis.h0000644000175000017500000001155512127651420011216 00000000000000/* * HT Editor * x86dis.h * * Copyright (C) 1999-2002 Stefan Weyergraf * Copyright (C) 2005-2007 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __X86DIS_H__ #define __X86DIS_H__ #include "asm.h" #include "x86opc.h" #define X86DIS_OPCODE_CLASS_STD 0 /* no prefix */ #define X86DIS_OPCODE_CLASS_EXT 1 /* 0F */ #define X86DIS_OPCODE_CLASS_EXT_66 2 /* 66 0F */ #define X86DIS_OPCODE_CLASS_EXT_F2 3 /* F2 0F */ #define X86DIS_OPCODE_CLASS_EXT_F3 4 /* F3 0F */ #define X86DIS_OPCODE_CLASS_EXTEXT 5 /* 0F 0F */ /* x86-specific styles */ #define X86DIS_STYLE_EXPLICIT_MEMSIZE 0x00000001 /* IF SET: mov word ptr [0000], ax ELSE: mov [0000], ax */ #define X86DIS_STYLE_OPTIMIZE_ADDR 0x00000002 /* IF SET: mov [eax*3], ax ELSE: mov [eax+eax*2+00000000], ax */ struct x86dis_vex { uint8 mmmm; uint8 vvvv; uint8 l; uint8 w; uint8 pp; }; struct x86dis_insn { bool invalid; sint8 opsizeprefix; sint8 lockprefix; sint8 repprefix; sint8 segprefix; uint8 rexprefix; x86dis_vex vexprefix; int size; int opcode; int opcodeclass; X86OpSize eopsize; X86AddrSize eaddrsize; bool ambiguous; const char *name; x86_insn_op op[5]; }; /* * CLASS x86dis */ class x86dis: public Disassembler { public: X86OpSize opsize; X86AddrSize addrsize; x86opc_insn (*x86_insns)[256]; protected: x86dis_insn insn; char insnstr[256]; byte *codep, *ocodep; CPU_ADDR addr; byte c; int modrm; int sib; int drex; int maxlen; int special_imm; uint32 disp; bool have_disp; bool fixdisp; /* new */ virtual void checkInfo(x86opc_insn *xinsn); void decode_insn(x86opc_insn *insn); void decode_vex_insn(x86opc_vex_insn *xinsn); virtual void decode_modrm(x86_insn_op *op, char size, bool allow_reg, bool allow_mem, bool mmx, bool xmm, bool ymm); void decode_op(x86_insn_op *op, x86opc_insn_op *xop); void decode_sib(x86_insn_op *op, int mod); int esizeop(uint c); int esizeop_ex(uint c); byte getbyte(); uint16 getword(); uint32 getdword(); uint64 getqword(); int getmodrm(); int getsib(); int getdrex(); uint32 getdisp(); int getspecialimm(); void invalidate(); bool isfloat(char c); bool isaddr(char c); virtual void prefixes(); void str_format(char **str, const char **format, char *p, char *n, char *op[5], int oplen[5], char stopchar, int print); virtual void str_op(char *opstr, int *opstrlen, x86dis_insn *insn, x86_insn_op *op, bool explicit_params); uint mkmod(uint modrm); uint mkreg(uint modrm); uint mkindex(uint modrm); uint mkrm(uint modrm); virtual uint64 getoffset(); virtual void filloffset(CPU_ADDR &addr, uint64 offset); public: x86dis(X86OpSize opsize, X86AddrSize addrsize); x86dis(BuildCtorArg&a): Disassembler(a) {}; /* overwritten */ virtual dis_insn * decode(byte *code, int maxlen, CPU_ADDR addr); virtual dis_insn * duplicateInsn(dis_insn *disasm_insn); virtual void getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align); virtual const char * getName(); virtual byte getSize(dis_insn *disasm_insn); virtual void load(ObjectStream &f); virtual ObjectID getObjectID() const; virtual const char * str(dis_insn *disasm_insn, int options); virtual const char * strf(dis_insn *disasm_insn, int options, const char *format); virtual void store(ObjectStream &f) const; virtual bool validInsn(dis_insn *disasm_insn); }; class x86_64dis: public x86dis { static x86opc_insn (*x86_64_insns)[256]; public: x86_64dis(); x86_64dis(BuildCtorArg&a): x86dis(a) {}; virtual void checkInfo(x86opc_insn *xinsn); virtual void decode_modrm(x86_insn_op *op, char size, bool allow_reg, bool allow_mem, bool mmx, bool xmm, bool ymm); virtual void prefixes(); virtual uint64 getoffset(); virtual void filloffset(CPU_ADDR &addr, uint64 offset); void load(ObjectStream &f); virtual ObjectID getObjectID() const; void prepInsns(); }; class x86dis_vxd: public x86dis { protected: virtual void str_op(char *opstr, int *opstrlen, x86dis_insn *insn, x86_insn_op *op, bool explicit_params); public: x86dis_vxd(BuildCtorArg&a): x86dis(a) {}; x86dis_vxd(X86OpSize opsize, X86AddrSize addrsize); virtual dis_insn * decode(byte *code, int maxlen, CPU_ADDR addr); virtual ObjectID getObjectID() const; }; #endif /* __X86DIS_H__ */ ht-2.0.22/asm/javaopc.h0000644000175000001440000000326110615342402011500 00000000000000/* * HT Editor * javaopc.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __JAVAOPC_H__ #define __JAVAOPC_H__ #include "io/types.h" #define JAVA_OPTYPE_EMPTY 0 #define JAVA_OPTYPE_IMM 1 #define JAVA_OPTYPE_DBL 2 #define JAVA_OPTYPE_REF 3 #define JAVA_OPTYPE_LABEL 4 #define JAVA_OPTYPE_CONST 5 #define JAVA_OPTYPE_ATYPE 6 #define JOPC_TYPE(t) ((t) & 0x1f) #define JOPC_TYPE_EMPTY 0 #define JOPC_TYPE_BYTE 1 #define JOPC_TYPE_SHORT 2 #define JOPC_TYPE_SIMM 3 #define JOPC_TYPE_CHAR 4 #define JOPC_TYPE_CONST 5 #define JOPC_TYPE_LOCAL 6 #define JOPC_TYPE_LABEL 7 #define JOPC_TYPE_ATYPE 8 #define JOPC_SIZE(t) ((t) & 0xe0) #define JOPC_SIZE_VAR 0x00 #define JOPC_SIZE_SMALL 0x40 #define JOPC_SIZE_WIDE 0x80 #define JAVAINSN_MAX_PARAM_COUNT 3 struct java_insn_op { int type; int size; union { uint32 imm; uint32 label; double dbl; uint32 ref; }; }; struct javaopc_insn { const char *name; int optype[JAVAINSN_MAX_PARAM_COUNT]; }; #define JAVA_WIDE_OPCODE 0xc4 extern javaopc_insn java_insns[256]; #endif /* __JAVAOPC_H__ */ ht-2.0.22/asm/asm.cc0000644000175000001440000001736310671520206011005 00000000000000/* * HT Editor * asm.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include "asm.h" #include "data.h" #include "atom.h" #include "htdebug.h" #include "snprintf.h" #include "alphadis.h" #include "ia64dis.h" #include "ildis.h" #include "javadis.h" #include "x86dis.h" #include "ppcdis.h" #include "armdis.h" /* * CLASS Assembler */ Assembler::Assembler(bool b) { codes = 0; bigendian = b; } Assembler::~Assembler() { free_asm_codes(); } asm_insn *Assembler::alloc_insn() { return NULL; } void Assembler::deletecode(asm_code *code) { asm_code **p=&codes, *c=codes; while (c) { if (c == code) { *p = c->next; delete c; return; } c = c->next; p = &(*p)->next; } } asm_code *Assembler::encode(asm_insn *asm_insn, int _options, CPU_ADDR cur_address) { free_asm_codes(); error = 0; options = _options; return 0; } void Assembler::clearcode() { code.size = 0; } void Assembler::emitbyte(byte b) { code.data[code.size] = b; code.size++; } void Assembler::emitword(uint16 w) { if (bigendian) { code.data[code.size+1] = (byte)w; code.data[code.size+0] = (byte)(w>>8); } else { code.data[code.size+0] = (byte)w; code.data[code.size+1] = (byte)(w>>8); } code.size += 2; } void Assembler::emitdword(uint32 d) { if (bigendian) { code.data[code.size+3] = (byte)d; code.data[code.size+2] = (byte)(d>>8); code.data[code.size+1] = (byte)(d>>16); code.data[code.size+0] = (byte)(d>>24); } else { code.data[code.size+0] = (byte)d; code.data[code.size+1] = (byte)(d>>8); code.data[code.size+2] = (byte)(d>>16); code.data[code.size+3] = (byte)(d>>24); } code.size += 4; } void Assembler::emitqword(uint64 q) { if (bigendian) { code.data[code.size+7] = (byte)q; code.data[code.size+6] = (byte)(q>>8); code.data[code.size+5] = (byte)(q>>16); code.data[code.size+4] = (byte)(q>>24); code.data[code.size+3] = (byte)(q>>32); code.data[code.size+2] = (byte)(q>>40); code.data[code.size+1] = (byte)(q>>48); code.data[code.size+0] = (byte)(q>>56); } else { code.data[code.size+0] = (byte)q; code.data[code.size+1] = (byte)(q>>8); code.data[code.size+2] = (byte)(q>>16); code.data[code.size+3] = (byte)(q>>24); code.data[code.size+4] = (byte)(q>>32); code.data[code.size+5] = (byte)(q>>40); code.data[code.size+6] = (byte)(q>>48); code.data[code.size+7] = (byte)(q>>56); } code.size += 8; } void Assembler::free_asm_codes() { while (codes) { asm_code *t = codes->next; delete codes; codes = t; } } const char *Assembler::get_error_msg() { return error_msg; } const char *Assembler::get_name() { return "generic asm"; } void Assembler::newcode() { code.size = 0; } asm_code *Assembler::shortest(asm_code *codes) { asm_code *best = NULL; int bestv = INT_MAX; while (codes) { if (codes->size < bestv) { best = codes; bestv = codes->size; } codes = codes->next; } return best; } void Assembler::pushcode() { asm_code **t=&codes; while (*t) { t = &(*t)->next; } *t = new asm_code; memcpy(*t, &code, sizeof code); (*t)->next = NULL; } void Assembler::set_error_msg(const char *format, ...) { va_list arg; va_start(arg, format); vsprintf(error_msg, format, arg); va_end(arg); error=1; } void Assembler::set_imm_eval_proc(int (*p)(void *context, const char *s, uint64 &v), void *c) { imm_eval_proc = p; imm_eval_context = c; } /* * CLASS disassembler */ Disassembler::Disassembler() { disable_highlighting(); } void Disassembler::load(ObjectStream &f) { disable_highlighting(); } char* (*addr_sym_func)(CPU_ADDR addr, int *symstrlen, void *context) = NULL; void* addr_sym_func_context = NULL; dis_insn *Disassembler::createInvalidInsn() { return NULL; } void Disassembler::hexd(char **s, int size, int options, uint32 imm) { char ff[16]; char *f = (char*)&ff; char *t = *s; *f++ = '%'; if (imm >= 0 && imm <= 9) { *s += sprintf(*s, "%d", imm); } else if (options & DIS_STYLE_SIGNED) { if (!(options & DIS_STYLE_HEX_NOZEROPAD)) f += sprintf(f, "0%d", size); *f++ = 'd'; *f = 0; *s += sprintf(*s, ff, imm); } else { if (options & DIS_STYLE_HEX_CSTYLE) *f++ = '#'; if (!(options & DIS_STYLE_HEX_NOZEROPAD)) f += sprintf(f, "0%d", size); if (options & DIS_STYLE_HEX_UPPERCASE) *f++ = 'X'; else *f++ = 'x'; if (options & DIS_STYLE_HEX_ASMSTYLE) *f++ = 'h'; *f = 0; *s += sprintf(*s, ff, imm); if ((options & DIS_STYLE_HEX_NOZEROPAD) && (*t-'0'>9)) { memmove(t+1, t, strlen(t)+1); *t = '0'; (*s)++; } } } void Disassembler::hexq(char **s, int size, int options, uint64 imm) { char ff[32]; char *f = (char*)&ff; char *t = *s; *f++ = '%'; if (imm >= 0 && imm <= 9) { *s += ht_snprintf(*s, 32, "%qd", imm); } else if (options & DIS_STYLE_SIGNED) { if (!(options & DIS_STYLE_HEX_NOZEROPAD)) f += sprintf(f, "0%d", size); *f++ = 'q'; *f++ = 'd'; *f = 0; *s += ht_snprintf(*s, 32, ff, imm); } else { if (options & DIS_STYLE_HEX_CSTYLE) *f++ = '#'; if (!(options & DIS_STYLE_HEX_NOZEROPAD)) f += sprintf(f, "0%d", size); if (options & DIS_STYLE_HEX_UPPERCASE) *f++ = 'X'; else *f++ = 'q'; *f++ = 'x'; if (options & DIS_STYLE_HEX_ASMSTYLE) *f++ = 'h'; *f = 0; *s += ht_snprintf(*s, 32, ff, imm); if ((options & DIS_STYLE_HEX_NOZEROPAD) && (*t-'0'>9)) { memmove(t+1, t, strlen(t)+1); *t = '0'; (*s)++; } } } bool Disassembler::selectNext(dis_insn *disasm_insn) { return false; } const char *Disassembler::str(dis_insn *disasm_insn, int style) { return strf(disasm_insn, style, DISASM_STRF_DEFAULT_FORMAT); } const char *Disassembler::get_cs(AsmSyntaxHighlightEnum style) { const char *highlights[] = { ASM_SYNTAX_DEFAULT, ASM_SYNTAX_COMMENT, ASM_SYNTAX_NUMBER, ASM_SYNTAX_SYMBOL, ASM_SYNTAX_STRING }; return highlight ? highlights[(int)style] : ""; } void Disassembler::enable_highlighting() { highlight = true; } void Disassembler::disable_highlighting() { highlight = false; } BUILDER(ATOM_DISASM_X86, x86dis, Disassembler) BUILDER(ATOM_DISASM_X86_64, x86_64dis, x86dis) BUILDER(ATOM_DISASM_X86_VXD, x86dis_vxd, x86dis) BUILDER(ATOM_DISASM_ALPHA, Alphadis, Disassembler) BUILDER(ATOM_DISASM_JAVA, javadis, Disassembler) BUILDER(ATOM_DISASM_IA64, IA64Disassembler, Disassembler) BUILDER(ATOM_DISASM_PPC, PPCDisassembler, Disassembler) BUILDER(ATOM_DISASM_IL, ILDisassembler, Disassembler) BUILDER(ATOM_DISASM_ARM, ArmDisassembler, Disassembler) bool init_asm() { REGISTER(ATOM_DISASM_X86, x86dis) REGISTER(ATOM_DISASM_X86_VXD, x86dis_vxd) REGISTER(ATOM_DISASM_ALPHA, Alphadis) REGISTER(ATOM_DISASM_JAVA, javadis) REGISTER(ATOM_DISASM_IA64, IA64Disassembler) REGISTER(ATOM_DISASM_PPC, PPCDisassembler) REGISTER(ATOM_DISASM_IL, ILDisassembler) REGISTER(ATOM_DISASM_X86_64, x86_64dis) REGISTER(ATOM_DISASM_ARM, ArmDisassembler) return true; } void done_asm() { UNREGISTER(ATOM_DISASM_ARM, ArmDisassembler) UNREGISTER(ATOM_DISASM_X86_64, x86dis) UNREGISTER(ATOM_DISASM_IL, ILDisassembler) UNREGISTER(ATOM_DISASM_PPC, PPCDisassembler) UNREGISTER(ATOM_DISASM_IA64, IA64Disassembler) UNREGISTER(ATOM_DISASM_JAVA, javadis) UNREGISTER(ATOM_DISASM_ALPHA, Alphadis) UNREGISTER(ATOM_DISASM_X86_VXD, x86dis_vxd) UNREGISTER(ATOM_DISASM_X86, x86dis) } ht-2.0.22/asm/ia64dis.cc0000644000175000001440000004773710634114571011503 00000000000000/* * HT Editor * ia64dis.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "data.h" #include "endianess.h" #include "ia64dis.h" #include "ia64opc.h" #include "snprintf.h" bool IA64Disassembler::selectNext(dis_insn *disasm_insn) { IA64DisInsn *insn = (IA64DisInsn *)disasm_insn; if (!insn->valid) return false; insn->selected += insn->slot[insn->selected].next; if (insn->selected > 2) { insn->selected = 0; return false; } return true; } uint64 IA64Disassembler::signExtend(uint64 a, int length) { uint64 sign = 1ULL << (length-1); if (a & sign) { sign <<= 1; sign -= 1; sign = ~sign; a |= sign; } return a; } void IA64Disassembler::decodeSlot(int slot_nb) { IA64SlotDisInsn *slot = &insn.slot[slot_nb]; byte role = insn.tmplt->slot[slot_nb] & 0xf0; if (role == IA64_INST_ROLE_LONG) { uint64 tmp = insn.slot[slot_nb].data; insn.slot[slot_nb].data = insn.slot[slot_nb+1].data; insn.slot[slot_nb+1].data = tmp; slot->next = 2; } else { slot->next = 1; } role >>= 4; uint32 major_opcode = (slot->data >> 37) & 0x0f; IA64DecisionTreeEntry dtree_entry = IA64DecisionTree[major_opcode * IA64_INST_ROLE_COUNT + role]; while (!IA64_DECISION_TREE_LEAF_NODE(dtree_entry)) { char pos = dtree_entry.pos - 6; char size = dtree_entry.size; uint32 value; if (pos < 0) { /* extensions in bits 0-5 */ // FIXME:redundant? pos += 6; value = (slot->data >> pos) & ((1 << size)-1); } else { value = (slot->data >> (pos+6)) & ((1 << size)-1); } uint16 next = dtree_entry.next_node + value; dtree_entry = IA64DecisionTree[next]; } uint16 inst_id = dtree_entry.next_node; if (inst_id >= IA64_OPCODE_INST_LAST || inst_id == IA64_OPCODE_ILLOP) { // FIXME: .. slot->valid = false; } else { slot->valid = true; slot->opcode = &IA64OpcodeTable[inst_id]; slot->qp = slot->data & 0x3f; for (int i=0; i<7; i++) slot->op[i].type = IA64_OPERAND_NO; int dest = 0; if (slot->opcode->op1.role == IA64_OPROLE_DST) { if (slot->opcode->op2.role == IA64_OPROLE_SRC) { dest = 2; } else { if (slot->opcode->op3.role == IA64_OPROLE_SRC) { dest = 3; } else { if (slot->opcode->op4.role == IA64_OPROLE_SRC) { dest = 4; } else { // ... } } } } if (dest) { slot->op[dest-1].type = IA64_OPERAND_EQUALS; } /* if (strcmp(slot->opcode->name, "adds")==0) { int as=0; }*/ switch (slot->opcode->format) { case IA64_FORMAT_A1: slot->op[0].type = IA64_OPERAND_REG; slot->op[0].reg = (slot->data >> 6) & 0x7f; slot->op[2].type = IA64_OPERAND_REG; slot->op[2].reg = (slot->data >> 13) & 0x7f; slot->op[3].type = IA64_OPERAND_REG; slot->op[3].reg = (slot->data >> 20) & 0x7f; if (slot->opcode->op1.type == IA64_OPTYPE_ONE) { slot->op[4].type = IA64_OPERAND_1; } break; case IA64_FORMAT_A3: slot->op[0].type = IA64_OPERAND_REG; slot->op[0].reg = (slot->data >> 6) & 0x7f; slot->op[2].type = IA64_OPERAND_IMM; slot->op[2].imm = ((slot->data >> 13) & 0x7f) | (((slot->data >> 36) & 1) << 7); slot->op[2].imm = signExtend(slot->op[2].imm, 8); slot->op[3].type = IA64_OPERAND_REG; slot->op[3].reg = ((slot->data >> 20) & 0x7f); break; case IA64_FORMAT_A4: slot->op[0].type = IA64_OPERAND_REG; slot->op[0].reg = ((slot->data >> 6) & 0x7f); slot->op[2].type = IA64_OPERAND_IMM; slot->op[2].imm = ((slot->data >> 13) & (0x7f)) | (((slot->data >> 27) & (0x3f)) << 7) |(((slot->data >> 36) & (1)) << 13); slot->op[2].imm = signExtend(slot->op[2].imm, 14); slot->op[3].type = IA64_OPERAND_REG; slot->op[3].reg = ((slot->data >> 20) & (0x7f)); break; case IA64_FORMAT_A5: slot->op[0].type = IA64_OPERAND_REG; slot->op[0].reg = ((slot->data >> 6) & (0x7f)); slot->op[2].type = IA64_OPERAND_IMM; slot->op[2].imm = ((slot->data >> 13) & (0x7f)) | (((slot->data >> 22) & (0x7fff)) << 7); slot->op[2].imm = signExtend(slot->op[2].imm, 22); slot->op[3].type = IA64_OPERAND_REG; slot->op[3].reg = ((slot->data >> 20) & 0x3); break; case IA64_FORMAT_A6: case IA64_FORMAT_A7: slot->op[0].type = IA64_OPERAND_PREG; slot->op[0].reg = ((slot->data >> 6) & 0x3f); slot->op[1].type = IA64_OPERAND_PREG; slot->op[1].reg = ((slot->data >> 27) & 0x3f); slot->op[3].type = IA64_OPERAND_REG; slot->op[3].reg = ((slot->data >> 13) & 0x7f); slot->op[4].type = IA64_OPERAND_REG; slot->op[4].reg = ((slot->data >> 20) & 0x7f); break; case IA64_FORMAT_A8: slot->op[0].type = IA64_OPERAND_PREG; slot->op[0].reg = ((slot->data >> 6) & 0x3f); slot->op[1].type = IA64_OPERAND_PREG; slot->op[1].reg = ((slot->data >> 27) & 0x3f); slot->op[3].type = IA64_OPERAND_IMM; slot->op[3].imm = ((slot->data >> 13) & 0x7f) |(((slot->data >> 36) & (1)) << 7); slot->op[3].imm = signExtend(slot->op[3].imm, 8); slot->op[4].type = IA64_OPERAND_REG; slot->op[4].reg = ((slot->data >> 20) & 0x7f); break; case IA64_FORMAT_B1: case IA64_FORMAT_B2: slot->op[0].type = IA64_OPERAND_ADDRESS; slot->op[0].ofs = ((slot->data >> 13) & ((1<<20)-1)) |(((slot->data >> 36) & (1)) << 20); slot->op[0].ofs = signExtend(slot->op[0].ofs, 21); slot->op[0].ofs <<= 4; slot->op[0].ofs += cpu_addr.flat64.addr; break; case IA64_FORMAT_B3: slot->op[0].type = IA64_OPERAND_BREG; slot->op[0].reg = ((slot->data >> 6) & (0x7)); slot->op[2].type = IA64_OPERAND_ADDRESS; slot->op[2].ofs = ((slot->data >> 13) & ((1<<20)-1)) |(((slot->data >> 36) & (1)) << 20); slot->op[2].ofs = signExtend(slot->op[2].ofs, 21); slot->op[2].ofs <<= 4; slot->op[2].ofs += cpu_addr.flat64.addr; break; case IA64_FORMAT_B4: slot->op[0].type = IA64_OPERAND_BREG; slot->op[0].reg = ((slot->data >> 13) & (0x7)); break; case IA64_FORMAT_B5: slot->op[0].type = IA64_OPERAND_BREG; slot->op[0].reg = ((slot->data >> 6) & (0x7)); slot->op[2].type = IA64_OPERAND_BREG; slot->op[2].reg = ((slot->data >> 13) & (0x7)); break; case IA64_FORMAT_B9: case IA64_FORMAT_F15: case IA64_FORMAT_I19: case IA64_FORMAT_M37: slot->op[0].type = IA64_OPERAND_IMM; slot->op[0].imm = ((slot->data >> 6) & ((1<<20)-1)) |(((slot->data >> 36) & (1)) << 20); break; case IA64_FORMAT_F2: slot->op[0].type = IA64_OPERAND_FREG; slot->op[0].reg = ((slot->data >> 6) & (0x7f)); slot->op[2].type = IA64_OPERAND_FREG; slot->op[2].reg = ((slot->data >> 20) & (0x7f)); slot->op[3].type = IA64_OPERAND_FREG; slot->op[3].reg = ((slot->data >> 27) & (0x7f)); slot->op[4].type = IA64_OPERAND_FREG; slot->op[4].reg = ((slot->data >> 13) & (0x7f)); break; case IA64_FORMAT_I21: slot->op[0].type = IA64_OPERAND_BREG; slot->op[0].reg = ((slot->data >> 6) & (0x7)); slot->op[2].type = IA64_OPERAND_REG; slot->op[2].reg = ((slot->data >> 13) & (0x7f)); slot->op[3].type = IA64_OPERAND_ADDRESS; slot->op[3].imm = (slot->data >> 24) & (0x1ff); slot->op[3].imm = (signExtend(slot->op[3].imm, 9)<<4)+cpu_addr.flat64.addr; break; case IA64_FORMAT_I22: slot->op[0].type = IA64_OPERAND_REG; slot->op[0].reg = ((slot->data >> 6) & (0x7f)); slot->op[2].type = IA64_OPERAND_BREG; slot->op[2].reg = ((slot->data >> 13) & (0x7)); break; case IA64_FORMAT_I23: slot->op[0].type = IA64_OPERAND_PRALL; slot->op[2].type = IA64_OPERAND_REG; slot->op[2].reg = ((slot->data >> 13) & (0x7f)); slot->op[3].type = IA64_OPERAND_IMM; slot->op[3].imm = (((slot->data >> 6) & (0x7f)) << 1) |(((slot->data >> 24) & (0xff)) << 8) |(((slot->data >> 36) & (1)) << 16); slot->op[3].imm = signExtend(slot->op[3].imm, 17); break; case IA64_FORMAT_I24: slot->op[0].type = IA64_OPERAND_PRROT; slot->op[2].type = IA64_OPERAND_IMM; slot->op[2].imm = (((slot->data >> 6) & (0x7ffffff)) << 16) |(((slot->data >> 36) & (1)) << 43); slot->op[2].imm = signExtend(slot->op[2].imm, 28); break; case IA64_FORMAT_I25: slot->op[0].type = IA64_OPERAND_REG; slot->op[0].reg = ((slot->data >> 6) & (0x7f)); if (slot->opcode->op2.type == IA64_OPTYPE_IP) { slot->op[2].type = IA64_OPERAND_IP; } else { slot->op[2].type = IA64_OPERAND_PRALL; } break; case IA64_FORMAT_I26: case IA64_FORMAT_M29: slot->op[0].type = IA64_OPERAND_AREG; slot->op[0].reg = ((slot->data >> 20) & (0x7f)); slot->op[2].type = IA64_OPERAND_REG; slot->op[2].reg = ((slot->data >> 13) & (0x7f)); break; case IA64_FORMAT_I27: case IA64_FORMAT_M31: slot->op[0].type = IA64_OPERAND_REG; slot->op[0].reg = ((slot->data >> 6) & (0x7f)); slot->op[2].type = IA64_OPERAND_AREG; slot->op[2].reg = ((slot->data >> 20) & (0x7f)); break; case IA64_FORMAT_I28: break; case IA64_FORMAT_I29: slot->op[0].type = IA64_OPERAND_REG; slot->op[0].reg = ((slot->data >> 6) & (0x7f)); slot->op[2].type = IA64_OPERAND_REG; slot->op[2].reg = ((slot->data >> 20) & (0x7f)); break; case IA64_FORMAT_M3: slot->op[3].type = IA64_OPERAND_IMM; slot->op[3].imm = ((slot->data >> 13) & (0x7f)) |(((slot->data >> 27) & (1))<<7) |(((slot->data >> 36) & (1))<<8); slot->op[3].imm = signExtend(slot->op[3].imm, 9); goto m1; case IA64_FORMAT_M2: slot->op[3].type = IA64_OPERAND_REG; slot->op[3].reg = ((slot->data >> 13) & (0x7f)); // fall-through case IA64_FORMAT_M1: m1: slot->op[0].type = IA64_OPERAND_REG; slot->op[0].reg = ((slot->data >> 6) & (0x7f)); slot->op[2].type = IA64_OPERAND_MEM_REG; slot->op[2].reg = ((slot->data >> 20) & (0x7f)); break; case IA64_FORMAT_M5: slot->op[3].type = IA64_OPERAND_IMM; slot->op[3].imm = ((slot->data >> 6) & (0x7f)) |(((slot->data >> 27) & (1))<<7) |(((slot->data >> 36) & (1))<<8); slot->op[3].imm = signExtend(slot->op[3].imm, 9); goto m4; case IA64_FORMAT_M4: m4: slot->op[0].type = IA64_OPERAND_MEM_REG; slot->op[0].reg = ((slot->data >> 20) & (0x7f)); slot->op[2].type = IA64_OPERAND_REG; slot->op[2].reg = ((slot->data >> 13) & (0x7f)); break; case IA64_FORMAT_M18: slot->op[0].type = IA64_OPERAND_FREG; slot->op[0].reg = ((slot->data >> 6) & (0x7f)); slot->op[2].type = IA64_OPERAND_REG; slot->op[2].reg = ((slot->data >> 13) & (0x7f)); break; case IA64_FORMAT_M19: slot->op[0].type = IA64_OPERAND_REG; slot->op[0].reg = ((slot->data >> 6) & (0x7f)); slot->op[2].type = IA64_OPERAND_FREG; slot->op[2].reg = ((slot->data >> 13) & (0x7f)); break; case IA64_FORMAT_M30: slot->op[0].type = IA64_OPERAND_AREG; slot->op[0].reg = ((slot->data >> 20) & (0x7f)); slot->op[2].type = IA64_OPERAND_IMM; slot->op[2].imm = ((slot->data >> 13) & 0x7f) |(((slot->data >> 36) & (1)) << 7); slot->op[2].imm = signExtend(slot->op[2].imm, 8); break; case IA64_FORMAT_M32: break; case IA64_FORMAT_M33: break; case IA64_FORMAT_M34: slot->op[0].type = IA64_OPERAND_REG; slot->op[0].reg = ((slot->data >> 6) & (0x7f)); slot->op[2].type = IA64_OPERAND_AR_PFS; slot->op[3].type = IA64_OPERAND_IMM; slot->op[3].imm = (slot->data >> 20) & (0x7f); slot->op[4].type = IA64_OPERAND_IMM; slot->op[4].imm = (0); slot->op[5].type = IA64_OPERAND_IMM; slot->op[5].imm = ((slot->data >> 13) & 0x7f)-slot->op[3].imm; slot->op[6].type = IA64_OPERAND_IMM; slot->op[6].imm = ((slot->data >> 27) & (0xf))<<3; break; case IA64_FORMAT_M35: break; case IA64_FORMAT_M36: break; case IA64_FORMAT_M42: slot->op[0].type = IA64_OPERAND_REG_FILE; slot->op[0].regfile.db = slot->opcode->op1.type - IA64_OPTYPE_PMC; slot->op[0].regfile.idx = ((slot->data >> 20) & (0x7f)); slot->op[2].type = IA64_OPERAND_REG; slot->op[2].reg = ((slot->data >> 13) & (0x7f)); break; case IA64_FORMAT_M43: break; case IA64_FORMAT_M45: slot->op[0].type = IA64_OPERAND_REG; slot->op[0].reg = ((slot->data >> 13) & (0x7f)); slot->op[1].type = IA64_OPERAND_REG; slot->op[1].reg = ((slot->data >> 20) & (0x7f)); break; case IA64_FORMAT_X2: slot->op[0].type = IA64_OPERAND_REG; slot->op[0].reg = ((slot->data >> 6) & (0x7f)); slot->op[2].type = IA64_OPERAND_IMM; slot->op[2].imm = ((slot->data >> 13) & (0x7f)) |(((slot->data >> 27) & (0x1ff)) << 7) |(((slot->data >> 22) & (0x1f)) << 16) |(((slot->data >> 21) & (1)) << 21) |(insn.slot[slot_nb+1].data << 22) |(((slot->data >> 36) & (1)) << 63); break; default: break; } } } dis_insn *IA64Disassembler::decode(byte *code, int maxlen, CPU_ADDR addr) { cpu_addr = addr; insn.selected = 0; if (maxlen < 16) { // invalid insn.valid = false; insn.size = maxlen; if (maxlen) memcpy(insn.data, code, maxlen); } else { insn.valid = true; insn.size = 16; if (maxlen) memcpy(insn.data, code, maxlen); insn.tmplt_idx = code[0] & 0x1f; insn.tmplt = &IA64Templates[insn.tmplt_idx]; if (insn.tmplt->slot[0] == IA64_SLOT_INVALID) { insn.valid = false; } else { insn.slot[0].data = (uint32(code[0]) >> 5) | (uint32(code[1]) << 3) | (uint32(code[2]) << 11) | (uint32(code[3]) << 19) | (uint32(code[4] & 0x1f) << 27) // 32 bits | ((uint64(code[4] >> 5) | (uint64(code[5] & 0x3f) << 3)) << 32); // +9 = 41 bits insn.slot[1].data = (uint32(code[5]) >> 6) | (uint32(code[6]) << 2) | (uint32(code[7]) << 10) | (uint32(code[8]) << 18) | (uint32(code[9] & 0x3f) << 26) // 32 bits | ((uint64(code[9] >> 6) | (uint64(code[10] & 0x7f) << 2)) << 32); // +9 = 41 bits insn.slot[2].data = (uint32(code[10]) >> 7) | (uint32(code[11]) << 1) | (uint32(code[12]) << 9) | (uint32(code[13]) << 17) | (uint32(code[14] & 0x7f) << 25) // 32 bits | ((uint64(code[14] >> 7) | (uint64(code[15]) << 1)) << 32); // +9 = 41 bits } for (int i=0; i<3; ) { insn.slot[i].valid = false; decodeSlot(i); i += insn.slot[i].next; } } return (dis_insn*)&insn; } dis_insn *IA64Disassembler::duplicateInsn(dis_insn *disasm_insn) { IA64DisInsn *insn = ht_malloc(sizeof (IA64DisInsn)); *insn = *(IA64DisInsn *)disasm_insn; return insn; } void IA64Disassembler::getOpcodeMetrics(int &min_length, int &max_length, int &min_look_ahead, int &avg_look_ahead, int &addr_align) { min_length = 16; max_length = 16; min_look_ahead = 16; avg_look_ahead = 16; addr_align = 16; } byte IA64Disassembler::getSize(dis_insn *disasm_insn) { return ((IA64DisInsn*)disasm_insn)->size; } const char *IA64Disassembler::getName() { return "IA64/Disassembler"; } const char *IA64Disassembler::str(dis_insn *disasm_insn, int style) { return strf(disasm_insn, style, ""); } const char *IA64Disassembler::strf(dis_insn *disasm_insn, int style, const char *format) { if (style & DIS_STYLE_HIGHLIGHT) enable_highlighting(); const char *cs_default = get_cs(e_cs_default); const char *cs_number = get_cs(e_cs_number); const char *cs_symbol = get_cs(e_cs_symbol); // const char *cs_string = get_cs(e_cs_string); const char *cs_comment = get_cs(e_cs_comment); IA64DisInsn *dis_insn = (IA64DisInsn *) disasm_insn; if (!dis_insn->valid) { char *is = insnstr + sprintf(insnstr, "db "); for (int i=0; i < dis_insn->size; i++) { is += sprintf(is, "%s%02x", cs_number, dis_insn->data[i]); if (i==7) is += sprintf(is, "-"); } } else { char *is = insnstr; IA64SlotDisInsn *slot = &dis_insn->slot[dis_insn->selected]; is[0] = 0; if (slot->valid) { char qp[10]; if (slot->qp) { ht_snprintf(qp, sizeof qp, "(p%d)", slot->qp); } else { qp[0] = 0; } is += ht_snprintf(is, 256, "%s%d %5s %s%-20s", cs_comment, dis_insn->selected, qp, cs_default, slot->opcode->name); for (int i=0; i < 7; i++) { if (slot->op[i].type == IA64_OPERAND_NO) break; if (slot->op[i].type == IA64_OPERAND_EQUALS) { is += ht_snprintf(is, 256, " %s= ", cs_symbol); i++; goto w; } else { if (i != 0) is += ht_snprintf(is, 256, "%s, ", cs_symbol); } w: switch (slot->op[i].type) { case IA64_OPERAND_1: is += ht_snprintf(is, 256, "%s1", cs_number); break; case IA64_OPERAND_REG: is += ht_snprintf(is, 256, "%sr%d", cs_default, slot->op[i].reg); break; case IA64_OPERAND_BREG: is += ht_snprintf(is, 256, "%sbr%d", cs_default, slot->op[i].reg); break; case IA64_OPERAND_FREG: is += ht_snprintf(is, 256, "%sf%d", cs_default, slot->op[i].reg); break; case IA64_OPERAND_PREG: is += ht_snprintf(is, 256, "%sp%d", cs_default, slot->op[i].reg); break; case IA64_OPERAND_AREG: is += ht_snprintf(is, 256, "%sar%d", cs_default, slot->op[i].reg); break; case IA64_OPERAND_PRALL: is += ht_snprintf(is, 256, "%spr", cs_default); break; case IA64_OPERAND_PRROT: is += ht_snprintf(is, 256, "%spr.rot", cs_default); break; case IA64_OPERAND_AR_PFS: is += ht_snprintf(is, 256, "%sar.pfs", cs_default); break; case IA64_OPERAND_IP: is += ht_snprintf(is, 256, "%sip", cs_default); break; case IA64_OPERAND_MEM_REG: is += ht_snprintf(is, 256, "%s[%sr%d%s]", cs_symbol, cs_default, slot->op[i].reg, cs_symbol); break; case IA64_OPERAND_IMM: is += ht_snprintf(is, 256, "%s%qx", cs_number, slot->op[i].imm); break; case IA64_OPERAND_ADDRESS: { CPU_ADDR caddr; caddr.flat64.addr = slot->op[i].ofs; int slen; char *s = (addr_sym_func) ? addr_sym_func(caddr, &slen, addr_sym_func_context) : NULL; if (s) { char *p = is; memmove(p, s, slen); p[slen] = 0; is += slen; } else { is += ht_snprintf(is, 256, "%s0x%qx", cs_number, &slot->op[i].ofs); } break; } case IA64_OPERAND_REG_FILE: { const char *dbs[] = {"pmc", "pmd", "pkr", "rr", "ibr", "dbr", "itr", "dtr", "msr"}; is += ht_snprintf(is, 256, "%s%s[%sr%d%s]", dbs[slot->op[i].regfile.db], cs_symbol, cs_default, slot->op[i].regfile.idx, cs_symbol); } } } } else { is += ht_snprintf(is, 256, "%s%d %-20s", cs_comment, dis_insn->selected, "invalid"); } char tmplt_str[100]; tmplt_str[0] = 0; char *t = tmplt_str; for (int i=0; i<3; i++) { switch (insn.tmplt->slot[i] & 0x0f) { case IA64_SLOT_INVALID: t+=sprintf(t, "*"); goto e; break; case IA64_SLOT_M_UNIT: t+=sprintf(t, "M"); break; case IA64_SLOT_I_UNIT: t+=sprintf(t, "I"); break; case IA64_SLOT_L_UNIT: t+=sprintf(t, "L"); break; case IA64_SLOT_X_UNIT: t+=sprintf(t, "X"); break; case IA64_SLOT_F_UNIT: t+=sprintf(t, "F"); break; case IA64_SLOT_B_UNIT: t+=sprintf(t, "B"); break; } } e:; // is += ht_snprintf(is, 256, " t=%02x(%s) s0=%013Q s1=%013Q s2=%013Q", insn.tmplt_idx, tmplt_str, &insn.slot[0].data, &insn.slot[1].data, &insn.slot[2].data); /* for (int i=0; i < dis_insn->size; i++) { is += sprintf(is, "%s%02x", cs_number, dis_insn->data[i]); if (i==7) is += sprintf(is, "-"); }*/ } disable_highlighting(); return insnstr; } ObjectID IA64Disassembler::getObjectID() const { return ATOM_DISASM_IA64; } bool IA64Disassembler::validInsn(dis_insn *disasm_insn) { return ((IA64DisInsn *)disasm_insn)->valid; } ht-2.0.22/config.guess0000755000175000017500000013014512146142707011461 00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright 1992-2013 Free Software Foundation, Inc. timestamp='2013-05-16' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # # Originally written by Per Bothner. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD # # Please send patches with a ChangeLog entry to config-patches@gnu.org. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright 1992-2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown case "${UNAME_SYSTEM}" in Linux|GNU|GNU/*) # If the system lacks a compiler, then just pick glibc. # We could probably try harder. LIBC=gnu eval $set_cc_for_build cat <<-EOF > $dummy.c #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc #else LIBC=gnu #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` ;; esac # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:Bitrig:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm*:riscos:*:*|arm*:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) UNAME_PROCESSOR=`/usr/bin/uname -p` case ${UNAME_PROCESSOR} in amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW64*:*) echo ${UNAME_MACHINE}-pc-mingw64 exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; aarch64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; aarch64_be:Linux:*:*) UNAME_MACHINE=aarch64_be echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="gnulibc1" ; fi echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arc:Linux:*:* | arceb:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-${LIBC} else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi else echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; cris:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; crisv32:Linux:*:*) echo ${UNAME_MACHINE}-axis-linux-${LIBC} exit ;; frv:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; hexagon:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:Linux:*:*) echo ${UNAME_MACHINE}-pc-linux-${LIBC} exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;; or1k:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; or32:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*) echo sparc-unknown-linux-${LIBC} exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-${LIBC} exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; *) echo hppa-unknown-linux-${LIBC} ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-${LIBC} exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-${LIBC} exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux-${LIBC} exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-${LIBC} exit ;; x86_64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; x86_64:Haiku:*:*) echo x86_64-unknown-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown eval $set_cc_for_build if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then case $UNAME_PROCESSOR in i386) UNAME_PROCESSOR=x86_64 ;; powerpc) UNAME_PROCESSOR=powerpc64 ;; esac fi fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-*:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; x86_64:VMkernel:*:*) echo ${UNAME_MACHINE}-unknown-esx exit ;; esac eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: ht-2.0.22/eval/0000755000175000017500000000000012156433676010155 500000000000000ht-2.0.22/eval/evaltype.h0000644000175000001440000000171710615343233012064 00000000000000#ifndef EVALTYPE_H #define EVALTYPE_H #define MAX_EVALFUNC_PARAMS 8 #include "io/types.h" /* * Types */ typedef enum { TYPE_UNKNOWN, TYPE_BYTE, TYPE_WORD, TYPE_DWORD } eval_inttype; typedef struct { uint64 value; eval_inttype type; } eval_int; typedef struct { double value; } eval_float; typedef struct { char *value; int len; } eval_str; typedef enum { SCALAR_NULL=0, SCALAR_INT, SCALAR_STR, SCALAR_FLOAT, SCALAR_ANY, SCALAR_VARARGS } eval_scalartype; typedef union { eval_int integer; eval_str str; eval_float floatnum; } eval_scalarbody; typedef struct { eval_scalartype type; eval_scalarbody scalar; } eval_scalar; typedef struct { int count; eval_scalar *scalars; } eval_scalarlist; typedef struct { const char *name; void *func; eval_scalartype ptype[MAX_EVALFUNC_PARAMS]; const char *desc; } eval_func; typedef enum { PROTOMATCH_OK=0, PROTOMATCH_NAME_FAIL, PROTOMATCH_PARAM_FAIL } eval_protomatch; #endif /* EVALTYPE_H */ ht-2.0.22/eval/eval.cc0000644000175000001440000010326611010140022011277 00000000000000/* * HT Editor * eval.cc * * Copyright (C) 1999, 2000, 2001 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "evaltype.h" #include "evalparse.h" #include "eval.h" #include "snprintf.h" #include "strtools.h" #ifdef EVAL_DEBUG int debug_dump_ident; #endif #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) /* * */ static eval_func_handler g_eval_func_handler; static eval_symbol_handler g_eval_symbol_handler; static void *eval_context; static int helpmode = 0; static eval_scalar helpstring; static char helpname[MAX_FUNCNAME_LEN+1]; uint64 f2i(double f) { uint64 r; if (f>0) r = (sint64)(f+.5); else r = (sint64)(f-.5); return r; } void set_helpmode(int flag, char *name) { helpmode = flag; int l = name ? strlen(name) : (MAX_FUNCNAME_LEN+1); if (l>MAX_FUNCNAME_LEN) { *helpname = 0; return; } strcpy(helpname, name); } static uint64 ipow(uint64 a, uint64 b) { uint64 r = 1ULL; uint64 m = 1ULL << 63; while (m != 0) { r *= r; if ((b & m) != 0) { r *= a; } m = m >> 1; } return r; } /* static int sprint_basen(char *buffer, int base, uint64 q) { static char *chars="0123456789abcdef"; if ((base<2) || (base>16)) return 0; int n = 0; char *b = buffer; while (q != to_qword(0)) { int c = QWORD_GET_INT(q % to_qword(base)); *buffer++ = chars[c]; n++; q /= to_qword(base); } for (int i=0; i < n/2; i++) { char t = b[i]; b[i] = b[n-i-1]; b[n-i-1] = t; } b[n] = 0; return n; } */ static void str2int(char *str, uint64 *q, int base) { *q = 0; uint64 qbase = base; while (*str) { int c = hexdigit(*str); if ((c == -1) || (c >= base)) break; *q *= qbase; *q += c; str++; } } char *binstr2cstr(char *s, int len) { char *x = ht_malloc(len+1); memcpy(x, s, len); x[len]=0; return x; } int bin2str(char *result, void *S, int len) { unsigned char *s = (unsigned char*)S; while (len--) { if (*s==0) *result=' '; else *result=*s; result++; s++; } *result=0; return len; } /* * ERROR HANDLING */ static int eval_error; static int eval_error_pos; static char eval_errstr[MAX_ERRSTR_LEN]; void clear_eval_error() { eval_error=0; } int get_eval_error(const char **str, int *pos) { if (eval_error) { if (str) *str = eval_errstr; if (pos) *pos = eval_error_pos; return eval_error; } if (str) *str = "?"; if (pos) *pos = 0; return 0; } void set_eval_error(const char *format,...) { va_list vargs; va_start(vargs, format); ht_vsnprintf(eval_errstr, sizeof eval_errstr, format, vargs); va_end(vargs); eval_error_pos = lex_current_buffer_pos(); eval_error = 1; } void set_eval_error_ex(int pos, const char *format, ...) { va_list vargs; va_start(vargs, format); ht_vsnprintf(eval_errstr, sizeof eval_errstr, format, vargs); va_end(vargs); eval_error_pos = pos; eval_error = 1; } /* * */ #ifdef EVAL_DEBUG void integer_dump(eval_int *i) { printf("%d", i->value); } void float_dump(eval_float *f) { printf("%f", f->value); } void string_dump(eval_str *s) { int i; for (i=0; ilen; i++) { if ((unsigned)s->value[i]<32) { printf("\\x%x", s->value[i]); } else { printf("%c", s->value[i]); } } } #endif void string_destroy(eval_str *s) { if (s->value) free(s->value); } /* * SCALARLIST */ void scalarlist_set(eval_scalarlist *l, eval_scalar *s) { l->count = 1; l->scalars = ht_malloc(sizeof (eval_scalar) * l->count); l->scalars[0] = *s; } void scalarlist_concat(eval_scalarlist *l, eval_scalarlist *a, eval_scalarlist *b) { l->count = a->count+b->count; l->scalars = ht_malloc(sizeof (eval_scalar) * l->count); memcpy(l->scalars, a->scalars, sizeof (eval_scalar) * a->count); memcpy(l->scalars + a->count, b->scalars, sizeof (eval_scalar) * b->count); } void scalarlist_destroy(eval_scalarlist *l) { int i; if (l && l->scalars) { for (i=0; i < l->count; i++) { scalar_destroy(&l->scalars[i]); } free(l->scalars); } } void scalarlist_destroy_gentle(eval_scalarlist *l) { if (l && l->scalars) free(l->scalars); } #ifdef EVAL_DEBUG void scalarlist_dump(eval_scalarlist *l) { int i; for (i=0; icount; i++) { scalar_dump(&l->scalars[i]); if (i!=l->count-1) { printf(", "); } } } #endif /* * SCALAR */ void scalar_setint(eval_scalar *s, eval_int *i) { s->type=SCALAR_INT; s->scalar.integer=*i; } void scalar_setstr(eval_scalar *s, eval_str *t) { s->type=SCALAR_STR; s->scalar.str=*t; } #ifdef EVAL_DEBUG void scalar_dump(eval_scalar *s) { switch (s->type) { case SCALAR_STR: { string_dump(&s->scalar.str); break; } case SCALAR_INT: { integer_dump(&s->scalar.integer); break; } case SCALAR_FLOAT: { float_dump(&s->scalar.floatnum); break; } default: break; } } #endif void scalar_create_int(eval_scalar *s, const eval_int *t) { s->type = SCALAR_INT; s->scalar.integer=*t; } void scalar_create_int_c(eval_scalar *s, const int i) { s->type = SCALAR_INT; s->scalar.integer.value = (sint64)i; s->scalar.integer.type = TYPE_UNKNOWN; } void scalar_create_int_q(eval_scalar *s, const uint64 q) { s->type = SCALAR_INT; s->scalar.integer.value = q; s->scalar.integer.type = TYPE_UNKNOWN; } void scalar_create_str(eval_scalar *s, const eval_str *t) { s->type = SCALAR_STR; s->scalar.str.value = ht_malloc(t->len ? t->len : 1); memcpy(s->scalar.str.value, t->value, t->len); s->scalar.str.len = t->len; } void scalar_create_str_c(eval_scalar *s, const char *cstr) { eval_str t; t.value = (char*)cstr; t.len = strlen(cstr); scalar_create_str(s, &t); } void scalar_create_float(eval_scalar *s, const eval_float *t) { s->type=SCALAR_FLOAT; s->scalar.floatnum=*t; } void scalar_create_float_c(eval_scalar *s, const double f) { s->type=SCALAR_FLOAT; s->scalar.floatnum.value=f; } void scalar_context_str(const eval_scalar *s, eval_str *t) { switch (s->type) { case SCALAR_INT: { char buf[64]; ht_snprintf(buf, sizeof buf, "%qd", /* FIXME: by reference*/ &s->scalar.integer.value); t->value = (char*)strdup(buf); t->len = strlen(buf); break; } case SCALAR_STR: { t->value = ht_malloc(s->scalar.str.len ? s->scalar.str.len : 1); t->len = s->scalar.str.len; memcpy(t->value, s->scalar.str.value, t->len); break; } case SCALAR_FLOAT: { char buf[64]; ht_snprintf(buf, sizeof buf, "%f", s->scalar.floatnum.value); t->value = (char*)strdup(buf); t->len = strlen(buf); break; } default: break; } } void scalar_context_int(const eval_scalar *s, eval_int *t) { switch (s->type) { case SCALAR_INT: { *t=s->scalar.integer; break; } case SCALAR_STR: { char *x = binstr2cstr(s->scalar.str.value, s->scalar.str.len); str2int(x, &t->value, 10); t->type = TYPE_UNKNOWN; free(x); break; } case SCALAR_FLOAT: { t->value=f2i(s->scalar.floatnum.value); t->type=TYPE_UNKNOWN; break; } default: break; } } void scalar_context_float(const eval_scalar *s, eval_float *t) { switch (s->type) { case SCALAR_INT: t->value = s->scalar.integer.value; break; case SCALAR_STR: { char *x = binstr2cstr(s->scalar.str.value, s->scalar.str.len); t->value = strtod(x, (char**)NULL); free(x); break; } case SCALAR_FLOAT: *t = s->scalar.floatnum; break; default: break; } } void string_concat(eval_str *s, eval_str *a, eval_str *b) { s->value = ht_malloc(a->len+b->len ? a->len+b->len : 1); memcpy(s->value, a->value, a->len); memcpy(s->value + a->len, b->value, b->len); s->len = a->len+b->len; free(a->value); a->len = 0; free(b->value); b->len = 0; } void scalar_clone(eval_scalar *result, const eval_scalar *s) { switch (s->type) { case SCALAR_INT: { *result = *s; break; } case SCALAR_STR: { *result = *s; result->scalar.str.value = ht_malloc(result->scalar.str.len); memcpy(result->scalar.str.value, s->scalar.str.value, result->scalar.str.len); break; } case SCALAR_FLOAT: { *result = *s; break; } default: break; } } void scalar_concat(eval_scalar *s, const eval_scalar *a, const eval_scalar *b) { eval_str as, bs, rs; scalar_context_str(a, &as); scalar_context_str(b, &bs); string_concat(&rs, &as, &bs); s->type=SCALAR_STR; s->scalar.str=rs; } void scalar_destroy(eval_scalar *s) { switch (s->type) { case SCALAR_STR: string_destroy(&s->scalar.str); break; default: break; } } int string_compare(const eval_str *a, const eval_str *b) { if (a->len==b->len) { return memcmp(a->value, b->value, a->len); } return a->len-b->len; } int scalar_strop(eval_scalar *xr, const eval_scalar *xa, const eval_scalar *xb, int op) { eval_str as, bs; int r; int c; scalar_context_str(xa, &as); scalar_context_str(xb, &bs); c = string_compare(&as, &bs); switch (op) { case EVAL_STR_EQ: r=(c==0); break; case EVAL_STR_NE: r=(c!=0); break; case EVAL_STR_GT: r=(c>0); break; case EVAL_STR_GE: r=(c>=0); break; case EVAL_STR_LT: r=(c<0); break; case EVAL_STR_LE: r=(c>=0); break; default: return 0; } xr->type = SCALAR_INT; xr->scalar.integer.value = r; xr->scalar.integer.type = TYPE_UNKNOWN; return 1; } int scalar_float_op(eval_scalar *xr, const eval_scalar *xa, const eval_scalar *xb, int op) { eval_float ai, bi; float a, b, r; scalar_context_float(xa, &ai); scalar_context_float(xb, &bi); a = ai.value; b = bi.value; switch (op) { case '*': r = a*b; break; case '/': { if (!b) { set_eval_error("division by zero"); return 0; } r = a/b; break; } case '+': r = a+b; break; case '-': r = a-b; break; case EVAL_POW: r = pow(a,b); break; default: { uint64 ri; switch (op) { case EVAL_EQ: ri = a==b; break; case EVAL_NE: ri = a!=b; break; case EVAL_GT: ri = a>b; break; case EVAL_GE: ri = a>=b; break; case EVAL_LT: ri = atype = SCALAR_INT; xr->scalar.integer.value = ri; xr->scalar.integer.type = TYPE_UNKNOWN; return 1; } } xr->type = SCALAR_FLOAT; xr->scalar.floatnum.value = r; return 1; } int scalar_int_op(eval_scalar *xr, const eval_scalar *xa, const eval_scalar *xb, int op) { eval_int ai, bi; uint64 a, b, r; scalar_context_int(xa, &ai); scalar_context_int(xb, &bi); a = ai.value; b = bi.value; switch (op) { case '*': r = a*b; break; case '/': { if (!b) { set_eval_error("division by zero"); return 0; } r = a/b; break; } case '%': { if (!b) { set_eval_error("division by zero"); return 0; } r = a%b; break; } case '+': r=a+b; break; case '-': r=a-b; break; case '&': r=a&b; break; case '|': r=a|b; break; case '^': r=a^b; break; // FIXME case EVAL_POW: r = ipow(a, b); break; // case EVAL_POW: r = to_qword((int)pow(QWORD_GET_INT(a),QWORD_GET_INT(b))); break; case EVAL_SHL: r = a << b; break; case EVAL_SHR: r = a >> b; break; case EVAL_EQ: r = a==b; break; case EVAL_NE: r = a!=b; break; case EVAL_GT: r = a>b; break; case EVAL_GE: r = a>=b; break; case EVAL_LT: r = atype = SCALAR_INT; xr->scalar.integer.value = r; xr->scalar.integer.type = TYPE_UNKNOWN; return 1; } int scalar_op(eval_scalar *xr, eval_scalar *xa, eval_scalar *xb, int op) { int r; if ((xa->type==SCALAR_FLOAT) || (xb->type==SCALAR_FLOAT)) { r=scalar_float_op(xr, xa, xb, op); } else { r=scalar_int_op(xr, xa, xb, op); } scalar_destroy(xa); scalar_destroy(xb); return r; } void scalar_negset(eval_scalar *xr, eval_scalar *xa) { if (xa->type==SCALAR_FLOAT) { eval_float a; a=xa->scalar.floatnum; xr->type=SCALAR_FLOAT; xr->scalar.floatnum.value=-a.value; } else { eval_int a; scalar_context_int(xa, &a); xr->type=SCALAR_INT; xr->scalar.integer.value=-a.value; xr->scalar.integer.type=TYPE_UNKNOWN; } scalar_destroy(xa); } void scalar_notset(eval_scalar *xr, eval_scalar *xa) { eval_int a; scalar_context_int(xa, &a); xr->type=SCALAR_INT; xr->scalar.integer.value=~a.value; xr->scalar.integer.type=TYPE_UNKNOWN; scalar_destroy(xa); } void scalar_lnotset(eval_scalar *xr, eval_scalar *xa) { eval_int a; scalar_context_int(xa, &a); xr->type = SCALAR_INT; xr->scalar.integer.value = !a.value; xr->scalar.integer.type = TYPE_UNKNOWN; scalar_destroy(xa); } void scalar_miniif(eval_scalar *xr, eval_scalar *xa, eval_scalar *xb, eval_scalar *xc) { eval_int a; scalar_context_int(xa, &a); if (a.value != 0) { *xr = *xb; } else { *xr = *xc; } scalar_destroy(xa); } /* * BUILTIN FUNCTIONS */ int func_typeof(eval_scalar *r, eval_scalar *s) { switch (s->type) { case SCALAR_INT: scalar_create_str_c(r, "int"); break; case SCALAR_STR: scalar_create_str_c(r, "string"); break; case SCALAR_FLOAT: scalar_create_str_c(r, "float"); break; default: // FIXME: should never happen scalar_create_str_c(r, "unknown"); break; } return 1; } int func_is_int(eval_scalar *r, eval_scalar *s) { if (s->type == SCALAR_INT) { scalar_create_int_c(r, 1); } else { scalar_create_int_c(r, 0); } return 1; } int func_is_string(eval_scalar *r, eval_scalar *s) { if (s->type == SCALAR_STR) { scalar_create_int_c(r, 1); } else { scalar_create_int_c(r, 0); } return 1; } int func_is_float(eval_scalar *r, eval_scalar *s) { if (s->type == SCALAR_FLOAT) { scalar_create_int_c(r, 1); } else { scalar_create_int_c(r, 0); } return 1; } int func_char(eval_scalar *r, eval_int *i) { eval_str s; char c = i->value; s.value = &c; s.len = 1; scalar_create_str(r, &s); return 1; } int func_byte(eval_scalar *r, eval_int *i) { uint c = i->value; scalar_create_int_c(r, c & 0xff); return 1; } int func_word(eval_scalar *r, eval_int *i) { uint c = i->value; scalar_create_int_c(r, c & 0xffff); return 1; } int func_dword(eval_scalar *r, eval_int *i) { uint c = i->value; scalar_create_int_q(r, c & 0xffffffff); return 1; } int func_sbyte(eval_scalar *r, eval_int *i) { uint c = i->value; scalar_create_int_c(r, (signed char)c); return 1; } int func_short(eval_scalar *r, eval_int *i) { uint c = i->value; scalar_create_int_c(r, (short)c); return 1; } int func_long(eval_scalar *r, eval_int *i) { int c = i->value; scalar_create_int_c(r, c); return 1; } int func_float(eval_scalar *r, eval_float *p) { scalar_create_float(r, p); return 1; } int func_fmax(eval_scalar *r, eval_float *p1, eval_float *p2) { r->type=SCALAR_FLOAT; r->scalar.floatnum.value=(p1->value>p2->value) ? p1->value : p2->value; return 1; } int func_fmin(eval_scalar *r, eval_float *p1, eval_float *p2) { r->type=SCALAR_FLOAT; r->scalar.floatnum.value=(p1->valuevalue) ? p1->value : p2->value; return 1; } int func_int(eval_scalar *r, eval_int *p) { scalar_create_int(r, p); return 1; } int func_ord(eval_scalar *r, eval_str *s) { if (s->len>=1) { scalar_create_int_c(r, s->value[0]); return 1; } set_eval_error("string must at least contain one character"); return 0; } int func_max(eval_scalar *r, eval_int *p1, eval_int *p2) { scalar_create_int(r, (p1->value>p2->value) ? p1 : p2); return 1; } int func_min(eval_scalar *r, eval_int *p1, eval_int *p2) { scalar_create_int(r, (p1->valuevalue) ? p1 : p2); return 1; } int func_random(eval_scalar *r, eval_int *p1) { uint64 d = rand(); scalar_create_int_q(r, (p1->value != 0) ? (d % p1->value):0); return 1; } int func_rnd(eval_scalar *r) { scalar_create_int_c(r, rand() % 2); return 1; } int func_round(eval_scalar *r, eval_float *p) { r->type=SCALAR_INT; r->scalar.integer.value=f2i(p->value+0.5); r->scalar.integer.type=TYPE_UNKNOWN; return 1; } int func_strchr(eval_scalar *r, eval_str *p1, eval_str *p2) { if (p2->len) { if (p1->len) { char *pos = (char *)memchr(p1->value, *p2->value, p1->len); if (pos) { scalar_create_int_c(r, pos-p1->value); } else { scalar_create_int_c(r, -1); } } else { scalar_create_int_c(r, -1); } return 1; } else { return 0; } } int func_strcmp(eval_scalar *r, eval_str *p1, eval_str *p2) { int r2=memcmp(p1->value, p2->value, MIN(p1->len, p2->len)); if (r2) { scalar_create_int_c(r, r2); } else { if (p1->len > p2->len) { scalar_create_int_c(r, 1); } else if (p1->len < p2->len) { scalar_create_int_c(r, -1); } else { scalar_create_int_c(r, 0); } } return 1; } int func_string(eval_scalar *r, eval_str *p) { scalar_create_str(r, p); return 1; } int func_strlen(eval_scalar *r, eval_str *p1) { scalar_create_int_c(r, p1->len); return 1; } int func_strncmp(eval_scalar *r, eval_str *p1, eval_str *p2, eval_int *p3) { return 1; } int func_strrchr(eval_scalar *r, eval_str *p1, eval_str *p2) { return 1; } int func_strstr(eval_scalar *r, eval_str *p1, eval_str *p2) { return 1; } int func_substr(eval_scalar *r, eval_str *p1, eval_int *p2, eval_int *p3) { if (p2->value >= 0 && p3->value > 0) { if (p2->value < p1->len) { eval_str s; s.len = MIN(p3->value, p1->len - p2->value); s.value = &p1->value[p2->value]; scalar_create_str(r, &s); } else { scalar_create_str_c(r, ""); } } else { scalar_create_str_c(r, ""); } return 1; } int func_trunc(eval_scalar *r, eval_float *p) { r->type=SCALAR_INT; r->scalar.integer.value=f2i(p->value); r->scalar.integer.type=TYPE_UNKNOWN; return 1; } #define EVALFUNC_FMATH1(name) int func_##name(eval_scalar *r, eval_float *p)\ {\ r->type=SCALAR_FLOAT;\ r->scalar.floatnum.value=name(p->value);\ return 1;\ } #define EVALFUNC_FMATH1i(name) int func_##name(eval_scalar *r, eval_float *p)\ {\ r->type=SCALAR_INT;\ r->scalar.integer.value=f2i(name(p->value));\ r->scalar.integer.type=TYPE_UNKNOWN;\ return 1;\ } #define EVALFUNC_FMATH2(name) int func_##name(eval_scalar *r, eval_float *p1, eval_float *p2)\ {\ r->type=SCALAR_FLOAT;\ r->scalar.floatnum.value=name(p1->value, p2->value);\ return 1;\ } EVALFUNC_FMATH2(pow) EVALFUNC_FMATH1(sqrt) EVALFUNC_FMATH1(exp) EVALFUNC_FMATH1(log) EVALFUNC_FMATH1i(ceil) EVALFUNC_FMATH1i(floor) EVALFUNC_FMATH1(sin) EVALFUNC_FMATH1(cos) EVALFUNC_FMATH1(tan) EVALFUNC_FMATH1(asin) EVALFUNC_FMATH1(acos) EVALFUNC_FMATH1(atan) EVALFUNC_FMATH1(sinh) EVALFUNC_FMATH1(cosh) EVALFUNC_FMATH1(tanh) #ifdef HAVE_ASINH EVALFUNC_FMATH1(asinh) #endif #ifdef HAVE_ACOSH EVALFUNC_FMATH1(acosh) #endif #ifdef HAVE_ATANH EVALFUNC_FMATH1(atanh) #endif void sprintf_puts(char **b, char *blimit, const char *buf) { while (*b < blimit && *buf) { **b = *(buf++); (*b)++; } } int sprintf_percent(char **fmt, int *fmtl, char **b, char *blimit, eval_scalar *s) { char cfmt[32]; char buf[512]; int ci=1; cfmt[0]='%'; while (*fmtl && ci < 32-1) { cfmt[ci]=(*fmt)[0]; cfmt[ci+1]=0; switch ((*fmt)[0]) { case 'd': case 'i': case 'o': case 'u': case 'x': case 'X': case 'c': { eval_int i; scalar_context_int(s, &i); ht_snprintf(buf, sizeof buf, cfmt, i.value); sprintf_puts(b, blimit, buf); return 1; } case 's': { char *q=cfmt+1; eval_str t; scalar_context_str(s, &t); while (*q!='s') { if ((*q>='0') && (*q<='9')) { unsigned int sl=strtol(q, NULL, 10); if (sl>sizeof buf-1) sl=sizeof buf-1; sprintf(q, "%ds", sl); break; } else { switch (*q) { case '+': case '-': case '#': case ' ': break; default: /* FIXME: invalid format */ break; } } q++; } if ((unsigned int)t.len>sizeof buf-1) t.len=sizeof buf-1; t.value[t.len]=0; ht_snprintf(buf, sizeof buf, cfmt, t.value); sprintf_puts(b, blimit, buf); string_destroy(&t); return 1; } case 'e': case 'E': case 'f': case 'F': case 'g': case 'G': { eval_float f; scalar_context_float(s, &f); ht_snprintf(buf, sizeof buf, cfmt, f.value); sprintf_puts(b, blimit, buf); return 1; } case '%': sprintf_puts(b, blimit, "%"); return 1; } (*fmt)++; (*fmtl)--; ci++; } return 0; } int func_sprintf(eval_scalar *r, const eval_str *format, const eval_scalarlist *scalars) { char buf[512]; /* FIXME: possible buffer overflow */ char *b=buf; char *fmt; int fmtl; eval_scalar *s=scalars->scalars; fmt=format->value; fmtl=format->len; while (fmtl) { if (fmt[0]=='%') { fmt++; fmtl--; if (!fmtl) break; if (fmt[0]!='%') { if (s-scalars->scalars >= scalars->count) { DEBUG_DUMP("too few parameters"); return 0; } if (!sprintf_percent(&fmt, &fmtl, &b, buf+sizeof buf, s)) return 0; s++; } else { *b++=fmt[0]; if (b-buf>=512) break; } } else { *b++=fmt[0]; if (b-buf>=512) break; } fmt++; fmtl--; } *b=0; r->type=SCALAR_STR; r->scalar.str.value=ht_strdup(buf); r->scalar.str.len=strlen(r->scalar.str.value); return 1; } /* * FUNCTIONS */ int func_eval(eval_scalar *r, eval_str *p) { char *q = ht_malloc(p->len+1); int x; memcpy(q, p->value, p->len); q[p->len] = 0; x = eval(r, q, g_eval_func_handler, g_eval_symbol_handler, eval_context); free(q); /* if (get_eval_error(NULL, NULL)) { eval_error_pos+=lex_current_buffer_pos(); }*/ return x; } int func_error(eval_scalar *r, eval_str *s) { char c[1024]; bin2str(c, s->value, MIN((unsigned int)s->len, sizeof c)); set_eval_error(c); return 0; } int func_help_helper(eval_scalar *r, eval_str *s) { if (s->len > MAX_FUNCNAME_LEN) return 0; char b[MAX_FUNCNAME_LEN+1]; bin2str(b, s->value, s->len); set_helpmode(1, b); eval_scalar str; scalar_create_str_c(&str, "NaF()"); scalar_create_str_c(&helpstring, ""); func_eval(r, &str.scalar.str); *r = helpstring; scalar_destroy(&str); set_helpmode(0, NULL); return 1; } int func_whatis(eval_scalar *r, eval_str *s) { int t = 0; if (s->len != 0) t = func_help_helper(r, s); if ((s->len == 0) || (r->scalar.str.len == 0)) { char n[MAX_FUNCNAME_LEN+1]; bin2str(n, s->value, s->len); set_eval_error("no such function \"%s\"", n); return 0; } return t; } int func_help(eval_scalar *r) { eval_scalar str; scalar_create_str_c(&str, ""); int t = func_help_helper(r, &str.scalar.str); scalar_destroy(&str); return t; } eval_func builtin_evalfuncs[]= { /* eval */ { "eval", (void*)&func_eval, {SCALAR_STR}, "evaluate string" }, /* help */ { "help", (void*)&func_help, {}, "get help on all functions"}, { "whatis", (void*)&func_whatis, {SCALAR_STR}, "get help on specific function"}, /* type juggling */ { "int", (void*)&func_int, {SCALAR_INT}, "converts to integer" }, { "string", (void*)&func_string, {SCALAR_STR}, "converts to string" }, { "float", (void*)&func_float, {SCALAR_FLOAT}, "converts to float" }, { "byte", (void*)&func_byte, {SCALAR_INT}, "converts to byte (1 bytes)" }, { "word", (void*)&func_word, {SCALAR_INT}, "converts to uint16 (2 bytes unsigned)" }, { "dword", (void*)&func_dword, {SCALAR_INT}, "converts to uint32 (4 bytes unsigned)" }, { "sbyte", (void*)&func_sbyte, {SCALAR_INT}, "converts to signed byte (1 bytes signed)" }, { "short", (void*)&func_short, {SCALAR_INT}, "converts to short (2 bytes signed)" }, { "long", (void*)&func_long, {SCALAR_INT}, "converts to long (4 bytes signed)" }, { "typeof", (void*)&func_typeof, {SCALAR_ANY}, "returns \"int\", \"string\" or \"float\"" }, { "is_int", (void*)&func_is_int, {SCALAR_ANY}, "returns non-zero if param is an integer" }, { "is_string", (void*)&func_is_string, {SCALAR_ANY}, "returns non-zero if param is a string" }, { "is_float", (void*)&func_is_float, {SCALAR_ANY}, "returns non-zero if param is a float" }, /* general */ { "error", (void*)&func_error, {SCALAR_STR}, "abort with error" }, /* string functions */ { "char", (void*)&func_char, {SCALAR_INT}, "return the ascii character (1-char string) specified by p1" }, { "ord", (void*)&func_ord, {SCALAR_STR}, "return the ordinal value of p1" }, { "sprintf", (void*)&func_sprintf, {SCALAR_STR, SCALAR_VARARGS}, "returns formatted string" }, { "strchr", (void*)&func_strchr, {SCALAR_STR, SCALAR_STR}, "returns position of first occurrence of character param2 in param1" }, { "strcmp", (void*)&func_strcmp, {SCALAR_STR, SCALAR_STR}, "returns zero for equality, positive number for str1 > str2 and negative number for str1 < str2" }, { "strlen", (void*)&func_strlen, {SCALAR_STR}, "returns length of string" }, { "strncmp", (void*)&func_strncmp, {SCALAR_STR, SCALAR_STR, SCALAR_INT}, "like strcmp, but considers a maximum of param3 characters" }, { "strstr", (void*)&func_strchr, {SCALAR_STR, SCALAR_STR}, "returns position of first occurrence of string param2 in param1" }, { "substr", (void*)&func_substr, {SCALAR_STR, SCALAR_INT, SCALAR_INT}, "returns substring from param1, start param2, length param3" }, /* { "stricmp", (void*)&func_stricmp, {SCALAR_STR, SCALAR_STR}, "like strcmp but case-insensitive" }, { "strnicmp", (void*)&func_strnicmp, {SCALAR_STR, SCALAR_STR}, "" }, */ /* math */ { "pow", (void*)&func_pow, {SCALAR_FLOAT, SCALAR_FLOAT}, 0 }, { "sqrt", (void*)&func_sqrt, {SCALAR_FLOAT}, 0 }, { "fmin", (void*)&func_fmin, {SCALAR_FLOAT, SCALAR_FLOAT}, 0 }, { "fmax", (void*)&func_fmax, {SCALAR_FLOAT, SCALAR_FLOAT}, 0 }, { "min", (void*)&func_min, {SCALAR_INT, SCALAR_INT}, 0 }, { "max", (void*)&func_max, {SCALAR_INT, SCALAR_INT}, 0 }, { "random", (void*)&func_random, {SCALAR_INT}, "returns a random integer between 0 and param1-1" }, { "rnd", (void*)&func_rnd, {}, "returns a random bit as integer (0 or 1)" }, { "exp", (void*)&func_exp, {SCALAR_FLOAT}, 0 }, { "log", (void*)&func_log, {SCALAR_FLOAT}, 0 }, { "ceil", (void*)&func_ceil, {SCALAR_FLOAT}, 0 }, { "floor", (void*)&func_floor, {SCALAR_FLOAT}, 0 }, { "round", (void*)&func_round, {SCALAR_FLOAT}, 0 }, { "trunc", (void*)&func_trunc, {SCALAR_FLOAT}, 0 }, { "sin", (void*)&func_sin, {SCALAR_FLOAT}, 0 }, { "cos", (void*)&func_cos, {SCALAR_FLOAT}, 0 }, { "tan", (void*)&func_tan, {SCALAR_FLOAT}, 0 }, { "asin", (void*)&func_asin, {SCALAR_FLOAT}, 0 }, { "acos", (void*)&func_acos, {SCALAR_FLOAT}, 0 }, { "atan", (void*)&func_atan, {SCALAR_FLOAT}, 0 }, { "sinh", (void*)&func_sinh, {SCALAR_FLOAT}, 0 }, { "cosh", (void*)&func_cosh, {SCALAR_FLOAT}, 0 }, { "tanh", (void*)&func_tanh, {SCALAR_FLOAT}, 0 }, #ifdef HAVE_ASINH { "asinh", (void*)&func_asinh, {SCALAR_FLOAT}, 0 }, #endif #ifdef HAVE_ACOSH { "acosh", (void*)&func_acosh, {SCALAR_FLOAT}, 0 }, #endif #ifdef HAVE_ATANH { "atanh", (void*)&func_atanh, {SCALAR_FLOAT}, 0 }, #endif { NULL, NULL } }; eval_protomatch match_evalfunc_proto(char *name, eval_scalarlist *params, eval_func *proto) { int j; int protoparams=0; if (strcmp(name, proto->name)!=0) return PROTOMATCH_NAME_FAIL; for (j=0; jptype[j]==SCALAR_NULL) break; if (proto->ptype[j]==SCALAR_VARARGS) { if (params->count > protoparams) protoparams=params->count; break; } protoparams++; } return (protoparams==params->count) ? PROTOMATCH_OK : PROTOMATCH_PARAM_FAIL; } int exec_evalfunc(eval_scalar *r, eval_scalarlist *params, eval_func *proto) { int j; int retv; eval_scalar sc[MAX_EVALFUNC_PARAMS]; void *pptrs[MAX_EVALFUNC_PARAMS]; int protoparams=0; eval_scalarlist *sclist=0; const char *errmsg; int errpos; for (j=0; jname); for (j=0; jptype[j]==SCALAR_NULL) break; switch (proto->ptype[j]) { case SCALAR_INT: protoparams++; if (params->countscalars[j], &sc[j].scalar.integer); pptrs[j]=&sc[j].scalar.integer; DEBUG_DUMP_SCALAR(&sc[j], "param %d: int=", j); break; case SCALAR_STR: protoparams++; if (params->countscalars[j], &sc[j].scalar.str); pptrs[j]=&sc[j].scalar.str; DEBUG_DUMP_SCALAR(&sc[j], "param %d: str=", j); break; case SCALAR_FLOAT: protoparams++; if (params->countscalars[j], &sc[j].scalar.floatnum); pptrs[j]=&sc[j].scalar.floatnum; DEBUG_DUMP_SCALAR(&sc[j], "param %d: float=", j); break; case SCALAR_ANY: { protoparams++; if (params->countscalars[j]); pptrs[j] = &sc[j]; DEBUG_DUMP_SCALAR(&sc[j], "param %d: vararg=", j); break; } case SCALAR_VARARGS: { sclist = ht_malloc(sizeof (eval_scalarlist)); sclist->count=params->count-j; if (sclist->count) { sclist->scalars=(eval_scalar*)malloc(sizeof (eval_scalar) * sclist->count); memcpy(sclist->scalars, ¶ms->scalars[j], sizeof (eval_scalar) * sclist->count); } else { sclist->scalars=NULL; } pptrs[j]=sclist; protoparams = params->count; term=1; DEBUG_DUMP_SCALARLIST(params, "param %d: varargs=", j); break; } default: set_eval_error("internal error (%s:%d)", __FILE__, __LINE__); return 0; } if (term) break; } if (params->count == protoparams) { DEBUG_DUMP_INDENT_IN; retv=((int(*)(eval_scalar*,void*,void*,void*,void*,void*,void*,void*,void*))proto->func)(r, pptrs[0], pptrs[1], pptrs[2], pptrs[3], pptrs[4], pptrs[5], pptrs[6], pptrs[7]); DEBUG_DUMP_INDENT_OUT; } else { retv=0; } if (retv) { DEBUG_DUMP_SCALAR(r, "returns "); } else { DEBUG_DUMP("fails..."); } if (sclist) { scalarlist_destroy_gentle(sclist); free(sclist); } for (j=0; jname, sizeof ee); ht_strlcat(ee, "(): ", sizeof ee); ht_strlcat(ee, errmsg, sizeof ee); set_eval_error_ex(errpos, "%s", ee); } return retv; } int evalsymbol(eval_scalar *r, char *sname) { int s=0; if (g_eval_symbol_handler) s = g_eval_symbol_handler(r, sname); if (!get_eval_error(NULL, NULL) && !s) { char sname_short[MAX_SYMBOLNAME_LEN+1]; ht_strlcpy(sname_short, sname, sizeof sname_short); set_eval_error("unknown symbol: %s", sname_short); } return s; } static const char *type2str(eval_scalartype t) { switch (t) { case SCALAR_INT: return "INT"; break; case SCALAR_STR: return "STRING"; break; case SCALAR_FLOAT: return "FLOAT"; break; case SCALAR_ANY: return "ANY"; break; case SCALAR_VARARGS: return "..."; break; default: return 0; break; } } static void proto_dump(char *buf, int bufsize, eval_func *proto, int full, const char *separator) { // FIXME: buffer safety/possible buffer overflow strcpy(buf, proto->name); strcat(buf, "("); for (int j=0; jptype[j]==SCALAR_NULL) break; if (j) strcat(buf, ", "); strcat(buf, type2str(proto->ptype[j])); if (proto->ptype[j] == SCALAR_VARARGS) break; } strcat(buf, ")"); if (full && proto->desc) { strcat(buf, separator); strcat(buf, proto->desc); } } int std_eval_func_handler(eval_scalar *result, char *fname, eval_scalarlist *params, eval_func *protos) { if (strlen(fname) > MAX_FUNCNAME_LEN) { set_eval_error("invalid function, function name too long"); return 0; } if (helpmode) { while (protos->name) { char buf[256]; if ((!*helpname) || (*helpname && (strcmp(helpname, protos->name)==0))) { if (protos->func) { proto_dump(buf, sizeof buf, protos, 1, "\n"); } else { strcpy(buf, protos->name); strcat(buf, " : "); strcat(buf, type2str(protos->ptype[0])); strcat(buf, "\n"); strcat(buf, protos->desc); } strcat(buf, "\n\n"); eval_scalar s; scalar_create_str_c(&s, buf); eval_scalar r; scalar_concat(&r, &helpstring, &s); scalar_destroy(&helpstring); scalar_destroy(&s); helpstring = r; } protos++; } } else { while (protos->name) { if (protos->func) switch (match_evalfunc_proto(fname, params, protos)) { case PROTOMATCH_OK: return exec_evalfunc(result, params, protos); case PROTOMATCH_PARAM_FAIL: { char b[256]; proto_dump(b, sizeof b, protos, 0, ""); set_eval_error("invalid params to function %s, declaration is: %s", protos->name, b); return 0; } default: {} } protos++; } } return 0; } int evalfunc(eval_scalar *r, char *fname, eval_scalarlist *params) { if (strlen(fname) > MAX_FUNCNAME_LEN) { set_eval_error("invalid function, function name too long"); return 0; } int s; if (g_eval_func_handler) { s = g_eval_func_handler(r, fname, params); if (get_eval_error(NULL, NULL)) return 0; if (s) return s; } s = std_eval_func_handler(r, fname, params, builtin_evalfuncs); if (get_eval_error(NULL, NULL)) return 0; if (s) return s; if (!helpmode) { set_eval_error("unknown function %s", fname); return 0; } else return 1; } void *eval_get_context() { return eval_context; } void eval_set_context(void *context) { eval_context = context; } void eval_set_func_handler(eval_func_handler func_handler) { g_eval_func_handler = func_handler; } void eval_set_symbol_handler(eval_symbol_handler symbol_handler) { g_eval_symbol_handler = symbol_handler; } ht-2.0.22/eval/lex.c0000644000175000001440000014551511035232002011007 00000000000000 #line 3 "lex.c" #define YY_INT_ALIGNED short int /* A lexical scanner generated by flex */ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 #define YY_FLEX_SUBMINOR_VERSION 33 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* First, we deal with platform-specific or compiler-specific issues. */ /* begin standard C headers. */ #include #include #include #include /* end standard C headers. */ /* flex integer type definitions */ #ifndef FLEXINT_H #define FLEXINT_H /* C99 systems have . Non-C99 systems may or may not. */ #if __STDC_VERSION__ >= 199901L /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 #endif #include typedef int8_t flex_int8_t; typedef uint8_t flex_uint8_t; typedef int16_t flex_int16_t; typedef uint16_t flex_uint16_t; typedef int32_t flex_int32_t; typedef uint32_t flex_uint32_t; #else typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; #endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN #define INT8_MIN (-128) #endif #ifndef INT16_MIN #define INT16_MIN (-32767-1) #endif #ifndef INT32_MIN #define INT32_MIN (-2147483647-1) #endif #ifndef INT8_MAX #define INT8_MAX (127) #endif #ifndef INT16_MAX #define INT16_MAX (32767) #endif #ifndef INT32_MAX #define INT32_MAX (2147483647) #endif #ifndef UINT8_MAX #define UINT8_MAX (255U) #endif #ifndef UINT16_MAX #define UINT16_MAX (65535U) #endif #ifndef UINT32_MAX #define UINT32_MAX (4294967295U) #endif #endif /* ! FLEXINT_H */ #ifdef __cplusplus /* The "const" storage-class-modifier is valid. */ #define YY_USE_CONST #else /* ! __cplusplus */ #if __STDC__ #define YY_USE_CONST #endif /* __STDC__ */ #endif /* ! __cplusplus */ #ifdef YY_USE_CONST #define yyconst const #else #define yyconst #endif /* Returned upon end-of-file. */ #define YY_NULL 0 /* Promotes a possibly negative, possibly signed char to an unsigned * integer for use as an array index. If the signed char is negative, * we want to instead treat it as an 8-bit unsigned char, hence the * double cast. */ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) /* Enter a start condition. This macro really ought to take a parameter, * but we do it the disgusting crufty way forced on us by the ()-less * definition of BEGIN. */ #define BEGIN (yy_start) = 1 + 2 * /* Translate the current start state into a value that can be later handed * to BEGIN to return to the state. The YYSTATE alias is for lex * compatibility. */ #define YY_START (((yy_start) - 1) / 2) #define YYSTATE YY_START /* Action number for EOF rule of a given start state. */ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) /* Special action meaning "start processing a new file". */ #define YY_NEW_FILE yyrestart(yyin ) #define YY_END_OF_BUFFER_CHAR 0 /* Size of default input buffer. */ #ifndef YY_BUF_SIZE #define YY_BUF_SIZE 16384 #endif /* The state buf must be large enough to hold one state per character in the main buffer. */ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) #ifndef YY_TYPEDEF_YY_BUFFER_STATE #define YY_TYPEDEF_YY_BUFFER_STATE typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif extern int yyleng; extern FILE *yyin, *yyout; #define EOB_ACT_CONTINUE_SCAN 0 #define EOB_ACT_END_OF_FILE 1 #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ *yy_cp = (yy_hold_char); \ YY_RESTORE_YY_MORE_OFFSET \ (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ YY_DO_BEFORE_ACTION; /* set up yytext again */ \ } \ while ( 0 ) #define unput(c) yyunput( c, (yytext_ptr) ) /* The following is because we cannot portably get our hands on size_t * (without autoconf's help, which isn't available because we want * flex-generated scanners to compile on their own). */ #ifndef YY_TYPEDEF_YY_SIZE_T #define YY_TYPEDEF_YY_SIZE_T typedef unsigned int yy_size_t; #endif #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state { FILE *yy_input_file; char *yy_ch_buf; /* input buffer */ char *yy_buf_pos; /* current position in input buffer */ /* Size of input buffer in bytes, not including room for EOB * characters. */ yy_size_t yy_buf_size; /* Number of characters read into yy_ch_buf, not including EOB * characters. */ int yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to * delete it. */ int yy_is_our_buffer; /* Whether this is an "interactive" input source; if so, and * if we're using stdio for input, then we want to use getc() * instead of fread(), to make sure we stop fetching input after * each newline. */ int yy_is_interactive; /* Whether we're considered to be at the beginning of a line. * If so, '^' rules will be active on the next match, otherwise * not. */ int yy_at_bol; int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ /* Whether to try to fill the input buffer when we reach the * end of it. */ int yy_fill_buffer; int yy_buffer_status; #define YY_BUFFER_NEW 0 #define YY_BUFFER_NORMAL 1 /* When an EOF's been seen but there's still some text to process * then we mark the buffer as YY_EOF_PENDING, to indicate that we * shouldn't try reading from the input source any more. We might * still have a bunch of tokens to match, though, because of * possible backing-up. * * When we actually see the EOF, we change the status to "new" * (via yyrestart()), so that the user can continue scanning by * just pointing yyin at a new input file. */ #define YY_BUFFER_EOF_PENDING 2 }; #endif /* !YY_STRUCT_YY_BUFFER_STATE */ /* Stack of input buffers. */ static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* We provide macros for accessing buffer states in case in the * future we want to put the buffer states in a more general * "scanner state". * * Returns the top of the stack, or NULL. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. */ #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] /* yy_hold_char holds the character lost when yytext is formed. */ static char yy_hold_char; static int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; static int yy_init = 0; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ /* Flag which is used to allow yywrap()'s to do buffer switches * instead of setting up a fresh yyin. A bit of a hack ... */ static int yy_did_buffer_switch_on_eof; void yyrestart (FILE *input_file ); void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ); void yy_delete_buffer (YY_BUFFER_STATE b ); void yy_flush_buffer (YY_BUFFER_STATE b ); void yypush_buffer_state (YY_BUFFER_STATE new_buffer ); void yypop_buffer_state (void ); static void yyensure_buffer_stack (void ); static void yy_load_buffer_state (void ); static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER ) YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ); YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ); YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ); void *yyalloc (yy_size_t ); void *yyrealloc (void *,yy_size_t ); void yyfree (void * ); #define yy_new_buffer yy_create_buffer #define yy_set_interactive(is_interactive) \ { \ if ( ! YY_CURRENT_BUFFER ){ \ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer(yyin,YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ } #define yy_set_bol(at_bol) \ { \ if ( ! YY_CURRENT_BUFFER ){\ yyensure_buffer_stack (); \ YY_CURRENT_BUFFER_LVALUE = \ yy_create_buffer(yyin,YY_BUF_SIZE ); \ } \ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ } #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) /* Begin user sect3 */ #define yywrap(n) 1 #define YY_SKIP_YYWRAP typedef unsigned char YY_CHAR; FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; typedef int yy_state_type; extern int yylineno; int yylineno = 1; extern char *yytext; #define yytext_ptr yytext static yy_state_type yy_get_previous_state (void ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); static int yy_get_next_buffer (void ); static void yy_fatal_error (yyconst char msg[] ); /* Done after the current pattern has been matched and before the * corresponding action - sets up yytext. */ #define YY_DO_BEFORE_ACTION \ (yytext_ptr) = yy_bp; \ yyleng = (size_t) (yy_cp - yy_bp); \ (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; #define YY_NUM_RULES 32 #define YY_END_OF_BUFFER 33 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info { flex_int32_t yy_verify; flex_int32_t yy_nxt; }; static yyconst flex_int16_t yy_accept[66] = { 0, 0, 0, 33, 30, 1, 31, 30, 30, 22, 30, 30, 30, 24, 24, 24, 24, 13, 30, 15, 30, 22, 22, 22, 22, 30, 1, 18, 0, 2, 0, 22, 19, 0, 3, 10, 0, 24, 24, 24, 0, 29, 27, 26, 28, 0, 11, 14, 17, 16, 12, 21, 8, 7, 6, 5, 4, 9, 20, 2, 23, 25, 0, 0, 23, 0 } ; static yyconst flex_int32_t yy_ec[256] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 5, 1, 6, 1, 7, 8, 1, 1, 9, 10, 1, 10, 11, 1, 12, 13, 14, 14, 14, 14, 14, 14, 15, 15, 1, 1, 16, 17, 18, 1, 6, 19, 19, 19, 19, 20, 19, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 1, 22, 1, 23, 21, 1, 19, 24, 19, 25, 26, 19, 27, 28, 21, 21, 21, 29, 21, 30, 31, 21, 32, 21, 21, 33, 21, 21, 21, 34, 21, 21, 1, 35, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; static yyconst flex_int32_t yy_meta[36] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 3, 2, 4, 1, 1, 3, 3, 2, 4, 5, 4, 4, 4, 4, 4, 4, 1 } ; static yyconst flex_int16_t yy_base[72] = { 0, 0, 0, 129, 130, 126, 130, 110, 31, 0, 119, 117, 115, 43, 89, 25, 29, 23, 105, 27, 98, 88, 39, 40, 90, 50, 82, 130, 42, 130, 56, 0, 130, 75, 130, 130, 67, 42, 0, 0, 47, 23, 22, 130, 130, 0, 130, 130, 130, 130, 130, 130, 0, 0, 0, 0, 0, 0, 130, 65, 26, 0, 76, 80, 84, 130, 99, 103, 108, 112, 116, 46 } ; static yyconst flex_int16_t yy_def[72] = { 0, 65, 1, 65, 65, 65, 65, 65, 66, 67, 65, 68, 65, 65, 13, 13, 15, 65, 65, 65, 65, 67, 67, 67, 67, 65, 65, 65, 66, 65, 66, 67, 65, 68, 65, 65, 65, 13, 15, 16, 69, 69, 69, 65, 65, 70, 65, 65, 65, 65, 65, 65, 67, 67, 67, 67, 67, 67, 65, 66, 71, 70, 65, 65, 65, 0, 65, 65, 65, 65, 65, 65 } ; static yyconst flex_int16_t yy_nxt[166] = { 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 4, 4, 13, 14, 15, 16, 17, 18, 19, 9, 9, 9, 4, 20, 9, 9, 21, 22, 9, 23, 24, 9, 9, 9, 9, 25, 29, 38, 38, 46, 47, 39, 39, 39, 49, 50, 62, 29, 60, 40, 43, 43, 62, 30, 36, 37, 37, 38, 39, 65, 65, 59, 40, 40, 30, 53, 55, 41, 42, 40, 29, 43, 54, 56, 44, 43, 65, 45, 30, 60, 60, 60, 60, 34, 26, 58, 63, 30, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 28, 28, 28, 28, 28, 31, 31, 31, 31, 33, 33, 33, 33, 33, 40, 40, 57, 40, 61, 61, 52, 51, 48, 65, 35, 34, 32, 27, 26, 65, 3, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } ; static yyconst flex_int16_t yy_chk[166] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 8, 15, 15, 17, 17, 16, 16, 16, 19, 19, 60, 28, 71, 15, 42, 41, 60, 8, 13, 13, 13, 13, 13, 15, 16, 30, 13, 13, 28, 22, 23, 13, 13, 13, 59, 13, 22, 23, 13, 40, 37, 13, 30, 36, 36, 36, 36, 33, 26, 25, 62, 59, 62, 62, 62, 62, 63, 63, 63, 63, 64, 64, 64, 64, 66, 66, 66, 66, 66, 67, 67, 67, 67, 68, 68, 68, 68, 68, 69, 69, 24, 69, 70, 70, 21, 20, 18, 14, 12, 11, 10, 7, 5, 3, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65 } ; static yy_state_type yy_last_accepting_state; static char *yy_last_accepting_cpos; extern int yy_flex_debug; int yy_flex_debug = 0; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. */ #define REJECT reject_used_but_not_detected #define yymore() yymore_used_but_not_detected #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *yytext; #line 1 "lex.l" #line 2 "lex.l" #define USE_PURE_PARSER #ifdef USE_PURE_PARSER #define YY_DECL int yylex (YYSTYPE *lvalp) #define YY_LVALP lvalp #else #define YY_LVALP (&yylval) #endif /* get current pos (offset from start of line) */ #define YY_USER_ACTION lex_pos=yy_bp - YY_CURRENT_BUFFER->yy_ch_buf; #include #include #include #include "eval.h" #include "evaltype.h" #include "evalparse.h" static int lex_pos; static int char2int(char a, int base) { int i; if ((a>='A') && (a<='Z')) { i=a-'A'+10; } else if ((a>='a') && (a<='z')) { i=a-'a'+10; } else if ((a>='0') && (a<='9')) { i=a-'0'; } else return -1; if (i>=base) return -1; return i; } static int parse_float(eval_scalar *f, char *fpn) { char *end; double d; d=strtod(fpn, &end); if (*end == 0) { f->type=SCALAR_FLOAT; f->scalar.floatnum.value=d; return 1; } return 0; } static int parse_integer(eval_scalar *i, char *num, int base, int lenmod) { uint64 k = 0; int l = strlen(num) + lenmod; while (l--) { int c=char2int(*num, base); if (c==-1) return 0; k *= base; k += c; num++; } i->type=SCALAR_INT; i->scalar.integer.value=k; i->scalar.integer.type=TYPE_UNKNOWN; return 1; } static int parse_cstring(eval_scalar *r, char *s, int len) { char *result; int alloclen = len; if (alloclen < 1) alloclen = 1; r->type = SCALAR_STR; r->scalar.str.value = (char*)malloc(alloclen); if (!r->scalar.str.value) return 0; result = r->scalar.str.value; // may not end with '\\' if (len && s[len-1] == '\\') return 0; while (s && *s && len) { if (*s == '\\') { s++;len--;if (!len) break; switch (*s) { case '0': *result++='\0'; break; case 'a': *result++='\a'; break; case 'b': *result++='\b'; break; case 'e': *result++='\e'; break; case 'f': *result++='\f'; break; case 'n': *result++='\n'; break; case 'r': *result++='\r'; break; case 't': *result++='\t'; break; case 'v': *result++='\v'; break; case '\"': *result++='"'; break; case '\\': *result++='\\'; break; case 'x': { int p, q; s++;len--;if (!len) break; p=char2int(*s, 16); if (p==-1) return 0; s++;len--;if (!len) break; q=char2int(*s, 16); if (q==-1) return 0; *result++=(char)p*16+q; break; } default: *result++='\\'; if (len) *result++=*s; break; } } else { *result++ = *s; } s++;len--; } r->scalar.str.len=result-r->scalar.str.value; return 1; } static int parse_pstring(eval_scalar *s, char *cstr, int len) { int alloclen=len; if (!len) alloclen=1; s->type=SCALAR_STR; s->scalar.str.value=(char*)malloc(alloclen); memcpy(s->scalar.str.value, cstr, len); s->scalar.str.len=len; return 1; } void *lex_current_buffer() { return (void*)YY_CURRENT_BUFFER; } int lex_current_buffer_pos() { return lex_pos; } void lex_switch_buffer(void *buffer) { yy_switch_to_buffer(buffer); } void lex_delete_buffer(void *buffer) { yy_delete_buffer(buffer); } void *lex_scan_string_buffer(const char *str) { return yy_scan_string(str); } /* */ #line 700 "lex.c" #define INITIAL 0 #ifndef YY_NO_UNISTD_H /* Special case for "unistd.h", since it is non-ANSI. We include it way * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ #include #endif #ifndef YY_EXTRA_TYPE #define YY_EXTRA_TYPE void * #endif static int yy_init_globals (void ); /* Macros after this point can all be overridden by user definitions in * section 1. */ #ifndef YY_SKIP_YYWRAP #ifdef __cplusplus extern "C" int yywrap (void ); #else extern int yywrap (void ); #endif #endif static void yyunput (int c,char *buf_ptr ); #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ); #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * ); #endif #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void ); #else static int input (void ); #endif #endif /* Amount of stuff to slurp up with each read. */ #ifndef YY_READ_BUF_SIZE #define YY_READ_BUF_SIZE 8192 #endif /* Copy whatever the last rule matched to the standard output. */ #ifndef ECHO /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ #define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, * is returned in "result". */ #ifndef YY_INPUT #define YY_INPUT(buf,result,max_size) \ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ size_t n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ if ( c == '\n' ) \ buf[n++] = (char) c; \ if ( c == EOF && ferror( yyin ) ) \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ else \ { \ errno=0; \ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ { \ if( errno != EINTR) \ { \ YY_FATAL_ERROR( "input in flex scanner failed" ); \ break; \ } \ errno=0; \ clearerr(yyin); \ } \ }\ \ #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - * we don't want an extra ';' after the "return" because that will cause * some compilers to complain about unreachable statements. */ #ifndef yyterminate #define yyterminate() return YY_NULL #endif /* Number of entries by which start-condition stack grows. */ #ifndef YY_START_STACK_INCR #define YY_START_STACK_INCR 25 #endif /* Report a fatal error. */ #ifndef YY_FATAL_ERROR #define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) #endif /* end tables serialization structures and prototypes */ /* Default declaration of generated scanner - a define so the user can * easily add parameters. */ #ifndef YY_DECL #define YY_DECL_IS_OURS 1 extern int yylex (void); #define YY_DECL int yylex (void) #endif /* !YY_DECL */ /* Code executed at the beginning of each rule, after yytext and yyleng * have been set up. */ #ifndef YY_USER_ACTION #define YY_USER_ACTION #endif /* Code executed at the end of each rule. */ #ifndef YY_BREAK #define YY_BREAK break; #endif #define YY_RULE_SETUP \ YY_USER_ACTION /** The main scanner function which does all the work. */ YY_DECL { register yy_state_type yy_current_state; register char *yy_cp, *yy_bp; register int yy_act; #line 192 "lex.l" #line 856 "lex.c" if ( !(yy_init) ) { (yy_init) = 1; #ifdef YY_USER_INIT YY_USER_INIT; #endif if ( ! (yy_start) ) (yy_start) = 1; /* first start state */ if ( ! yyin ) yyin = stdin; if ( ! yyout ) yyout = stdout; if ( ! YY_CURRENT_BUFFER ) { yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin,YY_BUF_SIZE ); } yy_load_buffer_state( ); } while ( 1 ) /* loops until end-of-file is reached */ { yy_cp = (yy_c_buf_p); /* Support of yytext. */ *yy_cp = (yy_hold_char); /* yy_bp points to the position in yy_ch_buf of the start of * the current run. */ yy_bp = yy_cp; yy_current_state = (yy_start); yy_match: do { register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 66 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; ++yy_cp; } while ( yy_base[yy_current_state] != 130 ); yy_find_action: yy_act = yy_accept[yy_current_state]; if ( yy_act == 0 ) { /* have to back up */ yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); yy_act = yy_accept[yy_current_state]; } YY_DO_BEFORE_ACTION; do_action: /* This label is used only to access EOF actions. */ switch ( yy_act ) { /* beginning of action switch */ case 0: /* must back up */ /* undo the effects of YY_DO_BEFORE_ACTION */ *yy_cp = (yy_hold_char); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); goto yy_find_action; case 1: YY_RULE_SETUP #line 194 "lex.l" /* nop */ YY_BREAK case 2: /* rule 2 can match eol */ YY_RULE_SETUP #line 195 "lex.l" if (parse_cstring(&YY_LVALP->scalar, yytext+1, strlen(yytext+1)-1)) return EVAL_STR; YY_BREAK case 3: /* rule 3 can match eol */ YY_RULE_SETUP #line 196 "lex.l" if (parse_pstring(&YY_LVALP->scalar, yytext+1, strlen(yytext+1)-1)) return EVAL_STR; YY_BREAK case 4: YY_RULE_SETUP #line 197 "lex.l" return EVAL_STR_LT; YY_BREAK case 5: YY_RULE_SETUP #line 198 "lex.l" return EVAL_STR_LE; YY_BREAK case 6: YY_RULE_SETUP #line 199 "lex.l" return EVAL_STR_GT; YY_BREAK case 7: YY_RULE_SETUP #line 200 "lex.l" return EVAL_STR_GE; YY_BREAK case 8: YY_RULE_SETUP #line 201 "lex.l" return EVAL_STR_EQ; YY_BREAK case 9: YY_RULE_SETUP #line 202 "lex.l" return EVAL_STR_NE; YY_BREAK case 10: YY_RULE_SETUP #line 203 "lex.l" return EVAL_POW; YY_BREAK case 11: YY_RULE_SETUP #line 204 "lex.l" return EVAL_SHL; YY_BREAK case 12: YY_RULE_SETUP #line 205 "lex.l" return EVAL_SHR; YY_BREAK case 13: YY_RULE_SETUP #line 206 "lex.l" return EVAL_LT; YY_BREAK case 14: YY_RULE_SETUP #line 207 "lex.l" return EVAL_LE; YY_BREAK case 15: YY_RULE_SETUP #line 208 "lex.l" return EVAL_GT; YY_BREAK case 16: YY_RULE_SETUP #line 209 "lex.l" return EVAL_GE; YY_BREAK case 17: YY_RULE_SETUP #line 210 "lex.l" return EVAL_EQ; YY_BREAK case 18: YY_RULE_SETUP #line 211 "lex.l" return EVAL_NE; YY_BREAK case 19: YY_RULE_SETUP #line 212 "lex.l" return EVAL_LAND; YY_BREAK case 20: YY_RULE_SETUP #line 213 "lex.l" return EVAL_LOR; YY_BREAK case 21: YY_RULE_SETUP #line 214 "lex.l" return EVAL_LXOR; YY_BREAK case 22: YY_RULE_SETUP #line 215 "lex.l" YY_LVALP->ident=strdup(yytext); return EVAL_IDENT; YY_BREAK case 23: YY_RULE_SETUP #line 216 "lex.l" if (parse_float(&YY_LVALP->scalar, yytext)) return EVAL_FLOAT; YY_BREAK case 24: YY_RULE_SETUP #line 217 "lex.l" if (parse_integer(&YY_LVALP->scalar, yytext, 10, 0)) return EVAL_INT; YY_BREAK case 25: YY_RULE_SETUP #line 218 "lex.l" if (parse_integer(&YY_LVALP->scalar, yytext+2, 16, 0)) return EVAL_INT; YY_BREAK case 26: YY_RULE_SETUP #line 219 "lex.l" if (parse_integer(&YY_LVALP->scalar, yytext, 16, -1)) return EVAL_INT; YY_BREAK case 27: YY_RULE_SETUP #line 220 "lex.l" if (parse_integer(&YY_LVALP->scalar, yytext, 10, -1)) return EVAL_INT; YY_BREAK case 28: YY_RULE_SETUP #line 221 "lex.l" if (parse_integer(&YY_LVALP->scalar, yytext, 8, -1)) return EVAL_INT; YY_BREAK case 29: YY_RULE_SETUP #line 222 "lex.l" if (parse_integer(&YY_LVALP->scalar, yytext, 2, -1)) return EVAL_INT; YY_BREAK case 30: YY_RULE_SETUP #line 223 "lex.l" return *yytext; YY_BREAK case 31: /* rule 31 can match eol */ YY_RULE_SETUP #line 224 "lex.l" return '\n'; YY_BREAK case 32: YY_RULE_SETUP #line 226 "lex.l" ECHO; YY_BREAK #line 1102 "lex.c" case YY_STATE_EOF(INITIAL): yyterminate(); case YY_END_OF_BUFFER: { /* Amount of text matched not including the EOB char. */ int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; /* Undo the effects of YY_DO_BEFORE_ACTION. */ *yy_cp = (yy_hold_char); YY_RESTORE_YY_MORE_OFFSET if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) { /* We're scanning a new file or input source. It's * possible that this happened because the user * just pointed yyin at a new source and called * yylex(). If so, then we have to assure * consistency between YY_CURRENT_BUFFER and our * globals. Here is the right place to do so, because * this is the first action (other than possibly a * back-up) that will match for the new input source. */ (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; } /* Note that here we test for yy_c_buf_p "<=" to the position * of the first EOB in the buffer, since yy_c_buf_p will * already have been incremented past the NUL character * (since all states make transitions on EOB to the * end-of-buffer state). Contrast this with the test * in input(). */ if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) { /* This was really a NUL. */ yy_state_type yy_next_state; (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); /* Okay, we're now positioned to make the NUL * transition. We couldn't have * yy_get_previous_state() go ahead and do it * for us because it doesn't know how to deal * with the possibility of jamming (and we don't * want to build jamming into it because then it * will run more slowly). */ yy_next_state = yy_try_NUL_trans( yy_current_state ); yy_bp = (yytext_ptr) + YY_MORE_ADJ; if ( yy_next_state ) { /* Consume the NUL. */ yy_cp = ++(yy_c_buf_p); yy_current_state = yy_next_state; goto yy_match; } else { yy_cp = (yy_c_buf_p); goto yy_find_action; } } else switch ( yy_get_next_buffer( ) ) { case EOB_ACT_END_OF_FILE: { (yy_did_buffer_switch_on_eof) = 0; if ( yywrap( ) ) { /* Note: because we've taken care in * yy_get_next_buffer() to have set up * yytext, we can now set up * yy_c_buf_p so that if some total * hoser (like flex itself) wants to * call the scanner after we return the * YY_NULL, it'll still work - another * YY_NULL will get returned. */ (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; yy_act = YY_STATE_EOF(YY_START); goto do_action; } else { if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; } break; } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_match; case EOB_ACT_LAST_MATCH: (yy_c_buf_p) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; yy_current_state = yy_get_previous_state( ); yy_cp = (yy_c_buf_p); yy_bp = (yytext_ptr) + YY_MORE_ADJ; goto yy_find_action; } break; } default: YY_FATAL_ERROR( "fatal flex scanner internal error--no action found" ); } /* end of action switch */ } /* end of scanning one token */ } /* end of yylex */ /* yy_get_next_buffer - try to read in a new buffer * * Returns a code representing an action: * EOB_ACT_LAST_MATCH - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position * EOB_ACT_END_OF_FILE - end of file */ static int yy_get_next_buffer (void) { register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; register char *source = (yytext_ptr); register int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) YY_FATAL_ERROR( "fatal flex scanner internal error--end of buffer missed" ); if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) { /* Don't try to fill the buffer, so this is an EOF. */ if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) { /* We matched a single character, the EOB, so * treat this as a final EOF. */ return EOB_ACT_END_OF_FILE; } else { /* We matched some text prior to the EOB, first * process it. */ return EOB_ACT_LAST_MATCH; } } /* Try to read more data. */ /* First move last chars to start of buffer. */ number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; for ( i = 0; i < number_to_move; ++i ) *(dest++) = *(source++); if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) /* don't do the read, it's not guaranteed to return an EOF, * just force an EOF */ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; else { int num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ YY_BUFFER_STATE b = YY_CURRENT_BUFFER; int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { int new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; else b->yy_buf_size *= 2; b->yy_ch_buf = (char *) /* Include room in for 2 EOB chars. */ yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); } else /* Can't grow it, we don't own it. */ b->yy_ch_buf = 0; if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" ); (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; } if ( num_to_read > YY_READ_BUF_SIZE ) num_to_read = YY_READ_BUF_SIZE; /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), (yy_n_chars), num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } if ( (yy_n_chars) == 0 ) { if ( number_to_move == YY_MORE_ADJ ) { ret_val = EOB_ACT_END_OF_FILE; yyrestart(yyin ); } else { ret_val = EOB_ACT_LAST_MATCH; YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_EOF_PENDING; } } else ret_val = EOB_ACT_CONTINUE_SCAN; (yy_n_chars) += number_to_move; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; return ret_val; } /* yy_get_previous_state - get the state just before the EOB char was reached */ static yy_state_type yy_get_previous_state (void) { register yy_state_type yy_current_state; register char *yy_cp; yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 66 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; } return yy_current_state; } /* yy_try_NUL_trans - try to make a transition on the NUL character * * synopsis * next_state = yy_try_NUL_trans( current_state ); */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) { register int yy_is_jam; register char *yy_cp = (yy_c_buf_p); register YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; (yy_last_accepting_cpos) = yy_cp; } while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; if ( yy_current_state >= 66 ) yy_c = yy_meta[(unsigned int) yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 65); return yy_is_jam ? 0 : yy_current_state; } static void yyunput (int c, register char * yy_bp ) { register char *yy_cp; yy_cp = (yy_c_buf_p); /* undo effects of setting up yytext */ *yy_cp = (yy_hold_char); if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ register int number_to_move = (yy_n_chars) + 2; register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; register char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) *--dest = *--source; yy_cp += (int) (dest - source); yy_bp += (int) (dest - source); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) YY_FATAL_ERROR( "flex scanner push-back overflow" ); } *--yy_cp = (char) c; (yytext_ptr) = yy_bp; (yy_hold_char) = *yy_cp; (yy_c_buf_p) = yy_cp; } #ifndef YY_NO_INPUT #ifdef __cplusplus static int yyinput (void) #else static int input (void) #endif { int c; *(yy_c_buf_p) = (yy_hold_char); if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) { /* yy_c_buf_p now points to the character we want to return. * If this occurs *before* the EOB characters, then it's a * valid NUL; if not, then we've hit the end of the buffer. */ if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) /* This was really a NUL. */ *(yy_c_buf_p) = '\0'; else { /* need more input */ int offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) { case EOB_ACT_LAST_MATCH: /* This happens because yy_g_n_b() * sees that we've accumulated a * token and flags that we need to * try matching the token before * proceeding. But for input(), * there's no matching to consider. * So convert the EOB_ACT_LAST_MATCH * to EOB_ACT_END_OF_FILE. */ /* Reset buffer status. */ yyrestart(yyin ); /*FALLTHROUGH*/ case EOB_ACT_END_OF_FILE: { if ( yywrap( ) ) return EOF; if ( ! (yy_did_buffer_switch_on_eof) ) YY_NEW_FILE; #ifdef __cplusplus return yyinput(); #else return input(); #endif } case EOB_ACT_CONTINUE_SCAN: (yy_c_buf_p) = (yytext_ptr) + offset; break; } } } c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ *(yy_c_buf_p) = '\0'; /* preserve yytext */ (yy_hold_char) = *++(yy_c_buf_p); return c; } #endif /* ifndef YY_NO_INPUT */ /** Immediately switch to a different input stream. * @param input_file A readable stream. * * @note This function does not reset the start condition to @c INITIAL . */ void yyrestart (FILE * input_file ) { if ( ! YY_CURRENT_BUFFER ){ yyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = yy_create_buffer(yyin,YY_BUF_SIZE ); } yy_init_buffer(YY_CURRENT_BUFFER,input_file ); yy_load_buffer_state( ); } /** Switch to a different input buffer. * @param new_buffer The new input buffer. * */ void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) { /* TODO. We should be able to replace this entire function body * with * yypop_buffer_state(); * yypush_buffer_state(new_buffer); */ yyensure_buffer_stack (); if ( YY_CURRENT_BUFFER == new_buffer ) return; if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } YY_CURRENT_BUFFER_LVALUE = new_buffer; yy_load_buffer_state( ); /* We don't actually know whether we did this switch during * EOF (yywrap()) processing, but the only time this flag * is looked at is after yywrap() is called, so it's safe * to go ahead and always set it. */ (yy_did_buffer_switch_on_eof) = 1; } static void yy_load_buffer_state (void) { (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; (yy_hold_char) = *(yy_c_buf_p); } /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. * * @return the allocated buffer state. */ YY_BUFFER_STATE yy_create_buffer (FILE * file, int size ) { YY_BUFFER_STATE b; b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_buf_size = size; /* yy_ch_buf has to be 2 characters longer than the size given because * we need to put in 2 end-of-buffer characters. */ b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 ); if ( ! b->yy_ch_buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); b->yy_is_our_buffer = 1; yy_init_buffer(b,file ); return b; } /** Destroy the buffer. * @param b a buffer created with yy_create_buffer() * */ void yy_delete_buffer (YY_BUFFER_STATE b ) { if ( ! b ) return; if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; if ( b->yy_is_our_buffer ) yyfree((void *) b->yy_ch_buf ); yyfree((void *) b ); } #ifndef _UNISTD_H /* assume unistd.h has isatty() for us */ #ifdef __cplusplus extern "C" { #endif #ifdef __THROW /* this is a gnuism */ extern int isatty (int ) __THROW; #else extern int isatty (int ); #endif #ifdef __cplusplus } #endif #endif /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a yyrestart() or at EOF. */ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) { int oerrno = errno; yy_flush_buffer(b ); b->yy_input_file = file; b->yy_fill_buffer = 1; /* If b is the current buffer, then yy_init_buffer was _probably_ * called from yyrestart() or through yy_get_next_buffer. * In that case, we don't want to reset the lineno or column. */ if (b != YY_CURRENT_BUFFER){ b->yy_bs_lineno = 1; b->yy_bs_column = 0; } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. * */ void yy_flush_buffer (YY_BUFFER_STATE b ) { if ( ! b ) return; b->yy_n_chars = 0; /* We always need two end-of-buffer characters. The first causes * a transition to the end-of-buffer state. The second causes * a jam in that state. */ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; b->yy_buf_pos = &b->yy_ch_buf[0]; b->yy_at_bol = 1; b->yy_buffer_status = YY_BUFFER_NEW; if ( b == YY_CURRENT_BUFFER ) yy_load_buffer_state( ); } /** Pushes the new state onto the stack. The new state becomes * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. * */ void yypush_buffer_state (YY_BUFFER_STATE new_buffer ) { if (new_buffer == NULL) return; yyensure_buffer_stack(); /* This block is copied from yy_switch_to_buffer. */ if ( YY_CURRENT_BUFFER ) { /* Flush out information for old buffer. */ *(yy_c_buf_p) = (yy_hold_char); YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } /* Only push if top exists. Otherwise, replace top. */ if (YY_CURRENT_BUFFER) (yy_buffer_stack_top)++; YY_CURRENT_BUFFER_LVALUE = new_buffer; /* copied from yy_switch_to_buffer. */ yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. * */ void yypop_buffer_state (void) { if (!YY_CURRENT_BUFFER) return; yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; if ((yy_buffer_stack_top) > 0) --(yy_buffer_stack_top); if (YY_CURRENT_BUFFER) { yy_load_buffer_state( ); (yy_did_buffer_switch_on_eof) = 1; } } /* Allocates the stack if it does not exist. * Guarantees space for at least one push. */ static void yyensure_buffer_stack (void) { int num_to_alloc; if (!(yy_buffer_stack)) { /* First allocation is just for 2 elements, since we don't know if this * scanner will even need a stack. We use 2 instead of 1 to avoid an * immediate realloc on the next call. */ num_to_alloc = 1; (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc (num_to_alloc * sizeof(struct yy_buffer_state*) ); memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; } if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ /* Increase the buffer to prepare for a possible push. */ int grow_size = 8 /* arbitrary grow size */; num_to_alloc = (yy_buffer_stack_max) + grow_size; (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc ((yy_buffer_stack), num_to_alloc * sizeof(struct yy_buffer_state*) ); /* zero only the new slots.*/ memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); (yy_buffer_stack_max) = num_to_alloc; } } /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer * * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size ) { YY_BUFFER_STATE b; if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) /* They forgot to leave room for the EOB's. */ return 0; b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ b->yy_buf_pos = b->yy_ch_buf = base; b->yy_is_our_buffer = 0; b->yy_input_file = 0; b->yy_n_chars = b->yy_buf_size; b->yy_is_interactive = 0; b->yy_at_bol = 1; b->yy_fill_buffer = 0; b->yy_buffer_status = YY_BUFFER_NEW; yy_switch_to_buffer(b ); return b; } /** Setup the input buffer state to scan a string. The next call to yylex() will * scan from a @e copy of @a str. * @param str a NUL-terminated string to scan * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * yy_scan_bytes() instead. */ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr ) { return yy_scan_bytes(yystr,strlen(yystr) ); } /** Setup the input buffer state to scan the given bytes. The next call to yylex() will * scan from a @e copy of @a bytes. * @param bytes the byte buffer to scan * @param len the number of bytes in the buffer pointed to by @a bytes. * * @return the newly allocated buffer state object. */ YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) { YY_BUFFER_STATE b; char *buf; yy_size_t n; int i; /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) yyalloc(n ); if ( ! buf ) YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); for ( i = 0; i < _yybytes_len; ++i ) buf[i] = yybytes[i]; buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; b = yy_scan_buffer(buf,n ); if ( ! b ) YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); /* It's okay to grow etc. this buffer, and we should throw it * away when we're done. */ b->yy_is_our_buffer = 1; return b; } #ifndef YY_EXIT_FAILURE #define YY_EXIT_FAILURE 2 #endif static void yy_fatal_error (yyconst char* msg ) { (void) fprintf( stderr, "%s\n", msg ); exit( YY_EXIT_FAILURE ); } /* Redefine yyless() so it works in section 3 code. */ #undef yyless #define yyless(n) \ do \ { \ /* Undo effects of setting up yytext. */ \ int yyless_macro_arg = (n); \ YY_LESS_LINENO(yyless_macro_arg);\ yytext[yyleng] = (yy_hold_char); \ (yy_c_buf_p) = yytext + yyless_macro_arg; \ (yy_hold_char) = *(yy_c_buf_p); \ *(yy_c_buf_p) = '\0'; \ yyleng = yyless_macro_arg; \ } \ while ( 0 ) /* Accessor methods (get/set functions) to struct members. */ /** Get the current line number. * */ int yyget_lineno (void) { return yylineno; } /** Get the input stream. * */ FILE *yyget_in (void) { return yyin; } /** Get the output stream. * */ FILE *yyget_out (void) { return yyout; } /** Get the length of the current token. * */ int yyget_leng (void) { return yyleng; } /** Get the current token. * */ char *yyget_text (void) { return yytext; } /** Set the current line number. * @param line_number * */ void yyset_lineno (int line_number ) { yylineno = line_number; } /** Set the input stream. This does not discard the current * input buffer. * @param in_str A readable stream. * * @see yy_switch_to_buffer */ void yyset_in (FILE * in_str ) { yyin = in_str ; } void yyset_out (FILE * out_str ) { yyout = out_str ; } int yyget_debug (void) { return yy_flex_debug; } void yyset_debug (int bdebug ) { yy_flex_debug = bdebug ; } static int yy_init_globals (void) { /* Initialization is the same as for the non-reentrant scanner. * This function is called from yylex_destroy(), so don't allocate here. */ (yy_buffer_stack) = 0; (yy_buffer_stack_top) = 0; (yy_buffer_stack_max) = 0; (yy_c_buf_p) = (char *) 0; (yy_init) = 0; (yy_start) = 0; /* Defined in main.c */ #ifdef YY_STDINIT yyin = stdin; yyout = stdout; #else yyin = (FILE *) 0; yyout = (FILE *) 0; #endif /* For future reference: Set errno on error, since we are called by * yylex_init() */ return 0; } /* yylex_destroy is for both reentrant and non-reentrant scanners. */ int yylex_destroy (void) { /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ yy_delete_buffer(YY_CURRENT_BUFFER ); YY_CURRENT_BUFFER_LVALUE = NULL; yypop_buffer_state(); } /* Destroy the stack itself. */ yyfree((yy_buffer_stack) ); (yy_buffer_stack) = NULL; /* Reset the globals. This is important in a non-reentrant scanner so the next time * yylex() is called, initialization will occur. */ yy_init_globals( ); return 0; } /* * Internal utility routines. */ #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { register int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } #endif #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s ) { register int n; for ( n = 0; s[n]; ++n ) ; return n; } #endif void *yyalloc (yy_size_t size ) { return (void *) malloc( size ); } void *yyrealloc (void * ptr, yy_size_t size ) { /* The cast to (char *) in the following accommodates both * implementations that use char* generic pointers, and those * that use void* generic pointers. It works with the latter * because both ANSI C and C++ allow castless assignment from * any pointer type to void*, and deal with argument conversions * as though doing an assignment. */ return (void *) realloc( (char *) ptr, size ); } void yyfree (void * ptr ) { free( (char *) ptr ); /* see yyrealloc() for (char *) cast */ } #define YYTABLES_NAME "yytables" #line 226 "lex.l" ht-2.0.22/eval/evalparse.c0000644000175000001440000016572611035232001012206 00000000000000/* A Bison parser, made by GNU Bison 2.3. */ /* Skeleton implementation for Bison's Yacc-like parsers in C Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* C LALR(1) parser skeleton written by Richard Stallman, by simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local variables, as they might otherwise be expanded by user macros. There are some unavoidable exceptions within include files to define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ #define YYBISON_VERSION "2.3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" /* Pure parsers. */ #define YYPURE 1 /* Using locations. */ #define YYLSP_NEEDED 0 /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { EVAL_INT = 258, EVAL_STR = 259, EVAL_FLOAT = 260, EVAL_IDENT = 261, EVAL_LAND = 262, EVAL_LXOR = 263, EVAL_LOR = 264, EVAL_EQ = 265, EVAL_NE = 266, EVAL_STR_EQ = 267, EVAL_STR_NE = 268, EVAL_LT = 269, EVAL_LE = 270, EVAL_GT = 271, EVAL_GE = 272, EVAL_STR_LT = 273, EVAL_STR_LE = 274, EVAL_STR_GT = 275, EVAL_STR_GE = 276, EVAL_SHL = 277, EVAL_SHR = 278, NEG = 279, EVAL_POW = 280 }; #endif /* Tokens. */ #define EVAL_INT 258 #define EVAL_STR 259 #define EVAL_FLOAT 260 #define EVAL_IDENT 261 #define EVAL_LAND 262 #define EVAL_LXOR 263 #define EVAL_LOR 264 #define EVAL_EQ 265 #define EVAL_NE 266 #define EVAL_STR_EQ 267 #define EVAL_STR_NE 268 #define EVAL_LT 269 #define EVAL_LE 270 #define EVAL_GT 271 #define EVAL_GE 272 #define EVAL_STR_LT 273 #define EVAL_STR_LE 274 #define EVAL_STR_GT 275 #define EVAL_STR_GE 276 #define EVAL_SHL 277 #define EVAL_SHR 278 #define NEG 279 #define EVAL_POW 280 /* Copy the first part of user declarations. */ #line 4 "evalparse.y" #define YYPARSE_PARAM resultptr #include "evaltype.h" #include "eval.h" void yyerror (char *s) { set_eval_error(s); } /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 #endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE # undef YYERROR_VERBOSE # define YYERROR_VERBOSE 1 #else # define YYERROR_VERBOSE 0 #endif /* Enabling the token table. */ #ifndef YYTOKEN_TABLE # define YYTOKEN_TABLE 0 #endif #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE #line 18 "evalparse.y" { eval_scalar scalar; char *ident; eval_scalarlist scalars; } /* Line 187 of yacc.c. */ #line 166 "evalparse.c" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif /* Copy the second part of user declarations. */ /* Line 216 of yacc.c. */ #line 179 "evalparse.c" #ifdef short # undef short #endif #ifdef YYTYPE_UINT8 typedef YYTYPE_UINT8 yytype_uint8; #else typedef unsigned char yytype_uint8; #endif #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; #elif (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) typedef signed char yytype_int8; #else typedef short int yytype_int8; #endif #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else typedef short int yytype_int16; #endif #ifndef YYSIZE_T # ifdef __SIZE_TYPE__ # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else # define YYSIZE_T unsigned int # endif #endif #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ # if YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) # endif # endif # ifndef YY_ # define YY_(msgid) msgid # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(e) ((void) (e)) #else # define YYUSE(e) /* empty */ #endif /* Identity function, used to suppress warnings about constant conditions. */ #ifndef lint # define YYID(n) (n) #else #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int YYID (int i) #else static int YYID (i) int i; #endif { return i; } #endif #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ # ifdef YYSTACK_USE_ALLOCA # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca # elif defined __BUILTIN_VA_ARG_INCR # include /* INFRINGES ON USER NAME SPACE */ # elif defined _AIX # define YYSTACK_ALLOC __alloca # elif defined _MSC_VER # include /* INFRINGES ON USER NAME SPACE */ # define alloca _alloca # else # define YYSTACK_ALLOC alloca # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ # ifndef _STDLIB_H # define _STDLIB_H 1 # endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC /* Pacify GCC's `empty if-body' warning. */ # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif # if (defined __cplusplus && ! defined _STDLIB_H \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ # ifndef _STDLIB_H # define _STDLIB_H 1 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif # endif #endif /* ! defined yyoverflow || YYERROR_VERBOSE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { yytype_int16 yyss; YYSTYPE yyvs; }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY # if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else # define YYCOPY(To, From, Count) \ do \ { \ YYSIZE_T yyi; \ for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ while (YYID (0)) # endif # endif /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ # define YYSTACK_RELOCATE(Stack) \ do \ { \ YYSIZE_T yynewbytes; \ YYCOPY (&yyptr->Stack, Stack, yysize); \ Stack = &yyptr->Stack; \ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ while (YYID (0)) #endif /* YYFINAL -- State number of the termination state. */ #define YYFINAL 16 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 562 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 42 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 6 /* YYNRULES -- Number of rules. */ #define YYNRULES 44 /* YYNRULES -- Number of states. */ #define YYNSTATES 83 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 280 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 37, 2, 2, 2, 35, 16, 2, 40, 41, 33, 32, 7, 31, 10, 34, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 9, 2, 2, 2, 2, 8, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 15, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 14, 2, 36, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 11, 12, 13, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 38, 39 }; #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ static const yytype_uint8 yyprhs[] = { 0, 0, 3, 5, 7, 9, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59, 63, 67, 71, 75, 79, 83, 87, 91, 95, 99, 103, 107, 111, 115, 118, 121, 124, 128, 134, 138, 143, 145, 146, 148, 150, 154 }; /* YYRHS -- A `-1'-separated list of the rules' RHS. */ static const yytype_int8 yyrhs[] = { 43, 0, -1, 44, -1, 3, -1, 4, -1, 5, -1, 44, 33, 44, -1, 44, 34, 44, -1, 44, 35, 44, -1, 44, 32, 44, -1, 44, 31, 44, -1, 44, 16, 44, -1, 44, 14, 44, -1, 44, 15, 44, -1, 44, 39, 44, -1, 44, 29, 44, -1, 44, 30, 44, -1, 44, 17, 44, -1, 44, 18, 44, -1, 44, 23, 44, -1, 44, 24, 44, -1, 44, 21, 44, -1, 44, 22, 44, -1, 44, 11, 44, -1, 44, 12, 44, -1, 44, 13, 44, -1, 44, 19, 44, -1, 44, 20, 44, -1, 44, 27, 44, -1, 44, 28, 44, -1, 44, 25, 44, -1, 44, 26, 44, -1, 31, 44, -1, 36, 44, -1, 37, 44, -1, 40, 44, 41, -1, 44, 8, 44, 9, 44, -1, 44, 10, 44, -1, 47, 40, 45, 41, -1, 47, -1, -1, 46, -1, 44, -1, 46, 7, 46, -1, 6, -1 }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint8 yyrline[] = { 0, 65, 65, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 108, 115, 124, 130, 133, 134, 142 }; #endif #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "EVAL_INT", "EVAL_STR", "EVAL_FLOAT", "EVAL_IDENT", "','", "'?'", "':'", "'.'", "EVAL_LAND", "EVAL_LXOR", "EVAL_LOR", "'|'", "'^'", "'&'", "EVAL_EQ", "EVAL_NE", "EVAL_STR_EQ", "EVAL_STR_NE", "EVAL_LT", "EVAL_LE", "EVAL_GT", "EVAL_GE", "EVAL_STR_LT", "EVAL_STR_LE", "EVAL_STR_GT", "EVAL_STR_GE", "EVAL_SHL", "EVAL_SHR", "'-'", "'+'", "'*'", "'/'", "'%'", "'~'", "'!'", "NEG", "EVAL_POW", "'('", "')'", "$accept", "input", "scalar", "scalarlist_or_null", "scalarlist", "identifier", 0 }; #endif # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 44, 63, 58, 46, 262, 263, 264, 124, 94, 38, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 45, 43, 42, 47, 37, 126, 33, 279, 280, 40, 41 }; # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 42, 43, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 45, 46, 46, 47 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 3, 5, 3, 4, 1, 0, 1, 1, 3, 1 }; /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { 0, 3, 4, 5, 44, 0, 0, 0, 0, 0, 2, 39, 32, 33, 34, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 35, 0, 37, 23, 24, 25, 12, 13, 11, 17, 18, 26, 27, 21, 22, 19, 20, 30, 31, 28, 29, 15, 16, 10, 9, 6, 7, 8, 14, 42, 0, 41, 0, 38, 0, 36, 43 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { -1, 9, 75, 76, 77, 11 }; /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -68 static const yytype_int16 yypact[] = { 43, -68, -68, -68, -68, 43, 43, 43, 43, 1, 138, -38, -36, -36, -36, 74, -68, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, -68, 108, 167, 38, 194, 220, 245, 269, 292, 315, 337, 358, 378, 397, 415, 432, 448, 463, 477, 490, 502, 513, 523, -24, -24, -36, -36, -36, -68, 138, -37, 5, 43, -68, 43, 138, -68 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { -68, -68, 0, -68, -67, -68 }; /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -1 static const yytype_int8 yytable[] = { 10, 16, 45, 44, 79, 12, 13, 14, 15, 41, 42, 43, 80, 82, 0, 44, 0, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 0, 1, 2, 3, 4, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 5, 0, 0, 44, 81, 6, 7, 0, 17, 8, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, 0, 46, 17, 78, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 17, 44, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, -1, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, -1, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, -1, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, -1, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, -1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, -1, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, -1, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, -1, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, -1, 35, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, -1, 36, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, -1, 37, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, -1, 38, 39, 40, 41, 42, 43, 0, 0, 0, 44, -1, 39, 40, 41, 42, 43, 0, 0, 0, 44 }; static const yytype_int8 yycheck[] = { 0, 0, 40, 39, 41, 5, 6, 7, 8, 33, 34, 35, 7, 80, -1, 39, -1, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, -1, 3, 4, 5, 6, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 31, -1, -1, 39, 78, 36, 37, -1, 8, 40, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, -1, 41, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, 8, 39, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39, 30, 31, 32, 33, 34, 35, -1, -1, -1, 39 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { 0, 3, 4, 5, 6, 31, 36, 37, 40, 43, 44, 47, 44, 44, 44, 44, 0, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 39, 40, 41, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 45, 46, 9, 41, 7, 44, 46 }; #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY (-2) #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrorlab /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(Token, Value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ else \ { \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ while (YYID (0)) #define YYTERROR 1 #define YYERRCODE 256 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. If N is 0, then set CURRENT to the empty location which ends the previous symbol: RHS[0] (always defined). */ #define YYRHSLOC(Rhs, K) ((Rhs)[K]) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (YYID (N)) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ } \ else \ { \ (Current).first_line = (Current).last_line = \ YYRHSLOC (Rhs, 0).last_line; \ (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ while (YYID (0)) #endif /* YY_LOCATION_PRINT -- Print the location on the stream. This macro was not mandated originally: define only if we know we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT # if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ (Loc).first_line, (Loc).first_column, \ (Loc).last_line, (Loc).last_column) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif #endif /* YYLEX -- calling `yylex' with the right arguments. */ #ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, YYLEX_PARAM) #else # define YYLEX yylex (&yylval) #endif /* Enable debugging if requested. */ #if YYDEBUG # ifndef YYFPRINTF # include /* INFRINGES ON USER NAME SPACE */ # define YYFPRINTF fprintf # endif # define YYDPRINTF(Args) \ do { \ if (yydebug) \ YYFPRINTF Args; \ } while (YYID (0)) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ do { \ if (yydebug) \ { \ YYFPRINTF (stderr, "%s ", Title); \ yy_symbol_print (stderr, \ Type, Value); \ YYFPRINTF (stderr, "\n"); \ } \ } while (YYID (0)) /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) #else static void yy_symbol_value_print (yyoutput, yytype, yyvaluep) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; #endif { if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # else YYUSE (yyoutput); # endif switch (yytype) { default: break; } } /*--------------------------------. | Print this symbol on YYOUTPUT. | `--------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) #else static void yy_symbol_print (yyoutput, yytype, yyvaluep) FILE *yyoutput; int yytype; YYSTYPE const * const yyvaluep; #endif { if (yytype < YYNTOKENS) YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); else YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep); YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) #else static void yy_stack_print (bottom, top) yytype_int16 *bottom; yytype_int16 *top; #endif { YYFPRINTF (stderr, "Stack now"); for (; bottom <= top; ++bottom) YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } # define YY_STACK_PRINT(Bottom, Top) \ do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ } while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yy_reduce_print (YYSTYPE *yyvsp, int yyrule) #else static void yy_reduce_print (yyvsp, yyrule) YYSTYPE *yyvsp; int yyrule; #endif { int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { fprintf (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) ); fprintf (stderr, "\n"); } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ yy_reduce_print (yyvsp, Rule); \ } while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ int yydebug; #else /* !YYDEBUG */ # define YYDPRINTF(Args) # define YY_SYMBOL_PRINT(Title, Type, Value, Location) # define YY_STACK_PRINT(Bottom, Top) # define YY_REDUCE_PRINT(Rule) #endif /* !YYDEBUG */ /* YYINITDEPTH -- initial size of the parser's stacks. */ #ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only if the built-in stack extension method is used). Do not make this value too large; the results are undefined if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH) evaluated with infinite-precision integer arithmetic. */ #ifndef YYMAXDEPTH # define YYMAXDEPTH 10000 #endif #if YYERROR_VERBOSE # ifndef yystrlen # if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) #else static YYSIZE_T yystrlen (yystr) const char *yystr; #endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) continue; return yylen; } # endif # endif # ifndef yystpcpy # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) #else static char * yystpcpy (yydest, yysrc) char *yydest; const char *yysrc; #endif { char *yyd = yydest; const char *yys = yysrc; while ((*yyd++ = *yys++) != '\0') continue; return yyd - 1; } # endif # endif # ifndef yytnamerr /* Copy to YYRES the contents of YYSTR after stripping away unnecessary quotes and backslashes, so that it's suitable for yyerror. The heuristic is that double-quoting is unnecessary unless the string contains an apostrophe, a comma, or backslash (other than backslash-backslash). YYSTR is taken from yytname. If YYRES is null, do not copy; instead, return the length of what the result would have been. */ static YYSIZE_T yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) switch (*++yyp) { case '\'': case ',': goto do_not_strip_quotes; case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; yyn++; break; case '"': if (yyres) yyres[yyn] = '\0'; return yyn; } do_not_strip_quotes: ; } if (! yyres) return yystrlen (yystr); return yystpcpy (yyres, yystr) - yyres; } # endif /* Copy into YYRESULT an error message about the unexpected token YYCHAR while in state YYSTATE. Return the number of bytes copied, including the terminating null byte. If YYRESULT is null, do not copy anything; just return the number of bytes that would be copied. As a special case, return 0 if an ordinary "syntax error" message will do. Return YYSIZE_MAXIMUM if overflow occurs during size calculation. */ static YYSIZE_T yysyntax_error (char *yyresult, int yystate, int yychar) { int yyn = yypact[yystate]; if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) return 0; else { int yytype = YYTRANSLATE (yychar); YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); YYSIZE_T yysize = yysize0; YYSIZE_T yysize1; int yysize_overflow = 0; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; int yyx; # if 0 /* This is so xgettext sees the translatable formats that are constructed on the fly. */ YY_("syntax error, unexpected %s"); YY_("syntax error, unexpected %s, expecting %s"); YY_("syntax error, unexpected %s, expecting %s or %s"); YY_("syntax error, unexpected %s, expecting %s or %s or %s"); YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); # endif char *yyfmt; char const *yyf; static char const yyunexpected[] = "syntax error, unexpected %s"; static char const yyexpecting[] = ", expecting %s"; static char const yyor[] = " or %s"; char yyformat[sizeof yyunexpected + sizeof yyexpecting - 1 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) * (sizeof yyor - 1))]; char const *yyprefix = yyexpecting; /* Start YYX at -YYN if negative to avoid negative indexes in YYCHECK. */ int yyxbegin = yyn < 0 ? -yyn : 0; /* Stay within bounds of both yycheck and yytname. */ int yychecklim = YYLAST - yyn + 1; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yycount = 1; yyarg[0] = yytname[yytype]; yyfmt = yystpcpy (yyformat, yyunexpected); for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { yycount = 1; yysize = yysize0; yyformat[sizeof yyunexpected - 1] = '\0'; break; } yyarg[yycount++] = yytname[yyx]; yysize1 = yysize + yytnamerr (0, yytname[yyx]); yysize_overflow |= (yysize1 < yysize); yysize = yysize1; yyfmt = yystpcpy (yyfmt, yyprefix); yyprefix = yyor; } yyf = YY_(yyformat); yysize1 = yysize + yystrlen (yyf); yysize_overflow |= (yysize1 < yysize); yysize = yysize1; if (yysize_overflow) return YYSIZE_MAXIMUM; if (yyresult) { /* Avoid sprintf, as that infringes on the user's name space. Don't have undefined behavior even if the translation produced a string with the wrong number of "%s"s. */ char *yyp = yyresult; int yyi = 0; while ((*yyp = *yyf) != '\0') { if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) { yyp += yytnamerr (yyp, yyarg[yyi++]); yyf += 2; } else { yyp++; yyf++; } } } return yysize; } } #endif /* YYERROR_VERBOSE */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ /*ARGSUSED*/ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) #else static void yydestruct (yymsg, yytype, yyvaluep) const char *yymsg; int yytype; YYSTYPE *yyvaluep; #endif { YYUSE (yyvaluep); if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); switch (yytype) { default: break; } } /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); #else int yyparse (); #endif #else /* ! YYPARSE_PARAM */ #if defined __STDC__ || defined __cplusplus int yyparse (void); #else int yyparse (); #endif #endif /* ! YYPARSE_PARAM */ /*----------. | yyparse. | `----------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void *YYPARSE_PARAM) #else int yyparse (YYPARSE_PARAM) void *YYPARSE_PARAM; #endif #else /* ! YYPARSE_PARAM */ #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) int yyparse (void) #else int yyparse () #endif #endif { /* The look-ahead symbol. */ int yychar; /* The semantic value of the look-ahead symbol. */ YYSTYPE yylval; /* Number of syntax errors so far. */ int yynerrs; int yystate; int yyn; int yyresult; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* Look-ahead token as an internal (translated) token number. */ int yytoken = 0; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; char *yymsg = yymsgbuf; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif /* Three stacks and their tools: `yyss': related to states, `yyvs': related to semantic values, `yyls': related to locations. Refer to the stacks thru separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ yytype_int16 yyssa[YYINITDEPTH]; yytype_int16 *yyss = yyssa; yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; YYSTYPE *yyvs = yyvsa; YYSTYPE *yyvsp; #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) YYSIZE_T yystacksize = YYINITDEPTH; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss; yyvsp = yyvs; goto yysetstate; /*------------------------------------------------------------. | yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) { /* Get the current used size of the three stacks, in elements. */ YYSIZE_T yysize = yyssp - yyss + 1; #ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); yyss = yyss1; yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE goto yyexhaustedlab; # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) yystacksize = YYMAXDEPTH; { yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; YYSTACK_RELOCATE (yyss); YYSTACK_RELOCATE (yyvs); # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); goto yybackup; /*-----------. | yybackup. | `-----------*/ yybackup: /* Do appropriate processing given the current state. Read a look-ahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; /* Not known => get a look-ahead token if don't already have one. */ /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; YYDPRINTF ((stderr, "Now at end of input.\n")); } else { yytoken = YYTRANSLATE (yychar); YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to detect an error, take that action. */ yyn += yytoken; if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) goto yydefault; yyn = yytable[yyn]; if (yyn <= 0) { if (yyn == 0 || yyn == YYTABLE_NINF) goto yyerrlab; yyn = -yyn; goto yyreduce; } if (yyn == YYFINAL) YYACCEPT; /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; /* Shift the look-ahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); /* Discard the shifted token unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; goto yynewstate; /*-----------------------------------------------------------. | yydefault -- do the default action for the current state. | `-----------------------------------------------------------*/ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; goto yyreduce; /*-----------------------------. | yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: `$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison users should not rely upon it. Assigning to YYVAL unconditionally makes the parser a bit smaller, and it avoids a GCC warning that YYVAL may be used uninitialized. */ yyval = yyvsp[1-yylen]; YY_REDUCE_PRINT (yyn); switch (yyn) { case 2: #line 65 "evalparse.y" { *(eval_scalar*)resultptr=(yyvsp[(1) - (1)].scalar); } break; case 3: #line 68 "evalparse.y" { (yyval.scalar) = (yyvsp[(1) - (1)].scalar); } break; case 4: #line 69 "evalparse.y" { (yyval.scalar) = (yyvsp[(1) - (1)].scalar); } break; case 5: #line 70 "evalparse.y" { (yyval.scalar) = (yyvsp[(1) - (1)].scalar); } break; case 6: #line 71 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), '*')) YYERROR; } break; case 7: #line 72 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), '/')) YYERROR; } break; case 8: #line 73 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), '%')) YYERROR; } break; case 9: #line 74 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), '+')) YYERROR; } break; case 10: #line 75 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), '-')) YYERROR; } break; case 11: #line 76 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), '&')) YYERROR; } break; case 12: #line 77 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), '|')) YYERROR; } break; case 13: #line 78 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), '^')) YYERROR; } break; case 14: #line 79 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_POW)) YYERROR; } break; case 15: #line 80 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_SHL)) YYERROR; } break; case 16: #line 81 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_SHR)) YYERROR; } break; case 17: #line 82 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_EQ)) YYERROR; } break; case 18: #line 83 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_NE)) YYERROR; } break; case 19: #line 84 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_GT)) YYERROR; } break; case 20: #line 85 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_GE)) YYERROR; } break; case 21: #line 86 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_LT)) YYERROR; } break; case 22: #line 87 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_LE)) YYERROR; } break; case 23: #line 88 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_LAND)) YYERROR; } break; case 24: #line 89 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_LXOR)) YYERROR; } break; case 25: #line 90 "evalparse.y" { if (!scalar_op(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_LOR)) YYERROR; } break; case 26: #line 91 "evalparse.y" { scalar_strop(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_STR_EQ); } break; case 27: #line 92 "evalparse.y" { scalar_strop(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_STR_NE); } break; case 28: #line 93 "evalparse.y" { scalar_strop(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_STR_GT); } break; case 29: #line 94 "evalparse.y" { scalar_strop(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_STR_GE); } break; case 30: #line 95 "evalparse.y" { scalar_strop(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_STR_LT); } break; case 31: #line 96 "evalparse.y" { scalar_strop(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar), EVAL_STR_LE); } break; case 32: #line 97 "evalparse.y" { scalar_negset(&(yyval.scalar), &(yyvsp[(2) - (2)].scalar)); } break; case 33: #line 98 "evalparse.y" { scalar_notset(&(yyval.scalar), &(yyvsp[(2) - (2)].scalar)); } break; case 34: #line 99 "evalparse.y" { scalar_lnotset(&(yyval.scalar), &(yyvsp[(2) - (2)].scalar)); } break; case 35: #line 100 "evalparse.y" { (yyval.scalar) = (yyvsp[(2) - (3)].scalar); } break; case 36: #line 101 "evalparse.y" { scalar_miniif(&(yyval.scalar), &(yyvsp[(1) - (5)].scalar), &(yyvsp[(3) - (5)].scalar), &(yyvsp[(5) - (5)].scalar)); } break; case 37: #line 103 "evalparse.y" { scalar_concat(&(yyval.scalar), &(yyvsp[(1) - (3)].scalar), &(yyvsp[(3) - (3)].scalar)); scalar_destroy(&(yyvsp[(1) - (3)].scalar)); scalar_destroy(&(yyvsp[(3) - (3)].scalar)); } break; case 38: #line 109 "evalparse.y" { int r=evalfunc(&(yyval.scalar), (yyvsp[(1) - (4)].ident), &(yyvsp[(3) - (4)].scalars)); scalarlist_destroy(&(yyvsp[(3) - (4)].scalars)); free((yyvsp[(1) - (4)].ident)); if (!r) YYERROR; } break; case 39: #line 116 "evalparse.y" { int r=evalsymbol(&(yyval.scalar), (yyvsp[(1) - (1)].ident)); free((yyvsp[(1) - (1)].ident)); if (!r) YYERROR; } break; case 40: #line 124 "evalparse.y" { eval_scalarlist s; s.count=0; s.scalars=NULL; (yyval.scalars) = s; } break; case 41: #line 130 "evalparse.y" { (yyval.scalars) = (yyvsp[(1) - (1)].scalars); } break; case 42: #line 133 "evalparse.y" { scalarlist_set(&(yyval.scalars), &(yyvsp[(1) - (1)].scalar)); } break; case 43: #line 135 "evalparse.y" { scalarlist_concat(&(yyval.scalars), &(yyvsp[(1) - (3)].scalars), &(yyvsp[(3) - (3)].scalars)); scalarlist_destroy_gentle(&(yyvsp[(1) - (3)].scalars)); scalarlist_destroy_gentle(&(yyvsp[(3) - (3)].scalars)); } break; case 44: #line 142 "evalparse.y" { (yyval.ident) = (yyvsp[(1) - (1)].ident); } break; /* Line 1267 of yacc.c. */ #line 1775 "evalparse.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; /*------------------------------------. | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { ++yynerrs; #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else { YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) { YYSIZE_T yyalloc = 2 * yysize; if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) yyalloc = YYSTACK_ALLOC_MAXIMUM; if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); yymsg = (char *) YYSTACK_ALLOC (yyalloc); if (yymsg) yymsg_alloc = yyalloc; else { yymsg = yymsgbuf; yymsg_alloc = sizeof yymsgbuf; } } if (0 < yysize && yysize <= yymsg_alloc) { (void) yysyntax_error (yymsg, yystate, yychar); yyerror (yymsg); } else { yyerror (YY_("syntax error")); if (yysize != 0) goto yyexhaustedlab; } } #endif } if (yyerrstatus == 3) { /* If just tried and failed to reuse look-ahead token after an error, discard it. */ if (yychar <= YYEOF) { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; } else { yydestruct ("Error: discarding", yytoken, &yylval); yychar = YYEMPTY; } } /* Else will try to reuse look-ahead token after shifting the error token. */ goto yyerrlab1; /*---------------------------------------------------. | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ if (/*CONSTCOND*/ 0) goto yyerrorlab; /* Do not reclaim the symbols of the rule which action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; /*-------------------------------------------------------------. | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) { yyn = yytable[yyn]; if (0 < yyn) break; } } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) YYABORT; yydestruct ("Error: popping", yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } if (yyn == YYFINAL) YYACCEPT; *++yyvsp = yylval; /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; /*-------------------------------------. | yyacceptlab -- YYACCEPT comes here. | `-------------------------------------*/ yyacceptlab: yyresult = 0; goto yyreturn; /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ yyabortlab: yyresult = 1; goto yyreturn; #ifndef yyoverflow /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ yyexhaustedlab: yyerror (YY_("memory exhausted")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif #if YYERROR_VERBOSE if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif /* Make sure YYID is used. */ return YYID (yyresult); } #line 145 "evalparse.y" ht-2.0.22/eval/evalx.h0000644000175000001440000000041707523775055011365 00000000000000#ifndef __EVALX_H__ #define __EVALX_H__ #include "evaltype.h" #include "eval.h" #ifdef __cplusplus extern "C" #endif int eval(eval_scalar *r, const char *str, eval_func_handler func_handler, eval_symbol_handler symbol_handler, void *context); #endif /* __EVALX_H__ */ ht-2.0.22/eval/Makefile.am0000644000175000017500000000063611724770100012120 00000000000000 AM_CPPFLAGS = ${my_CPPFLAGS} -I$(srcdir) -I$(top_srcdir) AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} AM_YFLAGS = -d AM_LFLAGS = AUTOMAKE_OPTIONS=foreign noinst_LIBRARIES = libhteval.a libhteval_a_SOURCES = evalparse.y evalparse.h eval.cc eval.h lex.l lex.h evalx.c evalx.h evaltype.h #bin_PROGRAMS = testeval #testeval_SOURCES = testeval.c #testeval_LDADD = libhteval.a #testeval_LDFLAGS = -lm ht-2.0.22/eval/evalparse.h0000644000175000001440000000615611035232001012202 00000000000000/* A Bison parser, made by GNU Bison 2.3. */ /* Skeleton interface for Bison's Yacc-like parsers in C Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work under terms of your choice, so long as that work isn't itself a parser generator using the skeleton or a modified version thereof as a parser skeleton. Alternatively, if you modify or redistribute the parser skeleton itself, you may (at your option) remove this special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE /* Put the tokens into the symbol table, so that GDB and other debuggers know about them. */ enum yytokentype { EVAL_INT = 258, EVAL_STR = 259, EVAL_FLOAT = 260, EVAL_IDENT = 261, EVAL_LAND = 262, EVAL_LXOR = 263, EVAL_LOR = 264, EVAL_EQ = 265, EVAL_NE = 266, EVAL_STR_EQ = 267, EVAL_STR_NE = 268, EVAL_LT = 269, EVAL_LE = 270, EVAL_GT = 271, EVAL_GE = 272, EVAL_STR_LT = 273, EVAL_STR_LE = 274, EVAL_STR_GT = 275, EVAL_STR_GE = 276, EVAL_SHL = 277, EVAL_SHR = 278, NEG = 279, EVAL_POW = 280 }; #endif /* Tokens. */ #define EVAL_INT 258 #define EVAL_STR 259 #define EVAL_FLOAT 260 #define EVAL_IDENT 261 #define EVAL_LAND 262 #define EVAL_LXOR 263 #define EVAL_LOR 264 #define EVAL_EQ 265 #define EVAL_NE 266 #define EVAL_STR_EQ 267 #define EVAL_STR_NE 268 #define EVAL_LT 269 #define EVAL_LE 270 #define EVAL_GT 271 #define EVAL_GE 272 #define EVAL_STR_LT 273 #define EVAL_STR_LE 274 #define EVAL_STR_GT 275 #define EVAL_STR_GE 276 #define EVAL_SHL 277 #define EVAL_SHR 278 #define NEG 279 #define EVAL_POW 280 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE #line 18 "evalparse.y" { eval_scalar scalar; char *ident; eval_scalarlist scalars; } /* Line 1489 of yacc.c. */ #line 105 "evalparse.h" YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 #endif ht-2.0.22/eval/lex.l0000644000175000001440000001100510615343233011016 00000000000000%{ #define USE_PURE_PARSER #ifdef USE_PURE_PARSER #define YY_DECL int yylex (YYSTYPE *lvalp) #define YY_LVALP lvalp #else #define YY_LVALP (&yylval) #endif /* get current pos (offset from start of line) */ #define YY_USER_ACTION lex_pos=yy_bp - YY_CURRENT_BUFFER->yy_ch_buf; #include #include #include #include "eval.h" #include "evaltype.h" #include "evalparse.h" static int lex_pos; static int char2int(char a, int base) { int i; if ((a>='A') && (a<='Z')) { i=a-'A'+10; } else if ((a>='a') && (a<='z')) { i=a-'a'+10; } else if ((a>='0') && (a<='9')) { i=a-'0'; } else return -1; if (i>=base) return -1; return i; } static int parse_float(eval_scalar *f, char *fpn) { char *end; double d; d=strtod(fpn, &end); if (*end == 0) { f->type=SCALAR_FLOAT; f->scalar.floatnum.value=d; return 1; } return 0; } static int parse_integer(eval_scalar *i, char *num, int base, int lenmod) { uint64 k = 0; int l = strlen(num) + lenmod; while (l--) { int c=char2int(*num, base); if (c==-1) return 0; k *= base; k += c; num++; } i->type=SCALAR_INT; i->scalar.integer.value=k; i->scalar.integer.type=TYPE_UNKNOWN; return 1; } static int parse_cstring(eval_scalar *r, char *s, int len) { char *result; int alloclen = len; if (alloclen < 1) alloclen = 1; r->type = SCALAR_STR; r->scalar.str.value = (char*)malloc(alloclen); if (!r->scalar.str.value) return 0; result = r->scalar.str.value; // may not end with '\\' if (len && s[len-1] == '\\') return 0; while (s && *s && len) { if (*s == '\\') { s++;len--;if (!len) break; switch (*s) { case '0': *result++='\0'; break; case 'a': *result++='\a'; break; case 'b': *result++='\b'; break; case 'e': *result++='\e'; break; case 'f': *result++='\f'; break; case 'n': *result++='\n'; break; case 'r': *result++='\r'; break; case 't': *result++='\t'; break; case 'v': *result++='\v'; break; case '\"': *result++='"'; break; case '\\': *result++='\\'; break; case 'x': { int p, q; s++;len--;if (!len) break; p=char2int(*s, 16); if (p==-1) return 0; s++;len--;if (!len) break; q=char2int(*s, 16); if (q==-1) return 0; *result++=(char)p*16+q; break; } default: *result++='\\'; if (len) *result++=*s; break; } } else { *result++ = *s; } s++;len--; } r->scalar.str.len=result-r->scalar.str.value; return 1; } static int parse_pstring(eval_scalar *s, char *cstr, int len) { int alloclen=len; if (!len) alloclen=1; s->type=SCALAR_STR; s->scalar.str.value=(char*)malloc(alloclen); memcpy(s->scalar.str.value, cstr, len); s->scalar.str.len=len; return 1; } void *lex_current_buffer() { return (void*)YY_CURRENT_BUFFER; } int lex_current_buffer_pos() { return lex_pos; } void lex_switch_buffer(void *buffer) { yy_switch_to_buffer(buffer); } void lex_delete_buffer(void *buffer) { yy_delete_buffer(buffer); } void *lex_scan_string_buffer(const char *str) { return yy_scan_string(str); } /* */ %} %option noyywrap %% [ \t]+ /* nop */ \"(\\\"|[^"])*\" if (parse_cstring(&YY_LVALP->scalar, yytext+1, strlen(yytext+1)-1)) return EVAL_STR; '[^']*' if (parse_pstring(&YY_LVALP->scalar, yytext+1, strlen(yytext+1)-1)) return EVAL_STR; lt return EVAL_STR_LT; le return EVAL_STR_LE; gt return EVAL_STR_GT; ge return EVAL_STR_GE; eq return EVAL_STR_EQ; ne return EVAL_STR_NE; \*\* return EVAL_POW; \<\< return EVAL_SHL; \>\> return EVAL_SHR; \< return EVAL_LT; \<\= return EVAL_LE; \> return EVAL_GT; \>\= return EVAL_GE; \=\= return EVAL_EQ; \!\= return EVAL_NE; \&\& return EVAL_LAND; \|\| return EVAL_LOR; \^\^ return EVAL_LXOR; [$@a-zA-Z_][a-zA-Z0-9_]* YY_LVALP->ident=strdup(yytext); return EVAL_IDENT; [0-9]+\.[0-9]+([eE][+-]?[0-9]+)? if (parse_float(&YY_LVALP->scalar, yytext)) return EVAL_FLOAT; [0-9]+ if (parse_integer(&YY_LVALP->scalar, yytext, 10, 0)) return EVAL_INT; 0x[0-9a-fA-F]+ if (parse_integer(&YY_LVALP->scalar, yytext+2, 16, 0)) return EVAL_INT; [0-9][0-9a-fA-F]*h if (parse_integer(&YY_LVALP->scalar, yytext, 16, -1)) return EVAL_INT; [0-9]+d if (parse_integer(&YY_LVALP->scalar, yytext, 10, -1)) return EVAL_INT; [0-7]+o if (parse_integer(&YY_LVALP->scalar, yytext, 8, -1)) return EVAL_INT; [0-1]+b if (parse_integer(&YY_LVALP->scalar, yytext, 2, -1)) return EVAL_INT; . return *yytext; \n return '\n'; %% ht-2.0.22/eval/lex.h0000644000175000001440000000040007507606555011026 00000000000000#ifndef __LEX_H__ #define __LEX_H__ void *lex_current_buffer(); int lex_current_buffer_pos(); void lex_switch_buffer(void *buffer); void lex_delete_buffer(void *buffer); void *lex_scan_string_buffer(const char *str); int yylex(); #endif /* __LEX_H__ */ ht-2.0.22/eval/evalx.c0000644000175000001440000000221507530221655011344 00000000000000#include "evaltype.h" #include "eval.h" #include "lex.h" extern int yyparse(eval_scalar *result); int eval(eval_scalar *r, const char *str, eval_func_handler func_handler, eval_symbol_handler symbol_handler, void *context) { void *oldbuffer = lex_current_buffer(); void *strbuffer; eval_scalar result; /* if (get_helpmode()) { eval_scalar *hs = get_helpstring(); scalar_create_str_c(hs, ""); strbuffer = lex_scan_string_buffer("NaF()"); } else {*/ strbuffer = lex_scan_string_buffer(str); /* }*/ DEBUG_DUMP("evaluating \"%s\":", str); DEBUG_DUMP_INDENT_IN; clear_eval_error(); eval_set_context(context); eval_set_func_handler(func_handler); eval_set_symbol_handler(symbol_handler); result.type=SCALAR_NULL; yyparse(&result); lex_delete_buffer(strbuffer); if (oldbuffer) lex_switch_buffer(oldbuffer); /* if (get_helpmode()) { eval_scalar *hs = get_helpstring(); *r = *hs; hs->type = SCALAR_NULL; clear_eval_error(); } else {*/ if (result.type == SCALAR_NULL) return 0; *r = result; if (get_eval_error(0, 0)) return 0; /* }*/ DEBUG_DUMP_INDENT_OUT; DEBUG_DUMP_SCALAR(r, "eval result:"); return 1; } ht-2.0.22/eval/Makefile.in0000644000175000017500000003462212127657374012152 00000000000000# Makefile.in generated by automake 1.10.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = eval DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in evalparse.c \ evalparse.h lex.c ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru libhteval_a_AR = $(AR) $(ARFLAGS) libhteval_a_LIBADD = am_libhteval_a_OBJECTS = evalparse.$(OBJEXT) eval.$(OBJEXT) \ lex.$(OBJEXT) evalx.$(OBJEXT) libhteval_a_OBJECTS = $(am_libhteval_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) YLWRAP = $(top_srcdir)/ylwrap YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS) SOURCES = $(libhteval_a_SOURCES) DIST_SOURCES = $(libhteval_a_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ HT_LDFLAGS = @HT_LDFLAGS@ HT_LIBS = @HT_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IO_DIR = @IO_DIR@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ LZO_LIBS = @LZO_LIBS@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ curses_CPPFLAGS = @curses_CPPFLAGS@ curses_LIBS = @curses_LIBS@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ ncurses_config = @ncurses_config@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = ${my_CPPFLAGS} -I$(srcdir) -I$(top_srcdir) AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} AM_YFLAGS = -d AM_LFLAGS = AUTOMAKE_OPTIONS = foreign noinst_LIBRARIES = libhteval.a libhteval_a_SOURCES = evalparse.y evalparse.h eval.cc eval.h lex.l lex.h evalx.c evalx.h evaltype.h all: all-am .SUFFIXES: .SUFFIXES: .c .cc .l .o .obj .y $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign eval/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign eval/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) evalparse.h: evalparse.c @if test ! -f $@; then \ rm -f evalparse.c; \ $(MAKE) $(AM_MAKEFLAGS) evalparse.c; \ else :; fi libhteval.a: $(libhteval_a_OBJECTS) $(libhteval_a_DEPENDENCIES) -rm -f libhteval.a $(libhteval_a_AR) libhteval.a $(libhteval_a_OBJECTS) $(libhteval_a_LIBADD) $(RANLIB) libhteval.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eval.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evalparse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/evalx.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lex.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` .l.c: $(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE) .y.c: $(am__skipyacc) $(SHELL) $(YLWRAP) $< y.tab.c $@ y.tab.h $*.h y.output $*.output -- $(YACCCOMPILE) ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -rm -f evalparse.c -rm -f evalparse.h -rm -f lex.c clean: clean-am clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am #bin_PROGRAMS = testeval #testeval_SOURCES = testeval.c #testeval_LDADD = libhteval.a #testeval_LDFLAGS = -lm # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ht-2.0.22/eval/eval.h0000644000175000001440000001315610615343233011162 00000000000000/* * HT Editor * eval.h * * Copyright (C) 1999, 2000, 2001 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __EVAL_H__ #define __EVAL_H__ /*#define EVAL_DEBUG*/ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ #include #include #include #include #include #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "evaltype.h" #ifndef __cplusplus #define bool int #endif typedef bool (*eval_func_handler)(eval_scalar *result, char *name, eval_scalarlist *params); typedef bool (*eval_symbol_handler)(eval_scalar *result, char *name); #include "lex.h" #include "evalx.h" #ifdef EVAL_DEBUG int debug_dump_ident; #endif /* * */ #define MAX_FUNCNAME_LEN 16 #define MAX_SYMBOLNAME_LEN 32 #define MAX_ERRSTR_LEN 128 /* int f2i(double f); char *binstr2cstr(char *s, int len); int bin2str(char *result, void *S, int len); */ /* * ERROR HANDLING */ void clear_eval_error(); int get_eval_error(const char **str, int *pos); void set_eval_error(const char *format,...); void set_eval_error_ex(int pos, const char *format, ...); /* * */ #ifdef EVAL_DEBUG void integer_dump(eval_int *i); void float_dump(eval_float *f); void string_dump(eval_str *s); #endif void string_destroy(eval_str *s); /* * SCALARLIST */ void scalarlist_set(eval_scalarlist *l, eval_scalar *s); void scalarlist_concat(eval_scalarlist *l, eval_scalarlist *a, eval_scalarlist *b); void scalarlist_destroy(eval_scalarlist *l); void scalarlist_destroy_gentle(eval_scalarlist *l); #ifdef EVAL_DEBUG void scalarlist_dump(eval_scalarlist *l); #endif /* * SCALAR */ void scalar_setint(eval_scalar *s, eval_int *i); void scalar_setstr(eval_scalar *s, eval_str *t); #ifdef EVAL_DEBUG void scalar_dump(eval_scalar *s); #endif void scalar_create_int(eval_scalar *result, const eval_int *t); void scalar_create_int_c(eval_scalar *result, const int i); void scalar_create_int_q(eval_scalar *result, const uint64 q); void scalar_create_str(eval_scalar *result, const eval_str *t); void scalar_create_str_c(eval_scalar *result, const char *cstr); void scalar_create_float(eval_scalar *result, const eval_float *t); void scalar_create_float_c(eval_scalar *result, const double f); void scalar_clone(eval_scalar *result, const eval_scalar *s); void scalar_context_str(const eval_scalar *s, eval_str *t); void scalar_context_int(const eval_scalar *s, eval_int *t); void scalar_context_float(const eval_scalar *s, eval_float *t); void string_concat(eval_str *s, eval_str *a, eval_str *b); void scalar_concat(eval_scalar *s, const eval_scalar *a, const eval_scalar *b); void scalar_destroy(eval_scalar *s); int string_compare(const eval_str *a, const eval_str *b); int scalar_strop(eval_scalar *xr, const eval_scalar *xa, const eval_scalar *xb, int op); int scalar_float_op(eval_scalar *xr, const eval_scalar *xa, const eval_scalar *xb, int op); int scalar_int_op(eval_scalar *xr, const eval_scalar *xa, const eval_scalar *xb, int op); int scalar_op(eval_scalar *xr, eval_scalar *xa, eval_scalar *xb, int op); void scalar_negset(eval_scalar *xr, eval_scalar *xa); void scalar_notset(eval_scalar *xr, eval_scalar *xa); void scalar_lnotset(eval_scalar *xr, eval_scalar *xa); void scalar_miniif(eval_scalar *xr, eval_scalar *xa, eval_scalar *xb, eval_scalar *xc); void sprintf_puts(char **b, char *blimit, const char *buf); int sprintf_percent(char **fmt, int *fmtl, char **b, char *blimit, eval_scalar *s); int func_sprintf(eval_scalar *r, const eval_str *format, const eval_scalarlist *scalars); /* * FUNCTIONS */ int func_eval(eval_scalar *r, eval_str *p); int func_error(eval_scalar *r, eval_str *s); eval_protomatch match_evalfunc_proto(char *name, eval_scalarlist *params, eval_func *proto); int exec_evalfunc(eval_scalar *r, eval_scalarlist *params, eval_func *proto); int evalsymbol(eval_scalar *r, char *sname); int std_eval_func_handler(eval_scalar *r, char *fname, eval_scalarlist *params, eval_func *protos); int evalfunc(eval_scalar *r, char *fname, eval_scalarlist *params); void *eval_get_context(); void eval_set_context(void *context); void eval_set_func_handler(eval_func_handler func_handler); void eval_set_symbol_handler(eval_symbol_handler symbol_handler); #ifdef __cplusplus } #endif /* __cplusplus */ /* * Debugging */ #ifdef EVAL_DEBUG extern int debug_dump_ident; #define DEBUG_DUMP_INDENT {\ int i;\ for (i=0; i EVAL_INT %token EVAL_STR %token EVAL_FLOAT %token EVAL_IDENT %type scalar %type scalarlist %type scalarlist_or_null %type identifier %left ',' %right '?' ':' %left '.' %left EVAL_LAND %left EVAL_LXOR %left EVAL_LOR %left '|' %left '^' %left '&' %nonassoc EVAL_EQ %nonassoc EVAL_NE %nonassoc EVAL_STR_EQ %nonassoc EVAL_STR_NE %nonassoc EVAL_LT %nonassoc EVAL_LE %nonassoc EVAL_GT %nonassoc EVAL_GE %nonassoc EVAL_STR_LT %nonassoc EVAL_STR_LE %nonassoc EVAL_STR_GT %nonassoc EVAL_STR_GE %nonassoc EVAL_SHL %nonassoc EVAL_SHR %left '-' '+' %left '*' '/' '%' %left NEG '~' '!' %left EVAL_POW %% input: scalar { *(eval_scalar*)resultptr=$1; } ; scalar: EVAL_INT { $$ = $1; } | EVAL_STR { $$ = $1; } | EVAL_FLOAT { $$ = $1; } | scalar '*' scalar { if (!scalar_op(&$$, &$1, &$3, '*')) YYERROR; } | scalar '/' scalar { if (!scalar_op(&$$, &$1, &$3, '/')) YYERROR; } | scalar '%' scalar { if (!scalar_op(&$$, &$1, &$3, '%')) YYERROR; } | scalar '+' scalar { if (!scalar_op(&$$, &$1, &$3, '+')) YYERROR; } | scalar '-' scalar { if (!scalar_op(&$$, &$1, &$3, '-')) YYERROR; } | scalar '&' scalar { if (!scalar_op(&$$, &$1, &$3, '&')) YYERROR; } | scalar '|' scalar { if (!scalar_op(&$$, &$1, &$3, '|')) YYERROR; } | scalar '^' scalar { if (!scalar_op(&$$, &$1, &$3, '^')) YYERROR; } | scalar EVAL_POW scalar { if (!scalar_op(&$$, &$1, &$3, EVAL_POW)) YYERROR; } | scalar EVAL_SHL scalar { if (!scalar_op(&$$, &$1, &$3, EVAL_SHL)) YYERROR; } | scalar EVAL_SHR scalar { if (!scalar_op(&$$, &$1, &$3, EVAL_SHR)) YYERROR; } | scalar EVAL_EQ scalar { if (!scalar_op(&$$, &$1, &$3, EVAL_EQ)) YYERROR; } | scalar EVAL_NE scalar { if (!scalar_op(&$$, &$1, &$3, EVAL_NE)) YYERROR; } | scalar EVAL_GT scalar { if (!scalar_op(&$$, &$1, &$3, EVAL_GT)) YYERROR; } | scalar EVAL_GE scalar { if (!scalar_op(&$$, &$1, &$3, EVAL_GE)) YYERROR; } | scalar EVAL_LT scalar { if (!scalar_op(&$$, &$1, &$3, EVAL_LT)) YYERROR; } | scalar EVAL_LE scalar { if (!scalar_op(&$$, &$1, &$3, EVAL_LE)) YYERROR; } | scalar EVAL_LAND scalar { if (!scalar_op(&$$, &$1, &$3, EVAL_LAND)) YYERROR; } | scalar EVAL_LXOR scalar { if (!scalar_op(&$$, &$1, &$3, EVAL_LXOR)) YYERROR; } | scalar EVAL_LOR scalar { if (!scalar_op(&$$, &$1, &$3, EVAL_LOR)) YYERROR; } | scalar EVAL_STR_EQ scalar { scalar_strop(&$$, &$1, &$3, EVAL_STR_EQ); } | scalar EVAL_STR_NE scalar { scalar_strop(&$$, &$1, &$3, EVAL_STR_NE); } | scalar EVAL_STR_GT scalar { scalar_strop(&$$, &$1, &$3, EVAL_STR_GT); } | scalar EVAL_STR_GE scalar { scalar_strop(&$$, &$1, &$3, EVAL_STR_GE); } | scalar EVAL_STR_LT scalar { scalar_strop(&$$, &$1, &$3, EVAL_STR_LT); } | scalar EVAL_STR_LE scalar { scalar_strop(&$$, &$1, &$3, EVAL_STR_LE); } | '-' scalar %prec NEG { scalar_negset(&$$, &$2); } | '~' scalar { scalar_notset(&$$, &$2); } | '!' scalar { scalar_lnotset(&$$, &$2); } | '(' scalar ')' { $$ = $2; } | scalar '?' scalar ':' scalar { scalar_miniif(&$$, &$1, &$3, &$5); } | scalar '.' scalar { scalar_concat(&$$, &$1, &$3); scalar_destroy(&$1); scalar_destroy(&$3); } | identifier '(' scalarlist_or_null ')' { int r=evalfunc(&$$, $1, &$3); scalarlist_destroy(&$3); free($1); if (!r) YYERROR; } | identifier { int r=evalsymbol(&$$, $1); free($1); if (!r) YYERROR; } ; scalarlist_or_null: /* empty */ { eval_scalarlist s; s.count=0; s.scalars=NULL; $$ = s; } | scalarlist { $$ = $1; } ; scalarlist: scalar { scalarlist_set(&$$, &$1); } | scalarlist ',' scalarlist { scalarlist_concat(&$$, &$1, &$3); scalarlist_destroy_gentle(&$1); scalarlist_destroy_gentle(&$3); } ; identifier: EVAL_IDENT { $$ = $1; } ; %% ht-2.0.22/htne.cc0000644000175000001440000003452710615341620010403 00000000000000/* * HT Editor * htne.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "log.h" #include "endianess.h" #include "htiobox.h" #include "htne.h" #include "htneent.h" #include "htnehead.h" #include "htneimp.h" #include "htnenms.h" #include "htneobj.h" #include "htneimg.h" #include "htnewexe.h" #include "nestruct.h" #include "tools.h" #include #include static format_viewer_if *htne_ifs[] = { &htneheader_if, &htnesegments_if, &htneimports_if, &htneentrypoints_if, &htnenames_if, &htneimage_if, 0 }; ne_import_rec::ne_import_rec(uint a, uint mod, bool b, uint i) { addr = a; module = mod; byname = b; ord = i; } int ne_import_rec::compareTo(const Object *obj) const { ne_import_rec *b=(ne_import_rec*)obj; if (module == b->module) { if (byname == b->byname) { if (byname) { return name_ofs - b->name_ofs; } else { return ord - b->ord; } } return byname - b->byname; } return module - b->module; } static ht_view *htne_init(Bounds *b, File *file, ht_format_group *format_group) { byte nemagic[2]; FileOfs h = get_newexe_header_ofs(file); file->seek(h); file->read(nemagic, 2); if ((nemagic[0]!=NE_MAGIC0) || (nemagic[1]!=NE_MAGIC1)) return 0; ht_ne *g=new ht_ne(); g->init(b, file, htne_ifs, format_group, h); return g; } format_viewer_if htne_if = { htne_init, 0 }; void ht_ne::init(Bounds *b, File *f, format_viewer_if **ifs, ht_format_group *format_group, FileOfs h) { ht_format_group::init(b, VO_BROWSABLE | VO_SELECTABLE | VO_RESIZE, DESC_NE, f, false, true, 0, format_group); VIEW_DEBUG_NAME("ht_ne"); String fn; LOG("%y: NE: found header at 0x%08qx", &file->getFilename(fn), h); ht_ne_shared_data *ne_shared = ht_malloc(sizeof (ht_ne_shared_data)); shared_data = ne_shared; ne_shared->fake_segment = 0; ne_shared->hdr_ofs = h; ne_shared->entrypoints = NULL; ne_shared->imports = NULL; ne_shared->v_image = NULL; file->seek(h); file->readx(&ne_shared->hdr, sizeof ne_shared->hdr); createHostStruct(&ne_shared->hdr, NE_HEADER_struct, little_endian); /* read segment descriptors */ ne_shared->segments.segment_count = ne_shared->hdr.cseg; ne_shared->segments.segments = ht_malloc(sizeof (NE_SEGMENT) * ne_shared->segments.segment_count); bool reloc_needed = false; NE_SEGMENT *s = ne_shared->segments.segments; file->seek(h+ne_shared->hdr.segtab); for (uint32 i = 0; i < ne_shared->segments.segment_count; i++) { file->readx(s, sizeof *s); createHostStruct(s, NE_SEGMENT_struct, little_endian); if (s->flags & NE_HASRELOC) reloc_needed = true; s++; } /* read entrypoint descriptors */ FileOfs o = h + ne_shared->hdr.enttab; NE_ENTRYPOINT_HEADER e; file->seek(o); file->readx(&e, sizeof e); createHostStruct(&e, NE_ENTRYPOINT_HEADER_struct, little_endian); o += sizeof e; Array *ep = new Array(true); uint32 index = 1; while (ohdr.enttab+ne_shared->hdr.cbenttab) { for (int i=0; ireadx(&me, sizeof me); createHostStruct(&me, NE_ENTRYPOINT_MOVABLE_struct, little_endian); ep->forceSetByIdx(index, new ht_ne_entrypoint(index, me.seg, me.offset, 0)); } else { o+=sizeof (NE_ENTRYPOINT_FIXED); NE_ENTRYPOINT_FIXED fe; file->seek(o); file->readx(&fe, sizeof fe); createHostStruct(&fe, NE_ENTRYPOINT_FIXED_struct, little_endian); ep->forceSetByIdx(index, new ht_ne_entrypoint(index, e.seg_index, fe.offset, 0)); } index++; } file->seek(o); file->readx(&e, sizeof e); createHostStruct(&e, NE_ENTRYPOINT_HEADER_struct, little_endian); o += sizeof e; } ne_shared->entrypoints = ep; /* read module names */ o = h + ne_shared->hdr.modtab; FileOfs no = h + ne_shared->hdr.imptab; file->seek(o); ne_shared->modnames_count = ne_shared->hdr.cmod; ne_shared->modnames = ht_malloc(sizeof *ne_shared->modnames * ne_shared->modnames_count); for (uint i=0; ihdr.cmod; i++) { char buf[2]; file->seek(o+i*2); if (file->read(buf, 2) != 2) break; int w = createHostInt(buf, 2, little_endian); file->seek(no+w); ne_shared->modnames[i] = file->readstrp(); } /* do relocations */ if (reloc_needed) { ht_ne_reloc_file *rf = new ht_ne_reloc_file(file, false, (ht_ne_shared_data*)shared_data); if (relocate(rf)) { rf->finalize(); file = rf; own_file = true; LOG("%y: NE: relocations present, relocation simulation layer enabled", &fn); } else { LOG_EX(LOG_WARN, "%y: NE relocations seem to be corrupted.", &fn); errorbox("%y: NE relocations seem to be corrupted.", &fn); delete rf; } } ht_format_group::init_ifs(ifs); } void ht_ne::done() { ht_format_group::done(); ht_ne_shared_data *ne_shared = (ht_ne_shared_data*)shared_data; if (ne_shared->segments.segments) { free(ne_shared->segments.segments); } if (ne_shared->modnames) { for (uint i=0; imodnames_count; i++) { free(ne_shared->modnames[i]); } free(ne_shared->modnames); } delete ne_shared->entrypoints; delete ne_shared->imports; free(shared_data); } void ht_ne::loc_enum_start() { // loc_enum=true; } bool ht_ne::loc_enum_next(ht_format_loc *loc) { #if 0 ht_ne_shared_data *sh=(ht_ne_shared_data*)shared_data; if (loc_enum) { loc->name="ne"; loc->start=sh->hdr_ofs; loc->length=file->get_size()-loc->start; /* FIXME: ENOTOK */ loc_enum=false; return true; } #endif return false; } bool ht_ne::create_fake_segment() { ht_ne_shared_data *ne_shared = (ht_ne_shared_data*)shared_data; uint i = ne_shared->hdr.cseg; NE_SEGMENT *newsegs = ht_malloc(sizeof *newsegs * (ne_shared->segments.segment_count+1)); memcpy(newsegs, ne_shared->segments.segments, sizeof *newsegs * ne_shared->segments.segment_count); ne_shared->segments.segment_count++; free(ne_shared->segments.segments); ne_shared->segments.segments = newsegs; newsegs[i].offset = 0; newsegs[i].size = 0; newsegs[i].flags = NE_DATA; newsegs[i].minalloc = 0; // = 64k ne_shared->fake_segment = i; return true; } bool ht_ne::relocate(ht_reloc_file *rf) { ht_ne_shared_data *ne_shared = (ht_ne_shared_data*)shared_data; if (!create_fake_segment()) return false; AVLTree *imports = new AVLTree(true); int fake_entry_count = 0; /* if selfload only relocate first segment. Is this "The Right Thing" ? */ /* Works for me though. */ uint c = (ne_shared->hdr.flags & NE_FLAGS_SELFLOAD) ? 1 : ne_shared->segments.segment_count; for (uint32 i = 0; i < c; i++) { if (ne_shared->segments.segments[i].flags & NE_HASRELOC) { FileOfs seg_ofs = NE_get_seg_ofs(ne_shared, i); FileOfs f = seg_ofs + NE_get_seg_psize(ne_shared, i); char buf[2]; file->seek(f); file->readx(buf, 2); f += 2; int c = createHostInt(buf, 2, little_endian); for (int j = 0; j < c; j++) { NE_RELOC_HEADER reloc; file->seek(f); file->readx(&reloc, sizeof reloc); createHostStruct(&reloc, NE_RELOC_HEADER_struct, little_endian); f += sizeof reloc; switch (reloc.flags & NE_RF_RT_MASK) { case NE_RF_INTERNAL: { NE_RELOC_INTERNAL sreloc; file->readx(&sreloc, sizeof sreloc); createHostStruct(&sreloc, NE_RELOC_INTERNAL_struct, little_endian); f += sizeof sreloc; if (sreloc.seg == 0xff) { // ne_shared->entrypoint->; if (!relocate_single(rf, i, seg_ofs + reloc.src_ofs, reloc.type, reloc.flags, 0xf1, 0)) return false; } else { if (!relocate_single(rf, i, seg_ofs + reloc.src_ofs, reloc.type, reloc.flags, sreloc.seg, sreloc.ofs)) return false; } break; } case NE_RF_IMPORT_ORD: { NE_RELOC_IMPORT sreloc; file->readx(&sreloc, sizeof sreloc); createHostStruct(&sreloc, NE_RELOC_IMPORT_struct, little_endian); f += sizeof sreloc; if (imports->insert(new ne_import_rec(fake_entry_count, sreloc.module, false, sreloc.ord))) { // if (!relocate_single(rf, i, seg_ofs + reloc.src_ofs, reloc.type, reloc.flags, 0xf2, sreloc.ord)) return false; if (!relocate_single(rf, i, seg_ofs + reloc.src_ofs, reloc.type, reloc.flags, ne_shared->fake_segment+1, fake_entry_count)) return false; fake_entry_count++; } break; } case NE_RF_IMPORT_NAME: { NE_RELOC_IMPORT sreloc; file->readx(&sreloc, sizeof sreloc); createHostStruct(&sreloc, NE_RELOC_IMPORT_struct, little_endian); f += sizeof sreloc; if (imports->insert(new ne_import_rec(fake_entry_count, sreloc.module, true, sreloc.name_ofs))) { // if (!relocate_single(rf, i, seg_ofs + reloc.src_ofs, reloc.type, reloc.flags, 0xf3, sreloc.name_ofs)) return false; if (!relocate_single(rf, i, seg_ofs + reloc.src_ofs, reloc.type, reloc.flags, ne_shared->fake_segment+1, fake_entry_count)) return false; fake_entry_count++; } break; } case NE_RF_OSFIXUP: { NE_RELOC_FIXUP sreloc; file->readx(&sreloc, sizeof sreloc); createHostStruct(&sreloc, NE_RELOC_FIXUP_struct, little_endian); f += sizeof sreloc; if (!relocate_single(rf, i, seg_ofs + reloc.src_ofs, reloc.type, reloc.flags, 0xdead, 0xcafebabe)) return false; break; } } } } } ne_shared->imports = imports; return true; } bool ht_ne::relocate_single(ht_reloc_file *rf, uint seg, FileOfs ofs, uint type, uint flags, uint16 value_seg, uint16 value_ofs) { ht_ne_shared_data *ne_shared = (ht_ne_shared_data*)shared_data; while (1) { if (flags & NE_RF_ADD) break; switch (type & NE_RT_MASK) { case NE_RT_SEG16: case NE_RT_PTR32: case NE_RT_OFS16: case NE_RT_PTR48: case NE_RT_OFS32: break; case NE_RT_OFS8: /* FIXME: we want to read a uint16 (offset) out of the file, but we can't because there's only one relocated byte. Maybe I dont understand NE relocs completely. */ default: /* unknown relocation record */ return false; } rf->insert_reloc(ofs, new ht_ne_reloc_entry(type, flags & NE_RF_ADD, value_seg, value_ofs)); char buf[2]; file->seek(ofs); file->readx(buf, 2); uint16 r = createHostInt(buf, 2, little_endian); if (r == 0xffff) break; NEAddress a = NE_MAKE_ADDR(seg+1, r); if (!NE_addr_to_ofs(ne_shared, a, &ofs)) { return false; } } return true; } /* * CLASS ht_ne_entrypoint */ ht_ne_entrypoint::ht_ne_entrypoint(uint Ordinal, uint Seg, uint Offset, uint Flags) { ordinal = Ordinal; seg = Seg; offset = Offset; flags = Flags; name = NULL; } ht_ne_entrypoint::~ht_ne_entrypoint() { free(name); } /* * CLASS ht_ne_reloc_entry */ ht_ne_reloc_entry::ht_ne_reloc_entry(uint Mode, bool Add, uint16 Seg, uint16 Ofs) { mode = Mode; add = Add; seg = Seg; ofs = Ofs; } /* * CLASS ht_ne_reloc_file */ ht_ne_reloc_file::ht_ne_reloc_file(File *s, bool os, ht_ne_shared_data *d) : ht_reloc_file(s, os) { data = d; } void ht_ne_reloc_file::reloc_apply(Object *reloc, byte *data) { ht_ne_reloc_entry *e = (ht_ne_reloc_entry*)reloc; switch (e->mode & NE_RT_MASK) { case NE_RT_OFS8: createForeignInt(data, e->ofs, 1, little_endian); break; case NE_RT_SEG16: createForeignInt(data, e->seg, 2, little_endian); break; case NE_RT_OFS16: createForeignInt(data, e->ofs, 2, little_endian); break; case NE_RT_PTR32: createForeignInt(data, e->ofs, 2, little_endian); createForeignInt(data+2, e->seg, 2, little_endian); break; case NE_RT_OFS32: createForeignInt(data, e->ofs, 4, little_endian); break; case NE_RT_PTR48: createForeignInt(data, e->ofs, 4, little_endian); createForeignInt(data+4, e->seg, 2, little_endian); break; } } bool ht_ne_reloc_file::reloc_unapply(Object *reloc, byte *data) { return false; // ht_ne_reloc_entry *e = (ht_ne_reloc_entry*)reloc; } /* * */ FileOfs NE_get_seg_ofs(ht_ne_shared_data *NE_shared, uint i) { return (NE_shared->segments.segments[i].offset << NE_shared->hdr.align); } NEAddress NE_get_seg_addr(ht_ne_shared_data *NE_shared, uint i) { return NE_MAKE_ADDR(i+1, 0); } uint NE_get_seg_psize(ht_ne_shared_data *NE_shared, uint i) { return (NE_shared->segments.segments[i].size || !NE_shared->segments.segments[i].offset) ? NE_shared->segments.segments[i].size : 0x10000; // return NE_shared->segments.segments[i].size; } uint NE_get_seg_vsize(ht_ne_shared_data *NE_shared, uint i) { return NE_shared->segments.segments[i].minalloc ? NE_shared->segments.segments[i].minalloc : 0x10000; // return NE_shared->segments.segments[i].minalloc; } bool NE_addr_to_segment(ht_ne_shared_data *NE_shared, NEAddress Addr, int *segment) { for (uint i = 0; i < NE_shared->segments.segment_count; i++) { NEAddress base = NE_get_seg_addr(NE_shared, i); uint evsize = MAX(NE_get_seg_vsize(NE_shared, i), NE_get_seg_psize(NE_shared, i)); if ((Addr >= base) && (Addr < base + evsize)) { *segment = i; return true; } } return false; } bool NE_addr_is_physical(ht_ne_shared_data *NE_shared, NEAddress Addr) { for (uint i = 0; i < NE_shared->segments.segment_count; i++) { NEAddress base = NE_get_seg_addr(NE_shared, i); uint epsize = MIN(NE_get_seg_vsize(NE_shared, i), NE_get_seg_psize(NE_shared, i)); if ((Addr >= base) && (Addr < base + epsize)) return true; } return false; } bool NE_addr_to_ofs(ht_ne_shared_data *NE_shared, NEAddress Addr, FileOfs *ofs) { for (uint i = 0; i < NE_shared->segments.segment_count; i++) { NEAddress base = NE_get_seg_addr(NE_shared, i); uint epsize = MIN(NE_get_seg_vsize(NE_shared, i), NE_get_seg_psize(NE_shared, i)); if ((Addr >= base) && (Addr < base + epsize)) { *ofs = NE_get_seg_ofs(NE_shared, i) + (Addr - base); return true; } } return false; } bool NE_ofs_to_addr(ht_ne_shared_data *NE_shared, FileOfs ofs, NEAddress *Addr) { for (uint i = 0; i < NE_shared->segments.segment_count; i++) { FileOfs sofs = NE_get_seg_ofs(NE_shared, i); if ((ofs >= sofs) && (ofs < sofs + NE_get_seg_psize(NE_shared, i))) { *Addr = NE_get_seg_addr(NE_shared, i) + (ofs - sofs); return true; } } return false; } ht-2.0.22/htcfg.h0000644000175000001440000000476110725334042010401 00000000000000/* * HT Editor * htcfg.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTCFG_H__ #define __HTCFG_H__ #include "data.h" #include "stream.h" #if defined(WIN32) || defined(__WIN32__) || defined(MSDOS) || defined(DJGPP) #define SYSTEM_CONFIG_FILE_NAME "ht2.cfg" #else #define SYSTEM_CONFIG_FILE_NAME ".htcfg2" #endif enum loadstore_result { LS_OK, LS_ERROR_NOT_FOUND, LS_ERROR_READ, LS_ERROR_WRITE, LS_ERROR_MAGIC, LS_ERROR_VERSION, // sets error_info to version LS_ERROR_FORMAT, LS_ERROR_CORRUPTED }; /* SYSTEM CONFIG FILE VERSION HISTORY * Version 2: HT 0.4.4 * Version 3: HT 0.4.5 * Version 4: HT 0.5.0 * Version 5: HT 0.6.0 * Version 6: HT 2.0beta */ #define ht_systemconfig_magic "HTCP" #define ht_systemconfig_fileversion 6 /* FILE CONFIG FILE VERSION HISTORY * Version 1: HT 0.5.0 * Version 2: HT 0.6.0 * Version 3: HT 0.7.0 * Version 4: HT 2.0beta */ #define ht_fileconfig_magic "HTCF" #define ht_fileconfig_fileversion 4 /* PROJECT CONFIG FILE VERSION HISTORY * Version 1: HT 0.7.0 * Version 2: HT 2.0beta */ #define ht_projectconfig_magic "HTPR" #define ht_projectconfig_fileversion 2 /**/ extern char *systemconfig_file; loadstore_result save_systemconfig(String &error_info); bool load_systemconfig(loadstore_result *result, int *error_info); typedef void (*load_fcfg_func)(ObjectStream &f, void *context); typedef void (*store_fcfg_func)(ObjectStream &f, void *context); loadstore_result save_fileconfig(const char *fileconfig_file, const char *magic, uint version, store_fcfg_func store_func, void *context, String &error_info); loadstore_result load_fileconfig(const char *fileconfig_file, const char *magic, uint version, load_fcfg_func load_func, void *context, String &error_info); /* * INIT */ extern bool ht_cfg_use_homedir; bool init_cfg(); /* * DONE */ void done_cfg(); #endif /* !__HTCFG_H__ */ ht-2.0.22/htnehead.h0000644000175000001440000000153010206756710011061 00000000000000/* * HT Editor * htnehead.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTNEHEAD_H__ #define __HTNEHEAD_H__ #include "formats.h" extern format_viewer_if htneheader_if; #endif /* !__HTNEHEAD_H__ */ ht-2.0.22/xexstruct.cc0000755000175000001440000000533610615345252011522 00000000000000/* * HT Editor * xexstruct.cc * * Copyright (C) 2006 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "endianess.h" #include "xexstruct.h" byte XEX_IMAGE_HEADER_struct[] = { STRUCT_ENDIAN_8, STRUCT_ENDIAN_8, STRUCT_ENDIAN_8, STRUCT_ENDIAN_8, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte XEX_IMAGE_HEADER_INFO_ENTRY_struct[] = { STRUCT_ENDIAN_8, STRUCT_ENDIAN_8, STRUCT_ENDIAN_8, STRUCT_ENDIAN_8, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte XEX_LOADER_INFO_HEADER_struct[] = { STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, 0 }; byte XEX_RAW_LOADER_ENTRY_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte XEX_FILE_HEADER_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_32, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_32, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64, STRUCT_ENDIAN_64, STRUCT_ENDIAN_32, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, }; ht-2.0.22/hteval.h0000644000175000001440000000174111010140016010544 00000000000000/* * HT Editor * hteval.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTEVAL_H__ #define __HTEVAL_H__ void eval_dialog(eval_func_handler func_handler, eval_symbol_handler symbol_handler, void *context); void dialog_eval_help(eval_func_handler func_handler, eval_symbol_handler symbol_handler, void *context); #endif /* __HTEVAL_H__ */ ht-2.0.22/machostruc.cc0000644000175000001440000002732110660124267011615 00000000000000/* * HT Editor * machostruc.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "machostruc.h" #include "endianess.h" byte MACHO_HEADER_struct[]= { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte MACHO_HEADER_64_struct[]= { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte MACHO_COMMAND_struct[]= { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte MACHO_SEGMENT_COMMAND_struct[]= { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte MACHO_SEGMENT_64_COMMAND_struct[]= { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte MACHO_SECTION_struct[]= { // sectname STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, // segname STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, // STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte MACHO_SECTION_64_struct[]= { // sectname STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, // segname STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, // STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte MACHO_THREAD_COMMAND_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, // .state not included ! 0 }; byte MACHO_PPC_THREAD_STATE_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte MACHO_PPC_64_THREAD_STATE_struct[] = { STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, 0 }; byte MACHO_ARM_THREAD_STATE_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte MACHO_I386_THREAD_STATE_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte MACHO_X86_64_THREAD_STATE_struct[] = { STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, 0 }; byte MACHO_SYMTAB_COMMAND_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte MACHO_SYMTAB_NLIST_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte MACHO_SYMTAB_NLIST_64_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, 0 }; ht-2.0.22/htxexhead.h0000755000175000001440000000213310615345251011264 00000000000000/* * HT Editor * htxexhead.h * * Copyright (C) 2006 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTXEXHEAD_H__ #define __HTXEXHEAD_H__ #include "formats.h" extern format_viewer_if htxexheader_if; /* * ht_xex_header_viewer */ class ht_xex_header_viewer: public ht_uformat_viewer { public: void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *group); /* overwritten */ virtual bool ref_sel(LINE_ID *id); }; #endif /* !__HTXEXHEAD_H__ */ ht-2.0.22/htelfhd.cc0000644000175000001440000002072312156430274011062 00000000000000/* * HT Editor * htelfhd.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "elfstruc.h" #include "atom.h" #include "htelf.h" #include "htelfhd.h" #include "httag.h" #include "formats.h" #include "snprintf.h" static ht_mask_ptable elfheader[]= { {"ident", 0}, {" magic", STATICTAG_EDIT_BYTE("00000000")" "STATICTAG_EDIT_BYTE("00000001")" "STATICTAG_EDIT_BYTE("00000002")" "STATICTAG_EDIT_BYTE("00000003")" = "STATICTAG_EDIT_CHAR("00000000") STATICTAG_EDIT_CHAR("00000001") STATICTAG_EDIT_CHAR("00000002") STATICTAG_EDIT_CHAR("00000003")}, {" class", STATICTAG_EDIT_BYTE("00000004")" ("STATICTAG_DESC_BYTE("00000004", ATOM_ELF_CLASS_STR)")"}, {" data", STATICTAG_EDIT_BYTE("00000005")" ("STATICTAG_DESC_BYTE("00000005", ATOM_ELF_DATA_STR)")"}, {" version", STATICTAG_EDIT_BYTE("00000006")}, {" OS ABI", STATICTAG_EDIT_BYTE("00000007")" ("STATICTAG_DESC_BYTE("00000007", ATOM_ELF_OS_ABI_STR)")"}, {" version", STATICTAG_EDIT_BYTE("00000008")}, {" reserved", STATICTAG_EDIT_BYTE("00000009")" "STATICTAG_EDIT_BYTE("0000000a")" "STATICTAG_EDIT_BYTE("0000000b")" "STATICTAG_EDIT_BYTE("0000000c")" "STATICTAG_EDIT_BYTE("0000000d")" "STATICTAG_EDIT_BYTE("0000000e")" "STATICTAG_EDIT_BYTE("0000000f")}, {0, 0} }; static ht_mask_ptable elfheader32[]= { {"type", STATICTAG_EDIT_WORD_VE("00000010")" ("STATICTAG_DESC_WORD_VE("00000010", ATOM_ELF_TYPE_STR)")"}, {"machine", STATICTAG_EDIT_WORD_VE("00000012")" ("STATICTAG_DESC_WORD_VE("00000012", ATOM_ELF_MACHINE_STR)")"}, {"version", STATICTAG_EDIT_DWORD_VE("00000014")}, {"entrypoint", STATICTAG_EDIT_DWORD_VE("00000018")}, {"program header offset", STATICTAG_EDIT_DWORD_VE("0000001c")}, {"section header offset", STATICTAG_EDIT_DWORD_VE("00000020")}, {"flags", STATICTAG_EDIT_DWORD_VE("00000024")}, {"elf header size", STATICTAG_EDIT_WORD_VE("00000028")}, {"program header entry size", STATICTAG_EDIT_WORD_VE("0000002a")}, {"program header count", STATICTAG_EDIT_WORD_VE("0000002c")}, {"section header entry size", STATICTAG_EDIT_WORD_VE("0000002e")}, {"section header count", STATICTAG_EDIT_WORD_VE("00000030")}, {"section header strtab section index", STATICTAG_EDIT_WORD_VE("00000032")}, {0, 0} }; static ht_mask_ptable elfheader64[]= { {"type", STATICTAG_EDIT_WORD_VE("00000010")" ("STATICTAG_DESC_WORD_VE("00000010", ATOM_ELF_TYPE_STR)")"}, {"machine", STATICTAG_EDIT_WORD_VE("00000012")" ("STATICTAG_DESC_WORD_VE("00000012", ATOM_ELF_MACHINE_STR)")"}, {"version", STATICTAG_EDIT_DWORD_VE("00000014")}, {"entrypoint", STATICTAG_EDIT_QWORD_VE("00000018")}, {"program header offset", STATICTAG_EDIT_QWORD_VE("00000020")}, {"section header offset", STATICTAG_EDIT_QWORD_VE("00000028")}, {"flags", STATICTAG_EDIT_DWORD_VE("00000030")}, {"elf header size", STATICTAG_EDIT_WORD_VE("00000034")}, {"program header entry size", STATICTAG_EDIT_WORD_VE("00000036")}, {"program header count", STATICTAG_EDIT_WORD_VE("00000038")}, {"section header entry size", STATICTAG_EDIT_WORD_VE("0000003a")}, {"section header count", STATICTAG_EDIT_WORD_VE("0000003c")}, {"section header strtab section index",STATICTAG_EDIT_WORD_VE("0000003e")}, {0, 0} }; static int_hash elf_class[] = { {ELFCLASSNONE, "invalid class type"}, {ELFCLASS32, "32-bit objects"}, {ELFCLASS64, "64-bit objects"}, {0, 0} }; static int_hash elf_data[] = { {ELFDATANONE, "invalid data encoding"}, {ELFDATA2LSB, "LSB encoding"}, {ELFDATA2MSB, "MSB encoding"}, {0, 0} }; static int_hash elf_os_abi[] = { {ELFOSABI_SYSV, "System V"}, {ELFOSABI_HPUX, "HP-UX"}, {ELFOSABI_LINUX, "Linux"}, {ELFOSABI_NETBSD, "NetBSD"}, {ELFOSABI_HURD, "GNU/Hurd"}, {ELFOSABI_86OPEN, "86Open common IA32 ABI"}, {ELFOSABI_SOLARIS, "Solaris"}, {ELFOSABI_MONTEREY, "Monterey"}, {ELFOSABI_IRIX, "IRIX"}, {ELFOSABI_FREEBSD, "FreeBSD"}, {ELFOSABI_TRU64, "TRU64 UNIX"}, {ELFOSABI_MODESTO, "Novell Modesto"}, {ELFOSABI_OPENBSD, "OpenBSD"}, {ELFOSABI_ARM, "ARM"}, {ELFOSABI_STANDALONE, "standalone"}, {0, 0} }; static int_hash elf_type[] = { {ELF_ET_NONE, "no file type"}, {ELF_ET_REL, "relocatable file"}, {ELF_ET_EXEC, "executable file"}, {ELF_ET_DYN, "shared object file"}, {ELF_ET_CORE, "core file"}, {0, 0} }; static int_hash elf_machine[] = { {ELF_EM_NONE, "no machine"}, {ELF_EM_M32, "AT&T WE32100"}, {ELF_EM_SPARC, "SPARC"}, {ELF_EM_386, "Intel 80386"}, {ELF_EM_68K, "Motorola 68000"}, {ELF_EM_88K, "Motorola 88000"}, {ELF_EM_486, "Intel 80486"}, {ELF_EM_860, "Intel 80860"}, {ELF_EM_MIPS, "MIPS R3000 big-endian"}, {ELF_EM_S370, "IBM System/370"}, {ELF_EM_MIPS_RS4_BE, "MIPS R4000 big-endian"}, {ELF_EM_PARISC, "HPPA"}, {ELF_EM_VPP550, "Fujitsu VPP500"}, {ELF_EM_SPARC32PLUS, "Sun's \"v8plus\""}, {ELF_EM_960, "Intel 80960"}, {ELF_EM_PPC, "PowerPC"}, {ELF_EM_PPC64, "64-bit PowerPC"}, {ELF_EM_V800, "NEC V800 series"}, {ELF_EM_FR20, "Fujitsu FR20"}, {ELF_EM_RH32, "TRW RH32"}, {ELF_EM_MCORE, "Motorola M*Core"}, {ELF_EM_ARM, "ARM"}, {ELF_EM_OLD_ALPHA, "Digital Alpha"}, {ELF_EM_SH, "Hitachi SH"}, {ELF_EM_SPARCV9, "SPARC v9 64-bit"}, {ELF_EM_TRICORE, "Siemens Tricore embedded processor"}, {ELF_EM_ARC, "Argonaut RISC Core, Argonaut Technologies Inc."}, {ELF_EM_H8_300, "Hitachi H8/300"}, {ELF_EM_H8_300H, "Hitachi H8/300H"}, {ELF_EM_H8S, "Hitachi H8S"}, {ELF_EM_H8_500, "Hitachi H8/500"}, {ELF_EM_IA_64, "Intel IA-64 Processor"}, {ELF_EM_MIPS_X, "Stanford MIPS-X"}, {ELF_EM_COLDFIRE, "Motorola Coldfire"}, {ELF_EM_68HC12, "Motorola M68HC12"}, {ELF_EM_MMA, "Fujitsu Multimedia Accelerator"}, {ELF_EM_PCP, "Siemens PCP"}, {ELF_EM_NCPU, "Sony nCPU embedded RISC processor"}, {ELF_EM_NDR1, "Denso NDR1 microprocesspr"}, {ELF_EM_STARCORE, "Motorola Star*Core processor"}, {ELF_EM_ME16, "Toyota ME16 processor"}, {ELF_EM_ST100, "STMicroelectronics ST100 processor"}, {ELF_EM_TINYJ, "Advanced Logic Corp. TinyJ embedded processor"}, {ELF_EM_X86_64, "x86-64 (AMD Opteron)"}, {ELF_EM_PDSP, "Sony DSP Processor"}, {ELF_EM_PDP10, "Digital Equipment Corp. PDP-10"}, {ELF_EM_PDP11, "Digital Equipment Corp. PDP-11"}, {ELF_EM_FX66, "Siemens FX66 microcontroller"}, {ELF_EM_ST9PLUS, "STMicroelectronics ST9+ 8/16 bit microcontroller"}, {ELF_EM_ST7, "STMicroelectronics ST7 8-bit microcontroller"}, {ELF_EM_68HC16, "Motorola MC68HC16 Microcontroller"}, {ELF_EM_68HC11, "Motorola MC68HC11 Microcontroller"}, {ELF_EM_68HC08, "Motorola MC68HC08 Microcontroller"}, {ELF_EM_68HC05, "Motorola MC68HC05 Microcontroller"}, {ELF_EM_SVX, "Silicon Graphics SVx"}, {ELF_EM_ST19, "STMicroelectronics ST19 8-bit microcontroller"}, {ELF_EM_VAX, "Digital VAX"}, {ELF_EM_AVR, "Atmel AVR 8-bit microcontroller"}, {ELF_EM_PJ, "picoJava"}, {ELF_EM_C166, "Infineon C16x/XC16x processor"}, {ELF_EM_ALPHA, "Alpha"}, {0, 0} }; ht_view *htelfheader_init(Bounds *b, File *file, ht_format_group *group) { ht_elf_shared_data *elf_shared=(ht_elf_shared_data *)group->get_shared_data(); ht_uformat_viewer *v = new ht_uformat_viewer(); v->init(b, DESC_ELF_HEADER, VC_EDIT, file, group); ht_mask_sub *m = new ht_mask_sub(); m->init(file, 0); char info[128]; ht_snprintf(info, sizeof info, "* ELF header at offset 0x%08qx", elf_shared->header_ofs); registerAtom(ATOM_ELF_CLASS, elf_class); registerAtom(ATOM_ELF_DATA, elf_data); registerAtom(ATOM_ELF_OS_ABI, elf_os_abi); registerAtom(ATOM_ELF_TYPE, elf_type); registerAtom(ATOM_ELF_MACHINE, elf_machine); m->add_mask(info); m->add_staticmask_ptable(elfheader, elf_shared->header_ofs, true); bool elf_bigendian = (elf_shared->ident.e_ident[ELF_EI_DATA] == ELFDATA2MSB); switch (elf_shared->ident.e_ident[ELF_EI_CLASS]) { case ELFCLASS32: m->add_staticmask_ptable(elfheader32, elf_shared->header_ofs, elf_bigendian); break; case ELFCLASS64: m->add_staticmask_ptable(elfheader64, elf_shared->header_ofs, elf_bigendian); break; } v->insertsub(m); return v; } format_viewer_if htelfheader_if = { htelfheader_init, 0 }; ht-2.0.22/htpef.cc0000644000175000001440000001644410615341623010554 00000000000000/* * HT Editor * htpef.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "pefstruc.h" #include "log.h" #include "htpef.h" #include "htpefhd.h" #include "htpefimp.h" #include "htpefimg.h" #include "endianess.h" #include "stream.h" #include "tools.h" #include format_viewer_if *htpef_ifs[] = { &htpefheader_if, &htpefimports_if, &htpefimage_if, 0 }; static ht_view *htpef_init(Bounds *b, File *file, ht_format_group *format_group) { byte id[12]; file->seek(0); file->read(&id, sizeof id); if (memcmp(id, "Joy!peff", 8)) return NULL; PEF_ARCH arch; if (memcmp(id+8, "pwpc", 4) == 0) { arch = PEFARCH_PowerPC; } else if (memcmp(id+8, "m68k", 4) == 0) { arch = PEFARCH_M68K; } else return NULL; ht_pef *g = new ht_pef(); g->init(b, file, htpef_ifs, format_group, 0); return g; } format_viewer_if htpef_if = { htpef_init, 0 }; /* * CLASS ht_pef */ void ht_pef::init(Bounds *b, File *f, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs) { ht_format_group::init(b, VO_SELECTABLE | VO_BROWSABLE | VO_RESIZE, DESC_PEF, f, false, true, 0, format_group); VIEW_DEBUG_NAME("ht_pef"); String fn; LOG("%y: PEF: found header at %08qx", &file->getFilename(fn), header_ofs); ht_pef_shared_data *pef_shared = ht_malloc(sizeof(ht_pef_shared_data)); memset(pef_shared, 0, sizeof *pef_shared); shared_data = pef_shared; /* always big-endian */ pef_shared->byte_order = big_endian; pef_shared->header_ofs = 0; pef_shared->imports.funcs = new Array(true); pef_shared->imports.funcs->init(); pef_shared->imports.libs = new Array(true); pef_shared->v_imports = NULL; /* read (container) header */ file->seek(header_ofs); file->read(&pef_shared->contHeader, sizeof pef_shared->contHeader); createHostStruct(&pef_shared->contHeader, PEF_CONTAINER_HEADER_struct, pef_shared->byte_order); if (memcmp(pef_shared->contHeader.architecture, "pwpc", 4) == 0) { pef_shared->arch = PEFARCH_PowerPC; } else if (memcmp(pef_shared->contHeader.architecture, "m68k", 4) == 0) { pef_shared->arch = PEFARCH_M68K; } else return; /* read section headers */ pef_shared->sheaders.count = pef_shared->contHeader.sectionCount; if (pef_shared->sheaders.count) { pef_shared->sheaders.sheaders = ht_malloc(pef_shared->sheaders.count*sizeof (PEF_SECTION_HEADER)); for (uint i=0; isheaders.count; i++) { file->read(&pef_shared->sheaders.sheaders[i], sizeof pef_shared->sheaders.sheaders[i]); createHostStruct(&pef_shared->sheaders.sheaders[i], PEF_SECTION_HEADER_struct, pef_shared->byte_order); // FIXME: hack pef_shared->sheaders.sheaders[i].defaultAddress = i*0x100000; if (!pef_shared->loader_info_header_ofs && pef_shared->sheaders.sheaders[i].sectionKind == PEF_SK_Loader) { pef_shared->loader_info_header_ofs = pef_shared->sheaders.sheaders[i].containerOffset; } } } if (pef_shared->loader_info_header_ofs) { file->seek(pef_shared->loader_info_header_ofs); file->read(&pef_shared->loader_info_header, sizeof pef_shared->loader_info_header); createHostStruct(&pef_shared->loader_info_header, PEF_LOADER_INFO_HEADER_struct, pef_shared->byte_order); } /* init ifs */ ht_format_group::init_ifs(ifs); } void ht_pef::done() { ht_format_group::done(); ht_pef_shared_data *pef_shared = (ht_pef_shared_data*)shared_data; delete pef_shared->imports.funcs; delete pef_shared->imports.libs; free(shared_data); } #define RELOC_BASE 0x10000000 #define RELOC_STEPPING 0x100000 #define RELOC_LIMIT 0xffffffff /*static uint32 pef_invent_reloc_address(uint si, PEF_SECTION_HEADER *s, uint scount) { elf32_addr a=RELOC_BASE; while (a=s[i].sh_addr) && (asectionKind <= 1) || (s->sectionKind == 3) || (s->sectionKind == 6); } bool pef_valid_section(PEF_SECTION_HEADER *s) { return (s->sectionKind <= 3) || (s->sectionKind == 6); } bool pef_addr_to_ofs(pef_section_headers *section_headers, PEFAddress addr, uint32 *ofs) { PEF_SECTION_HEADER *s = section_headers->sheaders; for (uint i=0; i < section_headers->count; i++) { if ((pef_phys_and_mem_section(s)) && (addr.a32 >= s->defaultAddress) && (addr.a32 < s->defaultAddress+s->packedSize)) { *ofs = addr.a32 - s->defaultAddress + s->containerOffset; return true; } s++; } return false; } bool pef_addr_to_section(pef_section_headers *section_headers, PEFAddress addr, int *section) { PEF_SECTION_HEADER *s = section_headers->sheaders; for (uint i = 0; i < section_headers->count; i++) { if ((pef_valid_section(s)) && (addr.a32 >= s->defaultAddress) && (addr.a32 < s->defaultAddress + s->totalSize)) { *section = i; return true; } s++; } return false; } bool pef_addr_is_valid(pef_section_headers *section_headers, PEFAddress addr) { PEF_SECTION_HEADER *s = section_headers->sheaders; for (uint i=0; icount; i++) { if ((pef_valid_section(s)) && (addr.a32 >= s->defaultAddress) && (addr.a32 < s->defaultAddress + s->totalSize)) { return true; } s++; } return false; } /* * offset conversion routines */ bool pef_ofs_to_addr(pef_section_headers *section_headers, uint32 ofs, PEFAddress *addr) { PEF_SECTION_HEADER *s = section_headers->sheaders; for (uint i = 0; i < section_headers->count; i++) { if ((pef_phys_and_mem_section(s)) && (ofs>=s->containerOffset) && (ofscontainerOffset+s->packedSize)) { addr->a32 = ofs - s->containerOffset + s->defaultAddress; return true; } s++; } return false; } bool pef_ofs_to_section(pef_section_headers *section_headers, uint32 ofs, int *section) { PEF_SECTION_HEADER *s=section_headers->sheaders; for (uint i=0; icount; i++) { if ((pef_valid_section(s)) && (ofs >= s->containerOffset) && (ofscontainerOffset+s->packedSize)) { *section = i; return true; } s++; } return false; } /* * ht_pef_reloc_entry */ #include "relfile.h" class ht_pef_reloc_entry: public Object { public: // ht_elf32_reloc_entry(uint symtabidx, elf32_addr offset, uint type, uint symbolidx, elf32_addr addend, ht_elf_shared_data *data, File *file); }; /* * ht_pef_reloc_file */ class ht_pef_reloc_file: public ht_reloc_file { protected: ht_pef_shared_data *data; /* overwritten */ virtual void reloc_apply(Object *reloc, byte *data); virtual bool reloc_unapply(Object *reloc, byte *data); public: ht_pef_reloc_file(File *s, bool own_s, ht_pef_shared_data *d) :ht_reloc_file(s, own_s) { data = d; } }; ht-2.0.22/missing0000755000175000017500000002634411637714046010552 00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2009-04-28.21; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; tar*) if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then exit 1 fi ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; tar*) shift # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case $firstarg in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case $firstarg in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: ht-2.0.22/htobj.cc0000644000175000001440000010662310763576160010565 00000000000000/* * HT Editor * htobj.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "atom.h" #include "cmds.h" #include "htapp.h" #include "htctrl.h" #include "htdebug.h" #include "keyb.h" #include "htmenu.h" #include "htobj.h" #include "htpal.h" #include "htreg.h" #include "strtools.h" #include "snprintf.h" #include "store.h" #include "tools.h" #include #include #include #define ATOM_HT_VIEW MAGIC32("OBJ\0") #define ATOM_HT_GROUP MAGIC32("OBJ\1") #define ATOM_HT_XGROUP MAGIC32("OBJ\2") #define ATOM_HT_WINDOW MAGIC32("OBJ\3") #define ATOM_HT_FRAME MAGIC32("OBJ\4") #define ATOM_HT_SCROLLBAR MAGIC32("OBJ\5") #define DEFAULT_VIEW_MIN_WIDTH 25 #define DEFAULT_VIEW_MIN_HEIGHT 6 static void bounds_and(Bounds *a, Bounds *b) { if (b->x > a->x) { a->w -= b->x-a->x; a->x = b->x; } if (b->y > a->y) { a->h -= b->y-a->y; a->y = b->y; } if (a->x + a->w > b->x+b->w) a->w -= a->x + a->w - b->x - b->w; if (a->y + a->h > b->y+b->h) a->h -= a->y + a->h - b->y - b->h; if (a->w < 0) a->w = 0; if (a->h < 0) a->h = 0; } void clearmsg(htmsg *msg) { msg->msg = msg_empty; msg->type = mt_empty; } /* * CLASS ht_text */ void ht_text::settext(const char *text) { } /* * CLASS ht_view */ void ht_view::init(Bounds *b, int o, const char *d) { Object::init(); VIEW_DEBUG_NAME("ht_view"); desc = ht_strdup(d); group = NULL; focused = false; browse_idx = 0; view_is_dirty = true; size = *b; prev = NULL; next = NULL; setoptions(o); buf = NULL; enabled = true; growmode = MK_GM(GMH_LEFT, GMV_TOP); // Bounds rel(0, 0, b->w, b->h); if (options & VO_OWNBUFFER) { buf = new BufferedRDisplay(size); } else { buf = new SystemRDisplay(screen, size); } g_hdist = 0; g_vdist = 0; setbounds(b); pal.data = NULL; pal.size = 0; pal_class = defaultpaletteclass(); pal_name = defaultpalette(); reloadpalette(); } void ht_view::done() { free(desc); free(pal.data); delete buf; Object::done(); } int ht_view::aclone() { return (group && group->isaclone(this)); } #if 0 int ht_view::buf_lprint(int aX, int aY, int c, int l, const char *text, Codepage cp) { if (y+aY >= vsize.y && y+aY < vsize.y+vsize.h) { if (x+aX+l > vsize.x+vsize.w) l = vsize.x+vsize.w-size.x-aX; if (x+aX-vsize.x < 0) { int kqx = -x-aX+vsize.x; for (int i=0; i < kqx; i++) { if (!*text) return 0; text++; aX++; l--; } } return (l > 0) ? buf->b_lprint(x+aX, y+aY, c, l, text) : 0; } return 0; } int ht_view::buf_lprintw(int aX, int aY, int c, int l, const AbstractChar *text, Codepage cp) { if (size.y+aY >= vsize.y && size.y+aY < vsize.y+vsize.h)) { if (x+aX+l > vsize.x+vsize.w) l=vsize.x+vsize.w-x-aX; if (x+aX-vsize.x < 0) { int kqx = -x-aX+vsize.x; for (int i=0; i < kqx; i++) { if (!*text) return 0; text++; x++; l--; } } return (l>0) ? buf->lprintw(size.x+x, size.y+y, c, l, text) : 0; } return 0; } int ht_view::buf_print(int x, int y, int c, const char *text, Codepage cp) { if ((size.y+y>=vsize.y) && (size.y+y0) ? buf->b_lprint(size.x+x, size.y+y, c, l, text) : 0; } return 0; } void ht_view::buf_printchar(int x, int y, int c, int ch, Codepage cp) { if (pointvisible(size.x+x, size.y+y)) buf->b_printchar(size.x+x, size.y+y, c, ch, cp); } int ht_view::buf_printf(int x, int y, int c, CodePage cp, const char *format, ...) { char buf[256]; /* secure */ va_list arg; va_start(arg, format); ht_vsnprintf(buf, sizeof buf, format, arg); va_end(arg); return buf_print(x, y, c, buf, cp); } int ht_view::buf_printw(int x, int y, int c, const AbstractChar *text, Codepage cp) { if ((size.y+y>=vsize.y) && (size.y+y0) ? buf->b_lprintw(size.x+x, size.y+y, c, l, text) : 0; } return 0; } #endif int ht_view::childcount() const { return 1; } void ht_view::cleanview() { view_is_dirty=0; } void ht_view::clear(int c) { buf->fill(0, 0, size.w, size.h, c, ' '); } void ht_view::clipbounds(Bounds *b) { Bounds c; getbounds(&c); bounds_and(b, &c); bounds_and(b, &vsize); } void ht_view::config_changed() { reloadpalette(); dirtyview(); } int ht_view::countselectables() { return (options & VO_SELECTABLE) ? 1 : 0; } int ht_view::datasize() { return 0; } const char *ht_view::defaultpalette() { return palkey_generic_window_default; } const char *ht_view::defaultpaletteclass() { return palclasskey_generic; } void ht_view::dirtyview() { view_is_dirty=1; } void ht_view::disable() { enabled=0; } void ht_view::disable_buffering() { if (options & VO_OWNBUFFER) { delete buf; // Bounds rel(0, 0, size.w, size.h); buf = new SystemRDisplay(screen, size); setoptions(options & ~VO_OWNBUFFER); } } void ht_view::draw() { } void ht_view::enable() { enabled=1; } void ht_view::enable_buffering() { if (!(options & VO_OWNBUFFER)) { delete buf; // Bounds rel(0, 0, size.w, size.h); buf = new BufferedRDisplay(size); setoptions(options | VO_OWNBUFFER); } } static bool view_line_exposed(ht_view *v, int y, int x1, int x2) { ht_group *g=v->group; while (g) { if (y >= g->size.y && y < g->size.y+g->size.h) { if (x1 < g->size.x) x1 = g->size.x; if (x2 > g->size.x + g->size.w) x2 = g->size.x+g->size.w; ht_view *n = g->first; while (n && n!=v) n=n->next; if (n) { n=n->next; if (n) while (n) { if (!(n->options & VO_TRANSPARENT_CHARS)) { if ((y>=n->size.y) && (ysize.y+n->size.h)) { if (n->size.x<=x1) { if (n->size.x+n->size.w>=x2) { return 0; } else if (n->size.x+n->size.w>x1) { x1=n->size.x+n->size.w; } } else if (n->size.x<=x2) { if (n->size.x+n->size.wsize.x)) return 0; x1=n->size.x+n->size.w; } else { x2=n->size.x; } } } } n=n->next; } } } else break; v=g; g=g->group; } return 1; } int ht_view::enum_start() { return 0; } ht_view *ht_view::enum_next(int *handle) { return 0; } bool ht_view::exposed() { #if 1 for (int y=0; y < size.h; y++) { if (view_line_exposed(this, size.y+y, size.x, size.x+size.w)) return 1; } return 0; #else return 1; #endif } void ht_view::fill(int x, int y, int w, int h, int c, char chr, Codepage cp) { Bounds b(x+size.x, y+size.y, w, h); bounds_and(&b, &vsize); buf->fill(b.x-size.x, b.y-size.y, b.w, b.h, c, chr, cp); } bool ht_view::focus(ht_view *view) { if (view == this) { if (!focused) receivefocus(); return true; } return false; } void ht_view::getbounds(Bounds *b) { *b = size; } vcp ht_view::getcolor(uint index) { return getcolorv(&pal, index); } void ht_view::getminbounds(int *width, int *height) { *width = DEFAULT_VIEW_MIN_WIDTH; *height = DEFAULT_VIEW_MIN_HEIGHT; } struct databufdup_s { MemMapFile *f; ObjectStreamNative *s; }; void ht_view::databuf_free(void *handle) { databufdup_s *s = (databufdup_s*)handle; delete s->s; delete s->f; delete s; } void *ht_view::databuf_get(void *buf, int bufsize) { MemMapFile *f = new MemMapFile(buf, bufsize); ObjectStreamNative *s = new ObjectStreamNative(f, false, true); getdata(*s); databufdup_s *q = new databufdup_s; q->f = f; q->s = s; return q; } void ht_view::databuf_set(void *buf, int bufsize) { ConstMemMapFile f(buf, bufsize); ObjectStreamNative s(&f, false, true); setdata(s); } void ht_view::getdata(ObjectStream &s) { } ht_view *ht_view::getfirstchild() { return 0; } uint ht_view::getnumber() { return 0; } const char *ht_view::getpalette() { return pal_name; } ht_view *ht_view::getselected() { return this; } void ht_view::handlemsg(htmsg *msg) { switch (msg->msg) { case msg_draw: redraw(); return; case msg_dirtyview: dirtyview(); if ((msg->type & mt_broadcast) == 0) clearmsg(msg); return; case msg_config_changed: config_changed(); // clearmsg(msg); return; } } void ht_view::hidecursor() { buf->setCursorMode(CURSOR_OFF); screen->setCursorMode(CURSOR_OFF); } int ht_view::isaclone(ht_view *view) { return (view==this) && (countselectables()==1); } int ht_view::isviewdirty() { return view_is_dirty; } void ht_view::load(ObjectStream &s) { /* s->get_bool(enabled, NULL); s->get_bool(focused, NULL); s->get_int_dec(options, 4, NULL); s->get_int_dec(browse_idx, 4, NULL); s->get_string(desc, NULL); get_bounds(s, &size); get_bounds(s, &vsize); s->get_string(pal_class, NULL); s->get_string(pal_name, NULL); s->get_int_dec(growmode, 4, NULL);*/ } void ht_view::move(int rx, int ry) { size.x += rx; size.y += ry; buf->move(rx, ry); vsize = size; if (group) group->clipbounds(&vsize); app->clipbounds(&vsize); } ObjectID ht_view::getObjectID() const { return ATOM_HT_VIEW; } bool ht_view::pointvisible(int x, int y) { x += size.x; y += size.y; return (x >= vsize.x && y >= vsize.y && x < vsize.x+vsize.w && y < vsize.y+vsize.h); } void ht_view::receivefocus() { dirtyview(); focused = true; } void ht_view::redraw() { if (exposed()) { if (options & VO_OWNBUFFER) { if (isviewdirty()) { draw(); cleanview(); } screen->copyFromDisplay(*buf, size.x, size.y, vsize); } else { draw(); cleanview(); } } } void ht_view::resize(int sx, int sy) { if (options & VO_RESIZE) { int min_width, min_height; getminbounds(&min_width, &min_height); if (size.w+sx <= min_width) sx = min_width - size.w; if (size.h+sy <= min_height) sy = min_height - size.h; size.w += sx; size.h += sy; buf->resize(sx, sy); } vsize = size; if (group) group->clipbounds(&vsize); app->clipbounds(&vsize); } void ht_view::releasefocus() { dirtyview(); hidecursor(); focused=0; } void ht_view::reloadpalette() { if (pal.data) { free(pal.data); pal.data=0; } load_pal(pal_class, pal_name, &pal); } void ht_view::relocate_to(ht_view *view) { Bounds b; view->getbounds(&b); move(b.x, b.y); } int ht_view::select(ht_view *view) { return (view==this); } void ht_view::selectfirst() { } void ht_view::selectlast() { } void ht_view::sendmsg(htmsg *msg) { if (enabled) handlemsg(msg); } void ht_view::sendmsg(int msg, void *data1, void *data2) { htmsg m; m.msg=msg; m.type=mt_empty; m.data1.ptr=data1; m.data2.ptr=data2; sendmsg(&m); } void ht_view::sendmsg(int msg, int data1, int data2) { htmsg m; switch (msg) { case msg_empty: return; case msg_draw: case msg_dirtyview: m.msg = msg; m.type = mt_broadcast; m.data1.integer = data1; m.data2.integer = data2; break; default: m.msg = msg; m.type = mt_empty; m.data1.integer = data1; m.data2.integer = data2; break; } sendmsg(&m); } void ht_view::setbounds(Bounds *b) { size = *b; setvisualbounds(b); } void ht_view::setvisualbounds(Bounds *b) { vsize = *b; // Bounds rel(0, 0, b->w, b->h); buf->setBounds(*b); } void ht_view::setcursor(int x, int y, CursorMode c) { if (pointvisible(x, y)) { buf->setCursor(x, y, c); screen->setCursor(size.x+x, size.y+y, c); } else { buf->setCursorMode(CURSOR_OFF); screen->setCursorMode(CURSOR_OFF); } } void ht_view::setdata(ObjectStream &s) { } void ht_view::setgroup(ht_group *_group) { group=_group; } void ht_view::setnumber(uint number) { } void ht_view::setoptions(int Options) { options = Options; } void ht_view::setpalette(const char *Pal_name) { pal_name = Pal_name; reloadpalette(); } void ht_view::setpalettefull(const char *_pal_name, const char *_pal_class) { pal_class=_pal_class; setpalette(pal_name); } void ht_view::store(ObjectStream &s) const { /* s->putBool(enabled, NULL); s->putBool(focused, NULL); s->putIntDec(options, 4, NULL); s->putIntDec(browse_idx, 4, NULL); s->putString(desc, NULL); put_bounds(s, &size); put_bounds(s, &vsize); s->putString(pal_class, NULL); s->putString(pal_name, NULL); s->putIntDec(growmode, 4, NULL);*/ } void ht_view::unrelocate_to(ht_view *view) { Bounds b; view->getbounds(&b); b.x=-b.x; b.y=-b.y; move(b.x, b.y); } /* * CLASS ht_group */ void ht_group::init(Bounds *b, int options, const char *desc) { first=0; current=0; last=0; ht_view::init(b, options, desc); VIEW_DEBUG_NAME("ht_group"); view_count=0; shared_data=0; growmode = MK_GM(GMH_FIT, GMV_FIT); } void ht_group::done() { ht_view *a, *b; a=first; while (a) { b=a->next; a->done(); delete a; a=b; } ht_view::done(); } int ht_group::childcount() const { return view_count; } int ht_group::countselectables() { int c=0; ht_view *v=first; while (v) { c+=v->countselectables(); v=v->next; } return c; } int ht_group::datasize() { uint size=0; ht_view *v=first; while (v) { size+=v->datasize(); v=v->next; } return size; } int ht_group::enum_start() { return -1; } ht_view *ht_group::enum_next(int *handle) { int lowest = 0x7fffffff; ht_view *view = 0; ht_view *v = first; while (v) { if (v->browse_idx > *handle && v->browse_idx < lowest) { lowest = v->browse_idx; view = v; } v = v->next; } *handle = lowest; return view; } bool ht_group::focus(ht_view *view) { ht_view *v = first; while (v) { if (v->focus(view)) { releasefocus(); current = v; putontop(v); receivefocus(); return true; } v = v->next; } return ht_view::focus(view); } bool ht_group::focusnext() { if (!current) return false; int i = current->browse_idx; bool r = (options & VO_SELBOUND); ht_view *x = NULL; while (true) { i++; if (i > view_count-1) i=0; if (i == current->browse_idx) break; ht_view *y = get_by_browse_idx(i); if (y && (y->options & VO_SELECTABLE)) { x = y; break; } } if (i < current->browse_idx && !aclone() && !r) { return false; } if (x) { x->selectfirst(); focus(x); return true; } return r; } bool ht_group::focusprev() { if (!current) return false; int i = current->browse_idx; bool r = (options & VO_SELBOUND); if (!i && !aclone() && !r) { return false; } while (true) { i--; if (i<0) i=view_count-1; if (i==current->browse_idx) break; ht_view *v=get_by_browse_idx(i); if (v && (v->options & VO_SELECTABLE)) { v->selectlast(); focus(v); return true; } } return r; } ht_view *ht_group::get_by_browse_idx(int i) { ht_view *v=first; while (v) { if (v->browse_idx==i) return v; v=v->next; } return 0; } void ht_group::getdata(ObjectStream &s) { ht_view *v; int h = enum_start(); while ((v = enum_next(&h))) { v->getdata(s); } } ht_view *ht_group::getselected() { if (current) return current->getselected(); else return NULL; } ht_view *ht_group::getfirstchild() { return first; } void ht_group::getminbounds(int *width, int *height) { ht_view::getminbounds(width, height); ht_view *v = first; while (v) { if (v->options & VO_RESIZE) { int w, h; v->getminbounds(&w, &h); w += v->size.x + size.w - (v->size.x + v->size.w); h += v->size.y + size.h - (v->size.y + v->size.h); uint gmh = GET_GM_H(v->growmode); uint gmv = GET_GM_V(v->growmode); if (gmh == GMH_FIT && w > *width) *width = w; if (gmv == GMV_FIT && h > *height) *height = h; } v = v->next; } } void ht_group::handlemsg(htmsg *msg) { if (!enabled) return; if (msg->type == mt_broadcast) { ht_view::handlemsg(msg); ht_view *v=first; while (v) { v->handlemsg(msg); v = v->next; } } else if (msg->type == mt_empty) { int msgtype = msg->type; ht_view *v; msg->type=mt_preprocess; v=first; while (v) { if (v->options & VO_PREPROCESS) { v->handlemsg(msg); } v=v->next; } msg->type=mt_empty; if (current) current->handlemsg(msg); msg->type=mt_postprocess; v=first; while (v) { if (v->options & VO_POSTPROCESS) { v->handlemsg(msg); } v=v->next; } msg->type=msgtype; ht_view::handlemsg(msg); } else if (msg->type == mt_preprocess) { ht_view *v; v=first; while (v) { if (v->options & VO_PREPROCESS) { v->handlemsg(msg); } v=v->next; } } else if (msg->type == mt_postprocess) { ht_view *v; v=first; while (v) { if (v->options & VO_POSTPROCESS) { v->handlemsg(msg); } v=v->next; } } if ((msg->type==mt_empty || msg->type==mt_broadcast) && (msg->msg == msg_keypressed)) { switch (msg->data1.integer) { case K_Left: case K_Shift_Tab: { if (focusprev()) { clearmsg(msg); dirtyview(); return; } break; } case K_Right: case K_Tab: { if (focusnext()) { clearmsg(msg); dirtyview(); return; } break; } } } } void ht_group::insert(ht_view *view) { if (current) current->releasefocus(); if (view->options & VO_PREPROCESS) setoptions(options | VO_PREPROCESS); if (view->options & VO_POSTPROCESS) setoptions(options | VO_POSTPROCESS); if (view->pal_class && pal_class && strcmp(view->pal_class, pal_class)==0) view->setpalette(pal_name); view->g_hdist=size.w - (view->size.x+view->size.w); view->g_vdist=size.h - (view->size.y+view->size.h); Bounds c; getbounds(&c); view->move(c.x, c.y); if (last) last->next=view; view->prev = last; view->next = NULL; last = view; if (!first) first = view; view->setgroup(this); view->browse_idx = view_count++; if (!current || (current && (!(current->options & VO_SELECTABLE)) && (view->options & VO_SELECTABLE))) { current = view; } if (current && (current->options & VO_SELECTABLE)) { if (focused) { focus(current); } else { select(current); } } } int ht_group::isaclone(ht_view *view) { ht_view *v = first; while (v) { if (v != view && v->countselectables()) return 0; v = v->next; } return 1; } int ht_group::isviewdirty() { ht_view *v = first; while (v) { if (v->isviewdirty()) return 1; v = v->next; } return 0; } void ht_group::load(ObjectStream &f) { } void ht_group::move(int rx, int ry) { ht_view::move(rx, ry); ht_view *v = first; while (v) { v->move(rx, ry); v = v->next; } } ObjectID ht_group::getObjectID() const { return ATOM_HT_GROUP; } void ht_group::putontop(ht_view *view) { if (view->next) { if (view->prev) view->prev->next=view->next; else first=view->next; view->next->prev=view->prev; view->prev=last; view->next=0; last->next=view; last=view; } } void ht_group::receivefocus() { ht_view::receivefocus(); if (current) current->receivefocus(); } void ht_group::releasefocus() { ht_view::releasefocus(); if (current) current->releasefocus(); } void ht_group::remove(ht_view *view) { ht_view *n = view->next ? view->next : view->prev; if (n) { focus(n); } else { releasefocus(); current = NULL; } Bounds c; getbounds(&c); view->move(-c.x, -c.y); if (view->prev) view->prev->next = view->next; if (view->next) view->next->prev = view->prev; if (first == view) first = first->next; if (last == view) last = last->prev; } void ht_group::reorder_view(ht_view *v, int rx, int ry) { int px = 0, py = 0; int sx = 0, sy = 0; int gmv = GET_GM_V(v->growmode); int gmh = GET_GM_H(v->growmode); switch (gmh) { case GMH_LEFT: /* do nothing */ break; case GMH_RIGHT: px = rx; break; case GMH_FIT: sx = rx; break; } switch (gmv) { case GMV_TOP: /* do nothing */ break; case GMV_BOTTOM: py = ry; break; case GMV_FIT: sy = ry; break; } v->move(px, py); v->resize(sx, sy); } void ht_group::resize(int sx, int sy) { int min_width, min_height; getminbounds(&min_width, &min_height); if (size.w+sx <= min_width) sx = min_width - size.w; if (size.h+sy <= min_height) sy = min_height - size.h; ht_view::resize(sx, sy); ht_view *v = first; while (v) { reorder_view(v, sx, sy); v = v->next; } } int ht_group::select(ht_view *view) { ht_view *v = first; while (v) { if (v->select(view)) { current = v; putontop(v); return 1; } v=v->next; } return ht_view::select(view); } void ht_group::selectfirst() { for (int i=0; ibrowse_idx==i) && (v->options & VO_SELECTABLE)) { select(v); return; } v=v->next; } } } void ht_group::selectlast() { for (int i=view_count-1; i>=0; i--) { ht_view *v=first; while (v) { if ((v->browse_idx==i) && (v->options & VO_SELECTABLE)) { select(v); return; } v=v->next; } } } void ht_group::setdata(ObjectStream &s) { ht_view *v; int h=enum_start(); while ((v=enum_next(&h))) { v->setdata(s); } } void ht_group::setpalette(const char *pal_name) { ht_view *v=first; while (v) { if (strcmp(pal_class, v->pal_class)==0) v->setpalette(pal_name); v=v->next; } ht_view::setpalette(pal_name); } void ht_group::store(ObjectStream &s) const { ht_view::store(s); PUTX_INT32D(s, childcount(), "childcount"); ht_view *v=first; while (v) { PUTX_OBJECT(s, v, "obj"); v=v->next; } } /* * CLASS ht_xgroup */ void ht_xgroup::init(Bounds *b, int options, const char *desc) { ht_group::init(b, options, desc); VIEW_DEBUG_NAME("ht_xgroup"); first=0; current=0; last=0; } void ht_xgroup::done() { ht_group::done(); } int ht_xgroup::countselectables() { return current->countselectables(); } void ht_xgroup::handlemsg(htmsg *msg) { if ((msg->msg!=msg_draw) && (msg->type==mt_broadcast)) { ht_group::handlemsg(msg); } else { if (msg->msg==msg_complete_init) return; if (current) current->handlemsg(msg); ht_view::handlemsg(msg); } } int ht_xgroup::isaclone(ht_view *view) { if (group) return group->isaclone(this); return 0; } void ht_xgroup::load(ObjectStream &s) { ht_group::load(s); } ObjectID ht_xgroup::getObjectID() const { return ATOM_HT_XGROUP; } void ht_xgroup::redraw() { ht_view::redraw(); /* no broadcasts. */ if (current) current->redraw(); } void ht_xgroup::selectfirst() { current->selectfirst(); } void ht_xgroup::selectlast() { current->selectlast(); } void ht_xgroup::store(ObjectStream &s) const { ht_group::store(s); } /* * CLASS ht_scrollbar */ bool scrollbar_pos(sint64 start, sint64 size, sint64 all, int *pstart, int *psize) { if (!all) return false; if (start+size >= all) { if (size >= all) return false; *psize = (int)(((double)size)*100/all); *pstart = 100 - *psize; } else { *psize = (int)(((double)size)*100/all); *pstart = (int)(((double)start)*100/all); } return true; } void ht_scrollbar::init(Bounds *b, palette *p, bool isv) { ht_view::init(b, VO_RESIZE, 0); VIEW_DEBUG_NAME("ht_scrollbar"); pstart = 0; psize = 0; gpal = p; isvertical = isv; if (isvertical) { growmode = MK_GM(GMH_RIGHT, GMV_FIT); } else { growmode = MK_GM(GMH_FIT, GMV_BOTTOM); } enable(); // enabled by default } void ht_scrollbar::done() { ht_view::done(); } void ht_scrollbar::enable() { enable_buffering(); ht_view::enable(); dirtyview(); } void ht_scrollbar::disable() { disable_buffering(); ht_view::disable(); dirtyview(); } void ht_scrollbar::draw() { if (enabled) { vcp color = getcolorv(gpal, palidx_generic_scrollbar); // vcp color2 = VCP(VCP_BACKGROUND(color), VCP_FOREGROUND(color)); if (isvertical) { fill(0, 1, size.w, size.h-2, color, ' '); int e, s; e=((size.h-2)*psize)/100; if (pstart+psize>=100) { s=size.h-2-e; } else { s=((size.h-2)*pstart)/100; } if (!e) { if (s==size.h-2) s--; e=1; } fill(0, s+1, 1, e, color, GC_MEDIUM, CP_GRAPHICAL); buf->printChar(0, 0, color, GC_ARROW_UP, CP_GRAPHICAL); buf->printChar(0, size.h-1, color, GC_ARROW_DOWN, CP_GRAPHICAL); } else { } } } void ht_scrollbar::getminbounds(int *width, int *height) { *width = 1; *height = 1; } ObjectID ht_scrollbar::getObjectID() const { return ATOM_HT_SCROLLBAR; } void ht_scrollbar::setpos(int ps, int pz) { pstart = ps; psize = pz; dirtyview(); } /* * CLASS ht_frame */ void ht_frame::init(Bounds *b, const char *desc, uint s, uint n) { ht_view::init(b, VO_RESIZE, desc); VIEW_DEBUG_NAME("ht_frame"); number = n; style = s; framestate = FST_UNFOCUSED; growmode = MK_GM(GMH_FIT, GMV_FIT); } void ht_frame::done() { ht_view::done(); } void ht_frame::draw() { int cornerul, cornerur, cornerll, cornerlr; int lineh, linev; ht_window *w = (ht_window*)group; if (framestate != FST_MOVE && framestate != FST_RESIZE) { setframestate(w->focused ? FST_FOCUSED : FST_UNFOCUSED); } if (style & FS_THICK) { cornerul = GC_2CORNER3; cornerur = GC_2CORNER0; cornerll = GC_2CORNER2; cornerlr = GC_2CORNER1; lineh = GC_2HLINE; linev = GC_2VLINE; } else { cornerul = GC_1CORNER3; cornerur = GC_1CORNER0; cornerll = GC_1CORNER2; cornerlr = GC_1CORNER1; lineh = GC_1HLINE; linev = GC_1VLINE; } vcp c = getcurcol_normal(); /* "/...\" */ buf->printChar(0, 0, c, cornerul, CP_GRAPHICAL); for (int i=1; i < size.w-1; i++) buf->printChar(i, 0, c, lineh, CP_GRAPHICAL); buf->printChar(0+size.w-1, 0, c, cornerur, CP_GRAPHICAL); /* "\.../" */ buf->printChar(0, size.h-1, c, cornerll, CP_GRAPHICAL); for (int i=1; i < size.w-1; i++) buf->printChar(i, size.h-1, c, lineh, CP_GRAPHICAL); /* if (style & FS_RESIZE) { buf->printChar(size.w-1, size.h-1, getcurcol_killer(), GC_1CORNER1, CP_GRAPHICAL); } else {*/ buf->printChar(size.w-1, size.h-1, c, cornerlr, CP_GRAPHICAL); // } /* "|", "|" */ for (int i=1; i < size.h-1; i++) { buf->printChar(0, i, c, linev, CP_GRAPHICAL); buf->printChar(size.w-1, i, c, linev, CP_GRAPHICAL); } /* "[x]" */ if (style & FS_KILLER) { buf->print(2, 0, c, "[ ]"); buf->printChar(3, 0, getcurcol_killer(), GC_FILLED_QUAD, CP_GRAPHICAL); } /* e.g. "1" */ int ns=0; if (style & FS_NUMBER) { int l = number; do { l = l/10; ns++; } while (l); buf->printf(size.w-4-ns, 0, c, CP_DEVICE, "%d", number); ns += 4; } /* */ const char *d; switch (framestate) { case FST_MOVE: d = (style & FS_RESIZE) ? "(moving) - hit space to resize" : "(moving)"; break; case FST_RESIZE: d = (style & FS_MOVE) ? "(resizing) - hit space to move" : "(resizing)"; break; default: d = desc; } int ks = (style & FS_KILLER) ? 4 : 0; ns++; if (d && (style & FS_TITLE)) { int l = strlen(d), k = 0; if (l > size.w-(5+ks+ns)) { k = l-(size.w-(6+ks+ns+2)); if (size.w > 6+ks+ns+2) { d += k; } else { d = ""; } buf->printf(2+ks, 0, c, CP_DEVICE, " ...%s ", d); } else { buf->printf((size.w-l-2)/2, 0, c, CP_DEVICE, " %s ", d); } } } vcp ht_frame::getcurcol_normal() { switch (framestate) { case FST_FOCUSED: return getcolor(palidx_generic_frame_focused); case FST_UNFOCUSED: return getcolor(palidx_generic_frame_unfocused); case FST_MOVE: case FST_RESIZE: return getcolor(palidx_generic_frame_move_resize); } return 0; } vcp ht_frame::getcurcol_killer() { return getcolor(palidx_generic_frame_killer); } uint ht_frame::getnumber() { return number; } uint ht_frame::getstyle() { return style; } ObjectID ht_frame::getObjectID() const { return ATOM_HT_FRAME; } void ht_frame::setframestate(uint _framestate) { framestate=_framestate; dirtyview(); } void ht_frame::setnumber(uint _number) { number=_number; dirtyview(); } void ht_frame::setstyle(uint s) { style=s; } void ht_frame::settext(const char *text) { free(desc); desc = ht_strdup(text); dirtyview(); } /* * CLASS ht_window */ void ht_window::init(Bounds *b, const char *desc, uint framestyle, uint num) { ht_group::init(b, VO_SELECTABLE | VO_SELBOUND | VO_BROWSABLE, desc); VIEW_DEBUG_NAME("ht_window"); number=num; hscrollbar=NULL; vscrollbar=NULL; pindicator=NULL; Bounds c=*b; c.x=0; c.y=0; frame=0; action_state=WAC_NORMAL; ht_frame *f=new ht_frame(); f->init(&c, desc, framestyle, number); setframe(f); } void ht_window::done() { pindicator=NULL; hscrollbar=NULL; vscrollbar=NULL; ht_group::done(); } void ht_window::draw() { vcp c=getcolor(palidx_generic_body); clear(c); } void ht_window::getclientarea(Bounds *b) { getbounds(b); if (frame) { b->x++; b->y++; b->w-=2; b->h-=2; } } uint ht_window::getnumber() { return number; } ht_frame *ht_window::getframe() { return frame; } void ht_window::handlemsg(htmsg *msg) { switch (msg->msg) { case msg_keypressed: if (action_state==WAC_MOVE) { if (options & VO_MOVE) { switch (msg->data1.integer) { case K_Up: if (size.y>group->size.y) move(0, -1); break; case K_Down: if (size.y<group->size.y+group->size.h-1) move(0, 1); break; case K_Left: if (size.x+size.w>group->size.x+1) move(-1, 0); break; case K_Right: if (size.x<group->size.x+group->size.w-1) move(1, 0); break; case K_Control_Up: if (size.y>group->size.y+5-1) move(0, -5); else move(0, group->size.y-size.y); break; case K_Control_Down: if (size.y<group->size.y+group->size.h-5) move(0, 5); else move(0, group->size.y+group->size.h-size.y-1); break; case K_Control_Left: if (size.x+size.w>group->size.x+5) move(-5, 0); else move(-(size.x+size.w)+group->size.x+1, 0); break; case K_Control_Right: if (size.x<group->size.x+group->size.w-5) move(5, 0); else move(group->size.x+group->size.w-size.x-1, 0); break; } } } else if (action_state == WAC_RESIZE) { if (options & VO_RESIZE) { int min_width, min_height; getminbounds(&min_width, &min_height); switch (msg->data1.integer) { case K_Up: if (size.h > min_height) resize(0, -1); break; case K_Down: if (size.h < group->size.h) resize(0, 1); break; case K_Left: if (size.x+size.w > 1 && size.w > min_width) resize(-1, 0); break; case K_Right: if (size.w < group->size.w) resize(1, 0); break; } } } else { if ((msg->data1.integer == K_Control_F5) || (msg->data1.integer == K_Control_R)) { sendmsg(cmd_window_resizemove); } break; } switch (msg->data1.integer) { case K_Escape: case K_Return: sendmsg(cmd_window_resizemove); break; case K_Space: case K_Control_F5: sendmsg(cmd_window_switch_resizemove); break; } app->sendmsg(msg_dirtyview, 0); clearmsg(msg); return; case cmd_window_resizemove: { bool b = (action_state == WAC_NORMAL); do { if (!next_action_state()) break; } while (b == (action_state == WAC_NORMAL)); dirtyview(); clearmsg(msg); return; } case cmd_window_switch_resizemove: do { if (!next_action_state()) break; } while (action_state == WAC_NORMAL); dirtyview(); clearmsg(msg); return; } ht_group::handlemsg(msg); } void ht_window::insert(ht_view *view) { if (frame) view->move(1, 1); ht_group::insert(view); } void ht_window::load(ObjectStream &s) { ht_group::load(s); } bool ht_window::next_action_state() { #define wstate_count 3 int ass[wstate_count] = { WAC_NORMAL, WAC_MOVE, WAC_RESIZE }; int fss[wstate_count] = { FST_FOCUSED, FST_MOVE, FST_RESIZE }; for (int i=0; i < wstate_count; i++) { if (action_state == ass[i]) { int p = i; while (++p != i) { if (p > wstate_count-1) p = 0; bool allowed = true; switch (ass[p]) { case WAC_MOVE: allowed = ((options & VO_MOVE) != 0); break; case WAC_RESIZE: allowed = ((options & VO_RESIZE) != 0); break; } if (allowed) { action_state = ass[p]; if (frame) frame->setframestate(fss[p]); return (p != i); } } return false; } } return false; } ObjectID ht_window::getObjectID() const { return ATOM_HT_WINDOW; } void ht_window::receivefocus() { htmsg m; m.msg = msg_contextmenuquery; m.type = mt_empty; sendmsg(&m); if (m.msg == msg_retval) { ht_menu *q = (ht_menu*)((ht_app*)app)->menu; ht_context_menu *n = (ht_context_menu*)m.data1.ptr; if (q) { if (!q->set_local_menu(n)) { n->done(); delete n; } q->sendmsg(msg_dirtyview); } else { n->done(); delete n; } } ht_group::receivefocus(); if (frame) frame->setstyle(frame->getstyle() | FS_THICK); } void ht_window::redraw() { htmsg m; if (pindicator) { char buf[256]; buf[0] = 0; m.msg = msg_get_pindicator; m.type = mt_empty; m.data1.integer = sizeof buf; m.data2.ptr = buf; sendmsg(&m); pindicator->settext(buf); } gsi_scrollbar_t p; if (hscrollbar) { p.pstart = 0; p.psize = 200; m.msg = msg_get_scrollinfo; m.type = mt_empty; m.data1.integer = gsi_hscrollbar; m.data2.ptr = &p; sendmsg(&m); if (p.psize >= 100) { hscrollbar->disable(); } else { hscrollbar->enable(); hscrollbar->setpos(p.pstart, p.psize); } } if (vscrollbar) { p.pstart = 0; p.psize = 200; m.msg = msg_get_scrollinfo; m.type = mt_empty; m.data1.integer = gsi_vscrollbar; m.data2.ptr = &p; sendmsg(&m); if (p.psize >= 100) { vscrollbar->disable(); } else { vscrollbar->enable(); vscrollbar->setpos(p.pstart, p.psize); } } ht_group::redraw(); } void ht_window::releasefocus() { ht_menu *q = (ht_menu*)((ht_app*)app)->menu; if (q) { q->delete_local_menu(); q->sendmsg(msg_dirtyview); } if (frame) frame->setstyle(frame->getstyle() & (~FS_THICK)); ht_group::releasefocus(); } void ht_window::setframe(ht_frame *newframe) { if (frame) { ht_group::remove(frame); frame->done(); delete frame; frame = NULL; } if (newframe) { uint style=newframe->getstyle(); if (style & FS_MOVE) options |= VO_MOVE; else options &= ~VO_MOVE; if (style & FS_RESIZE) options |= VO_RESIZE; else options &= ~VO_RESIZE; insert(newframe); } else { options &= ~VO_MOVE; options &= ~VO_RESIZE; } frame = newframe; } void ht_window::setnumber(uint aNumber) { if (frame) frame->setnumber(aNumber); number = aNumber; dirtyview(); } void ht_window::sethscrollbar(ht_scrollbar *s) { if (hscrollbar) remove(hscrollbar); hscrollbar = s; insert(hscrollbar); putontop(hscrollbar); } void ht_window::setpindicator(ht_text *p) { if (pindicator) remove(pindicator); pindicator = p; insert(pindicator); putontop(pindicator); } void ht_window::settitle(char *title) { free(desc); desc = ht_strdup(title); if (frame) frame->settext(title); } void ht_window::setvscrollbar(ht_scrollbar *s) { if (vscrollbar) remove(vscrollbar); vscrollbar = s; insert(vscrollbar); putontop(vscrollbar); } void ht_window::store(ObjectStream &s) const { ht_group::store(s); } /* * CLASS ht_vbar */ void ht_vbar::draw() { fill(0, 0, 1, size.h, getcolor(palidx_generic_body), GC_1VLINE, CP_GRAPHICAL); } /* * CLASS ht_hbar */ void ht_hbar::draw() { fill(0, 0, size.w, 1, getcolor(palidx_generic_body), GC_1HLINE, CP_GRAPHICAL); } /***/ BUILDER(ATOM_HT_VIEW, ht_view, Object); BUILDER(ATOM_HT_GROUP, ht_group, ht_view); BUILDER(ATOM_HT_XGROUP, ht_xgroup, ht_group); BUILDER(ATOM_HT_WINDOW, ht_window, ht_group); BUILDER(ATOM_HT_SCROLLBAR, ht_scrollbar, ht_view); /* * INIT */ bool init_obj() { REGISTER(ATOM_HT_VIEW, ht_view); REGISTER(ATOM_HT_GROUP, ht_group); REGISTER(ATOM_HT_XGROUP, ht_xgroup); REGISTER(ATOM_HT_WINDOW, ht_window); REGISTER(ATOM_HT_SCROLLBAR, ht_scrollbar); return true; } /* * DONE */ void done_obj() { UNREGISTER(ATOM_HT_VIEW, ht_view); UNREGISTER(ATOM_HT_GROUP, ht_group); UNREGISTER(ATOM_HT_XGROUP, ht_xgroup); UNREGISTER(ATOM_HT_WINDOW, ht_window); UNREGISTER(ATOM_HT_FRAME, ht_frame); UNREGISTER(ATOM_HT_SCROLLBAR, ht_scrollbar); } �������������������������������������������������������������������������������������������������������������ht-2.0.22/htneimp.h���������������������������������������������������������������������������������0000644�0001750�0000144�00000001526�10206756710�010752� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * htneimp.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTNEIMP_H__ #define __HTNEIMP_H__ #include "formats.h" extern format_viewer_if htneimports_if; #endif /* !__HTNEIMP_H__ */ ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/machostruc.h������������������������������������������������������������������������������0000644�0001750�0000144�00000054115�10660124267�011460� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * machostruc.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __MACHOSTRUC_H__ #define __MACHOSTRUC_H__ #include "io/types.h" struct MACHO_HEADER { byte magic[4]; uint32 cputype; uint32 cpusubtype; uint32 filetype; uint32 ncmds; uint32 sizeofcmds; uint32 flags; } PACKED; struct MACHO_HEADER64 { byte magic[4]; uint32 cputype; uint32 cpusubtype; uint32 filetype; uint32 ncmds; uint32 sizeofcmds; uint32 flags; uint32 reserved; } PACKED; /* Constants for the filetype field of the mach_header */ #define MH_OBJECT 0x1 /* relocatable object file */ #define MH_EXECUTE 0x2 /* demand paged executable file */ #define MH_FVMLIB 0x3 /* fixed VM shared library file */ #define MH_CORE 0x4 /* core file */ #define MH_PRELOAD 0x5 /* preloaded executable file */ #define MH_DYLIB 0x6 /* dynamicly bound shared library file*/ #define MH_DYLINKER 0x7 /* dynamic link editor */ #define MH_BUNDLE 0x8 /* dynamicly bound bundle file */ #define MH_DYLIB_STUB 0x9 /* shared library stub for static */ /* linking only, no section contents */ #define MH_DSYM 0xa /* companion file with only debug */ /* sections */ /* Constants for the flags field of the mach_header */ #define MH_NOUNDEFS 0x1 /* the object file has no undefined references, can be executed */ #define MH_INCRLINK 0x2 /* the object file is the output of an incremental link against a base file and can't be link edited again */ #define MH_DYLDLINK 0x4 /* the object file is input for the dynamic linker and can't be staticly link edited again */ #define MH_BINDATLOAD 0x8 /* the object file's undefined references are bound by the dynamic linker when loaded. */ #define MH_PREBOUND 0x10 /* the file has it's dynamic undefined references prebound. */ #define MH_SPLIT_SEGS 0x20 /* the file has its read-only and read-write segments split */ #define MH_LAZY_INIT 0x40 /* the shared library init routine is to be run lazily via catching memory faults to its writeable segments (obsolete) */ #define MH_TWOLEVEL 0x80 /* the image is using two-level name space bindings */ #define MH_FORCE_FLAT 0x100 /* the executable is forcing all images to use flat name space bindings */ #define MH_NOMULTIDEFS 0x200 /* this umbrella guarantees no multiple defintions of symbols in its sub-images so the two-level namespace hints can always be used. */ #define MH_NOFIXPREBINDING 0x400 /* do not have dyld notify the prebinding agent about this executable */ #define MH_PREBINDABLE 0x800 /* the binary is not prebound but can have its prebinding redone. only used when MH_PREBOUND is not set. */ #define MH_ALLMODSBOUND 0x1000 /* indicates that this binary binds to all two-level namespace modules of its dependent libraries. only used when MH_PREBINDABLE and MH_TWOLEVEL are both set. */ #define MH_SUBSECTIONS_VIA_SYMBOLS 0x2000/* safe to divide up the sections into sub-sections via symbols for dead code stripping */ #define MH_CANONICAL 0x4000 /* the binary has been canonicalized via the unprebind operation */ #define MH_WEAK_DEFINES 0x8000 /* the final linked image contains external weak symbols */ #define MH_BINDS_TO_WEAK 0x10000 /* the final linked image uses weak symbols */ #define MH_ALLOW_STACK_EXECUTION 0x20000/* When this bit is set, all stacks in the task will be given stack execution privilege. Only used in MH_EXECUTE filetypes. */ #define MH_ROOT_SAFE 0x40000 /* When this bit is set, the binary declares it is safe for use in processes with uid zero */ #define MH_SETUID_SAFE 0x80000 /* When this bit is set, the binary declares it is safe for use in processes when issetugid() is true */ #define MH_NO_REEXPORTED_DYLIBS 0x100000 /* When this bit is set on a dylib, the static linker does not need to examine dependent dylibs to see if any are re-exported */ #define MH_PIE 0x200000 /* When this bit is set, the OS will load the main executable at a random address. Only used in MH_EXECUTE filetypes. */ struct MACHO_COMMAND { uint32 cmd; /* type of load command */ uint32 cmdsize; /* total size of command in bytes */ } PACKED; /* Constants for the cmd field of all load commands, the type */ #define LC_SEGMENT 0x1 /* segment of this file to be mapped */ #define LC_SYMTAB 0x2 /* link-edit stab symbol table info */ #define LC_SYMSEG 0x3 /* link-edit gdb symbol table info (obsolete) */ #define LC_THREAD 0x4 /* thread */ #define LC_UNIXTHREAD 0x5 /* unix thread (includes a stack) */ #define LC_LOADFVMLIB 0x6 /* load a specified fixed VM shared library */ #define LC_IDFVMLIB 0x7 /* fixed VM shared library identification */ #define LC_IDENT 0x8 /* object identification info (obsolete) */ #define LC_FVMFILE 0x9 /* fixed VM file inclusion (internal use) */ #define LC_PREPAGE 0xa /* prepage command (internal use) */ #define LC_DYSYMTAB 0xb /* dynamic link-edit symbol table info */ #define LC_LOAD_DYLIB 0xc /* load a dynamicly linked shared library */ #define LC_ID_DYLIB 0xd /* dynamicly linked shared lib identification */ #define LC_LOAD_DYLINKER 0xe /* load a dynamic linker */ #define LC_ID_DYLINKER 0xf /* dynamic linker identification */ #define LC_PREBOUND_DYLIB 0x10 /* modules prebound for a dynamicly linked shared library */ #define LC_ROUTINES 0x11 /* image routines */ #define LC_SUB_FRAMEWORK 0x12 /* sub framework */ #define LC_SUB_UMBRELLA 0x13 /* sub umbrella */ #define LC_SUB_CLIENT 0x14 /* sub client */ #define LC_SUB_LIBRARY 0x15 /* sub library */ #define LC_TWOLEVEL_HINTS 0x16 /* two-level namespace lookup hints */ #define LC_PREBIND_CKSUM 0x17 /* prebind checksum */ #define LC_LOAD_WEAK_DYLIB (0x18 | LC_REQ_DYLD) #define LC_SEGMENT_64 0x19 /* 64-bit segment of this file to be mapped */ #define LC_ROUTINES_64 0x1a /* 64-bit image routines */ #define LC_UUID 0x1b /* the uuid */ #define LC_RPATH (0x1c | LC_REQ_DYLD) /* runpath additions */ #define LC_CODE_SIGNATURE 0x1d /* local of code signature */ #define LC_SEGMENT_SPLIT_INFO 0x1e /* local of info to split segments */ #define LC_REEXPORT_DYLIB (0x1f | LC_REQ_DYLD) /* load and re-export dylib */ struct MACHO_SEGMENT_COMMAND { uint32 cmd; /* LC_SEGMENT */ uint32 cmdsize; /* includes sizeof section structs */ byte segname[16]; /* segment name */ uint32 vmaddr; /* memory address of this segment */ uint32 vmsize; /* memory size of this segment */ uint32 fileoff; /* file offset of this segment */ uint32 filesize; /* amount to map from the file */ uint32 maxprot; /* maximum VM protection */ uint32 initprot; /* initial VM protection */ uint32 nsects; /* number of sections in segment */ uint32 flags; /* flags */ } PACKED; struct MACHO_SEGMENT_64_COMMAND { uint32 cmd; /* LC_SEGMENT_64 */ uint32 cmdsize; /* includes sizeof section_64 structs */ byte segname[16]; /* segment name */ uint64 vmaddr; /* memory address of this segment */ uint64 vmsize; /* memory size of this segment */ uint64 fileoff; /* file offset of this segment */ uint64 filesize; /* amount to map from the file */ uint32 maxprot; /* maximum VM protection */ uint32 initprot; /* initial VM protection */ uint32 nsects; /* number of sections in segment */ uint32 flags; /* flags */ } PACKED; /* Constants for the flags field of the segment_command */ #define SG_HIGHVM 0x1 /* the file contents for this segment is for the high part of the VM space, the low part is zero filled (for stacks in core files) */ #define SG_FVMLIB 0x2 /* this segment is the VM that is allocated by a fixed VM library, for overlap checking in the link editor */ #define SG_NORELOC 0x4 /* this segment has nothing that was relocated in it and nothing relocated to it, that is it maybe safely replaced without relocation */ #define SG_PROTECTED_VERSION_1 0x8 /* This segment is protected. If the segment starts at file offset 0, the first page of the segment is not protected. All other pages of the segment are protected. */ struct MACHO_SECTION { byte sectname[16]; /* name of this section */ byte segname[16]; /* segment this section goes in */ uint32 vmaddr; /* memory address of this section */ uint32 vmsize; /* size in bytes of this section */ uint32 fileoff; /* file offset of this section */ uint32 align; /* section alignment (power of 2) */ uint32 reloff; /* file offset of relocation entries */ uint32 nreloc; /* number of relocation entries */ uint32 flags; /* flags (section type and attributes)*/ uint32 reserved1; /* reserved */ uint32 reserved2; /* reserved */ } PACKED; struct MACHO_SECTION_64 { byte sectname[16]; /* name of this section */ byte segname[16]; /* segment this section goes in */ uint64 vmaddr; /* memory address of this section */ uint64 vmsize; /* size in bytes of this section */ uint32 fileoff; /* file offset of this section */ uint32 align; /* section alignment (power of 2) */ uint32 reloff; /* file offset of relocation entries */ uint32 nreloc; /* number of relocation entries */ uint32 flags; /* flags (section type and attributes)*/ uint32 reserved1; /* reserved (for offset or index) */ uint32 reserved2; /* reserved (for count or sizeof) */ uint32 reserved3; /* reserved */ } PACKED; struct MACHO_SECTION_U { bool _64; union { MACHO_SECTION s; MACHO_SECTION_64 s64; }; }; /* * The flags field of a section structure is separated into two parts a section * type and section attributes. The section types are mutually exclusive (it * can only have one type) but the section attributes are not (it may have more * than one attribute). */ #define MACHO_SECTION_TYPE 0x000000ff /* 256 section types */ #define MACHO_SECTION_ATTRIBUTES 0xffffff00 /* 24 section attributes */ /* Constants for the type of a section */ #define MACHO_S_REGULAR 0x0 /* regular section */ #define MACHO_S_ZEROFILL 0x1 /* zero fill on demand section */ #define MACHO_S_CSTRING_LITERALS 0x2 /* section with only literal C strings*/ #define MACHO_S_4BYTE_LITERALS 0x3 /* section with only 4 byte literals */ #define MACHO_S_8BYTE_LITERALS 0x4 /* section with only 8 byte literals */ #define MACHO_S_LITERAL_POINTERS 0x5 /* section with only pointers to */ /* literals */ /* * For the two types of symbol pointers sections and the symbol stubs section * they have indirect symbol table entries. For each of the entries in the * section the indirect symbol table entries, in corresponding order in the * indirect symbol table, start at the index stored in the reserved1 field * of the section structure. Since the indirect symbol table entries * correspond to the entries in the section the number of indirect symbol table * entries is inferred from the size of the section divided by the size of the * entries in the section. For symbol pointers sections the size of the entries * in the section is 4 bytes and for symbol stubs sections the byte size of the * stubs is stored in the reserved2 field of the section structure. */ #define MACHO_S_NON_LAZY_SYMBOL_POINTERS 0x6 /* section with only non-lazy symbol pointers */ #define MACHO_S_LAZY_SYMBOL_POINTERS 0x7 /* section with only lazy symbol pointers */ #define MACHO_S_SYMBOL_STUBS 0x8 /* section with only symbol stubs, byte size of stub in the reserved2 field */ #define MACHO_S_MOD_INIT_FUNC_POINTERS 0x9 /* section with only function pointers for initialization*/ #define MACHO_S_MOD_TERM_FUNC_POINTERS 0xa /* section with only function pointers for termination */ #define MACHO_S_COALESCED 0xb /* section contains symbols that are to be coalesced */ #define MACHO_S_GB_ZEROFILL 0xc /* zero fill on demand section (that can be larger than 4 gigabytes) */ #define MACHO_S_INTERPOSING 0xd /* section with only pairs of function pointers for interposing */ #define MACHO_S_16BYTE_LITERALS 0xe /* section with only 16 byte literals */ #define MACHO_S_DTRACE_DOF 0xf /* section contains DTrace Object Format */ /* * Constants for the section attributes part of the flags field of a section * structure. */ #define MACHO_SECTION_ATTRIBUTES_USR 0xff000000 /* User setable attributes */ #define MACHO_S_ATTR_PURE_INSTRUCTIONS 0x80000000 /* section contains only true machine instructions */ #define MACHO_SECTION_ATTRIBUTES_SYS 0x00ffff00 /* system setable attributes */ #define MACHO_S_ATTR_SOME_INSTRUCTIONS 0x00000400 /* section contains some machine instructions */ #define MACHO_S_ATTR_EXT_RELOC 0x00000200 /* section has external relocation entries */ #define MACHO_S_ATTR_LOC_RELOC 0x00000100 /* section has local relocation entries */ #define MACHO_S_ATTR_NO_DEAD_STRIP 0x10000000 /* no dead stripping */ #define MACHO_S_ATTR_LIVE_SUPPORT 0x08000000 /* blocks are live if they reference live blocks */ #define MACHO_S_ATTR_SELF_MODIFYING_CODE 0x04000000 /* Used with i386 code stubs written on by dyld */ struct MACHO_PPC_THREAD_STATE { uint32 srr[2]; uint32 r[32]; uint32 cr; uint32 xer; uint32 lr; uint32 ctr; uint32 mq; uint32 vrsave; } PACKED; struct MACHO_PPC_64_THREAD_STATE { uint64 srr[2]; } PACKED; #define FLAVOR_PPC_THREAD_STATE 1 #define FLAVOR_PPC_FLOAT_STATE 2 #define FLAVOR_PPC_EXCEPTION_STATE 3 #define FLAVOR_PPC_VECTOR_STATE 4 #define FLAVOR_THREAD_STATE_NONE 7 #define FLAVOR_PPC_64_THREAD_STATE 5 struct MACHO_ARM_THREAD_STATE { uint32 unknown[15]; uint32 pc; uint32 unknown2; } PACKED; #define FLAVOR_ARM_THREAD_STATE 1 struct MACHO_I386_THREAD_STATE { uint32 eax; uint32 ebx; uint32 ecx; uint32 edx; uint32 edi; uint32 esi; uint32 ebp; uint32 esp; uint32 ss; uint32 eflags; uint32 eip; uint32 cs; uint32 ds; uint32 es; uint32 fs; uint32 gs; } PACKED; #define i386_NEW_THREAD_STATE 1 /* used to be i386_THREAD_STATE */ #define i386_FLOAT_STATE 2 #define i386_ISA_PORT_MAP_STATE 3 #define i386_V86_ASSIST_STATE 4 #define i386_REGS_SEGS_STATE 5 #define THREAD_SYSCALL_STATE 6 #define THREAD_STATE_NONE 7 #define i386_SAVED_STATE 8 struct MACHO_X86_64_THREAD_STATE { uint64 rax; uint64 rbx; uint64 rcx; uint64 rdx; uint64 rdi; uint64 rsi; uint64 rbp; uint64 rsp; uint64 r[8]; uint64 rip; uint64 unknown[4]; } PACKED; #define FLAVOR_X86_64_THREAD_STATE 4 union MACHO_THREAD_STATE { MACHO_ARM_THREAD_STATE state_arm; MACHO_PPC_THREAD_STATE state_ppc; MACHO_I386_THREAD_STATE state_i386; MACHO_X86_64_THREAD_STATE state_x86_64; MACHO_PPC_64_THREAD_STATE state_ppc64; }; struct MACHO_THREAD_COMMAND { uint32 cmd; /* LC_THREAD or LC_UNIXTHREAD */ uint32 cmdsize; /* total size of this command */ uint32 flavor; /* flavor of thread state */ uint32 count; /* count of longs in thread state */ MACHO_THREAD_STATE state; } PACKED; union MACHO_COMMAND_U { MACHO_COMMAND cmd; MACHO_SEGMENT_COMMAND segment; MACHO_SEGMENT_64_COMMAND segment_64; MACHO_THREAD_COMMAND thread; }; struct MACHO_SYMTAB_COMMAND { uint32 cmd; /* LC_SYMTAB */ uint32 cmdsize; /* sizeof(struct symtab_command) */ uint32 symoff; /* symbol table offset */ uint32 nsyms; /* number of symbol table entries */ uint32 stroff; /* string table offset */ uint32 strsize; /* string table size in bytes */ } PACKED; struct MACHO_SYMTAB_NLIST { uint32 strx; uint8 type; uint8 sect; uint16 desc; uint32 value; } PACKED; struct MACHO_SYMTAB_NLIST_64 { uint32 strx; uint8 type; uint8 sect; uint16 desc; uint64 value; } PACKED; // masks for type #define MACHO_SYMBOL_N_STAB 0xe0 #define MACHO_SYMBOL_N_PEXT 0x10 #define MACHO_SYMBOL_N_TYPE 0x0e #define MACHO_SYMBOL_N_EXT 0x01 #define MACHO_SYMBOL_TYPE_N_UNDF 0x00 #define MACHO_SYMBOL_TYPE_N_ABS 0x02 #define MACHO_SYMBOL_TYPE_N_INDR 0x0a #define MACHO_SYMBOL_TYPE_N_PBUD 0x0c #define MACHO_SYMBOL_TYPE_N_SECT 0x0e /* * Machine types known by all. */ #define MACHO_CPU_TYPE_ANY -1 #define MACHO_CPU_TYPE_VAX 1 #define MACHO_CPU_TYPE_MC680x0 6 #define MACHO_CPU_TYPE_I386 7 #define MACHO_CPU_TYPE_MIPS 8 #define MACHO_CPU_TYPE_MC98000 10 #define MACHO_CPU_TYPE_HPPA 11 #define MACHO_CPU_TYPE_ARM 12 #define MACHO_CPU_TYPE_MC88000 13 #define MACHO_CPU_TYPE_SPARC 14 #define MACHO_CPU_TYPE_I860 15 #define MACHO_CPU_TYPE_ALPHA 16 #define MACHO_CPU_TYPE_POWERPC 18 #define MACHO_CPU_TYPE_X86_64 0x01000007 #define MACHO_CPU_TYPE_POWERPC64 0x01000012 /* * Machine subtypes (these are defined here, instead of in a machine * dependent directory, so that any program can get all definitions * regardless of where is it compiled. */ /* * Object files that are hand-crafted to run on any * implementation of an architecture are tagged with * MACHO_CPU_SUBTYPE_MULTIPLE. This functions essentially the same as * the "ALL" subtype of an architecture except that it allows us * to easily find object files that may need to be modified * whenever a new implementation of an architecture comes out. * * It is the responsibility of the implementor to make sure the * software handles unsupported implementations elegantly. */ #define MACHO_CPU_SUBTYPE_MULTIPLE -1 #define MACHO_CPU_SUBTYPE_LITTLE_ENDIAN 0 #define MACHO_CPU_SUBTYPE_BIG_ENDIAN 1 /* * VAX subtypes (these do *not* necessary conform to the actual cpu * ID assigned by DEC available via the SID register. */ #define MACHO_CPU_SUBTYPE_VAX_ALL 0 #define MACHO_CPU_SUBTYPE_VAX780 1 #define MACHO_CPU_SUBTYPE_VAX785 2 #define MACHO_CPU_SUBTYPE_VAX750 3 #define MACHO_CPU_SUBTYPE_VAX730 4 #define MACHO_CPU_SUBTYPE_UVAXI 5 #define MACHO_CPU_SUBTYPE_UVAXII 6 #define MACHO_CPU_SUBTYPE_VAX8200 7 #define MACHO_CPU_SUBTYPE_VAX8500 8 #define MACHO_CPU_SUBTYPE_VAX8600 9 #define MACHO_CPU_SUBTYPE_VAX8650 10 #define MACHO_CPU_SUBTYPE_VAX8800 11 #define MACHO_CPU_SUBTYPE_UVAXIII 12 /* * 680x0 subtypes * * The subtype definitions here are unusual for historical reasons. * NeXT used to consider 68030 code as generic 68000 code. For * backwards compatability: * * MACHO_CPU_SUBTYPE_MC68030 symbol has been preserved for source code * compatability. * * MACHO_CPU_SUBTYPE_MC680x0_ALL has been defined to be the same * subtype as MACHO_CPU_SUBTYPE_MC68030 for binary comatability. * * MACHO_CPU_SUBTYPE_MC68030_ONLY has been added to allow new object * files to be tagged as containing 68030-specific instructions. */ #define MACHO_CPU_SUBTYPE_MC680x0_ALL 1 #define MACHO_CPU_SUBTYPE_MC68030 1 /* compat */ #define MACHO_CPU_SUBTYPE_MC68040 2 #define MACHO_CPU_SUBTYPE_MC68030_ONLY 3 /* * I386 subtypes. */ #define MACHO_CPU_SUBTYPE_I386_ALL 3 #define MACHO_CPU_SUBTYPE_386 3 #define MACHO_CPU_SUBTYPE_486 4 #define MACHO_CPU_SUBTYPE_486SX 4 + 128 #define MACHO_CPU_SUBTYPE_586 5 #define MACHO_CPU_SUBTYPE_INTEL(f, m) (f + ((m) << 4) #define MACHO_CPU_SUBTYPE_PENT MACHO_CPU_SUBTYPE_INTEL(5, 0) #define MACHO_CPU_SUBTYPE_PENTPRO MACHO_CPU_SUBTYPE_INTEL(6, 1) #define MACHO_CPU_SUBTYPE_PENTII_M3 MACHO_CPU_SUBTYPE_INTEL(6, 3) #define MACHO_CPU_SUBTYPE_PENTII_M5 MACHO_CPU_SUBTYPE_INTEL(6, 5) #define MACHO_CPU_SUBTYPE_INTEL_FAMILY(x) ((x) & 15) #define MACHO_CPU_SUBTYPE_INTEL_FAMILY_MAX 15 #define MACHO_CPU_SUBTYPE_INTEL_MODEL(x) ((x) >> 4) #define MACHO_CPU_SUBTYPE_INTEL_MODEL_ALL 0 /* * Mips subtypes. */ #define MACHO_CPU_SUBTYPE_MIPS_ALL 0 #define MACHO_CPU_SUBTYPE_MIPS_R2300 1 #define MACHO_CPU_SUBTYPE_MIPS_R2600 2 #define MACHO_CPU_SUBTYPE_MIPS_R2800 3 #define MACHO_CPU_SUBTYPE_MIPS_R2000a 4 /* pmax */ #define MACHO_CPU_SUBTYPE_MIPS_R2000 5 #define MACHO_CPU_SUBTYPE_MIPS_R3000a 6 /* 3max */ #define MACHO_CPU_SUBTYPE_MIPS_R3000 7 /* * MC98000 (PowerPC subtypes */ #define MACHO_CPU_SUBTYPE_MC98000_ALL 0 #define MACHO_CPU_SUBTYPE_MC98601 1 /* * HPPA subtypes for Hewlett-Packard HP-PA family of * risc processors. Port by NeXT to 700 series. */ #define MACHO_CPU_SUBTYPE_HPPA_ALL 0 #define MACHO_CPU_SUBTYPE_HPPA_7100 0 /* compat */ #define MACHO_CPU_SUBTYPE_HPPA_7100LC 1 /* * MC88000 subtypes. */ #define MACHO_CPU_SUBTYPE_MC88000_ALL 0 #define MACHO_CPU_SUBTYPE_MC88100 1 #define MACHO_CPU_SUBTYPE_MC88110 2 /* * SPARC subtypes */ #define MACHO_CPU_SUBTYPE_SPARC_ALL 0 /* * I860 subtypes */ #define MACHO_CPU_SUBTYPE_I860_ALL 0 #define MACHO_CPU_SUBTYPE_I860_860 1 /* * PowerPC subtypes */ #define MACHO_CPU_SUBTYPE_POWERPC_ALL 0 #define MACHO_CPU_SUBTYPE_POWERPC_601 1 #define MACHO_CPU_SUBTYPE_POWERPC_602 2 #define MACHO_CPU_SUBTYPE_POWERPC_603 3 #define MACHO_CPU_SUBTYPE_POWERPC_603e 4 #define MACHO_CPU_SUBTYPE_POWERPC_603ev 5 #define MACHO_CPU_SUBTYPE_POWERPC_604 6 #define MACHO_CPU_SUBTYPE_POWERPC_604e 7 #define MACHO_CPU_SUBTYPE_POWERPC_620 8 #define MACHO_CPU_SUBTYPE_POWERPC_750 9 #define MACHO_CPU_SUBTYPE_POWERPC_7400 10 #define MACHO_CPU_SUBTYPE_POWERPC_7450 11 extern byte MACHO_HEADER_struct[]; extern byte MACHO_HEADER_64_struct[]; extern byte MACHO_COMMAND_struct[]; extern byte MACHO_SEGMENT_COMMAND_struct[]; extern byte MACHO_SEGMENT_64_COMMAND_struct[]; extern byte MACHO_SECTION_struct[]; extern byte MACHO_SECTION_64_struct[]; extern byte MACHO_THREAD_COMMAND_struct[]; // .state not included ! extern byte MACHO_PPC_THREAD_STATE_struct[]; extern byte MACHO_PPC_64_THREAD_STATE_struct[]; extern byte MACHO_ARM_THREAD_STATE_struct[]; extern byte MACHO_I386_THREAD_STATE_struct[]; extern byte MACHO_X86_64_THREAD_STATE_struct[]; extern byte MACHO_SYMTAB_COMMAND_struct[]; extern byte MACHO_SYMTAB_NLIST_struct[]; extern byte MACHO_SYMTAB_NLIST_64_struct[]; #endif /* __MACHOSTRUC_H__ */ ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/info/�������������������������������������������������������������������������������������0000755�0001750�0001750�00000000000�12156433676�010161� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/info/infoview.cc��������������������������������������������������������������������������0000644�0001750�0001750�00000034220�12127651420�012222� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * infoview.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <stdlib.h> #include <string.h> #include "htdoc.h" #include "htiobox.h" #include "htpal.h" #include "strtools.h" #include "snprintf.h" #include "tools.h" #include "infoview.h" class info_pos: public Object { public: uint line; uint ofs; info_pos(uint l, uint o) { line = l; ofs = o; } virtual int compareTo(const Object *data_b) const { info_pos *b = (info_pos*)data_b; uint da = line; uint db = b->line; if (da == db) { return ofs - b->ofs; } return da - db; } }; class info_xref: public Object { public: char *target; uint len; info_xref(const char *t, uint l) { target = ht_strdup(t); len = l; } ~info_xref() { free(target); } }; // FIXME: this function is considered harmful char *memndup(const char *s, int n) { char *q = ht_malloc(n+1); memcpy(q, s, n); q[n] = 0; return q; } /* * */ bool parse_xref_body(File *f, Container *t, const char *&n, uint *o, uint *line, bool note) { whitespaces(n); const char *l = strchr(n, ':'); if (!l) return false; const char *e = l; while (e > n && ((unsigned char)e[-1]) <= 32) e--; char *name = NULL; char *target = NULL; const char *end = l; bool extrabreak=false; l++; whitespaces(l); if (end[1] == ':') { name = memndup(n, e-n); end+=2; } else if ((note && l-1 > end) || (!note && end[1] == ' ')){ if (end[1] == '\n') extrabreak = true; const char *v = l; if (*l == '(') { v = strchr(l, ')'); if (!v) return false; } const char *q = v; while (*q && (*q != '.') && (*q != ',')) q++; if (!*q) return false; const char *p = q; while (q > l && ((unsigned char)q[-1] <= 32)) q--; name = memndup(n, e-n); target = memndup(l, q-l); end = p+1; } else return false; f->write(name, strlen(name)); // fprintf(stderr, "xref: %s -> %s\n", name, ttt); char *thetarget = strdup(target ? target : name); char *ttt = thetarget; while (*ttt) { if (*ttt == '\n') *ttt = ' '; ttt++; } const char *p = name; info_xref *x = new info_xref(thetarget, *o); t->insert(new KeyValue(new info_pos(*line, *o), x)); while (*p) { if (*p == '\n') { x->len = *o - x->len; *o = 0; (*line)++; x = new info_xref(thetarget, *o); t->insert(new KeyValue(new info_pos(*line, *o), x)); } else { (*o)++; } p++; } x->len = *o - x->len; if (extrabreak) { char cr = '\n'; f->write(&cr, 1); *o = 0; (*line)++; } free(thetarget); free(name); free(target); n = end; return true; } Container *parse_info_node(File *fl, const char *infotext) { const char *n = infotext; bool linestart = true; FileOfs f = 0; uint o = 0; uint l = 0; Container *t = new AVLTree(true); while (*n && *n != 0x1f) { const char *on = n; uint oo = o; uint ol = l; FileOfs of = f; const char *k = (*n == '*') ? n : strchr(n, '*'); if (k == n && ht_strnicmp(n, "*note", 5) == 0) { n += 5; if (!parse_xref_body(fl, t, n, &o, &l, true)) { n = on; o = oo; l = ol; f = of; fl->seek(f); goto fallback; } f = fl->tell(); } else if (linestart && k == n && n[1] == ' ') { n++; if (!parse_xref_body(fl, t, n, &o, &l, false)) { n = on; o = oo; l = ol; f = of; fl->seek(f); goto fallback; } f = fl->tell(); } else { fallback: if (k && k > n) { const char *cr = strchr(n, '\n'); if (cr && cr < k) k = cr; if (k-n == 0) goto fallback2; fl->write(n, k-n); linestart = false; o+= k-n; f+= k-n; n+= k-n; } else { fallback2: fl->write(n, 1); if (*n == '\n') { linestart = true; o=0; l++; } else { linestart = false; o++; } n++; f++; } } } // t->set_compare_keys(compare_keys_info_pos); return t; } /* \x1f\nFile:.*\n lex_line = 0; lex_pofs = 0; file_block(&YY_LVALP->node, yytext); lex_ofs += yyleng; return INFO_FILE; \x1f\nTag\ Table:.*\n lex_ofs += strlen(yytext); return INFO_TTBL; \x1f\nEnd\ Tag\ Table.*\n lex_ofs += strlen(yytext); return INFO_ENDTTBL; \*[nN]ote(\ |\n).[^:]*:: xref(&YY_LVALP->xref, yytext, 6); return INFO_XREF; \*[nN]ote(\ |\n).[^:]*:\ ((\(.+\))|.)[^.,]*[.,] xref(&YY_LVALP->xref, yytext, 6); return INFO_XREF; ^\*\ .[^:]*:: xref(&YY_LVALP->xref, yytext, 2); return INFO_XREF; ^\*\ .[^:]*:\ ((\(.+\))|.)[^.,]*[.,] xref(&YY_LVALP->xref, yytext, 2); return INFO_XREF; . lex_ofs++; lex_pofs++; return yytext[0]; \n lex_ofs++; lex_line++; lex_pofs=0; return yytext[0]; */ /* * CLASS ht_info_lexer */ void ht_info_lexer::init(ht_view *pf) { ht_syntax_lexer::init(); xrefs = NULL; cx = 0; cy = 0; pal_from = pf; } lexer_state ht_info_lexer::getinitstate() { return 1; } vcp ht_info_lexer::getcolor_syntax(uint pal_index) { return VCP(VC_WHITE, VC_BLACK); } lexer_token ht_info_lexer::geterrortoken() { return 42; } const char *ht_info_lexer::getname() { return "infoview"; } #define ILT_TEXT 1 #define ILT_LINK 2 #define ILT_LINK_SEL 3 lexer_token ht_info_lexer::gettoken(void *b, uint buflen, text_pos p, bool start_of_line, lexer_state *ret_state, uint *ret_len) { if (buflen) { if (xrefs) { KeyValue qq(new info_pos(p.line, p.pofs), NULL); KeyValue *kv = (KeyValue *)xrefs->get(xrefs->find(&qq)); if (kv) { info_xref *x = (info_xref*)kv->mValue; if (x) { *ret_len = MIN(x->len, buflen); return (cy == p.line && cx >= p.pofs && cx < p.pofs + x->len) ? ILT_LINK_SEL : ILT_LINK; } } } *ret_len = 1; return ILT_TEXT; } else { *ret_len = 0; return 0; } } vcp ht_info_lexer::gettoken_color(lexer_token t) { switch (t) { case ILT_TEXT: return pal_from->getcolor(palidx_generic_text_focused); case ILT_LINK: return pal_from->getcolor(palidx_generic_text_shortcut); case ILT_LINK_SEL: return pal_from->getcolor(palidx_generic_text_shortcut_selected); } return VCP(VC_WHITE, VC_RED); } void ht_info_lexer::set_cursor(uint x, uint y) { cx = x; cy = y; } void ht_info_lexer::set_xrefs(Container *x) { xrefs = x; } /* * CLASS ht_info_textfile */ class info_history_entry: public Object { public: char *cwd; char *file; char *node; uint cursorx; uint cursory; uint xofs; uint top_line; info_history_entry(char *c, char *f, char *n, uint x, uint y, uint xo, uint yo) { cwd = ht_strdup(c); file = ht_strdup(f); node = ht_strdup(n); cursorx = x; cursory = y; xofs = xo; top_line = yo; } ~info_history_entry() { free(cwd); free(file); free(node); } }; ht_info_textfile::ht_info_textfile(File *s, bool own_s, ht_syntax_lexer *l) :ht_ltextfile(s, own_s, l) { start = 0; end = 0; } ht_ltextfile_line *ht_info_textfile::fetch_line(uint line) const { if (line < linecount()) return ht_ltextfile::fetch_line(start+line); return NULL; } uint ht_info_textfile::linecount() const { return end-start; } void ht_info_textfile::set_node(uint ofs, uint len) { uint s, e, t; start = 0; end = ht_ltextfile::linecount(); convert_ofs2line(ofs, &s, &t); convert_ofs2line(ofs+len, &e, &t); start = s; end = e; } /* * CLASS ht_info_viewer */ void ht_info_viewer::init(Bounds *b) { MemoryFile *f = new MemoryFile(); ht_info_textfile *s = new ht_info_textfile(f, true, NULL); ht_text_viewer::init(b, true, s, NULL); cwd = NULL; file = NULL; node = NULL; xrefs = NULL; history = new Array(true); } void ht_info_viewer::done() { delete history; delete xrefs; free(cwd); free(node); free(file); ht_text_viewer::done(); } const char *ht_info_viewer::defaultpalette() { return palkey_generic_help_default; } void ht_info_viewer::draw() { ((ht_info_lexer*)lexer)->set_cursor(physical_cursorx(), cursory+top_line); ht_text_viewer::draw(); } int ht_info_viewer::find_node(const char *infotext, const char *node) { const char *tags[] = {"File", "Node", "Prev", "Next", "Up"}; #define NUM_NODE_TAGS (sizeof (tags) / sizeof (tags[0])) const char *s = infotext; const char *firstnode = NULL; while ((s=strchr(s, 0x1f))) { s++; while ((*s>0) && (*s<32)) s++; const char *cr = strchr(s, '\n'); if (cr) { while (*s && (s<cr)) { whitespaces(s); const char *os = s; for (uint i=0; i<NUM_NODE_TAGS; i++) { uint l = strlen(tags[i]); if (ht_strncmp(s, tags[i], l) == 0 && s[l] == ':') { s += l+1; whitespaces(s); const char *e = strchr(s, ','); if (!e || (e>cr)) e = cr; if (!firstnode && (strcmp(tags[i], "Node") == 0)) { firstnode = cr+1; } if (strcmp(tags[i], "Node") == 0 && (size_t)(e-s) == strlen(node) && ht_strncmp(s, node, e-s)==0) { return cr+1-infotext; } s = e+1; } } if (os == s) break; } } } // if (firstnode) return firstnode-infotext; return -1; } bool ht_info_viewer::gotonode(const char *f, const char *n) { return igotonode(f, n, true); } uint ht_info_viewer::readfile(char *fn, char **text) { FILE *f = fopen(fn, "r"); if (!f) return 0; fseek(f, 0, SEEK_END); int size = ftell(f); fseek(f, 0, SEEK_SET); char *x = ht_malloc(size+1); uint len = fread(x, 1, size, f); x[len] = 0; fclose(f); *text = x; return len; } bool ht_info_viewer::igotonode(const char *f, const char *n, bool add2hist) { char *infotext = NULL; char nfile[HT_NAME_MAX]; nfile[0] = 0; char ncwd[HT_NAME_MAX]; ncwd[0] = 0; bool newnode = !node || (node && (strcmp(node, n) != 0)); int fl = strlen(f)-strlen(MAGIC_HT_HELP); if ((fl>=0) && (strcmp(f+fl, MAGIC_HT_HELP) == 0)) { infotext = strdup(htinfo); strcpy(ncwd, ""); strcpy(nfile, MAGIC_HT_HELP); } else { char ff[HT_NAME_MAX], cff[HT_NAME_MAX]; cff[0] = 0; if (file && sys_common_canonicalize(cff, sizeof cff, file, cwd, sys_is_path_delim) != 0) return false; if (sys_common_canonicalize(ff, sizeof ff, f, cwd, sys_is_path_delim) != 0) return false; if ((strcmp(ff, cff) != 0) || newnode) { if (!readfile(ff, &infotext)) return false; char *c; if ((c = sys_dirname(ff))) strcpy(ncwd, c); if (sys_basename(c, ff) == 0) strcpy(nfile, c); free(c); } } if (infotext) { int o = find_node(infotext, n); if (o == -1) { free(infotext); return false; } MemoryFile *m = new MemoryFile(); Container *x = parse_info_node(m, infotext+o); if (x == NULL) { delete m; free(infotext); return false; } free(infotext); /* add to history or not*/ if (add2hist && cwd && file && node) { // fprintf(stderr, "histhist: c:%s, f:%s, n:%s\n", cwd, file, node); history->insert(new info_history_entry( cwd, file, node, cursorx, cursory, xofs, top_line)); } /* now modify text_viewer's state */ delete xrefs; xrefs = x; ht_info_textfile *infofile = new ht_info_textfile(m, true, NULL); ht_info_lexer *infolexer = new ht_info_lexer(); infolexer->init(this); infolexer->set_xrefs(xrefs); infofile->set_node(0, m->getSize()); set_textfile(infofile, true); set_lexer(infolexer, true); cursorx = 0; cursory = 0; xofs = 0; top_line = 0; free(file); file = strdup(nfile); free(cwd); cwd = strdup(ncwd); free(node); node = strdup(n); // fprintf(stderr, "setset: c:%s, f:%s, n:%s\n", cwd, file, node); select_clear(); return true; } return false; } int ht_info_viewer::get_pindicator_str(char *buf, int max_len) { return ht_snprintf(buf, max_len, " %d:%d (%s) %s ", top_line+cursory+1, xofs+cursorx+1, file, node); } void ht_info_viewer::handlemsg(htmsg *msg) { if (msg->msg == msg_keypressed) { switch (msg->data1.integer) { case K_Space: case K_Return: { if (xrefs) { KeyValue p(new info_pos(top_line + cursory, xofs + physical_cursorx()), NULL); KeyValue *kv = (KeyValue*)xrefs->get(xrefs->findLE(&p)); if (kv && kv->compareTo(&p)) { info_xref *x = (info_xref*)kv->mValue; uint cx = physical_cursorx(); info_pos *q = (info_pos*)kv->mKey; if (((q->line != top_line+cursory) || (cx < q->ofs) || (cx >= q->ofs + x->len))) { kv = NULL; } } if (kv) { info_xref *x = (info_xref*)kv->mValue; char *p = NULL, *q = NULL; char *a = x->target; if (*a == '(') { char *b = strchr(a, ')'); if (b) { p = memndup(a+1, b-a-1); q = ht_strdup(b+1); } } if (!p) p = ht_strdup(file); if (!q) q = ht_strdup(x->target); if (!igotonode(p, q, true)) errorbox("help topic '(%s)%s' not found", p, q); free(p); free(q); } clearmsg(msg); dirtyview(); return; } break; } case K_Meta_Backspace: case K_Backspace: { int c; if ((c = history->count())) { info_history_entry *e = (info_history_entry*) (*history)[c-1]; // fprintf(stderr, "backspace: %s, %s\n", e->file, e->node); if (e->node) { if (igotonode(e->file, e->node, false)) { cursorx = e->cursorx; cursory = e->cursory; xofs = e->xofs; top_line = e->top_line; } else { errorbox("help topic '(%s)%s' not found", e->file, e->node); } *history -= c-1; clearmsg(msg); dirtyview(); return; } } break; } case K_Tab: { if (xrefs) { KeyValue p(new info_pos(top_line + cursory, xofs + physical_cursorx()), NULL); KeyValue *kv = (KeyValue *)xrefs->get(xrefs->findG(&p)); if (kv) { info_pos *q = (info_pos*)kv->mKey; goto_line(q->line); cursor_pput(q->ofs); } } clearmsg(msg); dirtyview(); return; } case K_Shift_Tab: { if (xrefs) { KeyValue p(new info_pos(top_line + cursory, xofs + physical_cursorx()), NULL); KeyValue *kv = (KeyValue *)xrefs->get(xrefs->findL(&p)); if (kv) { info_pos *q = (info_pos*)kv->mKey; goto_line(q->line); cursor_pput(q->ofs); } } clearmsg(msg); dirtyview(); return; } } } ht_text_viewer::handlemsg(msg); } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/info/Makefile.am��������������������������������������������������������������������������0000644�0001750�0001750�00000000440�11724770100�012115� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/io/${IO_DIR} \ -I$(top_srcdir)/io -I$(top_srcdir)/eval AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_LIBRARIES = libinfo.a libinfo_a_SOURCES = infoview.cc infoview.h ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/info/infoview.h���������������������������������������������������������������������������0000644�0001750�0000144�00000005115�10615343355�012066� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * infoview.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __INFOVIEW_H__ #define __INFOVIEW_H__ #include "textedit.h" #include "textfile.h" #define MAGIC_HT_HELP "$$HTHELP" /* * CLASS info_node */ class info_node: public Object { public: FileOfs start; uint len; Container *xrefs; info_node(FileOfs start); ~info_node(); }; /* * CLASS ht_info_lexer */ class ht_info_lexer: public ht_syntax_lexer { public: Container *xrefs; uint cx, cy; ht_view *pal_from; void init(ht_view *pal_from); /* overwritten */ virtual vcp getcolor_syntax(uint pal_index); virtual lexer_state getinitstate(); virtual lexer_token geterrortoken(); virtual const char *getname(); virtual lexer_token gettoken(void *buf, uint buflen, text_pos p, bool start_of_line, lexer_state *ret_state, uint *ret_len); virtual vcp gettoken_color(lexer_token t); /* new */ void set_xrefs(Container *xrefs); void set_cursor(uint cx, uint cy); }; /* * CLASS ht_info_textfile */ class ht_info_textfile: public ht_ltextfile { protected: uint start, end; virtual ht_ltextfile_line *fetch_line(uint line) const; public: ht_info_textfile(File *streamfile, bool own_streamfile, ht_syntax_lexer *lexer); /* overwritten */ virtual uint linecount() const; /* new */ void set_node(uint ofs, uint len); }; /* * CLASS ht_info_viewer */ class ht_info_viewer: public ht_text_viewer { protected: char *cwd; char *file; char *node; Container *xrefs; Container *history; int find_node(const char *infofile, const char *node); bool igotonode(const char *file, const char *node, bool add2hist); uint readfile(char *fn, char **text); public: void init(Bounds *b); virtual void done(); /* overwritten */ virtual void draw(); virtual const char *defaultpalette(); virtual int get_pindicator_str(char *buf, int max_len); virtual void handlemsg(htmsg *msg); /* new */ virtual bool gotonode(const char *file, const char *node); }; #endif /* __INFOVIEW_H__ */ ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/info/Makefile.in��������������������������������������������������������������������������0000644�0001750�0001750�00000031344�12127657374�012154� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Makefile.in generated by automake 1.10.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = info DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru libinfo_a_AR = $(AR) $(ARFLAGS) libinfo_a_LIBADD = am_libinfo_a_OBJECTS = infoview.$(OBJEXT) libinfo_a_OBJECTS = $(am_libinfo_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libinfo_a_SOURCES) DIST_SOURCES = $(libinfo_a_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ HT_LDFLAGS = @HT_LDFLAGS@ HT_LIBS = @HT_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IO_DIR = @IO_DIR@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ LZO_LIBS = @LZO_LIBS@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ curses_CPPFLAGS = @curses_CPPFLAGS@ curses_LIBS = @curses_LIBS@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ ncurses_config = @ncurses_config@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/io/${IO_DIR} \ -I$(top_srcdir)/io -I$(top_srcdir)/eval AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_LIBRARIES = libinfo.a libinfo_a_SOURCES = infoview.cc infoview.h all: all-am .SUFFIXES: .SUFFIXES: .cc .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign info/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign info/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libinfo.a: $(libinfo_a_OBJECTS) $(libinfo_a_DEPENDENCIES) -rm -f libinfo.a $(libinfo_a_AR) libinfo.a $(libinfo_a_OBJECTS) $(libinfo_a_LIBADD) $(RANLIB) libinfo.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/infoview.Po@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/httext.h����������������������������������������������������������������������������������0000644�0001750�0000144�00000003652�10620173115�010620� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * httext.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTTEXT_H__ #define __HTTEXT_H__ #include "htformat.h" #include "formats.h" #define TEXT_DESC "text" extern format_viewer_if httext_if; /* * CLASS ht_text_viewer */ class ht_text_viewer2: public ht_uformat_viewer { public: /* overwritten */ virtual void handlemsg(htmsg *msg); }; /* * CLASS ht_text_sub */ class ht_text_sub: public ht_linear_sub { protected: /* new */ uint find_linelen_backwd(byte *buf, uint maxbuflen, FileOfs ofs, int *le_len); uint find_linelen_forwd(byte *buf, uint maxbuflen, FileOfs ofs, int *le_len); virtual byte *match_lineend_forwd(byte *buf, uint buflen, int *le_len); virtual byte *match_lineend_backwd(byte *buf, uint buflen, int *le_len); public: void init(File *file, FileOfs offset, int size); virtual void done(); /* overwritten */ virtual bool convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id); virtual bool convert_id_to_ofs(const LINE_ID line_id, FileOfs *offset); virtual void first_line_id(LINE_ID *line_id); virtual bool getline(char *line, int maxlen, const LINE_ID line_id); virtual void last_line_id(LINE_ID *line_id); virtual int next_line_id(LINE_ID *line_id, int n); virtual int prev_line_id(LINE_ID *line_id, int n); }; #endif /* !__HTTEXT_H__ */ ��������������������������������������������������������������������������������������ht-2.0.22/htelf.h�����������������������������������������������������������������������������������0000644�0001750�0001750�00000012223�12127651417�010412� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * htelf.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTELF_H__ #define __HTELF_H__ #include "elfstruc.h" #include "formats.h" #include "endianess.h" #include "htformat.h" #include "relfile.h" #define DESC_ELF "elf - unix exe/link format" #define DESC_ELF_HEADER "elf/header" #define DESC_ELF_SECTION_HEADERS "elf/section headers" #define DESC_ELF_PROGRAM_HEADERS "elf/program headers" #define DESC_ELF_SYMTAB "elf/symbol table %y (%d)" #define DESC_ELF_RELOCTAB "elf/relocation table %y (%d)" #define DESC_ELF_IMAGE "elf/image" #define ATOM_ELF_CLASS 0x454c4600 #define ATOM_ELF_CLASS_STR "454c4600" #define ATOM_ELF_DATA 0x454c4601 #define ATOM_ELF_DATA_STR "454c4601" #define ATOM_ELF_OS_ABI 0x454c4602 #define ATOM_ELF_OS_ABI_STR "454c4602" #define ATOM_ELF_TYPE 0x454c4603 #define ATOM_ELF_TYPE_STR "454c4603" #define ATOM_ELF_MACHINE 0x454c4604 #define ATOM_ELF_MACHINE_STR "454c4604" #define ATOM_ELF_SH_TYPE 0x454c4605 #define ATOM_ELF_SH_TYPE_STR "454c4605" #define ATOM_ELF_SH_FLAGS 0x454c4606 #define ATOM_ELF_SH_FLAGS_STR "454c4606" #define ATOM_ELF_PH_TYPE 0x454c4607 #define ATOM_ELF_PH_TYPE_STR "454c4607" #define ATOM_ELF_PH_FLAGS 0x454c4608 #define ATOM_ELF_PH_FLAGS_STR "454c4608" #define ATOM_ELF_ST_BIND 0x454c4609 #define ATOM_ELF_ST_BIND_STR "454c4609" #define ATOM_ELF_ST_TYPE 0x454c460a #define ATOM_ELF_ST_TYPE_STR "454c460a" #define ATOM_ELF_R_386_TYPE 0x454c460b #define ATOM_ELF_R_386_TYPE_STR "454c460b" #define ATOM_ELF_R_X86_64_TYPE 0x454c460c #define ATOM_ELF_R_X86_64_TYPE_STR "454c460c" extern format_viewer_if htelf_if; class FakeAddr: public Object { public: uint secidx; uint symidx; uint32 addr; FakeAddr(uint asecidx, uint asymidx, uint32 aAddr) : secidx(asecidx), symidx(asymidx), addr(aAddr) { } virtual int compareTo(const Object *) const; }; struct elf_section_headers { uint count; union { ELF_SECTION_HEADER32 *sheaders32; ELF_SECTION_HEADER64 *sheaders64; }; }; union elf_section_header { ELF_SECTION_HEADER32 sheaders32; ELF_SECTION_HEADER64 sheaders64; }; struct elf_program_headers { uint count; union { ELF_PROGRAM_HEADER32 *pheaders32; ELF_PROGRAM_HEADER64 *pheaders64; }; }; struct ht_elf_reloc_section32 { elf32_addr relocAddr; uint relocShIdx; }; struct ht_elf_shared_data { FileOfs header_ofs; ELF_HEADER ident; Endianess byte_order; union { ELF_HEADER32 header32; ELF_HEADER64 header64; }; elf_section_headers sheaders; ht_elf_reloc_section32 *shrelocs; char **shnames; elf_program_headers pheaders; uint symtables; uint reloctables; ht_format_viewer *v_image; int fake_undefined_shidx; uint fake_undefined_size; Container *undefined2fakeaddr; }; /* * ht_elf */ class ht_elf: public ht_format_group { protected: bool loc_enum; /* new */ void auto_relocate32(); void fake_undefined_symbols32(); uint find_reloc_section_for(uint si); void relocate_section(ht_reloc_file *f, uint si, uint rsi, elf32_addr a); public: void init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs); virtual void done(); /* extends ? */ virtual void loc_enum_start(); virtual bool loc_enum_next(ht_format_loc *loc); }; /* * ht_elf32_reloc_entry */ class ht_elf32_reloc_entry: public Object { public: uint type; union { uint32 r_32; uint32 r_pc32; } relocs; ht_elf32_reloc_entry(uint type, uint32 A, uint32 P, uint32 S); }; /* * ht_elf32_reloc_file */ class ht_elf32_reloc_file: public ht_reloc_file { protected: ht_elf_shared_data *data; /* extends ht_reloc_file */ virtual void reloc_apply(Object *reloc, byte *data); virtual bool reloc_unapply(Object *reloc, byte *data); public: ht_elf32_reloc_file(File *File, bool own_streamfile, ht_elf_shared_data *data); }; bool isValidELFSectionIdx(ht_elf_shared_data *elf_shared, int idx); bool elf_phys_and_mem_section(elf_section_header *s, uint elfclass); bool elf_valid_section(elf_section_header *s, uint elfclass); bool elf_addr_to_section(elf_section_headers *section_headers, uint elfclass, ELFAddress addr, int *section); bool elf_addr_to_ofs(elf_section_headers *section_headers, uint elfclass, ELFAddress addr, FileOfs *ofs); bool elf_addr_is_valid(elf_section_headers *section_headers, uint elfclass, ELFAddress addr); bool elf_ofs_to_addr(elf_section_headers *section_headers, uint elfclass, FileOfs ofs, ELFAddress *addr); bool elf_ofs_to_section(elf_section_headers *section_headers, uint elfclass, FileOfs ofs, uint32 *section); #endif /* !__HTELF_H__ */ �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/relfile.h���������������������������������������������������������������������������������0000644�0001750�0000144�00000002560�10615341624�010725� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * relfile.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __RELFILE_H__ #define __RELFILE_H__ #include "data.h" #include "stream.h" /* * CLASS ht_reloc_file */ class ht_reloc_file: public FileLayer { protected: Container *relocs; bool enabled; /* new */ virtual void reloc_apply(Object *reloc, byte *data) = 0; virtual bool reloc_unapply(Object *reloc, byte *data) = 0; public: ht_reloc_file(File *File, bool own_streamfile); virtual ~ht_reloc_file(); /* overwritten */ void finalize(); void insert_reloc(FileOfs o, Object *reloc); virtual uint read(void *buf, uint size); virtual int vcntl(uint cmd, va_list vargs); virtual uint write(const void *buf, uint size); }; #endif /* __RELFILE_H__ */ ������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/htsearch.cc�������������������������������������������������������������������������������0000644�0001750�0000144�00000107173�11724435030�011245� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * htsearch.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "atom.h" #include "cmds.h" #include "htctrl.h" #include "hthist.h" #include "htiobox.h" #include "keyb.h" #include "htsearch.h" #include "strtools.h" #include "htprocess.h" #include "snprintf.h" extern "C" { #include "evalx.h" } union search_pos { FileOfs offset; viewer_pos pos; }; /* FIXME: get rid of global vars */ uint lastsearchmodeid = 0; uint lastreplacemodeid = 0; typedef ht_search_request* (*create_request_func)(search_pos *ret_start, search_pos *ret_end, ht_view *form, ht_format_viewer *format, uint search_class); typedef Object* (*create_replace_context_func)(File *file, FileOfs ofs, FileOfs len, ht_view *form, FileOfs *return_repllen); struct ht_search_method { const char *name; uint search_class; // SC_* uint search_mode_mask; // SEARCHMODE_* uint histid; create_form_func create_form; create_request_func create_request; create_desc_func create_desc; }; struct ht_replace_method { const char *name; uint histid; create_form_func create_form; create_replace_context_func create_replace_context; process_func replace_process; }; #include <stdlib.h> #include <string.h> static bool test_str_to_ofs(FileOfs *ofs, byte *str, uint strlen, ht_format_viewer *format, const char *desc) { #define TEST_STR_TO_OFS_MAXSTRLEN 128 if (strlen > TEST_STR_TO_OFS_MAXSTRLEN) { throw MsgfException("%s: expression too long (len %d, max %d)", desc, strlen, TEST_STR_TO_OFS_MAXSTRLEN); return false; } if (strlen > 0) { char s[TEST_STR_TO_OFS_MAXSTRLEN+1]; bin2str(s, str, strlen); if (!format->string_to_offset(s, ofs)) { throw MsgfException("%s: invalid expression: '%s'", desc, s); return false; } } return true; } static bool test_str_to_pos(viewer_pos *pos, byte *str, uint strlen, ht_format_viewer *format, const char *desc) { #define TEST_STR_TO_POS_MAXSTRLEN 128 if (strlen > TEST_STR_TO_POS_MAXSTRLEN) { throw MsgfException("%s: expression too long (len %d, max %d)", desc, strlen, TEST_STR_TO_POS_MAXSTRLEN); } if (strlen > 0) { char s[TEST_STR_TO_POS_MAXSTRLEN+1]; bin2str(s, str, strlen); if (!format->string_to_pos(s, pos)) { throw MsgfException("%s: invalid expression: '%s'", desc, s); } } return true; } /* * CLASS ht_fxbin_search_request */ ht_view* create_form_hexascii(Bounds *b, uint histid) { ht_hexascii_search_form *form = new ht_hexascii_search_form(); form->init(b, 0, (List*)getAtomValue(histid)); return form; } ht_search_request* create_request_hexascii(search_pos *start, search_pos *end, ht_view *f, ht_format_viewer *format, uint search_class) { ht_hexascii_search_form *form = (ht_hexascii_search_form*)f; ht_hexascii_search_form_data d; ViewDataBuf vdb(form, &d, sizeof d); ht_fxbin_search_request *request; if (!d.str.textlen) { throw MsgfException("%s: string is empty", "hex/ascii"); } if (test_str_to_ofs(&start->offset, d.start.text, d.start.textlen, format, "start-offset") && test_str_to_ofs(&end->offset, d.end.text, d.end.textlen, format, "end-offset")) { request = new ht_fxbin_search_request(search_class, d.options.state & 1 ? SF_FXBIN_CASEINSENSITIVE: 0, d.str.textlen, d.str.text); } else { request = NULL; } return request; } void create_desc_hexascii(char *buf, int buflen, ht_view *f) { ht_hexascii_search_form *form=(ht_hexascii_search_form*)f; ht_hexascii_search_form_data d; ViewDataBuf vdb(form, &d, sizeof d); if (!d.str.textlen) { throw MsgfException("%s: string is empty", "hex/ascii"); } char *b = buf; b += escape_special(b, buflen, d.str.text, d.str.textlen, NULL, false); strncat(b, " (", buflen-(b-buf)); if (d.options.state & 1) { strncat(b, "case-insensitive", buflen-(b-buf)); } else { strncat(b, "case-sensitive", buflen-(b-buf)); } if (d.start.textlen) { strncat(b, ", start=", buflen-(b-buf)); if (b-buf<buflen) b+=strlen(b); b += escape_special(b, buflen-(b-buf), d.start.text, d.start.textlen); } if (d.end.textlen) { strncat(b, ", end=", buflen-(b-buf)); if (b-buf<buflen) b+=strlen(b); b += escape_special(b, buflen-(b-buf), d.end.text, d.end.textlen); } strncat(b, ")", buflen-(b-buf)); } /***/ ht_view* create_form_evalstr(Bounds *b, uint histid) { ht_evalstr_search_form *form=new ht_evalstr_search_form(); form->init(b, 0, (List*)getAtomValue(histid)); return form; } ht_search_request* create_request_evalstr(search_pos *start, search_pos *end, ht_view *f, ht_format_viewer *format, uint search_class) { #define EVALSTR_MAXSTRLEN 256 ht_evalstr_search_form *form=(ht_evalstr_search_form*)f; ht_evalstr_search_form_data d; ViewDataBuf vdb(form, &d, sizeof d); ht_fxbin_search_request *request = NULL; if (!d.str.textlen) { throw MsgfException("%s: string is empty", "eval str"); } else if (d.str.textlen<=EVALSTR_MAXSTRLEN) { char strbuf[EVALSTR_MAXSTRLEN+1]; bin2str(strbuf, d.str.text, d.str.textlen); eval_scalar r; eval_str s; if (eval(&r, strbuf, NULL, NULL, NULL)) { scalar_context_str(&r, &s); scalar_destroy(&r); if (test_str_to_ofs(&start->offset, d.start.text, d.start.textlen, format, "start-offset") && test_str_to_ofs(&end->offset, d.end.text, d.end.textlen, format, "end-offset")) { request = new ht_fxbin_search_request(search_class, d.options.state & 1 ? SF_FXBIN_CASEINSENSITIVE: 0, s.len, (byte*)s.value); } } else { const char *str; int pos; get_eval_error(&str, &pos); throw MsgfException("eval error at pos %d: %s", pos, str); } } else { throw MsgfException("%s: expression too long (len %d, max %d)", "eval str", d.str.textlen, EVALSTR_MAXSTRLEN); } return request; } void create_desc_evalstr(char *buf, int buflen, ht_view *f) { ht_evalstr_search_form *form=(ht_evalstr_search_form*)f; ht_evalstr_search_form_data d; ViewDataBuf vdb(form, &d, sizeof d); if (!d.str.textlen) { throw MsgfException("%s: string is empty", "eval str"); } char *b = buf; b += escape_special(b, buflen, d.str.text, d.str.textlen, NULL, false); strncat(b, " (", buflen-(b-buf)); if (d.options.state & 1) { strncat(b, "case-insensitive", buflen-(b-buf)); } else { strncat(b, "case-sensitive", buflen-(b-buf)); } if (d.start.textlen) { strncat(b, ", start=", buflen-(b-buf)); if (b-buf<buflen) b+=strlen(b); b+=escape_special(b, buflen-(b-buf), d.start.text, d.start.textlen); } if (d.end.textlen) { strncat(b, ", end=", buflen-(b-buf)); if (b-buf<buflen) b+=strlen(b); b+=escape_special(b, buflen-(b-buf), d.end.text, d.end.textlen); } strncat(b, ")", buflen-(b-buf)); } /***/ ht_fxbin_search_request::ht_fxbin_search_request(uint search_class, uint flags, uint ds, byte *d) : ht_search_request(search_class, ST_FXBIN, flags) { data_size = ds; data = ht_malloc(data_size); memcpy(data, d, data_size); } ht_fxbin_search_request::~ht_fxbin_search_request() { free(data); } ht_fxbin_search_request *ht_fxbin_search_request::clone() const { return new ht_fxbin_search_request(search_class, flags, data_size, data); } /* * CLASS ht_regex_search_request */ ht_view* create_form_vregex(Bounds *b, uint histid) { ht_vregex_search_form *form=new ht_vregex_search_form(); form->init(b, 0, (List*)getAtomValue(histid)); return form; } ht_search_request* create_request_vregex(search_pos *start, search_pos *end, ht_view *f, ht_format_viewer *format, uint search_class) { #define VREGEX_MAXSTRLEN 256 ht_vregex_search_form *form=(ht_vregex_search_form*)f; ht_vregex_search_form_data d; ViewDataBuf vdb(form, &d, sizeof d); ht_regex_search_request *request=NULL; if (!d.str.textlen) { throw MsgfException("%s: string is empty", "regex"); } else if (d.str.textlen <= VREGEX_MAXSTRLEN) { char strbuf[VREGEX_MAXSTRLEN+1]; bin2str(strbuf, d.str.text, d.str.textlen); if (test_str_to_pos(&start->pos, d.start.text, d.start.textlen, format, "start-address") && test_str_to_pos(&end->pos, d.end.text, d.end.textlen, format, "end-address")) { request = new ht_regex_search_request(search_class, d.options.state & 1 ? SF_REGEX_CASEINSENSITIVE : 0, strbuf); } } else { throw MsgfException("%s: expression too long (size %d, max %d)", "regex", strlen, VREGEX_MAXSTRLEN); } return request; } void create_desc_vregex(char *buf, int buflen, ht_view *f) { ht_vregex_search_form *form=(ht_vregex_search_form*)f; ht_vregex_search_form_data d; ViewDataBuf vdb(form, &d, sizeof d); if (!d.str.textlen) { throw MsgfException("%s: string is empty", "regex"); } char *b = buf; b += escape_special(b, buflen, d.str.text, d.str.textlen, NULL, false); strncat(b, " (", buflen-(b-buf)); if (d.options.state & 1) { strncat(b, "case-insensitive", buflen-(b-buf)); } else { strncat(b, "case-sensitive", buflen-(b-buf)); } if (d.start.textlen) { strncat(b, ", start=", buflen-(b-buf)); if (b-buf<buflen) b+=strlen(b); b+=escape_special(b, buflen-(b-buf), d.start.text, d.start.textlen); } if (d.end.textlen) { strncat(b, ", end=", buflen-(b-buf)); if (b-buf<buflen) b+=strlen(b); b+=escape_special(b, buflen-(b-buf), d.end.text, d.end.textlen); } strncat(b, ")", buflen-(b-buf)); } /***/ ht_regex_search_request::ht_regex_search_request(uint search_class, uint flags, char *regex) : ht_search_request(search_class, ST_REGEX, flags) { rx_str = ht_strdup(regex); int r = regcomp(&rx, rx_str, REG_EXTENDED | ((flags & SF_REGEX_CASEINSENSITIVE) ? REG_ICASE : 0)); if (r) throw ht_regex_search_exception(r, &rx); } ht_regex_search_request::~ht_regex_search_request() { regfree(&rx); free(rx_str); } ht_regex_search_request *ht_regex_search_request::clone() const { return new ht_regex_search_request(search_class, flags, rx_str); } /* * CLASS ht_regex_search_request */ ht_regex_search_exception::ht_regex_search_exception(int e, regex_t *r) { char s[128]; regerror(e, r, s, sizeof s); ht_snprintf(rxerr, sizeof rxerr, "error compiling regex: %s", s); } String &ht_regex_search_exception::reason(String &s) const { return s = rxerr; } /* * CLASS ht_expr_search_request */ ht_view* create_form_expr(Bounds *b, uint histid) { ht_expr_search_form *form = new ht_expr_search_form(); form->init(b, 0, (List*)getAtomValue(histid)); return form; } ht_search_request* create_request_expr(search_pos *start, search_pos *end, ht_view *f, ht_format_viewer *format, uint search_class) { #define EXPR_MAXSTRLEN 256 ht_expr_search_form *form=(ht_expr_search_form*)f; ht_expr_search_form_data d; ViewDataBuf vdb(form, &d, sizeof d); ht_expr_search_request *request = NULL; if (!d.str.textlen) { throw MsgfException("%s: string is empty", "expr"); } else if (d.str.textlen <= EXPR_MAXSTRLEN) { char strbuf[EXPR_MAXSTRLEN+1]; bin2str(strbuf, d.str.text, d.str.textlen); if (test_str_to_ofs(&start->offset, d.start.text, d.start.textlen, format, "start-offset") && test_str_to_ofs(&end->offset, d.end.text, d.end.textlen, format, "end-offset")) { request = new ht_expr_search_request(search_class, 0, strbuf); } } else { throw MsgfException("%s: expression too long (size %d, max %d)", "expr", strlen, EXPR_MAXSTRLEN); } return request; } void create_desc_expr(char *buf, int buflen, ht_view *f) { ht_vregex_search_form *form=(ht_vregex_search_form*)f; ht_vregex_search_form_data d; ViewDataBuf vdb(form, &d, sizeof d); if (!d.str.textlen) { throw MsgfException("%s: string is empty", "expr"); } char *b = buf; b += escape_special(b, buflen, d.str.text, d.str.textlen, NULL, false); strncat(b, " (", buflen-(b-buf)); if (d.options.state & 1) { strncat(b, "case-insensitive", buflen-(b-buf)); } else { strncat(b, "case-sensitive", buflen-(b-buf)); } if (d.start.textlen) { strncat(b, ", start=", buflen-(b-buf)); if (b-buf<buflen) b+=strlen(b); b+=escape_special(b, buflen-(b-buf), d.start.text, d.start.textlen); } if (d.end.textlen) { strncat(b, ", end=", buflen-(b-buf)); if (b-buf<buflen) b+=strlen(b); b+=escape_special(b, buflen-(b-buf), d.end.text, d.end.textlen); } strncat(b, ")", buflen-(b-buf)); } /***/ ht_expr_search_request::ht_expr_search_request(uint search_class, uint flags, char *Expr) : ht_search_request(search_class, ST_EXPR, flags) { expr = ht_strdup(Expr); } ht_expr_search_request::~ht_expr_search_request() { free(expr); } ht_expr_search_request *ht_expr_search_request::clone() const { return new ht_expr_search_request(search_class, flags, expr); } /* * binary search */ /* FIXME: put somewhere else */ void bufdowncase(byte *buf, uint32 len) { for (uint32 i=0; i<len; i++) { if (buf[i] >= 'A' && buf[i] <= 'Z') buf[i] += 32; } } #define SEARCH_BUF_SIZE 256*1024 ht_search_bin_context::~ht_search_bin_context() { free(buf); free(pat); } Object* create_search_bin_context(File *file, FileOfs ofs, FileOfs len, byte *pat, uint patlen, uint flags, FileOfs *return_ofs, bool *return_success) { if (patlen > SEARCH_BUF_SIZE) return NULL; ht_search_bin_context *ctx = new ht_search_bin_context(); ctx->file = file; ctx->file_end = false; ctx->ofs = ofs; ctx->flags = flags; ctx->len = len; ctx->pat = ht_malloc(patlen); memcpy(ctx->pat, pat, patlen); ctx->patlen = patlen; ctx->o = ofs; if (ctx->flags & SFBIN_CASEINSENSITIVE) bufdowncase(ctx->pat, ctx->patlen); ctx->buf = ht_malloc(SEARCH_BUF_SIZE); ctx->return_ofs = return_ofs; ctx->return_success = return_success; file->seek(ctx->o); ctx->c = file->read(ctx->buf, SEARCH_BUF_SIZE); ctx->bufptr = ctx->buf; ctx->file_end = (ctx->c != SEARCH_BUF_SIZE); if (ctx->flags & SFBIN_CASEINSENSITIVE) bufdowncase(ctx->buf, ctx->c); return ctx; } bool search_bin_process(Object *context, ht_text *progress_indicator) { ht_search_bin_context *ctx = (ht_search_bin_context*)context; if (ctx->bufptr - ctx->buf + ctx->patlen > ctx->c) { if (ctx->file_end) { *ctx->return_success = false; return false; } ctx->file->seek(ctx->o); ctx->c = ctx->file->read(ctx->buf, SEARCH_BUF_SIZE); ctx->bufptr = ctx->buf; ctx->file_end = (ctx->c != SEARCH_BUF_SIZE); if (ctx->flags & SFBIN_CASEINSENSITIVE) bufdowncase(ctx->buf, ctx->c); } while (ctx->bufptr + ctx->patlen <= ctx->buf + ctx->c) { if (memcmp(ctx->pat, ctx->bufptr, ctx->patlen) == 0) { *ctx->return_success = true; *ctx->return_ofs = ctx->o; return false; } ctx->bufptr++; ctx->o++; } ctx->o -= ctx->patlen-1; int p = (((double)(ctx->o - ctx->ofs))*100/ctx->len); char status[64]; ht_snprintf(status, sizeof status, "%d %% (%d MiB)", p, int ((unsigned long long)ctx->o >> 20)); progress_indicator->settext(status); return true; } /* * CLASS ht_hexascii_search_form */ void ht_hexascii_search_form::init(Bounds *b, int options, List *history) { ht_group::init(b, VO_SELECTABLE, NULL); VIEW_DEBUG_NAME("ht_hexascii_search_form"); Bounds c; /* ascii string */ c.x=6; c.y=0; c.w=b->w-6; c.h=1; str=new ht_strinputfield(); str->init(&c, 64, history); insert(str); /* ascii string label */ c.x=0; c.w=5; c.h=1; ht_label *strlabel=new ht_label(); strlabel->init(&c, "~ascii", str); insert(strlabel); /* hex string */ c.x=6; c.y=2; c.w=b->w-6; c.h=1; ht_hexinputfield *hex=new ht_hexinputfield(); hex->init(&c, 64); hex->attach(str); insert(hex); /* hex string label */ c.x=0; c.w=5; c.h=1; ht_label *hexlabel=new ht_label(); hexlabel->init(&c, "~hex", hex); insert(hexlabel); /* range start */ c.x=10; c.y=4; c.w=10; c.h=1; range_start=new ht_strinputfield(); range_start->init(&c, 10); insert(range_start); /* range start label */ c.x=0; c.w=9; c.h=1; ht_label *rslabel=new ht_label(); rslabel->init(&c, "~from ofs", range_start); insert(rslabel); /* range end */ c.x=10; c.y=6; c.w=10; c.h=1; range_end=new ht_strinputfield(); range_end->init(&c, 10); insert(range_end); /* range end label */ c.x=0; c.w=9; c.h=1; ht_label *relabel=new ht_label(); relabel->init(&c, "~to ofs", range_end); insert(relabel); /* options */ c.w=35; c.y=8; c.h=2; ht_string_list *opts = new ht_string_list(); opts->init(); opts->insert_string("case ~insensitive"); option_boxes = new ht_checkboxes(); option_boxes->init(&c, opts); ht_checkboxes_data d; d.state = options; option_boxes->databuf_set(&d, sizeof d); insert(option_boxes); } /* * CLASS ht_evalstr_search_form */ void ht_evalstr_search_form::init(Bounds *b, int options, List *history) { ht_group::init(b, VO_SELECTABLE, NULL); VIEW_DEBUG_NAME("ht_evalstr_search_form"); Bounds c; /* string */ c.x=0; c.y=1; c.w=b->w; c.h=1; str=new ht_strinputfield(); str->init(&c, 64, history); insert(str); /* string label */ c.x=0; c.y=0; c.w=23; c.h=1; ht_label *strlabel=new ht_label(); strlabel->init(&c, "s~earch evaluated string", str); insert(strlabel); /* hint */ /* c.x=0; c.y=2; c.w=b->w-2; c.h=1; ht_statictext *hint=new ht_statictext(); hint->init(&c, "(example: \"hello\\n\\0\\077\\xd\" 'ho',011b,66o)", 0); insert(hint);*/ /* range start */ c.x=10; c.y=4; c.w=10; c.h=1; range_start=new ht_strinputfield(); range_start->init(&c, 10); insert(range_start); /* range start label */ c.x=0; c.w=9; c.h=1; ht_label *rslabel=new ht_label(); rslabel->init(&c, "~from ofs", range_start); insert(rslabel); /* range end */ c.x=10; c.y=6; c.w=10; c.h=1; range_end=new ht_strinputfield(); range_end->init(&c, 10); insert(range_end); /* range end label */ c.x=0; c.w=9; c.h=1; ht_label *relabel=new ht_label(); relabel->init(&c, "~to ofs", range_end); insert(relabel); /* options */ c.w = 35; c.y = 8; c.h = 2; ht_string_list *opts = new ht_string_list(); opts->init(); opts->insert_string("case ~insensitive"); option_boxes = new ht_checkboxes(); option_boxes->init(&c, opts); ht_checkboxes_data d; d.state = options; option_boxes->databuf_set(&d, sizeof d); insert(option_boxes); } /* * CLASS ht_vregex_search_form */ void ht_vregex_search_form::init(Bounds *b, int options, List *history) { ht_group::init(b, VO_SELECTABLE, NULL); VIEW_DEBUG_NAME("ht_text_search_form"); Bounds c; /* string */ c.x=0; c.y=1; c.w=b->w; c.h=1; str=new ht_strinputfield(); str->init(&c, 64, history); insert(str); /* string label */ c.x=0; c.y=0; c.w=12; c.h=1; ht_label *strlabel=new ht_label(); strlabel->init(&c, "s~earch regex", str); insert(strlabel); /* range start */ c.x=10; c.y=4; c.w=10; c.h=1; range_start=new ht_strinputfield(); range_start->init(&c, 10); insert(range_start); /* range start label */ c.x=0; c.w=9; c.h=1; ht_label *rslabel=new ht_label(); rslabel->init(&c, "~from addr", range_start); insert(rslabel); /* range end */ c.x=10; c.y=6; c.w=10; c.h=1; range_end=new ht_strinputfield(); range_end->init(&c, 10); insert(range_end); /* range end label */ c.x=0; c.w=9; c.h=1; ht_label *relabel=new ht_label(); relabel->init(&c, "~to addr", range_end); insert(relabel); /* options */ c.w = 35; c.y = 8; c.h = 2; ht_string_list *opts = new ht_string_list(); opts->init(); opts->insert_string("case ~insensitive"); option_boxes = new ht_checkboxes(); option_boxes->init(&c, opts); ht_checkboxes_data d; d.state = options; option_boxes->databuf_set(&d, sizeof d); insert(option_boxes); } /* * CLASS ht_expr_search_form */ void ht_expr_search_form::init(Bounds *b, int options, List *history) { ht_group::init(b, VO_SELECTABLE, NULL); VIEW_DEBUG_NAME("ht_expr_search_form"); Bounds c; /* string */ c.x=0; c.y=1; c.w=b->w; c.h=1; str=new ht_strinputfield(); str->init(&c, 256, history); insert(str); /* string label */ c.x=0; c.y=0; c.w=17; c.h=1; ht_label *strlabel=new ht_label(); strlabel->init(&c, "s~earch expression", str); insert(strlabel); /* hint */ c.x=0; c.y=2; c.w=b->w-2; c.h=1; ht_statictext *hint=new ht_statictext(); hint->init(&c, "stops if expression evaluates to non-zero", align_left); insert(hint); /* range start */ c.x=10; c.y=4; c.w=10; c.h=1; range_start=new ht_strinputfield(); range_start->init(&c, 10); insert(range_start); /* range start label */ c.x=0; c.w=9; c.h=1; ht_label *rslabel=new ht_label(); rslabel->init(&c, "~from ofs", range_start); insert(rslabel); /* range end */ c.x=10; c.y=6; c.w=10; c.h=1; range_end=new ht_strinputfield(); range_end->init(&c, 10); insert(range_end); /* range end label */ c.x=0; c.w=9; c.h=1; ht_label *relabel=new ht_label(); relabel->init(&c, "~to ofs", range_end); insert(relabel); /* options */ /* c.w=35; c.y=8; c.h=2; ht_string_list *opts=new ht_string_list(); opts->init(); option_boxes=new ht_checkboxes(); option_boxes->init(&c, opts); ht_checkboxes_data d; d.state=options; option_boxes->databuf_set(&d); insert(option_boxes);*/ } /* * CLASS ht_replace_hexascii_search_form */ ht_replace_bin_context::~ht_replace_bin_context() { free(repl); } ht_view* create_form_replace_hexascii(Bounds *b, uint histid) { ht_replace_hexascii_search_form *form=new ht_replace_hexascii_search_form(); form->init(b, 0, (List*)getAtomValue(histid)); return form; } Object* create_replace_hexascii_context(File *file, FileOfs ofs, FileOfs len, ht_view *form, FileOfs *return_repllen) { ht_replace_hexascii_search_form_data d; ViewDataBuf vdb(form, &d, sizeof d); ht_replace_bin_context *ctx = (ht_replace_bin_context*) create_replace_bin_context(file, ofs, len, d.str.text, d.str.textlen, return_repllen); return ctx; } void ht_replace_hexascii_search_form::init(Bounds *b, int options, List *history) { ht_group::init(b, VO_SELECTABLE, NULL); VIEW_DEBUG_NAME("ht_replace_hexascii_search_form"); Bounds c; /* ascii string */ c.x=6; c.y=0; c.w=40; c.h=1; str=new ht_strinputfield(); str->init(&c, 64, history); insert(str); /* ascii string label */ c.x=0; c.w=5; c.h=1; ht_label *strlabel=new ht_label(); strlabel->init(&c, "~ascii", str); insert(strlabel); /* hex string */ c.x=6; c.y=2; c.w=40; c.h=1; ht_hexinputfield *hex=new ht_hexinputfield(); hex->init(&c, 64); hex->attach(str); insert(hex); /* hex string label */ c.x=0; c.w=5; c.h=1; ht_label *hexlabel=new ht_label(); hexlabel->init(&c, "~hex", hex); insert(hexlabel); } /* * */ static ht_search_method search_methods[] = { { "bin: hex/ascii", SC_PHYSICAL, SEARCHMODE_BIN, HISTATOM_SEARCH_BIN, create_form_hexascii, create_request_hexascii, create_desc_hexascii }, { "bin: eval str", SC_PHYSICAL, SEARCHMODE_EVALSTR, HISTATOM_SEARCH_EVALSTR, create_form_evalstr, create_request_evalstr, create_desc_evalstr }, { "display: regex", SC_VISUAL, SEARCHMODE_VREGEX, HISTATOM_SEARCH_VREGEX, create_form_vregex, create_request_vregex, create_desc_vregex }, { "expr non-zero", SC_PHYSICAL, SEARCHMODE_EXPR, HISTATOM_SEARCH_EXPR, create_form_expr, create_request_expr, create_desc_expr }, { NULL } }; ht_search_request *search_dialog(ht_format_viewer *format, uint searchmodes, viewer_pos *start, viewer_pos *end) { ht_search_request *result = NULL; Bounds b; b.w = 50; b.h = 15; b.x = (screen->w - b.w)/2; b.y = (screen->h - b.h)/2; ht_search_dialog *dialog = new ht_search_dialog(); dialog->init(&b, "search"); Bounds k; dialog->search_mode_xgroup->getbounds(&k); k.x = 0; k.y = 0; int modes = 0; int i = 0; ht_search_method *q = search_methods; while (q->name) { if (q->search_mode_mask & searchmodes) { Bounds v = k; ht_view *form = q->create_form(&v, q->histid); dialog->insert_search_mode(i, q->name, form); modes++; } q++; i++; } dialog->select_search_mode(lastsearchmodeid); if (dialog->run(false)) { int modeid = dialog->get_search_modeid(); lastsearchmodeid = modeid; ht_search_method *s = &search_methods[modeid]; ht_view *form = dialog->get_search_modeform(); search_pos sstart, send; try { /* create history entry */ if (s->create_desc) { char hist_desc[1024]; s->create_desc(hist_desc, sizeof hist_desc, form); insert_history_entry((List*)getAtomValue(s->histid), hist_desc, form); } /* create request */ switch (s->search_class) { case SC_PHYSICAL: if (!format->pos_to_offset(*start, &sstart.offset)) { throw MsgfException("Internal error: can't convert viewer_pos to offset"); } if (!format->pos_to_offset(*end, &send.offset)) { send.offset = -1; } break; case SC_VISUAL: sstart.pos = *start; send.pos = *end; break; } result = s->create_request(&sstart, &send, form, format, s->search_class); switch (s->search_class) { case SC_PHYSICAL: if (!format->offset_to_pos(sstart.offset, start)) { throw MsgfException("Internal error: can't convert offset to viewer_pos"); } if (!format->pos_to_offset(*end, &send.offset)) { send.offset = -1; } break; case SC_VISUAL: *start = sstart.pos; *end = send.pos; break; } } catch (const Exception &e) { errorbox("error: %y", &e); } } dialog->done(); delete dialog; return result; } static ht_replace_method replace_methods[] = { { "bin: hex/ascii", 0, create_form_replace_hexascii, create_replace_hexascii_context, replace_bin_process }, { NULL } }; uint replace_dialog(ht_format_viewer *format, uint searchmodes, bool *cancelled) { *cancelled = false; Bounds b; b.w = 50; b.h = 22; b.x = (screen->w - b.w)/2; b.y = (screen->h - b.h)/2; ht_replace_dialog *dialog = new ht_replace_dialog(); dialog->init(&b); Bounds k; dialog->search_mode_xgroup->getbounds(&k); k.x = 0; k.y = 0; int i; i = 0; ht_search_method *q = search_methods; while (q->name) { if ((q->search_mode_mask & searchmodes) && (q->search_class == SC_PHYSICAL)) { Bounds v = k; ht_view *form = q->create_form(&v, q->histid); dialog->insert_search_mode(i, q->name, form); } q++; i++; } dialog->replace_mode_xgroup->getbounds(&k); k.x = 0; k.y = 0; i = 0; ht_replace_method *w = replace_methods; while (w->name) { Bounds v = k; ht_view *form = w->create_form(&v, w->histid); dialog->insert_replace_mode(i, w->name, form); w++; i++; } dialog->select_search_mode(lastsearchmodeid); dialog->select_replace_mode(lastreplacemodeid); uint repl_count = 0; if (dialog->run(false)) { int smodeid = dialog->get_search_modeid(); int rmodeid = dialog->get_replace_modeid(); lastsearchmodeid = smodeid; lastreplacemodeid = rmodeid; ht_search_method *s = &search_methods[smodeid]; ht_replace_method *r = &replace_methods[rmodeid]; ht_view *sform = dialog->get_search_modeform(); ht_view *rform = dialog->get_replace_modeform(); search_pos start, end; ht_search_request *request = NULL; try { /* create history entry */ if (s->create_desc) { char hist_desc[1024]; s->create_desc(hist_desc, sizeof hist_desc, sform); insert_history_entry((List*)getAtomValue(s->histid), hist_desc, sform); } /* search */ start.offset=0; end.offset=0xffffffff; format->get_current_offset(&start.offset); request = s->create_request(&start, &end, sform, format, s->search_class); } catch (const Exception &e) { errorbox("error: %y", &e); } if (request) { FileOfs so = start.offset, eo = end.offset; ht_physical_search_result *result; format->vstate_save(); try { bool replace_all = false; while ((result = (ht_physical_search_result*)format->psearch(request, so, eo))) { FileOfs irepllen = 0; bool do_replace = false; if (!replace_all) { bool showed = format->show_search_result(result); int r = msgbox(btmask_yes+btmask_no+btmask_all+btmask_cancel, "confirmation", 0, align_center, "replace?"); if (showed) app->sendmsg(cmd_vstate_restore); switch (r) { case button_yes: do_replace = true; break; case button_no: break; case button_all: replace_all = true; break; } if (r == button_cancel) { *cancelled = true; delete result; break; } } if (replace_all || do_replace) { Object *rctx = r->create_replace_context(format->get_file(), result->offset, result->size, rform, &irepllen); bool p = execute_process(r->replace_process, rctx); delete rctx; if (!p) { delete result; break; } if (irepllen != result->size) { format->sendmsg(msg_filesize_changed); } so = result->offset + irepllen; repl_count++; } else { so = result->offset + result->size; } delete result; } } catch (const Exception &e) { errorbox("error: %y", &e); } app->sendmsg(cmd_vstate_restore); } delete request; } dialog->done(); delete dialog; return repl_count; } #define REPLACE_COPY_BUF_SIZE 64*1024 Object* create_replace_bin_context(File *file, FileOfs ofs, FileOfs len, byte *repl, FileOfs repllen, FileOfs *return_repllen) { ht_replace_bin_context *ctx = new ht_replace_bin_context(); ctx->file = file; ctx->ofs = ofs; ctx->len = len; ctx->repl = ht_malloc(repllen); memcpy(ctx->repl, repl, repllen); ctx->repllen = repllen; if (repllen > len) { ctx->o = file->getSize(); } else if (len > repllen) { ctx->o = ofs + len; } ctx->z = REPLACE_COPY_BUF_SIZE; if (len != repllen) ctx->buf = ht_malloc(REPLACE_COPY_BUF_SIZE); ctx->return_repllen = return_repllen; return ctx; } bool replace_bin_process(Object *context, ht_text *progress_indicator) { progress_indicator->settext("replacing...\n"); ht_replace_bin_context *c = (ht_replace_bin_context*)context; if (c->repllen > c->len) { /* grow */ uint size = c->file->getSize(); c->file->extend(size + c->repllen - c->len); if (c->o > c->z) { c->o -= c->z; } else { c->z = c->o; c->o = 0; } if (c->o < c->ofs+c->len) { c->z -= c->ofs + c->len - c->o; c->o = c->ofs + c->len; } c->file->seek(c->o); c->file->readx(c->buf, c->z); c->file->seek(c->o + c->repllen - c->len); c->file->writex(c->buf, c->z); if (c->o > c->ofs + c->len) return true; c->file->seek(c->ofs); c->file->writex(c->repl, c->repllen); free(c->buf); } else if (c->repllen < c->len) { /* shrink */ uint size = c->file->getSize(); if (c->o == c->ofs + c->len) { c->file->seek(c->ofs); c->file->writex(c->repl, c->repllen); } if (c->z > size - c->o) { c->z = size - c->o; } c->file->seek(c->o); c->file->readx(c->buf, c->z); c->file->seek(c->o - (c->len - c->repllen)); c->file->writex(c->buf, c->z); c->o += REPLACE_COPY_BUF_SIZE; if (c->z == REPLACE_COPY_BUF_SIZE) return true; c->file->truncate(size - (c->len - c->repllen)); free(c->buf); } else { c->file->seek(c->ofs); c->file->writex(c->repl, c->repllen); } if (c->return_repllen) *c->return_repllen = c->repllen; return false; } /* * CLASS ht_search_dialog */ void ht_search_dialog::init(Bounds *b, const char *title) { ht_dialog::init(b, title, FS_KILLER | FS_TITLE | FS_MOVE); VIEW_DEBUG_NAME("ht_search_dialog"); smodecount = 0; smodeidx = -1; Bounds c; c.x=1; c.y=1; c.w=20; c.h=1; search_mode_popup = new ht_listpopup(); search_mode_popup->init(&c); insert(search_mode_popup); c.x=1; c.y=0; c.w=4; c.h=1; ht_label *mlabel=new ht_label(); mlabel->init(&c, "~mode", search_mode_popup); insert(mlabel); c.x = 1; c.y = 3; c.w = size.w-4; c.h = MIN(10, size.h-4); search_mode_xgroup = new ht_xgroup(); search_mode_xgroup->init(&c, VO_SELECTABLE, "modes"); insert(search_mode_xgroup); } void ht_search_dialog::done() { ht_dialog::done(); } int ht_search_dialog::find_search_mode(int id) { for (int i=0; i<smodecount; i++) { if (smodes[i].id==id) { return i; } } return -1; } void ht_search_dialog::handlemsg(htmsg *msg) { if (msg->msg==msg_keypressed) { ht_dialog::handlemsg(msg); ht_listpopup_data data; ViewDataBuf vdb(search_mode_popup, &data, sizeof data); if ((int)data.cursor_pos != smodeidx) { smodeidx = data.cursor_pos; select_search_mode_bymodeidx(); } } else ht_dialog::handlemsg(msg); } int ht_search_dialog::get_search_modeid() { return smodes[smodeidx].id; } ht_view *ht_search_dialog::get_search_modeform() { return smodes[smodeidx].view; } void ht_search_dialog::insert_search_mode(int id, const char *desc, ht_view *v) { if (smodecount < MAX_SEARCH_DIALOG_MODES) { search_mode_xgroup->insert(v); search_mode_popup->insertstring(desc); smodes[smodecount].id=id; smodes[smodecount].view=v; smodecount++; focus(search_mode_xgroup); } } void ht_search_dialog::select_search_mode(int id) { int i=find_search_mode(id); if (i!=-1) { smodeidx=i; select_search_mode_bymodeidx(); } } void ht_search_dialog::select_search_mode_bymodeidx() { ht_listpopup_data d; d.cursor_pos = smodeidx; d.cursor_string = NULL; search_mode_popup->databuf_set(&d, sizeof d); focus(smodes[smodeidx].view); sendmsg(msg_dirtyview, 0); } /* * CLASS ht_replace_dialog */ void ht_replace_dialog::init(Bounds *b) { ht_search_dialog::init(b, "replace"); rmodecount=0; Bounds c; c.x=1; c.y=15; c.w=20; c.h=1; replace_mode_popup = new ht_listpopup(); replace_mode_popup->init(&c); insert(replace_mode_popup); c.x=0; c.y=13; c.w=size.w-2; c.h=1; ht_hbar *hbar=new ht_hbar(); hbar->init(&c, 0, NULL); insert(hbar); c.x=1; c.y=14; c.w=4; c.h=1; ht_label *mlabel=new ht_label(); mlabel->init(&c, "~replace mode", replace_mode_popup); insert(mlabel); c.x=1; c.y=17; c.w=size.w-4; c.h=size.h-c.y; replace_mode_xgroup = new ht_xgroup(); replace_mode_xgroup->init(&c, VO_SELECTABLE, "replace modes"); insert(replace_mode_xgroup); } void ht_replace_dialog::done() { ht_dialog::done(); } int ht_replace_dialog::find_replace_mode(int id) { for (int i=0; i<rmodecount; i++) { if (rmodes[i].id==id) { return i; } } return -1; } void ht_replace_dialog::handlemsg(htmsg *msg) { if (msg->msg == msg_keypressed) { ht_search_dialog::handlemsg(msg); ht_listpopup_data data; ViewDataBuf vdb(replace_mode_popup, &data, sizeof data); if ((int)data.cursor_pos != rmodeidx) { rmodeidx=data.cursor_pos; select_replace_mode_bymodeidx(); } } else ht_search_dialog::handlemsg(msg); } int ht_replace_dialog::get_replace_modeid() { return rmodes[rmodeidx].id; } ht_view *ht_replace_dialog::get_replace_modeform() { return rmodes[rmodeidx].view; } void ht_replace_dialog::insert_replace_mode(int id, const char *desc, ht_view *v) { if (rmodecount < MAX_REPLACE_DIALOG_MODES) { replace_mode_xgroup->insert(v); replace_mode_popup->insertstring(desc); rmodes[rmodecount].id=id; rmodes[rmodecount].view=v; rmodecount++; // focus(replace_mode_xgroup); } } void ht_replace_dialog::select_replace_mode(int id) { int i=find_replace_mode(id); if (i!=-1) { rmodeidx=i; select_replace_mode_bymodeidx(); } } void ht_replace_dialog::select_replace_mode_bymodeidx() { ht_listpopup_data d; d.cursor_pos = rmodeidx; d.cursor_string = NULL; replace_mode_popup->databuf_set(&d, sizeof d); // focus(rmodes[rmodeidx].view); sendmsg(msg_dirtyview, 0); } /* * */ ht_search_result *linear_bin_search(ht_search_request *search, FileOfs start, FileOfs end, File *file, FileOfs fofs, FileOfs fsize) { ht_fxbin_search_request *s = (ht_fxbin_search_request*)search; int fl = (search->flags & SFBIN_CASEINSENSITIVE) ? SFBIN_CASEINSENSITIVE : 0; if (start < fofs) start = fofs; if (end > fofs+fsize) end = fofs+fsize; if (fsize && start < end) { /* create result */ bool search_success = false; FileOfs search_ofs; Object *ctx = create_search_bin_context(file, start, end-start, s->data, s->data_size, fl, &search_ofs, &search_success); if (execute_process(search_bin_process, ctx)) { delete ctx; if (search_success) { ht_physical_search_result *r=new ht_physical_search_result(); r->offset = search_ofs; r->size = s->data_size; return r; } } else delete ctx; } return NULL; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/���������������������������������������������������������������������������������������0000755�0001750�0001750�00000000000�12156433676�007635� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/file.h���������������������������������������������������������������������������������0000644�0001750�0001750�00000012367�12127651420�010641� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * file.h * * File system functions * * Copyright (C) 1999-2004 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __FILE_H__ #define __FILE_H__ /* Note: all functions only take absolute dir/filenames ! */ #include "types.h" #include "fileofs.h" #include <dirent.h> #include <sys/types.h> #include <time.h> #ifdef PATH_MAX #define HT_NAME_MAX PATH_MAX /* DJGPP at least */ #else #ifdef MAXNAMLEN #define HT_NAME_MAX MAXNAMLEN /* some BSD... */ #else #ifdef NAME_MAX #define HT_NAME_MAX NAME_MAX /* POSIX and friends... */ #else #define HT_NAME_MAX 260 /* unknown... */ #endif #endif #endif #define HT_S_IFREG 0x1000 #define HT_S_IFBLK 0x2000 #define HT_S_IFCHR 0x3000 #define HT_S_IFDIR 0x4000 #define HT_S_IFFIFO 0x5000 #define HT_S_IFLNK 0x6000 #define HT_S_IFSOCK 0x7000 #define HT_S_IFMT 0xf000 #define HT_S_ISREG(m) (((m) & HT_S_IFMT) == HT_S_IFREG) #define HT_S_ISBLK(m) (((m) & HT_S_IFMT) == HT_S_IFBLK) #define HT_S_ISCHR(m) (((m) & HT_S_IFMT) == HT_S_IFCHR) #define HT_S_ISDIR(m) (((m) & HT_S_IFMT) == HT_S_IFDIR) #define HT_S_ISFIFO(m) (((m) & HT_S_IFMT) == HT_S_IFFIFO) #define HT_S_ISLNK(m) (((m) & HT_S_IFMT) == HT_S_IFLNK) #define HT_S_ISSOCK(m) (((m) & HT_S_IFMT) == HT_S_IFSOCK) #define HT_S_IRUSR 0x0100 #define HT_S_IRGRP 0x0020 #define HT_S_IROTH 0x0004 #define HT_S_IWUSR 0x0080 #define HT_S_IWGRP 0x0010 #define HT_S_IWOTH 0x0002 #define HT_S_IXUSR 0x0040 #define HT_S_IXGRP 0x0008 #define HT_S_IXOTH 0x0001 #define HT_S_IRWXU (HT_S_IRUSR || HT_S_IWUSR || HT_S_IXUSR) #define HT_S_IRWXG (HT_S_IRGRP || HT_S_IWGRP || HT_S_IXGRP) #define HT_S_IRWXO (HT_S_IROTH || HT_S_IWOTH || HT_S_IXOTH) #define pstat_ctime 0x00000001 #define pstat_mtime 0x00000002 #define pstat_atime 0x00000004 #define pstat_uid 0x00000008 #define pstat_gid 0x00000010 #define pstat_mode_usr 0x00000020 #define pstat_mode_grp 0x00000040 #define pstat_mode_oth 0x00000080 #define pstat_mode_r 0x00000100 #define pstat_mode_w 0x00000200 #define pstat_mode_x 0x00000400 #define pstat_mode_type 0x00000800 #define pstat_size 0x00001000 #define pstat_inode 0x00002000 #define pstat_cluster 0x00004000 #define pstat_fsid 0x00008000 #define pstat_desc 0x00010000 #define pstat_mode_all (pstat_mode_usr|pstat_mode_grp|pstat_mode_oth|pstat_mode_r|pstat_mode_w|pstat_mode_x|pstat_mode_type) struct pstat_t { uint32 caps; time_t ctime; time_t mtime; time_t atime; uint uid; uint gid; mode_t mode; // S_ISUID, S_ISGID, S_I[RWX](USR|GRP|OTH) uint64 size; union { uint inode; uint cluster; uint fsid; }; char desc[32]; }; struct pfind_t { const char *name; pstat_t stat; void *findstate; }; typedef bool (*is_path_delim)(char c); /* File open mode */ enum FileOpenMode { FOM_EXISTS, FOM_CREATE, FOM_APPEND }; /* Stream access mode */ enum IOAccessModeAtomic { IOAM_NULL = 0, IOAM_READ = 1, IOAM_WRITE = 2 }; typedef uint IOAccessMode; #define SYS_SEEK_SET 1 #define SYS_SEEK_REL 2 #define SYS_SEEK_END 3 // Add abstraction to files #define SYS_FILE void /* system-independant (implementation in sys.cc) */ int sys_file_mode(int mode); int sys_basename(char *result, const char *filename); char * sys_dirname(char *path); char * sys_get_home_dir(); int sys_relname(char *result, const char *filename, const char *cwd); int sys_common_canonicalize(char *result, int ressize, const char *in_name, const char *cwd, is_path_delim delim); const char * sys_filename_suffix(const char *fn); int sys_tmpfile_fd(); /* system-dependant (implementation in $MYSYSTEM/ *.cc) */ int sys_canonicalize(char **result, const char *filename); int sys_findclose(pfind_t &pfind); int sys_findfirst(pfind_t &pfind, const char *dirname); int sys_findnext(pfind_t &pfind); int sys_pstat(pstat_t &s, const char *filename); int sys_pstat_fd(pstat_t &s, int fd); int sys_pstat_file(pstat_t &s, SYS_FILE *file); int sys_truncate(const char *filename, FileOfs ofs); int sys_truncate_fd(int fd, FileOfs ofs); int sys_deletefile(const char *filename); bool sys_is_path_delim(char c); int sys_filename_cmp(const char *a, const char *b); bool sys_filename_is_absolute(const char *filename); SYS_FILE * sys_fopen(const char *filename, FileOpenMode openmode, IOAccessMode accessmode); SYS_FILE * sys_freopen(const char *filename, FileOpenMode openmode, IOAccessMode accessmode, SYS_FILE *file); void sys_fclose(SYS_FILE *file); int sys_fread(SYS_FILE *file, byte *buf, int size); int sys_fwrite(SYS_FILE *file, byte *buf, int size); int sys_fseek(SYS_FILE *file, FileOfs newofs, int seekmode = SYS_SEEK_SET); FileOfs sys_ftell(SYS_FILE *file); #endif /* __FILE_H__ */ �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/djgpp/���������������������������������������������������������������������������������0000755�0001750�0001750�00000000000�12156433676�010741� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/djgpp/htsys.cc�������������������������������������������������������������������������0000644�0001750�0000144�00000016323�10206756715�012337� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * htsys.cc (DJGPP implementation) * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "htsys.h" #include <ctype.h> #include <dir.h> #include <dpmi.h> #include <errno.h> #include <limits.h> #include <string.h> #include <stdlib.h> #include <sys/stat.h> #include <unistd.h> #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) int sys_canonicalize(char *result, const char *filename) { _fixpath(filename, result); return 0; } struct djfindstate { struct ffblk fstate; }; char sys_find_name[HT_NAME_MAX]; int sys_findclose(pfind_t *pfind) { free(pfind->findstate); return 0; } time_t dostime2time_t(unsigned short time, unsigned short date) { struct tm t; t.tm_sec=(time & 0x1f) * 2; t.tm_min=(time >> 5) & 0x3f; t.tm_hour=(time >> 11) & 0x1f; t.tm_mday=date & 0x1f; t.tm_mon=((date >> 5) & 0x0f)-1; t.tm_year=((date >> 9) & 0x7f) + 80; t.tm_wday=1; t.tm_yday=1; t.tm_isdst=0; return mktime(&t); } void ff2pstat(struct ffblk *f, pstat_t *s) { s->caps=pstat_size | pstat_mtime | pstat_mode_type | pstat_mode_usr; s->size=f->ff_fsize; s->mtime=dostime2time_t(f->ff_ftime, f->ff_fdate); s->mode=HT_S_IRUSR; if (f->ff_attrib & FA_DIREC) { s->mode|=HT_S_IFDIR; } else { s->mode|=HT_S_IFREG; } if (!(f->ff_attrib & FA_RDONLY)) { s->mode|=HT_S_IWUSR; } if ((f->lfn_magic[0]=='L') && (f->lfn_magic[1]=='F') && (f->lfn_magic[2]=='N') && (f->lfn_magic[3]=='3') && (f->lfn_magic[4]=='2') && (f->lfn_magic[5]==0)) { s->caps|=pstat_ctime | pstat_atime; s->ctime=dostime2time_t(f->lfn_ctime, f->lfn_cdate); s->atime=dostime2time_t(f->lfn_atime, f->lfn_adate); } } int sys_findfirst(const char *dirname, pfind_t *pfind) { int dnl=strlen(dirname); strcpy(sys_find_name, dirname); if ((dirname[dnl-1]!='\\') && (dirname[dnl-1]!='/')) { sys_find_name[dnl]='\\'; sys_find_name[dnl+1]=0; } strcat(sys_find_name, "*.*"); char *s=sys_find_name; while ((s=strchr(s, '/'))) *s='\\'; pfind->findstate=malloc(sizeof (djfindstate)); djfindstate *dfs=(djfindstate*)pfind->findstate; int e=findfirst(sys_find_name, &dfs->fstate, FA_RDONLY | FA_HIDDEN | FA_SYSTEM | FA_DIREC | FA_ARCH); if (e) { free(pfind->findstate); return e; } strcpy(sys_find_name, dfs->fstate.ff_name); pfind->name=sys_find_name; ff2pstat(&dfs->fstate, &pfind->stat); return 0; } int sys_findnext(pfind_t *pfind) { djfindstate *dfs=(djfindstate*)pfind->findstate; int e=findnext(&dfs->fstate); if (e) return e; strcpy(sys_find_name, dfs->fstate.ff_name); pfind->name=sys_find_name; ff2pstat(&dfs->fstate, &pfind->stat); return 0; } int sys_pstat(pstat_t *s, const char *filename) { char fn[HT_NAME_MAX]; strncpy(fn, filename, sizeof fn); int flen = strlen(fn); if (flen && sys_is_path_delim(fn[flen-1]) && (flen !=3) || (fn[1]!=':')) fn[flen-1] = 0; struct stat st; errno = 0; int e = stat(fn, &st); if (e) return errno ? errno : ENOENT; s->caps = pstat_mtime|pstat_mode_usr|pstat_mode_w|pstat_size/*|pstat_cluster*/|pstat_mode_type; s->mtime = st.st_mtime; s->mode = sys_ht_mode(st.st_mode); s->size = st.st_size; s->size_high = 0; s->fsid = st.st_ino; return 0; } void sys_suspend() { __dpmi_yield(); } int sys_get_free_mem() { _go32_dpmi_meminfo info; _go32_dpmi_get_free_memory_information(&info); return info.available_memory; } int sys_truncate(const char *filename, FILEOFS ofs) { return truncate(filename, ofs); } int sys_deletefile(const char *filename) { return unlink(filename); } bool sys_is_path_delim(const char c) { return (c == '/') || (c == '\\'); } int sys_filename_cmp(const char *a, const char *b) { while (*a && *b) { if (sys_is_path_delim(*a) && sys_is_path_delim(*b)) { } else if (tolower(*a) != tolower(*b)) { break; } else if (*a != *b) { break; } a++; b++; } return tolower(*a) - tolower(*b); } int sys_ipc_exec(ht_streamfile **in, ht_streamfile **out, ht_streamfile **err, int *handle, const char *cmd, int options) { if (options & HT_IPC_NONBLOCKING) return ENOSYS; int save_stdin = dup(STDIN_FILENO); int save_stdout = dup(STDOUT_FILENO); int save_stderr = dup(STDERR_FILENO); int fdout = sys_tmpfile(); int fderr = sys_tmpfile(); close(STDIN_FILENO); dup2(fdout, STDOUT_FILENO); dup2(fderr, STDERR_FILENO); /*int r = */system(cmd); dup2(save_stdin, STDIN_FILENO); dup2(save_stdout, STDOUT_FILENO); dup2(save_stderr, STDERR_FILENO); close(save_stdout); close(save_stderr); lseek(fdout, 0, SEEK_SET); lseek(fderr, 0, SEEK_SET); ht_null_file *nf = new ht_null_file(); nf->init(); *in = nf; ht_sys_file *sf; sf = new ht_sys_file(); sf->init(fdout, true, FAM_READ); *out = sf; sf = new ht_sys_file(); sf->init(fderr, true, FAM_READ); *err = sf; return 0; } bool sys_ipc_is_valid(int handle) { // no multitasking, never valid return false; } int sys_ipc_terminate(int handle) { // already terminated, do nothing return 0; } int sys_get_caps() { return 0; } /* * Clipboard functions */ static bool open_clipboard() { __dpmi_regs r; r.x.ax = 0x1700; // version __dpmi_int(0x2f, &r); if (r.x.ax == 0x1700) return false; r.x.ax = 0x1701; // open __dpmi_int(0x2f, &r); return (r.x.ax != 0); } static void close_clipboard() { __dpmi_regs r; r.x.ax = 0x1708; __dpmi_int(0x2f, &r); } bool sys_write_data_to_native_clipboard(const void *data, int size) { if (size > 0xffff) return false; if (!open_clipboard()) return false; int sel; word seg = __dpmi_allocate_dos_memory((size+15)>>4, &sel); if (seg == 0xffff) { close_clipboard(); return false; } dosmemput(data, size, seg*16); __dpmi_regs r; r.x.ax = 0x1703; r.x.dx = 0x01; // text r.x.es = seg; r.x.bx = 0; r.x.si = size >> 16; r.x.cx = size & 0xffff; __dpmi_int(0x2f, &r); __dpmi_free_dos_memory(sel); close_clipboard(); return (r.x.ax != 0); } int sys_get_native_clipboard_data_size() { return 10000; if (!open_clipboard()) return 0; __dpmi_regs r; r.x.ax = 0x1704; r.x.dx = 0x07; // text __dpmi_int(0x2f, &r); close_clipboard(); return ((dword)r.x.dx)<<16+r.x.ax; } bool sys_read_data_from_native_clipboard(void *data, int max_size) { int dz = sys_get_native_clipboard_data_size(); if (!open_clipboard()) return false; if (!dz) { close_clipboard(); return false; } int sel; word seg = __dpmi_allocate_dos_memory((dz+15)>>4, &sel); if (seg == 0xffff) { close_clipboard(); return false; } __dpmi_regs r; r.x.ax = 0x1705; r.x.dx = 0x1; r.x.es = seg; r.x.bx = 0; __dpmi_int(0x2f, &r); if (r.x.ax) { dosmemget(seg*16, MIN(max_size, dz), data); } __dpmi_free_dos_memory(sel); close_clipboard(); return (r.x.ax != 0); } /* * INIT */ bool init_system() { return true; } /* * DONE */ void done_system() { } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/djgpp/htsys.h��������������������������������������������������������������������������0000644�0001750�0000144�00000003607�10206756715�012202� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * htsys.h (DJGPP implementation) * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTSYS_H__ #define __HTSYS_H__ #include "htio.h" #include "global.h" #define HT_SYS_NAME "DJGPP" #define SYS_SUPPORT_NATIVE_CLIPBOARD #define SYS_NATIVE_CLIPBOARD_NAME "Windows Clipboard" int sys_canonicalize(char *result, const char *filename); int sys_findclose(pfind_t *pfind); int sys_findfirst(const char *dirname, pfind_t *pfind); int sys_findnext(pfind_t *pfind); int sys_pstat(pstat_t *s, const char *filename); void sys_suspend(); int sys_get_free_mem(); int sys_truncate(const char *filename, FILEOFS ofs); int sys_deletefile(const char *filename); bool sys_is_path_delim(char c); int sys_filename_cmp(const char *a, const char *b); bool sys_write_data_to_native_clipboard(const void *data, int size); int sys_get_native_clipboard_data_size(); bool sys_read_data_from_native_clipboard(void *data, int max_size); #include "stream.h" // FIXME: ARGH int sys_ipc_exec(ht_streamfile **in, ht_streamfile **out, ht_streamfile **err, int *handle, const char *cmd, int options); bool sys_ipc_is_valid(int handle); int sys_ipc_terminate(int handle); int sys_get_caps(); /* * INIT */ bool init_system(); /* * DONE */ void done_system(); #endif /* __HTSYS_H__ */ �������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/djgpp/htcurses.cc����������������������������������������������������������������������0000644�0001750�0000144�00000011617�10206756714�013025� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * htcurses.cc (DJGPP implementation) * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "global.h" #include "htcurses.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <conio.h> #include <dpmi.h> #include <go32.h> #include <pc.h> void put_vc(unsigned short *dest, char ch, int vc) { int fg, bg; if (VC_GET_BASECOLOR(VCP_BACKGROUND(vc))==VC_TRANSPARENT) { bg=(((unsigned char*)dest)[1])>>4; } else if (VC_GET_LIGHT(VCP_BACKGROUND(vc))) { bg=VC_GET_BASECOLOR(VCP_BACKGROUND(vc))+8; } else { bg=VC_GET_BASECOLOR(VCP_BACKGROUND(vc)); } if (VC_GET_BASECOLOR(VCP_FOREGROUND(vc))==VC_TRANSPARENT) { fg=(((unsigned char*)dest)[1])&0xf; } else if (VC_GET_LIGHT(VCP_FOREGROUND(vc))) { fg=VC_GET_BASECOLOR(VCP_FOREGROUND(vc))+8; } else { fg=VC_GET_BASECOLOR(VCP_FOREGROUND(vc)); } *dest=( ((bg<<4)|fg) <<8)|((unsigned char)ch); } /* * CLASS screendrawbuf */ screendrawbuf::screendrawbuf(char *title) { bounds b; buf=0; cursorx=0; cursory=0; cursorhidden = false; cursoroverwrite = false; hidecursor(); b.x=0; b.y=0; b.w=ScreenCols(); b.h=ScreenRows(); b_setbounds(&b); screensel=__dpmi_allocate_ldt_descriptors(1); __dpmi_set_descriptor_access_rights(screensel, 0xc0f3); __dpmi_set_segment_base_address(screensel, 0xb8000); __dpmi_set_segment_limit(screensel, 0x7fff); show(); } screendrawbuf::~screendrawbuf() { /* hack to keep prompt color white on black */ b_printchar(size.w-1, size.h-1, VCP(VC_WHITE, VC_BLACK), ' '); setcursormode(false); setcursor(0, size.h-1); show(); if (buf) { delete buf; } } void screendrawbuf::drawbuffer(drawbuf *b, int x, int y, bounds *clipping) { drawbufch *ch=b->buf; for (int iy=0; iy<b->size.h; iy++) { unsigned short *k=buf+x+(iy+y)*size.w; if (y+iy>=clipping->y+clipping->h) break; if (y+iy>=clipping->y) for (int ix=0; ix<b->size.w; ix++) { if ((x+ix<clipping->x+clipping->w) && (x+ix>=clipping->x)) put_vc(k, ch->ch, ch->c); k++; ch++; } } } void screendrawbuf::b_fill(int x, int y, int w, int h, int c, int ch) { for (int i=0; i<h; i++) { unsigned short *b=buf+x+(y+i)*size.w; if (y+i>=size.h) break; if (y+i>=0) for (int j=0; j<w; j++) { if (x+j>=0) put_vc(b, ch, c); if (x+j>=size.w-1) break; b++; } } } void screendrawbuf::b_printchar(int x, int y, int c, int ch) { unsigned short*b=buf+x+y*size.w; put_vc(b, ch, c); } int screendrawbuf::b_lprint(int x, int y, int c, int l, char *text) { int n=0; unsigned short *b=buf+x+y*size.w; while ((*text) && (n<l)) { put_vc(b, (unsigned char)*text, c); b++; text++; n++; } return n; } int screendrawbuf::b_lprintw(int x, int y, int c, int l, int *text) { int n=0; unsigned short *b=buf+x+y*size.w; while ((*text) && (n<l)) { put_vc(b, (unsigned char)*text, c); b++; text++; n++; } return n; } void screendrawbuf::b_resize(int rw, int rh) { /* screens are not sizeable (?) */ } void screendrawbuf::b_rmove(int rx, int ry) { /* screens are not movable */ } void screendrawbuf::b_setbounds(bounds *b) { genericdrawbuf::b_setbounds(b); if (buf) delete buf; buf=(unsigned short *)malloc(sizeof *buf * size.w * size.h); b_fill(size.x, size.y, size.w, size.h, VCP(VC_WHITE, VC_BLACK), ' '); } void screendrawbuf::show() { gotoxy(cursorx+1, cursory+1); /* FIXME: */ movedata(_go32_my_ds(), (int)buf, screensel, 0, size.w*size.h*2); } void screendrawbuf::getcursor(int *x, int *y) { *x=cursorx; *y=cursory; } void screendrawbuf::hidecursor() { if (!cursorhidden) { __dpmi_regs r; r.h.ah = 1; r.h.ch = 31; r.h.cl = 30; __dpmi_int(0x10, &r); cursorhidden = true; } } void screendrawbuf::setcursor(int x, int y) { showcursor(); cursorx=x; cursory=y; } void screendrawbuf::setcursormode(bool overwrite) { if (cursoroverwrite != overwrite) { cursoroverwrite = overwrite; if (!cursorhidden) { hidecursor(); showcursor(); } } } void screendrawbuf::showcursor() { if (cursorhidden) { __dpmi_regs r; r.h.ah = 1; if (cursoroverwrite) { r.h.ch = 0; r.h.cl = 31; } else { r.h.ch = 30; r.h.cl = 31; } __dpmi_int(0x10, &r); cursorhidden = false; } } /*void waitretrace() { asm (" mov $0x3da, %edx waitretrace_eot: in %dx, %al test $8, %al jnz waitretrace_eot waitretrace_eor: in %dx, %al test $8, %al jz waitretrace_eor"); }*/ �����������������������������������������������������������������������������������������������������������������ht-2.0.22/io/djgpp/htkeyb.h�������������������������������������������������������������������������0000644�0001750�0000144�00000001705�10206756715�012313� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * htkeyb.h (DJGPP implementation) * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTKEYB_H__ #define __HTKEYB_H__ #include "htio.h" bool ht_keypressed(); ht_key ht_getkey(); int ht_raw_getkey(); /* * INIT */ bool init_keyb(); /* * DONE */ void done_keyb(); #endif /* !__HTKEYB_H__ */ �����������������������������������������������������������ht-2.0.22/io/djgpp/Makefile.am����������������������������������������������������������������������0000644�0001750�0001750�00000000401�11724770100�012672� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/io AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_LIBRARIES = libhtio.a libhtio_a_SOURCES = htcurses.cc htcurses.h htkeyb.cc htkeyb.h htsys.cc htsys.h ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/djgpp/htkeyb.cc������������������������������������������������������������������������0000644�0001750�0000144�00000013155�10206756715�012453� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * htkeyb.cc (DJGPP implementation) * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "htkeyb.h" #include <pc.h> #include <stdio.h> #include <bios.h> #define SHIFT_KEY(k) (k | 0x80000000) bool ht_shift_pressed() { return (bioskey(2) & 3); } bool ht_keypressed() { return kbhit(); } int ht_raw_getkey() { int k=-1; if (ht_shift_pressed()) { k=getkey(); switch (k) { case 0x14b: /* K_Left */ case 0x14d: /* K_Right */ case 0x148: /* K_Up */ case 0x150: /* K_Down */ case 0x149: /* K_PageUp */ case 0x151: /* K_PageDown */ case 0x147: /* K_Home */ case 0x14f: /* K_End */ case 0x152: /* K_Insert */ case 0x153: /* K_Delete */ case 0x173: /* K_Control_Left */ case 0x174: /* K_Control_Right */ k=SHIFT_KEY(k); break; } } else k=getkey(); return k; } ht_key ht_getkey() { UINT r=ht_raw_getkey(); ht_key k=ht_rawkey2key(r); if ((k==K_INVALID) && (r<=255)) return (ht_key)r; return k; } struct ht_key_keycode { ht_key key; int keycode; }; ht_key_keycode ht_dj_key_defs[] = { {K_Backspace, 0x008}, {K_BackTab, 0x10f}, {K_Tab, 0x009}, {K_Return, 0x00d}, {K_Escape, 0x01b}, {K_Control_A, 0x001}, {K_Control_B, 0x002}, {K_Control_C, 0x003}, {K_Control_D, 0x004}, {K_Control_E, 0x005}, {K_Control_F, 0x006}, {K_Control_G, 0x007}, {K_Control_H, 0x008}, {K_Control_I, 0x009}, {K_Control_J, 0x00a}, {K_Control_K, 0x00b}, {K_Control_L, 0x00c}, {K_Control_M, 0x00d}, {K_Control_N, 0x00e}, {K_Control_O, 0x00f}, {K_Control_P, 0x010}, {K_Control_Q, 0x011}, {K_Control_R, 0x012}, {K_Control_S, 0x013}, {K_Control_T, 0x014}, {K_Control_U, 0x015}, {K_Control_V, 0x016}, {K_Control_W, 0x017}, {K_Control_X, 0x018}, {K_Control_Y, 0x019}, {K_Control_Z, 0x01a}, {K_Alt_Escape, 0x101}, {K_Alt_Backspace, 0x10e}, {K_Alt_Tab, 0x1a5}, {K_Alt_Enter, 0x1a6}, {K_Alt_A, 0x11e}, {K_Alt_B, 0x130}, {K_Alt_C, 0x12e}, {K_Alt_D, 0x120}, {K_Alt_E, 0x112}, {K_Alt_F, 0x121}, {K_Alt_G, 0x122}, {K_Alt_H, 0x123}, {K_Alt_I, 0x117}, {K_Alt_J, 0x124}, {K_Alt_K, 0x125}, {K_Alt_L, 0x126}, {K_Alt_M, 0x132}, {K_Alt_N, 0x131}, {K_Alt_O, 0x118}, {K_Alt_P, 0x119}, {K_Alt_Q, 0x110}, {K_Alt_R, 0x113}, {K_Alt_S, 0x11f}, {K_Alt_T, 0x114}, {K_Alt_U, 0x116}, {K_Alt_V, 0x12f}, {K_Alt_W, 0x111}, {K_Alt_X, 0x12d}, {K_Alt_Y, 0x115}, {K_Alt_Z, 0x12c}, {K_F1, 0x13b}, {K_F2, 0x13c}, {K_F3, 0x13d}, {K_F4, 0x13e}, {K_F5, 0x13f}, {K_F6, 0x140}, {K_F7, 0x141}, {K_F8, 0x142}, {K_F9, 0x143}, {K_F10, 0x144}, {K_F11, 0x185}, {K_F12, 0x186}, {K_Shift_F1, 0x154}, {K_Shift_F2, 0x155}, {K_Shift_F3, 0x156}, {K_Shift_F4, 0x157}, {K_Shift_F5, 0x158}, {K_Shift_F6, 0x159}, {K_Shift_F7, 0x15a}, {K_Shift_F8, 0x15b}, {K_Shift_F9, 0x15c}, {K_Shift_F10, 0x15d}, {K_Shift_F11, 0x187}, {K_Shift_F12, 0x188}, {K_Control_F1, 0x15e}, {K_Control_F2, 0x15f}, {K_Control_F3, 0x160}, {K_Control_F4, 0x161}, {K_Control_F5, 0x162}, {K_Control_F6, 0x163}, {K_Control_F7, 0x164}, {K_Control_F8, 0x165}, {K_Control_F9, 0x166}, {K_Control_F10, 0x167}, {K_Control_F11, 0x189}, {K_Control_F12, 0x18a}, {K_Alt_F1, 0x168}, {K_Alt_F2, 0x169}, {K_Alt_F3, 0x16a}, {K_Alt_F4, 0x16b}, {K_Alt_F5, 0x16c}, {K_Alt_F6, 0x16d}, {K_Alt_F7, 0x16e}, {K_Alt_F8, 0x16f}, {K_Alt_F9, 0x170}, {K_Alt_F10, 0x171}, {K_Alt_F11, 0x18b}, {K_Alt_F12, 0x18c}, {K_Alt_1, 0x178}, {K_Alt_2, 0x179}, {K_Alt_3, 0x17a}, {K_Alt_4, 0x17b}, {K_Alt_5, 0x17c}, {K_Alt_6, 0x17d}, {K_Alt_7, 0x17e}, {K_Alt_8, 0x17f}, {K_Alt_9, 0x180}, {K_Alt_0, 0x181}, {K_Left, 0x14b}, {K_Right, 0x14d}, {K_Up, 0x148}, {K_Down, 0x150}, {K_PageUp, 0x149}, {K_PageDown, 0x151}, {K_Home, 0x147}, {K_End, 0x14f}, {K_Insert, 0x152}, {K_Delete, 0x153}, {K_Control_Left, 0x173}, {K_Control_Right, 0x174}, {K_Control_Up, 0x18d}, {K_Control_Down, 0x191}, {K_Control_PageUp, 0x184}, {K_Control_PageDown, 0x176}, {K_Control_Home, 0x177}, {K_Control_End, 0x175}, {K_Control_Insert, 0x192}, {K_Control_Delete, 0x193}, {K_Shift_Left, SHIFT_KEY(0x14b)}, {K_Shift_Right, SHIFT_KEY(0x14d)}, {K_Shift_Up, SHIFT_KEY(0x148)}, {K_Shift_Down, SHIFT_KEY(0x150)}, {K_Shift_PageUp, SHIFT_KEY(0x149)}, {K_Shift_PageDown, SHIFT_KEY(0x151)}, {K_Shift_Home, SHIFT_KEY(0x147)}, {K_Shift_End, SHIFT_KEY(0x14f)}, {K_Shift_Insert, SHIFT_KEY(0x152)}, {K_Shift_Delete, SHIFT_KEY(0x153)}, {K_Control_Shift_Left, SHIFT_KEY(0x173)}, {K_Control_Shift_Right, SHIFT_KEY(0x174)} }; /* * INIT */ bool init_keyb() { UINT i; for (i=0; i<K_COUNT; i++) { ht_set_key((ht_key)i, -1); } for (i=0; i<sizeof ht_dj_key_defs/sizeof ht_dj_key_defs[0]; i++) { ht_set_key(ht_dj_key_defs[i].key, ht_dj_key_defs[i].keycode); } return true; } /* * DONE */ void done_keyb() { } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/djgpp/Makefile.in����������������������������������������������������������������������0000644�0001750�0001750�00000031600�12127657374�012727� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Makefile.in generated by automake 1.10.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = io/djgpp DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru libhtio_a_AR = $(AR) $(ARFLAGS) libhtio_a_LIBADD = am_libhtio_a_OBJECTS = htcurses.$(OBJEXT) htkeyb.$(OBJEXT) \ htsys.$(OBJEXT) libhtio_a_OBJECTS = $(am_libhtio_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libhtio_a_SOURCES) DIST_SOURCES = $(libhtio_a_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ HT_LDFLAGS = @HT_LDFLAGS@ HT_LIBS = @HT_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IO_DIR = @IO_DIR@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ LZO_LIBS = @LZO_LIBS@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ curses_CPPFLAGS = @curses_CPPFLAGS@ curses_LIBS = @curses_LIBS@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ ncurses_config = @ncurses_config@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/io AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_LIBRARIES = libhtio.a libhtio_a_SOURCES = htcurses.cc htcurses.h htkeyb.cc htkeyb.h htsys.cc htsys.h all: all-am .SUFFIXES: .SUFFIXES: .cc .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign io/djgpp/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign io/djgpp/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libhtio.a: $(libhtio_a_OBJECTS) $(libhtio_a_DEPENDENCIES) -rm -f libhtio.a $(libhtio_a_AR) libhtio.a $(libhtio_a_OBJECTS) $(libhtio_a_LIBADD) $(RANLIB) libhtio.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htcurses.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htkeyb.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htsys.Po@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ��������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/djgpp/htcurses.h�����������������������������������������������������������������������0000644�0001750�0000144�00000006356�10206756715�012674� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * htcurses.h (DJGPP implementation) * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTCURSES_H__ #define __HTCURSES_H__ #include "htio.h" #include "common.h" #define CHAR_LINEV (unsigned char)'\xb3' #define CHAR_LINEH (unsigned char)'\xc4' #define CHAR_LINEV_DBL (unsigned char)'\xba' #define CHAR_LINEH_DBL (unsigned char)'\xcd' #define CHAR_LINEH_BU (unsigned char)'\xdf' #define CHAR_LINEH_BL (unsigned char)'\xdc' #define CHAR_BORDERTL (unsigned char)'\xc3' #define CHAR_BORDERTR (unsigned char)'\xb4' #define CHAR_BORDERTU (unsigned char)'\xc2' #define CHAR_BORDERTD (unsigned char)'\xc1' #define CHAR_CORNERUL (unsigned char)'\xda' #define CHAR_CORNERLL (unsigned char)'\xc0' #define CHAR_CORNERUR (unsigned char)'\xbf' #define CHAR_CORNERLR (unsigned char)'\xd9' #define CHAR_CORNERUL_DBL (unsigned char)'\xc9' #define CHAR_CORNERLL_DBL (unsigned char)'\xc8' #define CHAR_CORNERUR_DBL (unsigned char)'\xbb' #define CHAR_CORNERLR_DBL (unsigned char)'\xbc' #define CHAR_FILLED_L (unsigned char)'\xb0' /* FILLED, low density */ #define CHAR_FILLED_M (unsigned char)'\xb1' /* FILLED, medium density */ #define CHAR_FILLED_H (unsigned char)'\xb2' /* FILLED, high density */ #define CHAR_FILLED_F (unsigned char)'\xdb' /* FILLED, filled entirely */ #define CHAR_FILLED_HU (unsigned char)'\xdf' /* FILLED, upper half - filled entirely */ #define CHAR_FILLED_HL (unsigned char)'\xdc' /* FILLED, lower half - filled entirely */ #define CHAR_QUAD_SMALL (unsigned char)'\xfe' #define CHAR_ARROW_UP (unsigned char)'\x18' #define CHAR_ARROW_DOWN (unsigned char)'\x19' #define CHAR_ARROWBIG_UP (unsigned char)'\x1e' #define CHAR_ARROWBIG_DOWN (unsigned char)'\x1f' #define CHAR_ARROWBIG_LEFT (unsigned char)'\x11' #define CHAR_ARROWBIG_RIGHT (unsigned char)'\x10' #define CHAR_RADIO (unsigned char)'\x7' class screendrawbuf: public genericdrawbuf { protected: unsigned short *buf; int screensel; int cursorx, cursory; bool cursorhidden; bool cursoroverwrite; public: screendrawbuf(char *title); ~screendrawbuf(); virtual void b_fill(int x, int y, int w, int h, int c, int ch); virtual void b_printchar(int x, int y, int c, int ch); virtual int b_lprint(int x, int y, int c, int l, char *text); virtual int b_lprintw(int x, int y, int c, int l, int *text); virtual void b_resize(int rw, int rh); virtual void b_rmove(int rx, int ry); virtual void b_setbounds(bounds *b); /* new */ void drawbuffer(drawbuf *buf, int x, int y, bounds *clipping); void show(); void getcursor(int *x, int *y); void hidecursor(); void showcursor(); void setcursor(int x, int y); void setcursormode(bool override); }; #endif /* !__HTCURSES_H__ */ ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/keyb.cc��������������������������������������������������������������������������������0000755�0001750�0000144�00000016150�10615344121�011000� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * keyb.cc * * Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <cstdio> #include <cstring> #include "keyb.h" #include "strtools.h" ht_key keyb_unmetakey(ht_key key) { switch (key) { case K_Meta_A: return K_A; case K_Meta_B: return K_B; case K_Meta_C: return K_C; case K_Meta_D: return K_D; case K_Meta_E: return K_E; case K_Meta_F: return K_F; case K_Meta_G: return K_G; case K_Meta_H: return K_H; case K_Meta_I: return K_I; case K_Meta_J: return K_J; case K_Meta_K: return K_K; case K_Meta_L: return K_L; case K_Meta_M: return K_M; case K_Meta_N: return K_N; case K_Meta_O: return K_O; case K_Meta_P: return K_P; case K_Meta_Q: return K_Q; case K_Meta_R: return K_R; case K_Meta_S: return K_S; case K_Meta_T: return K_T; case K_Meta_U: return K_U; case K_Meta_V: return K_V; case K_Meta_W: return K_W; case K_Meta_X: return K_X; case K_Meta_Y: return K_Y; case K_Meta_Z: return K_Z; default: return K_INVALID; } } static ht_key keyb_lmetakey(ht_key key) { switch (key) { case K_A: return K_Meta_A; case K_B: return K_Meta_B; case K_C: return K_Meta_C; case K_D: return K_Meta_D; case K_E: return K_Meta_E; case K_F: return K_Meta_F; case K_G: return K_Meta_G; case K_H: return K_Meta_H; case K_I: return K_Meta_I; case K_J: return K_Meta_J; case K_K: return K_Meta_K; case K_L: return K_Meta_L; case K_M: return K_Meta_M; case K_N: return K_Meta_N; case K_O: return K_Meta_O; case K_P: return K_Meta_P; case K_Q: return K_Meta_Q; case K_R: return K_Meta_R; case K_S: return K_Meta_S; case K_T: return K_Meta_T; case K_U: return K_Meta_U; case K_V: return K_Meta_V; case K_W: return K_Meta_W; case K_X: return K_Meta_X; case K_Y: return K_Meta_Y; case K_Z: return K_Meta_Z; default: return K_INVALID; } } ht_key keyb_metakey(ht_key key) { if ((key>=K_A) && (key<=K_Z)) { return keyb_lmetakey(key); /* } else if ((key>=K_Shift_A) && (key<=K_Shift_Z)) { return ht_lmetakey( (ht_key) ((int)key-(int)K_Meta_A+(int)K_A));*/ } return K_INVALID; } static int ht_keys1[K_COUNT]; static int ht_keys2[K_COUNT]; static int ht_keys3[K_COUNT]; ht_key keyb_rawkey2key(int rawkey) { for (int i=0; i<K_COUNT; i++) { if (ht_keys1[i]==(int)rawkey) return (ht_key)i; if (ht_keys2[i]==(int)rawkey) return (ht_key)i; if (ht_keys3[i]==(int)rawkey) return (ht_key)i; } return K_INVALID; } void keyb_setkey(ht_key key, int rawkey) { int i = (int)key; if (i<K_COUNT) { if (rawkey == -1) { ht_keys1[i] = -1; ht_keys2[i] = -1; ht_keys3[i] = -1; } else if ((ht_keys1[i] == -1) || (ht_keys1[i] == rawkey)) ht_keys1[i] = rawkey; else if ((ht_keys2[i] == -1) || (ht_keys2[i] == rawkey)) ht_keys2[i] = rawkey; else if ((ht_keys3[i] == -1) || (ht_keys3[i] == rawkey)) ht_keys3[i] = rawkey; } } #if defined(WIN32) || defined(__WIN32__) #define META_KEY_NAME "Alt" #else #define META_KEY_NAME "Meta" #endif bool keyb_getkeydesc(char *buf, int bufsize, ht_key k) { char b2[64]; const char *b; bool r = true; switch (k) { case K_Backspace: b = "Backspace"; break; case K_Meta_Backspace: b = "Alt+Backspace"; break; case K_Return: b = "Enter"; break; case K_Tab: b = "Tab"; break; case K_Escape: b = "Escape"; break; case K_Left: b = "Left"; break; case K_Right: b = "Right"; break; case K_Up: b = "Up"; break; case K_Down: b = "Down"; break; case K_PageUp: b = "PgUp"; break; case K_PageDown: b = "PgDn"; break; case K_Insert: b = "Insert"; break; case K_Delete: b = "Delete"; break; case K_Home: b = "Home"; break; case K_End: b = "End"; break; case K_Meta_Left: b = META_KEY_NAME"+Left"; break; case K_Meta_Right: b = META_KEY_NAME"+Right"; break; case K_Meta_Up: b = META_KEY_NAME"+Up"; break; case K_Meta_Down: b = META_KEY_NAME"+Down"; break; case K_Meta_PageUp: b = META_KEY_NAME"+PgUp"; break; case K_Meta_PageDown: b = META_KEY_NAME"+PgDn"; break; case K_Meta_Insert: b = META_KEY_NAME"+Insert"; break; case K_Meta_Delete: b = META_KEY_NAME"+Delete"; break; case K_Meta_Home: b = META_KEY_NAME"+Home"; break; case K_Meta_End: b = META_KEY_NAME"+End"; break; case K_Control_Up: b = "Ctrl+Up"; break; case K_Control_Down: b = "Ctrl+Down"; break; case K_Control_Left: b = "Ctrl+Left"; break; case K_Control_Right: b = "Ctrl+Right"; break; case K_Control_PageUp: b = "Ctrl+PgUp"; break; case K_Control_PageDown: b = "Ctrl+PgDn"; break; case K_Control_Insert: b = "Ctrl+Insert"; break; case K_Control_Delete: b = "Ctrl+Delete"; break; case K_Control_Home: b = "Ctrl+Home"; break; case K_Control_End: b = "Ctrl+End"; break; case K_Control_Tab: b = "Ctrl+Tab"; break; case K_Shift_Left: b = "Shift+Left"; break; case K_Shift_Right: b = "Shift+Right"; break; case K_Shift_Up: b = "Shift+Up"; break; case K_Shift_Down: b = "Shift+Down"; break; case K_Shift_PageUp: b = "Shift+PgUp"; break; case K_Shift_PageDown: b = "Shift+PgDn"; break; case K_Shift_Insert: b = "Shift+Insert"; break; case K_Shift_Delete: b = "Shift+Delete"; break; case K_Shift_Home: b = "Shift+Home"; break; case K_Shift_End: b = "Shift+End"; break; case K_Shift_Tab: b = "Shift+Tab"; break; default: { char kk = (char)k; b = b2; if (!(k & ~0xff) && (((kk>='a') && (kk<='z')) || ((kk>='A') && (kk<='Z')) || ((kk>='0') && (kk<='9')) || ((strchr("[]{}()/\\'\"$%&?!.:,;-_=*+-#~<>|", kk) != NULL)))) { b2[0] = kk; b2[1] = 0; } else if ((k>=K_F1) && (k<=K_F12)) { sprintf(b2, "F%d", (int)k-(int)K_F1+1); } else if ((k>=K_Shift_F1) && (k<=K_Shift_F12)) { sprintf(b2, "Shift-F%d", (int)k-(int)K_Shift_F1+1); } else if ((k>=K_Control_F1) && (k<=K_Control_F12)) { sprintf(b2, "Ctrl-F%d", (int)k-(int)K_Control_F1+1); } else if ((k>=K_Control_Shift_F1) && (k<=K_Control_Shift_F12)) { sprintf(b2, "Ctrl-Shift-F%d", (int)k-(int)K_Control_Shift_F1+1); } else if ((k>=K_Meta_F1) && (k<=K_Meta_F12)) { sprintf(b2, META_KEY_NAME"-F%d", (int)k-(int)K_Meta_F1+1); } else if ((k>=K_Meta_1) && (k<=K_Meta_0)) { sprintf(b2, META_KEY_NAME"-%d", ((int)k-(int)K_Meta_1+1)%10); } else if ((k>=K_Control_A) && (k<=K_Control_Z)) { sprintf(b2, "Ctrl-%c", (int)k-(int)K_Control_A+'A'); } else if ((k>=K_Meta_A) && (k<=K_Meta_Z)) { sprintf(b2, META_KEY_NAME"-%c", (int)k-(int)K_Meta_A+'A'); } else { if ((unsigned int)k>255) { sprintf(b2, "key <%x>", (int)k); } else { sprintf(b2, "key <%x> '%c'", (int)k, (int)k); } r = false; } } } if (bufsize > 0) { ht_strlcpy(buf, b, bufsize); } return r; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/sys.h����������������������������������������������������������������������������������0000755�0001750�0000144�00000003554�10615344121�010532� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * sys.h * * Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __SYS_H__ #define __SYS_H__ /* system-dependant (implementation in $MYSYSTEM/ *.cc) */ /* Note: all functions only take absolute dir/filenames ! */ #define SYSCAP_IPC 1 #define SYSCAP_NBIPC 2 #define SYSCAP_NATIVE_CLIPBOARD 4 int sys_get_caps(); int sys_ht_mode(int mode); void sys_get_driver_desc(char *buf, int len); // return time slice to system void sys_suspend(); int sys_native_clipboard_read(void *buf, int bufsize); bool sys_native_clipboard_write(const void *buf, int bufsize); int sys_native_clipboard_get_size(); const char * sys_native_clipboard_name(); const char * sys_get_name(); #if 1 class File; #define SPE_STDERR_TO_STDOUT 1 int sys_child_create(File **in, File **out, File **err, int &process_handle, int options, const char *filename, char* const* argv); // FIXME: creates empty subshell if filename == NULL int sys_child_create_in_subshell(char *ttyname_32bytes, int &tty_fd, int &process_handle, const char *filename, char* const *argv); bool sys_child_is_running(int process_handle); int sys_child_terminate(int process_handle); #endif bool init_system(); void done_system(); #endif /* __SYS_H__ */ ����������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/types.h��������������������������������������������������������������������������������0000644�0001750�0000144�00000004326�10615344121�011053� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * types.h * * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) * Copyright (C) 1999-2003 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __TYPES_H__ #define __TYPES_H__ #ifdef HAVE_CONFIG_H #include "config.h" #endif #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) /* * structure packing */ #ifdef __cplusplus #ifdef __GNUC__ # define FUNCTION_CONST __attribute__((const)) # define PACKED __attribute__((packed)) # define UNUSED __attribute__((unused)) # define DEPRECATED __attribute__((deprecated)) # define NORETURN __attribute__((noreturn)) # define ALIGN_STRUCT(n) __attribute__((aligned(n))) #else #error "You are not using the GNU C compiler collection (GCC). Please add the __htpacked macro and conditionals for your compiler" #define __htpacked #endif /* !__GNUC__ */ #endif /* __cplusplus */ /* * integers */ #include SYSTEM_OSAPI_SPECIFIC_TYPES_HDR /* * C++ specific */ #ifdef __cplusplus #define DDECL_UINT(name) uint32 name PACKED #define DDECL_PTR(type, name) type *name PACKED #define NEW_PTR(type, var) type *var = (type *) malloc(sizeof(type)) #define NEW_OBJECT(instance, class, params...) \ ((class *)(instance = new class()))->init(params) #define DELETE_OBJECT(obj) obj->done(); delete obj; #define DPRINTF(msg...) /* * steves strucs */ //#define BOUNDS_ASSIGN(b, X, Y, W, H) b.x=X; b.y=Y; b.w=W; b.h=H; union htmsg_param { int integer; uint64 q; void *ptr; char *str; const char *cstr; }; struct htmsg { int msg; int type; htmsg_param data1; htmsg_param data2; }; #endif /* __cplusplus */ #endif ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/keyb.h���������������������������������������������������������������������������������0000755�0001750�0000144�00000012534�10615344121�010644� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * keyb.h * * Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __KEYB_H__ #define __KEYB_H__ enum ht_key { K_FIRST = 0, /* ASCII > 0 */ K_Backspace = 1, K_Shift_Tab = 2, K_Tab = '\t', K_Return = '\n', K_Escape = '\e', // Start of printables K_Space = ' ', K_ExclamationPoint = '!', K_DoubleQuote = '"', K_Hash = '#', K_Dollar = '$', K_Percent = '%', K_Ampersand = '&', K_Quote = '\'', K_LParen = '(', K_RParen = ')', K_Star = '*', K_Plus = '+', K_Comma = ',', K_Dash = '-', K_Period = '.', K_Slash = '/', K_Colon = ':', K_SemiColon = ';', K_LAngle = '<', K_Equals = '=', K_RAngle = '>', K_QuestionMark = '?', K_At = '@', K_LBracket = '[', K_BackSlash = '\'', K_RBracket = ']', K_Caret = '^', K_UnderScore = '_', K_BackQuote = '`', K_LBrace = '{', K_Pipe = '|', K_RBrace = '}', K_Tilde = '~', K_0 = '0', K_1 = '1', K_2 = '2', K_3 = '3', K_4 = '4', K_5 = '5', K_6 = '6', K_7 = '7', K_8 = '8', K_9 = '9', K_A = 'a', K_B = 'b', K_C = 'c', K_D = 'd', K_E = 'e', K_F = 'f', K_G = 'g', K_H = 'h', K_I = 'i', K_J = 'j', K_K = 'k', K_L = 'l', K_M = 'm', K_N = 'n', K_O = 'o', K_P = 'p', K_Q = 'q', K_R = 'r', K_S = 's', K_T = 't', K_U = 'u', K_V = 'v', K_W = 'w', K_X = 'x', K_Y = 'y', K_Z = 'z', K_Shift_A = 'A', K_Shift_B = 'B', K_Shift_C = 'C', K_Shift_D = 'D', K_Shift_E = 'E', K_Shift_F = 'F', K_Shift_G = 'G', K_Shift_H = 'H', K_Shift_I = 'I', K_Shift_J = 'J', K_Shift_K = 'K', K_Shift_L = 'L', K_Shift_M = 'M', K_Shift_N = 'N', K_Shift_O = 'O', K_Shift_P = 'P', K_Shift_Q = 'Q', K_Shift_R = 'R', K_Shift_S = 'S', K_Shift_T = 'T', K_Shift_U = 'U', K_Shift_V = 'V', K_Shift_W = 'W', K_Shift_X = 'X', K_Shift_Y = 'Y', K_Shift_Z = 'Z', // end of printables K_LASTASCII = 0xff, /* Special keys start here */ K_BackTick, K_Meta_Escape, K_Meta_Backspace, K_Meta_Tab, K_Meta_Enter, K_Left, K_Right, K_Up, K_Down, K_PageUp, K_PageDown, K_Home, K_End, K_Insert, K_Delete, K_Control_Left, K_Control_Right, K_Control_Up, K_Control_Down, K_Control_PageUp, K_Control_PageDown, K_Control_Home, K_Control_End, K_Control_Insert, K_Control_Delete, K_Control_Tab, K_Control_Shift_Left, K_Control_Shift_Right, K_Shift_Left, K_Shift_Right, K_Shift_Up, K_Shift_Down, K_Shift_PageUp, K_Shift_PageDown, K_Shift_Home, K_Shift_End, K_Shift_Insert, K_Shift_Delete, K_Meta_Left, K_Meta_Right, K_Meta_Up, K_Meta_Down, K_Meta_PageUp, K_Meta_PageDown, K_Meta_Home, K_Meta_End, K_Meta_Insert, K_Meta_Delete, K_Meta_A, K_Meta_B, K_Meta_C, K_Meta_D, K_Meta_E, K_Meta_F, K_Meta_G, K_Meta_H, K_Meta_I, K_Meta_J, K_Meta_K, K_Meta_L, K_Meta_M, K_Meta_N, K_Meta_O, K_Meta_P, K_Meta_Q, K_Meta_R, K_Meta_S, K_Meta_T, K_Meta_U, K_Meta_V, K_Meta_W, K_Meta_X, K_Meta_Y, K_Meta_Z, K_Meta_1, K_Meta_2, K_Meta_3, K_Meta_4, K_Meta_5, K_Meta_6, K_Meta_7, K_Meta_8, K_Meta_9, K_Meta_0, K_F1, K_F2, K_F3, K_F4, K_F5, K_F6, K_F7, K_F8, K_F9, K_F10, K_F11, K_F12, K_Shift_F1, K_Shift_F2, K_Shift_F3, K_Shift_F4, K_Shift_F5, K_Shift_F6, K_Shift_F7, K_Shift_F8, K_Shift_F9, K_Shift_F10, K_Shift_F11, K_Shift_F12, K_Control_F1, K_Control_F2, K_Control_F3, K_Control_F4, K_Control_F5, K_Control_F6, K_Control_F7, K_Control_F8, K_Control_F9, K_Control_F10, K_Control_F11, K_Control_F12, K_Control_Shift_F1, K_Control_Shift_F2, K_Control_Shift_F3, K_Control_Shift_F4, K_Control_Shift_F5, K_Control_Shift_F6, K_Control_Shift_F7, K_Control_Shift_F8, K_Control_Shift_F9, K_Control_Shift_F10, K_Control_Shift_F11, K_Control_Shift_F12, K_Control_A, K_Control_B, K_Control_C, K_Control_D, K_Control_E, K_Control_F, K_Control_G, K_Control_H, K_Control_I, K_Control_J, K_Control_K, K_Control_L, K_Control_M, K_Control_N, K_Control_O, K_Control_P, K_Control_Q, K_Control_R, K_Control_S, K_Control_T, K_Control_U, K_Control_V, K_Control_W, K_Control_X, K_Control_Y, K_Control_Z, K_Meta_F1, K_Meta_F2, K_Meta_F3, K_Meta_F4, K_Meta_F5, K_Meta_F6, K_Meta_F7, K_Meta_F8, K_Meta_F9, K_Meta_F10, K_Meta_F11, K_Meta_F12, K_LAST, K_INVALID = -1 }; #define K_COUNT ((int)K_LAST) /* system-independant (implementation in keyb.cc) */ ht_key keyb_metakey(ht_key key); /* generate ht_key for M+key from key */ ht_key keyb_unmetakey(ht_key metakey); /* generate ht_key for key from M+key */ void keyb_setkey(ht_key key, int rawkey); ht_key keyb_rawkey2key(int rawkey); bool keyb_getkeydesc(char *buf, int bufsize, ht_key k); //#include "event.h" struct sys_event_t; /* system-dependant (implementation in $MYSYSTEM/ *.cc) */ bool keyb_getevent(sys_event_t &event); /* deprecated interface */ bool keyb_keypressed(); ht_key keyb_getkey(); int keyb_getrawkey(); bool init_keyb(); void done_keyb(); #endif /* __KEYB_H__ */ ��������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/event.h��������������������������������������������������������������������������������0000755�0001750�0000144�00000003736�10615344121�011037� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * event.h * * Copyright (C) 1999-2004 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __EVENT_H__ #define __EVENT_H__ #include "keyb.h" enum sys_event_type { SYSEV_NONE, SYSEV_KEYPRESSED, SYSEV_MOUSE_EVENT, SYSEV_SCREEN_RESIZE, SYSEV_FD_EVENT }; #define FD_FLAG_READABLE 1 #define FD_FLAG_WRITABLE 2 #define FD_FLAG_EXCEPTION 4 struct fd_event_t { int fd; int fd_flags; }; struct screen_resize_t { int w, h; }; enum mouse_button_event_t { MBE_PRESSED, MBE_RELEASED }; typedef int mouse_button_mask_t; enum mouse_button_t { MBM_LEFT = 1, MBM_MIDDLE = 2, MBM_RIGHT = 4, MBM_BUTTON4 = 8, MBM_BUTTON5 = 16, MBM_BUTTON6 = 32 }; struct mouse_event_t { mouse_button_event_t button_event; mouse_button_mask_t button_mask; int x, y; }; struct sys_event_t { sys_event_type type; union { ht_key key; screen_resize_t screen_resize; fd_event_t fd_event; mouse_event_t mouse_event; }; }; /* system-dependant (implementation in $MYSYSTEM/ *.cc) */ bool sys_next_event(sys_event_t &event, int wait_usec); bool sys_listen_fd_event(int fd, int fd_flags); bool sys_unlisten_fd_event(int fd); // if set, sys_next_event() translates events on stdin (fd 0) to SYSEV_KEYPRESSED // if not set, sys_next_event() translates events on stdin (fd 0) to SYSEV_FD_EVENT void sys_set_key_translation(bool translate_keys); #endif /* __EVENT_H__ */ ����������������������������������ht-2.0.22/io/win32/���������������������������������������������������������������������������������0000755�0001750�0001750�00000000000�12156433676�010577� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/win32/syskeyb.cc�����������������������������������������������������������������������0000644�0001750�0000144�00000027341�10615343757�012520� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * syskeyb.cc - keyboard access functions for Win32 * * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "io/keyb.h" #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <ctype.h> #include <stdio.h> #include <stdlib.h> HANDLE gInputHandle; static INPUT_RECORD key_event_record; static bool key_pending=false; static bool k_shift_state=false; static bool k_ctrl_state=false; static bool k_alt_state=false; //#define KEY_DEBUG #ifdef KEY_DEBUG static FILE *kd; #endif struct ht_key_keycode { ht_key key; int keycode; }; #define HT_VK 0x300 #define HT_VK_ALT (0x1000) #define HT_VK_SHIFT (0x2000) #define HT_VK_CTRL (0x3000) static ht_key_keycode ht_win32_key_defs[] = { {K_Control_A, (0x001+HT_VK_CTRL)}, {K_Control_B, (0x002+HT_VK_CTRL)}, {K_Control_C, (0x003+HT_VK_CTRL)}, {K_Control_D, (0x004+HT_VK_CTRL)}, {K_Control_E, (0x005+HT_VK_CTRL)}, {K_Control_F, (0x006+HT_VK_CTRL)}, {K_Control_G, (0x007+HT_VK_CTRL)}, {K_Backspace, (VK_BACK+HT_VK)}, {K_Control_H, (0x008+HT_VK_CTRL)}, {K_Tab, (VK_TAB+HT_VK)}, {K_Control_I, (0x009+HT_VK_CTRL)}, {K_Control_J, (0x00a+HT_VK_CTRL)}, {K_Control_K, (0x00b+HT_VK_CTRL)}, {K_Control_L, (0x00c+HT_VK_CTRL)}, {K_Return, (VK_RETURN+HT_VK)}, {K_Control_M, (0x00d+HT_VK_CTRL)}, {K_Control_N, (0x00e + HT_VK_CTRL)}, // preprocessor problem :-) {K_Control_O, (0x00f+HT_VK_CTRL)}, {K_Control_P, (0x010+HT_VK_CTRL)}, {K_Control_Q, (0x011+HT_VK_CTRL)}, {K_Control_R, (0x012+HT_VK_CTRL)}, {K_Control_S, (0x013+HT_VK_CTRL)}, {K_Control_T, (0x014+HT_VK_CTRL)}, {K_Control_U, (0x015+HT_VK_CTRL)}, {K_Control_V, (0x016+HT_VK_CTRL)}, {K_Control_W, (0x017+HT_VK_CTRL)}, {K_Control_X, (0x018+HT_VK_CTRL)}, {K_Control_Y, (0x019+HT_VK_CTRL)}, {K_Control_Z, (0x01a+HT_VK_CTRL)}, {K_Escape, (VK_ESCAPE+HT_VK)}, // {K_Control_LBracket, 0x01b}, // {K_Control_BackSlash, 0x01c}, // {K_Control_RBracket, 0x01d}, // {K_Control_Caret, 0x01e}, // {K_Control_Underscore, 0x01f}, // {K_Control_Backspace, (VK_BACK+HT_VK+HT_VK_CTRL)}, {K_Meta_Escape, (VK_ESCAPE+HT_VK+HT_VK_ALT)}, // {K_Control_At, 0x103}, {K_Meta_Backspace, (VK_BACK+HT_VK+HT_VK_ALT)}, {K_Shift_Tab, (VK_TAB+HT_VK+HT_VK_SHIFT)}, {K_Control_Tab, (VK_TAB+HT_VK+HT_VK_CTRL)}, {K_Meta_Q, ('q'+HT_VK_ALT)}, {K_Meta_W, ('w'+HT_VK_ALT)}, {K_Meta_E, ('e'+HT_VK_ALT)}, {K_Meta_R, ('r'+HT_VK_ALT)}, {K_Meta_T, ('t'+HT_VK_ALT)}, {K_Meta_Y, ('y'+HT_VK_ALT)}, {K_Meta_U, ('u'+HT_VK_ALT)}, {K_Meta_I, ('i'+HT_VK_ALT)}, {K_Meta_O, ('o'+HT_VK_ALT)}, {K_Meta_P, ('p'+HT_VK_ALT)}, // {K_Meta_LBracket, 0x11a}, // {K_Meta_RBracket, 0x11b}, // {K_Meta_Return, 0x11c}, {K_Meta_A, ('a'+HT_VK_ALT)}, {K_Meta_S, ('s'+HT_VK_ALT)}, {K_Meta_D, ('d'+HT_VK_ALT)}, {K_Meta_F, ('f'+HT_VK_ALT)}, {K_Meta_G, ('g'+HT_VK_ALT)}, {K_Meta_H, ('h'+HT_VK_ALT)}, {K_Meta_J, ('j'+HT_VK_ALT)}, {K_Meta_K, ('k'+HT_VK_ALT)}, {K_Meta_L, ('l'+HT_VK_ALT)}, // {K_Meta_Semicolon, 0x127}, // {K_Meta_Quote, 0x128}, // {K_Meta_Backquote, 0x129}, // {K_Meta_Backslash, 0x12b}, {K_Meta_Z, ('z'+HT_VK_ALT)}, {K_Meta_X, ('x'+HT_VK_ALT)}, {K_Meta_C, ('c'+HT_VK_ALT)}, {K_Meta_V, ('v'+HT_VK_ALT)}, {K_Meta_B, ('b'+HT_VK_ALT)}, {K_Meta_N, ('n'+HT_VK_ALT)}, {K_Meta_M, ('m'+HT_VK_ALT)}, // {K_Meta_Comma, 0x133}, // {K_Meta_Period, 0x134}, // {K_Meta_Slash, 0x135}, // {K_Meta_KPStar, 0x137}, {K_F1, (VK_F1+HT_VK)}, {K_F2, (VK_F2+HT_VK)}, {K_F3, (VK_F3+HT_VK)}, {K_F4, (VK_F4+HT_VK)}, {K_F5, (VK_F5+HT_VK)}, {K_F6, (VK_F6+HT_VK)}, {K_F7, (VK_F7+HT_VK)}, {K_F8, (VK_F8+HT_VK)}, {K_F9, (VK_F9+HT_VK)}, {K_F10, (VK_F10+HT_VK)}, {K_Home, (VK_HOME+HT_VK)}, {K_Up, (VK_UP+HT_VK)}, {K_PageUp, (VK_PRIOR+HT_VK)}, // {K_Meta_KPMinus, 0x14a}, {K_Left, (VK_LEFT+HT_VK)}, // {K_Center, 0x14c}, {K_Right, (VK_RIGHT+HT_VK)}, // {K_Meta_KPPlus, 0x14e}, {K_End, (VK_END+HT_VK)}, {K_Down, (VK_DOWN+HT_VK)}, {K_PageDown, (VK_NEXT+HT_VK)}, {K_Insert, (VK_INSERT+HT_VK)}, {K_Delete, (VK_DELETE+HT_VK)}, {K_Shift_F1, (VK_F1+HT_VK+HT_VK_SHIFT)}, {K_Shift_F2, (VK_F2+HT_VK+HT_VK_SHIFT)}, {K_Shift_F3, (VK_F3+HT_VK+HT_VK_SHIFT)}, {K_Shift_F4, (VK_F4+HT_VK+HT_VK_SHIFT)}, {K_Shift_F5, (VK_F5+HT_VK+HT_VK_SHIFT)}, {K_Shift_F6, (VK_F6+HT_VK+HT_VK_SHIFT)}, {K_Shift_F7, (VK_F7+HT_VK+HT_VK_SHIFT)}, {K_Shift_F8, (VK_F8+HT_VK+HT_VK_SHIFT)}, {K_Shift_F9, (VK_F9+HT_VK+HT_VK_SHIFT)}, {K_Shift_F10, (VK_F10+HT_VK+HT_VK_SHIFT)}, {K_Control_F1, (VK_F1+HT_VK+HT_VK_CTRL)}, {K_Control_F2, (VK_F2+HT_VK+HT_VK_CTRL)}, {K_Control_F3, (VK_F3+HT_VK+HT_VK_CTRL)}, {K_Control_F4, (VK_F4+HT_VK+HT_VK_CTRL)}, {K_Control_F5, (VK_F5+HT_VK+HT_VK_CTRL)}, {K_Control_F6, (VK_F6+HT_VK+HT_VK_CTRL)}, {K_Control_F7, (VK_F7+HT_VK+HT_VK_CTRL)}, {K_Control_F8, (VK_F8+HT_VK+HT_VK_CTRL)}, {K_Control_F9, (VK_F9+HT_VK+HT_VK_CTRL)}, {K_Control_F10, (VK_F10+HT_VK+HT_VK_CTRL)}, {K_Meta_F1, (VK_F1+HT_VK+HT_VK_ALT)}, {K_Meta_F2, (VK_F2+HT_VK+HT_VK_ALT)}, {K_Meta_F3, (VK_F3+HT_VK+HT_VK_ALT)}, {K_Meta_F4, (VK_F4+HT_VK+HT_VK_ALT)}, {K_Meta_F5, (VK_F5+HT_VK+HT_VK_ALT)}, {K_Meta_F6, (VK_F6+HT_VK+HT_VK_ALT)}, {K_Meta_F7, (VK_F7+HT_VK+HT_VK_ALT)}, {K_Meta_F8, (VK_F8+HT_VK+HT_VK_ALT)}, {K_Meta_F9, (VK_F9+HT_VK+HT_VK_ALT)}, {K_Meta_F10, (VK_F10+HT_VK+HT_VK_ALT)}, // {K_Control_Print 0x172}, {K_Control_Left, (VK_LEFT+HT_VK_CTRL+HT_VK)}, {K_Control_Right, (VK_RIGHT+HT_VK_CTRL+HT_VK)}, {K_Control_End, (VK_END+HT_VK_CTRL+HT_VK)}, {K_Control_PageDown, (VK_NEXT+HT_VK_CTRL+HT_VK)}, {K_Control_Home, (VK_HOME+HT_VK_CTRL+HT_VK)}, {K_Meta_1, ('1'+HT_VK_ALT)}, {K_Meta_2, ('2'+HT_VK_ALT)}, {K_Meta_3, ('3'+HT_VK_ALT)}, {K_Meta_4, ('4'+HT_VK_ALT)}, {K_Meta_5, ('5'+HT_VK_ALT)}, {K_Meta_6, ('6'+HT_VK_ALT)}, {K_Meta_7, ('7'+HT_VK_ALT)}, {K_Meta_8, ('8'+HT_VK_ALT)}, {K_Meta_9, ('9'+HT_VK_ALT)}, {K_Meta_0, ('0'+HT_VK_ALT)}, // {K_Meta_Dash, 0x182}, // {K_Meta_Equals, 0x183}, {K_Control_PageUp, (VK_PRIOR+HT_VK_CTRL+HT_VK)}, {K_F11, (VK_F11+HT_VK+HT_VK)}, {K_F12, (VK_F12+HT_VK+HT_VK)}, {K_Shift_F11, (VK_F11+HT_VK+HT_VK_SHIFT)}, {K_Shift_F12, (VK_F12+HT_VK+HT_VK_SHIFT)}, {K_Control_F11, (VK_F11+HT_VK+HT_VK_CTRL)}, {K_Control_F12, (VK_F12+HT_VK+HT_VK_CTRL)}, {K_Meta_F11, (VK_F11+HT_VK+HT_VK_ALT)}, {K_Meta_F12, (VK_F12+HT_VK+HT_VK_ALT)}, {K_Control_Up, (VK_UP+HT_VK_CTRL+HT_VK)}, // {K_Control_KPDash, 0x18e}, // {K_Control_Center, 0x18f}, // {K_Control_KPPlus, 0x190}, {K_Control_Down, (VK_DOWN+HT_VK_CTRL+HT_VK)}, {K_Control_Insert, (VK_INSERT+HT_VK_CTRL+HT_VK)}, {K_Control_Delete, (VK_DELETE+HT_VK_CTRL+HT_VK)}, // {K_Control_KPSlash, 0x195}, // {K_Control_KPStar, 0x196}, {K_Meta_Tab, (VK_TAB+HT_VK_ALT+HT_VK)}, {K_Meta_Enter, (VK_RETURN+HT_VK+HT_VK_ALT)}, {K_Shift_Up, (HT_VK_SHIFT+VK_UP+HT_VK)}, {K_Shift_Down, (HT_VK_SHIFT+VK_DOWN+HT_VK)}, {K_Shift_Left, (HT_VK_SHIFT+VK_LEFT+HT_VK)}, {K_Shift_Right, (HT_VK_SHIFT+VK_RIGHT+HT_VK)}, {K_Shift_PageUp, (HT_VK_SHIFT+VK_PRIOR+HT_VK)}, {K_Shift_PageDown, (HT_VK_SHIFT+VK_NEXT+HT_VK)}, {K_Shift_Home, (HT_VK_SHIFT+VK_HOME+HT_VK)}, {K_Shift_End, (HT_VK_SHIFT+VK_END+HT_VK)}, {K_Shift_Delete, (HT_VK_SHIFT+VK_DELETE+HT_VK)}, {K_Shift_Insert, (HT_VK_SHIFT+VK_INSERT+HT_VK)}, {K_INVALID, -1} }; static bool gWinChFlag; bool sys_get_winch_flag() { return gWinChFlag; } void sys_set_winch_flag(bool f) { gWinChFlag = f; } bool keyb_keypressed() { DWORD read; if (key_pending) return true; while (1) { PeekConsoleInputA(gInputHandle, &key_event_record, 1, &read); if (!read) return false; ReadConsoleInputA(gInputHandle, &key_event_record, 1, &read); if (key_event_record.EventType & KEY_EVENT) { switch (key_event_record.Event.KeyEvent.wVirtualKeyCode) { case VK_CONTROL: k_ctrl_state = key_event_record.Event.KeyEvent.bKeyDown; break; case VK_MENU: k_alt_state = key_event_record.Event.KeyEvent.bKeyDown; break; } if (key_event_record.Event.KeyEvent.bKeyDown) { key_pending = true; return true; } } else if (key_event_record.EventType & WINDOW_BUFFER_SIZE_EVENT) { gWinChFlag = true; } } } int ht_key_meta(bool shift, bool control, bool alt) { return (((key_event_record.Event.KeyEvent.dwControlKeyState & SHIFT_PRESSED) && shift) ? HT_VK_SHIFT : 0) +(((key_event_record.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED)) && control) ? HT_VK_CTRL : 0) +(((key_event_record.Event.KeyEvent.dwControlKeyState & (LEFT_ALT_PRESSED|RIGHT_ALT_PRESSED)) && alt) ? HT_VK_ALT : 0); } int keyb_getrawkey() { if (!keyb_keypressed()) return -1; key_pending = false; #ifdef KEY_DEBUG if (key_event_record.Event.KeyEvent.uChar.AsciiChar && !(key_event_record.Event.KeyEvent.dwControlKeyState & 256)) { fprintf(kd, "ASC: %4d [%c], control = 0x%lx {VK: %d shift: %d, alt: %d, ctrl: %d}\n", key_event_record.Event.KeyEvent.uChar.AsciiChar, ((unsigned)key_event_record.Event.KeyEvent.uChar.AsciiChar >= 32) ? key_event_record.Event.KeyEvent.uChar.AsciiChar: ' ', key_event_record.Event.KeyEvent.dwControlKeyState, key_event_record.Event.KeyEvent.wVirtualKeyCode, k_shift_state, k_alt_state, k_ctrl_state); } else { fprintf(kd, " VK: %4d shift: %d, alt: %d, ctrl: %d\n", key_event_record.Event.KeyEvent.wVirtualKeyCode, k_shift_state, k_alt_state, k_ctrl_state); } #endif if (key_event_record.Event.KeyEvent.uChar.AsciiChar && !(key_event_record.Event.KeyEvent.dwControlKeyState & 256)) { /* * Filter keys which also have a ascii representation. */ switch (key_event_record.Event.KeyEvent.wVirtualKeyCode) { case VK_BACK: case VK_TAB: case VK_RETURN: case VK_ESCAPE: case VK_CLEAR: return key_event_record.Event.KeyEvent.wVirtualKeyCode + HT_VK + ht_key_meta(true, true, true); } /* * Local keys, which can only be access via AltGr * [in german e.g. '\'=(altgr+'-') and '@'=(altgr+'q')] * are handled separately */ switch (key_event_record.Event.KeyEvent.uChar.AsciiChar) { case '\\': case '@': case '|': case 'ý': case '~': case '{': case '}': case '[': case ']': return ((unsigned char)key_event_record.Event.KeyEvent.uChar.AsciiChar) + ht_key_meta(false, false, false); default: return ((unsigned char)key_event_record.Event.KeyEvent.uChar.AsciiChar) + ht_key_meta(false, true, true); } } else { return key_event_record.Event.KeyEvent.wVirtualKeyCode + HT_VK + ht_key_meta(true, true, true); } } ht_key keyb_getkey() { UINT r = keyb_getrawkey(); ht_key k = keyb_rawkey2key(r); if (k == K_INVALID && r <= 255) return (ht_key)r; return k; } bool init_keyb() { gInputHandle = GetStdHandle(STD_INPUT_HANDLE); SetConsoleMode(gInputHandle, 0); //ENABLE_PROCESSED_INPUT); #ifdef KEY_DEBUG kd = fopen("_kd.kd", "wt"); #endif int i; for (i=0; i<K_COUNT; i++) { keyb_setkey((ht_key)i, -1); } for (i=0; ht_win32_key_defs[i].key!=K_INVALID; i++) { keyb_setkey(ht_win32_key_defs[i].key, ht_win32_key_defs[i].keycode); } return true; } void done_keyb() { #ifdef KEY_DEBUG fclose(kd); #endif } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/win32/types.h��������������������������������������������������������������������������0000644�0001750�0000144�00000002243�10615343757�012027� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * PearPC * types.h * * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __WIN32_TYPES_H__ #define __WIN32_TYPES_H__ // >> FIXME: only works on x86 typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; typedef unsigned long long uint64; typedef signed char sint8; typedef signed short sint16; typedef signed int sint32; typedef signed long long sint64; // << typedef unsigned int uint; typedef signed int sint; typedef uint8 byte; #endif �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/win32/sysfile.cc�����������������������������������������������������������������������0000644�0001750�0001750�00000017073�11705633333�012503� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * sysfile.cc - file system functions for Win32 * * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <cctype> #include <errno.h> #include <cstdlib> #include <cstdio> #include <sys/stat.h> #include "io/sys.h" #include "io/file.h" #include "data.h" #include "strtools.h" #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #include <windows.h> struct winfindstate { HANDLE fhandle; WIN32_FIND_DATA find_data; }; bool sys_is_path_delim(char c) { return (c == '\\') /*|| (c == '/')*/; } inline bool sys_filename_is_absolute(const char *filename) { return (isalpha(filename[0]) && (filename[1] == ':') && sys_is_path_delim(filename[2])); } int sys_filename_cmp(const char *a, const char *b) { while (*a && *b) { if (sys_is_path_delim(*a) && sys_is_path_delim(*b)) { } else if (tolower(*a) != tolower(*b)) { break; /* } else if (*a != *b) { break;*/ } a++; b++; } return tolower(*a) - tolower(*b); } int sys_canonicalize(char **result, const char *filename) { if (!sys_filename_is_absolute(filename)) return ENOENT; char *dunno; int res; int maxlen = 100; *result = (char*)malloc(maxlen); while ((res = GetFullPathName(filename, maxlen, *result, &dunno)) > 0) { if (res >= maxlen) { *result = (char*)realloc(*result, res); maxlen = res+1; } else { return 0; } } return ENOENT; } static uint filetime_to_ctime(FILETIME f) { uint64 q; q = ((uint64)f.dwHighDateTime) << 32 | f.dwLowDateTime; q /= 10000000ULL; // 100 nano-sec to full sec return q + 1240431886; // MAGIC: this is 1.1.1970 minus 1.1.1601 in seconds } static void sys_findfill(pfind_t &pfind) { /*DWORD dwFileAttributes; FILETIME ftCreationTime; FILETIME ftLastAccessTime; FILETIME ftLastWriteTime; DWORD nFileSizeHigh; DWORD nFileSizeLow; DWORD dwReserved0; DWORD dwReserved1; TCHAR cFileName[ MAX_PATH ]; TCHAR cAlternateFileName[ 14 ];*/ winfindstate *wfs = (winfindstate*)pfind.findstate; pfind.name = (char *)&wfs->find_data.cFileName; pfind.stat.caps = pstat_ctime|pstat_mtime|pstat_atime|pstat_size|pstat_mode_type; pfind.stat.size = (wfs->find_data.nFileSizeLow) | (((uint64)wfs->find_data.nFileSizeHigh) << 32); pfind.stat.mode = (wfs->find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? HT_S_IFDIR : HT_S_IFREG; pfind.stat.ctime = filetime_to_ctime(wfs->find_data.ftCreationTime); pfind.stat.mtime = filetime_to_ctime(wfs->find_data.ftLastWriteTime); pfind.stat.atime = filetime_to_ctime(wfs->find_data.ftLastAccessTime); } int sys_findfirst(pfind_t &pfind, const char *dirname) { if (!sys_filename_is_absolute(dirname)) return ENOENT; char *Dirname = ht_malloc(strlen(dirname)+5); strcpy(Dirname, dirname); int dnl = strlen(dirname); if ((dirname[dnl-1] != '\\') && (dirname[dnl-1] != '/')) { Dirname[dnl] = '\\'; Dirname[dnl+1] = 0; } char *s = Dirname; while ((s = strchr(s, '/'))) *s = '\\'; strcat(Dirname, "*.*"); pfind.findstate = malloc(sizeof (winfindstate)); winfindstate *wfs = (winfindstate*)pfind.findstate; wfs->fhandle = FindFirstFile(Dirname, &wfs->find_data); free(Dirname); if (wfs->fhandle == INVALID_HANDLE_VALUE) { free(pfind.findstate); return ENOENT; } sys_findfill(pfind); return 0; } int sys_findnext(pfind_t &pfind) { winfindstate *wfs = (winfindstate*)pfind.findstate; if (!FindNextFile(wfs->fhandle, &wfs->find_data)) { return ENOENT; } sys_findfill(pfind); return 0; } int sys_findclose(pfind_t &pfind) { int r = FindClose(((winfindstate*)pfind.findstate)->fhandle); free(pfind.findstate); return r ? ENOENT : 0; } static void stat_to_pstat_t(const struct stat &st, pstat_t &s) { s.caps = pstat_ctime|pstat_mtime|pstat_atime|pstat_uid|pstat_gid|pstat_mode_all|pstat_size|pstat_inode; s.ctime = st.st_ctime; s.mtime = st.st_mtime; s.atime = st.st_atime; s.gid = st.st_uid; s.uid = st.st_gid; s.mode = sys_file_mode(st.st_mode); s.size = st.st_size; s.fsid = st.st_ino; } int sys_pstat(pstat_t &s, const char *filename) { char fn[HT_NAME_MAX]; ht_strlcpy(fn, filename, sizeof fn); int flen = strlen(fn); if (flen && sys_is_path_delim(fn[flen-1]) && (flen !=3) || (fn[1]!=':')) fn[flen-1] = 0; if (!sys_filename_is_absolute(fn)) return ENOENT; struct stat st; int e = stat(fn, &st); if (e) return errno ? errno : ENOENT; stat_to_pstat_t(st, s); return 0; } int sys_pstat_fd(pstat_t &s, int fd) { struct stat st; int e = fstat(fd, &st); if (e) return errno ? errno : ENOENT; stat_to_pstat_t(st, s); return 0; } int sys_pstat_filename(pstat_t &s, const char *filename) { } int sys_pstat_file(pstat_t &s, SYS_FILE *file) { return sys_pstat_fd(s, fileno((FILE*)file)); } int sys_truncate(const char *filename, FileOfs ofs) { if (!sys_filename_is_absolute(filename)) return ENOENT; HANDLE hfile = CreateFile(filename, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hfile == INVALID_HANDLE_VALUE) { return EIO; } if (SetFilePointer(hfile, ofs, NULL, FILE_BEGIN)==0xffffffff) { CloseHandle(hfile); return EIO; } if (!SetEndOfFile(hfile)) { CloseHandle(hfile); return EIO; } CloseHandle(hfile); return 0; } int sys_truncate_fd(int fd, FileOfs ofs) { return ENOSYS; } int sys_deletefile(const char *filename) { if (!sys_filename_is_absolute(filename)) return ENOENT; if (DeleteFile(filename)) { return 0; } return EIO; } void sys_suspend() { Sleep(42); } static const char *openmode2mode(FileOpenMode om, IOAccessMode am) { char *mode = NULL; switch (om) { case FOM_APPEND: mode = "ab+"; break; case FOM_CREATE: if (am & IOAM_WRITE) mode = "wb"; if (am & IOAM_READ) mode = "wb+"; break; case FOM_EXISTS: if (am & IOAM_READ) mode = "rb"; if (am & IOAM_WRITE) mode = "rb+"; break; } return mode; } SYS_FILE *sys_freopen(const char *filename, FileOpenMode openmode, IOAccessMode accessmode, SYS_FILE *file) { return (SYS_FILE *)freopen(filename, openmode2mode(openmode, accessmode), (FILE*)file); } SYS_FILE *sys_fopen(const char *filename, FileOpenMode openmode, IOAccessMode accessmode) { return (SYS_FILE *)fopen(filename, openmode2mode(openmode, accessmode)); } void sys_fclose(SYS_FILE *file) { fclose((FILE *)file); } int sys_fread(SYS_FILE *file, byte *buf, int size) { return fread(buf, 1, size, (FILE *)file); } int sys_fwrite(SYS_FILE *file, byte *buf, int size) { return fwrite(buf, 1, size, (FILE *)file); } int sys_fseek(SYS_FILE *file, FileOfs newofs, int seekmode) { int r; switch (seekmode) { case SYS_SEEK_SET: r = fseek((FILE *)file, newofs, SEEK_SET); break; case SYS_SEEK_REL: r = fseek((FILE *)file, newofs, SEEK_CUR); break; case SYS_SEEK_END: r = fseek((FILE *)file, newofs, SEEK_END); break; default: return EINVAL; } return r ? errno : 0; } FileOfs sys_ftell(SYS_FILE *file) { return ftell((FILE *)file); } const char *sys_get_name() { return "win32"; } int sys_get_caps() { return SYSCAP_NATIVE_CLIPBOARD; } /* * INIT */ bool init_system() { return true; } /* * DONE */ void done_system() { } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/win32/sysclipboard.cc������������������������������������������������������������������0000755�0001750�0000144�00000004256�11013057540�013511� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * clipboard.cc - Win32-specific (windows-)clipboard functions * * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define WIN32_LEAN_AND_MEAN #include <windows.h> #define MIN(a,b) (((a)<(b))?(a):(b)) bool sys_native_clipboard_write(const void *data, int size) { // FIXME: if (!OpenClipboard(NULL)) return false; HGLOBAL hdata; hdata = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, size); if (hdata) { void *ptr = GlobalLock(hdata); memcpy(ptr, data, size); GlobalUnlock(hdata); if (SetClipboardData(CF_OEMTEXT, hdata)) { CloseClipboard(); return true; } } CloseClipboard(); return false; } int sys_native_clipboard_get_size() { if (!OpenClipboard(NULL)) return false; HANDLE h = GetClipboardData(CF_OEMTEXT); int len = 0; if (h) { void *mem = GlobalLock(h); len = strlen((char*)mem); GlobalUnlock(h); } CloseClipboard(); return len; } #include "snprintf.h" int sys_native_clipboard_read(void *data, int max_size) { // ht_printf("sys_native_clipboard_read(%d)\n", max_size); if (!OpenClipboard(NULL)) return false; HANDLE hdata = GetClipboardData(CF_OEMTEXT); if (!hdata) { CloseClipboard(); return 0; } int size = GlobalSize(hdata); void *ptr = GlobalLock(hdata); int r = MIN(size, max_size); memcpy(data, ptr, r); GlobalUnlock(hdata); CloseClipboard(); // ht_printf("=%d\n", r); return r; } const char *sys_native_clipboard_name() { return "Windows Clipboard"; } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/win32/sysdisplay.cc��������������������������������������������������������������������0000644�0001750�0000144�00000025025�10771300605�013214� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * sysdisplay.cc - screen access functions for Win32 * * Copyright (C) 1999-2005 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "io/display.h" #include "io/types.h" #include <cstdio> #include <cstdlib> #include <cstring> #define WIN32_LEAN_AND_MEAN #include <windows.h> uint mapToGraphical(char chr) { switch (chr) { case GC_1VLINE: return 0x2502; case GC_1HLINE: return 0x2500; case GC_1CORNER0: return 0x2510; case GC_1CORNER1: return 0x2518; case GC_1CORNER2: return 0x2514; case GC_1CORNER3: return 0x250c; case GC_1UTEE: return 0x252c; case GC_1LTEE: return 0x251c; case GC_1DTEE: return 0x2534; case GC_1RTEE: return 0x2524; case GC_2VLINE: return 0x2551; case GC_2HLINE: return 0x2550; case GC_2CORNER0: return 0x2557; case GC_2CORNER1: return 0x255c; case GC_2CORNER2: return 0x255a; case GC_2CORNER3: return 0x2554; case GC_LOW: return 0x2591; case GC_MEDIUM: return 0x2592; case GC_HIGH: return 0x2593; case GC_FULL: return 0x2588; case GC_ARROW_UP: return 0x25b2; case GC_ARROW_DOWN: return 0x25bc; case GC_ARROW_LEFT: return 0x25c4; case GC_ARROW_RIGHT: return 0x25ba; case GC_SMALL_ARROW_UP: return 0x2191; case GC_SMALL_ARROW_DOWN: return 0x2193; case GC_FILLED_CIRCLE: return 0x25cf; case GC_FILLED_QUAD: return 0x25a0; case GC_FILLED_UPPER: return 0x2580; case GC_FILLED_LOWER: return 0x2584; } return '?'; } uint mapCharToSystemCP(char chr, Codepage codepage) { switch (codepage) { case CP_WINDOWS: case CP_UNICODE: return chr; case CP_DEVICE: if (byte(chr) > 127) { char in[2] = {chr, 0}; WCHAR out[2]; OemToCharW(in, out); return out[0]; } else { return chr; } case CP_GRAPHICAL: return mapToGraphical(chr); case CP_INVALID: return '?'; } return chr; } bool sys_get_screen_size(int &w, int &h) { CONSOLE_SCREEN_BUFFER_INFO screen_info; GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &screen_info); w = screen_info.srWindow.Right - screen_info.srWindow.Left + 1; h = screen_info.srWindow.Bottom - screen_info.srWindow.Top + 1; return true; } /* * Class Win32SystemDisplay */ class Win32SystemDisplay: public SystemDisplay { public: CHAR_INFO *buf; CHAR_INFO *old_buf; vcp *colorbuf; HANDLE output; CursorMode cursor_mode; CursorMode last_cursor_mode; int cursorx, cursory; int dx, dy; void cursorBold(); void cursorHide(); void cursorNormal(); bool initConsole(); public: Win32SystemDisplay(const char *title); virtual ~Win32SystemDisplay(); /* extends Display */ virtual void copyFromDisplay(const Display &display, int x, int y, const Bounds &clipping); virtual void fill(int x, int y, int w, int h, vcp color, char chr, Codepage cp = CP_DEVICE); virtual void getCursor(int &x, int &y) const; virtual CursorMode getCursorMode() const; virtual int nprint(int x, int y, vcp color, const char *str, int maxstrlen, Codepage codepage = CP_DEVICE); virtual bool read(uint &rawchar, vcp &color, int x, int y) const; virtual void setBounds(const Bounds &b); virtual void setCursor(int x, int y, CursorMode mode = CURSOR_NORMAL); virtual void setCursorMode(CursorMode mode = CURSOR_NORMAL); /* extends SystemDisplay */ virtual void show(); /* new */ void putChar(int dest, uint rawchar, vcp vc); uint vcpToSystem(vcp color); }; Win32SystemDisplay::Win32SystemDisplay(const char *title) : SystemDisplay() { CONSOLE_SCREEN_BUFFER_INFO screen_info; buf = NULL; colorbuf = NULL; old_buf = NULL; if (!initConsole()) ;//throw sys_exception("unable to init console"); GetConsoleScreenBufferInfo(output, &screen_info); SetConsoleTitleA(title); assign(0, 0, screen_info.srWindow.Right - screen_info.srWindow.Left + 1, screen_info.srWindow.Bottom - screen_info.srWindow.Top + 1); dx = screen_info.srWindow.Left; dy = screen_info.srWindow.Top; setCursor(dx, dy, CURSOR_OFF); last_cursor_mode = CURSOR_NORMAL; /* COORD xy; xy.X = dx; xy.Y = dy; SetConsoleCursorPosition(output, xy); xy.X = dx+w-1; xy.Y = dy+h-1; SetConsoleCursorPosition(output, xy); xy.X = dx; xy.Y = dy; SetConsoleCursorPosition(output, xy); ScrollConsoleScreenBuffer(output, );*/ show(); } Win32SystemDisplay::~Win32SystemDisplay() { COORD xy; printChar(w-1, h-1, VCP(VC_WHITE, VC_BLACK), ' '); xy.X = dx; xy.Y = dy+h-1; SetConsoleCursorPosition(output, xy); free(buf); free(old_buf); free(colorbuf); cursorNormal(); } bool Win32SystemDisplay::initConsole() { CONSOLE_SCREEN_BUFFER_INFO csbiInfo; SMALL_RECT windowRect; output = GetStdHandle(STD_OUTPUT_HANDLE); if (output == INVALID_HANDLE_VALUE) return false; /* if (!SetConsoleActiveScreenBuffer(output)) return false; if (!GetConsoleScreenBufferInfo(output, &csbiInfo)) return false; windowRect.Left = 0; windowRect.Top = 0; windowRect.Right = csbiInfo.dwSize.X - 1; windowRect.Bottom = csbiInfo.dwSize.Y - 1; if (!SetConsoleWindowInfo(output, TRUE, &windowRect)) return false;*/ if (!SetConsoleMode(output, 0)) return false; return true; } void Win32SystemDisplay::fill(int x, int y, int w, int h, vcp color, char chr, Codepage codepage) { uint rawchar = mapCharToSystemCP(chr, codepage); for (int i=0; i < h; i++) { if (y+i >= this->h) break; if (y+i < 0) continue; int dest = x + (y+i)*this->w; for (int j=0; j < w; j++) { if (x+j >= this->w) break; if (x+j >= 0) putChar(dest, rawchar, color); dest++; } } } int Win32SystemDisplay::nprint(int x, int y, vcp color, const char *str, int maxstrlen, Codepage codepage) { int n = 0; int dest = x + y*w; while (*str && n < maxstrlen && x+n < w) { if (x+n >= 0) putChar(dest, mapCharToSystemCP(*str, codepage), color); dest++; str++; n++; } return n; } bool Win32SystemDisplay::read(uint &rawchar, vcp &color, int x, int y) const { rawchar = buf[x+y*w].Char.AsciiChar; color = colorbuf[x+y*w]; return true; } void Win32SystemDisplay::setBounds(const Bounds &b) { SystemDisplay::setBounds(b); free(buf); free(old_buf); free(colorbuf); buf = ht_malloc(w * h * sizeof(CHAR_INFO)); old_buf = ht_malloc(w * h * sizeof(CHAR_INFO)); colorbuf = ht_malloc(w * h * sizeof(vcp)); memset(old_buf, 0, w * h * sizeof(CHAR_INFO)); fill(x, y, w, h, VCP(VC_WHITE, VC_BLACK), ' '); } void Win32SystemDisplay::copyFromDisplay(const Display &d, int x, int y, const Bounds &clipping) { for (int iy=0; iy < d.h; iy++) { if (y+iy >= clipping.y+clipping.h) break; if (y+iy < clipping.y) break; int dest = x+(iy+y)*w; for (int ix=0; ix < d.w; ix++) { uint rawchar; vcp color; d.read(rawchar, color, ix, iy); if ((x+ix < clipping.x+clipping.w) && (x+ix >= clipping.x)) putChar(dest, rawchar, color); dest++; } } } void Win32SystemDisplay::getCursor(int &x, int &y) const { x = cursorx; y = cursory; } CursorMode Win32SystemDisplay::getCursorMode() const { return cursor_mode; } void Win32SystemDisplay::putChar(int dest, uint rawchar, vcp vc) { if (dest >= w*h || dest < 0) return; buf[dest].Char.UnicodeChar = rawchar ? rawchar : ' '; colorbuf[dest] = mixColors(colorbuf[dest], vc); buf[dest].Attributes = vcpToSystem(colorbuf[dest]); } void Win32SystemDisplay::setCursor(int x, int y, CursorMode mode) { cursorx = x; cursory = y; if (cursorx < 0) cursorx = 0; if (cursory < 0) cursory = 0; if (cursorx >= w) cursorx = w-1; if (cursory >= h) cursory = h-1; setCursorMode(mode); } void Win32SystemDisplay::setCursorMode(CursorMode mode) { cursor_mode = mode; } void Win32SystemDisplay::show() { int first = h, last = 0; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { if (buf[y*w+x].Char.UnicodeChar != old_buf[y*w+x].Char.UnicodeChar || buf[y*w+x].Attributes != old_buf[y*w+x].Attributes) { if (first == h) { first = y; } last = y; break; } } } COORD xy, xy2; if (cursor_mode != CURSOR_OFF) { xy.X = cursorx + dx; xy.Y = cursory + dy; } else { xy.X = dx; xy.Y = dy; } SetConsoleCursorPosition(output, xy); if (last_cursor_mode != cursor_mode) { switch (cursor_mode) { case CURSOR_OFF: cursorHide(); break; case CURSOR_NORMAL: cursorNormal(); break; case CURSOR_BOLD: cursorBold(); break; } last_cursor_mode = cursor_mode; } if (first > last) return; xy.X = 0; xy.Y = first; xy2.X = w; xy2.Y = h; SMALL_RECT sr; sr.Left = dx; sr.Top = dy+first; sr.Right = dx+w-1; sr.Bottom = dy+last; WriteConsoleOutputW(output, buf, xy2, xy, &sr); memcpy(old_buf, buf, w * h * sizeof(CHAR_INFO)); return; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { // if (buf[y*w+x].Char.UnicodeChar != old_buf[y*w+x].Char.UnicodeChar // || buf[y*w+x].Attributes != old_buf[y*w+x].Attributes) { xy.X = x; xy.Y = y; xy2.X = w; xy2.Y = h; SMALL_RECT sr; sr.Left = dx+x; sr.Top = dy+y; sr.Right = dx+x+1; sr.Bottom = dy+y+1; WriteConsoleOutputW(output, buf, xy2, xy, &sr); // } } } memcpy(old_buf, buf, w * h * sizeof(CHAR_INFO)); } void Win32SystemDisplay::cursorHide() { COORD xy; xy.X = dx+w-1; xy.Y = dy+h-1; SetConsoleCursorPosition(output, xy); CONSOLE_CURSOR_INFO ci; ci.dwSize = 1; ci.bVisible = false; SetConsoleCursorInfo(output, &ci); } void Win32SystemDisplay::cursorBold() { CONSOLE_CURSOR_INFO ci; ci.dwSize = 99; ci.bVisible = true; SetConsoleCursorInfo(output, &ci); } void Win32SystemDisplay::cursorNormal() { CONSOLE_CURSOR_INFO ci; ci.dwSize = 13; ci.bVisible = true; SetConsoleCursorInfo(output, &ci); } uint Win32SystemDisplay::vcpToSystem(vcp vc) { byte fg, bg; if (VC_GET_LIGHT(VCP_BACKGROUND(vc))) { bg=VC_GET_BASECOLOR(VCP_BACKGROUND(vc))+8; } else { bg=VC_GET_BASECOLOR(VCP_BACKGROUND(vc)); } if (VC_GET_LIGHT(VCP_FOREGROUND(vc))) { fg=VC_GET_BASECOLOR(VCP_FOREGROUND(vc))+8; } else { fg=VC_GET_BASECOLOR(VCP_FOREGROUND(vc)); } return (bg<<4|fg); } static int sysdisplay_count = 0; SystemDisplay *allocSystemDisplay(const char *title) { if (sysdisplay_count) return NULL; sysdisplay_count++; return new Win32SystemDisplay(title); } void sys_display_enter() { } void sys_display_leave() { } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/win32/Makefile.am����������������������������������������������������������������������0000644�0001750�0001750�00000000402�11724770100�012531� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/io AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_LIBRARIES = libhtio.a libhtio_a_SOURCES = syskeyb.cc sysfile.cc sysclipboard.cc sysdisplay.cc types.h ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/win32/Makefile.in����������������������������������������������������������������������0000644�0001750�0001750�00000031756�12127657374�012601� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Makefile.in generated by automake 1.10.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = io/win32 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru libhtio_a_AR = $(AR) $(ARFLAGS) libhtio_a_LIBADD = am_libhtio_a_OBJECTS = syskeyb.$(OBJEXT) sysfile.$(OBJEXT) \ sysclipboard.$(OBJEXT) sysdisplay.$(OBJEXT) libhtio_a_OBJECTS = $(am_libhtio_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libhtio_a_SOURCES) DIST_SOURCES = $(libhtio_a_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ HT_LDFLAGS = @HT_LDFLAGS@ HT_LIBS = @HT_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IO_DIR = @IO_DIR@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ LZO_LIBS = @LZO_LIBS@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ curses_CPPFLAGS = @curses_CPPFLAGS@ curses_LIBS = @curses_LIBS@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ ncurses_config = @ncurses_config@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/io AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_LIBRARIES = libhtio.a libhtio_a_SOURCES = syskeyb.cc sysfile.cc sysclipboard.cc sysdisplay.cc types.h all: all-am .SUFFIXES: .SUFFIXES: .cc .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign io/win32/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign io/win32/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libhtio.a: $(libhtio_a_OBJECTS) $(libhtio_a_DEPENDENCIES) -rm -f libhtio.a $(libhtio_a_AR) libhtio.a $(libhtio_a_OBJECTS) $(libhtio_a_LIBADD) $(RANLIB) libhtio.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysclipboard.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysdisplay.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syskeyb.Po@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ������������������ht-2.0.22/io/display.h������������������������������������������������������������������������������0000755�0001750�0000144�00000021275�10615344121�011361� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * display.h * * Copyright (C) 1999-2004 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __DISPLAY_H__ #define __DISPLAY_H__ #include "bounds.h" #include "types.h" #include "data.h" /* codepages */ enum Codepage { CP_INVALID = 0, CP_DEVICE, CP_GRAPHICAL, CP_WINDOWS, CP_UNICODE, }; /* "graphical" chars (ie. lines, corners and patterns like in ASCII) */ // if a char has all 4 orthogonally possible alignments, we suffix its name // by a number 0..3, counting clockwise (mathematically positive) #define GC_TRANSPARENT '0' // transparent #define GC_1VLINE '|' // single vertical line #define GC_1HLINE '-' // single horizontal line #define GC_1CORNER0 'l' // right-upper corner, single #define GC_1CORNER1 'j' // right-lower corner, single #define GC_1CORNER2 'L' // left-lower corner, single #define GC_1CORNER3 'F' // left-upper corner, single #define GC_1UTEE 0x01 // 'T', with "nose" pointing up #define GC_1LTEE 0x02 // 'T', with "nose" pointing left #define GC_1DTEE 0x03 // 'T', with "nose" pointing down #define GC_1RTEE 0x04 // 'T', with "nose" pointing right #define GC_1CROSS 0x05 // a cross like in '+', but bigger to fit with other line-drawing chars #define GC_2VLINE 'H' // double vertical line #define GC_2HLINE '=' // double horizontal line #define GC_2CORNER0 0x06 // right-upper corner, double #define GC_2CORNER1 0x07 // right-lower corner, double #define GC_2CORNER2 0x08 // left-lower corner, double #define GC_2CORNER3 0x09 // left-upper corner, double #define GC_LOW 0x0a // regular pattern, density: low #define GC_MEDIUM 0x0b // regular pattern, density: medium #define GC_HIGH 0x0c // regular pattern, density: high #define GC_FULL 0x0d // regular pattern, density: full #define GC_ARROW_UP '^' // a filled triangle, points up #define GC_ARROW_DOWN 'v' // a filled triangle, points down #define GC_ARROW_LEFT '<' // a filled triangle, points left #define GC_ARROW_RIGHT '>' // a filled triangle, points right #define GC_SMALL_ARROW_UP 'A' // an arrow up #define GC_SMALL_ARROW_DOWN 'V' // an arrow down #define GC_FILLED_CIRCLE 'o' // a filled and centered circle #define GC_FILLED_QUAD 'x' // a filled and centered quad #define GC_FILLED_UPPER 0x0e // upper half filled #define GC_FILLED_LOWER 0x0f // lower half filled /* virtual colors */ typedef int vc; #define NUM_VCS 15 // real colors #define VC_BLACK 0 #define VC_BLUE 1 #define VC_GREEN 2 #define VC_CYAN 3 #define VC_RED 4 #define VC_MAGENTA 5 #define VC_YELLOW 6 #define VC_WHITE 7 // functional colors #define VC_TRANSPARENT 8 #define VC_LIGHTEN 9 #define VC_DARKEN 10 #define VC_MONOCHROME 11 #define VC_INVERSE 12 // like VC_TRANSPARENT, but always change 'this color' if it would equal the 'other color' #define VC_TRANSPARENT_EXCLUSIVE 13 // like VC_TRANSPARENT, but always change the 'other color' if it would equal 'this color' #define VC_TRANSPARENT_EXCLUSIVE_DOM 14 #define VC_LIGHT(vc) ((vc) | 0x80) #define VC_GET_LIGHT(vc) ((vc) & 0x80) #define VC_GET_BASECOLOR(vc) ((vc) & 0x7f) /* virtual color pairs (fg/bg) */ typedef int vcp; #define VCP_INVALID -1 #define VCP(vc_fg, vc_bg) (vcp)((vc_bg) | ((vc_fg)<<8)) #define VCP_BACKGROUND(v) ((v) & 0xff) #define VCP_FOREGROUND(v) ((v>>8) & 0xff) vcp mixColors(vcp base, vcp layer); /* * Display (absolute/screen coordinates) */ struct AbstractChar { Codepage codepage; uint32 chr; }; struct AbstractColoredChar { Codepage codepage; vcp color; uint32 chr; }; enum CursorMode { CURSOR_OFF, CURSOR_NORMAL, CURSOR_BOLD }; class Display: public Bounds { public: Display() {}; Display(const Bounds &b) : Bounds(b) {}; virtual ~Display() {}; /* extends Bounds */ virtual void assign(int x, int y, int w, int h); virtual void move(int deltax, int deltay); virtual void resize(int deltaw, int deltah); /* new */ virtual void fill(int x, int y, int w, int h, vcp color, char chr, Codepage cp = CP_DEVICE) = 0; void fillAll(vcp color, char chr, Codepage cp = CP_DEVICE); virtual void getCursor(int &x, int &y) const = 0; virtual CursorMode getCursorMode() const = 0; virtual int nprint(int x, int y, vcp color, const char *str, int maxstrlen, Codepage cp = CP_DEVICE) = 0; int nprintW(int x, int y, vcp color, const AbstractChar *widestr, int maxstrlen); int nprintf(int x, int y, vcp color, int maxstrlen, Codepage cp, const char *format, ...); int print(int x, int y, vcp color, const char *str, Codepage cp = CP_DEVICE); int printW(int x, int y, vcp color, const AbstractChar *widestr); int printChar(int x, int y, vcp color, char chr, Codepage cp = CP_DEVICE); int printf(int x, int y, vcp color, Codepage cp, const char *format, ...); virtual bool read(uint &rawchar, vcp &color, int x, int y) const = 0; virtual void setBounds(const Bounds &b); virtual void setCursor(int x, int y, CursorMode mode = CURSOR_NORMAL) = 0; virtual void setCursorMode(CursorMode mode = CURSOR_NORMAL) = 0; #if 0 /* graphical extension */ virtual void line(int px1, int py1, int px2, int py2, uint color); virtual void putPixel(int px, int py, uint color); virtual void textToPixelCoord(int tx, int ty, int &px, int &py) const; virtual void pixelToTextCoord(int px, int py, int &tx, int &ty) const; #endif }; /* * RDisplay (relative coords) */ typedef Display RDisplay; /* * NullRDisplay */ class NullRDisplay: public RDisplay { protected: uint cursorx, cursory; CursorMode cursorMode; public: NullRDisplay(const Bounds &b); /* extends Display */ virtual void fill(int x, int y, int w, int h, vcp color, char chr, Codepage cp = CP_DEVICE); virtual void getCursor(int &x, int &y) const; virtual CursorMode getCursorMode() const; virtual int nprint(int x, int y, vcp color, const char *str, int maxstrlen, Codepage cp = CP_DEVICE); virtual bool read(uint &rawchar, vcp &color, int x, int y) const; virtual void setCursor(int x, int y, CursorMode mode = CURSOR_NORMAL); virtual void setCursorMode(CursorMode mode = CURSOR_NORMAL); }; /* * BufferedRDisplay */ struct ColoredChar { uint rawchar; vcp color; }; class BufferedRDisplay: public RDisplay { protected: int cursorx, cursory; CursorMode cursorMode; public: ColoredChar *buf; BufferedRDisplay(const Bounds &b); virtual ~BufferedRDisplay(); /* extends RDisplay */ virtual void fill(int x, int y, int w, int h, vcp color, char chr, Codepage cp = CP_DEVICE); virtual void getCursor(int &x, int &y) const; virtual CursorMode getCursorMode() const; virtual int nprint(int x, int y, vcp color, const char *str, int maxstrlen, Codepage cp = CP_DEVICE); virtual bool read(uint &rawchar, vcp &color, int x, int y) const; virtual void setBounds(const Bounds &b); virtual void setCursor(int x, int y, CursorMode mode = CURSOR_NORMAL); virtual void setCursorMode(CursorMode mode = CURSOR_NORMAL); }; /* system-dependant (implementation in $MYSYSTEM/ *.cc) */ uint mapCharToSystemCP(char chr, Codepage cp); bool sys_get_screen_size(int &w, int &h); bool sys_set_screen_size(int w, int h); bool sys_get_winch_flag(); void sys_set_winch_flag(bool f); class SystemDisplay: public Display { public: SystemDisplay(); /* new */ virtual void copyFromDisplay(const Display &display, int x, int y, const Bounds &clipping) = 0; virtual void show() = 0; }; SystemDisplay *allocSystemDisplay(const char *title); /* * SystemRDisplay */ class SystemRDisplay: public RDisplay { public: SystemDisplay *system_display; SystemRDisplay(SystemDisplay *system_display, const Bounds &b); virtual ~SystemRDisplay(); /* extends Display */ virtual void fill(int x, int y, int w, int h, vcp color, char chr, Codepage cp = CP_DEVICE); virtual void getCursor(int &x, int &y) const; virtual CursorMode getCursorMode() const; virtual int nprint(int x, int y, vcp color, const char *str, int maxstrlen, Codepage cp = CP_DEVICE); virtual bool read(uint &rawchar, vcp &color, int x, int y) const; virtual void setBounds(const Bounds &b); virtual void setCursor(int x, int y, CursorMode mode = CURSOR_NORMAL); virtual void setCursorMode(CursorMode mode = CURSOR_NORMAL); }; #endif /* __DISPLAY_H__ */ �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/file.cc��������������������������������������������������������������������������������0000755�0001750�0001750�00000022425�12127651420�010776� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * file.cc * * Copyright (C) 1999-2004 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "file.h" #include <ctype.h> #include <errno.h> #include <limits.h> #include <cstdarg> #include <cstdio> #include <cstdlib> #include <cstring> #include <sys/stat.h> #include "strtools.h" #include "str.h" /* * COMMON SYS */ #ifndef S_IFMT #define S_IFMT 0xf000 #endif #ifndef S_ISREG # ifndef S_IFREG # define S_ISREG(m) (0) # else # define S_ISREG(m) (((m) & S_IFMT)==S_IFREG) # endif #endif #ifndef S_ISBLK # ifndef S_IFBLK # define S_ISBLK(m) (0) # else # define S_ISBLK(m) (((m) & S_IFMT)==S_IFBLK) # endif #endif #ifndef S_ISCHR # ifndef S_IFCHR # define S_ISCHR(m) (0) # else # define S_ISCHR(m) (((m) & S_IFMT)==S_IFCHR) # endif #endif #ifndef S_ISDIR # ifndef S_IFDIR # define S_ISDIR(m) (0) # else # define S_ISDIR(m) (((m) & S_IFMT)==S_IFDIR) # endif #endif #ifndef S_ISFIFO # ifndef S_IFFIFO # define S_ISFIFO(m) (0) # else # define S_ISFIFO(m) (((m) & S_IFMT)==S_IFFIFO) # endif #endif #ifndef S_ISLNK # ifndef S_IFLNK # define S_ISLNK(m) (0) # else # define S_ISLNK(m) (((m) & S_IFMT)==S_IFLNK) # endif #endif #ifndef S_ISSOCK # ifndef S_IFSOCK # define S_ISSOCK(m) (0) # else # define S_ISSOCK(m) (((m) & S_IFMT)==S_IFSOCK) # endif #endif #ifndef S_IRUSR #define S_IRUSR 0 #endif #ifndef S_IRGRP #define S_IRGRP 0 #endif #ifndef S_IROTH #define S_IROTH 0 #endif #ifndef S_IWUSR #define S_IWUSR 0 #endif #ifndef S_IWGRP #define S_IWGRP 0 #endif #ifndef S_IWOTH #define S_IWOTH 0 #endif #ifndef S_IXUSR #define S_IXUSR 0 #endif #ifndef S_IXGRP #define S_IXGRP 0 #endif #ifndef S_IXOTH #define S_IXOTH 0 #endif #if defined(WIN32) || defined(__WIN32__) # include <windows.h> # include <winreg.h> #endif //----------------------------------------------------------------------------- static char *_str_strip(char *str, int len) { char *pr = ht_malloc(len + 1); pr[len] = 0; memcpy(pr, str, len); return pr; } //----------------------------------------------------------------------------- /* 1. char *s - old string 2. unsigned int s_len - old string len 3. char *r - new string 4. unsigned int r_len - new string len 5. unsigned int at - offset in old string 6. unsigned int len - len of substring for delete ( at - start) */ static char *_substr_replace(char *s, unsigned int s_len, char *r, unsigned int r_len, unsigned int at, unsigned int len) { if (!s_len || !r_len) return NULL; if (at > s_len) at = 0; unsigned int nlen = s_len + r_len - len; char *out = ht_malloc(nlen+1); out[nlen] = 0; memcpy(out, s, at); memcpy(out+at, r, r_len); while (s_len-- > (at + len)) { out[--nlen] = s[s_len]; } return out; } //----------------------------------------------------------------------------- static char *_env_replace(char *str, unsigned int len) { bool e = false; unsigned int cc = 0; // count unsigned int sp = 0; // start pos char *p = NULL; char *prt = NULL; char *t; char *t2; while (cc != len) { t2 = prt?prt:str; #if defined(WIN32) || defined(__WIN32__) || defined(DJGPP) || defined(MSDOC) if (t2[cc] == '%' || t2[cc] == ' ') { #else if (t2[cc] == '$' || t2[cc] == ' ') { #endif if (e) { free(p); p = _str_strip(t2 + sp, cc - sp); if ((t = getenv(p)) != NULL) { prt = _substr_replace(t2, prt?strlen(prt):strlen(str), t, strlen(t), sp-1, (cc - sp) + 2); if (t2 != str) free(t2); len = strlen(prt); cc = sp; } e = false; } else { if (t2[cc] != ' ') { sp = cc + 1; e = true; } } } cc++; } if (prt == NULL) { prt = ht_malloc(len+1); prt[len] = 0; memcpy(prt, str, len); } return prt; } //----------------------------------------------------------------------------- int sys_basename(char *result, const char *filename) { // FIXME: use is_path_delim const char *slash1 = strrchr(filename, '/'); const char *slash2 = strrchr(filename, '\\'); const char *slash = (slash1 > slash2) ? slash1 : slash2; if (slash) { int l = strlen(filename); ht_strlcpy(result, slash+1, l-(slash-filename)+1); return 0; } strcpy(result, filename); return 0; } char *sys_dirname(char *path) { char *r; // result char *ptr = path; int c = 0; int last = 0; do { c++; if (*ptr == '/' || *ptr == '\\') { last = c; } else if (*ptr == 0) { r = ht_malloc(last + 1); strncpy(r, path, last); r[last] = 0; return r; } } while (*ptr++); return NULL; } /* filename and pathname must be canonicalized */ int sys_relname(char *result, const char *filename, const char *cwd) { const char *f = filename, *p = cwd; while ((*f == *p) && (*f)) { f++; p++; } if (*f == '/') f++; const char *last = f, *h = f; while (*h) { if (*h == '/') { *(result++) = '.'; *(result++) = '.'; *(result++) = '/'; last = h+1; } h++; } while (f<last) { *(result++) = *f; f++; } *result = 0; strcat(result, last); return 0; } char *sys_get_home_dir(void) { #if defined(WIN32) || defined(__WIN32__) HKEY hKey; char path[HT_NAME_MAX]; /* LONG len = HT_NAME_MAX; if(RegOpenKey(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders", &hKey) == ERROR_SUCCESS){ if(RegQueryValue(hKey, "Personal", path, &len) == ERROR_SUCCESS){ RegCloseKey(hKey); if(len > HT_NAME_MAX) return NULL; else return _env_replace(path, len); } } */ // not work on Windows 3.1 ? DWORD len = HT_NAME_MAX; if (RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders", 0, KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS) { if (RegQueryValueEx(hKey, "Personal", NULL, NULL, (LPBYTE)path, &len) == ERROR_SUCCESS) { RegCloseKey(hKey); if (len > HT_NAME_MAX) { return NULL; } else { return _env_replace(path, len); } } } #elif defined(MSDOS) // -? #elif defined(DJGPP) // unknown... #else char *path = getenv("HOME"); if (path) return _env_replace(path, strlen(path)); #endif return NULL; } int sys_file_mode(int mode) { int m = 0; if (S_ISREG(mode)) { m |= HT_S_IFREG; } else if (S_ISBLK(mode)) { m |= HT_S_IFBLK; } else if (S_ISCHR(mode)) { m |= HT_S_IFCHR; } else if (S_ISDIR(mode)) { m |= HT_S_IFDIR; } else if (S_ISFIFO(mode)) { m |= HT_S_IFFIFO; } else if (S_ISLNK(mode)) { m |= HT_S_IFLNK; } else if (S_ISSOCK(mode)) { m |= HT_S_IFSOCK; } if (mode & S_IRUSR) m |= HT_S_IRUSR; if (mode & S_IRGRP) m |= HT_S_IRGRP; if (mode & S_IROTH) m |= HT_S_IROTH; if (mode & S_IWUSR) m |= HT_S_IWUSR; if (mode & S_IWGRP) m |= HT_S_IWGRP; if (mode & S_IWOTH) m |= HT_S_IWOTH; if (mode & S_IXUSR) m |= HT_S_IXUSR; if (mode & S_IXGRP) m |= HT_S_IXGRP; if (mode & S_IXOTH) m |= HT_S_IXOTH; return m; } static char *next_delim(char *s, is_path_delim delim) { while (*s) { s++; if (delim(*s)) return s; } return NULL; } static int flatten_path(char *path, is_path_delim delim) { if (!path || !*path) return 0; char *q = next_delim(path, delim); int pp = flatten_path(q, delim); int ll = q ? (q-path-1) : strlen(path)-1; if (ll == 2 && ht_strncmp(path+1, "..", 2) == 0) { if (q) memmove(path, q, strlen(q)+1); else *path = 0; pp++; } else if (ll == 1 && ht_strncmp(path+1, ".", 1) == 0) { if (q) memmove(path, q, strlen(q)+1); else *path = 0; } else if (pp) { if (q) memmove(path, q, strlen(q)+1); else *path = 0; pp--; } return pp; } bool sys_path_is_absolute(const char *filename, is_path_delim delim) { return delim(filename[0]) || (isalpha(filename[0]) && (filename[1] == ':')); } int sys_common_canonicalize(char *result, int ressize, const char *filename, const char *cwd, is_path_delim delim) { String res; if (!sys_path_is_absolute(filename, delim)) { if (cwd) { res.assign(cwd); } else { return EINVAL; } if (res.length() > 0 && !delim(res.at(res.length()-1))) { res.appendChar('/'); } } res.append(filename); char *f = ht_strdup(res.contentChar()); int k = flatten_path(f, delim); if (k != 0) { free(f); return EINVAL; } res.assign(f); free(f); if (res.length() + 1 > ressize) { return EINVAL; } strcpy(result, res.contentChar()); return 0; } const char *sys_filename_suffix(const char *fn) { const char *s = NULL; while (fn && *fn) { if (sys_is_path_delim(*fn)) s = fn+1; fn++; } const char *p = s ? strrchr(s, '.') : NULL; return p ? p+1 : NULL; } int sys_tmpfile_fd() { #if 1 // FIXME: this might leak something... FILE *f = tmpfile(); return fileno(f); #else // is this better ? return open(tmpnam(NULL), O_RDWR | O_EXCL | O_CREAT); #endif } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/Makefile.am����������������������������������������������������������������������������0000644�0001750�0001750�00000000760�11724770100�011576� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AUTOMAKE_OPTIONS=foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(srcdir) -I$(top_srcdir) -I$(srcdir)/$(MY_IO_DIR) AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} if USE_POSIX_DIR MY_IO_DIR=posix endif if USE_DJGPP_DIR MY_IO_DIR=djgpp endif if USE_WIN32_DIR MY_IO_DIR=win32 endif noinst_LIBRARIES = libcomio.a libcomio_a_SOURCES = bounds.h display.cc display.h keyb.cc keyb.h sys.cc sys.h \ file.cc file.h fileofs.h types.h event.h SUBDIRS = $(MY_IO_DIR) EXTRA_SUBDIRS = djgpp posix win32 ����������������ht-2.0.22/io/posix/���������������������������������������������������������������������������������0000755�0001750�0001750�00000000000�12156433676�010777� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/posix/syskeyb.cc�����������������������������������������������������������������������0000644�0001750�0000144�00000033701�10634114571�012704� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * syskeyb.cc - keyboard access functions for POSIX * * Copyright (C) 1999-2004 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "config.h" #include CURSES_HDR #include "io/event.h" #include "io/keyb.h" #include "io/types.h" #ifdef HAVE_TEXTMODE_X11 #define META_KEY(c) ((c) | 0x80000000) #define UNMETA_KEY(c) ((c) & (~0x80000000)) #define SHIFT_KEY(c) ((c) | 0x40000000) #define UNSHIFT_KEY(c) ((c) & (~0x40000000)) #define CTRL_KEY(c) ((c) | 0x20000000) #define UNCTRL_KEY(c) ((c) & (~0x20000000)) #else #define META_KEY(c) ((c) | 0x80000000) #define UNMETA_KEY(c) ((c) & (~0x80000000)) #define SHIFT_KEY(c) ((c) | 0x80000000) #define UNSHIFT_KEY(c) ((c) & (~0x80000000)) #define CTRL_KEY(c) ((((c)>='a') && ((c)<='z')) ? (c-'a'+1) : ((c) | 0x80000000)) #define UNCTRL_KEY(c) ((c) & (~0x80000000)) #endif #define CTRL_ALPHA_KEY(c) ((c)-'a'+1) #ifdef HAVE_TEXTMODE_X11 #include <X11/Xlib.h> static Display *Xdisplay; static Window Xwindow; #endif /* HAVE_TEXTMODE_X11 */ void sys_get_driver_desc(char *buf) { #ifdef HAVE_TEXTMODE_X11 sprintf(buf, "POSIX/NCurses/X11 (X server %sconnected)", Xdisplay ? "" : "NOT "); #else sprintf(buf, "POSIX/NCurses"); #endif } static int get_modifier(int key) { #ifdef HAVE_TEXTMODE_X11 if (Xdisplay) { Window root, child; int root_x, root_y; int win_x, win_y; unsigned int mask; Bool b; int result = key; b = XQueryPointer(Xdisplay, Xwindow, &root, &child, &root_x, &root_y, &win_x, &win_y, &mask); if (mask & ShiftMask) result = SHIFT_KEY(result); if (mask & ControlMask) result = CTRL_KEY(result); return result; } #endif return key; } static int escseq2rawkey(uint r) { switch (r) { case 'H': return KEY_HOME; case 'F': return KEY_END; case 'P': return KEY_F(1); case 'Q': return KEY_F(2); case 'R': return KEY_F(3); case 'S': return KEY_F(4); } return -1; } /* From xterm's ctlseqs: On button press or release, xterm sends CSI M CbCxCy. The low two bits of Cb encode button information: 0=MB1 pressed, 1=MB2 pressed, 2=MB3 pressed, 3=release. The next three bits encode the modifiers which were down when the button was pressed and are added together: 4=Shift, 8=Meta, 16=Control. Note however that the shift and control bits are normally unavailable because xterm uses the control modifier with mouse for popup menus, and the shift modifier is used in the default translations for button events. The Meta modifier recognized by xterm is the mod1 mask, and is not nec- essarily the "Meta" key (see xmodmap). Cx and Cy are the x and y coor- dinates of the mouse event, encoded as in X10 mode. Wheel mice may return buttons 4 and 5. Those buttons are represented by adding 64 to the event code. */ static bool keyb_getmouseevent(sys_event_t &event) { event.type = SYSEV_MOUSE_EVENT; // CSI M is already parsed. now get Cb, Cx and Cy int b = getch(); b -= 32; switch (b & 3) { case 0: if (b & 64) { // button 4 pressed (normally mouse wheel up) event.mouse_event.button_mask = MBM_BUTTON4; } else { // left button pressed event.mouse_event.button_mask = MBM_LEFT; } event.mouse_event.button_event = MBE_PRESSED; break; case 1: if (b & 64) { // button 5 pressed (normally mouse wheel down) event.mouse_event.button_mask = MBM_BUTTON5; } else { // middle button pressed event.mouse_event.button_mask = MBM_MIDDLE; } event.mouse_event.button_event = MBE_PRESSED; break; case 2: if (b & 64) { // button 6 pressed (whatever ?) event.mouse_event.button_mask = MBM_BUTTON6; } else { // right button pressed event.mouse_event.button_mask = MBM_RIGHT; } event.mouse_event.button_event = MBE_PRESSED; break; case 3: // all buttons released event.mouse_event.button_mask = MBM_LEFT | MBM_MIDDLE | MBM_RIGHT | MBM_BUTTON4 | MBM_BUTTON5 | MBM_BUTTON6; event.mouse_event.button_event = MBE_RELEASED; break; } int x = getch()-32; // now 1-based int y = getch()-32; // now 1-based event.mouse_event.x = x-1; // now 0-based event.mouse_event.y = y-1; // now 0-based return true; } bool keyb_getevent(sys_event_t &event) { int r = keyb_getrawkey(); if (r == KEY_MOUSE) return keyb_getmouseevent(event); ht_key k = K_INVALID; int r2 = UNMETA_KEY(UNCTRL_KEY(UNSHIFT_KEY(r))); if (META_KEY(r) == r && (r2 == '[' || r2 == 'O')) {/* escape seq */ r2 = r; if (keyb_keypressed()) { r = keyb_getrawkey(); r = escseq2rawkey(r); #ifdef HAVE_TEXTMODE_X11 if (CTRL_KEY(r2) == r2) r = CTRL_KEY(r); if (SHIFT_KEY(r2) == r2) r = SHIFT_KEY(r); #endif } } k = keyb_rawkey2key(r); if ((k == K_INVALID) && ((unsigned int)r <= 255)) k = (ht_key)r; event.type = SYSEV_KEYPRESSED; /* if (k == 'a') { event.key = K_Control_PageDown; } else {*/ event.key = k; // } return true; } ht_key keyb_getkey() { int r = keyb_getrawkey(); ht_key k = K_INVALID; int r2 = UNMETA_KEY(UNCTRL_KEY(UNSHIFT_KEY(r))); if (META_KEY(r) == r && ((r2 == '[') || (r2 == 'O'))) {/* escape seq */ r2 = r; if (keyb_keypressed()) { r = keyb_getrawkey(); r = escseq2rawkey(r); #ifdef HAVE_TEXTMODE_X11 if (CTRL_KEY(r2) == r2) r = CTRL_KEY(r); if (SHIFT_KEY(r2) == r2) r = SHIFT_KEY(r); #endif } } k = keyb_rawkey2key(r); if (k == K_INVALID && (unsigned int)r <= 255) { // if (r == 'a') { // return K_Control_PageDown; // } return (ht_key)r; } //debug: if (k == K_INVALID) return (ht_key)r; return k; } struct key_keycode { ht_key key; int keycode; }; bool keyb_keypressed() { int i = getch(); if (i != -1) ungetch(i); return (i != -1); } int keyb_getrawkey() { int c = getch(); if (c == '\e') { c = getch(); if ((c == -1) || (c == '\e')) c = '\e'; else c = META_KEY(c); } if ((unsigned int)c>=0x100) c = get_modifier(c); // fprintf(stderr, "getrawkey() %d/0x%x\n", c, c); return c; } static key_keycode curses_key_defs[] = { {K_Return, '\n'}, {K_Delete, KEY_DC}, {K_Insert, KEY_IC}, {K_Backspace, KEY_BACKSPACE}, {K_Backspace, 8}, {K_Backspace, 127}, {K_Meta_Backspace, META_KEY(KEY_BACKSPACE)}, {K_Meta_Backspace, META_KEY(8)}, {K_Meta_Backspace, META_KEY(127)}, {K_F1, KEY_F(1)}, {K_F2, KEY_F(2)}, {K_F3, KEY_F(3)}, {K_F4, KEY_F(4)}, {K_F5, KEY_F(5)}, {K_F6, KEY_F(6)}, {K_F7, KEY_F(7)}, {K_F8, KEY_F(8)}, {K_F9, KEY_F(9)}, {K_F10, KEY_F(10)}, {K_F11, KEY_F(11)}, {K_F12, KEY_F(12)}, {K_Home, KEY_HOME}, {K_End, KEY_END}, {K_Up, KEY_UP}, {K_Down, KEY_DOWN}, {K_Left, KEY_LEFT}, {K_Right, KEY_RIGHT}, {K_PageUp, KEY_PPAGE}, {K_PageDown, KEY_NPAGE}, {K_Tab, '\t'}, {K_Meta_Up, META_KEY(KEY_UP)}, {K_Meta_Down, META_KEY(KEY_DOWN)}, {K_Meta_Left, META_KEY(KEY_LEFT)}, {K_Meta_Right, META_KEY(KEY_RIGHT)}, {K_Meta_PageUp, META_KEY(KEY_PPAGE)}, {K_Meta_PageDown, META_KEY(KEY_NPAGE)}, {K_Meta_Insert, META_KEY(KEY_IC)}, {K_Meta_Delete, META_KEY(KEY_DC)}, {K_Meta_Home, META_KEY(KEY_HOME)}, {K_Meta_End, META_KEY(KEY_END)}, {K_Control_Up, CTRL_KEY(KEY_UP)}, {K_Control_Down, CTRL_KEY(KEY_DOWN)}, {K_Control_Left, CTRL_KEY(KEY_LEFT)}, {K_Control_Right, CTRL_KEY(KEY_RIGHT)}, {K_Control_PageUp, CTRL_KEY(KEY_PPAGE)}, {K_Control_PageDown, CTRL_KEY(KEY_NPAGE)}, {K_Control_Insert, CTRL_KEY(KEY_IC)}, {K_Control_Delete, CTRL_KEY(KEY_DC)}, {K_Control_Home, CTRL_KEY(KEY_HOME)}, {K_Control_End, CTRL_KEY(KEY_END)}, {K_Shift_Tab, SHIFT_KEY('\t')}, {K_Shift_Up, SHIFT_KEY(KEY_UP)}, {K_Shift_Down, SHIFT_KEY(KEY_DOWN)}, {K_Shift_Left, SHIFT_KEY(KEY_LEFT)}, {K_Shift_Right, SHIFT_KEY(KEY_RIGHT)}, {K_Shift_PageUp, SHIFT_KEY(KEY_PPAGE)}, {K_Shift_PageDown, SHIFT_KEY(KEY_NPAGE)}, {K_Shift_Delete, SHIFT_KEY(KEY_DC)}, {K_Shift_Insert, SHIFT_KEY(KEY_IC)}, {K_Shift_Home, SHIFT_KEY(KEY_HOME)}, {K_Shift_End, SHIFT_KEY(KEY_END)}, {K_Meta_1, META_KEY('1')}, {K_Meta_2, META_KEY('2')}, {K_Meta_3, META_KEY('3')}, {K_Meta_4, META_KEY('4')}, {K_Meta_5, META_KEY('5')}, {K_Meta_6, META_KEY('6')}, {K_Meta_7, META_KEY('7')}, {K_Meta_8, META_KEY('8')}, {K_Meta_9, META_KEY('9')}, {K_Meta_0, META_KEY('0')}, {K_Control_A, CTRL_ALPHA_KEY('a')}, {K_Control_B, CTRL_ALPHA_KEY('b')}, {K_Control_C, CTRL_ALPHA_KEY('c')}, {K_Control_D, CTRL_ALPHA_KEY('d')}, {K_Control_E, CTRL_ALPHA_KEY('e')}, {K_Control_F, CTRL_ALPHA_KEY('f')}, {K_Control_G, CTRL_ALPHA_KEY('g')}, {K_Control_H, CTRL_ALPHA_KEY('h')}, {K_Control_I, CTRL_ALPHA_KEY('i')}, {K_Control_J, CTRL_ALPHA_KEY('j')}, {K_Control_K, CTRL_ALPHA_KEY('k')}, {K_Control_L, CTRL_ALPHA_KEY('l')}, {K_Control_M, CTRL_ALPHA_KEY('m')}, {K_Control_N, CTRL_ALPHA_KEY('n')}, {K_Control_O, CTRL_ALPHA_KEY('o')}, {K_Control_P, CTRL_ALPHA_KEY('p')}, {K_Control_Q, CTRL_ALPHA_KEY('q')}, {K_Control_R, CTRL_ALPHA_KEY('r')}, {K_Control_S, CTRL_ALPHA_KEY('s')}, {K_Control_T, CTRL_ALPHA_KEY('t')}, {K_Control_U, CTRL_ALPHA_KEY('u')}, {K_Control_V, CTRL_ALPHA_KEY('v')}, {K_Control_W, CTRL_ALPHA_KEY('w')}, {K_Control_X, CTRL_ALPHA_KEY('x')}, {K_Control_Y, CTRL_ALPHA_KEY('y')}, {K_Control_Z, CTRL_ALPHA_KEY('z')}, {K_Meta_A, META_KEY('a')}, {K_Meta_B, META_KEY('b')}, {K_Meta_C, META_KEY('c')}, {K_Meta_D, META_KEY('d')}, {K_Meta_E, META_KEY('e')}, {K_Meta_F, META_KEY('f')}, {K_Meta_G, META_KEY('g')}, {K_Meta_H, META_KEY('h')}, {K_Meta_I, META_KEY('i')}, {K_Meta_J, META_KEY('j')}, {K_Meta_K, META_KEY('k')}, {K_Meta_L, META_KEY('l')}, {K_Meta_M, META_KEY('m')}, {K_Meta_N, META_KEY('n')}, {K_Meta_O, META_KEY('o')}, {K_Meta_P, META_KEY('p')}, {K_Meta_Q, META_KEY('q')}, {K_Meta_R, META_KEY('r')}, {K_Meta_S, META_KEY('s')}, {K_Meta_T, META_KEY('t')}, {K_Meta_U, META_KEY('u')}, {K_Meta_V, META_KEY('v')}, {K_Meta_W, META_KEY('w')}, {K_Meta_X, META_KEY('x')}, {K_Meta_Y, META_KEY('y')}, {K_Meta_Z, META_KEY('z')}, /* {K_Shift_F1, SHIFT_KEY(KEY_F(1))}, {K_Shift_F2, SHIFT_KEY(KEY_F(2))}, {K_Shift_F3, SHIFT_KEY(KEY_F(3))}, {K_Shift_F4, SHIFT_KEY(KEY_F(4))}, {K_Shift_F5, SHIFT_KEY(KEY_F(5))}, {K_Shift_F6, SHIFT_KEY(KEY_F(6))}, {K_Shift_F7, SHIFT_KEY(KEY_F(7))}, {K_Shift_F8, SHIFT_KEY(KEY_F(8))}, {K_Shift_F9, SHIFT_KEY(KEY_F(9))}, {K_Shift_F10, SHIFT_KEY(KEY_F(10))}, {K_Shift_F11, SHIFT_KEY(KEY_F(11))}, {K_Shift_F12, SHIFT_KEY(KEY_F(12))},*/ {K_Shift_F1, SHIFT_KEY(KEY_F(1+12))}, {K_Shift_F2, SHIFT_KEY(KEY_F(2+12))}, {K_Shift_F3, SHIFT_KEY(KEY_F(3+12))}, {K_Shift_F4, SHIFT_KEY(KEY_F(4+12))}, {K_Shift_F5, SHIFT_KEY(KEY_F(5+12))}, {K_Shift_F6, SHIFT_KEY(KEY_F(6+12))}, {K_Shift_F7, SHIFT_KEY(KEY_F(7+12))}, {K_Shift_F8, SHIFT_KEY(KEY_F(8+12))}, {K_Shift_F9, SHIFT_KEY(KEY_F(9+12))}, {K_Shift_F10, SHIFT_KEY(KEY_F(10+12))}, {K_Shift_F11, SHIFT_KEY(KEY_F(11+12))}, {K_Shift_F12, SHIFT_KEY(KEY_F(12+12))}, {K_Control_Shift_F1, CTRL_KEY(SHIFT_KEY(KEY_F(1+12)))}, {K_Control_Shift_F2, CTRL_KEY(SHIFT_KEY(KEY_F(2+12)))}, {K_Control_Shift_F3, CTRL_KEY(SHIFT_KEY(KEY_F(3+12)))}, {K_Control_Shift_F4, CTRL_KEY(SHIFT_KEY(KEY_F(4+12)))}, {K_Control_Shift_F5, CTRL_KEY(SHIFT_KEY(KEY_F(5+12)))}, {K_Control_Shift_F6, CTRL_KEY(SHIFT_KEY(KEY_F(6+12)))}, {K_Control_Shift_F7, CTRL_KEY(SHIFT_KEY(KEY_F(7+12)))}, {K_Control_Shift_F8, CTRL_KEY(SHIFT_KEY(KEY_F(8+12)))}, {K_Control_Shift_F9, CTRL_KEY(SHIFT_KEY(KEY_F(9+12)))}, {K_Control_Shift_F10, CTRL_KEY(SHIFT_KEY(KEY_F(10+12)))}, {K_Control_Shift_F11, CTRL_KEY(SHIFT_KEY(KEY_F(11+12)))}, {K_Control_Shift_F12, CTRL_KEY(SHIFT_KEY(KEY_F(12+12)))}, {K_Control_F1, CTRL_KEY(KEY_F(1))}, {K_Control_F2, CTRL_KEY(KEY_F(2))}, {K_Control_F3, CTRL_KEY(KEY_F(3))}, {K_Control_F4, CTRL_KEY(KEY_F(4))}, {K_Control_F5, CTRL_KEY(KEY_F(5))}, {K_Control_F6, CTRL_KEY(KEY_F(6))}, {K_Control_F7, CTRL_KEY(KEY_F(7))}, {K_Control_F8, CTRL_KEY(KEY_F(8))}, {K_Control_F9, CTRL_KEY(KEY_F(9))}, {K_Control_F10, CTRL_KEY(KEY_F(10))}, {K_Control_F11, CTRL_KEY(KEY_F(11))}, {K_Control_F12, CTRL_KEY(KEY_F(12))}, {K_Meta_F1, META_KEY(KEY_F(1))}, {K_Meta_F2, META_KEY(KEY_F(2))}, {K_Meta_F3, META_KEY(KEY_F(3))}, {K_Meta_F4, META_KEY(KEY_F(4))}, {K_Meta_F5, META_KEY(KEY_F(5))}, {K_Meta_F6, META_KEY(KEY_F(6))}, {K_Meta_F7, META_KEY(KEY_F(7))}, {K_Meta_F8, META_KEY(KEY_F(8))}, {K_Meta_F9, META_KEY(KEY_F(9))}, {K_Meta_F10, META_KEY(KEY_F(10))}, {K_Meta_F11, META_KEY(KEY_F(11))}, {K_Meta_F12, META_KEY(KEY_F(12))}, }; bool init_keyb() { uint i; #ifdef HAVE_TEXTMODE_X11 Xdisplay = XOpenDisplay(0); if (Xdisplay) Xwindow = DefaultRootWindow(Xdisplay); #endif /* HAVE_TEXTMODE_X11 */ for (i=0; i<K_COUNT; i++) { keyb_setkey((ht_key)i, -1); } for (i=0; i<sizeof curses_key_defs/ sizeof curses_key_defs[0]; i++) { int kc = curses_key_defs[i].keycode; #ifdef HAVE_TEXTMODE_X11 if (!Xdisplay) { if (kc & 0x40000000) kc = (kc & ~0x40000000) | 0x80000000; if (kc & 0x20000000) kc = (kc & ~0x20000000) | 0x80000000; } #endif /* HAVE_TEXTMODE_X11 */ keyb_setkey(curses_key_defs[i].key, kc); // fprintf(stderr, "%x - %x\n", curses_key_defs[i].key, kc); } // fprintf(stderr, "%d/%x\n", KEY_F(1), KEY_F(1)); /* Mouse support */ // xterm (VT200-like) // printf("\e[?1001s"); // save old highlight mouse tracking // printf("\e[?1000h"); // enable mouse tracking aka. receive mouse events through stdin return true; } void done_keyb() { #ifdef HAVE_TEXTMODE_X11 if (Xdisplay) XCloseDisplay(Xdisplay); #endif /* HAVE_TEXTMODE_X11 */ fflush(stdout); fflush(stdin); /* Mouse support */ // xterm (VT200-like) // printf("\e[?1000l"); // disable mouse tracking // printf("\e[?1001r"); // restore old highlight mouse tracking } ���������������������������������������������������������������ht-2.0.22/io/posix/types.h��������������������������������������������������������������������������0000644�0001750�0000144�00000002253�10615343663�012224� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * PearPC * types.h * * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __POSIX_TYPES_H__ #define __POSIX_TYPES_H__ #ifdef HAVE_STDINT_H #include <stdint.h> #else #include <inttypes.h> #endif /* HAVE_STDINT_H */ #include <sys/types.h> typedef uint8_t uint8; typedef uint16_t uint16; typedef uint32_t uint32; typedef uint64_t uint64; typedef int8_t sint8; typedef int16_t sint16; typedef int32_t sint32; typedef int64_t sint64; typedef signed int sint; typedef uint8 byte; #endif �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/posix/sysinit.cc�����������������������������������������������������������������������0000644�0001750�0000144�00000003216�10615343663�012720� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * sysinit.cc - POSIX-specific initialization * * Copyright (C) 1999-2004 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <signal.h> #include <unistd.h> #include <sys/types.h> #include "io/sys.h" bool initKeyb(); void doneKeyb(); bool initSysEvent(); void doneSysEvent(); struct sigaction old_SIGTRAP; struct sigaction old_SIGWINCH; void SIGCHLD_sigaction(int i, siginfo_t *info, void *v); void SIGTRAP_sigaction(int i, siginfo_t *info, void *v); void SIGWINCH_sigaction(int i, siginfo_t *info, void *v); bool init_system() { setuid(getuid()); struct sigaction sa; #if 0 sa.sa_sigaction = SIGCHLD_sigaction; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_SIGINFO; sigaction(SIGCHLD, &sa, NULL); sa.sa_sigaction = SIGTRAP_sigaction; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_SIGINFO; sigaction(SIGTRAP, &sa, &old_SIGTRAP); #endif sa.sa_sigaction = SIGWINCH_sigaction; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_SIGINFO; sigaction(SIGWINCH, &sa, &old_SIGWINCH); return true; } void done_system() { } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/posix/sysfile.cc�����������������������������������������������������������������������0000644�0001750�0000144�00000013237�10615343663�012700� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * sysfile.cc - file system functions for POSIX * * Copyright (C) 1999-2004 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> #include "io/file.h" struct posixfindstate { DIR *fhandle; }; bool sys_filename_is_absolute(const char *filename) { return sys_is_path_delim(filename[0]); } bool sys_is_path_delim(char c) { return c == '/'; } int sys_filename_cmp(const char *a, const char *b) { while (*a && *b) { if (sys_is_path_delim(*a) && sys_is_path_delim(*b)) { } else if (*a != *b) { break; } a++; b++; } return *a - *b; } int sys_canonicalize(char **result, const char *filename) { if (!sys_filename_is_absolute(filename)) return ENOENT; *result = (char*)malloc(HT_NAME_MAX); if (realpath(filename, *result)==*result) { return 0; } else { free(*result); return ENOENT; } } static char sys_find_dirname[HT_NAME_MAX]; int sys_findclose(pfind_t &pfind) { int r = closedir(((posixfindstate*)pfind.findstate)->fhandle); free(pfind.findstate); return r; } int sys_findfirst(pfind_t &pfind, const char *dirname) { if (!sys_filename_is_absolute(dirname)) return ENOENT; int r; pfind.findstate = malloc(sizeof (posixfindstate)); posixfindstate *pfs = (posixfindstate*)pfind.findstate; if ((pfs->fhandle = opendir(dirname))) { strcpy(sys_find_dirname, dirname); char *s = sys_find_dirname+strlen(sys_find_dirname); if ((s > sys_find_dirname) && (*(s-1) != '/')) { *(s++) = '/'; *s = 0; } r = sys_findnext(pfind); } else r = errno ? errno : ENOENT; if (r) free(pfind.findstate); return r; } int sys_findnext(pfind_t &pfind) { posixfindstate *pfs = (posixfindstate*)pfind.findstate; struct dirent *d; if ((d = readdir(pfs->fhandle))) { pfind.name = d->d_name; char *s = sys_find_dirname+strlen(sys_find_dirname); strcpy(s, d->d_name); sys_pstat(pfind.stat, sys_find_dirname); *s = 0; return 0; } return ENOENT; } static void stat_to_pstat_t(const struct stat &st, pstat_t &s) { s.caps = pstat_ctime|pstat_mtime|pstat_atime|pstat_uid|pstat_gid|pstat_mode_all|pstat_size|pstat_inode; s.ctime = st.st_ctime; s.mtime = st.st_mtime; s.atime = st.st_atime; s.gid = st.st_uid; s.uid = st.st_gid; s.mode = sys_file_mode(st.st_mode); s.size = st.st_size; s.fsid = st.st_ino; } int sys_pstat(pstat_t &s, const char *filename) { if (!sys_filename_is_absolute(filename)) return ENOENT; struct stat st; errno = 0; int e = lstat(filename, &st); if (e) return errno ? errno : ENOENT; stat_to_pstat_t(st, s); return 0; } int sys_pstat_fd(pstat_t &s, int fd) { struct stat st; errno = 0; int e = fstat(fd, &st); if (e) return errno ? errno : ENOENT; stat_to_pstat_t(st, s); return 0; } int sys_pstat_file(pstat_t &s, SYS_FILE *file) { return sys_pstat_fd(s, fileno((FILE*)file)); } int sys_truncate(const char *filename, FileOfs ofs) { if (!sys_filename_is_absolute(filename)) return ENOENT; int fd = open(filename, O_RDWR, 0); if (fd < 0) return errno; if (ftruncate(fd, ofs) != 0) { close(fd); return errno; } if (close(fd)) return errno; return 0; } int sys_truncate_fd(int fd, FileOfs ofs) { if (ftruncate(fd, ofs) != 0) return errno; return 0; } int sys_deletefile(const char *filename) { if (!sys_filename_is_absolute(filename)) return ENOENT; return remove(filename); } void sys_suspend() { timeval tm; fd_set zerofds; FD_ZERO(&zerofds); tm.tv_sec = 0; tm.tv_usec = 100; select(0, &zerofds, &zerofds, &zerofds, &tm); } static const char *openmode2mode(FileOpenMode om, IOAccessMode am) { const char *mode = NULL; switch (om) { case FOM_APPEND: mode = "ab+"; break; case FOM_CREATE: if (am & IOAM_WRITE) mode = "wb"; if (am & IOAM_READ) mode = "wb+"; break; case FOM_EXISTS: if (am & IOAM_READ) mode = "rb"; if (am & IOAM_WRITE) mode = "rb+"; break; } return mode; } SYS_FILE *sys_freopen(const char *filename, FileOpenMode openmode, IOAccessMode accessmode, SYS_FILE *file) { return (SYS_FILE *)freopen(filename, openmode2mode(openmode, accessmode), (FILE*)file); } SYS_FILE *sys_fopen(const char *filename, FileOpenMode openmode, IOAccessMode accessmode) { return (SYS_FILE *)fopen(filename, openmode2mode(openmode, accessmode)); } void sys_fclose(SYS_FILE *file) { fclose((FILE *)file); } int sys_fread(SYS_FILE *file, byte *buf, int size) { return fread(buf, 1, size, (FILE *)file); } int sys_fwrite(SYS_FILE *file, byte *buf, int size) { return fwrite(buf, 1, size, (FILE *)file); } int sys_fseek(SYS_FILE *file, FileOfs newofs, int seekmode) { int r; switch (seekmode) { case SYS_SEEK_SET: r = fseeko((FILE *)file, newofs, SEEK_SET); break; case SYS_SEEK_REL: r = fseeko((FILE *)file, newofs, SEEK_CUR); break; case SYS_SEEK_END: r = fseeko((FILE *)file, newofs, SEEK_END); break; default: return EINVAL; } return r ? errno : 0; } FileOfs sys_ftell(SYS_FILE *file) { return ftello((FILE *)file); } const char *sys_get_name() { return "POSIX"; } int sys_get_caps() { return 0; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/posix/sysclipboard.cc������������������������������������������������������������������0000644�0001750�0000144�00000002127�10615343662�013713� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * clipboard.cc - POSIX-specific (OS-)clipboard functions * * Copyright (C) 1999-2004 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <cstdio> #include "io/sys.h" #include "io/types.h" bool sys_native_clipboard_write(const void *buf, int bufsize) { return false; } int sys_native_clipboard_get_size() { return 0; } int sys_native_clipboard_read(void *buf, int bufsize) { return false; } const char *sys_native_clipboard_name() { return NULL; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/posix/sysdisplay.cc��������������������������������������������������������������������0000644�0001750�0001750�00000030246�11724770100�013421� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * sysdisplay.cc - screen access functions for POSIX * * Copyright (C) 1999-2004 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "config.h" #include CURSES_HDR #include <sys/ioctl.h> #include <signal.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <locale.h> #include "io/display.h" #include "io/types.h" extern struct sigaction old_SIGTRAP; uint mapToGraphical(char chr) { switch (chr) { case GC_1VLINE: return ACS_VLINE; case GC_1HLINE: return ACS_HLINE; case GC_1CORNER0: return ACS_URCORNER; case GC_1CORNER1: return ACS_LRCORNER; case GC_1CORNER2: return ACS_LLCORNER; case GC_1CORNER3: return ACS_ULCORNER; /* for all 'T's: ACS nomenclature differs from ours */ case GC_1UTEE: return ACS_BTEE; case GC_1LTEE: return ACS_RTEE; case GC_1DTEE: return ACS_TTEE; case GC_1RTEE: return ACS_LTEE; case GC_1CROSS: return ACS_PLUS; case GC_2VLINE: return ACS_VLINE; case GC_2HLINE: return ACS_HLINE; case GC_2CORNER0: return ACS_URCORNER; case GC_2CORNER1: return ACS_LRCORNER; case GC_2CORNER2: return ACS_LLCORNER; case GC_2CORNER3: return ACS_ULCORNER; case GC_LOW: return ACS_CKBOARD; case GC_MEDIUM: return ACS_CKBOARD; case GC_HIGH: return ACS_CKBOARD; case GC_FULL: return ACS_BLOCK; case GC_ARROW_UP: return ACS_UARROW; case GC_ARROW_DOWN: return ACS_DARROW; case GC_ARROW_LEFT: return (byte)'<'; case GC_ARROW_RIGHT: return (byte)'>'; case GC_SMALL_ARROW_UP: return ACS_UARROW; case GC_SMALL_ARROW_DOWN: return ACS_DARROW; case GC_FILLED_CIRCLE: return ACS_BULLET; case GC_FILLED_QUAD: return 'x'; case GC_TRANSPARENT: return 0; case GC_FILLED_UPPER: return '^'; case GC_FILLED_LOWER: return '_'; } return '?'; } #if 0 #define CHAR_LINEV ACS_VLINE #define CHAR_LINEH ACS_HLINE #define CHAR_LINEV_DBL ACS_VLINE #define CHAR_LINEH_DBL ACS_HLINE #define CHAR_BORDERTL ACS_LTEE #define CHAR_BORDERTR ACS_RTEE #define CHAR_BORDERTU ACS_TTEE #define CHAR_BORDERTD ACS_BTEE #define CHAR_BORDERTL_DBL ACS_LTEE #define CHAR_BORDERTR_DBL ACS_RTEE #define CHAR_BORDERTU_DBL ACS_TTEE #define CHAR_BORDERTD_DBL ACS_BTEE #define CHAR_CORNERUL ACS_ULCORNER #define CHAR_CORNERLL ACS_LLCORNER #define CHAR_CORNERUR ACS_URCORNER #define CHAR_CORNERLR ACS_LRCORNER #define CHAR_CORNERUL_DBL ACS_ULCORNER #define CHAR_CORNERLL_DBL ACS_LLCORNER #define CHAR_CORNERUR_DBL ACS_URCORNER #define CHAR_CORNERLR_DBL ACS_LRCORNER #define CHAR_FILLED_L ACS_CKBOARD /* low */ #define CHAR_FILLED_M ACS_CKBOARD /* medium */ #define CHAR_FILLED_H ACS_CKBOARD /* high */ #define CHAR_FILLED_F ACS_BLOCK /* full */ #define CHAR_FILLED_HU '#' #define CHAR_FILLED_HL ' ' #define CHAR_QUAD_SMALL 'x' #define CHAR_ARROW_UP ACS_UARROW #define CHAR_ARROW_DOWN ACS_DARROW #define CHAR_ARROWBIG_UP ACS_UARROW #define CHAR_ARROWBIG_DOWN ACS_DARROW #define CHAR_ARROWBIG_RIGHT '>' #define CHAR_ARROWBIG_LEFT '<' #define CHAR_RADIO ACS_BULLET #endif uint mapCharToSystemCP(char chr, Codepage cp) { switch (cp) { case CP_DEVICE: return (byte)chr; // case CP_WINDOWS: return (byte)chr; case CP_GRAPHICAL: return mapToGraphical(chr); default: break; } return (byte)chr; } /* * Class CursesSystemDisplay */ struct CursesChar { uint rawchar; vcp color; }; class CursesSystemDisplay: public SystemDisplay { protected: CursorMode cursor_mode; int cursorx, cursory; CursesChar *buf; WINDOW *win; SCREEN *terminal; bool use_colors, use_high_colors, is_xterm; short colormap[64]; void cursorBold(); void cursorHide(); void cursorNormal(); void putChar(CursesChar *dest, uint rawchar, vcp vc); public: CursesSystemDisplay(const char *title); virtual ~CursesSystemDisplay(); /* extends Display */ virtual void copyFromDisplay(const Display &display, int x, int y, const Bounds &clipping); virtual void fill(int x, int y, int w, int h, vcp color, char chr, Codepage cp = CP_DEVICE); virtual void getCursor(int &x, int &y) const; virtual CursorMode getCursorMode() const; virtual int nprint(int x, int y, vcp color, const char *str, int maxstrlen, Codepage cp = CP_DEVICE); virtual bool read(uint &rawchar, vcp &color, int x, int y) const; virtual void setBounds(const Bounds &b); virtual void setCursor(int x, int y, CursorMode mode = CURSOR_NORMAL); virtual void setCursorMode(CursorMode mode = CURSOR_NORMAL); /* extends SystemDisplay */ virtual void show(); /* debug */ void doShowCursor(); void term_on(); void term_off(); }; CursesSystemDisplay *gDisplay = NULL; extern struct sigaction old_SIGWINCH; // from sysinit.cc // dont work, dont know why... void SIGTRAP_sigaction(int i, siginfo_t *info, void *v) { // set cursor for gdb if (gDisplay) gDisplay->doShowCursor(); old_SIGTRAP.sa_sigaction(i, info, v); } sig_atomic_t gWinChFlag = 0; void SIGWINCH_sigaction(int i, siginfo_t *info, void *v) { // FIXME: really, really, really possible??? (or just Valgrind's fault) // if (!info) return; gWinChFlag = true; if (old_SIGWINCH.sa_sigaction) old_SIGWINCH.sa_sigaction(i, info, v); } bool sys_get_winch_flag() { return gWinChFlag; } void sys_set_winch_flag(bool f) { gWinChFlag = f; } bool sys_get_screen_size(int &w, int &h) { #if defined TIOCGWINSZ && !defined SCO_FLAVOR struct winsize winsz; winsz.ws_col = winsz.ws_row = 0; /* Ioctl on the STDIN_FILENO */ ioctl(0, TIOCGWINSZ, &winsz); if (winsz.ws_col && winsz.ws_row) { w = winsz.ws_col; h = winsz.ws_row; resizeterm(winsz.ws_row, winsz.ws_col); clearok(stdscr, TRUE); return true; } #endif /* TIOCGWINSZ && !SCO_FLAVOR */ return false; } bool sys_set_screen_size(int w, int h) { #if defined TIOCSWINSZ && !defined SCO_FLAVOR struct winsize tty_size; tty_size.ws_row = h; tty_size.ws_col = w; tty_size.ws_xpixel = tty_size.ws_ypixel = 0; return ioctl(0, TIOCSWINSZ, &tty_size) == 0; #endif return false; } CursesSystemDisplay::CursesSystemDisplay(const char *title) : SystemDisplay() { buf = NULL; cursorx = 0; cursory = 0; terminal = NULL; term_on(); show(); } CursesSystemDisplay::~CursesSystemDisplay() { term_off(); free(buf); } void CursesSystemDisplay::term_off() { // if (!terminal) return; ::erase(); ::refresh(); ::endwin(); // ::delscreen(terminal); terminal = NULL; } void CursesSystemDisplay::term_on() { if (terminal) return; int colors[8] = { COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, COLOR_RED, COLOR_MAGENTA, COLOR_YELLOW, COLOR_WHITE }; setCursor(0, 0, CURSOR_OFF); ::setlocale(LC_ALL, ""); // terminal = ::newterm(NULL, stdout, stdin); win = ::initscr(); // win = stdscr; // ::setlocale(LC_ALL, "C"); use_colors = false; use_high_colors = false; if (::has_colors()) { use_colors = true; char *term = getenv("TERM"); bool bold_support = false; attr_t attrs; short cur_color = 1; ::start_color(); /* FIXME: Does this work ???: test if the WA_BOLD attr can be set */ ::attr_on(WA_BOLD, 0); attrs = WA_NORMAL; attr_get(&attrs, &cur_color, 0); bold_support = (attrs==WA_BOLD); ::attr_off(WA_BOLD, 0); is_xterm = (term && strcmp(term, "linux") && strcmp(term, "console")); if (!is_xterm && !bold_support) { fprintf(stderr, "warning: terminal is of type '%s' (non-x-terminal) but bold_test fails!", term); } if (bold_support) { use_high_colors = true; } else { fprintf(stderr, "warning: terminal only supports 8 foreground colors!"); } for (int fg=0; fg < 8; fg++) { for (int bg=0; bg < 8; bg++) { colormap[fg+bg*8] = fg+bg*8; ::init_pair(fg+bg*8, colors[fg], colors[bg]); } } colormap[7] = 0; colormap[0] = 7; ::init_pair(7, COLOR_BLACK, COLOR_BLACK); } else { fprintf(stderr, "warning: terminal lacks color support!"); } ::wtimeout(win, 1); ::meta(win, 1); ::keypad(win, 1); ::nodelay(win, 1); ::noecho(); ::cbreak(); ::set_escdelay(500); assign(0, 0, getmaxx(win), getmaxy(win)); } void CursesSystemDisplay::copyFromDisplay(const Display &d, int x, int y, const Bounds &clipping) { CursorMode cm = d.getCursorMode(); int cx, cy; d.getCursor(cx,cy); cx += d.x; cy += d.y; // setCursor(cx, cy, cm); for (int iy = 0; iy < d.h; iy++) { CursesChar *k = buf+x+(iy+y)*w; if (y+iy >= clipping.y+clipping.h) break; if (y+iy >= clipping.y) for (int ix=0; ix < d.w; ix++) { uint rawchar; vcp color; d.read(rawchar, color, ix, iy); if (x+ix < clipping.x+clipping.w && x+ix >= clipping.x) putChar(k, rawchar, color); k++; } } } void CursesSystemDisplay::fill(int x, int y, int w, int h, vcp color, char chr, Codepage cp) { uint rawchar = mapCharToSystemCP(chr, cp); for (int i=0; i<h; i++) { CursesChar *b = buf+x+(y+i)*this->w; if (y+i >= this->h) break; if (y+i >= 0) for (int j=0; j<w; j++) { if (x+j >= this->w) break; if (x+j >= 0) putChar(b, rawchar, color); b++; } } } void CursesSystemDisplay::getCursor(int &x, int &y) const { x = cursorx; y = cursory; } CursorMode CursesSystemDisplay::getCursorMode() const { return cursor_mode; } int CursesSystemDisplay::nprint(int x, int y, vcp color, const char *str, int maxstrlen, Codepage cp) { int n = 0; CursesChar *b=buf+x+y*w; while (n < maxstrlen && *str && x+n < w) { uint rawchar = mapCharToSystemCP(*str, cp); if (x+n>=0) putChar(b, rawchar, color); b++; str++; n++; } return n; } bool CursesSystemDisplay::read(uint &rawchar, vcp &color, int x, int y) const { CursesChar *b = buf+x+y*w; rawchar = b->rawchar; color = b->color; return true; } void CursesSystemDisplay::setBounds(const Bounds &b) { SystemDisplay::setBounds(b); free(buf); buf = ht_malloc(sizeof *buf * w * h); memset(buf, 0, sizeof *buf * w * h); fill(x, y, w, h, VCP(VC_WHITE, VC_BLACK), ' '); } void CursesSystemDisplay::setCursor(int x, int y, CursorMode mode) { cursorx = x; cursory = y; setCursorMode(mode); } void CursesSystemDisplay::setCursorMode(CursorMode mode) { cursor_mode = mode; } void CursesSystemDisplay::show() { CursesChar *ch = buf; vcp c = -1; for (int iy=0; iy < h; iy++) { ::move(iy+y, x); for (int ix=0; ix < w; ix++) { if (use_colors && ch->color != c) { vc fg = VCP_FOREGROUND(ch->color); vc bg = VCP_BACKGROUND(ch->color); if (use_high_colors) { if (0 && is_xterm && fg == VC_LIGHT(VC_BLACK)) { /* some terminals can't display dark grey (=light black), so we take light grey instead... */ attrset(A_NORMAL); fg = VC_WHITE; } else { if (VC_GET_LIGHT(fg)) attrset(A_BOLD); else attrset(A_NORMAL); } } /* fg = VC_GET_BASECOLOR(fg); bg = VC_GET_BASECOLOR(bg);*/ fg &= 7; bg &= 7; color_set(colormap[bg*8+fg], 0); } uint chr = (uint)ch->rawchar; if ((chr >= 0x20 && chr < 0x7f) || chr > 0xff) { addch(chr); } else { attrset(A_BOLD); color_set(colormap[VC_RED*8+VC_WHITE], 0); addch('?'); } ch++; } } ::curs_set(0); ::refresh(); ::move(cursory, cursorx); switch (cursor_mode) { case CURSOR_OFF: ::curs_set(0); break; case CURSOR_NORMAL: ::curs_set(1); break; case CURSOR_BOLD: if (::curs_set(2) == ERR) ::curs_set(1); break; } ::refresh(); } void CursesSystemDisplay::doShowCursor() { /* ::move(0,0); curs_set(1); refresh();*/ } void CursesSystemDisplay::putChar(CursesChar *dest, uint rawchar, vcp vc) { if (dest >= buf+w*h || dest < buf) return; if (rawchar) dest->rawchar = rawchar; dest->color = mixColors(dest->color, vc); } static int sysdisplay_count = 0; SystemDisplay *allocSystemDisplay(const char *title) { if (sysdisplay_count) return NULL; sysdisplay_count++; gDisplay = new CursesSystemDisplay(title); return gDisplay; } /* void sys_display_enter() { gDisplay->term_on(); } void sys_display_leave() { gDisplay->term_off(); } */ ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/posix/Makefile.am����������������������������������������������������������������������0000644�0001750�0001750�00000000567�11724770100�012745� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/io \ ${curses_CPPFLAGS} AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_LIBRARIES = libhtio.a libhtio_a_SOURCES = event.cc sysfile.cc sysdisplay.cc syskeyb.cc sysinit.cc \ sysclipboard.cc types.h #htcurses.cc htcurses.h htkeyb.cc htkeyb.h htsys.cc htsys.h �����������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/posix/event.cc�������������������������������������������������������������������������0000644�0001750�0000144�00000007446�10615343657�012353� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * event.cc * * Copyright (C) 1999-2004 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <string.h> #include <sys/select.h> #include <sys/time.h> #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include "io/display.h" #include "io/event.h" struct fd_listener { int fd; int fd_flags; }; #define MAX_FD_LISTENERS 32 static fd_listener fd_listener[MAX_FD_LISTENERS]; static int fd_listeners = 0; static fd_set grfds, gwfds, gxfds; static int g_highest_fd = 0; static bool gTranslateKeys = true; bool sys_next_event(sys_event_t &event, int wait_usec) { if (sys_get_winch_flag()) { sys_set_winch_flag(false); if (sys_get_screen_size(event.screen_resize.w, event.screen_resize.h)) { event.type = SYSEV_SCREEN_RESIZE; return true; } } fd_set rfds = grfds, wfds = gwfds, xfds = gxfds; timeval t; t.tv_sec = 0; t.tv_usec = wait_usec; int e = select(g_highest_fd+1, &rfds, &wfds, &xfds, &t); if (e > 0) { if (FD_ISSET(0, &rfds)) { if (gTranslateKeys) { return keyb_getevent(event); } else { event.type = SYSEV_FD_EVENT; event.fd_event.fd = 0; event.fd_event.fd_flags = FD_FLAG_READABLE; return true; } } else { for (int i=0; i<fd_listeners; i++) { int fl = 0; fl |= ((fd_listener[i].fd_flags & FD_FLAG_READABLE) && FD_ISSET(fd_listener[i].fd, &rfds)) ? FD_FLAG_READABLE : 0; fl |= ((fd_listener[i].fd_flags & FD_FLAG_WRITABLE) && FD_ISSET(fd_listener[i].fd, &wfds)) ? FD_FLAG_WRITABLE : 0; fl |= ((fd_listener[i].fd_flags & FD_FLAG_EXCEPTION) && FD_ISSET(fd_listener[i].fd, &xfds)) ? FD_FLAG_EXCEPTION : 0; if (fl) { event.type = SYSEV_FD_EVENT; event.fd_event.fd = fd_listener[i].fd; event.fd_event.fd_flags = fl; return true; } } } // should not happen ! fprintf(stderr, "argh: %s:%d", __FILE__, __LINE__); exit(1); } return false; } static void updateFDSets() { FD_ZERO(&grfds); FD_ZERO(&gwfds); FD_ZERO(&gxfds); g_highest_fd = 0; for (int i=0; i<fd_listeners; i++) { if (fd_listener[i].fd > g_highest_fd) g_highest_fd = fd_listener[i].fd; if (fd_listener[i].fd_flags & FD_FLAG_READABLE) FD_SET(fd_listener[i].fd, &grfds); if (fd_listener[i].fd_flags & FD_FLAG_WRITABLE) FD_SET(fd_listener[i].fd, &gwfds); if (fd_listener[i].fd_flags & FD_FLAG_EXCEPTION) FD_SET(fd_listener[i].fd, &gxfds); } // always listen on stdin FD_SET(0, &grfds); } bool sys_listen_fd_event(int fd, int fd_flags) { if (fd_listeners == MAX_FD_LISTENERS) return false; for (int i=0; i<fd_listeners; i++) { // already listening to fd ? if (fd_listener[i].fd == fd) return false; } fd_listener[fd_listeners].fd = fd; fd_listener[fd_listeners].fd_flags = fd_flags; fd_listeners++; updateFDSets(); return true; } bool sys_unlisten_fd_event(int fd) { for (int i=0; i<fd_listeners; i++) { if (fd_listener[i].fd == fd) { memmove(fd_listener+i, fd_listener+i+1, (fd_listeners-i-1)*sizeof fd_listener[0]); fd_listeners--; updateFDSets(); return true; } } return false; } void sys_set_key_translation(bool translate_keys) { gTranslateKeys = translate_keys; } bool initSysEvent() { updateFDSets(); return true; } void doneSysEvent() { } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/posix/Makefile.in����������������������������������������������������������������������0000644�0001750�0001750�00000032426�12127657374�012774� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Makefile.in generated by automake 1.10.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = io/posix DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru libhtio_a_AR = $(AR) $(ARFLAGS) libhtio_a_LIBADD = am_libhtio_a_OBJECTS = event.$(OBJEXT) sysfile.$(OBJEXT) \ sysdisplay.$(OBJEXT) syskeyb.$(OBJEXT) sysinit.$(OBJEXT) \ sysclipboard.$(OBJEXT) libhtio_a_OBJECTS = $(am_libhtio_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libhtio_a_SOURCES) DIST_SOURCES = $(libhtio_a_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ HT_LDFLAGS = @HT_LDFLAGS@ HT_LIBS = @HT_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IO_DIR = @IO_DIR@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ LZO_LIBS = @LZO_LIBS@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ curses_CPPFLAGS = @curses_CPPFLAGS@ curses_LIBS = @curses_LIBS@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ ncurses_config = @ncurses_config@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/io \ ${curses_CPPFLAGS} AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_LIBRARIES = libhtio.a libhtio_a_SOURCES = event.cc sysfile.cc sysdisplay.cc syskeyb.cc sysinit.cc \ sysclipboard.cc types.h all: all-am .SUFFIXES: .SUFFIXES: .cc .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign io/posix/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign io/posix/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libhtio.a: $(libhtio_a_OBJECTS) $(libhtio_a_DEPENDENCIES) -rm -f libhtio.a $(libhtio_a_AR) libhtio.a $(libhtio_a_OBJECTS) $(libhtio_a_LIBADD) $(RANLIB) libhtio.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/event.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysclipboard.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysdisplay.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysinit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syskeyb.Po@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am #htcurses.cc htcurses.h htkeyb.cc htkeyb.h htsys.cc htsys.h # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/display.cc�����������������������������������������������������������������������������0000755�0001750�0000144�00000022202�10615344121�011506� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * display.cc * * Copyright (C) 1999-2004 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include <new> #include <cstdarg> #include <cstdlib> #include "display.h" #include "snprintf.h" #if 0 static vc gInverseColors[8] = { VC_WHITE, VC_YELLOW, VC_MAGENTA, VC_RED, VC_CYAN, VC_GREEN, VC_BLUE, VC_BLACK }; #define VC_GET_INVERSE(vc) gInverseColor[(vc)&7] #else #define VC_GET_INVERSE(vc) (7-((vc)&7)) #endif inline vc mixSingleColor(vc base, vc layer) { if (VC_GET_BASECOLOR(base) > 7) return layer; switch (VC_GET_BASECOLOR(layer)) { case VC_TRANSPARENT_EXCLUSIVE_DOM: case VC_TRANSPARENT_EXCLUSIVE: case VC_TRANSPARENT: return base; case VC_DARKEN: return VC_GET_BASECOLOR(base); case VC_LIGHTEN: return VC_LIGHT(base); case VC_MONOCHROME: { switch (base) { case VC_CYAN: case VC_MAGENTA: case VC_YELLOW: case VC_WHITE: return VC_WHITE; case VC_RED: case VC_BLACK: case VC_BLUE: case VC_GREEN: default: return VC_BLACK; } } case VC_INVERSE: return VC_GET_INVERSE(VC_GET_BASECOLOR(base)); } return layer; } vcp mixColors(vcp base, vcp layer) { vc fg = mixSingleColor(VCP_FOREGROUND(base), VCP_FOREGROUND(layer)); vc bg = mixSingleColor(VCP_BACKGROUND(base), VCP_BACKGROUND(layer)); if (fg == bg) { if (VC_GET_BASECOLOR(VCP_FOREGROUND(layer)) == VC_TRANSPARENT_EXCLUSIVE || VC_GET_BASECOLOR(VCP_BACKGROUND(layer)) == VC_TRANSPARENT_EXCLUSIVE_DOM) { int fglight = VC_GET_LIGHT(fg); fg = VC_GET_INVERSE(VC_GET_BASECOLOR(bg)) | fglight; fg = VC_BLACK; } else if (VC_GET_BASECOLOR(VCP_BACKGROUND(layer)) == VC_TRANSPARENT_EXCLUSIVE || VC_GET_BASECOLOR(VCP_FOREGROUND(layer)) == VC_TRANSPARENT_EXCLUSIVE_DOM) { int bglight = VC_GET_LIGHT(bg); bg = VC_GET_INVERSE(VC_GET_BASECOLOR(fg)) | bglight; } } return VCP(fg, bg); } /* * Display */ void Display::assign(int x, int y, int w, int h) { Bounds b(x, y, w, h); setBounds(b); } void Display::fillAll(vcp color, char chr, Codepage cp) { fill(0, 0, w, h, color, chr, cp); } void Display::move(int deltax, int deltay) { Bounds b(*this); b.move(deltax, deltay); setBounds(b); } void Display::resize(int deltaw, int deltah) { Bounds b(*this); b.resize(deltaw, deltah); setBounds(b); } int Display::nprintf(int x, int y, vcp color, int maxstrlen, Codepage cp, const char *format, ...) { char buf[512]; va_list ap; va_start(ap, format); ht_vsnprintf(buf, MIN((int)sizeof buf, maxstrlen), format, ap); va_end(ap); return print(x, y, color, buf, cp); } int Display::print(int x, int y, vc color, const char *str, Codepage cp) { return nprint(x, y, color, str, 0x7fffffff, cp); } int Display::printW(int x, int y, vcp color, const AbstractChar *widestr) { const AbstractChar *owidestr = widestr; // FIXME: speed ? while (widestr->codepage != CP_INVALID) { if (!printChar(x++, y, color, widestr->chr, widestr->codepage)) break; widestr++; } return widestr-owidestr; } int Display::nprintW(int x, int y, vcp color, const AbstractChar *widestr, int maxstrlen) { const AbstractChar *owidestr = widestr; // FIXME: speed ? while (widestr->codepage != CP_INVALID && maxstrlen--) { if (!printChar(x++, y, color, widestr->chr, widestr->codepage)) break; widestr++; } return widestr-owidestr; } int Display::printChar(int x, int y, vcp color, char chr, Codepage cp) { // FIXME: speed ? fill(x, y, 1, 1, color, chr, cp); return 1; } int Display::printf(int x, int y, vcp color, Codepage cp, const char *format, ...) { char buf[512]; va_list ap; va_start(ap, format); ht_vsnprintf(buf, sizeof buf, format, ap); va_end(ap); return print(x, y, color, buf, cp); } void Display::setBounds(const Bounds &b) { Bounds::assign(b.x, b.y, b.w, b.h); } /* graphical extension */ #if 0 void Display::line(int px1, int py1, int px2, int py2, uint color) { } void Display::putPixel(int px, int py, uint color) { } void Display::textToPixelCoord(int tx, int ty, int &px, int &py) const { px = tx; py = ty; } void Display::pixelToTextCoord(int px, int py, int &tx, int &ty) const { tx = px; ty = py; } #endif /* * NullDisplay */ NullRDisplay::NullRDisplay(const Bounds &b) : RDisplay(b) { setCursor(0, 0, CURSOR_OFF); } void NullRDisplay::fill(int x, int y, int w, int h, vcp color, char chr, Codepage cp) { } void NullRDisplay::getCursor(int &x, int &y) const { x = cursorx; y = cursory; } CursorMode NullRDisplay::getCursorMode() const { return cursorMode; } int NullRDisplay::nprint(int ix, int iy, vcp color, const char *str, int maxstrlen, Codepage cp) { int i = 0; // FIXME: more efficient impl if (y < h) { while ((ix+i < w) && (*str) && (i<maxstrlen)) { i++; } } return i; } bool NullRDisplay::read(uint &rawchar, vcp &color, int x, int y) const { if ((x >= w) || (y >= h)) return false; return true; } void NullRDisplay::setCursor(int x, int y, CursorMode mode) { cursorx = x; cursory = y; setCursorMode(mode); } void NullRDisplay::setCursorMode(CursorMode mode) { cursorMode = mode; } /* * BufferedRDisplay */ BufferedRDisplay::BufferedRDisplay(const Bounds &b) : RDisplay(b) { buf = NULL; setBounds(b); setCursor(0, 0, CURSOR_OFF); } BufferedRDisplay::~BufferedRDisplay() { free(buf); } void BufferedRDisplay::fill(int x, int y, int w, int h, vcp color, char chr, Codepage cp) { uint rawchar = mapCharToSystemCP(chr, cp); bool transparent = (cp == CP_GRAPHICAL && chr == GC_TRANSPARENT); if (y < 0) { h += y; y = 0; } if (x < 0) { w += x; x = 0; } if (x+w > this->w) { w = this->w - x; } if (y+h > this->h) { h = this->h - y; } for (int iy = y; iy < y+h; iy++) { ColoredChar *b = buf+x+ iy * this->w; for (int ix = x; ix < x+w; ix++) { if (!transparent) b->rawchar = rawchar; b->color = mixColors(b->color, color); b++; } } } void BufferedRDisplay::getCursor(int &x, int &y) const { x = cursorx; y = cursory; } CursorMode BufferedRDisplay::getCursorMode() const { return cursorMode; } int BufferedRDisplay::nprint(int ix, int iy, vcp color, const char *str, int maxstrlen, Codepage cp) { int i = 0; ColoredChar *b = buf+ix+ iy * w; if (iy < h) { while (ix+i < w && str[i] && i < maxstrlen) { bool transparent = (cp == CP_GRAPHICAL && str[i] == GC_TRANSPARENT); if (!transparent) b->rawchar = mapCharToSystemCP(str[i], cp); b->color = mixColors(b->color, color); i++; b++; } } return i; } bool BufferedRDisplay::read(uint &rawchar, vcp &color, int x, int y) const { if (!buf) return false; if ((x >= w) || (y >= h)) return false; ColoredChar *b = buf + x + y*w; rawchar = b->rawchar; color = b->color; return true; } void BufferedRDisplay::setBounds(const Bounds &b) { Bounds oldb = *(Bounds*)this; RDisplay::setBounds(b); ColoredChar *bufnew; if (w * h) { bufnew = ht_malloc(sizeof *buf * w * h); if (!bufnew) throw std::bad_alloc(); ColoredChar *bb = bufnew; for (int iy = 0; iy < h; iy++) { for (int ix = 0; ix < w; ix++) { if ((ix < oldb.w) && (iy < oldb.h) && buf) { *bb = buf[ix+iy*oldb.w]; } else { bb->rawchar = ' '; bb->color = VCP(VC_TRANSPARENT, VC_TRANSPARENT); } bb++; } } } else bufnew = NULL; free(buf); buf = bufnew; } void BufferedRDisplay::setCursor(int x, int y, CursorMode mode) { cursorx = x; cursory = y; setCursorMode(mode); } void BufferedRDisplay::setCursorMode(CursorMode mode) { cursorMode = mode; } /* * SystemDisplay */ SystemDisplay::SystemDisplay() { } /* * SystemRDisplay */ SystemRDisplay::SystemRDisplay(SystemDisplay *System_display, const Bounds &b) : RDisplay(b) { system_display = System_display; } SystemRDisplay::~SystemRDisplay() { } void SystemRDisplay::fill(int x, int y, int w, int h, vcp color, char chr, Codepage cp) { x += this->x; y += this->y; system_display->fill(x, y, w, h, color, chr, cp); } void SystemRDisplay::getCursor(int &x, int &y) const { system_display->getCursor(x, y); x -= this->x; y -= this->y; } CursorMode SystemRDisplay::getCursorMode() const { return system_display->getCursorMode(); } int SystemRDisplay::nprint(int x, int y, vcp color, const char *str, int maxstrlen, Codepage cp) { x += this->x; y += this->y; return system_display->nprint(x, y, color, str, maxstrlen, cp); } bool SystemRDisplay::read(uint &rawchar, vcp &color, int x, int y) const { x += this->x; y += this->y; return system_display->read(rawchar, color, x, y); } void SystemRDisplay::setBounds(const Bounds &b) { RDisplay::setBounds(b); } void SystemRDisplay::setCursor(int x, int y, CursorMode mode) { x += this->x; y += this->y; system_display->setCursor(x, y, mode); } void SystemRDisplay::setCursorMode(CursorMode mode) { system_display->setCursorMode(mode); } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/fileofs.h������������������������������������������������������������������������������0000644�0001750�0000144�00000001725�10615344121�011336� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * fileofs.h * * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) * Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __FILEOFS_H__ #define __FILEOFS_H__ #include "io/types.h" typedef uint64 FileOfs; const FileOfs invFileOfs = ((FileOfs)0xffffffffffffffffLL); #endif /* __FILEOFS_H__ */ �������������������������������������������ht-2.0.22/io/Makefile.in����������������������������������������������������������������������������0000644�0001750�0001750�00000042121�12127657374�011623� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Makefile.in generated by automake 1.10.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = io DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru libcomio_a_AR = $(AR) $(ARFLAGS) libcomio_a_LIBADD = am_libcomio_a_OBJECTS = display.$(OBJEXT) keyb.$(OBJEXT) sys.$(OBJEXT) \ file.$(OBJEXT) libcomio_a_OBJECTS = $(am_libcomio_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libcomio_a_SOURCES) DIST_SOURCES = $(libcomio_a_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive ETAGS = etags CTAGS = ctags DIST_SUBDIRS = djgpp posix win32 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ HT_LDFLAGS = @HT_LDFLAGS@ HT_LIBS = @HT_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IO_DIR = @IO_DIR@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ LZO_LIBS = @LZO_LIBS@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ curses_CPPFLAGS = @curses_CPPFLAGS@ curses_LIBS = @curses_LIBS@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ ncurses_config = @ncurses_config@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(srcdir) -I$(top_srcdir) -I$(srcdir)/$(MY_IO_DIR) AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} @USE_DJGPP_DIR_TRUE@MY_IO_DIR = djgpp @USE_POSIX_DIR_TRUE@MY_IO_DIR = posix @USE_WIN32_DIR_TRUE@MY_IO_DIR = win32 noinst_LIBRARIES = libcomio.a libcomio_a_SOURCES = bounds.h display.cc display.h keyb.cc keyb.h sys.cc sys.h \ file.cc file.h fileofs.h types.h event.h SUBDIRS = $(MY_IO_DIR) EXTRA_SUBDIRS = djgpp posix win32 all: all-recursive .SUFFIXES: .SUFFIXES: .cc .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign io/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign io/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libcomio.a: $(libcomio_a_OBJECTS) $(libcomio_a_DEPENDENCIES) -rm -f libcomio.a $(libcomio_a_AR) libcomio.a $(libcomio_a_OBJECTS) $(libcomio_a_LIBADD) $(RANLIB) libcomio.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/display.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keyb.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sys.Po@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ distdir=`$(am__cd) $(distdir) && pwd`; \ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$top_distdir" \ distdir="$$distdir/$$subdir" \ am__remove_distdir=: \ am__skip_length_check=: \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile $(LIBRARIES) installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ install-strip .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES ctags ctags-recursive distclean \ distclean-compile distclean-generic distclean-tags distdir dvi \ dvi-am html html-am info info-am install install-am \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs installdirs-am \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-compile mostlyclean-generic pdf pdf-am ps ps-am \ tags tags-recursive uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/sys.cc���������������������������������������������������������������������������������0000644�0001750�0000144�00000007165�10615344121�010667� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * sys.cc * * Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "sys.h" #include <ctype.h> #include <errno.h> #include <limits.h> #include <cstdarg> #include <cstdio> #include <cstdlib> #include <cstring> #include <sys/stat.h> #include "file.h" #include "strtools.h" /* * COMMON SYS */ #ifndef S_IFMT #define S_IFMT 0xf000 #endif #ifndef S_ISREG # ifndef S_IFREG # define S_ISREG(m) (0) # else # define S_ISREG(m) (((m) & S_IFMT)==S_IFREG) # endif #endif #ifndef S_ISBLK # ifndef S_IFBLK # define S_ISBLK(m) (0) # else # define S_ISBLK(m) (((m) & S_IFMT)==S_IFBLK) # endif #endif #ifndef S_ISCHR # ifndef S_IFCHR # define S_ISCHR(m) (0) # else # define S_ISCHR(m) (((m) & S_IFMT)==S_IFCHR) # endif #endif #ifndef S_ISDIR # ifndef S_IFDIR # define S_ISDIR(m) (0) # else # define S_ISDIR(m) (((m) & S_IFMT)==S_IFDIR) # endif #endif #ifndef S_ISFIFO # ifndef S_IFFIFO # define S_ISFIFO(m) (0) # else # define S_ISFIFO(m) (((m) & S_IFMT)==S_IFFIFO) # endif #endif #ifndef S_ISLNK # ifndef S_IFLNK # define S_ISLNK(m) (0) # else # define S_ISLNK(m) (((m) & S_IFMT)==S_IFLNK) # endif #endif #ifndef S_ISSOCK # ifndef S_IFSOCK # define S_ISSOCK(m) (0) # else # define S_ISSOCK(m) (((m) & S_IFMT)==S_IFSOCK) # endif #endif #ifndef S_IRUSR #define S_IRUSR 0 #endif #ifndef S_IRGRP #define S_IRGRP 0 #endif #ifndef S_IROTH #define S_IROTH 0 #endif #ifndef S_IWUSR #define S_IWUSR 0 #endif #ifndef S_IWGRP #define S_IWGRP 0 #endif #ifndef S_IWOTH #define S_IWOTH 0 #endif #ifndef S_IXUSR #define S_IXUSR 0 #endif #ifndef S_IXGRP #define S_IXGRP 0 #endif #ifndef S_IXOTH #define S_IXOTH 0 #endif int sys_ht_mode(int mode) { int m = 0; if (S_ISREG(mode)) { m |= HT_S_IFREG; } else if (S_ISBLK(mode)) { m |= HT_S_IFBLK; } else if (S_ISCHR(mode)) { m |= HT_S_IFCHR; } else if (S_ISDIR(mode)) { m |= HT_S_IFDIR; } else if (S_ISFIFO(mode)) { m |= HT_S_IFFIFO; } else if (S_ISLNK(mode)) { m |= HT_S_IFLNK; } else if (S_ISSOCK(mode)) { m |= HT_S_IFSOCK; } if (mode & S_IRUSR) m |= HT_S_IRUSR; if (mode & S_IRGRP) m |= HT_S_IRGRP; if (mode & S_IROTH) m |= HT_S_IROTH; if (mode & S_IWUSR) m |= HT_S_IWUSR; if (mode & S_IWGRP) m |= HT_S_IWGRP; if (mode & S_IWOTH) m |= HT_S_IWOTH; if (mode & S_IXUSR) m |= HT_S_IXUSR; if (mode & S_IXGRP) m |= HT_S_IXGRP; if (mode & S_IXOTH) m |= HT_S_IXOTH; return m; } static char *next_delim(char *s, is_path_delim delim) { while (*s) { s++; if (delim(*s)) return s; } return NULL; } static int flatten_path(char *path, is_path_delim delim) { if (!path || !*path) return 0; char *q = next_delim(path, delim); int pp = flatten_path(q, delim); int ll = q ? (q-path-1) : strlen(path)-1; if ((ll == 2) && (ht_strncmp(path+1, "..", 2) == 0)) { if (q) memmove(path, q, strlen(q)+1); else *path = 0; pp++; } else if ((ll == 1) && (ht_strncmp(path+1, ".", 1) == 0)) { if (q) memmove(path, q, strlen(q)+1); else *path = 0; } else if (pp) { if (q) memmove(path, q, strlen(q)+1); else *path = 0; pp--; } return pp; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/io/bounds.h�������������������������������������������������������������������������������0000755�0001750�0000144�00000003235�10615344121�011202� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * bounds.h - Bounds for rectangular objects * * Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __BOUNDS_H__ #define __BOUNDS_H__ #include "types.h" /** * Rectangular visual Bounds */ struct Bounds { int x, y, w, h; Bounds() {} Bounds(const Bounds &b) { x = b.x; y = b.y; w = b.w; h = b.h; } Bounds(int X, int Y, int W, int H) { x = X; y = Y; w = W; h = H; } inline void assign(int X, int Y, int W, int H) { x = X; y = Y; w = W; h = H; } inline void move(int deltax, int deltay) { x += deltax; y += deltay; } inline void resize(int deltaw, int deltah) { w += deltaw; h += deltah; } inline void intersectWith(const Bounds &b) { if (b.x > x) { w -= b.x-x; x = b.x; } if (b.y > y) { h -= b.y-y; y = b.y; } if (x+w > b.x+b.w) w -= x+w-b.x-b.w; if (y+h > b.y+b.h) h -= y+h-b.y-b.h; if (w < 0) w = 0; if (h < 0) h = 0; } inline bool containsPoint(int ax, int ay) { return (ax >= x) && (ax < x+w) && (ay >= y) && (ay < y+h); } }; #endif /* __BOUNDS_H__ */ �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/htelfimg.cc�������������������������������������������������������������������������������0000644�0001750�0001750�00000010141�11705332140�011230� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * htelfimg.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "log.h" #include "htelfimg.h" #include "htpal.h" #include "strtools.h" #include "formats.h" #include "tools.h" #include "elfstruc.h" #include "elf_analy.h" static ht_view *htelfimage_init(Bounds *b, File *file, ht_format_group *group) { ht_elf_shared_data *elf_shared=(ht_elf_shared_data *)group->get_shared_data(); // if (elf_shared->ident.e_ident[ELF_EI_CLASS]!=ELFCLASS32) return 0; String fn; LOG("%y: ELF: loading image (starting analyser)...", &file->getFilename(fn)); ElfAnalyser *p = new ElfAnalyser(); p->init(elf_shared, file); Bounds c = *b; ht_group *g = new ht_group(); g->init(&c, VO_RESIZE, DESC_ELF_IMAGE"-g"); AnalyInfoline *head; c.y += 2; c.h -= 2; ht_elf_aviewer *v = new ht_elf_aviewer(); v->init(&c, DESC_ELF_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, p, elf_shared); c.y -= 2; c.h = 2; head = new AnalyInfoline(); head->init(&c, v, ANALY_STATUS_DEFAULT); v->attachInfoline(head); /* find lowest/highest address */ Address *low = NULL; Address *high = NULL; switch (elf_shared->ident.e_ident[ELF_EI_CLASS]) { case ELFCLASS32: { ELFAddress l, h; l.a32 = (uint32)-1; h.a32 = 0; ELF_SECTION_HEADER32 *s = elf_shared->sheaders.sheaders32; for (uint i=0; i < elf_shared->sheaders.count; i++) { if (elf_valid_section((elf_section_header*)s, elf_shared->ident.e_ident[ELF_EI_CLASS])) { if (s->sh_addr < l.a32) l.a32=s->sh_addr; if ((s->sh_addr + s->sh_size > h.a32) && s->sh_size) h.a32=s->sh_addr + s->sh_size - 1; } s++; } low = p->createAddress32(l.a32); high = p->createAddress32(h.a32); break; } case ELFCLASS64: { ELFAddress l, h; l.a64 = (uint64)-1; h.a64 = 0; ELF_SECTION_HEADER64 *s = elf_shared->sheaders.sheaders64; for (uint i=0; i < elf_shared->sheaders.count; i++) { if (elf_valid_section((elf_section_header*)s, elf_shared->ident.e_ident[ELF_EI_CLASS])) { if (s->sh_addr < l.a64) l.a64 = s->sh_addr; if ((s->sh_addr + s->sh_size > h.a64) && s->sh_size != 0) { h.a64 = s->sh_addr + s->sh_size - 1; } } s++; } low = p->createAddress64(l.a64); high = p->createAddress64(h.a64); break; } } ht_analy_sub *analy = new ht_analy_sub(); if (low->compareTo(high) < 0) { analy->init(file, v, p, low, high); v->analy_sub = analy; v->insertsub(analy); } else { delete analy; v->done(); delete v; head->done(); delete head; g->done(); delete g; delete high; delete low; return NULL; } delete high; delete low; v->sendmsg(msg_complete_init, 0); Address *tmpaddr = NULL; switch (elf_shared->ident.e_ident[ELF_EI_CLASS]) { case ELFCLASS32: tmpaddr = p->createAddress32(elf_shared->header32.e_entry); break; case ELFCLASS64: tmpaddr = p->createAddress64(elf_shared->header64.e_entry); break; } v->gotoAddress(tmpaddr, NULL); delete tmpaddr; g->insert(head); g->insert(v); g->setpalette(palkey_generic_window_default); elf_shared->v_image=v; return g; } format_viewer_if htelfimage_if = { htelfimage_init, 0 }; /* * CLASS ht_elf_aviewer */ void ht_elf_aviewer::init(Bounds *b, const char *desc, int caps, File *File, ht_format_group *format_group, Analyser *Analy, ht_elf_shared_data *ELF_shared) { ht_aviewer::init(b, desc, caps, File, format_group, Analy); elf_shared = ELF_shared; } void ht_elf_aviewer::setAnalyser(Analyser *a) { ((ElfAnalyser *)a)->elf_shared = elf_shared; ((ElfAnalyser *)a)->file = file; analy = a; analy_sub->setAnalyser(a); } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/htpal.cc����������������������������������������������������������������������������������0000644�0001750�0000144�00000020305�10620204005�010531� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * htpal.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "atom.h" #include "display.h" #include "htctrl.h" #include "htdialog.h" #include "htpal.h" #include "htreg.h" #include "strtools.h" #include "snprintf.h" #include "tools.h" // include indices #include "httag.h" #include "syntax.h" #include "out_ht.h" // #include <stdlib.h> #include <string.h> #define ATOM_PALETTE_ENTRY MAGIC32("PAL\x00") #define ATOM_HT_CREATE_PALETTE_ENTRY MAGIC32("PAL\x10") struct pal_layout { int idx; const char *name; }; /* palette layout: tags */ pal_layout pal_layout_tags[]={ {palidx_tags_edit_tag_cursor_select, "edit-tag cursor select"}, {palidx_tags_edit_tag_cursor_edit, "edit-tag cursor edit"}, {palidx_tags_edit_tag_cursor_unfocused, "edit-tag cursor unfocused"}, {palidx_tags_edit_tag_selected, "edit-tag selected"}, {palidx_tags_edit_tag_modified, "edit-tag modified"}, {palidx_tags_edit_tag, "edit-tag"}, {palidx_tags_sel_tag_cursor_focused, "sel-tag cursor focused"}, {palidx_tags_sel_tag_cursor_unfocused, "sel-tag cursor unfocused"}, {palidx_tags_sel_tag, "sel-tag"}, {0, NULL} }; /* palette layout: generic */ pal_layout pal_layout_generic[] = { {palidx_generic_body, "body"}, {palidx_generic_text_focused, "text focused"}, {palidx_generic_text_unfocused, "text unfocused"}, {palidx_generic_text_shortcut, "text shortcut"}, {palidx_generic_text_shortcut_selected, "text shortcut selected"}, {palidx_generic_text_selected, "text selected"}, {palidx_generic_text_disabled, "text disabled"}, {palidx_generic_frame_focused, "frame focused"}, {palidx_generic_frame_unfocused, "frame unfocused"}, {palidx_generic_frame_move_resize, "frame move-resize"}, {palidx_generic_frame_killer, "frame killer"}, {palidx_generic_scrollbar, "scrollbar"}, {palidx_generic_input_focused, "input focused"}, {palidx_generic_input_unfocused, "input unfocused"}, {palidx_generic_input_selected, "input selected"}, {palidx_generic_input_clip, "input clip-chars"}, {palidx_generic_button_focused, "button focused"}, {palidx_generic_button_unfocused, "button unfocused"}, {palidx_generic_button_shadow, "button shadow"}, {palidx_generic_button_shortcut, "button shortcut"}, {palidx_generic_list_focused_selected, "list focused & selected"}, {palidx_generic_list_focused_unselected, "list focused & unselected"}, {palidx_generic_list_unfocused_selected, "list unfocused & selected"}, {palidx_generic_list_unfocused_unselected, "list unfocused & unselected"}, {palidx_generic_cluster_focused, "cluster focused"}, {palidx_generic_cluster_unfocused, "cluster unfocused"}, {palidx_generic_cluster_shortcut, "cluster shortcut"}, {0, NULL} }; /* palette layout: syntax */ pal_layout pal_layout_syntax[] = { {palidx_syntax_whitespace, "whitespace"}, {palidx_syntax_comment, "comment"}, {palidx_syntax_identifier, "identifier"}, {palidx_syntax_reserved, "reserved"}, {palidx_syntax_intnum, "integer number"}, {palidx_syntax_floatnum, "float number"}, {palidx_syntax_string, "string"}, {palidx_syntax_char, "character"}, {palidx_syntax_symbol, "symbol"}, {palidx_syntax_preprocess, "preprocess"}, {palidx_syntax_meta, "meta"} }; /* palette layout: analyser */ pal_layout pal_layout_analyser[] = { {palidx_analyser_default, "default"}, {palidx_analyser_comment, "comment"}, {palidx_analyser_label, "label"}, {palidx_analyser_number, "number"}, {palidx_analyser_string, "string"}, {palidx_analyser_symbol, "symbol-character"}, }; /* all layouts */ struct pal_class { pal_layout *layout; const char *name; }; pal_class pal_layouts[] = { {pal_layout_generic, "generic"}, {pal_layout_tags, "tags"}, {pal_layout_syntax, "syntax"}, {pal_layout_analyser, "analyser"}, {NULL, NULL} }; /* * reg/pal management */ vcp getcolorv(palette *pal, uint index) { if ((index<pal->size) && (pal->data)) return pal->data[index]; return VCP(VC_WHITE, VC_RED); } pal_layout *find_pal_layout(pal_class *layouts, const char *pal_class, int *lsize) { pal_layout *pl = NULL; while (layouts->layout && layouts->name) { if (strcmp(layouts->name, pal_class) == 0) { pl = layouts->layout; break; } layouts++; } int s = 0; if (pl) { pal_layout *p = pl; while (p->name) { p++; s++; } } if (pl) *lsize = s; return pl; } int find_pal_entry_idx(pal_layout *layout, const char *name) { while (layout->name) { if (strcmp(layout->name, name) == 0) return layout->idx; layout++; } return -1; } bool load_pal(const char *pal_class, const char *pal_flavour, palette *p) { if ((!pal_flavour) || (!pal_class)) return false; char dir[256]; /* secure */ ht_snprintf(dir, sizeof dir, "%s/%s/%s", palettekey, pal_class, pal_flavour); int psize = 0; pal_layout *pl = find_pal_layout(pal_layouts, pal_class, &psize); if (!pl) return false; p->size = psize; p->data = ht_malloc(sizeof *p->data * psize); for (int i=0; i < psize; i++) p->data[i] = VCP(VC_WHITE, VC_RED); ht_registry_node *n = NULL; ht_registry_node_type rnt_pal = registry->lookup_node_type(rnt_palette_name); while ((n = registry->enum_next(dir, n))) { if (n->type == rnt_pal) { int idx = find_pal_entry_idx(pl, n->name); if (idx != -1 && idx < psize) { p->data[idx] = ((palette_entry *)n->data)->color; } } } return true; } /* * CLASS palette_entry */ palette_entry::palette_entry(uint _idx, vcp _color) { idx=_idx; color=_color; } bool palette_entry::editdialog(const char *keyname) { Bounds b; b.w = 50; b.h = 15; b.x = (screen->w - b.w)/2; b.y = (screen->h - b.h)/2; ht_dialog *d=new ht_dialog(); d->init(&b, "edit palette entry", FS_TITLE | FS_KILLER); ht_color_block *fgc, *bgc; ht_label *l1, *l2; b.assign(2, 1, 16, 5); fgc = new ht_color_block(); fgc->init(&b, VCP_FOREGROUND(color), cf_transparent | cf_light); d->insert(fgc); b.assign(2, 0, 16, 1); l1 = new ht_label(); l1->init(&b, "~foreground", fgc); d->insert(l1); b.assign(20, 1, 16, 5); bgc = new ht_color_block(); bgc->init(&b, VCP_BACKGROUND(color), cf_transparent | cf_light); d->insert(bgc); b.assign(20, 0, 16, 1); l2 = new ht_label(); l2->init(&b, "~background", bgc); d->insert(l2); bool r = false; if (d->run(false)) { ht_color_block_data fgd, bgd; ViewDataBuf vdb1(fgc, &fgd, sizeof fgd); ViewDataBuf vdb2(bgc, &bgd, sizeof bgd); color = VCP(fgd.color, bgd.color); r = true; } d->done(); delete d; return r; } void palette_entry::load(ObjectStream &f) { GET_INT32D(f, idx); GET_INT32D(f, color); } ObjectID palette_entry::getObjectID() const { return ATOM_PALETTE_ENTRY; } void palette_entry::store(ObjectStream &f) const { PUT_INT32D(f, idx); PUT_INT32D(f, color); } void palette_entry::strvalue(char *buf32bytes) { char *p = buf32bytes; const char *text; int fg = VCP_FOREGROUND(color); int bg = VCP_BACKGROUND(color); if (fg == VC_TRANSPARENT && bg == VC_TRANSPARENT) { text = "transparent"; fg = VC_WHITE; bg = VC_BLACK; } else if (fg == VC_TRANSPARENT) { text = "fgtrans"; fg = VC_WHITE; if (bg == fg) fg = VC_BLACK; } else if (bg == VC_TRANSPARENT) { text = "bgtrans"; bg = VC_BLACK; if (bg == fg) fg = VC_WHITE; } else { text = "normal"; } p = tag_make_color(p, 32, VCP(fg, bg)); p += sprintf(p, text); p = tag_make_default_color(p, 32); *p = 0; } ht_registry_data *create_empty_palette_entry() { return new palette_entry(); } /* * INIT */ BUILDER(ATOM_PALETTE_ENTRY, palette_entry, ht_registry_data); bool init_pal() { REGISTER(ATOM_PALETTE_ENTRY, palette_entry); registerAtom(ATOM_HT_CREATE_PALETTE_ENTRY, (void*)create_empty_palette_entry); return true; } /* * DONE */ void done_pal() { UNREGISTER(ATOM_PALETTE_ENTRY, palette_entry); unregisterAtom(ATOM_HT_CREATE_PALETTE_ENTRY); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/depcomp�����������������������������������������������������������������������������������0000755�0001750�0001750�00000044400�11637714046�010521� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2009-04-28.21; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free # Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>. case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputing dependencies. libtool Whether libtool is used (yes/no). Report bugs to <bug-automake@gnu.org>. EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u="sed s,\\\\\\\\,/,g" depmode=msvisualcpp fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/hthist.cc���������������������������������������������������������������������������������0000644�0001750�0000144�00000010200�10774162455�010743� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * hthist.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "atom.h" #include "data.h" #include "htdebug.h" #include "hthist.h" #include "strtools.h" #include "tools.h" #include <string.h> #define ATOM_HT_HISTORY_ENTRY MAGIC32("HIS\0") #define ATOM_COMPARE_KEYS_HISTORY_ENTRY MAGIC32("HIS\1") #define MAX_HISTORY_ENTRY_COUNT 40 bool insert_history_entry(List *history, char *name, ht_view *view) { if (name && *name) { ObjectStreamBin *os = NULL; MemoryFile *file = NULL; if (view) { file = new MemoryFile(); os = new ObjectStreamBin(file, false); view->getdata(*os); } ht_history_entry *e = new ht_history_entry(name, os, file); ObjHandle li = history->find(e); if (li == invObjHandle) { history->prepend(e); } else { delete e; history->moveTo(li, history->findFirst()); } /* limit number of history entries to MAX_HISTORY_ENTRY_COUNT */ while (history->count() > MAX_HISTORY_ENTRY_COUNT) { history->del(history->findLast()); } return true; } return false; } /* * CLASS ht_history_entry */ ht_history_entry::ht_history_entry(char *s, ObjectStreamBin *d, MemoryFile *file) { desc = ht_strdup(s); assert(desc); data = d; datafile = file; } ht_history_entry::~ht_history_entry() { free(desc); delete data; delete datafile; } int ht_history_entry::compareTo(const Object *o) const { return strcmp(desc, ((ht_history_entry*)o)->desc); } void ht_history_entry::load(ObjectStream &s) { GET_STRING(s, desc); uint size; GET_INT32D(s, size); if (size) { datafile = new MemoryFile(); data = new ObjectStreamBin(datafile, false); byte d[size]; GETX_BINARY(s, d, size, "data"); datafile->write(d, size); } else { datafile = NULL; data = NULL; } } void ht_history_entry::store(ObjectStream &s) const { PUT_STRING(s, desc); if (datafile) { uint size = datafile->getSize(); PUT_INT32D(s, size); PUTX_BINARY(s, datafile->getBufPtr(), size, "data"); } else { PUTX_INT32D(s, 0, "size"); } } ObjectID ht_history_entry::getObjectID() const { return ATOM_HT_HISTORY_ENTRY; } /* * ATOMS */ static int hist_atoms[]={ HISTATOM_GOTO, HISTATOM_FILE, HISTATOM_SEARCH_BIN, HISTATOM_SEARCH_EVALSTR, HISTATOM_SEARCH_VREGEX, HISTATOM_SEARCH_EXPR, HISTATOM_ASSEMBLER, HISTATOM_NAME_ADDR, HISTATOM_EVAL_EXPR }; void create_hist_atom(uint atom) { List *c = new Array(true); registerAtom(atom, c); } void destroy_hist_atom(uint atom) { Object *c = (Object*)getAtomValue(atom); if (c) { unregisterAtom(atom); delete c; } } void store_history(ObjectStream &s) { uint count = sizeof hist_atoms / sizeof hist_atoms[0]; PUT_INT32D(s, count); for (uint i=0; i < count; i++) { putIDComment(s, hist_atoms[i]); PUTX_INT32X(s, hist_atoms[i], "atom"); List *c = (List*)getAtomValue(hist_atoms[i]); PUTX_OBJECT(s, c, "list"); } } bool load_history(ObjectStream &s) { uint count; GET_INT32D(s, count); for (uint i=0; i < count; i++) { int atom; GET_INT32X(s, atom); destroy_hist_atom(atom); List *c = GETX_OBJECT(s, "list"); registerAtom(atom, c); } return true; } /* * INIT */ BUILDER(ATOM_HT_HISTORY_ENTRY, ht_history_entry, Object); bool init_hist() { for (uint i=0; i < sizeof hist_atoms / sizeof hist_atoms[0]; i++) { create_hist_atom(hist_atoms[i]); } REGISTER(ATOM_HT_HISTORY_ENTRY, ht_history_entry); return true; } /* * DONE */ void done_hist() { UNREGISTER(ATOM_HT_HISTORY_ENTRY, ht_history_entry); for (uint i=0; i<sizeof hist_atoms / sizeof hist_atoms[0]; i++) { destroy_hist_atom(hist_atoms[i]); } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/output/�����������������������������������������������������������������������������������0000755�0001750�0001750�00000000000�12156433676�010566� 5����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ht-2.0.22/output/out_html.cc������������������������������������������������������������������������0000644�0001750�0000144�00000011745�10615344411�012636� �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������/* * HT Editor * out_html.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "analy_names.h" #include "htdebug.h" #include "htinfo.h" #include "out_html.h" #include "tools.h" #include "x86dis.h" #include "string.h" #include "snprintf.h" static const char *header_str = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">\n<html>\n<head>\n"; static const char *footer_str = "</body>\n</html>\n"; static const char *stylesheet_str = "<style type=\"text/css\">\n" "<!--\n" "body {\n" "\tfont: 10pt arial,helvetica,sans-serif;\n" "\tcolor:#00ff00;\n" "\tbackground:#000080;\n" "}\n" "A {\n" "\tcolor:#ffffff;\n" "\ttext-decoration: none;\n" "}\n" ".c {\n" "\tcolor:#c0c0c0;\n" "}\n" ".l {\n" "\tcolor:#ffff00;\n" "}\n" ".sym {\n" "\tcolor:#00ffff;\n" "}\n" ".n {\n" "\tcolor:#008080;\n" "}\n" ".str {\n" "\tcolor:#ff0000;\n" "}\n" "//-->\n" "</style>\n"; void AnalyserHTMLOutput::init(Analyser *analy, Stream *s) { AnalyserOutput::init(analy); stream = s; dis_style = DIS_STYLE_HIGHLIGHT+DIS_STYLE_HEX_NOZEROPAD+DIS_STYLE_HEX_ASMSTYLE+X86DIS_STYLE_OPTIMIZE_ADDR; } void AnalyserHTMLOutput::beginLine() { AnalyserOutput::beginLine(); char temp[20], temp3[20]; if (line == 0) { addr->stringify(temp, sizeof temp, ADDRESS_STRING_FORMAT_LEADING_WHITESPACE); char temp2[20]; last = addr->stringify(temp2, sizeof temp2, ADDRESS_STRING_FORMAT_COMPACT); } else { int s = addr->stringSize(); memset(temp, ' ', s); memset(&temp[s-last], '.', last); temp[s] = 0; } write("<a name=\""); addr->stringify(temp3, sizeof temp, ADDRESS_STRING_FORMAT_LEADING_ZEROS | ADDRESS_STRING_FORMAT_ADD_H); write(temp3); write("\">"); write(temp); write("</a>"); if (analy->explored->contains(addr)) { write("<span class=\"n\"> ! </span>"); } else { write(" "); } } void AnalyserHTMLOutput::endLine() { write("\n"); AnalyserOutput::endLine(); } Stream *AnalyserHTMLOutput::getGenerateStream() { return stream; } int AnalyserHTMLOutput::elementLength(const char *s) { return strlen(s); } char *AnalyserHTMLOutput::link(char *s, Address *Addr) { global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS | ADDRESS_STRING_FORMAT_ADD_H; ht_snprintf(tmpbuf, sizeof tmpbuf, "<a href=\"#%y\">%s</a>", Addr, s); return tmpbuf; } char *AnalyserHTMLOutput::externalLink(char *s, uint32 type1, uint32 type2, uint32 type3, uint32 type4, void *special) { strcpy(tmpbuf, "test"); return tmpbuf; } static void swrite(Stream *s, const char *str) { s->writex(str, strlen(str)); } void AnalyserHTMLOutput::footer() { swrite(stream, footer_str); } void AnalyserHTMLOutput::putElement(int element_type, const char *element) { switch (element_type) { case ELEMENT_TYPE_PRE_COMMENT: case ELEMENT_TYPE_COMMENT: case ELEMENT_TYPE_POST_COMMENT: write("<span class=\"c\">"); write(element); write("</span>"); break; case ELEMENT_TYPE_LABEL: write("<span class=\"l\">"); write(element); write("</span>"); break; case ELEMENT_TYPE_DATA_CODE: write(element); break; case ELEMENT_TYPE_HIGHLIGHT_DATA_CODE: { bool span = false; write(" "); while (*element) { if (*element == '\\') { element++; if (*element == '@') { element++; const char *cl = NULL; switch (*element) { case '#': // comment cl = "c"; break; case 'c': // symbol cl = "sym"; break; case 'd': // default break; case 'n': // number cl = "n"; break; case 's': // string cl = "str"; break; } if (span) write("</span>"); span = false; if (cl) { write("<span class=\""); write(cl); write("\">"); span = true; } element++; } else { *work_buffer++ = '\\'; *work_buffer++ = *element++; } continue; } *work_buffer++ = *element++; } if (span) write("</span>"); break; } case ELEMENT_TYPE_INDENT_XREF: write(" "); break; } } void AnalyserHTMLOutput::header() { String name; analy->getName(name); swrite(stream, header_str); swrite(stream, "\t<title>Analysis of "); swrite(stream, name.contentChar()); swrite(stream, "\n"); swrite(stream, stylesheet_str); swrite(stream, "\n\n\n"); swrite(stream, "Analysis of "); swrite(stream, name.contentChar()); swrite(stream, "
generated by "ht_name" version "ht_version".\n
\n
\n");
}
ht-2.0.22/output/out_ht.h0000644000175000001440000000344410763544657012166 00000000000000/* 
 *	HT Editor
 *	out_ht.h
 *
 *	Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef OUT_HT_H
#define OUT_HT_H

#include "analy.h"
#include "io/types.h"
#include "htobj.h"
#include "out.h"

/*
 *	analyser palette
 */

#define palidx_analyser_default					0
#define palidx_analyser_label						1
#define palidx_analyser_comment					2
#define palidx_analyser_string					3
#define palidx_analyser_number					4
#define palidx_analyser_symbol					5

/*
 *	CLASS analyser_ht_output
 */

class AnalyserHTOutput: public AnalyserOutput {
	palette	analy_pal;
	char tmpbuffer[1024];
	byte *work_buffer_edit_bytes_insert;
	int last;

	vcp getcolor_analy(uint pal_index);
public:

			void init(Analyser *analy);
		virtual	void done();
		virtual	void beginAddr();
		virtual	void beginLine();
		virtual	void changeConfig();
		virtual	int  elementLength(const char *s);
		virtual	void endAddr();
		virtual	void endLine();
		virtual	void putElement(int element_type, const char *element);
		virtual	char *link(char *s, Address *Addr);
		virtual	char *externalLink(char *s, uint32 type1, uint32 type2, uint32 type3, uint32 type4, void *special);
private:
			void reloadPalette();
};

#endif
ht-2.0.22/output/out_sym.h0000644000175000001440000000167410615344411012344 00000000000000/*
 *	HT Editor
 *	out_sym.h
 *
 *	Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net)
 *	Copyright (C) 2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __OUT_SYM_H__
#define __OUT_SYM_H__

#include "analy.h"
#include "io/types.h"
#include "stream.h"

int export_to_sym(Analyser *analy, File *file);

#endif /* __OUT_SYM_H__ */
ht-2.0.22/output/out_sym.cc0000644000175000001440000001353610615344411012502 00000000000000/*
 *	HT Editor
 *	out_sym.cc
 *
 *	Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net)
 *	Copyright (C) 2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "analy_names.h"
#include "htdebug.h"
#include "htinfo.h"
#include "out_html.h"
#include "tools.h"
#include "x86dis.h"
#include "string.h"

/*
 *
 *	Format of .SYM files:
 * ==========================================================================
 *	1. Header, see (1)
 *	2. "seg_count" "Segment tables", see (2)
 *	3. Terminator ???, see (A)
 *
 *   (1) Header
 * ==========================================================================
 *	The header holds the number of symbols+something ('q_count'),
 *	the number of segments ('seg_count') and the module_name.
 *	I dont know what the other fields stand for...
 *	The header always has 32 bytes.
 *
 *	(2) Segment table (starts 16-byte aligned)
 * ==========================================================================
 *	(2.1) Segment Header
 *	- number of symbols "n"
 *	- pointer to "Symbol pointer table" see (2.3), relative to start of
 *	  this header
 *
 *	(2.2) Symbol table
 *	- usually has "n+1" entries of "Symbol table entry", see (3)
 *	- first entry usually is segment descriptor (informative)
 *
 *	(2.3) Symbol pointer table
 *	- consists of "n" entries of 16-bit pointers to a "Symbol table entry"
 *	  (pointers are relative to "Segment Header")
 *
 *   (3) Symbol table entry
 * ==========================================================================
 *	contains 32-bit integer ("the address"), followed by a counted
 *	(Pascal-style) string ("the name").
 *
 *   (A) Appendix A - Unsure
 * ==========================================================================
 *	observed files always had an additional 4 bytes appended.
 *	bytes are either 00,00,00,04 or 00,00,00,06
 */

struct ImageSymHeader {
	uint32 file_size;		// in 16-byte blocks
	uint16 entry_seg;
	uint16 u0;				// 0000
	uint16 u1;				// 0015 (some flags ?, 0014 for 16-bit .SYM ?)
	uint16 seg_count;
	uint32 u2;				// 04020002 (some flags ?)
	byte	module_name[16];
} PACKED;

struct ImageSymSegHeader {
	uint16 next_rec_ofs;		// in 16-byte blocks (ring list, last points to first)
	uint16 sym_count;
	uint16 sym_ptr_table_ptr;
	uint16 seg_idx;
	uint32 seg_start;
	uint32 seg_size;
} PACKED;

struct ImageSymDescriptor {
	uint32 address;
//	byte  name_len;
//   name;
//   ^^^^ pascal string
} PACKED;

/*
 *
 */

#define MAX_BYTES_PER_SEGMENT		0xff00
#define MAX_SYMBOLS_PER_SEGMENT		0x4000

static void write_sym(Stream &stream, uint32 addr, const char *name, uint *bytes_written)
{
	ImageSymDescriptor desc;
	desc.address = addr;
	stream.write(&desc, sizeof desc); // FIXME: endianess !
	stream.writestrp(name);
	*bytes_written += sizeof desc + 1 + strlen(name);
}

static void g(Stream &stream, Symbol *s, uint *bytes_written, uint *symbols_written, uint16 *ptr_table)
{
	if (*bytes_written >= MAX_BYTES_PER_SEGMENT) return;
	if (*symbols_written >= MAX_SYMBOLS_PER_SEGMENT) return;

	uint32 addr;
	if (s->location->addr->byteSize() == sizeof addr) {
		s->location->addr->putIntoArray((byte*)&addr);
//		addr -= 0xbff70000;	/* FIXME: hack for kernel32.dll */
	} else {
		addr = 0;
	}
	
	ptr_table[*symbols_written] = *bytes_written;
	write_sym(stream, addr, s->name, bytes_written);
	
	(*symbols_written) ++;
}

static void align16(File *file, uint *bytes_written)
{
	byte c = 0;
	while (*bytes_written % 16) {
		file->write(&c, 1);
		(*bytes_written) ++;
	}
}
 
int export_to_sym(Analyser *analy, File *file)
{
	if ((!analy) || (!file)) return /*HTML_OUTPUT_ERR_GENERIC*/1;
	if (analy->active) return /*HTML_OUTPUT_ERR_ANALY_NOT_FINISHED*/1;

	const char *module_name = "TEST";
	ImageSymHeader head;
	ImageSymSegHeader seg_head;

// write dummy header
	memset(&head, 0, sizeof head);
	file->write(&head, sizeof head);


/* foreach ($seg) { */

// write dummy seg header
	memset(&seg_head, 0, sizeof seg_head);
	file->write(&seg_head, sizeof seg_head);

	uint bytes_written = sizeof seg_head, symbols_written = 0;

	write_sym(*file, 0xff000000, "_TEXT", &bytes_written);

	uint16 *ptr_table = ht_malloc(MAX_SYMBOLS_PER_SEGMENT * sizeof *ptr_table);

	Symbol *sym = NULL;
	while ((sym = analy->enumSymbols(sym))) {
		g(*file, sym, &bytes_written, &symbols_written, ptr_table);
	}
	
	uint sym_ptr_table_ptr = bytes_written;

	// FIXME: endianess !
	file->write(ptr_table, sizeof *ptr_table * symbols_written);
	bytes_written += sizeof *ptr_table * symbols_written;
	free(ptr_table);

	align16(file, &bytes_written);

	// FIXME: wrong code order, endianess !
	uint32 terminator = 0x04000000;
	file->write(&terminator, sizeof terminator);
	bytes_written += 4;

	file->seek(0x0020);
// write segment header
	seg_head.next_rec_ofs = 0x0002;
	seg_head.sym_count = symbols_written;
	seg_head.sym_ptr_table_ptr = sym_ptr_table_ptr;
	seg_head.seg_idx = 1;
	seg_head.seg_start = 0;
	seg_head.seg_size = 0x0000ffff;
	// FIXME: endianess !
	file->write(&seg_head, sizeof seg_head);
	
/* } */


	bytes_written += sizeof head;
	file->seek(0);
// write header
	head.file_size = (bytes_written-1) / 16;
	head.entry_seg = 0;
	head.u0 = 0;
	head.u1 = 0x0015;
	head.seg_count = 1;
	head.u2 = 0x04020002;
	memcpy(head.module_name, module_name, MIN(strlen(module_name), sizeof head.module_name));
	// FIXME: endianess !
	file->write(&head, sizeof head);

	return 0;
}

ht-2.0.22/output/out_ht.cc0000644000175000001440000001605510763544657012326 00000000000000/* 
 *	HT Editor
 *	out_ht.cc
 *
 *	Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "analy.h"
#include "atom.h"
#include "htctrl.h"
#include "htdebug.h"
#include "httag.h"
#include "htpal.h"
#include "out_ht.h"

#include 
#include 

#define palclasskey_analyser		"analyser"
#define palkey_analyser_default		"default"

void AnalyserHTOutput::init(Analyser *Analy)
{
	analy_pal.data = NULL;
	analy_pal.size = 0;
	AnalyserOutput::init(Analy);
}

void AnalyserHTOutput::done()
{
	free(analy_pal.data);
	AnalyserOutput::done();
}

vcp AnalyserHTOutput::getcolor_analy(uint pal_index)
{
	return getcolorv(&analy_pal, pal_index);
}

void AnalyserHTOutput::reloadPalette()
{
	free(analy_pal.data);
	analy_pal.data = NULL;
	load_pal(palclasskey_analyser, palkey_analyser_default, &analy_pal);
}

void AnalyserHTOutput::beginAddr()
{
	AnalyserOutput::beginAddr();
}

void AnalyserHTOutput::beginLine()
{
	AnalyserOutput::beginLine();
	if (analy->mode & ANALY_SHOW_ADDRESS) {
		char temp[20];
		if (line == 0) {
#if 0
			char temp2[20];
			addr->stringify(temp2, sizeof temp2, ADDRESS_STRING_FORMAT_COMPACT);
			int s = strlen(temp2);
			int s2 = addr->stringSize();
			memset(temp, ' ', s2);
			memcpy(&temp[(s2-s)/2], temp2, s);
			temp[s2]=0;
#endif
			// FIXME:sda lksdfj
			addr->stringify(temp, sizeof temp, ADDRESS_STRING_FORMAT_LEADING_WHITESPACE);
			char temp2[20];
			last = addr->stringify(temp2, sizeof temp2, ADDRESS_STRING_FORMAT_COMPACT);
		} else {
			int s = addr->stringSize();
			memset(temp, ' ', s);
			memset(&temp[s-last], '.', last);
//			memcpy(&temp[(s-3)/2], "...", 3);
			temp[s] = 0;
		}
		// FIXME: buffer bla
		work_buffer = (byte *)tag_make_sel((TAGSTRING *)work_buffer, work_buffer_end-work_buffer, temp);
	}
	
	if (analy->explored->contains(addr)) {
		write(" ! ");
	} else {
		write("   ");
	}

	work_buffer_edit_bytes_insert = work_buffer;
}

void	AnalyserHTOutput::changeConfig()
{
	reloadPalette();
}

int	AnalyserHTOutput::elementLength(const char *s)
{
	return tag_strlen(s);
}

void	AnalyserHTOutput::endAddr()
{
	AnalyserOutput::endAddr();
}

void	AnalyserHTOutput::endLine()
{
	if ((analy->mode & ANALY_EDIT_BYTES) && bytes_line) {
		if (analy->validAddress(addr, scinitialized)) {

			// FIXME: bufferbla? and ugly
			FileOfs a = analy->addressToFileofs(addr);
			assert(a != INVALID_FILE_OFS);

			char workbuf2[1024];
			char *work_buffer2 = workbuf2;
			char *work_buffer2_end = workbuf2 + sizeof workbuf2 - 1;
			*work_buffer2_end = 0;
			
			a += bytes_line - want_bytes_line;
			
			for (int i=0; i < want_bytes_line; i++) {
				work_buffer2 = tag_make_edit_byte(work_buffer2, work_buffer2_end - work_buffer2, a+i);
			}
			for (int i=0; i <= analy->max_opcode_length*2-want_bytes_line*2; i++) {
				if (work_buffer2 < work_buffer2_end) {
					*work_buffer2++ = ' ';
				}
			}

			/* ugly */
			if (work_buffer + (work_buffer2-workbuf2) < work_buffer_end) {
				*work_buffer = 0;
				memmove(work_buffer_edit_bytes_insert+(work_buffer2-workbuf2), work_buffer_edit_bytes_insert, tag_strlen((char*)work_buffer_edit_bytes_insert));
				memcpy(work_buffer_edit_bytes_insert, workbuf2, (work_buffer2-workbuf2));
				work_buffer += (work_buffer2-workbuf2);
			}
		}
	}
	AnalyserOutput::endLine();
}

char *AnalyserHTOutput::externalLink(char *s, uint32 type1, uint32 type2, uint32 type3, uint32 type4, void *special)
{
	*(tag_make_ref(tmpbuffer, sizeof tmpbuffer, type1, type2, type3, type4, s)) = 0;
	return tmpbuffer;
}


char *AnalyserHTOutput::link(char *s, Address *Addr)
{
	// FIXNEW
	uint64 u;
	Addr->putIntoUInt64(u);
	*(tag_make_ref(tmpbuffer, sizeof tmpbuffer, u >> 32, u, 0, 0, s)) = 0;
	return tmpbuffer;
}

void AnalyserHTOutput::putElement(int element_type, const char *element)
{
	// bufferbla's
	switch (element_type) {
	case ELEMENT_TYPE_PRE_COMMENT:
		work_buffer = (byte *)tag_make_color((TAGSTRING *)work_buffer, work_buffer_end-work_buffer, getcolor_analy(palidx_analyser_comment));
		write(element);
		break;
	case ELEMENT_TYPE_COMMENT:
		work_buffer = (byte *)tag_make_color((TAGSTRING *)work_buffer, work_buffer_end-work_buffer, getcolor_analy(palidx_analyser_comment));
		write(element);
		break;
	case ELEMENT_TYPE_POST_COMMENT:
		work_buffer = (byte *)tag_make_color((TAGSTRING *)work_buffer, work_buffer_end-work_buffer, getcolor_analy(palidx_analyser_comment));
		write(element);
		break;
	case ELEMENT_TYPE_LABEL:
		work_buffer = (byte *)tag_make_color((TAGSTRING *)work_buffer, work_buffer_end-work_buffer, getcolor_analy(palidx_analyser_label));
		write(element);
		break;
	case ELEMENT_TYPE_DATA_CODE:
		write(element);
		break;
	case ELEMENT_TYPE_HIGHLIGHT_DATA_CODE:
		work_buffer = (byte *)tag_make_color((TAGSTRING *)work_buffer, work_buffer_end-work_buffer, getcolor_analy(palidx_analyser_default));
		write("  ");
		while (*element && work_buffer < work_buffer_end) {
			if (*element == '\e') {
				int len = tag_get_len(element);
				if (len > work_buffer_end - work_buffer) {
					memset(work_buffer, 0, work_buffer_end - work_buffer);
					work_buffer = work_buffer_end;
				} else {
					while (len--) *work_buffer++ = *element++;
				}
				continue;
			}
			if (*element == '\\') {
				element++;
				if (*element == '@') {
					element++;
					switch (*element) {
					case '#': // comment
						work_buffer = (byte *)tag_make_color((TAGSTRING *)work_buffer, work_buffer_end-work_buffer, getcolor_analy(palidx_analyser_comment));
						break;
					case 'c': // symbol
						work_buffer = (byte *)tag_make_color((TAGSTRING *)work_buffer, work_buffer_end-work_buffer, getcolor_analy(palidx_analyser_symbol));
						break;
					case 'd': // default
						work_buffer = (byte *)tag_make_color((TAGSTRING *)work_buffer, work_buffer_end-work_buffer, getcolor_analy(palidx_analyser_default));
						break;
					case 'n': // number
						work_buffer = (byte *)tag_make_color((TAGSTRING *)work_buffer, work_buffer_end-work_buffer, getcolor_analy(palidx_analyser_number));
						break;
					case 's': // string
						work_buffer = (byte *)tag_make_color((TAGSTRING *)work_buffer, work_buffer_end-work_buffer, getcolor_analy(palidx_analyser_string));
						break;
					}
					element++;
				} else {
					if (work_buffer_end - work_buffer < 2) {
						memset(work_buffer, 0, work_buffer_end - work_buffer);
						work_buffer = work_buffer_end;
					} else {
						*work_buffer++ = '\\';
						*work_buffer++ = *(element++);
					}
				}
				continue;
			}
			*work_buffer++ = *element++;
		}
		break;
	case ELEMENT_TYPE_INDENT_XREF:
		write("  ");
		break;
	}
}


ht-2.0.22/output/Makefile.am0000644000175000017500000000066011724770100012526 00000000000000AUTOMAKE_OPTIONS = foreign

AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/analyser \
              -I$(top_srcdir)/asm -I$(top_srcdir)/io/${IO_DIR} \
              -I$(top_srcdir)/io -I$(top_srcdir)/output
AM_CFLAGS   = ${my_CFLAGS}
AM_CXXFLAGS = ${my_CXXFLAGS}

noinst_LIBRARIES = liboutput.a

liboutput_a_SOURCES = out_html.cc out_html.h out.cc out.h out_ht.cc out_ht.h \
out_sym.cc out_sym.h out_txt.cc out_txt.h

ht-2.0.22/output/out.cc0000644000175000001440000005155511137637676011637 00000000000000/* 
 *	HT Editor
 *	out.cc
 *
 *	Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "analy.h"
#include "analy_names.h"
#include "htdebug.h"
#include "strtools.h"
#include "snprintf.h"
#include "tools.h"
#include "out.h"

// FIXME: grrrrrrrrrrr
#include "x86dis.h"

#include 

#undef DPRINTF
#define DPRINTF(msg...)
#define DPRINTF2(msg...)
//#define DPRINTF(msg...) printf(##msg)
//#define DPRINTF2(msg...) printf(##msg)

int compare_keys_addresses_delinear(Object *key_a, Object *key_b)
{
	return ((Address*)key_a)->compareDelinear((Address*)key_b);
}

/*
 *
 */
OutLine::OutLine(byte *Text, int Textlen, int Bytes)
{
	textlen = Textlen;
	text = ht_malloc(Textlen);
	memcpy(text, Text, textlen);
	bytes = Bytes;
}

OutLine::~OutLine()
{
	free(text);
}


/*
 *
 */
OutAddr::OutAddr(Address *aAddr, uint aTime)
{
	addr = aAddr->clone();
	updateTime(aTime);
	lines = new Array(true);
	size = 0;
	bytes = 0;	
}

OutAddr::~OutAddr()
{
	delete addr;
	delete lines;
}

void OutAddr::appendLine(OutLine *l)
{
	lines->insert(l);
	bytes += l->bytes;
	size += l->textlen;
}

void OutAddr::clear()
{
	lines->delAll();
	bytes = 0;
	size = 0;
}

OutLine *OutAddr::getLine(int i)
{
	return (OutLine*) (*lines)[i];
}

int OutAddr::compareTo(const Object *o) const
{
//	uint oo = o->getObjectID();
	return addr->compareTo(((OutAddr*)o)->addr);
}

void OutAddr::updateTime(uint Time)
{
	time = Time;
}

/*
 *
 */
void	AnalyserOutput::init(Analyser *Analy)
{
	analy = Analy;
	addr = new InvalidAddress();
	cur_addr = NULL;
	cur_out_addr = NULL;
	out_addrs = new AVLTree(true);
	bytes_addr = 0;
	bytes_line = 0;
	size = 0;
	current_time = 0;
	work_buffer_start = ht_malloc(WORKBUF_LEN);
	work_buffer = work_buffer_start;
	work_buffer_end = work_buffer_start + WORKBUF_LEN - 1;
	*work_buffer_end = 0;
	temp_buffer = ht_malloc(WORKBUF_LEN);
	dis_style = DIS_STYLE_HIGHLIGHT+DIS_STYLE_HEX_NOZEROPAD+DIS_STYLE_HEX_ASMSTYLE+X86DIS_STYLE_OPTIMIZE_ADDR;
	changeConfig();
}

void AnalyserOutput::done()
{
	delete out_addrs;
	delete addr;
	free(work_buffer_start);
	free(temp_buffer);
}

void	AnalyserOutput::beginAddr()
{
	bytes_addr = 0;
	line = 0;
}

void	AnalyserOutput::beginLine()
{
	work_buffer = work_buffer_start;
	bytes_line = 0;
}

void	AnalyserOutput::changeConfig()
{
}

int	AnalyserOutput::elementLength(const char *s)
{
	return strlen(s);
}

void	AnalyserOutput::endAddr()
{
}

void	AnalyserOutput::endLine()
{
	cur_out_addr->appendLine(new OutLine(work_buffer_start, (work_buffer-work_buffer_start), bytes_line));
	bytes_addr += bytes_line;
	line++;
}

void AnalyserOutput::footer()
{
	// STUB
}

static char *analyser_output_addr_sym_func(CPU_ADDR Addr, int *symstrlen, void *context)
{
	AnalyserOutput *output = (AnalyserOutput *) context;
	char *buf;
	Address *addr = output->analy->createAddress();
/*     if (Addr.addr32.offset == 0xaea) {
		int as=0;
	}*/
	addr->getFromCPUAddress(&Addr);
	Location *loc = output->analy->getLocationByAddress(addr);

	if (loc && loc->label) {
		buf = output->link(loc->label->name, addr);
		if (symstrlen) *symstrlen = output->elementLength(buf);
		delete addr;
		return buf;
	} else {
		if (output->analy->validAddress(addr, scvalid)) {
			char m[90];
			addr->stringify(m, sizeof m, ADDRESS_STRING_FORMAT_COMPACT | ADDRESS_STRING_FORMAT_ADD_H);
			buf = output->link(m, addr);
			if (symstrlen) *symstrlen = output->elementLength(buf);
			delete addr;
			return buf;
		}
	}
	delete addr;
	return NULL;
}

void AnalyserOutput::generateAddr(Address *Addr, OutAddr *oa)
{
#define LABELINDENT 32
#define MAX_XREF_COLS 3
#define MAX_XREF_LINES 7

#if 0	
	char tbuf[1024];
	Addr->stringify(tbuf, sizeof tbuf, 0);
	printf("generate_addr(%s, ", tbuf);
	char tbuf2[1024];
	addr->stringify(tbuf2, sizeof tbuf2, 0);
	printf("%s)\n", tbuf2);
#endif

	cur_addr = analy->getLocationByAddress(addr);
	cur_out_addr = oa;
	cur_out_addr->clear();

	beginAddr();

	if (cur_addr) {
		int xref_count = cur_addr->xrefs ? cur_addr->xrefs->count() : 0;
		// comments
		CommentList *c = cur_addr->comments;
		if (c && (analy->mode & ANALY_SHOW_COMMENTS)) {
			int c1 = c->count();
			for (int i=0; i < c1; i++) {
				beginLine();
				putElement(ELEMENT_TYPE_PRE_COMMENT, c->getName(i));
				endLine();
			}
		}
		// label && xrefs
		bool collapsed_xrefs = false;
		if (analy->mode & ANALY_COLLAPSE_XREFS) {
			// count xrefs
			if (xref_count >= MAX_XREF_COLS * MAX_XREF_LINES) {
				collapsed_xrefs = true;
			}
		}               
		if ((cur_addr->label && (analy->mode & ANALY_SHOW_LABELS)) || (cur_addr->xrefs && (analy->mode & ANALY_SHOW_XREFS))) {
			beginLine();
			// label
			int labellength = (cur_addr->label) ? strlen(cur_addr->label->name) : 0;
			if (labellength && (analy->mode & ANALY_SHOW_LABELS)) {
				putElement(ELEMENT_TYPE_LABEL, cur_addr->label->name);
				write(":");
				labellength++;
			}
			// xrefs
			if (labellength >= LABELINDENT && cur_addr->xrefs) {
				endLine();
				beginLine();
				labellength = 0;
			}
			if (collapsed_xrefs) {
				for (int j=labellength; j>", xref_count);
				char *t;
				uint64 u;
				Addr->putIntoUInt64(u);
				t = externalLink(b, u >> 32, u, 0, 1, NULL);
				write(t);
			} else {
				Container *xr = cur_addr->xrefs;
				if (xr) {
					int i=0;
					ObjHandle xh = xr->findFirst();
					while (xh != invObjHandle) {
						if ((i % (MAX_XREF_COLS+1))!=0) {
							AddrXRef *x = (AddrXRef *)xr->get(xh);
							char buf3[90];
							sprintf(buf3, " %c", xref_type_short(x->type));
							write(buf3);
							x->addr->stringify(buf3, sizeof buf3, ADDRESS_STRING_FORMAT_COMPACT);
							write(link(buf3, x->addr));
							xh = xr->findNext(xh);
						} else {
							if (i!=0) {
								endLine();
								beginLine();
							}
							for (int j=labellength; jvalidAddress(addr, scinitialized);
	bool is_valid_code_addr = analy->validCodeAddress(addr);
	
	if (
		is_valid_ini_addr 
		&& (
			(
				cur_addr 
				&& (
					cur_addr->type.type == dt_code
					|| (
						cur_addr->type.type == dt_unknown 
						&& is_valid_code_addr
					)
				)
			)			
			|| (
				!cur_addr 
				&& is_valid_code_addr
			)
		)
	) {	
		// code
		Location *next_addr = analy->enumLocations(addr);
		int op_len;
		
		// max. length of current opcode
		if (next_addr) {
			int d = 255;
			next_addr->addr->difference(d, addr);
			op_len = MIN(uint32(analy->max_opcode_length), uint(d));
		} else {
			op_len = analy->max_opcode_length;
		}

		byte buf[16];
		int buffer_size = analy->bufPtr(addr, buf, sizeof buf);
		if (analy->disasm && buffer_size) {
			OPCODE *o = analy->disasm->decode(buf, MIN(buffer_size, op_len), analy->mapAddr(Addr));
			/* inits for addr-sym transformations */
			addr_sym_func_context = this;
			if (analy->mode & ANALY_TRANSLATE_SYMBOLS) addr_sym_func = &analyser_output_addr_sym_func;

			int complete_bytes_line = analy->disasm->getSize(o);
			bool s = true;
			do {
				if (s) {
					const char *x = analy->disasm->str(o, dis_style);
					putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, x);
				}
				if ((s = analy->disasm->selectNext(o))/* || complete_bytes_line*/) {
					endLine();
					beginLine();
				} else {
					if (analy->mode & ANALY_EDIT_BYTES) {
						want_bytes_line = MIN(complete_bytes_line, 16);
					} else {
						want_bytes_line = complete_bytes_line;
					}					
					bytes_line += want_bytes_line;
					complete_bytes_line -= want_bytes_line;
				}
			} while (s || complete_bytes_line);
			
			/* deinits for addr-sym transformations */
			addr_sym_func_context = NULL;
			addr_sym_func = NULL;
		} else {
			if (buffer_size >= 1) {
				char buff[20];
				sprintf(buff, "db          \\@n%02xh", buf[0]);
				putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, buff);
				sprintf(buff, " ; '%c'", (buf[0]<32)?' ':buf[0]);
				putElement(ELEMENT_TYPE_COMMENT, buff);

			} else {
				putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, "db          ??");
			}
			bytes_line = want_bytes_line = 1;
		}
		
	} else {
		// data
		if (analy->validAddress(addr, scvalid)) {
			if (cur_addr && (cur_addr->type.type != dt_unknown)
			&& (cur_addr->type.type != dt_unknown_data)
			&& (cur_addr->type.type != dt_code)) {
				switch (cur_addr->type.type) {
					case dt_int: {
						bytes_line = want_bytes_line = cur_addr->type.length;
						assert(cur_addr->type.length);
						if (analy->validAddress(addr, scinitialized)) {
							char buf[50];
							switch (cur_addr->type.int_subtype) {
							case dst_iword: {
								uint16 c;
								analy->bufPtr(addr, (byte *)&c, 2);
								sprintf(buf, "dw          \\@n%04xh", c);
								putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, buf);
								break;
							}
							case dst_idword: {
								uint32 c;
								analy->bufPtr(addr, (byte *)&c, 4);
								sprintf(buf, "dd          \\@n%08xh", c);
								putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, buf);
								break;
							}
							case dst_iqword: {
								uint64 c;
								analy->bufPtr(addr, (byte *)&c, 8);
								ht_snprintf(buf, sizeof buf, "dq          \\@n%016qxh", c);
								putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, buf);
								break;
							}
							case dst_ibyte:
							default: {
								byte c;
								if (analy->bufPtr(addr, &c, 1)==1) {
									sprintf(buf, "db          \\@n%02xh ", c);
									putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, buf);
									sprintf(buf, "; '%c'", (c<32)?32:c);
									putElement(ELEMENT_TYPE_COMMENT, buf);
								} else {
									putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, "db          ??");
								}
							}
							}
						} else {
							// not initialized
							switch (cur_addr->type.int_subtype) {
							case dst_iword:
								putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, "dw          ????");
								break;
							case dst_idword:
								putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, "dd          ????????");
								break;
							case dst_iqword:
								putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, "dq          ????????????????");
								break;
							case dst_ibyte:
							default:
								putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, "db          ??");
							}
						}
						break;
					}
					case dt_array: {
						if (analy->validAddress(addr, scinitialized)) {
							switch (cur_addr->type.array_subtype) {
							case dst_string: {
								char buf[1024];
								byte bufread[1024];
								char *b;
								int r = analy->bufPtr(addr, bufread, MIN(cur_addr->type.length, sizeof bufread));
								strcpy(buf, "db          \\@s\"");
								b = buf + 16 + escape_special(buf+16, 100, bufread, r, "\"", false);
								*b++ = '\"'; *b = 0;
								putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, buf);
								bytes_line = want_bytes_line = cur_addr->type.length;
								break;
							}
							default: {assert(0);}
							}
						} else {
							putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, "db          ?");
						}
						break;
					}                         
					default: {
						assert(0);
					}
				}
			} else {
				// not a known address
				bytes_line = want_bytes_line = 1;
				byte c;
				if (analy->validAddress(addr, scinitialized) && (analy->bufPtr(addr, &c, 1)==1)) {
					char buf[20];
					sprintf(buf, "db          \\@n%02xh ", c);
					putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, buf);
					sprintf(buf, "; '%c'", (c<32)?32:c);
					putElement(ELEMENT_TYPE_COMMENT, buf);
				} else {
					putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, "db          ??");
				}
			}
		} else {
			// invalid addr
			Address *next = analy->nextValid(Addr);
			int d;
			if (next && next->isValid() && next->difference(d, Addr)) {
				bytes_line += d;
				char buf[100];
				sprintf(buf, "db          ?? * %d", d);
				putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, buf);
			} else {
				bytes_line = want_bytes_line = 1;
				putElement(ELEMENT_TYPE_HIGHLIGHT_DATA_CODE, "db          ??");
			}
		}
	}
	
	endLine();
	endAddr();
}

Stream *AnalyserOutput::getGenerateStream()
{
	return NULL;
}

int AnalyserOutput::generateFile(Address *from, Address *to)
{
	if (analy->active) return OUTPUT_GENERATE_ERR_ANALYSER_NOT_FINISHED;
	if (!from->isValid() || !to->isValid()) return OUTPUT_GENERATE_ERR_INVAL;
	Stream *out = getGenerateStream();
	if (!out) return OUTPUT_GENERATE_ERR_INVAL;
	header();
	int line = 0;
	int len = 0;
	while (from->compareTo(to) <= 0) {
		char buffer[1024];
		if (getLineString(buffer, sizeof buffer, from, line)) {
			// FIXME: remove strlen
			uint wr = strlen(buffer);
			if (out->write(buffer, wr) != wr) return OUTPUT_GENERATE_ERR_STREAM;
			
			int tmplen;
			if (getLineByteLength(tmplen, from, line)) {
				len += tmplen;
			}
			line++;
		} else {
			from->add(len);
			len = 0;
			line = 0;
		}
	}
	footer();
	return OUTPUT_GENERATE_ERR_OK;
}

void	AnalyserOutput::generatePage(Address *from, int lines)
{

}

OutAddr *AnalyserOutput::getAddr(Address *Addr)
{
	char tbuf[1024];
	Addr->stringify(tbuf, sizeof tbuf, 0);
	DPRINTF("%s -- ",tbuf);
	if (!addr->isValid() || Addr->compareTo(addr) != 0) {
		assert(addr != Addr);
		DPRINTF("not cached1 --");
		delete addr;
		addr = Addr->clone();
		OutAddr oatmp(addr, 0);
		OutAddr *oa = (OutAddr*)out_addrs->get(out_addrs->find(&oatmp));
		if (!oa) {
			DPRINTF("generate\n");
			if (out_addrs->count() > 1024) {
				reset();
				delete addr;
				addr = Addr->clone();
			}
			oa = new OutAddr(Addr, current_time);
			generateAddr(Addr, oa);
			out_addrs->insert(oa);
		} else {
			DPRINTF("but cached2 ");
			if (oa->time != current_time) {
				DPRINTF("(and generate)");
				generateAddr(Addr, oa);
				oa->updateTime(current_time);
			}
			DPRINTF("\n");
		}
		cur_out_addr = oa;
	} else {
		DPRINTF("Cached! ");
		if (cur_out_addr->time != current_time) {
			DPRINTF("(but generate)");
			generateAddr(Addr, cur_out_addr);
			cur_out_addr->updateTime(current_time);
		}
		DPRINTF("\n");
	}
	return cur_out_addr;
}

OutLine *AnalyserOutput::getLine(Address *Addr, int line)
{
	return getAddr(Addr)->getLine(line);
}

bool AnalyserOutput::getLineString(char *buf, int maxlen, Address *Addr, int line)
{
	OutLine *ol = getLine(Addr, line);
	if (ol) {
		if (maxlen>0) {
			int len = MIN(ol->textlen+1, maxlen);
			len--;
			memcpy(buf, ol->text, len);
			buf[len] = 0;
		}
		return true;
	} else {
		return false;
	}
}

bool AnalyserOutput::getLineByteLength(int &len, Address *Addr, int line)
{
	OutLine *ol = getLine(Addr, line);
	if (ol) {
		len = ol->bytes;
		return true;
	} else {
		return false;
	}
}

int AnalyserOutput::getLineCount(Address *Addr)
{
    return getAddr(Addr)->lines->count();
}

int AnalyserOutput::getAddrByteLength(Address *Addr)
{
	return getAddr(Addr)->bytes;
}

void	AnalyserOutput::header()
{
	// STUB
}

char *AnalyserOutput::link(char *s, Address *Addr)
{
	strcpy((char*)temp_buffer, s);
	return (char*)temp_buffer;
}

char *AnalyserOutput::externalLink(char *s, uint32 type1, uint32 type2, uint32 type3, uint32 type4, void *special)
{
	strcpy((char*)temp_buffer, s);
	return (char*)temp_buffer;
}

void	AnalyserOutput::invalidateCache()
{
	DPRINTF("invalidateCache()\n");
	current_time++;
	if ((current_time % 50)==0) {
		// collect garbage
		reset();
	}
}

int	AnalyserOutput::nextLine(Address *&Addr, int &line, int n, Address *max)
{
	int res = 0;
	int len;
	while (n--) {
		if (getLineByteLength(len, Addr, line + 1)) {
			line++;
		} else {
			getLineByteLength(len, Addr, line);
			if (Addr->compareTo(max) >= 0) return res;
			if (!Addr->add(len)) return res;
			line = 0;
		}
		res++;
	}
	return res;
}

int	AnalyserOutput::prevLine(Address *&Addr, int &line, int n, Address *min)
{
//#undef DPRINTF2
//#define DPRINTF2(msg...) {ht_snprintf(tbuf, 1024, msg); fprintf(stderr, "%s", tbuf);}
//	char tbuf[1024];
	DPRINTF2("prev_line(%y, %d, %d, %y)\n", Addr, line, n, min);

	int res = 0;
	int cmp = Addr->compareTo(min);
	
	DPRINTF2("cmp=%d\n", cmp);
	/*
	 *	If we have reached |min| and line==0, we're on top
	 */
	if (cmp < 0 || (cmp == 0 && line == 0)) {
		DPRINTF2("geht nicht\n");
		return 0;
	}
	/*
	 *	A simple case: no address-change, only line-changes.
	 *	Go up while line > 0
	 */
	while (n && line) {
		DPRINTF2("simple\n");
		n--;
		line--;
		res++;
	}
	DPRINTF2("test\n");     
	if (!n) return res;
	DPRINTF2("test2\n");

	/*
	 *	Now it gets complicated. We have to go to an other address.
	 *	First we have to figure out where we should start to search for
	 *	the previous address.
	 */
	int min_length, max_length, min_look_ahead, avg_look_ahead, addr_align;
	if (analy->disasm) {
		analy->disasm->getOpcodeMetrics(min_length, max_length, min_look_ahead, avg_look_ahead, addr_align);
	} else {
		min_look_ahead = 1;
		avg_look_ahead = 1;
	}
	
	int l = n*avg_look_ahead;
	if (l < min_look_ahead) l = min_look_ahead;

	/*
	 *	The disassember whats us to go |l| bytes back
	 */
	 
	Address *search_addr = Addr->clone();
	if (!search_addr->add(-l) || search_addr->compareTo(min) < 0) {
		/*
		 *	It isnt possible, to go |l| bytes back. So we start at |min|.
		 */
		delete search_addr;
		search_addr = min->clone();
	}
	DPRINTF2("search-start: %y\n", search_addr);

	/*
	 *	|prev| contains the previous "logical" location.
	 *	That is some address known to be "atomic".
	 */
	Location *prev = analy->enumLocationsReverse(Addr);
	if (prev) {
		DPRINTF2("prev: %y\n", prev->addr);
		/*
		 *	|prevnext| contains the "end address" of |prev|.
		 *	So we know how long (how much bytes) prev is.
		 */
		Address *prevnext = prev->addr->clone();
		if (prevnext->add(getAddrByteLength(prev->addr))) {
			DPRINTF2("mid-test: prevnext %y\n", prevnext);
			if (prevnext->compareTo(Addr) > 0) {
				/*
				 *   We were in the middle of a location.
				 *	We solve this situation by starting a new search
				 *	with |prev->addr|. This is counted as "one line up".
				 */
				delete Addr;
				delete search_addr;
				delete prevnext;
				Addr = prev->addr->clone();
				line = 0;
				res++;
				DPRINTF2("mid\n");
				return prevLine(Addr, line, n-1, min)+res;
			}
			if (prevnext->compareTo(Addr) == 0) {
				delete Addr;
				delete search_addr;
				delete prevnext;
				Addr = prev->addr->clone();
				line = getLineCount(prev->addr)-1;
				res++;
				DPRINTF2("mid2\n");
				return prevLine(Addr, line, n-1, min)+res;
			}
			DPRINTF2("prev: %y prevnext: %y search_addr: %y\n", prev->addr, prevnext, search_addr);
			Address *oldprevnext = prevnext->clone();
			if (prevnext->add(l) && prevnext->compareTo(Addr) >= 0) {
				delete search_addr;
				search_addr = oldprevnext;
				DPRINTF2("prevnext: %y Addr: %y\n", prevnext, Addr);
				DPRINTF2("search_addr: %y\n", search_addr);
				DPRINTF2("mid3\n");
			} else {
				delete oldprevnext;
			}
		}
		delete prevnext;
	}

	int search_line = 0;
	if (search_addr->compareTo(min) < 0) {
		/*
		 *	We have to start the search at |min|.
		 */
		DPRINTF2("search_addr < min\n");
		delete search_addr;
		search_addr = min->clone();
	}

	Address *addrbuf[1024];
	int linebuf[1024];
	int i = 0;
	int len;

	Address *next_addr = search_addr->clone();
	while (1) {
		DPRINTF2("search_addr: (%y, %d) ", search_addr, search_line);
		DPRINTF2("next_addr: %y \n", next_addr);
		if (search_addr->compareTo(Addr) >= 0) {
			if (search_line >= line || (search_addr->compareTo(Addr) > 0)) break;
		}
		if (getLineByteLength(len, search_addr, search_line)) {
			next_addr->add(len);
			search_line++;
		} else {
			delete search_addr;
			search_addr = next_addr->clone();
			search_line = 0;
			continue;
		}
		addrbuf[i & 1023] = search_addr->clone();
		linebuf[i & 1023] = search_line-1;
		i++;
		if (i >= 1023) break;
	}

	delete next_addr;
	delete search_addr;
	
	if (!i) {
		DPRINTF2("no i!\n");
		return res;
	}
	delete Addr;
	if (i >= n) {
		Addr = addrbuf[(i-n) & 1023]->clone();
		line = linebuf[(i-n) & 1023];
		res += n;
		n = 0;
	} else {
		Addr = addrbuf[0]->clone();
		line = linebuf[0];
		res += i;
		n -= i;
	}

	for (int j=0; j < i; j++) delete addrbuf[j];

	if (n) return prevLine(Addr, line, n, min) + res;
	return res;
}

void AnalyserOutput::putElement(int element_type, const char *element)
{
	write(element);
}

void AnalyserOutput::reset()
{
	delete addr;
	addr = new InvalidAddress;
	cur_out_addr = NULL;
	out_addrs->delAll();
}

void AnalyserOutput::write(const char *s)
{
	int len = elementLength(s);
	len = MIN(len, work_buffer_end-work_buffer);
	memcpy(work_buffer, s, len);
	work_buffer += len;
}

void AnalyserOutput::write(const char *s, int n)
{
	n = MIN(n, work_buffer_end-work_buffer);
	memcpy(work_buffer, s, n);
	work_buffer += n;
}
ht-2.0.22/output/out_txt.h0000644000175000001440000000267310615344411012353 00000000000000/* 
 *	HT Editor
 *	out_txt.cc
 *
 *	Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef OUT_TXT_H
#define OUT_TXT_H

#include "analy.h"
#include "io/types.h"
#include "stream.h"
#include "out.h"

class AnalyserTxtOutput: public AnalyserOutput {
	Stream *stream;
	char tmpbuf[1024];
	int last;
public:
		void init(Analyser *analy, Stream *stream);
	virtual	void beginAddr();
	virtual	void beginLine();
	virtual	Stream *getGenerateStream();
	virtual	int  elementLength(const char *s);
	virtual	void endAddr();
	virtual	void endLine();
	virtual	void footer();
	virtual	void header();
	virtual	void putElement(int element_type, const char *element);
	virtual	char *link(char *s, Address *Addr);
	virtual	char *externalLink(char *s, uint32 type1, uint32 type2, uint32 type3, uint32 type4, void *special);
};

#endif
ht-2.0.22/output/out_txt.cc0000644000175000001440000000625210615344411012506 00000000000000/* 
 *	HT Editor
 *	out_txt.cc
 *
 *	Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "analy.h"
#include "htdebug.h"
#include "htinfo.h"
#include "snprintf.h"
#include "out_txt.h"

#include 
#include 

// FIXMEMEMEMEME
#include "x86dis.h"

void	AnalyserTxtOutput::init(Analyser *analy, Stream *s)
{
	AnalyserOutput::init(analy);
	stream = s;
	dis_style = DIS_STYLE_HEX_NOZEROPAD+DIS_STYLE_HEX_ASMSTYLE+X86DIS_STYLE_OPTIMIZE_ADDR;
}

void	AnalyserTxtOutput::beginAddr()
{
	AnalyserOutput::beginAddr();
}

void	AnalyserTxtOutput::beginLine()
{
	AnalyserOutput::beginLine();
	char temp[20];
	if (line==0) {
		addr->stringify(temp, sizeof temp, ADDRESS_STRING_FORMAT_LEADING_WHITESPACE);
		char temp2[20];
		last = addr->stringify(temp2, sizeof temp2, ADDRESS_STRING_FORMAT_COMPACT);
	} else {
		int s = addr->stringSize();
		memset(temp, ' ', s);
		memset(&temp[s-last], '.', last);
		temp[s] = 0;
	}
	write(temp);
	
	if (analy->explored->contains(addr)) {
		write(" ! ");
	} else {
		write("   ");
	}
}

Stream *AnalyserTxtOutput::getGenerateStream()
{
	return stream;
}

int	AnalyserTxtOutput::elementLength(const char *s)
{
	return strlen(s);
}

void	AnalyserTxtOutput::endAddr()
{
	AnalyserOutput::endAddr();
}

void	AnalyserTxtOutput::endLine()
{
	write("\n");
	AnalyserOutput::endLine();
}

void AnalyserTxtOutput::putElement(int element_type, const char *element)
{
	switch (element_type) {
	case ELEMENT_TYPE_HIGHLIGHT_DATA_CODE: {
		write("  ");
		while (*element) {
			if (*element == '\\') {
				element++;
				if (*element == '@') {
					element++;
					if (!*element) break;
					element++;
				} else if (*element == 0) {
					break;
				} else {
					*work_buffer++ = '\\';
					*work_buffer++ = *element++;
				}
				continue;
			}
			*work_buffer++ = *element++;
		}
		break;
	}
	case ELEMENT_TYPE_INDENT_XREF:
		write("  ");
		break;
	default:
		write(element);
		break;
	}
}

char *AnalyserTxtOutput::link(char *s, Address *Addr)
{
	global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS | ADDRESS_STRING_FORMAT_ADD_H;
	ht_snprintf(tmpbuf, sizeof tmpbuf, "%s<%y>", s, Addr);
	return tmpbuf;
}

char *AnalyserTxtOutput::externalLink(char *s, uint32 type1, uint32 type2, uint32 type3, uint32 type4, void *special)
{
	strcpy(tmpbuf, "test");
	return tmpbuf;
}

void AnalyserTxtOutput::footer()
{
}

void	AnalyserTxtOutput::header()
{
	String name;
	ht_snprintf(tmpbuf, sizeof tmpbuf, "Analysis of %y\ngenerated by "ht_name" version "ht_version" ("ht_url")\n\n", &analy->getName(name));
	stream->write(tmpbuf, strlen(tmpbuf));
}

ht-2.0.22/output/Makefile.in0000644000175000017500000003236712127657374012567 00000000000000# Makefile.in generated by automake 1.10.3 from Makefile.am.
# @configure_input@

# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005, 2006, 2007, 2008, 2009  Free Software Foundation,
# Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.

@SET_MAKE@

VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
target_triplet = @target@
subdir = output
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
	$(ACLOCAL_M4)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
LIBRARIES = $(noinst_LIBRARIES)
ARFLAGS = cru
liboutput_a_AR = $(AR) $(ARFLAGS)
liboutput_a_LIBADD =
am_liboutput_a_OBJECTS = out_html.$(OBJEXT) out.$(OBJEXT) \
	out_ht.$(OBJEXT) out_sym.$(OBJEXT) out_txt.$(OBJEXT)
liboutput_a_OBJECTS = $(am_liboutput_a_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
	-o $@
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(liboutput_a_SOURCES)
DIST_SOURCES = $(liboutput_a_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
GREP = @GREP@
HT_LDFLAGS = @HT_LDFLAGS@
HT_LIBS = @HT_LIBS@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
IO_DIR = @IO_DIR@
LDFLAGS = @LDFLAGS@
LEX = @LEX@
LEXLIB = @LEXLIB@
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
LZO_LIBS = @LZO_LIBS@
MAKE = @MAKE@
MAKEINFO = @MAKEINFO@
MKDIR_P = @MKDIR_P@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
YACC = @YACC@
YFLAGS = @YFLAGS@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
curses_CPPFLAGS = @curses_CPPFLAGS@
curses_LIBS = @curses_LIBS@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
ncurses_config = @ncurses_config@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target = @target@
target_alias = @target_alias@
target_cpu = @target_cpu@
target_os = @target_os@
target_vendor = @target_vendor@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign
AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/analyser \
              -I$(top_srcdir)/asm -I$(top_srcdir)/io/${IO_DIR} \
              -I$(top_srcdir)/io -I$(top_srcdir)/output

AM_CFLAGS = ${my_CFLAGS}
AM_CXXFLAGS = ${my_CXXFLAGS}
noinst_LIBRARIES = liboutput.a
liboutput_a_SOURCES = out_html.cc out_html.h out.cc out.h out_ht.cc out_ht.h \
out_sym.cc out_sym.h out_txt.cc out_txt.h

all: all-am

.SUFFIXES:
.SUFFIXES: .cc .o .obj
$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
	@for dep in $?; do \
	  case '$(am__configure_deps)' in \
	    *$$dep*) \
	      ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
	        && { if test -f $@; then exit 0; else break; fi; }; \
	      exit 1;; \
	  esac; \
	done; \
	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  output/Makefile'; \
	cd $(top_srcdir) && \
	  $(AUTOMAKE) --foreign  output/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
	@case '$?' in \
	  *config.status*) \
	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
	  *) \
	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
	esac;

$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh

$(top_srcdir)/configure:  $(am__configure_deps)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh

clean-noinstLIBRARIES:
	-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
liboutput.a: $(liboutput_a_OBJECTS) $(liboutput_a_DEPENDENCIES) 
	-rm -f liboutput.a
	$(liboutput_a_AR) liboutput.a $(liboutput_a_OBJECTS) $(liboutput_a_LIBADD)
	$(RANLIB) liboutput.a

mostlyclean-compile:
	-rm -f *.$(OBJEXT)

distclean-compile:
	-rm -f *.tab.c

@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/out.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/out_ht.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/out_html.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/out_sym.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/out_txt.Po@am__quote@

.cc.o:
@am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ $<

.cc.obj:
@am__fastdepCXX_TRUE@	$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
@am__fastdepCXX_TRUE@	mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@	$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`

ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
	unique=`for i in $$list; do \
	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
	  done | \
	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
	      END { if (nonempty) { for (i in files) print i; }; }'`; \
	mkid -fID $$unique
tags: TAGS

TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
		$(TAGS_FILES) $(LISP)
	tags=; \
	here=`pwd`; \
	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
	unique=`for i in $$list; do \
	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
	  done | \
	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
	      END { if (nonempty) { for (i in files) print i; }; }'`; \
	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
	  test -n "$$unique" || unique=$$empty_fix; \
	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
	    $$tags $$unique; \
	fi
ctags: CTAGS
CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
		$(TAGS_FILES) $(LISP)
	tags=; \
	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
	unique=`for i in $$list; do \
	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
	  done | \
	  $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
	      END { if (nonempty) { for (i in files) print i; }; }'`; \
	test -z "$(CTAGS_ARGS)$$tags$$unique" \
	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
	     $$tags $$unique

GTAGS:
	here=`$(am__cd) $(top_builddir) && pwd` \
	  && cd $(top_srcdir) \
	  && gtags -i $(GTAGS_ARGS) $$here

distclean-tags:
	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags

distdir: $(DISTFILES)
	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
	list='$(DISTFILES)'; \
	  dist_files=`for file in $$list; do echo $$file; done | \
	  sed -e "s|^$$srcdirstrip/||;t" \
	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
	case $$dist_files in \
	  */*) $(MKDIR_P) `echo "$$dist_files" | \
			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
			   sort -u` ;; \
	esac; \
	for file in $$dist_files; do \
	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
	  if test -d $$d/$$file; then \
	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
	    fi; \
	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
	  else \
	    test -f $(distdir)/$$file \
	    || cp -p $$d/$$file $(distdir)/$$file \
	    || exit 1; \
	  fi; \
	done
check-am: all-am
check: check-am
all-am: Makefile $(LIBRARIES)
installdirs:
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am

install-am: all-am
	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am

installcheck: installcheck-am
install-strip:
	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
	  `test -z '$(STRIP)' || \
	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:

clean-generic:

distclean-generic:
	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)

maintainer-clean-generic:
	@echo "This command is intended for maintainers to use"
	@echo "it deletes files that may require special tools to rebuild."
clean: clean-am

clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am

distclean: distclean-am
	-rm -rf ./$(DEPDIR)
	-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
	distclean-tags

dvi: dvi-am

dvi-am:

html: html-am

html-am:

info: info-am

info-am:

install-data-am:

install-dvi: install-dvi-am

install-dvi-am:

install-exec-am:

install-html: install-html-am

install-html-am:

install-info: install-info-am

install-info-am:

install-man:

install-pdf: install-pdf-am

install-pdf-am:

install-ps: install-ps-am

install-ps-am:

installcheck-am:

maintainer-clean: maintainer-clean-am
	-rm -rf ./$(DEPDIR)
	-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic

mostlyclean: mostlyclean-am

mostlyclean-am: mostlyclean-compile mostlyclean-generic

pdf: pdf-am

pdf-am:

ps: ps-am

ps-am:

uninstall-am:

.MAKE: install-am install-strip

.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
	clean-noinstLIBRARIES ctags distclean distclean-compile \
	distclean-generic distclean-tags distdir dvi dvi-am html \
	html-am info info-am install install-am install-data \
	install-data-am install-dvi install-dvi-am install-exec \
	install-exec-am install-html install-html-am install-info \
	install-info-am install-man install-pdf install-pdf-am \
	install-ps install-ps-am install-strip installcheck \
	installcheck-am installdirs maintainer-clean \
	maintainer-clean-generic mostlyclean mostlyclean-compile \
	mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \
	uninstall-am

# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
ht-2.0.22/output/out_html.h0000644000175000001440000000262010615344411012470 00000000000000/*
 *	HT Editor
 *	out_html.h
 *
 *	Copyright (C) 1999, 2000, 2001 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef OUT_HTML_H
#define OUT_HTML_H

#include "analy.h"
#include "io/types.h"
#include "stream.h"
#include "out.h"

class AnalyserHTMLOutput: public AnalyserOutput {
	Stream *stream;
	char tmpbuf[1024];
	int last;
public:
		void init(Analyser *analy, Stream *stream);
	virtual	void beginLine();
	virtual	void endLine();
	virtual	Stream *getGenerateStream();
	virtual	int  elementLength(const char *s);
	virtual	void footer();
	virtual	void header();
	virtual	void putElement(int element_type, const char *element);
	virtual	char *link(char *s, Address *Addr);
	virtual	char *externalLink(char *s, uint32 type1, uint32 type2, uint32 type3, uint32 type4, void *special);
};

#endif
ht-2.0.22/output/out.h0000644000175000001440000000722210620204005011435 00000000000000/* 
 *	HT Editor
 *	out.h
 *
 *	Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef OUT_H
#define OUT_H

#include "analy.h"
#include "io/types.h"
#include "data.h"

class OutLine: public Object {
public:
	int		textlen;
	byte		*text;
	int		bytes;                    // bytes of line in file
			OutLine(byte *Text, int Textlen, int Bytes);
			~OutLine();
};


class OutAddr: public Object {
public:
	Address		*addr;
	uint		time;
	Container	*lines;
	int		size;                     // size in memory
	int		bytes;                    // bytes of address in file
	
			OutAddr(Address *Addr, uint Time);
			~OutAddr();
	void     	appendLine(OutLine *l);
	void		clear();
	OutLine		*getLine(int i);
	void		updateTime(uint Time);

	virtual int	compareTo(const Object *) const;
};

/*
 *	max. length of a generated line is 1024
 */
#define WORKBUF_LEN 1024

#define ELEMENT_TYPE_PRE_COMMENT 0
#define ELEMENT_TYPE_COMMENT 1
#define ELEMENT_TYPE_POST_COMMENT 2
#define ELEMENT_TYPE_LABEL 3
#define ELEMENT_TYPE_DATA_CODE 4
#define ELEMENT_TYPE_HIGHLIGHT_DATA_CODE 5
#define ELEMENT_TYPE_INDENT_XREF 6

#define EXTERNAL_LINK_SHOW_XREFS 0
#define EXTERNAL_LINK_SHOW_COMMENTS 1

#define OUTPUT_GENERATE_ERR_OK 0
#define OUTPUT_GENERATE_ERR_INVAL 1
#define OUTPUT_GENERATE_ERR_ANALYSER_NOT_FINISHED 2
#define OUTPUT_GENERATE_ERR_STREAM 3

/*
 *
 */
class AnalyserOutput: public Object {
public:
	Analyser	*analy;
	Address		*addr;
	int		line;
	Location	*cur_addr;
	OutAddr		*cur_out_addr;
	int		bytes_line;               // bytes of current line in file
	int		want_bytes_line;
	int		bytes_addr;               // bytes of current addr in file
		
	Container	*out_addrs;

	byte		*work_buffer_start;
	byte		*work_buffer_end;
	byte		*work_buffer;

	byte		*temp_buffer;
		
	uint		current_time;
	int		size;
		
	int		dis_style;
		
		void			init(Analyser *analy);
	virtual	void			done();
	virtual	void			beginAddr();
	virtual	void			beginLine();
	virtual	void			changeConfig();
	virtual	int			elementLength(const char *s);
	virtual	void			endAddr();
	virtual	void			endLine();
	virtual	char *			externalLink(char *s, uint32 type1, uint32 type2, uint32 type3, uint32 type4, void *special);
	virtual	void			footer();
			void		generateAddr(Address *Addr, OutAddr *oa);
			int		generateFile(Address *from, Address *to);
	virtual	Stream *		getGenerateStream();
			void		generatePage(Address *from, int lines);
			OutAddr *	getAddr(Address *Addr);
			OutLine *	getLine(Address *Addr, int line);
			bool		getLineString(char *buf, int maxlen, Address *Addr, int line);
			bool		getLineByteLength(int &len, Address *Addr, int line);
			int		getLineCount(Address *Addr);
			int		getAddrByteLength(Address *Addr);
	virtual	void			header();
			void		invalidateCache();
	virtual	char *			link(char *s, Address *Addr);
			int		nextLine(Address *&Addr, int &line, int n, Address *max);
			int		prevLine(Address *&Addr, int &line, int n, Address *min);
	virtual	void			putElement(int element_type, const char *element);
			void		reset();
			void		write(const char *s);
			void		write(const char *s, int n);
};

#endif
ht-2.0.22/htleimg.cc0000644000175000001440000001004710615341620011065 00000000000000/*
 *	HT Editor
 *	htleimg.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "log.h"
#include "htnewexe.h"
#include "htpal.h"
#include "htleimg.h"
#include "htsearch.h"
#include "strtools.h"
#include "formats.h"
#include "tools.h"

#include "lestruct.h"

#include "htanaly.h"
#include "le_analy.h"

static ht_view *htleimage_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_le_shared_data *le_shared=(ht_le_shared_data *)group->get_shared_data();

	File *myfile = le_shared->reloc_file;

	String fn;
	LOG("%y: LE: loading image (starting analyser)...", &file->getFilename(fn));
	LEAnalyser *p = new LEAnalyser();
	p->init(le_shared, myfile);

	Bounds c = *b;
	ht_group *g = new ht_group();
	g->init(&c, VO_RESIZE, DESC_LE_IMAGE"-g");
	AnalyInfoline *head;

	c.y += 2;
	c.h -= 2;
	ht_le_aviewer *v = new ht_le_aviewer();
	v->init(&c, DESC_LE_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, myfile, group, p, le_shared);
	v->search_caps = SEARCHMODE_VREGEX;

	c.y -= 2;
	c.h = 2;
	head = new AnalyInfoline();
	head->init(&c, v, ANALY_STATUS_DEFAULT);

	v->attachInfoline(head);

/* search for lowest/highest */
	LEAddress l=(LEAddress)-1, h=0;
	LE_OBJECT *s = le_shared->objmap.header;
	for (uint i=0; iobjmap.count; i++) {
		LEAddress base = LE_MAKE_ADDR(le_shared, i, 0);
		uint evsize = MAX(LE_get_seg_vsize(le_shared, i), LE_get_seg_psize(le_shared, i));
		if (base < l) l = base;
		if ((base + evsize > h) && (evsize)) h = base + evsize - 1;
		s++;
	}
/**/
	Address *low = p->createAddressFlat32(l);
	Address *high = p->createAddressFlat32(h);
	ht_analy_sub *analy = new ht_analy_sub();
	analy->init(myfile, v, p, low, high);
	v->analy_sub = analy;
	v->insertsub(analy);
	delete high;
	delete low;

	v->sendmsg(msg_complete_init, 0);

	g->insert(head);
	g->insert(v);

	g->setpalette(palkey_generic_window_default);

	le_shared->v_image = v;
	return g;
}

format_viewer_if htleimage_if = {
	htleimage_init,
	0
};

/*
 *	CLASS ht_le_aviewer
 */

void ht_le_aviewer::init(Bounds *b, const char *desc, int caps, File *File, ht_format_group *format_group, Analyser *Analy, ht_le_shared_data *LE_shared)
{
	ht_aviewer::init(b, desc, caps, File, format_group, Analy);
	le_shared = LE_shared;
	file = File;
}

const char *ht_le_aviewer::func(uint i, bool execute)
{
	switch (i) {
		case 3: {
			bool e = false;
			file->cntl(FCNTL_GET_RELOC, &e);
			if (execute) {
				file->cntl(FCNTL_SET_RELOC, !e);
				analy_sub->output->invalidateCache();
				dirtyview();
			}
			return e ? (char*)"unrelocate" : (char*)"relocate";
		}
	}
	return ht_aviewer::func(i, execute);
}

bool ht_le_aviewer::offset_to_pos(FileOfs ofs, viewer_pos *p)
{
	if (!analy) return false;
	Address *a = ((LEAnalyser*)analy)->realFileofsToAddress(ofs);
	bool res = convertAddressToViewerPos(a, p);
	delete a;
	return res;
}

bool ht_le_aviewer::pos_to_offset(viewer_pos p, FileOfs *ofs)
{
	if (analy) {
		Address *addr;
		if (!convertViewerPosToAddress(p, &addr)) return false;
		FileOfs o=((LEAnalyser*)analy)->addressToRealFileofs(addr);
		delete addr;
		if (o!=INVALID_FILE_OFS) {
			*ofs=o;
			return true;
		}
	}
	return false;
}

bool ht_le_aviewer::get_current_real_offset(FileOfs *ofs)
{
	FileOfs o;
	if (!get_current_offset(&o)) return false;
	FileOfs m;
	if (!le_shared->linear_file->map_ofs(o, ofs, &m)) return false;
	return true;
}

void ht_le_aviewer::setAnalyser(Analyser *a)
{
	((LEAnalyser*)a)->le_shared = le_shared;
	((LEAnalyser*)a)->file = file;
	analy = a;
	analy_sub->setAnalyser(a);
}
ht-2.0.22/coff_s.h0000644000175000001440000001632210615341616010544 00000000000000/* 
 *	HT Editor
 *	coff_s.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __COFF_S_H_
#define __COFF_S_H_

#include "io/types.h"
#include "tools.h"

typedef unsigned int RVA;

struct COFF_HEADER {
	uint16 machine;
	uint16 section_count;
	uint32 timestamp;
	uint32 symbol_table_offset;
	uint32 symbol_count;
	uint16 optional_header_size;
	uint16 characteristics;
} PACKED;

#define COFF_RELOCS_STRIPPED		   	0x0001  // Relocation info stripped from file.
#define COFF_EXECUTABLE_IMAGE		   	0x0002  // File is executable  (i.e. no unresolved externel references).
#define COFF_LINE_NUMS_STRIPPED			0x0004  // Line nunbers stripped from file.
#define COFF_LOCAL_SYMS_STRIPPED	   	0x0008  // Local symbols stripped from file.
#define COFF_AGGRESIVE_WS_TRIM	  		0x0010  // Agressively trim working set
#define COFF_LARGE_ADDRESS	  		0x0020  // Large address aware
#define COFF_BYTES_REVERSED_LO	  		0x0080  // Bytes of machine uint16 are reversed.
#define COFF_32BIT_MACHINE			0x0100  // 32 bit uint16 machine.
#define COFF_DEBUG_STRIPPED		   	0x0200  // Debugging info stripped from file in .DBG file
#define COFF_REMOVABLE_RUN_FROM_SWAP   		0x0400  // If Image is on removable media, copy and run from the swap file.
#define COFF_NET_RUN_FROM_SWAP	   		0x0800  // If Image is on Net, copy and run from the swap file.
#define COFF_SYSTEM				0x1000  // System File.
#define COFF_DLL				0x2000  // File is a DLL.
#define COFF_UP_SYSTEM_ONLY		   	0x4000  // File should only be run on a UP machine
#define COFF_BYTES_REVERSED_HI	  		0x8000  // Bytes of machine uint16 are reversed.

#define COFF_MACHINE_UNKNOWN		   	0
#define COFF_MACHINE_I386		   	0x14c   // Intel 386
#define COFF_MACHINE_I486		   	0x14d   // Intel 486
#define COFF_MACHINE_I586		  	0x14e   // Intel 586
#define COFF_MACHINE_R3000BE			0x160   // MIPS big-endian
#define COFF_MACHINE_R3000			0x162   // MIPS little-endian
#define COFF_MACHINE_R4000			0x166   // MIPS little-endian
#define COFF_MACHINE_R10000		   	0x168   // MIPS little-endian
#define COFF_MACHINE_ALPHA			0x184   // Alpha_AXP
#define COFF_MACHINE_SH3			0x1a2   // Hitachi SH3
#define COFF_MACHINE_SH4		   	0x1a6   // Hitachi SH4
#define COFF_MACHINE_ARM			0x1c0   // ARM
#define COFF_MACHINE_THUMB			0x1c2   // THUMB
#define COFF_MACHINE_POWERPC_BE		   	0x1df   // IBM PowerPC Big-Endian (?)
#define COFF_MACHINE_POWERPC_LE		   	0x1f0   // IBM PowerPC Little-Endian
#define COFF_MACHINE_POWERPC64_BE		0x1f2   // IBM PowerPC64 Big-Endian (?)
#define COFF_MACHINE_IA64			0x200   // Intel IA64
#define COFF_MACHINE_MIPS16			0x266   // MIPS16
#define COFF_MACHINE_68k			0x268   // Motorola 68k
#define COFF_MACHINE_ALPHA_AXP_64		0x284   // Alpha AXP 64
#define COFF_MACHINE_MIPSf			0x366   // MIPSf
#define COFF_MACHINE_MIPS16f			0x466   // MIPS16f
#define COFF_MACHINE_AMD64			0x8664  // AMD 64

// FIXME: not yet implemented: XCOFF64, no sample file available
//#define COFF_MACHINE_POWERPC64_BE	   	0x1ef   // XCOFF 64Bit Big-Endian (PowerPC only ?)

//
// Optional header format.
//

#define COFF_OPTSIZE_0				0x00

#define COFF_OPTSIZE_COFF32			0x1c
#define COFF_OPTSIZE_XCOFF32			0x48

#define COFF_OPTSIZE_PE32			0xe0


#define COFF_OPTMAGIC_ROMIMAGE			0x107

#define COFF_OPTMAGIC_PE32			0x10b
#define COFF_OPTMAGIC_COFF32			0x10b

#define COFF_OPTMAGIC_PE64			0x20b

struct	COFF_OPTIONAL_HEADER32 {
	uint16 magic;
	byte major_linker_version;
	byte minor_linker_version;
	uint32 code_size;
	uint32 data_size;
	uint32 bss_size;
	uint32 entrypoint_address;
	uint32 code_base;
	uint32 data_base;
} PACKED;

/*
 *	same as COFF_OPTIONAL_HEADER32 but no data_base
 */
struct	COFF_OPTIONAL_HEADER64 {
	uint16 magic;
	byte major_linker_version;
	byte minor_linker_version;
	uint32 code_size;
	uint32 data_size;
	uint32 bss_size;
	uint32 entrypoint_address;
	uint32 code_base;
} PACKED;

/*
 *	Section header
 */

#define COFF_SIZEOF_SHORT_NAME			8

struct COFF_SECTION_HEADER {
	byte name[COFF_SIZEOF_SHORT_NAME];
	uint32 data_vsize;	// or data_phys_address !
	uint32 data_address;
	uint32 data_size;
	uint32 data_offset;
	uint32 relocation_offset;
	uint32 linenumber_offset;
	uint16 relocation_count;
	uint16 linenumber_count;
	uint32 characteristics;
} PACKED;

#define COFF_SIZEOF_SECTION_HEADER		40

/*
 * Section characteristics.
 */

//      COFF_SCN_TYPE_REG			0x00000000  // Reserved.
//      COFF_SCN_TYPE_DSECT			0x00000001  // Reserved.
//      COFF_SCN_TYPE_NOLOAD			0x00000002  // Reserved.
//      COFF_SCN_TYPE_GROUP			0x00000004  // Reserved.
#define COFF_SCN_TYPE_NO_PAD			0x00000008  // Reserved.
//      COFF_SCN_TYPE_COPY			0x00000010  // Reserved.

#define COFF_SCN_CNT_CODE			0x00000020	// Section contains code.
#define COFF_SCN_CNT_INITIALIZED_DATA		0x00000040	// Section contains initialized data.
#define COFF_SCN_CNT_UNINITIALIZED_DATA		0x00000080	// Section contains uninitialized data.

#define COFF_SCN_LNK_OTHER			0x00000100	// Reserved.
#define COFF_SCN_LNK_INFO			0x00000200	// Section contains comments or some other type of information.
//      COFF_SCN_TYPE_OVER			0x00000400	// Reserved.
#define COFF_SCN_LNK_REMOVE			0x00000800	// Section contents will not become part of image.
#define COFF_SCN_LNK_COMDAT			0x00001000	// Section contents comdat.
//						0x00002000	// Reserved.

//      COFF_SCN_MEM_PROTECTED - Obsolete	0x00004000
#define COFF_SCN_MEM_FARDATA			0x00008000
//      COFF_SCN_MEM_SYSHEAP  - Obsolete	0x00010000
#define COFF_SCN_MEM_PURGEABLE			0x00020000
#define COFF_SCN_MEM_16BIT			0x00020000
#define COFF_SCN_MEM_LOCKED			0x00040000
#define COFF_SCN_MEM_PRELOAD			0x00080000

#define COFF_SCN_ALIGN_1BYTES			0x00100000	//
#define COFF_SCN_ALIGN_2BYTES			0x00200000	//
#define COFF_SCN_ALIGN_4BYTES			0x00300000	//
#define COFF_SCN_ALIGN_8BYTES			0x00400000	//
#define COFF_SCN_ALIGN_16BYTES		   	0x00500000	// Default alignment if no others are specified.
#define COFF_SCN_ALIGN_32BYTES		   	0x00600000	//
#define COFF_SCN_ALIGN_64BYTES		   	0x00700000	//
// Unused					0x00800000

#define COFF_SCN_LNK_NRELOC_OVFL		0x01000000	// Section contains extended relocations.
#define COFF_SCN_MEM_DISCARDABLE		0x02000000	// Section can be discarded.
#define COFF_SCN_MEM_NOT_CACHED			0x04000000	// Section is not cachable.
#define COFF_SCN_MEM_NOT_PAGED			0x08000000	// Section is not pageable.
#define COFF_SCN_MEM_SHARED			0x10000000	// Section is shareable.
#define COFF_SCN_MEM_EXECUTE			0x20000000	// Section is executable.
#define COFF_SCN_MEM_READ			0x40000000	// Section is readable.
#define COFF_SCN_MEM_WRITE			0x80000000	// Section is writeable.

extern byte COFF_HEADER_struct[];
extern byte COFF_OPTIONAL_HEADER32_struct[];
extern byte COFF_OPTIONAL_HEADER64_struct[];
extern byte COFF_SECTION_HEADER_struct[];

#endif /* !__COFF_S_H_ */
ht-2.0.22/htdialog.cc0000644000175000001440000016145110776766223011257 00000000000000/*
 *	HT Editor
 *	htdialog.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include 
#include 
#include 
#include 

#include "htclipboard.h"
#include "htctrl.h"
#include "htdialog.h"
#include "hthist.h"
#include "htidle.h"
#include "keyb.h"
#include "htpal.h"
#include "snprintf.h"
#include "strtools.h"
#include "tools.h"

ht_queued_msg::ht_queued_msg(ht_view *aTarget, htmsg &aMsg)
{
	target = aTarget;
	msg = aMsg;
}

void ht_dialog_widget::getminbounds(int *width, int *height)
{
	*width = 1;
	*height = 1;
}

/*
 *	CLASS ht_dialog
 */

void ht_dialog::init(Bounds *b, const char *desc, uint framestyle)
{
	ht_window::init(b, desc, framestyle);
	VIEW_DEBUG_NAME("ht_dialog");
	options &= ~VO_SELBOUND;
	msgqueue = new Queue(true);
}

void ht_dialog::done()
{
	delete msgqueue;
	ht_window::done();
}

int ht_dialog::aclone()
{
	return 1;
}

const char *ht_dialog::defaultpalette()
{
	return palkey_generic_dialog_default;
}

ht_queued_msg *ht_dialog::dequeuemsg()
{
	return (ht_queued_msg*)msgqueue->deQueue();
}

void ht_dialog::draw()
{
	clear(getcolor(palidx_generic_body));
	ht_group::draw();
}

int ht_dialog::getstate(int *aReturn_val)
{
	if (aReturn_val) *aReturn_val = return_val;
	return state;
}

void ht_dialog::handlemsg(htmsg *msg)
{
	if (msg->msg == msg_button_pressed) {
		switch (msg->data1.integer) {
		case button_cancel:
			setstate(ds_term_cancel, msg->data1.integer);
			clearmsg(msg);
			return;
		default:
			setstate(ds_term_ok, msg->data1.integer);
			clearmsg(msg);
			return;
		}
	}
	ht_window::handlemsg(msg);
	if (msg->msg == msg_keypressed) {
		switch (msg->data1.integer) {
		case K_Escape:
			setstate(ds_term_cancel, msg->data1.integer);
			clearmsg(msg);
			return;
		case K_Return:
			sendmsg(msg_button_pressed, button_ok);
			clearmsg(msg);
			return;
		case K_Control_O: {
		}
		}
	}
}

void do_modal_resize();

int ht_dialog::run(bool modal)
{
	ht_view *orig_focused=app->getselected(), *orig_baseview=baseview;
	int oldx, oldy;
	ht_view *drawer=modal ? this : app;
	screen->getCursor(oldx, oldy);
	setstate(ds_normal, 0);
	((ht_group*)app)->insert(this);
	((ht_group*)app)->focus(this);
	baseview = this;
	drawer->sendmsg(msg_draw, 0);
	screen->show();
	while (getstate(0) == ds_normal) {
		if (keyb_keypressed()) {
			ht_key k = keyb_getkey();
			sendmsg(msg_keypressed, k);
			drawer->sendmsg(msg_draw, 0);
			screen->show();
		}
		if (sys_get_winch_flag()) {
			do_modal_resize();
		}
		ht_queued_msg *q;
		while ((q = dequeuemsg())) {
			htmsg m = q->msg;
			q->target->sendmsg(&m);
			sendmsg(msg_draw);
			delete q;
		}
		if (!modal) do_idle();
	}
	int return_val;
	int state = getstate(&return_val);
	screen->setCursor(oldx, oldy);
	((ht_group*)app)->remove(this);
	app->focus(orig_focused);
	baseview = orig_baseview;
	if (state != ds_term_cancel) {
		return return_val;
	} else {
		return 0;
	}
}

void ht_dialog::queuemsg(ht_view *target, htmsg &msg)
{
	msgqueue->enQueue(new ht_queued_msg(target, msg));
}

void ht_dialog::setstate(int st, int retval)
{
	state = st;
	return_val = retval;
}

/*
 *	CLASS ht_cluster
 */

void ht_cluster::init(Bounds *b, ht_string_list *_strings)
{
	ht_view::init(b, VO_SELECTABLE | VO_OWNBUFFER | VO_POSTPROCESS, 0);
	VIEW_DEBUG_NAME("ht_cluster");
	strings=_strings;
	scount=strings->count();
	if (scount>32) scount=32;			/* cant use more than 32... */
	sel=0;
	for (int i=0; iget_string(i);
		s = strchr(s, '~');
		if (s) {
			shortcuts[i] = keyb_metakey((ht_key)*(s+1));
		} else shortcuts[i] = K_INVALID;
	}
}

void ht_cluster::done()
{
	delete strings;
	ht_view::done();
}

const char *ht_cluster::defaultpalette()
{
	return palkey_generic_dialog_default;
}

/*
 *	CLASS ht_checkboxes
 */

void ht_checkboxes::init(Bounds *b, ht_string_list *strings)
{
	ht_cluster::init(b, strings);
	VIEW_DEBUG_NAME("ht_checkboxes");
	state=0;
}

void ht_checkboxes::done()
{
	ht_cluster::done();
}

int ht_checkboxes::datasize()
{
	return sizeof (ht_checkboxes_data);
}

void ht_checkboxes::draw()
{
	clear(getcolor(focused ? palidx_generic_cluster_focused
		: palidx_generic_cluster_unfocused));
	int i=0;
	int vx=0, vy=0;
	int maxcolstrlen=0;
	while (iget_string(i);
		int slen = strlen(s);
		if (slen > maxcolstrlen) maxcolstrlen = slen;
		if ((1 << i) & state) {
			buf->print(vx, vy, c, "[X]");
		} else {
			buf->print(vx, vy, c, "[ ]");
		}
		int k=0, oc=c;
		for (int q=0; q < size.w-4; q++) {
			if (!*(s+q)) break;
			if (*(s+q)=='~') {
				c = getcolor(palidx_generic_cluster_shortcut);
				continue;
			} else {
				buf->printChar(vx+k+4, vy, c, *(s+q));
				k++;
			}
			c=oc;
		}
		i++;
		vy++;
		if (vy>=size.h) {
			vx+=maxcolstrlen+5;
			vy=0;
			maxcolstrlen=0;
		}
	}
}

void ht_checkboxes::getdata(ObjectStream &s)
{
	PUT_INT32D(s, state);
}

void ht_checkboxes::handlemsg(htmsg *msg)
{
	if (msg->type==mt_postprocess) {
		if (msg->msg==msg_keypressed) {
			for (int i=0; idata1.integer == shortcuts[i]) {
					sel = i;
					state = state ^ (1<focus(this);
					dirtyview();
					clearmsg(msg);
					return;
				}
			}
		}
	} else {
		if (msg->msg==msg_keypressed) {
			switch (msg->data1.integer) {
			case K_Left:
				sel -= size.h;
				if (sel < 0) sel=0;
				dirtyview();
				clearmsg(msg);
				return;
			case K_Right:
				sel += size.h;
				if (sel >= scount) sel = scount-1;
				dirtyview();
				clearmsg(msg);
				return;
			case K_Up:
				sel--;
				if (sel < 0) sel = 0;
				dirtyview();
				clearmsg(msg);
				return;
			case K_Down:
				sel++;
				if (sel >= scount) sel = scount-1;
				dirtyview();
				clearmsg(msg);
				return;
			case K_Space:
				state = state ^ (1<get_string(i);
		int slen=strlen(s);
		if (slen>maxcolstrlen) maxcolstrlen=slen;
		buf->print(vx, vy, c, "( )");
		if (i==sel) {
			buf->printChar(vx+1, vy, c, GC_FILLED_CIRCLE, CP_GRAPHICAL);
		}
		buf->print(vx+4, vy, c, s);
		i++;
		vy++;
		if (vy>=size.h) {
			vx+=maxcolstrlen+5;
			vy=0;
			maxcolstrlen=0;
		}
	}
}

void ht_radioboxes::getdata(ObjectStream &s)
{
	PUT_INT32D(s, sel);
}

void ht_radioboxes::handlemsg(htmsg *msg)
{
	if (msg->msg==msg_keypressed) {
		switch (msg->data1.integer) {
			case K_Left:
				sel-=size.h;
				if (sel<0) sel=0;
				dirtyview();
				clearmsg(msg);
				return;
			case K_Right:
				sel+=size.h;
				if (sel>=scount) sel=scount-1;
				dirtyview();
				clearmsg(msg);
				return;
			case K_Up:
				sel--;
				if (sel<0) sel=0;
				dirtyview();
				clearmsg(msg);
				return;
			case K_Down:
				sel++;
				if (sel>=scount) sel=scount-1;
				dirtyview();
				clearmsg(msg);
				return;
/*			case K_Space:
				state=state^(1<count();
}

void *ht_history_listbox::getFirst()
{
	if (history->count()) {
		return (void*)1;
	} else {
		return NULL;
	}
}

void *ht_history_listbox::getLast()
{
	if (history->count()) {
		return (void*)(history->count());
	} else {
		return NULL;
	}
}

void *ht_history_listbox::getNext(void *entry)
{
	unsigned long e=(unsigned long)entry;
	if (!e) return NULL;
	if (e < history->count()) {
		return (void*)(e+1);
	} else {
		return NULL;
	}
}

void *ht_history_listbox::getPrev(void *entry)
{
	unsigned long e=(unsigned long)entry;
	if (e > 1) {
		return (void*)(e-1);
	} else {
		return NULL;
	}
}

const char *ht_history_listbox::getStr(int col, void *entry)
{
	return ((ht_history_entry*)(*history)[(long)entry-1])->desc;
}

void ht_history_listbox::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
		case msg_keypressed:
			switch (msg->data1.integer) {
				case K_Delete: {
					int p = pos;
					cursorUp(1);
					history->del(history->findByIdx(p));
					update();
					if (p) cursorDown(1);
					dirtyview();
					clearmsg(msg);
					break;
				}
			}
		break;
	}
	ht_listbox::handlemsg(msg);
}

void *ht_history_listbox::quickfind(const char *s)
{
	void *item = getFirst();
	int slen = strlen(s);
	while (item && (ht_strncmp(getStr(0, item), s, slen)!=0)) {
		item = getNext(item);
	}
	return item;
}

char	*ht_history_listbox::quickfindCompletition(const char *s)
{
	void *item = getFirst();
	char *res = NULL;
	int slen = strlen(s);
	while (item) {
		if (ht_strncmp(getStr(0, item), s, slen)==0) {
			if (!res) {
				res = ht_strdup(getStr(0, item));
			} else {
				int a = ht_strccomm(res, getStr(0, item));
				res[a] = 0;
			}
		}
		item = getNext(item);
	}
	return res;
}


/*
 *	CLASS ht_history_popup_dialog
 */

void ht_history_popup_dialog::init(Bounds *b, List *hist)
{
	history = hist;
	ht_listpopup_dialog::init(b, "history");
}

void ht_history_popup_dialog::getdata(ObjectStream &s)
{
	// FIXME: public member needed:
	PUTX_INT32D(s, listbox->pos, NULL);
	if (history->count()) {
		PUTX_STRING(s, ((ht_history_entry*)(*history)[listbox->pos])->desc, NULL);
	} else {
		PUTX_STRING(s, NULL, NULL);
	}
}

void ht_history_popup_dialog::init_text_listbox(Bounds *b)
{
	listbox = new ht_history_listbox();
	((ht_history_listbox *)listbox)->init(b, history);
	insert(listbox);
}

void ht_history_popup_dialog::setdata(ObjectStream &s)
{
}

/*
 *	CLASS ht_inputfield
 */

void ht_inputfield::init(Bounds *b, int Maxtextlen, List *hist)
{
	ht_view::init(b, VO_SELECTABLE | VO_RESIZE, "some inputfield");
	VIEW_DEBUG_NAME("ht_inputfield");

	history = hist;
	maxtextlenv = Maxtextlen;
	growmode = MK_GM(GMH_FIT, GMV_TOP);
	
	textv = ht_malloc(maxtextlenv+1);
	curcharv = textv;
	textlenv = 0;
	selstartv = 0;
	selendv = 0;

	text = &textv;
	curchar = &curcharv;
	textlen = &textlenv;
	maxtextlen = &maxtextlenv;
	selstart = &selstartv;
	selend = &selendv;

	insert = 1;
	ofs = 0;
	attachedto = 0;
}

void ht_inputfield::done()
{
	freebuf();
	ht_view::done();
}

void ht_inputfield::attach(ht_inputfield *inputfield)
{
	freebuf();
	inputfield->query(&curchar, &text, &selstart, &selend, &textlen, &maxtextlen);
	attachedto=inputfield;
	ofs=0;
	insert=1;
}

int ht_inputfield::datasize()
{
	return sizeof (ht_inputfield_data);
}

const char *ht_inputfield::defaultpalette()
{
	return palkey_generic_dialog_default;
}

void ht_inputfield::freebuf()
{
	if (!attachedto && text) free(*text);
}

void ht_inputfield::getdata(ObjectStream &s)
{
	if (!attachedto) {
		PUTX_INT32D(s, *textlen, NULL);
		PUTX_BINARY(s, *text, *textlen, NULL);
	}
/*	FIXPORT uint h = s->recordStart(datasize());
	if (!attachedto) {
		s->putIntDec(*textlen, 4, NULL);
		s->putBinary(*text, *textlen, NULL);
	}
	s->recordEnd(h);*/
}

int ht_inputfield::insertbyte(byte *pos, byte b)
{
	if (*textlen<*maxtextlen) {
		if (*selstart) {
			if (pos<*selstart) {
				(*selstart)++;
				(*selend)++;
			} else if (pos<*selend) {
				(*selend)++;
			}
		}
		memmove(pos+1, pos, *textlen-(pos-*text));
		*pos=b;
		(*textlen)++;
		dirtyview();
		return 1;
	}
	return 0;
}

void ht_inputfield::isetcursor(uint pos)
{
	if (pos < (uint)*textlen) *curchar = *text + pos;
}

void ht_inputfield::query(byte ***c, byte ***t, byte ***ss, byte ***se, int **tl, int **mtl)
{
	*c=curchar;
	*t=text;
	*ss=selstart;
	*se=selend;
	*tl=textlen;
	*mtl=maxtextlen;
}

void ht_inputfield::select_add(byte *start, byte *end)
{
	if (end*selend) {
		byte *temp=*selstart;
		*selstart=*selend;
		*selend=temp;
	}
}

void ht_inputfield::setdata(ObjectStream &s)
{
//	FIXPORT uint h=s->recordStart(datasize());
	if (!attachedto) {
		textlen=&textlenv;
		GET_INT32D(s, *textlen);
		
		if (*textlen > *maxtextlen) *textlen = *maxtextlen;
		
		GET_BINARY(s, *text, *textlen);
		
		curchar = &curcharv;
		*curchar = *text + *textlen;
		
		if (*textlen) {
			*selstart = *text;
			*selend = *text+*textlen;
		} else {
			*selstart = 0;
			*selend = 0;
		}

		ofs = 0;
	}
	
//	s->recordEnd(h);
	dirtyview();
}

/*
 *	CLASS ht_strinputfield
 */

void ht_strinputfield::init(Bounds *b, int maxstrlen, List *history)
{
	ht_inputfield::init(b, maxstrlen, history);
	VIEW_DEBUG_NAME("ht_strinputfield");
	is_virgin = true;
	selectmode = false;
}

void ht_strinputfield::done()
{
	ht_inputfield::done();
}

void ht_strinputfield::correct_viewpoint()
{
	if (*curchar - *text < ofs) {
		ofs = *curchar-*text; 
	} else {
		if (*curchar - *text - (size.w-2)*size.h+1 > ofs) {
			ofs = *curchar-*text-(size.w-2)*size.h+1;
		}
	}
}

void ht_strinputfield::draw()
{
	int c=focused ? getcolor(palidx_generic_input_focused) :
		getcolor(palidx_generic_input_unfocused);
	byte *t = *text + ofs;
	int l = *textlen - ofs;
	if (l > size.w) l = size.w;
	int y = 0;
	fill(0, 0, size.w, size.h, c, ' ');
	if (ofs) buf->printChar(0, y, getcolor(palidx_generic_input_clip), '<');
	for (int k=0; k < *textlen-ofs; k++) {
		if (1+k-y*(size.w-2) > size.w-2) {
			if (y+1 < size.h) y++; else break;
		}
		if (t < *selstart || t >= *selend) {
			buf->printChar(1+k-y*(size.w-2), y, c, *(t++));
		} else {
			buf->printChar(1+k-y*(size.w-2), y, getcolor(palidx_generic_input_selected), *(t++));
		}
	}
	if (*textlen-ofs > (size.w-2)*size.h) {
		buf->printChar(size.w-1, y, getcolor(palidx_generic_input_clip), '>');
	}
	if (history && history->count()) {
		buf->printChar(size.w-1, y+size.h-1, getcolor(palidx_generic_input_clip), GC_SMALL_ARROW_DOWN, CP_GRAPHICAL);
	}
	if (focused) {
		int cx, cy;
		if (*curchar-*text-ofs >= (size.w-2)*size.h) {
			cx = size.w-1;
			cy = size.h-1;
		} else {
			cx = (*curchar - *text - ofs) % (size.w-2)+1;
			cy = (*curchar - *text - ofs) / (size.w-2);
		}
		setcursor(cx, cy, insert ? CURSOR_NORMAL : CURSOR_BOLD);
	}
}

void ht_strinputfield::handlemsg(htmsg *msg)
{
	if (msg->type == mt_empty && msg->msg == msg_keypressed) {
		int k = msg->data1.integer;
		switch (k) {
			case K_Meta_S:
				selectmode = !selectmode;
				clearmsg(msg);
				break;
			case K_Up:
				is_virgin = false;
				if (*curchar - *text - ofs < size.w - 2) {
					ofs -= size.w-2;
					if (ofs < 0) ofs=0;
				}
				*curchar -= size.w-2;
				if (*curchar < *text) *curchar = *text;
				correct_viewpoint();
				dirtyview();
				clearmsg(msg);
				return;
			case K_Down:
				is_virgin = false;
				if (*curchar + size.w - 2 - *text > *textlen) {
					history_dialog();
					clearmsg(msg);
					return;
				} else {
					*curchar += size.w-2;
					if (*curchar - *text > *textlen) {
						*curchar = *text + *textlen;
					}
					correct_viewpoint();
					dirtyview();
				}
				clearmsg(msg);
				return;
			case K_Shift_Left:
			case K_Left:
				is_virgin = false;
				if (*curchar>*text) {
					(*curchar)--;
					if ((k==K_Shift_Left) != selectmode) {
						select_add(*curchar, *curchar+1);
					}
				}				    
				correct_viewpoint();
				dirtyview();
				clearmsg(msg);
				return;
			case K_Shift_Right:				
			case K_Right:
				is_virgin = false;
				if (*curchar-*text<*textlen) {
					(*curchar)++;
					if ((k==K_Shift_Right) != selectmode) {
						select_add(*curchar-1, *curchar);
					}
				}					
				correct_viewpoint();
				dirtyview();
				clearmsg(msg);
				return;
			case K_Backspace:
				if (is_virgin) {
					is_virgin = false;
					*selstart = 0;
					*selend = 0;
					*textlen = 0;
					*curchar = *text;
					dirtyview();
					clearmsg(msg);
				} else if (*curchar > *text) {
					*selstart = 0;
					*selend = 0;
					memmove(*curchar-1, *curchar, *textlen-(*curchar-*text));
					(*textlen)--;
					(*curchar)--;
					is_virgin=0;
					correct_viewpoint();
					dirtyview();
					clearmsg(msg);
					return;
				}
				break;
			case K_Delete:
				if (is_virgin) {
					is_virgin = false;
					*selstart = 0;
					*selend = 0;
					*textlen = 0;
					*curchar = *text;
					dirtyview();
					clearmsg(msg);
				} else if (*curchar-*text < *textlen && *textlen) {
					if (*selstart) {
						if (*curchar >= *selstart) {
							if (*curchar < *selend) (*selend)--;
							if (*selstart == *selend) {
								*selstart=0;
								*selend=0;
							}
						} else {
							(*selstart)--;
							(*selend)--;
						}
					}
					memmove(*curchar, *curchar+1, *textlen-(*curchar-*text)-1);
					(*textlen)--;
					dirtyview();
					clearmsg(msg);
					return;
				}
				break;
			case K_Shift_Home:
			case K_Home:
				is_virgin = false;
				if ((k == K_Shift_Home) != selectmode) {
					select_add(*curchar, *text);
				}					
				*curchar = *text;
				correct_viewpoint();
				dirtyview();
				clearmsg(msg);
				return;
			case K_Shift_End:
			case K_End:
				is_virgin = false;
				if ((k == K_Shift_End) != selectmode) {
					select_add(*curchar, *text+*textlen);
				}						
				*curchar = *text + *textlen;
				correct_viewpoint();
				dirtyview();
				clearmsg(msg);
				return;
			case K_Insert:
				insert=!insert;
				dirtyview();
				clearmsg(msg);
				return;
			case K_Meta_X:
			case K_Shift_Delete:
				if (*selend > *selstart) clipboard_copy("inputfield", *selstart, *selend-*selstart);
			case K_Meta_D:
			case K_Control_Delete:
				if (*selend > *selstart) {
					memmove(*selstart, *selend, *textlen-(*selend-*text));
					*textlen -= *selend - *selstart;
					*curchar = *selstart;
					*selstart = 0;
					*selend = 0;
					is_virgin = false;
					correct_viewpoint();
				}
				dirtyview();
				clearmsg(msg);
				return;
			case K_Meta_C:
			case K_Control_Insert:
				if (*selend > *selstart) clipboard_copy("inputfield", *selstart, *selend-*selstart);
				is_virgin = false;
				dirtyview();
				clearmsg(msg);
				return;
			case K_Meta_V:
			case K_Shift_Insert: {
				int maxsize = MIN(*maxtextlen-*textlen, (int)clipboard_getsize());
				byte *buf = ht_malloc(maxsize);
				int r = clipboard_paste(buf, maxsize);
				if (r) {
					for (int i=0; i < r; i++) {
						setbyte(buf[r-i-1]);
					}
					*selstart=*curchar;
					*selend=*curchar+r;
				}
				delete buf;
				is_virgin = false;
				dirtyview();
				clearmsg(msg);
				return;
			}
			default:
				if (msg->data1.integer >= ' ' && msg->data1.integer < 256) {
					if (is_virgin) {
						is_virgin = false;
						*selstart = 0;
						*selend = 0;
						*textlen = 0;
						*curchar = *text;
						ofs = 0;
					}
					inputbyte(msg->data1.integer);
					dirtyview();
					clearmsg(msg);
					return;
				}
		}
	}
	ht_inputfield::handlemsg(msg);
}

void ht_strinputfield::history_dialog()
{
	if (history && history->count()) {
		Bounds b;
		getbounds(&b);
		b.y--;
		b.h=8;
		ht_history_popup_dialog *l=new ht_history_popup_dialog();
		l->init(&b, history);
		if (l->run(false)) {
			ht_listpopup_dialog_data d;
			ViewDataBuf vdb(l, &d, sizeof d);

			if (d.cursor_string) {
				ht_history_entry *v=(ht_history_entry*)(*history)[d.cursor_pos];
				if (v->data && group) {
					v->datafile->seek(0);
					group->setdata(*v->data);
				} else {
					ht_inputfield_data e;
					e.textlen = strlen(d.cursor_string);
					e.text = (byte*)d.cursor_string;
					databuf_set(&e, sizeof e);
				}
			}
			is_virgin = false;
		}
		l->done();
		delete l;
	}
}

void ht_strinputfield::receivefocus()
{
	correct_viewpoint();
	ht_inputfield::receivefocus();
}

bool ht_strinputfield::inputbyte(byte a)
{
	if (setbyte(a)) {
		(*curchar)++;
		correct_viewpoint();
		is_virgin = false;
		return true;
	}
	return false;
}

bool ht_strinputfield::setbyte(byte a)
{
	if (insert || *curchar-*text >= *textlen) {
		if (insertbyte(*curchar, a) && *curchar-*text<*textlen) return true;
	} else {
		**curchar=a;
		return true;
	}
	return false;
}

/*
 *	CLASS ht_hexinputfield
 */

void ht_hexinputfield::init(Bounds *b, int maxstrlen)
{
	ht_inputfield::init(b, maxstrlen);
	VIEW_DEBUG_NAME("ht_strinputfield");
	nib=0;
	insert=1;
}

void ht_hexinputfield::done()
{
	ht_inputfield::done();
}

void ht_hexinputfield::correct_viewpoint()
{
	if (*curchar-*textofs*3) {
		ofs = ((*curchar-*text)*3-(size.w-2)*size.h+5) / 3;
	}
}

void ht_hexinputfield::draw()
{
	int c=focused ? getcolor(palidx_generic_input_focused) :
		getcolor(palidx_generic_input_unfocused);
	char hbuf[256], *h=hbuf;
	int y=0;
	fill(0, 0, size.w, size.h, c, ' ');
	if (ofs) buf->print(0, y, getcolor(palidx_generic_input_clip), "<");
	int vv=*textlen-ofs;
	if (vv<0) vv=0; else if (vv>(size.w-2)*size.h/3) vv=(size.w-2)*size.h/3+1;
	for (int k=0; knprint(1, y, c, h, size.w-2);
			y++;
		}
		y--;
	}
	if ((*textlen-ofs)*3 > (size.w-2)*size.h) {
		buf->print(size.w-1, y, getcolor(palidx_generic_input_clip), ">");
	}
	if (focused) {
		int cx, cy;
		if ((*curchar-*text-ofs)*3+nib+1 >= (size.w-2)*size.h) {
			cx = size.w-1;
			cy = size.h-1;
		} else {
			cx = ((*curchar-*text-ofs)*3+nib+1) % (size.w-2);
			cy = ((*curchar-*text-ofs)*3+nib+1) / (size.w-2);
		}
		setcursor(cx, cy, insert ? CURSOR_NORMAL : CURSOR_BOLD);
	}
}

void ht_hexinputfield::handlemsg(htmsg *msg)
{
	if (msg->msg==msg_keypressed) {
		switch (msg->data1.integer) {
			case K_Up:
				if (*curchar-*text-ofs<(size.w-2)/3) {
					ofs-=(size.w-2)/3;
					if (ofs<0) ofs=0;
				}
				*curchar-=(size.w-2)/3;
				if (*curchar<*text) *curchar=*text;
				correct_viewpoint();
				dirtyview();
				clearmsg(msg);
				return;
			case K_Down:
/*				if (*curchar-*text-ofs>=(size.w-2)*(size.h-1)/3) {
					ofs+=(size.w-2)/3;
				}*/
				*curchar+=(size.w-2)/3;
				if (*curchar-*text>*textlen) *curchar=*text+*textlen;
				if (*curchar-*text>=*textlen) nib=0;
				correct_viewpoint();
				dirtyview();
				clearmsg(msg);
				return;
			case K_Left:
				if (nib) {
					nib=0;
				} else if (*curchar>*text) {
					(*curchar)--;
					nib=1;
				}
				correct_viewpoint();
				dirtyview();
				clearmsg(msg);
				return;
			case K_Right:
				if (!nib) {
					if (*curchar-*text<*textlen) nib=1;
				} else if (*curchar-*text<*textlen) {
					(*curchar)++;
					nib=0;
				}
				correct_viewpoint();
				dirtyview();
				clearmsg(msg);
				return;
			case K_Backspace:
				if (*textlen) {
					if (*curchar+nib>*text) {
/*						if (*curchar-*text<*textlen) {
							memmove(*curchar, *curchar+1, *textlen-(*curchar-*text)-1);
						}
					} else {*/
						memmove(*curchar-1+nib, *curchar+nib, *textlen-(*curchar-*text));
						(*textlen)--;
						if (*curchar-*text && !nib) (*curchar)--;
						nib=0;
						correct_viewpoint();
						dirtyview();
					}
					clearmsg(msg);
					return;
				}
				break;
			case K_Delete:
				if ((*curchar-*text<*textlen) && (*textlen)) {
					memmove(*curchar, *curchar+1, *textlen-(*curchar-*text)-1);
					(*textlen)--;
					nib=0;
					dirtyview();
					clearmsg(msg);
					return;
				}
				break;
			case K_Home:
				*curchar=*text;
				nib=0;
				correct_viewpoint();
				dirtyview();
				clearmsg(msg);
				return;
			case K_End:
				*curchar=*text+*textlen;
				nib=0;
				correct_viewpoint();
				dirtyview();
				clearmsg(msg);
				return;
			case K_Insert:
				insert=!insert;
				dirtyview();
				clearmsg(msg);
				return;
			default:
				if ((msg->data1.integer>='0') && (msg->data1.integer<='9')) {
					setnibble(msg->data1.integer-'0');
					dirtyview();
					clearmsg(msg);
				} else if ((msg->data1.integer>='a') && (msg->data1.integer<='f')) {
					setnibble(msg->data1.integer-'a'+10);
					dirtyview();
					clearmsg(msg);
				}
				return;
		}
	}
	ht_inputfield::handlemsg(msg);
}

void ht_hexinputfield::receivefocus()
{
	correct_viewpoint();
	if (nib && *curchar-*text == *textlen) {
		nib=0;
	}
	ht_inputfield::receivefocus();
}

void ht_hexinputfield::setnibble(byte a)
{
	if ((insert || *curchar-*text >= *textlen) && nib == 0) {
		if ((insertbyte(*curchar, a<<4)) && (*curchar-*text<*textlen)) nib=1;
	} else {
		if (nib) {
			**curchar=(**curchar & 0xf0) | a;
			(*curchar)++;
			nib=0;
		} else {
			**curchar=(**curchar & 0xf) | (a<<4);
			nib=1;
		}
	}
	correct_viewpoint();
}

/*
 *	CLASS ht_button
 */

void ht_button::init(Bounds *b, const char *Text, int Value)
{
	ht_view::init(b, VO_SELECTABLE | VO_OWNBUFFER | VO_POSTPROCESS, "some button");
	VIEW_DEBUG_NAME("ht_button");
	value = Value;
	text = ht_strdup(Text);
	pressed = 0;
	magicchar = strchr(text, '~');
	if (magicchar) {
		int l = strlen(text);
		memmove(magicchar, magicchar+1, l-(magicchar-text));
		shortcut1 = keyb_metakey((ht_key)tolower(*magicchar));
		shortcut2 = (ht_key)tolower(*magicchar);
	} else {
		shortcut1 = K_INVALID;
		shortcut2 = K_INVALID;
	}
}

void ht_button::done()
{
	free(text);
	ht_view::done();
}

void ht_button::getminbounds(int *width, int *height)
{
	*width = 6;
	*height = 2;
}

const char *ht_button::defaultpalette()
{
	return palkey_generic_dialog_default;
}

void ht_button::draw()
{
	int c=focused ? getcolor(palidx_generic_button_focused) :
		getcolor(palidx_generic_button_unfocused);
	fill(0, 0, size.w-1, size.h-1, c, ' ');
	int xp = (size.w - strlen(text))/2, yp = (size.h-1)/2;
	buf->print(xp, yp, c, text);
	if (magicchar) buf->printChar(xp+(magicchar-text), yp, getcolor(palidx_generic_button_shortcut), *magicchar);
	/* shadow */
	buf->printChar(0, 1, getcolor(palidx_generic_button_shadow), ' ');
	for (int i=1; iprintChar(i, 1, getcolor(palidx_generic_button_shadow), GC_FILLED_UPPER, CP_GRAPHICAL);
	}
	buf->printChar(size.w-1, 0, getcolor(palidx_generic_button_shadow), GC_FILLED_LOWER, CP_GRAPHICAL);
	buf->printChar(size.w-1, 1, getcolor(palidx_generic_button_shadow), GC_FILLED_UPPER, CP_GRAPHICAL);
}

void ht_button::handlemsg(htmsg *msg)
{
	if (msg->type == mt_postprocess) {
		if (msg->msg == msg_keypressed) {
			if ((shortcut1 != K_INVALID && msg->data1.integer==shortcut1) ||
			(shortcut2 != K_INVALID && msg->data1.integer==shortcut2)) {
				push();
				dirtyview();
				clearmsg(msg);
				return;
			}
		}
	} else if (msg->type == mt_empty) {
		if (msg->msg == msg_keypressed) {
			switch (msg->data1.integer) {
			case K_Return:
			case K_Space:
				push();
				dirtyview();
				clearmsg(msg);
				return;
			}
		}
	}
	ht_view::handlemsg(msg);
}

void ht_button::push()
{
	/* FIXME: wont work for encapsulated buttons... */
	/* FIXME: (thats why I hacked this now...) */
	app->sendmsg(msg_button_pressed, value);
//	baseview->sendmsg(msg_button_pressed, value);	// why not like this ?
	pressed=1;
}

/*
 *	CLASS ht_listbox_title
 */
void	ht_listbox_title::init(Bounds *b)
{
	ht_view::init(b, VO_RESIZE, "ht_listbox_title");
	growmode = MK_GM(GMH_FIT, GMV_TOP);
	texts = NULL;
	listbox = NULL;
	cols = 0;
}

void	ht_listbox_title::done()
{
	if (texts) {
		for (int i=0; i < cols; i++) {
			free(texts[i]);
		}
		free(texts);
	}
	ht_view::done();
}

const char *ht_listbox_title::defaultpalette()
{
	return palkey_generic_dialog_default;
}

void ht_listbox_title::draw()
{
	vcp color = getTextColor();
	clear(color);
	if (!texts || !listbox) return;
	int x = 0;
	for (int i=0; i < cols; i++) {     
		buf->nprint(x, 0, color, texts[i], size.w - x);
		x += listbox->widths[i];
		if (i+1 < cols) {
			if (x >= size.w) break;
			buf->printChar(x++, 0, color, ' ');
			if (x >= size.w) break;
			buf->printChar(x++, 0, color, GC_1VLINE, CP_GRAPHICAL);
			if (x >= size.w) break;
			buf->printChar(x++, 0, color, ' ');
		}
	}
}

vcp ht_listbox_title::getTextColor()
{
	return getcolor(palidx_generic_body);
}

void ht_listbox_title::setText(int cols, ...)
{
	va_list vargs;
	va_start(vargs, cols);
	setTextv(cols, vargs);
	va_end(vargs);
}

void ht_listbox_title::setTextv(int c, va_list vargs)
{
	if (texts) {
		for (int i=0; iwidths) {
		for (int i=0; i listbox->widths[i]) listbox->widths[i] = s;
		}
	}
}


/*
 *	CLASS ht_listbox
 */

class ht_listbox_vstate: public Object {
public:
	void *e_top;
	void *e_cursor;

	ht_listbox_vstate(void *top, void *cursor)
	{
		e_top = top;
		e_cursor = cursor;
	}
};

void ht_listbox::init(Bounds *b, uint Listboxcaps)
{
	ht_view::init(b, VO_SELECTABLE | VO_OWNBUFFER | VO_RESIZE, 0);
	cached_count = 0;

	growmode = MK_GM(GMH_FIT, GMV_FIT);

	Bounds c = *b;
	c.x = c.w-1;
	c.y = 0;
	c.w = 1;
	scrollbar = new ht_scrollbar();
	scrollbar->init(&c, &pal, true);

	pos = 0;
	cursor = 0;
	e_top = getFirst();
	e_cursor = e_top;
	title = NULL;
	visible_height = 0;
	x = 0;
	widths = NULL;
	clearQuickfind();
	update();
	listboxcaps = Listboxcaps;
	cols = 0;
}

void	ht_listbox::done()
{
	scrollbar->done();
	delete scrollbar;
	free(widths);
	ht_view::done();
}

void ht_listbox::adjustPosHack()
{
	if (e_cursor != e_top) return;
	int i=0;
	void *tmp = e_cursor;
	if (!tmp) return;
	while (tmp && i <= visible_height) {
		tmp = getNext(tmp);
		i++;
	}
	if (i < visible_height) {
		cursorDown(cursorUp(visible_height - pos - i));
	}
}

void ht_listbox::adjustScrollbar()
{
	int pstart, psize;
	if (scrollbar_pos(pos-cursor, size.h, cached_count, &pstart, &psize)) {
		mScrollbarEnabled = true;
		scrollbar->enable();
		Bounds c = size;
		c.x = c.w-1;
		c.y = 0;
		c.w = 1;
		scrollbar->setbounds(&c);
		scrollbar->setpos(pstart, psize);
	} else {
		mScrollbarEnabled = false;
		scrollbar->disable();
	}
}

void ht_listbox::attachTitle(ht_listbox_title *aTitle)
{
	if (numColumns() > cols) rearrangeColumns();
	title = aTitle;
	title->listbox = this;
	title->update();
	title->dirtyview();
}

void ht_listbox::clearQuickfind()
{
	quickfinder[0] = 0;
	qpos = quickfinder;
	updateCursor();
}

int  ht_listbox::cursorAdjust()
{
	return 0;
}

int  ht_listbox::cursorUp(int n)
{
	void *tmp;
	int  i = 0;

	while (n--) {
		tmp = getPrev(e_cursor);
		if (!tmp) break;
		if (e_cursor == e_top) {
			e_top = tmp;
		} else {
			cursor--;
		}
		e_cursor = tmp;
		pos--;
		if (pos < 0) pos = 0; // if cursor was out of sync
		i++;
	}
	return i;
}

int  ht_listbox::cursorDown(int n)
{
	void *tmp;
	int  i = 0;

	while (n--) {
		tmp = getNext(e_cursor);
		if (!tmp) break;
		if (cursor+1 >= visible_height) {
			e_top = getNext(e_top);
		} else {
			cursor++;
		}
		pos++;
		e_cursor = tmp;
		i++;
	}
	return i;
}

int  ht_listbox::datasize()
{
	return sizeof (ht_listbox_data);
}

const char *ht_listbox::defaultpalette()
{
	return palkey_generic_dialog_default;
}

void ht_listbox::draw()
{
	int fc = focused ? getcolor(palidx_generic_list_focused_unselected) :
		getcolor(palidx_generic_list_unfocused_unselected);

	int Cols = numColumns();
	if (Cols > cols) rearrangeColumns();

	bool title_redraw = false;
	bool resizing_cols;

	do {
		resizing_cols = false;
		clear(fc);
		void *entry = e_top;
		int i = 0;
		while (entry && i < visible_height) {
			int c = (i==cursor) ? (focused ? getcolor(palidx_generic_list_focused_selected) :
				getcolor(palidx_generic_list_unfocused_selected)) : fc;
			if (i == cursor) {
				fill(0, i, size.w, 1, c, ' ');
			}
			int X = -x;
			for (int j=0; j < cols; j++) {
				const char *s = getStr(j, entry);
				int slen = strlen(s);
				if (slen > widths[j]) {
					widths[j] = slen;
					/*
					 *	a column has been resized,
					 *	therefore we have to redraw a second time.
					 */
					resizing_cols = true;
					title_redraw = true;
				}
				if (s) {
					if (X >= 0) {
						buf->nprint(X, i, c, s, size.w);
					} else {
						if (slen > -X) buf->nprint(0, i, c, &s[-X], size.w);
					}
				}
				if (j==cols-1) {
					X += slen;
				} else {
					X += widths[j];
				}
				if (j+1 < cols) {
					buf->printChar(X++, i, c, ' ');
					buf->printChar(X++, i, c, GC_1VLINE, CP_GRAPHICAL);
					buf->printChar(X++, i, c, ' ');
				}
			}
			if (x > 0) {
				// more text on the left
				buf->printChar(0, i, c, '<');
			}
			// position of '>' char is scrollbar dependent
			int a = mScrollbarEnabled ? 0 : 1;
			if (X >= size.w+a) {
				// more text right
				buf->printChar(size.w-2+a, i, c, '>');
			}
			entry = getNext(entry);
			i++;
		}
	} while (resizing_cols);
	updateCursor();
	if (title_redraw && title) {
		title->update();
		title->dirtyview();
	}
/*     char dbg[100];
	sprintf(dbg, "cursor=%d pos=%d vh=%d qc:%s", cursor, pos, visible_height, quickfinder);
	lprint(0, 0, 1, size.w, dbg);
	sprintf(dbg, "e_top=%s", getstr(0, e_top));
	lprint(0, 1, 1, size.w, dbg);
	sprintf(dbg, "e_cursor=%s", getstr(0, e_cursor));
	lprint(0, 2, 1, size.w, dbg);*/
}

int  ht_listbox::estimateEntryPos(void *entry)
{
	// this is slow!
	void *tmp = getFirst();
	int res = 0;
	while (tmp) {
		if (tmp == entry) break;
		tmp = getNext(tmp);
		res++;
	}
	return (tmp==entry) ? res : -1;
}

void ht_listbox::getdata(ObjectStream &s)
{
	ht_listbox_data_internal d;
	d.top_ptr = e_top;
	d.cursor_ptr = e_cursor;
	PUTX_BINARY(s, &d, sizeof d, NULL);
}

void ht_listbox::gotoItemByEntry(void *entry, bool clear_quickfind)
{
	if (clear_quickfind) clearQuickfind();
	if (!entry) return;
	void *tmp = e_top;
	int i=0;
	bool ok=false;
	pos -= cursor;
	if (pos<0) pos = 0; // if cursor was out of sync
	cursor = 0;

	while (tmp && i < visible_height) {
		if (tmp == entry) {
			ok = true;
			break;
		}
		pos++;
		cursor++;
		i++;
		tmp = getNext(tmp);
	}
	e_cursor = entry;
	if (!ok) {
		e_top = entry;
		cursor = 0;
		pos = estimateEntryPos(entry);
		assert(pos != -1);
	}
	adjustPosHack();
	stateChanged();
}

void ht_listbox::gotoItemByPosition(uint pos)
{
	void *entry = getFirst();
	while (pos--) entry = getNext(entry);
	gotoItemByEntry(entry, true);
}

void ht_listbox::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
		case msg_vstate_restore: {
			ht_listbox_vstate *vs = (ht_listbox_vstate*)msg->data1.ptr;
			e_top = vs->e_top;
			e_cursor = vs->e_cursor;
			update();
			// FIXME: what about deleting entries?
			clearmsg(msg);
			return;
		}
		case msg_keypressed: switch (msg->data1.integer) {
			case K_Control_PageUp:
			case K_Home:
				clearQuickfind();
				pos = cursor = 0;
				e_top = e_cursor = getFirst();
				dirtyview();
				clearmsg(msg);
				stateChanged();
				return;
			case K_Control_PageDown:
			case K_End: {
				clearQuickfind();
				cursor = 0;
				pos = cached_count ? cached_count-1 : 0;
				e_cursor = e_top = getLast();
				cursorUp(visible_height-1);
				cursorDown(visible_height-1);
				dirtyview();
				clearmsg(msg);
				stateChanged();
				return;
			}
			case K_PageUp:
				clearQuickfind();
				cursorUp(visible_height-1);
				dirtyview();
				clearmsg(msg);
				stateChanged();
				return;
			case K_PageDown: {
				clearQuickfind();
				cursorDown(visible_height-1);
				dirtyview();
				clearmsg(msg);
				stateChanged();
				return;
			}
			case K_Up:
				clearQuickfind();
				cursorUp(1);
				dirtyview();
				clearmsg(msg);
				stateChanged();
				return;
			case K_Down:
				clearQuickfind();
				cursorDown(1);
				dirtyview();
				clearmsg(msg);
				stateChanged();
				return;
			case K_Left:
			case K_Control_Left:
				if (x > 0) x--;
				updateCursor();
				dirtyview();
				clearmsg(msg);
				stateChanged();
				return;
			case K_Right:
			case K_Control_Right:
				x++;
				updateCursor();
				dirtyview();
				clearmsg(msg);
				stateChanged();
				return;
			case K_Tab:
				if (listboxcaps & LISTBOX_QUICKFIND) {
					if (*quickfinder) {
						char *qc = quickfindCompletition(quickfinder);
						if (qc) {
							strcpy(quickfinder, qc);
							qpos = ht_strend(quickfinder);
							free(qc);
							goto qf;
						}
					}
				}
				break;
			case K_Backspace: {
				if (listboxcaps & LISTBOX_QUICKFIND) {
					if (qpos > quickfinder) {
						*(--qpos) = 0;
						qf:
						void *a = quickfind(quickfinder);
						if (a) {
							gotoItemByEntry(a, false);
							updateCursor();
							dirtyview();
						}
						clearmsg(msg);
						stateChanged();
					}
				}
				return;
			}
			default: {
				if ((listboxcaps & LISTBOX_QUICKFIND) && msg->data1.integer > 31 && msg->data1.integer < 0xff) {
					*qpos++ = msg->data1.integer;
					*qpos = 0;
					void *a = quickfind(quickfinder);
					if (a) {
						gotoItemByEntry(a, false);
						updateCursor();
						dirtyview();
						clearmsg(msg);
						stateChanged();
					} else {
						*(--qpos) = 0;
					}
				}
			}
		}
		break;
	}
	ht_view::handlemsg(msg);
}

int	ht_listbox::numColumns()
{
	return 1;
}

char	*ht_listbox::quickfindCompletition(const char *s)
{
	return ht_strdup(s);
}

void ht_listbox::rearrangeColumns()
{
	free(widths);
	cols = numColumns();
	widths = (int*)calloc(cols*sizeof(int), 1);
}

void ht_listbox::redraw()
{
	ht_view::redraw();
	scrollbar->relocate_to(this);
//	fprintf(stderr, "scrollbar: x=%d, y=%d, w=%d, h=%d\n", scrollbar->vsize.x, scrollbar->vsize.y, scrollbar->vsize.w, scrollbar->vsize.h);
	scrollbar->redraw();
	if (title) {
		title->redraw();
	}
	scrollbar->unrelocate_to(this);
}

void ht_listbox::resize(int rw, int rh)
{
	ht_view::resize(rw, rh);
	update();
}

void ht_listbox::stateChanged()
{
	adjustScrollbar();
}

bool ht_listbox::selectEntry(void *entry)
{
	return true;
}

void ht_listbox::setdata(ObjectStream &s)
{
	ht_listbox_data_internal d;
	GET_BINARY(s, &d, sizeof d);
	e_top = d.top_ptr;
	e_cursor = d.cursor_ptr;
	update();
}

Object *ht_listbox::vstate_create()
{
	return new ht_listbox_vstate(e_top, e_cursor);
}

void ht_listbox::vstate_save()
{
	Object *vs = vstate_create();
	if (vs) {
		htmsg m;
		m.msg = msg_vstate_save;
		m.type = mt_empty;
		m.data1.ptr = vs;
		m.data2.ptr = this;
		app->sendmsg(&m);
	}
}

/*
 *	must be called if data has changed
 */
void ht_listbox::update()
{
	void *entry = getFirst();
	cached_count = calcCount();
	visible_height = MIN(size.h, cached_count);
	if (cached_count <= size.h) {
		if (!e_cursor) e_cursor = getFirst();
		cursor = 0;
		while (entry && cursor < visible_height) {
			if (entry == e_cursor) {
				e_top = getFirst();
				goto ok;
			}
			entry = getNext(entry);
			cursor++;
		}
	}
	if (!e_top) {
		e_top = getFirst();
	}     
	if (!e_cursor) e_cursor = e_top;
	entry = e_top;
	cursor = 0;
	while (entry && cursor < visible_height) {
		if (entry == e_cursor) goto ok;
		entry = getNext(entry);
		cursor++;
	}
	cursor = 0;
	e_top = e_cursor;
ok:
	adjustPosHack();
	stateChanged();
	if (title) {
		title->update();
		title->dirtyview();
	}
	dirtyview();
}

void ht_listbox::updateCursor()
{
	if (focused) {
		if (*quickfinder) {
			setcursor((qpos-quickfinder)+cursorAdjust()-x, cursor);
		} else {
			hidecursor();
		}
	}		
}

/*
 *	ht_text_listbox
 */

void	ht_text_listbox::init(Bounds *b, int aCols, int aKeycol, uint aListboxcaps)
{
	first = last = NULL;
	count = 0;
	ht_listbox::init(b, aListboxcaps);
	cols = aCols;
	keycol = aKeycol;
	Cursor_adjust = 0;
	rearrangeColumns();
}

void ht_text_listbox::done()
{
	clearAll();
	ht_listbox::done();
}

void ht_text_listbox::clearAll()
{
	ht_text_listbox_item *temp = first;
	while (temp) {
		ht_text_listbox_item *temp2 = temp->next;
		freeExtraData(temp->extra_data);
		for (int i=0; i < cols; i++) {
			free(temp->data[i]);
		}
		free(temp);
		temp = temp2;
	}
	first = last = NULL;
	
	pos = 0;
	cursor = 0;
	e_top = getFirst();
	e_cursor = e_top;
	x = 0;
	clearQuickfind();

	count = 0;
	Cursor_adjust = 0;
}

int	ht_text_listbox::calcCount()
{
	return count;
}

int	ht_text_listbox::compare_strn(const char *s1, const char *s2, int l)
{
	return ht_strncmp(s1, s2, l);
}

int	ht_text_listbox::compare_ccomm(const char *s1, const char *s2)
{
	return ht_strccomm(s1, s2);
}

int  ht_text_listbox::cursorAdjust()
{
	return Cursor_adjust;
}

void ht_text_listbox::freeExtraData(void *extra_data)
{
}

void *ht_text_listbox::getFirst()
{
	return first;
}

uint ht_text_listbox::getID(void *entry)
{
	if (entry) {
		return ((ht_text_listbox_item *)entry)->id;
	} else {
		return 0;
	}	    
}

void *ht_text_listbox::getExtra(void *entry)
{
	if (entry) {
		return ((ht_text_listbox_item *)entry)->extra_data;
	} else {
		return NULL;
	}	    
}

void *ht_text_listbox::getLast()
{
	return last;
}

void *ht_text_listbox::getNext(void *entry)
{
	if (!entry) return NULL;
	return ((ht_text_listbox_item *)entry)->next;
}

void *ht_text_listbox::getPrev(void *entry)
{
	if (!entry) return NULL;
	return ((ht_text_listbox_item *)entry)->prev;
}

const char *ht_text_listbox::getStr(int col, void *entry)
{
	if (entry && col < cols) {
		return ((ht_text_listbox_item *)entry)->data[col];
	} else {
		return "";
	}
}

void ht_text_listbox::insert_str_extra(int id, void *extra_data, const char **strs)
{
	// FIXME: code duplication...
	ht_text_listbox_item *item = ht_malloc(sizeof(ht_text_listbox_item)+sizeof(char *)*cols);
	item->next = NULL;
	item->prev = last;
	item->id = id;
	item->extra_data = extra_data;
	for (int i=0; i widths[i]) {
			widths[i] = slen;
		}

		item->data[i] = ht_strdup(strs[i]);
	}
	if (first) {
		last->next = item;
	} else {
		first = item;
	}
	last = item;
	count++;
}

void	ht_text_listbox::insert_str_extra(int id, void *extra_data, const char *str, ...)
{
	ht_text_listbox_item *item = ht_malloc(sizeof(ht_text_listbox_item)+sizeof(char *)*cols);
	item->next = NULL;
	item->prev = last;
	item->id = id;
	item->extra_data = extra_data;
	va_list str2;
	va_start(str2, str);
	const char *str3 = str;
	for (int i=0; i widths[i]) {
			widths[i] = slen;
		}

		item->data[i] = ht_strdup(str3);
		str3 = va_arg(str2, char *);
	}
	va_end(str2);
	if (first) {
		last->next = item;
	} else {
		first = item;
	}
	last = item;
	count++;
}

void	ht_text_listbox::insert_str(int id, const char **strs)
{
	insert_str_extra(id, NULL, strs);
}

void ht_text_listbox::insert_str(int id, const char *str, ...)
{
	// FIXME: same as insert_str(id, NULL, str, ...)
	ht_text_listbox_item *item = ht_malloc(sizeof(ht_text_listbox_item)+sizeof(char *)*cols);
	item->next = NULL;
	item->prev = last;
	item->id = id;
	item->extra_data = NULL;
	va_list str2;
	va_start(str2, str);
	const char *str3 = str;
	for (int i=0; i widths[i]) {
			widths[i] = slen;
		}

		item->data[i] = ht_strdup(str3);
		str3 = va_arg(str2, char *);
	}
	va_end(str2);
	if (first) {
		last->next = item;
	} else {
		first = item;
	}
	last = item;
	count++;
}

int ht_text_listbox::numColumns()
{
	return cols;
}

void *ht_text_listbox::quickfind(const char *s)
{
	ht_text_listbox_item *item = first;
	int slen = strlen(s);
	while (item && (compare_strn(item->data[keycol], s, slen)!=0)) {
		item = item->next;
	}
	return item;
}

char *ht_text_listbox::quickfindCompletition(const char *s)
{
	ht_text_listbox_item *item = first;
	char *res = NULL;
	int slen = strlen(s);
	while (item) {
		if (compare_strn(item->data[keycol], s, slen)==0) {
			if (!res) {
				res = ht_strdup(item->data[keycol]);
			} else {
				int a = compare_ccomm(item->data[keycol], res);
				res[a] = 0;
			}
		}
		item = item->next;
	}
	return res;
}

static int ht_text_listboxcomparatio(ht_text_listbox_item *a, ht_text_listbox_item *b, int count, ht_text_listbox_sort_order *so)
{
	for (int i=0;idata[so[i].col], b->data[so[i].col]);
		if (r!=0) return r;
	}
	return 0;
}

static void ht_text_listboxqsort(int l, int r, int count, ht_text_listbox_sort_order *so, ht_text_listbox_item **list)
{
	int m = (l+r)/2;
	int L = l;
	int R = r;
	ht_text_listbox_item *c = list[m];
	do {
		while (l <= r && ht_text_listboxcomparatio(list[l], c, count, so) < 0) l++;
		while (l <= r && ht_text_listboxcomparatio(list[r], c, count, so) > 0) r--;
		if (l<=r) {
			ht_text_listbox_item *t = list[l];
			list[l] = list[r];
			list[r] = t;
			l++;
			r--;
		}
	} while(l < r);
	if (L < r) ht_text_listboxqsort(L, r, count, so, list);
	if (l < R) ht_text_listboxqsort(l, R, count, so, list);
}

void ht_text_listbox::sort(int count, ht_text_listbox_sort_order *so)
{
	ht_text_listbox_item **list;
	ht_text_listbox_item *tmp;
	int i=0;
	int cnt = calcCount();

	if (cnt < 2) return;
	
	list = ht_malloc(cnt*sizeof(void *));
	tmp = first;
	while (tmp) {
		list[i++] = tmp;
		tmp = (ht_text_listbox_item *)getNext(tmp);
	}

	int c_id = ((ht_text_listbox_item*)e_cursor)->id;

	ht_text_listboxqsort(0, cnt-1, count, so, list);

	for (i=0; iid == c_id) {
			pos = i;
			e_cursor = list[i];
		}
	}

	first = list[0];
	last = list[cnt-1];
	first->prev = NULL;
	last->next = NULL;
	last->prev = list[cnt-2];
	tmp = first->next = list[1];
	for (i=1; iprev = list[i-1];
		tmp->next = list[i+1];
		tmp = list[i+1];
	}
	free(list);

	update();
	stateChanged();
}

void ht_text_listbox::update()
{
	ht_listbox::update();
	Cursor_adjust = 0;
	if (widths) {
		for (int i=0; iofs = (w-d->len)/2;
		break;
	case align_right:
		d->ofs = w-d->len;
		break;
	default:
		d->ofs = 0;
		break;
	}
}

void ht_statictext::init(Bounds *b, const char *t, statictext_align al, bool breakl, bool trans)
{
	ht_view::init(b, VO_OWNBUFFER | VO_RESIZE, "some statictext");
	VIEW_DEBUG_NAME("ht_statictext");

	align = al;
	breaklines = breakl;
	transparent = trans;
	text = ht_strdup(t);
}

void ht_statictext::done()
{
	free(text);
	ht_view::done();
}

const char *ht_statictext::defaultpalette()
{
	return palkey_generic_dialog_default;
}

#define ssst_word		0
#define ssst_separator	1
#define ssst_whitespace	2

static int get_ssst(char s)
{
	if (strchr(".,:;+-*/=()[]", s)) {
		return ssst_separator;
	} else if (s==' ') {
		return ssst_whitespace;
	}
	return ssst_word;
}

void ht_statictext::draw()
{
	if (!transparent) clear(gettextcolor());
	char text[size.w*size.h];
	if (gettext(text, size.w*size.h) <= 0) return;
	char *t = text;
	if (breaklines) {
		/* format string... */	
		ht_statictext_linedesc *orig_d = ht_malloc(sizeof (ht_statictext_linedesc)*size.h);
		ht_statictext_linedesc *d = orig_d;
		statictext_align lalign = align;
		int c=0;
		while (*t && c < size.h) {
			/* custom alignment */
			if (*t == ALIGN_CHAR_ESCAPE && align == align_custom) {
				switch (t[1]) {
				case ALIGN_CHAR_LEFT:
					lalign=align_left;
					break;
				case ALIGN_CHAR_CENTER:
					lalign=align_center;
					break;
				case ALIGN_CHAR_RIGHT:
					lalign=align_right;
					break;
				}
				t+=2;
			}
			/* determine line length */
			int i=0, len=1;
			char *bp = t+1;
			char *n = t+1;
			int ssst = get_ssst(t[i]);
			while (t[i]) {
				if (i+1 > size.w || t[i]=='\n' || !t[i+1]) {
					bool kill_ws = (t[i]!='\n');
					if (i+1 <= size.w) {
						/* line shorter than size.w */
						bp=t+i+1;
					} else if (t[i]=='\n') {
						/* line end */
						bp=t+i+1;
					} else if (size.w && ((bp-t)*100/size.w < STATICTEXT_MIN_LINE_FILL)) {
						/* force break to make line long enough */
						bp=t+i;
					}
					len=bp-t;
					if (t[len-1]=='\n') len--;
					n=bp;
					if (kill_ws) {
						while (*n==' ') n++;
						while (t[len-1]==' ') len--;
					}
					break;
				}
				int s=get_ssst(t[i+1]);
				if ((ssst!=s) || (ssst==ssst_separator)) {
					bp=t+i+1;
				}
				ssst=s;
				i++;
			}
			d->text=t;
			d->len=len;
			ht_statictext_align(d, lalign, size.w);
			d++;
			c++;
			t=n;
		}

/**/
		d = orig_d;
		for (int i=0; inprint(d->ofs, i, gettextcolor(), d->text, d->len);
			d++;
		}
		free(orig_d);
	} else {
		int o=0;
		buf->print(o, 0, gettextcolor(), t);
	}
}

vcp ht_statictext::gettextcolor()
{
	return getcolor(palidx_generic_body);
//	return VCP(VC_RED, VC_BLACK);
}

int ht_statictext::gettext(char *aText, int maxlen)
{
	if (text) {
		return ht_strlcpy(aText, text, maxlen);
	} else {
		if (maxlen > 0) *aText = 0;
		return 0;
	}
}

void ht_statictext::settext(const char *aText)
{
	free(text);
	text = ht_strdup(aText);
	dirtyview();
}

/*
 *	CLASS ht_listpopup_dialog
 */

void ht_listpopup_dialog::init(Bounds *b, const char *desc)
{
	ht_dialog::init(b, desc, FS_TITLE | FS_MOVE);
	VIEW_DEBUG_NAME("ht_listpopup_dialog");

	Bounds c;
	getclientarea(&c);
	c.x=0;
	c.y=0;
	init_text_listbox(&c);
}

int ht_listpopup_dialog::datasize()
{
	return sizeof (ht_listpopup_dialog_data);
}

const char *ht_listpopup_dialog::defaultpalette()
{
	return palkey_generic_blue;
}

void ht_listpopup_dialog::getdata(ObjectStream &s)
{
	ht_listbox_data d;
	ViewDataBuf vdb(listbox, &d, sizeof d);

	PUTX_INT32D(s, ((ht_text_listbox*)listbox)->getID(d.data->cursor_ptr), NULL);

	ht_text_listbox_item *cursor = (ht_text_listbox_item*)d.data->cursor_ptr;
	if (cursor) {
		PUTX_STRING(s, cursor->data[0], NULL);
	} else {
		PUTX_STRING(s, NULL, NULL);
	}
}

void ht_listpopup_dialog::init_text_listbox(Bounds *b)
{
	listbox = new ht_text_listbox();
	((ht_text_listbox *)listbox)->init(b);
	insert(listbox);
}

void ht_listpopup_dialog::insertstring(const char *string)
{
	((ht_text_listbox *)listbox)->insert_str(listbox->calcCount(), string);
	listbox->update();
}

void ht_listpopup_dialog::select_next()
{
	listbox->cursorDown(1);
}

void ht_listpopup_dialog::select_prev()
{
	listbox->cursorUp(1);
}

void ht_listpopup_dialog::setdata(ObjectStream &s)
{
	int cursor_id = GETX_INT32D(s, NULL);
//	free(GETX_STRING(s, NULL));	/* ignored */

	listbox->gotoItemByPosition(cursor_id);
}

/*
 *	CLASS ht_listpopup
 */

void	ht_listpopup::init(Bounds *b)
{
	ht_statictext::init(b, 0, align_left, 0);
	setoptions(options | VO_SELECTABLE);
	VIEW_DEBUG_NAME("ht_listpopup");

	Bounds c=*b;
	c.x=0;
	c.y=0;
	c.h=5;
	
	listpopup = new ht_listpopup_dialog();
	listpopup->init(&c, 0);
}

void	ht_listpopup::done()
{
	listpopup->done();
	delete listpopup;
	
	ht_view::done();
}

int ht_listpopup::datasize()
{
	return listpopup->datasize();
}

void ht_listpopup::draw()
{
	ht_statictext::draw();
	buf->printChar(size.w-1, 0, gettextcolor(), GC_SMALL_ARROW_DOWN, CP_GRAPHICAL);
}

vcp ht_listpopup::gettextcolor()
{
	return focused ? getcolor(palidx_generic_input_selected) :
		getcolor(palidx_generic_input_focused);
}

void ht_listpopup::getdata(ObjectStream &s)
{
	listpopup->getdata(s);
}

int ht_listpopup::gettext(char *text, int maxlen)
{
	ht_listpopup_dialog_data d;
	ViewDataBuf vdb(listpopup, &d, sizeof d);
	return ht_strlcpy(text, d.cursor_string, maxlen);
}

void ht_listpopup::handlemsg(htmsg *msg)
{
	if (msg->msg == msg_keypressed) {
		switch (msg->data1.integer) {
		case K_Up: {
			int r;
			ht_listpopup_dialog_data d;
			ViewDataBuf vdb(listpopup, &d, sizeof d);
			listpopup->select_prev();
			r = run_listpopup();
			clearmsg(msg);
			if (!r) listpopup->databuf_set(&d, sizeof d);
			return;
		}
		case K_Down: {
			int r;
			ht_listpopup_dialog_data d;
			ViewDataBuf vdb(listpopup, &d, sizeof d);
			listpopup->select_next();
			r = run_listpopup();
			clearmsg(msg);
			if (!r) listpopup->databuf_set(&d, sizeof d);
			return;
		}				
		}
	}
	ht_statictext::handlemsg(msg);
}

int ht_listpopup::run_listpopup()
{
	int r;
	listpopup->relocate_to(this);
	r = listpopup->run(false);
	listpopup->unrelocate_to(this);
	return r;
}

void ht_listpopup::insertstring(const char *string)
{
	listpopup->insertstring(string);
}

void ht_listpopup::setdata(ObjectStream &s)
{
	listpopup->setdata(s);
}

/*
 *	CLASS ht_label
 */

void ht_label::init(Bounds *b, const char *_text, ht_view *_connected)
{
	ht_view::init(b, VO_POSTPROCESS, 0);
	text = ht_strdup(_text);
	magicchar = strchr(text, '~');
	if (magicchar) {
		int l = strlen(text);
		memmove(magicchar, magicchar+1, l-(magicchar-text));
	}
	connected = _connected;
	if (magicchar) {
		shortcut = keyb_metakey((ht_key)*magicchar);
	} else {
		shortcut = K_INVALID;
	}
}

void ht_label::done()
{
	free(text);
	ht_view::done();
}

const char *ht_label::defaultpalette()
{
	return palkey_generic_dialog_default;
}

void ht_label::draw()
{
	vcp c;
	vcp sc = getcolor(palidx_generic_text_shortcut);
	if (connected->focused) {
		c = getcolor(palidx_generic_text_focused);
	} else {
		c = getcolor(palidx_generic_text_unfocused);
	}
	buf->nprint(0, 0, c, text, size.w);
	if (magicchar) buf->printChar(magicchar-text, 0, sc, *magicchar);
}

void ht_label::handlemsg(htmsg *msg)
{
	if (msg->type==mt_postprocess) {
		if (msg->msg==msg_keypressed) {
			if ((shortcut!=-1) && (msg->data1.integer==shortcut)) {
				app->focus(connected);
				dirtyview();
				clearmsg(msg);
				return;
			}
		}
	} else ht_view::handlemsg(msg);
}

/*
 *	CLASS ht_progress_indicator
 */

void	ht_progress_indicator::init(Bounds *b, const char *hint)
{
	ht_window::init(b, NULL, 0);

	Bounds c=*b;

	c.x=1;
	c.y=1;
	c.w-=c.x+2;
	c.h-=c.y+3;
	text=new ht_statictext();
	text->init(&c, NULL, align_center, true);
	insert(text);

	c.y+=2;
	c.h=1;
	ht_statictext *t=new ht_statictext();
	t->init(&c, hint, align_center);
	insert(t);
}

const char *ht_progress_indicator::defaultpalette()
{
	return palkey_generic_dialog_default;
}

void ht_progress_indicator::settext(const char *t)
{
	text->settext(t);
}

/*
 *	CLASS ht_color_block
 */

int vcs[16]={VC_BLACK, VC_BLUE, VC_GREEN, VC_CYAN, VC_RED, VC_MAGENTA, VC_YELLOW, VC_WHITE,   VC_LIGHT(VC_BLACK), VC_LIGHT(VC_BLUE), VC_LIGHT(VC_GREEN), VC_LIGHT(VC_CYAN), VC_LIGHT(VC_RED), VC_LIGHT(VC_MAGENTA), VC_LIGHT(VC_YELLOW), VC_LIGHT(VC_WHITE)};

void ht_color_block::init(Bounds *b, int selected, int Flags)
{
	ht_view::init(b, VO_OWNBUFFER | VO_SELECTABLE, 0);
	VIEW_DEBUG_NAME("ht_color_block");
	flags=Flags;
	
	ht_color_block_data d;
	d.color = selected;
	databuf_set(&d, sizeof d);
	if (flags & cf_light) colors=16; else colors=8;
}

void ht_color_block::done()
{
	ht_view::done();
}

int ht_color_block::datasize()
{
	return sizeof (ht_color_block_data);
}

const char *ht_color_block::defaultpalette()
{
	return palkey_generic_dialog_default;
}

void ht_color_block::draw()
{
	clear(getcolor(palidx_generic_body));
	uint32 cursor=VCP(focused ? VC_LIGHT(VC_WHITE) : VC_BLACK, VC_TRANSPARENT);
	for (int i=0; i < colors; i++) {
		buf->printChar((i%4)*3+1, i/4, VCP(vcs[i], VC_TRANSPARENT), GC_FULL, CP_GRAPHICAL);
		buf->printChar((i%4)*3+2, i/4, VCP(vcs[i], VC_BLACK), GC_MEDIUM, CP_GRAPHICAL);
		if (i == color) {
			buf->printChar((i%4)*3, i/4, cursor, '>');
			buf->printChar((i%4)*3+3, i/4, cursor, '<');
		}
	}
	if (flags & cf_transparent) {
		buf->print(1, (colors==8) ? 2 : 4, VCP(VC_BLACK, VC_TRANSPARENT), "transparent");
		if (color == -1) {
			buf->printChar(0, (colors==8) ? 2 : 4, cursor, '>');
			buf->printChar(12, (colors==8) ? 2 : 4, cursor, '<');
		}
	}
}

void ht_color_block::getdata(ObjectStream &s)
{
	PUTX_INT32D(s, (color==-1) ? VC_TRANSPARENT : vcs[color], NULL);
}

void ht_color_block::handlemsg(htmsg *msg)
{
	if (msg->msg==msg_keypressed) {
		switch (msg->data1.integer) {
			case K_Left:
				if (color==-1) color=(flags & cf_light) ? 15 : 7; else
					if (color%4-1>=0) color--;
				dirtyview();
				clearmsg(msg);
				return;
			case K_Right:
				if (color==-1) color=(flags & cf_light) ? 15 : 7; else
					if (color%4+1<=3) color++;
				dirtyview();
				clearmsg(msg);
				return;
			case K_Up:
				if (color==-1) color=(flags & cf_light) ? 15 : 7; else
					if (color-4>=0) color-=4;
				dirtyview();
				clearmsg(msg);
				return;
			case K_Down:
				if (color != -1) {
					if (color+4 < colors) {
						color += 4;
					} else {
						color = -1;
					}
				}
				dirtyview();
				clearmsg(msg);
				return;
		}
	}
	ht_view::handlemsg(msg);
}

void ht_color_block::setdata(ObjectStream &s)
{
	int c = GETX_INT32D(s, NULL);
	if (c == VC_TRANSPARENT) {
		color = -1; 
	} else {
		for (int i=0; i<16; i++) if (vcs[i]==c) {
			color=i;
			break;
		}
	}
	dirtyview();
}

void center_bounds(Bounds *b)
{
	Bounds c;
	app->getbounds(&c);
	b->x = (c.w - b->w) / 2;
	b->y = (c.h - b->h) / 2;     
}
ht-2.0.22/atom.cc0000644000175000001440000000353310615345250010401 00000000000000/* 
 *	HT Editor
 *	atom.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include 

#include "atom.h"
#include "data.h"
#include "snprintf.h"

static AVLTree atoms(true);

class Atom: public Object {
public:
	uint id;
	void *value;

	Atom(uint i, void *v)
	   :  id(i),
	      value(v)
	{
	}

	int compareTo(const Object *obj) const
	{
		Atom *a = (Atom*)obj;
		return id - a->id;
	}
	
	int toString(char *buf, int buflen) const
	{
		return ht_snprintf(buf, buflen, "[%08x, %p]\n", id, value);
	}
	
};

void *getAtomValue(uint id)
{
	if (id != invalid_atom_id) {
		Atom a(id, NULL);
		Atom *f = (Atom*)atoms.get(atoms.find(&a));
		if (f) return f->value;
	}
	return NULL;
}

uint getAtomId(void *value)
{
	if (value) {
		foreach(Atom, a, atoms,
			if (a->value == value) return a->id;
		);
	}
	return invalid_atom_id;
}

#include "htdebug.h"

bool registerAtom(uint id, void *value)
{
	Atom a(id, NULL);
	if (atoms.contains(&a)) {
		return false;
	}
	assert(value);
	atoms.insert(new Atom(id, value));
	return true;
}

bool unregisterAtom(uint id)
{
	Atom a(id, NULL);
	atoms.delObj(&a);
	return true;
}

/*
 *	Module Init/Done
 */
 
bool init_atom()
{
	return true;
} 
 
void done_atom()
{
	atoms.delAll();
}
ht-2.0.22/vxdserv.cc0000644000175000001440000015322310206756711011150 00000000000000/* 
 *	HT Editor
 *	vxdserv.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "vxd.h"

vxd_service_desc vxd_vmm_services[] = {
		{ 0x0000,	"Get_VMM_Version" },
		{ 0x0001,	"Get_Cur_VM_Handle"	},
		{ 0x0002,	"Test_Cur_VM_Handle" },
		{ 0x0003,	"Get_Sys_VM_Handle"	},
		{ 0x0004,	"Test_Sys_VM_Handle" },
		{ 0x0005,	"Validate_VM_Handle" },
		{ 0x0006,	"Get_VMM_Reenter_Count" },
		{ 0x0007,	"Begin_Reentrant_Execution" },
		{ 0x0008,	"End_Reentrant_Execution" },
		{ 0x0009,	"Install_V86_Break_Point" },
		{ 0x000a,	"Remove_V86_Break_Point"	},
		{ 0x000b,	"Allocate_V86_Call_Back"	},
		{ 0x000c,	"Allocate_PM_Call_Back" },
		{ 0x000d,	"Call_When_VM_Returns" },
		{ 0x000e,	"Schedule_Global_Event" },
		{ 0x000f,	"Schedule_VM_Event"	},
		{ 0x0010,	"Call_Global_Event"	},
		{ 0x0011,	"Call_VM_Event" },
		{ 0x0012,	"Cancel_Global_Event" },
		{ 0x0013,	"Cancel_VM_Event" },
		{ 0x0014,	"Call_Priority_VM_Event"	},
		{ 0x0015,	"Cancel_Priority_VM_Event" },
		{ 0x0016,	"Get_NMI_Handler_Addr" },
		{ 0x0017,	"Set_NMI_Handler_Addr" },
		{ 0x0018,	"Hook_NMI_Event" },
		{ 0x0019,	"Call_When_VM_Ints_Enabled" },
		{ 0x001a,	"Enable_VM_Ints" },
		{ 0x001b,	"Disable_VM_Ints" },
		{ 0x001c,	"Map_Flat" },
		{ 0x001d,	"Map_Lin_To_VM_Addr" },
		{ 0x001e,	"Adjust_Exec_Priority" },
		{ 0x001f,	"Begin_Critical_Section"	},
		{ 0x0020,	"End_Critical_Section" },
		{ 0x0021,	"End_Crit_And_Suspend" },
		{ 0x0022,	"Claim_Critical_Section"	},
		{ 0x0023,	"Release_Critical_Section" },
		{ 0x0024,	"Call_When_Not_Critical"	},
		{ 0x0025,	"Create_Semaphore" },
		{ 0x0026,	"Destroy_Semaphore"	},
		{ 0x0027,	"Wait_Semaphore" },
		{ 0x0028,	"Signal_Semaphore" },
		{ 0x0029,	"Get_Crit_Section_Status" },
		{ 0x002a,	"Call_When_Task_Switched" },
		{ 0x002b,	"Suspend_VM" },
		{ 0x002c,	"Resume_VM" },
		{ 0x002d,	"No_Fail_Resume_VM"	},
		{ 0x002e,	"Nuke_VM"	},
		{ 0x002f,	"Crash_Cur_VM"	},
		{ 0x0030,	"Get_Execution_Focus" },
		{ 0x0031,	"Set_Execution_Focus" },
		{ 0x0032,	"Get_Time_Slice_Priority" },
		{ 0x0033,	"Set_Time_Slice_Priority" },
		{ 0x0034,	"Get_Time_Slice_Granularity" },
		{ 0x0035,	"Set_Time_Slice_Granularity" },
		{ 0x0036,	"Get_Time_Slice_Info" },
		{ 0x0037,	"Adjust_Execution_Time" },
		{ 0x0038,	"Release_Time_Slice" },
		{ 0x0039,	"Wake_Up_VM" },
		{ 0x003a,	"Call_When_Idle" },
		{ 0x003b,	"Get_Next_VM_Handle" },
		{ 0x003c,	"Set_Global_Time_Out" },
		{ 0x003d,	"Set_VM_Time_Out" },
		{ 0x003e,	"Cancel_Time_Out" },
		{ 0x003f,	"Get_System_Time" },
		{ 0x0040,	"Get_VM_Exec_Time" },
		{ 0x0041,	"Hook_V86_Int_Chain" },
		{ 0x0042,	"Get_V86_Int_Vector" },
		{ 0x0043,	"Set_V86_Int_Vector" },
		{ 0x0044,	"Get_PM_Int_Vector"	},
		{ 0x0045,	"Set_PM_Int_Vector"	},
		{ 0x0046,	"Simulate_Int"	},
		{ 0x0047,	"Simulate_Iret" },
		{ 0x0048,	"Simulate_Far_Call"	},
		{ 0x0049,	"Simulate_Far_Jmp" },
		{ 0x004a,	"Simulate_Far_Ret" },
		{ 0x004b,	"Simulate_Far_Ret_N" },
		{ 0x004c,	"Build_Int_Stack_Frame" },
		{ 0x004d,	"Simulate_Push" },
		{ 0x004e,	"Simulate_Pop"	},
		{ 0x004f,	"HeapAllocate"	},
		{ 0x0050,	"HeapReAllocate" },
		{ 0x0051,	"HeapFree" },
		{ 0x0052,	"HeapGetSize" },
		{ 0x0053,	"PageAllocate"	},
		{ 0x0054,	"PageReAllocate" },
		{ 0x0055,	"PageFree" },
		{ 0x0056,	"PageLock" },
		{ 0x0057,	"PageUnLock" },
		{ 0x0058,	"PageGetSizeAddr" },
		{ 0x0059,	"PageGetAllocInfo" },
		{ 0x005a,	"GetFreePageCount" },
		{ 0x005b,	"GetSysPageCount" },
		{ 0x005c,	"GetVMPgCount"	},
		{ 0x005d,	"MapIntoV86" },
		{ 0x005e,	"PhysIntoV86" },
		{ 0x005f,	"TestGlobalV86Mem" },
		{ 0x0060,	"ModifyPageBits" },
		{ 0x0061,	"CopyPageTable" },
		{ 0x0062,	"LinMapIntoV86" },
		{ 0x0063,	"LinPageLock" },
		{ 0x0064,	"LinPageUnLock" },
		{ 0x0065,	"SetResetV86Pageable" },
		{ 0x0066,	"GetV86PageableArray" },
		{ 0x0067,	"PageCheckLinRange"	},
		{ 0x0068,	"PageOutDirtyPages"	},
		{ 0x0069,	"PageDiscardPages" },
		{ 0x006a,	"GetNulPageHandle" },
		{ 0x006b,	"GetFirstV86Page" },
		{ 0x006c,	"MapPhysToLinear" },
		{ 0x006d,	"GetAppFlatDSAlias"	},
		{ 0x006e,	"SelectorMapFlat" },
		{ 0x006f,	"GetDemandPageInfo"	},
		{ 0x0070,	"GetSetPageOutCount" },
		{ 0x0071,	"Hook_V86_Page" },
		{ 0x0072,	"Assign_Device_V86_Pages" },
		{ 0x0073,	"DeAssign_Device_V86_Pages" },
		{ 0x0074,	"Get_Device_V86_Pages_Array" },
		{ 0x0075,	"MMGR_SetNULPageAddr" },
		{ 0x0076,	"Allocate_GDT_Selector" },
		{ 0x0077,	"Free_GDT_Selector"	},
		{ 0x0078,	"Allocate_LDT_Selector" },
		{ 0x0079,	"Free_LDT_Selector"	},
		{ 0x007a,	"BuildDescriptorDWORDs" },
		{ 0x007b,	"GetDescriptor" },
		{ 0x007c,	"SetDescriptor" },
		{ 0x007d,	"MMGR_Toggle_HMA" },
		{ 0x007e,	"Get_Fault_Hook_Addrs" },
		{ 0x007f,	"Hook_V86_Fault" },
		{ 0x0080,	"Hook_PM_Fault" },
		{ 0x0081,	"Hook_VMM_Fault" },
		{ 0x0082,	"Begin_Nest_V86_Exec" },
		{ 0x0083,	"Begin_Nest_Exec" },
		{ 0x0084,	"Exec_Int" },
		{ 0x0085,	"Resume_Exec" },
		{ 0x0086,	"End_Nest_Exec" },
		{ 0x0087,	"Allocate_PM_App_CB_Area" },
		{ 0x0088,	"Get_Cur_PM_App_CB"	},
		{ 0x0089,	"Set_V86_Exec_Mode"	},
		{ 0x008a,	"Set_PM_Exec_Mode" },
		{ 0x008b,	"Begin_Use_Locked_PM_Stack" },
		{ 0x008c,	"End_Use_Locked_PM_Stack" },
		{ 0x008d,	"Save_Client_State"	},
		{ 0x008e,	"Restore_Client_State" },
		{ 0x008f,	"Exec_VxD_Int"	},
		{ 0x0090,	"Hook_Device_Service" },
		{ 0x0091,	"Hook_Device_V86_API" },
		{ 0x0092,	"Hook_Device_PM_API" },
		{ 0x0093,	"System_Control" },
		{ 0x0094,	"Simulate_IO" },
		{ 0x0095,	"Install_Mult_IO_Handlers" },
		{ 0x0096,	"Install_IO_Handler" },
		{ 0x0097,	"Enable_Global_Trapping"	},
		{ 0x0098,	"Enable_Local_Trapping" },
		{ 0x0099,	"Disable_Global_Trapping" },
		{ 0x009a,	"Disable_Local_Trapping"	},
		{ 0x009b,	"List_Create" },
		{ 0x009c,	"List_Destroy"	},
		{ 0x009d,	"List_Allocate" },
		{ 0x009e,	"List_Attach" },
		{ 0x009f,	"List_Attach_Tail" },
		{ 0x00a0,	"List_Insert" },
		{ 0x00a1,	"List_Remove" },
		{ 0x00a2,	"List_Deallocate" },
		{ 0x00a3,	"List_Get_First" },
		{ 0x00a4,	"List_Get_Next" },
		{ 0x00a5,	"List_Remove_First"	},
		{ 0x00a6,	"AddInstanceItem" },
		{ 0x00a7,	"Allocate_Device_CB_Area" },
		{ 0x00a8,	"Allocate_Global_V86_Data_Area" },
		{ 0x00a9,	"Allocate_Temp_V86_Data_Area"	},
		{ 0x00aa,	"Free_Temp_V86_Data_Area" },
		{ 0x00ab,	"Get_Profile_Decimal_Int" },
		{ 0x00ac,	"Convert_Decimal_String"	},
		{ 0x00ad,	"Get_Profile_Fixed_Point" },
		{ 0x00ae,	"Convert_Fixed_Point_String" },
		{ 0x00af,	"Get_Profile_Hex_Int" },
		{ 0x00b0,	"Convert_Hex_String" },
		{ 0x00b1,	"Get_Profile_Boolean" },
		{ 0x00b2,	"Convert_Boolean_String"	},
		{ 0x00b3,	"Get_Profile_String" },
		{ 0x00b4,	"Get_Next_Profile_String" },
		{ 0x00b5,	"Get_Environment_String"	},
		{ 0x00b6,	"Get_Exec_Path" },
		{ 0x00b7,	"Get_Config_Directory" },
		{ 0x00b8,	"OpenFile" },
		{ 0x00b9,	"Get_PSP_Segment" },
		{ 0x00ba,	"GetDOSVectors" },
		{ 0x00bb,	"Get_Machine_Info" },
		{ 0x00bc,	"GetSet_HMA_Info" },
		{ 0x00bd,	"Set_System_Exit_Code" },
		{ 0x00be,	"Fatal_Error_Handler" },
		{ 0x00bf,	"Fatal_Memory_Error" },
		{ 0x00c0,	"Update_System_Clock" },
		{ 0x00c1,	"Test_Debug_Installed" },
		{ 0x00c2,	"Out_Debug_String" },
		{ 0x00c3,	"Out_Debug_Chr" },
		{ 0x00c4,	"In_Debug_Chr"	},
		{ 0x00c5,	"Debug_Convert_Hex_Binary" },
		{ 0x00c6,	"Debug_Convert_Hex_Decimal" },
		{ 0x00c7,	"Debug_Test_Valid_Handle" },
		{ 0x00c8,	"Validate_Client_Ptr" },
		{ 0x00c9,	"Test_Reenter"	},
		{ 0x00ca,	"Queue_Debug_String" },
		{ 0x00cb,	"Log_Proc_Call" },
		{ 0x00cc,	"Debug_Test_Cur_VM"	},
		{ 0x00cd,	"Get_PM_Int_Type" },
		{ 0x00ce,	"Set_PM_Int_Type" },
		{ 0x00cf,	"Get_Last_Updated_System_Time" },
		{ 0x00d0,	"Get_Last_Updated_VM_Exec_Time" },
		{ 0x00d1,	"Test_DBCS_Lead_Byte" },
		{ 0x00d2,	"AddFreePhysPage" },
		{ 0x00d3,	"PageResetHandlePAddr" },
		{ 0x00d4,	"SetLastV86Page" },
		{ 0x00d5,	"GetLastV86Page" },
		{ 0x00d6,	"MapFreePhysReg" },
		{ 0x00d7,	"UnmapFreePhysReg" },
		{ 0x00d8,	"XchgFreePhysReg" },
		{ 0x00d9,	"SetFreePhysRegCalBk" },
		{ 0x00da,	"Get_Next_Arena" },
		{ 0x00db,	"Get_Name_Of_Ugly_TSR" },
		{ 0x00dc,	"Get_Debug_Options"	},
		{ 0x00dd,	"Set_Physical_HMA_Alias"	},
		{ 0x00de,	"GetGlblRng0V86IntBase" },
		{ 0x00df,	"Add_Global_V86_Data_Area" },
		{ 0x00e0,	"GetSetDetailedVMError" },
		{ 0x00e1,	"Is_Debug_Chr"	},
		{ 0x00e2,	"Clear_Mono_Screen"	},
		{ 0x00e3,	"Out_Mono_Chr"	},
		{ 0x00e4,	"Out_Mono_String" },
		{ 0x00e5,	"Set_Mono_Cur_Pos" },
		{ 0x00e6,	"Get_Mono_Cur_Pos" },
		{ 0x00e7,	"Get_Mono_Chr"	},
		{ 0x00e8,	"Locate_Byte_In_ROM" },
		{ 0x00e9,	"Hook_Invalid_Page_Fault" },
		{ 0x00ea,	"Unhook_Invalid_Page_Fault" },
		{ 0x00eb,	"Set_Delete_On_Exit_File" },
		{ 0x00ec,	"Close_VM" },
		{ 0x00ed,	"Enable_Touch_1st_Meg" },
		{ 0x00ee,	"Disable_Touch_1st_Meg" },
		{ 0x00ef,	"Install_Exception_Handler" },
		{ 0x00f0,	"Remove_Exception_Handler" },
		{ 0x00f1,	"Get_Crit_Status_No_Block" },
		{ 0x00f2,	"GetLastUpdatedThreadExecTime" },
		{ 0x00f3,	"Trace_Out_Service"	},
		{ 0x00f4,	"Debug_Out_Service"	},
		{ 0x00f5,	"Debug_Flags_Service" },
		{ 0x00f6,	"VMMAddImportModuleName"	},
		{ 0x00f7,	"VMM_Add_DDB" },
		{ 0x00f8,	"VMM_Remove_DDB" },
		{ 0x00f9,	"Test_VM_Ints_Enabled" },
		{ 0x00fa,	"BlockOnID" },
		{ 0x00fb,	"Schedule_Thread_Event" },
		{ 0x00fc,	"Cancel_Thread_Event" },
		{ 0x00fd,	"Set_Thread_Time_Out" },
		{ 0x00fe,	"Set_Async_Time_Out" },
		{ 0x00ff,	"AllocateThreadDataSlot"	},
		{ 0x0100,	"FreeThreadDataSlot" },
		{ 0x0101,	"CreateMutex" },
		{ 0x0102,	"DestroyMutex"	},
		{ 0x0103,	"GetMutexOwner" },
		{ 0x0104,	"Call_When_Thread_Switched" },
		{ 0x0105,	"VMMCreateThread" },
		{ 0x0106,	"GetThreadExecTime"	},
		{ 0x0107,	"VMMTerminateThread" },
		{ 0x0108,	"Get_Cur_Thread_Handle" },
		{ 0x0109,	"Test_Cur_Thread_Handle"	},
		{ 0x010a,	"Get_Sys_Thread_Handle" },
		{ 0x010b,	"Test_Sys_Thread_Handle"	},
		{ 0x010c,	"Validate_Thread_Handle"	},
		{ 0x010d,	"Get_Initial_Thread_Handle" },
		{ 0x010e,	"Test_Initial_Thread_Handle" },
		{ 0x010f,	"Debug_Test_Valid_Thread_Handle" },
		{ 0x0110,	"Debug_Test_Cur_Thread" },
		{ 0x0111,	"VMM_GetSystemInitState"	},
		{ 0x0112,	"Cancel_Call_When_Thread_Switched"	},
		{ 0x0113,	"Get_Next_Thread_Handle"	},
		{ 0x0114,	"Adjust_Thread_Exec_Priority"	},
		{ 0x0115,	"Deallocate_Device_CB_Area" },
		{ 0x0116,	"Remove_IO_Handler"	},
		{ 0x0117,	"Remove_Mult_IO_Handlers" },
		{ 0x0118,	"Unhook_V86_Int_Chain" },
		{ 0x0119,	"Unhook_V86_Fault" },
		{ 0x011a,	"Unhook_PM_Fault" },
		{ 0x011b,	"Unhook_VMM_Fault" },
		{ 0x011c,	"Unhook_Device_Service" },
		{ 0x011d,	"PageReserve" },
		{ 0x011e,	"PageCommit" },
		{ 0x011f,	"PageDecommit"	},
		{ 0x0120,	"PagerRegister" },
		{ 0x0121,	"PagerQuery" },
		{ 0x0122,	"PagerDeregister" },
		{ 0x0123,	"ContextCreate" },
		{ 0x0124,	"ContextDestroy" },
		{ 0x0125,	"PageAttach" },
		{ 0x0126,	"PageFlush" },
		{ 0x0127,	"SignalID" },
		{ 0x0128,	"PageCommitPhys" },
		{ 0x0129,	"Register_Win32_Services" },
		{ 0x012a,	"Cancel_Call_When_Not_Critical" },
		{ 0x012b,	"Cancel_Call_When_Idle" },
		{ 0x012c,	"Cancel_Call_When_Task_Switched" },
		{ 0x012d,	"Debug_Printf_Service" },
		{ 0x012e,	"EnterMutex" },
		{ 0x012f,	"LeaveMutex" },
		{ 0x0130,	"Simulate_VM_IO" },
		{ 0x0131,	"Signal_Semaphore_No_Switch" },
		{ 0x0132,	"ContextSwitch" },
		{ 0x0133,	"PageModifyPermissions" },
		{ 0x0134,	"PageQuery" },
		{ 0x0135,	"EnterMustComplete"	},
		{ 0x0136,	"LeaveMustComplete"	},
		{ 0x0137,	"ResumeExecMustComplete"	},
		{ 0x0138,	"GetThreadTerminationStatus" },
		{ 0x0139,	"GetInstanceInfo" },
		{ 0x013a,	"ExecIntMustComplete" },
		{ 0x013b,	"ExecVxDIntMustComplete"	},
		{ 0x013c,	"Begin_V86_Serialization" },
		{ 0x013d,	"Unhook_V86_Page" },
		{ 0x013e,	"VMM_GetVxDLocationList"	},
		{ 0x013f,	"VMM_GetDDBList" },
		{ 0x0140,	"Unhook_NMI_Event" },
		{ 0x0141,	"Get_Instanced_V86_Int_Vector" },
		{ 0x0142,	"Get_Set_Real_DOS_PSP" },
		{ 0x0143,	"Call_Priority_Thread_Event" },
		{ 0x0144,	"Get_System_Time_Address" },
		{ 0x0145,	"Get_Crit_Status_Thread"	},
		{ 0x0146,	"Get_DDB"	},
		{ 0x0147,	"Directed_Sys_Control" },
		{ 0x0148,	"RegOpenKey" },
		{ 0x0149,	"RegCloseKey" },
		{ 0x014a,	"RegCreateKey"	},
		{ 0x014b,	"RegDeleteKey"	},
		{ 0x014c,	"RegEnumKey" },
		{ 0x014d,	"RegQueryValue" },
		{ 0x014e,	"RegSetValue" },
		{ 0x014f,	"RegDeleteValue" },
		{ 0x0150,	"RegEnumValue"	},
		{ 0x0151,	"RegQueryValueEx" },
		{ 0x0152,	"RegSetValueEx" },
		{ 0x0153,	"CallRing3" },
		{ 0x0154,	"Exec_PM_Int" },
		{ 0x0155,	"RegFlushKey" },
		{ 0x0156,	"PageCommitContig" },
		{ 0x0157,	"GetCurrentContext"	},
		{ 0x0158,	"LocalizeSprintf" },
		{ 0x0159,	"LocalizeStackSprintf" },
		{ 0x015a,	"Call_Restricted_Event" },
		{ 0x015b,	"Cancel_Restricted_Event" },
		{ 0x015c,	"Register_PEF_Provider" },
		{ 0x015d,	"GetPhysPageInfo" },
		{ 0x015e,	"RegQueryInfoKey" },
		{ 0x015f,	"MemArb_Reserve_Pages" },
		{ 0x0160,	"Time_Slice_Sys_VM_Idle"	},
		{ 0x0161,	"Time_Slice_Sleep" },
		{ 0x0162,	"Boost_With_Decay" },
		{ 0x0163,	"Set_Inversion_Pri"	},
		{ 0x0164,	"Reset_Inversion_Pri" },
		{ 0x0165,	"Release_Inversion_Pri" },
		{ 0x0166,	"Get_Thread_Win32_Pri" },
		{ 0x0167,	"Set_Thread_Win32_Pri" },
		{ 0x0168,	"Set_Thread_Static_Boost" },
		{ 0x0169,	"Set_VM_Static_Boost" },
		{ 0x016a,	"Release_Inversion_Pri_ID" },
		{ 0x016b,	"Attach_Thread_To_Group"	},
		{ 0x016c,	"Detach_Thread_From_Group" },
		{ 0x016d,	"Set_Group_Static_Boost"	},
		{ 0x016e,	"GetRegistryPath" },
		{ 0x016f,	"GetRegistryKey" },
		{ 0x0170,	"Cleanup_Thread_State" },
		{ 0x0171,	"RegRemapPreDefKey"	},
		{ 0x0172,	"End_V86_Serialization" },
		{ 0x0173,	"Assert_Range"	},
		{ 0x0174,	"Sprintf"	},
		{ 0x0175,	"PageChangePager" },
		{ 0x0176,	"RegCreateDynKey" },
		{ 0x0177,	"RegQMulti" },
		{ 0x0178,	"Boost_Thread_With_VM" },
		{ 0x0179,	"Get_Boot_Flags" },
		{ 0x017a,	"Set_Boot_Flags" },
		{ 0x017b,	"lstrcpyn" },
		{ 0x017c,	"lstrlen"	},
		{ 0x017d,	"lmemcpy"	},
		{ 0x017e,	"GetVxDName" },
		{ 0x017f,	"Force_Mutexes_Free" },
		{ 0x0180,	"Restore_Forced_Mutexes"	},
		{ 0x0181,	"AddReclaimableItem" },
		{ 0x0182,	"SetReclaimableItem" },
		{ 0x0183,	"EnumReclaimableItem" },
		{ 0x0184,	"Time_Slice_Wake_Sys_VM"	},
		{ 0x0185,	"VMM_Replace_Global_Environment" },
		{ 0x0186,	"Begin_Non_Serial_Nest_V86_Exec" },
		{ 0x0187,	"Get_Nest_Exec_Status" },
		{ 0x0188,	"Open_Boot_Log" },
		{ 0x0189,	"Write_Boot_Log" },
		{ 0x018a,	"Close_Boot_Log" },
		{ 0x018b,	"EnableDisable_Boot_Log"	},
		{ 0x018c,	"Call_On_My_Stack" },
		{ 0x018d,	"Get_Inst_V86_Int_Vec_Base" },
		{ 0x018e,	"lstrcmpi" },
		{ 0x018f,	"strupr" },
		{ 0x0190,	"Log_Fault_Call_Out" },
		{ 0x0191,	"AtEventTime" },
		{ 0x0192,	"PageOutPages"	},
		{ 0x0193,	"Call_On_My_Not_Flat_Stack" },
		{ 0x0194,	"LinRegionLock" },
		{ 0x0195,	"LinRegionUnLock" },
		{ 0x0196,	"AttemptingSomethingDangerous" },
		{ 0x0197,	"Vsprintf" },
		{ 0x0198,	"Vsprintfw" },
		{ 0x0199,	"Load_FS_Service" },
		{ 0x019a,	"Assert_FS_Service"	},
		{ 0x019b,	"ObsoleteRtlUnwind"	},
		{ 0x019c,	"ObsoleteRtlRaiseException" },
		{ 0x019d,	"ObsoleteRtlRaiseStatus"	},
		{ 0x019e,	"ObsoleteKeGetCurrentIrql" },
		{ 0x019f,	"ObsoleteKfRaiseIrql" },
		{ 0x01a0,	"ObsoleteKfLowerIrql" },
		{ 0x01a1,	"Begin_Preemptable_Code"	},
		{ 0x01a2,	"End_Preemptable_Code" },
		{ 0x01a3,	"Set_Preemptable_Count" },
		{ 0x01a4,	"ObsoleteKeInitializeDpc" },
		{ 0x01a5,	"ObsoleteKeInsertQueueDpc" },
		{ 0x01a6,	"ObsoleteKeRemoveQueueDpc" },
		{ 0x01a7,	"HeapAllocateEx" },
		{ 0x01a8,	"HeapReAllocateEx" },
		{ 0x01a9,	"HeapGetSizeEx" },
		{ 0x01aa,	"HeapFreeEx" },
		{ 0x01ab,	"Get_CPUID_Flags" },
		{ 0x01ac,	"KeCheckDivideByZeroTrap" },
		{ 0x01ad,	"RegisterGARTHandler" },
		{ 0x01ae,	"GARTReserve" },
		{ 0x01af,	"GARTCommit" },
		{ 0x01b0,	"GARTUnCommit"	},
		{ 0x01b1,	"GARTFree" },
		{ 0x01b2,	"GARTMemAttributes"	},
		{ 0x01b3,	"KfRaiseIrqlToDpcLevel" },
		{ 0x01b4,	"VMMCreateThreadEx"	},
		{ 0x01b5,	"FlushCaches" },
		{ 0x01b6,	"Set_Thread_Win32_Pri_NoYield" },
		{ 0x01b7,	"FlushMappedCacheBlock" },
		{ 0x01b8,	"ReleaseMappedCacheBlock" },
		{ 0x01b9,	"Run_Preemptable_Events"	},
		{ 0x01ba,	"MMPreSystemExit" },
		{ 0x01bb,	"MMPageFileShutDown" },
		{ 0x01bc,	"Set_Global_Time_Out_Ex"	},
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_debug_services[] =	{
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Fault" },
		{ 0x0002,	"CheckFault" },
		{ 0x0003,	"LoadSyms" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vpicd_services[] =	{
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Virtualize_IRQ" },
		{ 0x0002,	"Set_Int_Request" },
		{ 0x0003,	"Clear_Int_Request"	},
		{ 0x0004,	"Phys_EOI" },
		{ 0x0005,	"Get_Complete_Status" },
		{ 0x0006,	"Get_Status" },
		{ 0x0007,	"Test_Phys_Request"	},
		{ 0x0008,	"Physically_Mask" },
		{ 0x0009,	"Physically_Unmask"	},
		{ 0x000a,	"Set_Auto_Masking" },
		{ 0x000b,	"Get_IRQ_Complete_Status" },
		{ 0x000c,	"Convert_Handle_To_IRQ" },
		{ 0x000d,	"Convert_IRQ_To_Int" },
		{ 0x000e,	"Convert_Int_To_IRQ" },
		{ 0x000f,	"Call_When_Hw_Int" },
		{ 0x0010,	"Force_Default_Owner" },
		{ 0x0011,	"Force_Default_Behavior"	},
		{ 0x0012,	"Auto_Mask_At_Inst_Swap"	},
		{ 0x0013,	"Begin_Inst_Page_Swap" },
		{ 0x0014,	"End_Inst_Page_Swap" },
		{ 0x0015,	"Virtual_EOI" },
		{ 0x0016,	"Get_Virtualization_Count" },
		{ 0x0017,	"Post_Sys_Critical_Init"	},
		{ 0x0018,	"VM_SlavePIC_Mask_Change" },
		{ 0x0019,	"Clear_IR_Bits" },
		{ 0x001a,	"Get_Level_Mask" },
		{ 0x001b,	"Set_Level_Mask" },
		{ 0x001c,	"Set_Irql_Mask" },
		{ 0x001d,	"Set_Channel_Irql" },
		{ 0x001e,	"Prepare_For_Shutdown" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vdmad_services[] =	{
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Virtualize_Channel" },
		{ 0x0002,	"Get_Region_Info" },
		{ 0x0003,	"Set_Region_Info" },
		{ 0x0004,	"Get_Virt_State" },
		{ 0x0005,	"Set_Virt_State" },
		{ 0x0006,	"Set_Phys_State" },
		{ 0x0007,	"Mask_Channel"	},
		{ 0x0008,	"UnMask_Channel" },
		{ 0x0009,	"Lock_DMA_Region" },
		{ 0x000a,	"Unlock_DMA_Region"	},
		{ 0x000b,	"Scatter_Lock"	},
		{ 0x000c,	"Scatter_Unlock" },
		{ 0x000d,	"Reserve_Buffer_Space" },
		{ 0x000e,	"Request_Buffer" },
		{ 0x000f,	"Release_Buffer" },
		{ 0x0010,	"Copy_To_Buffer" },
		{ 0x0011,	"Copy_From_Buffer" },
		{ 0x0012,	"Default_Handler" },
		{ 0x0013,	"Disable_Translation" },
		{ 0x0014,	"Enable_Translation" },
		{ 0x0015,	"Get_EISA_Adr_Mode"	},
		{ 0x0016,	"Set_EISA_Adr_Mode"	},
		{ 0x0017,	"Unlock_DMA_Region_No_Dirty" },
		{ 0x0018,	"Phys_Mask_Channel"	},
		{ 0x0019,	"Phys_Unmask_Channel" },
		{ 0x001a,	"Unvirtualize_Channel" },
		{ 0x001b,	"Set_IO_Address" },
		{ 0x001c,	"Get_Phys_Count" },
		{ 0x001d,	"Get_Phys_Status" },
		{ 0x001e,	"Get_Max_Phys_Page"	},
		{ 0x001f,	"Set_Channel_Callbacks" },
		{ 0x0020,	"Get_Virt_Count" },
		{ 0x0021,	"Set_Virt_Count" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vtd_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Update_System_Clock" },
		{ 0x0002,	"Get_Interrupt_Period" },
		{ 0x0003,	"Begin_Min_Int_Period" },
		{ 0x0004,	"End_Min_Int_Period" },
		{ 0x0005,	"Disable_Trapping" },
		{ 0x0006,	"Enable_Trapping" },
		{ 0x0007,	"Get_Real_Time" },
		{ 0x0008,	"Get_Date_And_Time"	},
		{ 0x0009,	"Adjust_VM_Count" },
		{ 0x000a,	"Delay" },
		{ 0x000b,	"GetTimeZoneBias" },
		{ 0x000c,	"ObsoleteKeQueryPerformanceCounter" },
		{ 0x000d,	"ObsoleteKeQuerySystemTime" },
		{ 0x000e,	"Install_IO_Handle"	},
		{ 0x000f,	"Remove_IO_Handle" },
		{ 0x0010,	"Delay_Ex" },
		{ 0x0011,	"Init_Timer" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_v86mmgr_services[]	= {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Allocate_V86_Pages" },
		{ 0x0002,	"Set_EMS_XMS_Limits" },
		{ 0x0003,	"Get_EMS_XMS_Limits" },
		{ 0x0004,	"Set_Mapping_Info" },
		{ 0x0005,	"Get_Mapping_Info" },
		{ 0x0006,	"Xlat_API" },
		{ 0x0007,	"Load_Client_Ptr" },
		{ 0x0008,	"Allocate_Buffer" },
		{ 0x0009,	"Free_Buffer" },
		{ 0x000a,	"Get_Xlat_Buff_State" },
		{ 0x000b,	"Set_Xlat_Buff_State" },
		{ 0x000c,	"Get_VM_Flat_Sel" },
		{ 0x000d,	"Map_Pages" },
		{ 0x000e,	"Free_Page_Map_Region" },
		{ 0x000f,	"LocalGlobalReg" },
		{ 0x0010,	"GetPgStatus" },
		{ 0x0011,	"SetLocalA20" },
		{ 0x0012,	"ResetBasePages" },
		{ 0x0013,	"SetAvailMapPgs" },
		{ 0x0014,	"NoUMBInitCalls" },
		{ 0x0015,	"Get_EMS_XMS_Avail"	},
		{ 0x0016,	"Toggle_HMA" },
		{ 0x0017,	"Dev_Init" },
		{ 0x0018,	"Alloc_UM_Page" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_pageswap_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0006,	"Test_IO_Valid" },
		{ 0x0007,	"Read_Or_Write" },
		{ 0x0008,	"Grow_File" },
		{ 0x0009,	"Init_File" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vdd_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"PIF_State" },
		{ 0x0002,	"Get_GrabRtn" },
		{ 0x0003,	"Hide_Cursor" },
		{ 0x0004,	"Set_VMType" },
		{ 0x0005,	"Get_ModTime" },
		{ 0x0006,	"Set_HCurTrk" },
		{ 0x0007,	"Msg_ClrScrn" },
		{ 0x0008,	"Msg_ForColor"	},
		{ 0x0009,	"Msg_BakColor"	},
		{ 0x000a,	"Msg_TextOut" },
		{ 0x000b,	"Msg_SetCursPos" },
		{ 0x000c,	"Query_Access"	},
		{ 0x000d,	"Check_Update_Soon"	},
		{ 0x000e,	"Get_Mini_Dispatch_Table" },
		{ 0x000f,	"Register_Virtual_Port" },
		{ 0x0010,	"Get_VM_Info" },
		{ 0x0011,	"Get_Special_VM_IDs" },
		{ 0x0012,	"Register_Extra_Screen_Selector" },
		{ 0x0013,	"Takeover_VGA_Port"	},
		{ 0x0014,	"Get_DISPLAYINFO" },
		{ 0x0015,	"Do_Physical_IO" },
		{ 0x0016,	"Set_Sleep_Flag_Addr" },
		{ 0x0017,	"EnableDevice"	},
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vsd_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Bell" },
		{ 0x0002,	"SoundOn"	},
		{ 0x0003,	"TakeSoundPort" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vmd_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Set_Mouse_Type" },
		{ 0x0002,	"Get_Mouse_Owner" },
		{ 0x0003,	"Post_Pointer_Message" },
		{ 0x0004,	"Set_Cursor_Proc" },
		{ 0x0005,	"Call_Cursor_Proc" },
		{ 0x0006,	"Set_Mouse_Data" },
		{ 0x0007,	"Get_Mouse_Data" },
		{ 0x0008,	"Manipulate_Pointer_Message" },
		{ 0x0009,	"Set_Middle_Button"	},
		{ 0x000a,	"Enable_Disable_Mouse_Events"	},
		{ 0x000b,	"Post_Absolute_Pointer_Message" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vkd_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Define_Hot_Key" },
		{ 0x0002,	"Remove_Hot_Key" },
		{ 0x0003,	"Local_Enable_Hot_Key" },
		{ 0x0004,	"Local_Disable_Hot_Key" },
		{ 0x0005,	"Reflect_Hot_Key" },
		{ 0x0006,	"Cancel_Hot_Key_State" },
		{ 0x0007,	"Force_Keys" },
		{ 0x0008,	"Get_Kbd_Owner" },
		{ 0x0009,	"Define_Paste_Mode"	},
		{ 0x000a,	"Start_Paste" },
		{ 0x000b,	"Cancel_Paste"	},
		{ 0x000c,	"Get_Msg_Key" },
		{ 0x000d,	"Peek_Msg_Key"	},
		{ 0x000e,	"Flush_Msg_Key_Queue" },
		{ 0x000f,	"Enable_Keyboard" },
		{ 0x0010,	"Disable_KeyBoard" },
		{ 0x0011,	"Get_Shift_State" },
		{ 0x0012,	"Filter_Keyboard_Input" },
		{ 0x0013,	"Put_Byte" },
		{ 0x0014,	"Set_Shift_State" },
		{ 0x0015,	"Send_Data" },
		{ 0x0016,	"Set_LEDs" },
		{ 0x0017,	"Set_Key_Rate"	},
		{ 0x0018,	"Get_Key_Rate"	},
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vcd_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Set_Port_Global" },
		{ 0x0002,	"Get_Focus" },
		{ 0x0003,	"Virtualize_Port" },
		{ 0x0004,	"Acquire_Port"	},
		{ 0x0005,	"Free_Port" },
		{ 0x0006,	"Acquire_Port_Windows_Style" },
		{ 0x0007,	"Free_Port_Windows_Style" },
		{ 0x0008,	"Steal_Port_Windows_Style" },
		{ 0x0009,	"Find_COM_Index" },
		{ 0x000a,	"Set_Port_Global_Special" },
		{ 0x000b,	"Virtualize_Port_Dynamic" },
		{ 0x000c,	"Unvirtualize_Port_Dynamic" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vpd_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Acquire"	},
		{ 0x0002,	"Release"	},
		{ 0x0003,	"Jumbo_Acquire" },
		{ 0x0004,	"Jumbo_Release" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_ios_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"BD_Register_Device" },
		{ 0x0002,	"Find_Int13_Drive" },
		{ 0x0003,	"Get_Device_List" },
		{ 0x0004,	"SendCommand" },
		{ 0x0005,	"BD_Command_Complete" },
		{ 0x0006,	"Synchronous_Command" },
		{ 0x0007,	"Register" },
		{ 0x0008,	"Requestor_Service"	},
		{ 0x0009,	"Exclusive_Access" },
		{ 0x000a,	"Send_Next_Command"	},
		{ 0x000b,	"Set_Async_Time_Out" },
		{ 0x000c,	"Signal_Semaphore_No_Switch" },
		{ 0x000d,	"IdleStatus" },
		{ 0x000e,	"MapIORSToI24"	},
		{ 0x000f,	"MapIORSToI21"	},
		{ 0x0010,	"PrintLog" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vmcpd_services[] =	{
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Get_Virt_State" },
		{ 0x0002,	"Set_Virt_State" },
		{ 0x0003,	"Get_CR0_State" },
		{ 0x0004,	"Set_CR0_State" },
		{ 0x0005,	"Get_Thread_State" },
		{ 0x0006,	"Set_Thread_State" },
		{ 0x0007,	"Get_FP_Instruction_Size" },
		{ 0x0008,	"Set_Thread_Precision" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_ebios_services[] =	{
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Get_Unused_Mem" },
		{ -1, 0 }		  /* Terminator */
};

vxd_service_desc vxd_vnetbios_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Register" },
		{ 0x0002,	"Submit" },
		{ 0x0003,	"Enum" },
		{ 0x0004,	"Deregister" },
		{ 0x0005,	"Register2" },
		{ 0x0006,	"Map" },
		{ 0x0007,	"Enum2" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_dosmgr_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Set_Exec_VM_Data" },
		{ 0x0002,	"Copy_VM_Drive_State" },
		{ 0x0003,	"Exec_VM"	},
		{ 0x0004,	"Get_IndosPtr"	},
		{ 0x0005,	"Add_Device" },
		{ 0x0006,	"Remove_Device" },
		{ 0x0007,	"Instance_Device" },
		{ 0x0008,	"Get_DOS_Crit_Status" },
		{ 0x0009,	"Enable_Indos_Polling" },
		{ 0x000a,	"BackFill_Allowed" },
		{ 0x000b,	"LocalGlobalReg" },
		{ 0x000c,	"Init_UMB_Area" },
		{ 0x000d,	"Begin_V86_App" },
		{ 0x000e,	"End_V86_App" },
		{ 0x000f,	"Alloc_Local_Sys_VM_Mem"	},
		{ 0x0010,	"Grow_CDSs" },
		{ 0x0011,	"Translate_Server_DOS_Call" },
		{ 0x0012,	"MMGR_PSP_Change_Notifier" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_shell_services[] =	{
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Resolve_Contention" },
		{ 0x0002,	"Event" },
		{ 0x0003,	"SYSMODAL_Message" },
		{ 0x0004,	"Message"	},
		{ 0x0005,	"GetVMInfo" },
		{ 0x0006,	"PostMessage" },
		{ 0x0007,	"ShellExecute"	},
		{ 0x0008,	"PostShellMessage" },
		{ 0x0009,	"DispatchRing0AppyEvents" },
		{ 0x000a,	"Hook_Properties" },
		{ 0x000b,	"Unhook_Properties"	},
		{ 0x000c,	"Update_User_Activity" },
		{ 0x000d,	"QueryAppyTimeAvailable"	},
		{ 0x000e,	"CallAtAppyTime" },
		{ 0x000f,	"CancelAppyTimeEvent" },
		{ 0x0010,	"BroadcastSystemMessage"	},
		{ 0x0011,	"HookSystemBroadcast" },
		{ 0x0012,	"UnhookSystemBroadcast" },
		{ 0x0013,	"LocalAllocEx"	},
		{ 0x0014,	"LocalFree" },
		{ 0x0015,	"LoadLibrary" },
		{ 0x0016,	"FreeLibrary" },
		{ 0x0017,	"GetProcAddress" },
		{ 0x0018,	"CallDll"	},
		{ 0x0019,	"SuggestSingleMSDOSMode"	},
		{ 0x001a,	"CheckHotkeyAllowed" },
		{ 0x001b,	"GetDOSAppInfo" },
		{ 0x001c,	"Update_User_Activity_Ex" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vmpool_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Enable_Disable" },
		{ 0x0002,	"Reset_Detection" },
		{ 0x0003,	"Check_Idle" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_dosnet_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Send_FILESYSCHANGE" },
		{ 0x0002,	"Do_PSP_Adjust" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_int13_services[] =	{
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Device_Registered"	},
		{ 0x0002,	"Translate_VM_Int" },
		{ 0x0003,	"Hooking_BIOS_Int" },
		{ 0x0004,	"Unhooking_BIOS_Int" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_pagefile_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Init_File" },
		{ 0x0002,	"Clean_Up" },
		{ 0x0003,	"Grow_File" },
		{ 0x0004,	"Read_Or_Write" },
		{ 0x0005,	"Cancel" },
		{ 0x0006,	"Test_IO_Valid" },
		{ 0x0007,	"Get_Size_Info" },
		{ 0x0008,	"Set_Async_Manager"	},
		{ 0x0009,	"Call_Async_Manager" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vpowerd_services[]	= {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Get_APM_BIOS_Version" },
		{ 0x0002,	"Get_Power_Management_Level" },
		{ 0x0003,	"Set_Power_Management_Level" },
		{ 0x0004,	"Set_Device_Power_State"	},
		{ 0x0005,	"Set_System_Power_State"	},
		{ 0x0006,	"Restore_Power_On_Defaults" },
		{ 0x0007,	"Get_Power_Status" },
		{ 0x0008,	"Get_Power_State" },
		{ 0x0009,	"OEM_APM_Function" },
		{ 0x000a,	"Register_Power_Handler"	},
		{ 0x000b,	"Deregister_Power_Handler" },
		{ 0x000c,	"W32_Get_System_Power_Status"	},
		{ 0x000d,	"W32_Set_System_Power_State" },
		{ 0x000e,	"Get_Capabilities" },
		{ 0x000f,	"Enable_Resume_On_Ring" },
		{ 0x0010,	"Disable_Resume_On_Ring"	},
		{ 0x0011,	"Set_Resume_Timer" },
		{ 0x0012,	"Get_Resume_Timer" },
		{ 0x0013,	"Disable_Resume_Timer" },
		{ 0x0014,	"Enable_Timer_Based_Requests"	},
		{ 0x0015,	"Disable_Timer_Based_Requests" },
		{ 0x0016,	"W32_Get_Power_Status" },
		{ 0x0017,	"Get_Timer_Based_Requests_Status" },
		{ 0x0018,	"Get_Ring_Resume_Status"	},
		{ 0x0019,	"Transfer_Control" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vxdldr_services[] = {
		{ 0x0000,	"GetVersion" },
		{ 0x0001,	"LoadDevice" },
		{ 0x0002,	"UnloadDevice"	},
		{ 0x0003,	"DevInitSucceeded" },
		{ 0x0004,	"DevInitFailed" },
		{ 0x0005,	"GetDeviceList" },
		{ 0x0006,	"UnloadMe" },
		{ 0x0007,	"PELDR_LoadModule" },
		{ 0x0008,	"PELDR_GetModuleHandle" },
		{ 0x0009,	"PELDR_GetModuleUsage" },
		{ 0x000a,	"PELDR_GetEntryPoint" },
		{ 0x000b,	"PELDR_GetProcAddress" },
		{ 0x000c,	"PELDR_AddExportTable" },
		{ 0x000d,	"PELDR_RemoveExportTable" },
		{ 0x000e,	"PELDR_FreeModule" },
		{ 0x000f,	"Notify" },
		{ 0x0010,	"PELDR_InitCompleted" },
		{ 0x0011,	"PELDR_LoadModuleEx" },
		{ 0x0012,	"PELDR_LoadModule2"	},
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_ndis_services[] = {
		{ 0x0000,	"GetVersion" },
		{ 0x0001,	"AllocateSpinLock" },
		{ 0x0002,	"FreeSpinLock"	},
		{ 0x0003,	"AcquireSpinLock" },
		{ 0x0004,	"ReleaseSpinLock" },
		{ 0x0005,	"OpenConfiguration"	},
		{ 0x0006,	"ReadConfiguration"	},
		{ 0x0007,	"CloseConfiguration" },
		{ 0x0008,	"ReadEisaSlotInformation" },
		{ 0x0009,	"ReadMcaPosInformation" },
		{ 0x000a,	"AllocateMemory" },
		{ 0x000b,	"FreeMemory" },
		{ 0x000c,	"SetTimer" },
		{ 0x000d,	"CancelTimer" },
		{ 0x000e,	"StallExecution" },
		{ 0x000f,	"InitializeInterrupt" },
		{ 0x0010,	"RemoveInterrupt" },
		{ 0x0011,	"SynchronizeWithInterrupt" },
		{ 0x0012,	"OpenFile" },
		{ 0x0013,	"MapFile"	},
		{ 0x0014,	"UnmapFile" },
		{ 0x0015,	"CloseFile" },
		{ 0x0016,	"AllocatePacketPool" },
		{ 0x0017,	"FreePacketPool" },
		{ 0x0018,	"AllocatePacket" },
		{ 0x0019,	"ReinitializePacket" },
		{ 0x001a,	"FreePacket" },
		{ 0x001b,	"QueryPacket" },
		{ 0x001c,	"AllocateBufferPool" },
		{ 0x001d,	"FreeBufferPool" },
		{ 0x001e,	"AllocateBuffer" },
		{ 0x001f,	"CopyBuffer" },
		{ 0x0020,	"FreeBuffer" },
		{ 0x0021,	"QueryBuffer" },
		{ 0x0022,	"GetBufferPhysicalAddress" },
		{ 0x0023,	"ChainBufferAtFront" },
		{ 0x0024,	"ChainBufferAtBack"	},
		{ 0x0025,	"UnchainBufferAtFront" },
		{ 0x0026,	"UnchainBufferAtBack" },
		{ 0x0027,	"GetNextBuffer" },
		{ 0x0028,	"CopyFromPacketToPacket"	},
		{ 0x0029,	"RegisterProtocol" },
		{ 0x002a,	"DeregisterProtocol" },
		{ 0x002b,	"OpenAdapter" },
		{ 0x002c,	"CloseAdapter"	},
		{ 0x002d,	"Send" },
		{ 0x002e,	"TransferData"	},
		{ 0x002f,	"Reset" },
		{ 0x0030,	"Request"	},
		{ 0x0031,	"InitializeWrapper"	},
		{ 0x0032,	"TerminateWrapper" },
		{ 0x0033,	"RegisterMac" },
		{ 0x0034,	"DeregisterMac" },
		{ 0x0035,	"RegisterAdapter" },
		{ 0x0036,	"DeregisterAdapter"	},
		{ 0x0037,	"CompleteOpenAdapter" },
		{ 0x0038,	"CompleteCloseAdapter" },
		{ 0x0039,	"CompleteSend"	},
		{ 0x003a,	"CompleteTransferData" },
		{ 0x003b,	"CompleteReset" },
		{ 0x003c,	"CompleteRequest" },
		{ 0x003d,	"IndicateReceive" },
		{ 0x003e,	"IndicateReceiveComplete" },
		{ 0x003f,	"IndicateStatus" },
		{ 0x0040,	"IndicateStatusComplete"	},
		{ 0x0041,	"CompleteQueryStatistics" },
		{ 0x0042,	"EqualString" },
		{ 0x0043,	"RegAdaptShutdown" },
		{ 0x0044,	"ReadNetworkAddress" },
		{ 0x0045,	"WriteErrorLogEntry" },
		{ 0x0046,	"MapIoSpace" },
		{ 0x0047,	"DeregAdaptShutdown" },
		{ 0x0048,	"AllocateSharedMemory" },
		{ 0x0049,	"FreeSharedMemory" },
		{ 0x004a,	"AllocateDmaChannel" },
		{ 0x004b,	"SetupDmaTransfer" },
		{ 0x004c,	"CompleteDmaTransfer" },
		{ 0x004d,	"ReadDmaCounter" },
		{ 0x004e,	"FreeDmaChannel" },
		{ 0x004f,	"ReleaseAdapterResources" },
		{ 0x0050,	"QueryGlobalStatistics" },
		{ 0x0051,	"OpenProtocolConfiguration" },
		{ 0x0052,	"CompleteBindAdapter" },
		{ 0x0053,	"CompleteUnbindAdapter" },
		{ 0x0054,	"WrapperStartNet" },
		{ 0x0055,	"WrapperGetComponentList" },
		{ 0x0056,	"WrapperQueryAdapterResources" },
		{ 0x0057,	"WrapperDelayBinding" },
		{ 0x0058,	"WrapperResumeBinding" },
		{ 0x0059,	"WrapperRemoveChildren" },
		{ 0x005a,	"ImmediateReadPciSlotInformation" },
		{ 0x005b,	"ImmediateWritePciSlotInformation"	},
		{ 0x005c,	"ReadPciSlotInformation"	},
		{ 0x005d,	"WritePciSlotInformation" },
		{ 0x005e,	"PciAssignResources" },
		{ 0x005f,	"QueryBufferOffset"	},
		{ 0x0062,	"InitializeEvent" },
		{ 0x0063,	"SetEvent" },
		{ 0x0064,	"ResetEvent" },
		{ 0x0065,	"WaitEvent" },
		{ 0x0066,	"ReturnPackets" },
		{ 0x0067,	"QueryReceiveInformation" },
		{ 0x0068,	"CmRegisterAddressFamily" },
		{ 0x0069,	"ClOpenAddressFamily" },
		{ 0x006a,	"CmOpenAddressFamilyComplete"	},
		{ 0x006b,	"ClCloseAddressFamily" },
		{ 0x006c,	"CmCloseAddressFamilyComplete" },
		{ 0x006d,	"ClRegisterSap" },
		{ 0x006e,	"CmRegisterSapComplete" },
		{ 0x006f,	"ClDeregisterSap" },
		{ 0x0070,	"CmDeregisterSapComplete" },
		{ 0x0071,	"ClMakeCall" },
		{ 0x0072,	"CmMakeCallComplete" },
		{ 0x0073,	"CmDispatchIncomingCall"	},
		{ 0x0074,	"ClIncomingCallComplete"	},
		{ 0x0075,	"CmDispatchCallConnected" },
		{ 0x0076,	"ClModifyCallQoS" },
		{ 0x0077,	"CmModifyCallQoSComplete" },
		{ 0x0078,	"CmDispatchIncomingCallQoSChange" },
		{ 0x0079,	"ClCloseCall" },
		{ 0x007a,	"CmCloseCallComplete" },
		{ 0x007b,	"CmDispatchIncomingCloseCall"	},
		{ 0x007c,	"ClAddParty" },
		{ 0x007d,	"CmAddPartyComplete" },
		{ 0x007e,	"ClDropParty" },
		{ 0x007f,	"CmDropPartyComplete" },
		{ 0x0080,	"CmDispatchIncomingDropParty"	},
		{ 0x0081,	"CoCreateVc" },
		{ 0x0082,	"CoDeleteVc" },
		{ 0x0083,	"CmActivateVc"	},
		{ 0x0084,	"CmDeactivateVc" },
		{ 0x0085,	"CoRequest" },
		{ 0x0086,	"CoRequestComplete"	},
		{ 0x0087,	"CoSendPackets" },
		{ 0x0088,	"InitAnsiString" },
		{ 0x0089,	"InitUnicodeString"	},
		{ 0x008a,	"AnsiStringToUnicodeString" },
		{ 0x008b,	"UnicodeStringToAnsiString" },
		{ 0x008c,	"WriteConfiguration" },
		{ 0x008d,	"OpenConfigurationKeyByName" },
		{ 0x008e,	"OpenConfigurationKeyByIndex"	},
		{ 0x008f,	"ConvertStringToAtmAddress" },
		{ 0x0090,	"AllocateMemoryWithTag" },
		{ 0x0091,	"OpenGlobalConfiguration" },
		{ 0x0092,	"InterlockedIncrement" },
		{ 0x0093,	"InterlockedDecrement" },
		{ 0x0094,	"InterlockedAddUlong" },
		{ 0x0095,	"InterlockedInsertHeadList" },
		{ 0x0096,	"InterlockedInsertTailList" },
		{ 0x0097,	"InterlockedRemoveHeadList" },
		{ 0x0098,	"InterlockedPopEntryList" },
		{ 0x0099,	"InterlockedPushEntryList" },
		{ 0x009a,	"WriteEventLogEntry" },
		{ 0x009b,	"GetFirstBufferFromPacket" },
		{ 0x009c,	"SendPackets" },
		{ 0x009e,	"GetSystemUpTime" },
		{ 0x009f,	"ScheduleWorkItem" },
		{ 0x00a0,	"QueryAdapterInstanceName" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vwin32_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"DIOCCompletionRoutine" },
		{ 0x0002,	"QueueUserApc"	},
		{ 0x0003,	"GetThreadContext" },
		{ 0x0004,	"SetThreadContext" },
		{ 0x0005,	"CopyMem"	},
		{ 0x0006,	"NpxException"	},
		{ 0x0007,	"EmulateNpx" },
		{ 0x0008,	"CheckDelayedNpxTrap" },
		{ 0x0009,	"EnterCrstR0" },
		{ 0x000a,	"LeaveCrstR0" },
		{ 0x000b,	"FaultPopup" },
		{ 0x000c,	"GetContextHandle" },
		{ 0x000d,	"GetCurrentProcessHandle" },
		{ 0x000e,	"SetWin32Event" },
		{ 0x000f,	"PulseWin32Event" },
		{ 0x0010,	"ResetWin32Event" },
		{ 0x0011,	"WaitSingleObject" },
		{ 0x0012,	"WaitMultipleObjects" },
		{ 0x0013,	"CreateRing0Thread"	},
		{ 0x0014,	"CloseVxDHandle" },
		{ 0x0015,	"ActiveTimeBiasSet"	},
		{ 0x0016,	"GetCurrentDirectory" },
		{ 0x0017,	"BlueScreenPopup" },
		{ 0x0018,	"TerminateApp"	},
		{ 0x0019,	"QueueKernelAPC" },
		{ 0x001a,	"SysErrorBox" },
		{ 0x001b,	"IsClientWin32" },
		{ 0x001c,	"IFSRIPWhenLev2Taken" },
		{ 0x001d,	"InitWin32Event" },
		{ 0x001e,	"InitWin32Mutex" },
		{ 0x001f,	"ReleaseWin32Mutex"	},
		{ 0x0020,	"BlockThreadEx" },
		{ 0x0021,	"GetProcessHandle" },
		{ 0x0022,	"InitWin32Semaphore" },
		{ 0x0023,	"SignalWin32Sem" },
		{ 0x0024,	"QueueUserApcEx" },
		{ 0x0025,	"OpenVxDHandle" },
		{ 0x0026,	"CloseWin32Handle" },
		{ 0x0027,	"AllocExternalHandle" },
		{ 0x0028,	"UseExternalHandle"	},
		{ 0x0029,	"UnuseExternalHandle" },
		{ 0x002a,	"KeInitializeTimer"	},
		{ 0x002b,	"KeSetTimer" },
		{ 0x002c,	"KeCancelTimer" },
		{ 0x002d,	"KeReadStateTimer" },
		{ 0x002e,	"ReferenceObject" },
		{ 0x002f,	"GetExternalHandle"	},
		{ 0x0030,	"ConvertNtTimeout" },
		{ 0x0031,	"SetWin32EventBoostPriority" },
		{ 0x0032,	"GetRing3Flat32Selectors" },
		{ 0x0033,	"GetCurThreadCondition" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vcomm_services[] =	{
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Register_Port_Driver" },
		{ 0x0002,	"Acquire_Port"	},
		{ 0x0003,	"Release_Port"	},
		{ 0x0004,	"OpenComm" },
		{ 0x0005,	"SetCommState"	},
		{ 0x0006,	"GetCommState"	},
		{ 0x0007,	"SetupComm" },
		{ 0x0008,	"TransmitCommChar" },
		{ 0x0009,	"CloseComm" },
		{ 0x000a,	"GetCommQueueStatus" },
		{ 0x000b,	"ClearCommError" },
		{ 0x000c,	"GetModemStatus" },
		{ 0x000d,	"GetCommProperties"	},
		{ 0x000e,	"EscapeCommFunction" },
		{ 0x000f,	"PurgeComm" },
		{ 0x0010,	"SetCommEventMask" },
		{ 0x0011,	"GetCommEventMask" },
		{ 0x0012,	"WriteComm" },
		{ 0x0013,	"ReadComm" },
		{ 0x0014,	"EnableCommNotification"	},
		{ 0x0015,	"GetLastError"	},
		{ 0x0016,	"Steal_Port" },
		{ 0x0017,	"SetReadCallBack" },
		{ 0x0018,	"SetWriteCallBack" },
		{ 0x0019,	"Add_Port" },
		{ 0x001a,	"GetSetCommTimeouts" },
		{ 0x001b,	"SetWriteRequest" },
		{ 0x001c,	"SetReadRequest" },
		{ 0x001d,	"Dequeue_Request" },
		{ 0x001e,	"Enumerate_DevNodes" },
		{ 0x001f,	"Map_Win32DCB_To_Ring0" },
		{ 0x0020,	"Map_Ring0DCB_To_Win32" },
		{ 0x0021,	"Get_Contention_Handler"	},
		{ 0x0022,	"Map_Name_To_Resource" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_configmg_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Initialize" },
		{ 0x0002,	"Locate_DevNode" },
		{ 0x0003,	"Get_Parent" },
		{ 0x0004,	"Get_Child" },
		{ 0x0005,	"Get_Sibling" },
		{ 0x0006,	"Get_Device_ID_Size" },
		{ 0x0007,	"Get_Device_ID" },
		{ 0x0008,	"Get_Depth" },
		{ 0x0009,	"Get_Private_DWord"	},
		{ 0x000a,	"Set_Private_DWord"	},
		{ 0x000b,	"Create_DevNode" },
		{ 0x000c,	"Query_Remove_SubTree" },
		{ 0x000d,	"Remove_SubTree" },
		{ 0x000e,	"Register_Device_Driver"	},
		{ 0x000f,	"Register_Enumerator" },
		{ 0x0010,	"Register_Arbitrator" },
		{ 0x0011,	"Deregister_Arbitrator" },
		{ 0x0012,	"Query_Arbitrator_Free_Size" },
		{ 0x0013,	"Query_Arbitrator_Free_Data" },
		{ 0x0014,	"Sort_NodeList" },
		{ 0x0015,	"Yield" },
		{ 0x0016,	"Lock" },
		{ 0x0017,	"Unlock" },
		{ 0x0018,	"Add_Empty_Log_Conf" },
		{ 0x0019,	"Free_Log_Conf" },
		{ 0x001a,	"Get_First_Log_Conf" },
		{ 0x001b,	"Get_Next_Log_Conf"	},
		{ 0x001c,	"Add_Res_Des" },
		{ 0x001d,	"Modify_Res_Des" },
		{ 0x001e,	"Free_Res_Des"	},
		{ 0x001f,	"Get_Next_Res_Des" },
		{ 0x0020,	"Get_Performance_Info" },
		{ 0x0021,	"Get_Res_Des_Data_Size" },
		{ 0x0022,	"Get_Res_Des_Data" },
		{ 0x0023,	"Process_Events_Now" },
		{ 0x0024,	"Create_Range_List"	},
		{ 0x0025,	"Add_Range" },
		{ 0x0026,	"Delete_Range"	},
		{ 0x0027,	"Test_Range_Available" },
		{ 0x0028,	"Dup_Range_List" },
		{ 0x0029,	"Free_Range_List" },
		{ 0x002a,	"Invert_Range_List"	},
		{ 0x002b,	"Intersect_Range_List" },
		{ 0x002c,	"First_Range" },
		{ 0x002d,	"Next_Range" },
		{ 0x002e,	"Dump_Range_List" },
		{ 0x002f,	"Load_DLVxDs" },
		{ 0x0030,	"Get_DDBs" },
		{ 0x0031,	"Get_CRC_CheckSum" },
		{ 0x0032,	"Register_DevLoader" },
		{ 0x0033,	"Reenumerate_DevNode" },
		{ 0x0034,	"Setup_DevNode" },
		{ 0x0035,	"Reset_Children_Marks" },
		{ 0x0036,	"Get_DevNode_Status" },
		{ 0x0037,	"Remove_Unmarked_Children" },
		{ 0x0038,	"ISAPNP_To_CM"	},
		{ 0x0039,	"CallBack_Device_Driver"	},
		{ 0x003a,	"CallBack_Enumerator" },
		{ 0x003b,	"Get_Alloc_Config" },
		{ 0x003c,	"Get_DevNode_Key_Size" },
		{ 0x003d,	"Get_DevNode_Key" },
		{ 0x003e,	"Read_Registry_Value" },
		{ 0x003f,	"Write_Registry_Value" },
		{ 0x0040,	"Disable_DevNode" },
		{ 0x0041,	"Enable_DevNode" },
		{ 0x0042,	"Move_DevNode"	},
		{ 0x0043,	"Set_Bus_Info"	},
		{ 0x0044,	"Get_Bus_Info"	},
		{ 0x0045,	"Set_HW_Prof" },
		{ 0x0046,	"Recompute_HW_Prof"	},
		{ 0x0047,	"Query_Change_HW_Prof" },
		{ 0x0048,	"Get_Device_Driver_Private_DWord" },
		{ 0x0049,	"Set_Device_Driver_Private_DWord" },
		{ 0x004a,	"Get_HW_Prof_Flags"	},
		{ 0x004b,	"Set_HW_Prof_Flags"	},
		{ 0x004c,	"Read_Registry_Log_Confs" },
		{ 0x004d,	"Run_Detection" },
		{ 0x004e,	"Call_At_Appy_Time"	},
		{ 0x004f,	"Fail_Change_HW_Prof" },
		{ 0x0050,	"Set_Private_Problem" },
		{ 0x0051,	"Debug_DevNode" },
		{ 0x0052,	"Get_Hardware_Profile_Info" },
		{ 0x0053,	"Register_Enumerator_Function" },
		{ 0x0054,	"Call_Enumerator_Function" },
		{ 0x0055,	"Add_ID" },
		{ 0x0056,	"Find_Range" },
		{ 0x0057,	"Get_Global_State" },
		{ 0x0058,	"Broadcast_Device_Change_Message" },
		{ 0x0059,	"Call_DevNode_Handler" },
		{ 0x005a,	"Remove_Reinsert_All" },
		{ 0x005b,	"Change_DevNode_Status" },
		{ 0x005c,	"Reprocess_DevNode"	},
		{ 0x005d,	"Assert_Structure" },
		{ 0x005e,	"Discard_Boot_Log_Conf" },
		{ 0x005f,	"Set_Dependent_DevNode" },
		{ 0x0060,	"Get_Dependent_DevNode" },
		{ 0x0061,	"Refilter_DevNode" },
		{ 0x0062,	"Merge_Range_List" },
		{ 0x0063,	"Substract_Range_List" },
		{ 0x0064,	"Set_DevNode_PowerState"	},
		{ 0x0065,	"Get_DevNode_PowerState"	},
		{ 0x0066,	"Set_DevNode_PowerCapabilities" },
		{ 0x0067,	"Get_DevNode_PowerCapabilities" },
		{ 0x0068,	"Read_Range_List" },
		{ 0x0069,	"Write_Range_List" },
		{ 0x006a,	"Get_Log_Conf_Priority" },
		{ 0x006b,	"Support_Share_Irq"	},
		{ 0x006c,	"Get_Parent_Structure" },
		{ 0x006d,	"Register_DevNode_For_Idle_Detection" },
		{ 0x006e,	"CM_To_ISAPNP"	},
		{ 0x006f,	"Get_DevNode_Handler" },
		{ 0x0070,	"Detect_Resource_Conflict" },
		{ 0x0071,	"Get_Device_Interface_List" },
		{ 0x0072,	"Get_Device_Interface_List_Size" },
		{ 0x0073,	"Get_Conflict_Info"	},
		{ 0x0074,	"Add_Remove_DevNode_Property"	},
		{ 0x0075,	"CallBack_At_Appy_Time" },
		{ 0x0076,	"Register_Device_Interface" },
		{ 0x0077,	"System_Device_Power_State_Mapping" },
		{ 0x0078,	"Get_Arbitrator_Info" },
		{ 0x0079,	"Waking_Up_From_DevNode"	},
		{ 0x007a,	"Set_DevNode_Problem" },
		{ 0x007b,	"Get_Device_Interface_Alias" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_cm_services[]	= {
		{ 0x0000,	"GetVersion" },
		{ 0x0001,	"GetConfig" },
		{ 0x0002,	"LockConfig" },
		{ 0x0003,	"UnlockConfig"	},
		{ 0x0004,	"CME_QueryResources" },
		{ 0x0005,	"CME_AllocResources" },
		{ 0x0006,	"CME_DeallocResources" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vfbackup_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Lock_NEC" },
		{ 0x0002,	"UnLock_NEC" },
		{ 0x0003,	"Register_NEC"	},
		{ 0x0004,	"Register_VFD"	},
		{ 0x0005,	"Lock_All_Ports" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vmini_services[] =	{
		{ 0x0000,	"GetVersion" },
		{ 0x0001,	"Update" },
		{ 0x0002,	"Status" },
		{ 0x0003,	"DisplayError"	},
		{ 0x0004,	"SetTimeStamp"	},
		{ 0x0005,	"Siren" },
		{ 0x0006,	"RegisterAccess" },
		{ 0x0007,	"GetData"	},
		{ 0x0008,	"ShutDownItem"	},
		{ 0x0009,	"RegisterSK" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vcond_services[] =	{
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Launch_ConApp_Inherited" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_wsock_services[] =	{
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Register" },
		{ 0x0002,	"Deregister" },
		{ 0x0003,	"SignalNotify"	},
		{ 0x0004,	"SignalAllNotify" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_ifsmgr_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"RegisterMount" },
		{ 0x0002,	"RegisterNet" },
		{ 0x0003,	"RegisterMailSlot" },
		{ 0x0004,	"Attach" },
		{ 0x0005,	"Detach" },
		{ 0x0006,	"Get_NetTime" },
		{ 0x0007,	"Get_DOSTime" },
		{ 0x0008,	"SetupConnection" },
		{ 0x0009,	"DerefConnection" },
		{ 0x000a,	"ServerDOSCall" },
		{ 0x000b,	"CompleteAsync" },
		{ 0x000c,	"RegisterHeap"	},
		{ 0x000d,	"GetHeap"	},
		{ 0x000e,	"RetHeap"	},
		{ 0x000f,	"CheckHeap" },
		{ 0x0010,	"CheckHeapItem" },
		{ 0x0011,	"FillHeapSpare" },
		{ 0x0012,	"Block" },
		{ 0x0013,	"Wakeup" },
		{ 0x0014,	"Yield" },
		{ 0x0015,	"SchedEvent" },
		{ 0x0016,	"QueueEvent" },
		{ 0x0017,	"KillEvent" },
		{ 0x0018,	"FreeIOReq" },
		{ 0x0019,	"MakeMailSlot"	},
		{ 0x001a,	"DeleteMailSlot" },
		{ 0x001b,	"WriteMailSlot" },
		{ 0x001c,	"PopUp" },
		{ 0x001d,	"printf" },
		{ 0x001e,	"AssertFailed"	},
		{ 0x001f,	"LogEntry" },
		{ 0x0020,	"DebugMenu" },
		{ 0x0021,	"DebugVars" },
		{ 0x0022,	"GetDebugString" },
		{ 0x0023,	"GetDebugHexNum" },
		{ 0x0024,	"NetFunction" },
		{ 0x0025,	"DoDelAllUses"	},
		{ 0x0026,	"SetErrString"	},
		{ 0x0027,	"GetErrString"	},
		{ 0x0028,	"SetReqHook" },
		{ 0x0029,	"SetPathHook" },
		{ 0x002a,	"UseAdd" },
		{ 0x002b,	"UseDel" },
		{ 0x002c,	"InitUseAdd" },
		{ 0x002d,	"ChangeDir" },
		{ 0x002e,	"DelAllUses" },
		{ 0x002f,	"CDROM_Attach"	},
		{ 0x0030,	"CDROM_Detach"	},
		{ 0x0031,	"Win32DupHandle" },
		{ 0x0032,	"Ring0_FileIO"	},
		{ 0x0033,	"Toggle_Extended_File_Handles" },
		{ 0x0034,	"Get_Drive_Info" },
		{ 0x0035,	"Ring0GetDriveInfo"	},
		{ 0x0036,	"BlockNoEvents" },
		{ 0x0037,	"NetToDosTime"	},
		{ 0x0038,	"DosToNetTime"	},
		{ 0x0039,	"DosToWin32Time" },
		{ 0x003a,	"Win32ToDosTime" },
		{ 0x003b,	"NetToWin32Time" },
		{ 0x003c,	"Win32ToNetTime" },
		{ 0x003d,	"MetaMatch" },
		{ 0x003e,	"TransMatch" },
		{ 0x003f,	"CallProvider"	},
		{ 0x0040,	"UniToBCS" },
		{ 0x0041,	"UniToBCSPath"	},
		{ 0x0042,	"BCSToUni" },
		{ 0x0043,	"UniToUpper" },
		{ 0x0044,	"UniCharToOEM"	},
		{ 0x0045,	"CreateBasis" },
		{ 0x0046,	"MatchBasisName" },
		{ 0x0047,	"AppendBasisTail" },
		{ 0x0048,	"FcbToShort" },
		{ 0x0049,	"ShortToFcb" },
		{ 0x004a,	"ParsePath" },
		{ 0x004b,	"Query_PhysLock" },
		{ 0x004c,	"VolFlush" },
		{ 0x004d,	"NotifyVolumeArrival" },
		{ 0x004e,	"NotifyVolumeRemoval" },
		{ 0x004f,	"QueryVolumeRemoval" },
		{ 0x0050,	"FSDUnmountCFSD" },
		{ 0x0051,	"GetConversionTablePtrs"	},
		{ 0x0052,	"CheckAccessConflict" },
		{ 0x0053,	"LockFile" },
		{ 0x0054,	"UnlockFile" },
		{ 0x0055,	"RemoveLocks" },
		{ 0x0056,	"CheckLocks" },
		{ 0x0057,	"CountLocks" },
		{ 0x0058,	"ReassignLockFileInst" },
		{ 0x0059,	"UnassignLockList" },
		{ 0x005a,	"MountChildVolume" },
		{ 0x005b,	"UnmountChildVolume" },
		{ 0x005c,	"SwapDrives" },
		{ 0x005d,	"FSDMapFHtoIOREQ" },
		{ 0x005e,	"FSDParsePath"	},
		{ 0x005f,	"FSDAttachSFT"	},
		{ 0x0060,	"GetTimeZoneBias" },
		{ 0x0061,	"PNPEvent" },
		{ 0x0062,	"RegisterCFSD"	},
		{ 0x0063,	"Win32MapExtendedHandleToSFT"	},
		{ 0x0064,	"DbgSetFileHandleLimit" },
		{ 0x0065,	"Win32MapSFTToExtendedHandle"	},
		{ 0x0066,	"FSDGetCurrentDrive" },
		{ 0x0067,	"InstallFileSystemApiHook" },
		{ 0x0068,	"RemoveFileSystemApiHook" },
		{ 0x0069,	"RunScheduledEvents" },
		{ 0x006a,	"CheckDelResource" },
		{ 0x006b,	"Win32GetVMCurdir" },
		{ 0x006c,	"SetupFailedConnection" },
		{ 0x006d,	"GetMappedErr"	},
		{ 0x006e,	"ShortToLossyFcb" },
		{ 0x006f,	"GetLockState"	},
		{ 0x0070,	"BcsToBcs" },
		{ 0x0071,	"SetLoopback" },
		{ 0x0072,	"ClearLoopback" },
		{ 0x0073,	"ParseOneElement" },
		{ 0x0074,	"BcsToBcsUpper" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_pci_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Read_Config" },
		{ 0x0002,	"Write_Config"	},
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_perf_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Server_Register" },
		{ 0x0002,	"Server_Deregister"	},
		{ 0x0003,	"Server_Add_Stat" },
		{ 0x0004,	"Server_Remove_Stat" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_mtrr_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"SetPhysicalCacheTypeRange" },
		{ 0x0002,	"IsPatSupported" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_ntkern_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"CreateFile" },
		{ 0x0002,	"Close" },
		{ 0x0003,	"ReadFile" },
		{ 0x0004,	"WriteFile" },
		{ 0x0005,	"DeviceIoControl" },
		{ 0x0006,	"GetWorkerThread" },
		{ 0x0007,	"LoadDriver" },
		{ 0x0008,	"QueueWorkItem" },
		{ 0x0009,	"PhysicalDeviceObjectToDevNode" },
		{ 0x000a,	"SetPhysicalCacheTypeRange" },
		{ 0x000b,	"Win9XLoadDriver" },
		{ 0x000c,	"CancelIoFile"	},
		{ 0x000d,	"GetVPICDHandleFromInterruptObj" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_acpi_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"SetSystemPowerState" },
		{ 0x0002,	"SetTimingMode" },
		{ 0x0003,	"RegisterOpRegionCookedHandler" },
		{ 0x0004,	"Set_RTC"	},
		{ 0x0005,	"GetTimingMode" },
		{ 0x0006,	"GetTaskFile" },
		{ 0x0007,	"WalkNameSpace" },
		{ 0x0008,	"GetObject" },
		{ 0x0009,	"NameSpaceToDevNode" },
		{ 0x000a,	"DevNodeToNameSpace" },
		{ 0x000b,	"RunControlMethod" },
		{ 0x000f,	"EvalPackageElement" },
		{ 0x0010,	"EvalPkgDataElement" },
		{ 0x0011,	"FreeDataBuffs" },
		{ 0x0014,	"GetNameSpaceObject" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_smclib_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"SmartcardCreateLink" },
		{ 0x0002,	"SmartcardDeleteLink" },
		{ 0x0003,	"SmartcardDeviceControl"	},
		{ 0x0004,	"SmartcardExit" },
		{ 0x0005,	"SmartcardInitialize" },
		{ 0x0006,	"SmartcardLogError"	},
		{ 0x0007,	"SmartcardRawReply"	},
		{ 0x0008,	"SmartcardRawRequest" },
		{ 0x0009,	"SmartcardT0Reply" },
		{ 0x000a,	"SmartcardT0Request" },
		{ 0x000b,	"SmartcardT1Reply" },
		{ 0x000c,	"SmartcardT1Request" },
		{ 0x000d,	"SmartcardUpdateCardCapabilities" },
		{ 0x000e,	"SmartcardGetDebugLevel"	},
		{ 0x000f,	"SmartcardSetDebugLevel"	},
		{ 0x0010,	"MapNtStatusToWinError" },
		{ 0x0011,	"Assert" },
		{ 0x0012,	"VxD_CreateDevice" },
		{ 0x0013,	"VxD_DeleteDevice" },
		{ 0x0014,	"SmartcardCompleteCardTracking" },
		{ 0x0015,	"SmartcardCompleteRequest" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vflatd_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Unmap_Flat_Selector" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vjoyd_services[] =	{
		{ 0x0000,	"Register_Device_Driver"	},
		{ 0x0001,	"GetPosEx_Service" },
		{ 0x0002,	"GetInitParams_Service" },
		{ 0x0003,	"Poll_Service"	},
		{ 0x0004,	"Escape_Service" },
		{ 0x0005,	"CtrlMsg_Service" },
		{ 0x0006,	"SetGain_Service" },
		{ 0x0007,	"SendFFCommand_Service" },
		{ 0x0008,	"GetFFState_Service" },
		{ 0x0009,	"DownloadEffect_Service"	},
		{ 0x000a,	"DestroyEffect_Service" },
		{ 0x000b,	"StartEffect_Service" },
		{ 0x000c,	"StopEffect_Service" },
		{ 0x000d,	"GetEffectStatus_Service" },
		{ 0x000e,	"DeviceUpdateNotify_Service" },
		{ 0x000f,	"JoystickActivity_Service" },
		{ 0x0010,	"OpenTypeKey_Service" },
		{ 0x0011,	"OpenConfigKey_Service" },
		{ 0x0012,	"NewGameportDevNode" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_mmdevldr_services[] = {
		{ 0x0000,	"Register_Device_Driver"	},
		{ 0x0001,	"SetDevicePresence"	},
		{ 0x0002,	"SetEnvironmentString" },
		{ 0x0003,	"GetEnvironmentString" },
		{ 0x0004,	"RemoveEnvironmentString" },
		{ 0x0005,	"AddEnvironmentString" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vnetsup_services[]	= {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"GetVars"	},
		{ 0x0002,	"RegisterTerm"	},
		{ 0x0003,	"SetInfo"	},
		{ 0x0004,	"ServerHook" },
		{ 0x0005,	"PassEncrypt" },
		{ 0x0006,	"PassEncryptNT" },
		{ 0x0007,	"PassEncrypt2"	},
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vredir_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"BcnSetWfWVersion" },
		{ 0x0002,	"BcnSetWfWBits" },
		{ 0x0003,	"BcnIncWfWCount" },
		{ 0x0004,	"BcnTriggerPulse" },
		{ 0x0005,	"BcnWfWBrowser" },
		{ 0x0006,	"BcnSetMaster"	},
		{ 0x0007,	"SendMessage" },
		{ 0x0008,	"SetRemoteDebug" },
		{ 0x0009,	"ValidateUser"	},
		{ 0x000a,	"ConnectServer" },
		{ 0x000b,	"DisconnectServer" },
		{ 0x000c,	"RemoteMailSlotWrite" },
		{ 0x000d,	"NetInfo"	},
		{ 0x000e,	"BcnSetHook" },
		{ 0x000f,	"UserGetGroups" },
		{ 0x0010,	"SetIPXError" },
		{ 0x0011,	"NetGetDfsReferrals" },
		{ 0x0012,	"AddPathElement" },
		{ 0x0013,	"MakeResourceDfs" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vshare_services[] = {
		{ 0x0000,	"Get_Version" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vtdi_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Start_Timer" },
		{ 0x0002,	"Stop_Timer" },
		{ 0x0003,	"Schedule_Event" },
		{ 0x0004,	"Cancel_Event"	},
		{ 0x0005,	"Block" },
		{ 0x0006,	"Signal" },
		{ 0x0007,	"Register" },
		{ 0x0008,	"Get_Info" },
		{ 0x0009,	"Unload" },
		{ 0x000a,	"Initialize" },
		{ 0x000b,	"Register_UnloadProc" },
		{ 0x000c,	"Register_LoadProc"	},
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vip_services[] = {
		{ 0x0000,	"VIP_Get_Version" },
		{ 0x0001,	"VIP_Get_Net_Info" },
		{ 0x0002,	"VIP_Register_Protocol" },
		{ 0x0003,	"VIP_Register_Driver" },
		{ 0x0004,	"VIP_Set_Addr"	},
		{ 0x0005,	"VIP_ICMP_Echo" },
		{ 0x0006,	"VIP_Register_Addr_Change" },
		{ 0x0007,	"VIP_Set_DCHP_Interface"	},
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_mstcp_services[] =	{
		{ 0x0000,	"Get_Version" },
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_vcache_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Register" },
		{ 0x0002,	"GetSize"	},
		{ 0x0003,	"CheckAvail" },
		{ 0x0004,	"FindBlock" },
		{ 0x0005,	"FreeBlock" },
		{ 0x0006,	"MakeMRU"	},
		{ 0x0007,	"Hold" },
		{ 0x0008,	"Unhold" },
		{ 0x0009,	"Enum" },
		{ 0x000a,	"TestHandle" },
		{ 0x000b,	"VerifySums" },
		{ 0x000c,	"RecalcSums" },
		{ 0x000d,	"TestHold" },
		{ 0x000e,	"GetStats" },
		{ 0x000f,	"Deregister" },
		{ 0x0010,	"AdjustMinimum" },
		{ 0x0011,	"SwapBuffers" },
		{ 0x0012,	"RelinquishPage" },
		{ 0x0013,	"UseThisPage" },
		{ 0x0014,	"CreateLookupCache"	},
		{ 0x0015,	"CloseLookupCache" },
		{ 0x0016,	"DeleteLookupCache"	},
		{ 0x0017,	"Lookup" },
		{ 0x0018,	"UpdateLookup"	},
		{ -1 }			/* Terminator */
};

vxd_service_desc vxd_pccard_services[] = {
		{ 0x0000,	"Get_Version" },
		{ 0x0001,	"Card_Services" },
		{ 0x0002,	"Access_CIS_Memory"	},
		{ -1 }			/* Terminator */
};
ht-2.0.22/htnewexe.h0000644000175000001440000000153310615341623011130 00000000000000/* 
 *	HT Editor
 *	htnewexe.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTNEWEXE_H__
#define __HTNEWEXE_H__

#include "stream.h"

FileOfs get_newexe_header_ofs(File *file);

#endif /* !__HTNEWEXE_H__ */
ht-2.0.22/str.h0000644000175000001440000001676711010140021010103 00000000000000/*
 *	HT Editor
 *	str.h
 *
 *	Copyright (C) 2002 Stefan Weyergraf (stefan@weyergraf.de)
 *	Copyright (C) 2002, 2003 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __STR_H__
#define __STR_H__

#include "data.h"

enum StringCase {
	stringCaseLower,
	stringCaseUpper,
	stringCaseCaps
};

/**
 *	Class for easy string handling.
 */
class String: public Object {
protected:
	int mLength;
	byte *mContent;
public:
				String(BuildCtorArg &a): Object(a) {};
				String();
				String(const char *s);
				String(const String *s);
				String(const String &s);
				String(const byte *s, int aLength);
				String(char c, int count = 1);
	virtual			~String();

		void		assign(const String *s);
		void		assign(const String &s);
		void		assign(const char *s);
		void		assign(const byte *s, int aLength);
		void		assign(char c, int count = 1);
		void		assignFormat(const char *s, ...);

		void		append(const String &s);
		void		append(const char *s);
		void		append(const byte *s, int aLength);
		void		appendChar(char c);
		void		appendFormat(const char *s, ...);
	inline	char &		at(int aIndex) const;
	inline	bool		chop();
		void		clear();
	virtual	String *	clone() const;
	virtual	int		compareChar(char c1, char c2) const;
	virtual	int		compareTo(const Object *o) const;
		int		compare(const String &s) const;
		int		compare(const String &s, int aMax) const;
	inline	byte *		content() const;
	inline	char *		contentChar() const;
		uint		countChar(char c) const;
		void		crop(int aNewLength);
		void		del(int pos, int aLength);
		void		escape(const char *aSpecialChars, bool bit7 = true);
	virtual	int		findCharFwd(char c, int start = -1, int ith_match = 0) const;
	virtual	int		findStringFwd(const String &s, int start = -1, int ith_match = 0) const;
	virtual	int		findCharBwd(char c, int start = -1, int ith_match = 0) const;
	virtual	int		findStringBwd(const String &s, int start = -1, int ith_match = 0) const;
	inline	char		firstChar() const;
		void		insert(const String &s, int pos);
	inline	bool		isEmpty() const;
	virtual	void		load(ObjectStream &s);
	virtual	ObjectID	getObjectID() const;
		void		grab(String &s);
		byte *		grabContent();
		char *		grabContentChar();
	virtual	void		store(ObjectStream &s) const;
	inline	char		lastChar() const;
	inline	int		length() const;
		bool		leftSplit(char chr, String &initial, String &rem) const;
		void		prepend(const String &s);
		bool		regexMatch(const String &aRegEx, Container *resultStrings = NULL) const;
//		bool		regexReplace(const String &aRegEx, Container *resultStrings = NULL) const;
		int		replace(String &what, String &with);
		bool		rightSplit(char chr, String &initial, String &rem) const;
		int		subString(int aStart, int aLength, String &result) const;
		void		transformCase(StringCase c);
		void		translate(const String &inAlpha, const String &outAlpha);
	virtual	int		toArray(byte *buf, int buflen) const;
		bool		toInt32(uint32 &u32, int defaultbase) const;
		bool		toInt64(uint64 &u64, int defaultbase) const;
	virtual	int		toString(char *buf, int buflen) const;
	virtual	char *		toString() const;
		void		unescape();

	inline	char &	operator [](int aIndex) const;

	inline	String &	operator =(const String &s);
	inline	String &	operator =(const char *s);
	inline	String &	operator +=(const String &s);
	inline	String &	operator +=(const char *s);
		String &	operator +=(char c);
			
	inline	bool		operator < (const String &s) const;
	inline	bool		operator > (const String &s) const;
	inline	bool		operator <=(const String &s) const;
	inline	bool		operator >=(const String &s) const;
	inline	bool		operator ==(const String &s) const;
	inline	bool		operator !=(const String &s) const;

	inline	bool		operator < (const char *s) const;
	inline	bool		operator > (const char *s) const;
	inline	bool		operator <=(const char *s) const;
	inline	bool		operator >=(const char *s) const;
	inline	bool		operator ==(const char *s) const;
	inline	bool		operator !=(const char *s) const;
protected:
		int		compare(const char *s) const;
		void		realloc(int aNewSize);
};

String operator +(const String &s1, const String &s2);
String operator +(const char *s1, const String &s2);

/**
 *	case-insensitive string.
 */
class IString: public String {
public:
				IString(BuildCtorArg &a): String(a) {};
				IString();

	virtual	IString *	clone() const;
	virtual	int		compareChar(char c1, char c2) const;
	virtual	ObjectID	getObjectID() const;
};

/*
 *	inline functions
 */

//class MsgException;

/**
 *	@returns char at position |aIndex|
 *	@throws exception if aIndex out of bounds
 */
inline char &String::at(int aIndex) const
{
//	if ((uint)aIndex >= (uint)mLength) throw new MsgException("index out of bounds");
	return (char &)mContent[aIndex];
}

/**
 *	Removes the last character of the string if string length is non-zero.
 */
inline bool String::chop()
{
	if (mLength) {
		crop(mLength-1);
		return true;
	} else {
		return false;
	}
}

/**
 *	@returns a string content ptr
 */
inline byte *String::content() const
{
	return mContent;
}
 
/**
 *	@returns a string content ptr (as char*)
 */
inline char *String::contentChar() const
{
	return (char*)mContent;
}
 
/**
 *	@returns first character of string
 *	@throws exception if string is empty
 */
inline char String::firstChar() const
{
	return at(0);
}

/**
 *	@returns true if string is empty.
 */
inline bool String::isEmpty() const
{
	return mLength == 0;
}

/**
 *	@returns last character of string
 *	@throws exception if string is empty
 */
inline char String::lastChar() const
{
	return at(mLength-1);
}

/**
 *	@returns length of string
 */
inline int String::length() const
{
	return mLength;
}

inline char &String::operator [](int aIndex) const
{
	return at(aIndex);
}

inline String &String::operator =(const String &s)
{
	assign(s);
	return *this;
}

inline String &String::operator =(const char *s)
{
	assign(s);
	return *this;
}

inline String &String::operator +=(const String &s)
{
	append(s);
	return *this;
}

inline String &String::operator +=(const char *s)
{
	append(s);
	return *this;
}

inline bool String::operator < (const String &s) const
{
	return compare(s) < 0;
}

inline bool String::operator <= (const String &s) const
{
	return compare(s) <= 0;
}

inline bool String::operator > (const String &s) const
{
	return compare(s) > 0;
}

inline bool String::operator >= (const String &s) const
{
	return compare(s) >= 0;
}

inline bool String::operator == (const String &s) const
{
	return compare(s) == 0;
}

inline bool String::operator != (const String &s) const
{
	return compare(s) != 0;
}

inline bool String::operator < (const char *s) const
{
	return compare(s) < 0;
}

inline bool String::operator <= (const char *s) const
{
	return compare(s) <= 0;
}

inline bool String::operator > (const char *s) const
{
	return compare(s) > 0;
}

inline bool String::operator >= (const char *s) const
{
	return compare(s) >= 0;
}

inline bool String::operator == (const char *s) const
{
	return compare(s) == 0;
}

inline bool String::operator != (const char *s) const
{
	return compare(s) != 0;
}
#endif
ht-2.0.22/cp-demangle.h0000644000175000001440000001257211510433406011456 00000000000000/* Internal demangler interface for g++ V3 ABI.
   Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010
   Free Software Foundation, Inc.
   Written by Ian Lance Taylor .

   This file is part of the libiberty library, which is part of GCC.

   This file is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   In addition to the permissions in the GNU General Public License, the
   Free Software Foundation gives you unlimited permission to link the
   compiled version of this file into combinations with other programs,
   and to distribute those combinations without any restriction coming
   from the use of this file.  (The General Public License restrictions
   do apply in other respects; for example, they cover modification of
   the file, and distribution when not linked into a combined
   executable.)

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. 
*/

/* This file provides some definitions shared by cp-demangle.c and
   cp-demint.c.  It should not be included by any other files.  */

/* Information we keep for operators.  */

struct demangle_operator_info
{
  /* Mangled name.  */
  const char *code;
  /* Real name.  */
  const char *name;
  /* Length of real name.  */
  int len;
  /* Number of arguments.  */
  int args;
};

/* How to print the value of a builtin type.  */

enum d_builtin_type_print
{
  /* Print as (type)val.  */
  D_PRINT_DEFAULT,
  /* Print as integer.  */
  D_PRINT_INT,
  /* Print as unsigned integer, with trailing "u".  */
  D_PRINT_UNSIGNED,
  /* Print as long, with trailing "l".  */
  D_PRINT_LONG,
  /* Print as unsigned long, with trailing "ul".  */
  D_PRINT_UNSIGNED_LONG,
  /* Print as long long, with trailing "ll".  */
  D_PRINT_LONG_LONG,
  /* Print as unsigned long long, with trailing "ull".  */
  D_PRINT_UNSIGNED_LONG_LONG,
  /* Print as bool.  */
  D_PRINT_BOOL,
  /* Print as float--put value in square brackets.  */
  D_PRINT_FLOAT,
  /* Print in usual way, but here to detect void.  */
  D_PRINT_VOID
};

/* Information we keep for a builtin type.  */

struct demangle_builtin_type_info
{
  /* Type name.  */
  const char *name;
  /* Length of type name.  */
  int len;
  /* Type name when using Java.  */
  const char *java_name;
  /* Length of java name.  */
  int java_len;
  /* How to print a value of this type.  */
  enum d_builtin_type_print print;
};

/* The information structure we pass around.  */

struct d_info
{
  /* The string we are demangling.  */
  const char *s;
  /* The end of the string we are demangling.  */
  const char *send;
  /* The options passed to the demangler.  */
  int options;
  /* The next character in the string to consider.  */
  const char *n;
  /* The array of components.  */
  struct demangle_component *comps;
  /* The index of the next available component.  */
  int next_comp;
  /* The number of available component structures.  */
  int num_comps;
  /* The array of substitutions.  */
  struct demangle_component **subs;
  /* The index of the next substitution.  */
  int next_sub;
  /* The number of available entries in the subs array.  */
  int num_subs;
  /* The number of substitutions which we actually made from the subs
     array, plus the number of template parameter references we
     saw.  */
  int did_subs;
  /* The last name we saw, for constructors and destructors.  */
  struct demangle_component *last_name;
  /* A running total of the length of large expansions from the
     mangled name to the demangled name, such as standard
     substitutions and builtin types.  */
  int expansion;
};

/* To avoid running past the ending '\0', don't:
   - call d_peek_next_char if d_peek_char returned '\0'
   - call d_advance with an 'i' that is too large
   - call d_check_char(di, '\0')
   Everything else is safe.  */
#define d_peek_char(di) (*((di)->n))
#define d_peek_next_char(di) ((di)->n[1])
#define d_advance(di, i) ((di)->n += (i))
#define d_check_char(di, c) (d_peek_char(di) == c ? ((di)->n++, 1) : 0)
#define d_next_char(di) (d_peek_char(di) == '\0' ? '\0' : *((di)->n++))
#define d_str(di) ((di)->n)

/* Functions and arrays in cp-demangle.c which are referenced by
   functions in cp-demint.c.  */
#ifdef IN_GLIBCPP_V3
#define CP_STATIC_IF_GLIBCPP_V3 static
#else
#define CP_STATIC_IF_GLIBCPP_V3 extern
#endif

#ifndef IN_GLIBCPP_V3
extern const struct demangle_operator_info cplus_demangle_operators[];
#endif

#define D_BUILTIN_TYPE_COUNT (33)

CP_STATIC_IF_GLIBCPP_V3
const struct demangle_builtin_type_info
cplus_demangle_builtin_types[D_BUILTIN_TYPE_COUNT];

CP_STATIC_IF_GLIBCPP_V3
struct demangle_component *
cplus_demangle_mangled_name (struct d_info *, int);

CP_STATIC_IF_GLIBCPP_V3
struct demangle_component *
cplus_demangle_type (struct d_info *);

extern void
cplus_demangle_init_info (const char *, int, size_t, struct d_info *);

/* cp-demangle.c needs to define this a little differently */
#undef CP_STATIC_IF_GLIBCPP_V3
ht-2.0.22/htreg.h0000644000175000017500000001525712127651417010433 00000000000000/* 
 *	HT Editor
 *	htreg.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTREG_H__
#define __HTREG_H__

#include "data.h"
#include "strtools.h"

/*
 *	CLASS ht_registry_data
 */

class ht_registry_data: public Object {
public:
/* new */
		ht_registry_data() {};
		ht_registry_data(BuildCtorArg&a): Object(a) {};
	virtual	bool editdialog(const char *keyname);
	virtual void strvalue(char *buf32bytes);
};

/*
 *	CLASS ht_registry_data_stree
 */

class ht_registry_data_stree: public ht_registry_data {
public:
	Container *tree;

			ht_registry_data_stree(AVLTree *aTree);
			ht_registry_data_stree(BuildCtorArg&a): ht_registry_data(a) {};
			~ht_registry_data_stree();
/* overwritten */
	virtual	void load(ObjectStream &f);
	virtual	ObjectID getObjectID() const;
	virtual	void store(ObjectStream &f) const;
	virtual	void strvalue(char *buf32bytes);
};

/*
 *	CLASS ht_registry_data_dword
 */

class ht_registry_data_dword: public ht_registry_data {
public:
	uint32 value;

		ht_registry_data_dword(uint32 value);
		ht_registry_data_dword(BuildCtorArg&a): ht_registry_data(a) {};
/* overwritten */
	virtual	bool editdialog(const char *keyname);
	virtual	void load(ObjectStream &f);
	virtual	ObjectID getObjectID() const;
	virtual	void store(ObjectStream &f) const;
	virtual	void strvalue(char *buf32bytes);
};

/*
 *	CLASS ht_registry_data_raw
 */

class ht_registry_data_raw: public ht_registry_data {
public:
	void *value;
	uint size;

			ht_registry_data_raw(const void *value, uint size);
			ht_registry_data_raw(BuildCtorArg&a): ht_registry_data(a) {};
			~ht_registry_data_raw();
/* overwritten */
	virtual	bool editdialog(const char *keyname);
	virtual	void load(ObjectStream &f);
	virtual	ObjectID getObjectID() const;
	virtual	void store(ObjectStream &f) const;
	virtual	void strvalue(char *buf32bytes);
};

/*
 *	CLASS ht_registry_data_string
 */

class ht_registry_data_string: public ht_registry_data {
public:
	char *value;

		ht_registry_data_string(const char *s);
		ht_registry_data_string(BuildCtorArg&a): ht_registry_data(a) {};
		~ht_registry_data_string();
/* overwritten */
	virtual	bool editdialog(const char *keyname);
	virtual	void load(ObjectStream &f);
	virtual	ObjectID getObjectID() const;
	virtual	void store(ObjectStream &f) const;
	virtual	void strvalue(char *buf32bytes);
};

/*
 *	CLASS ht_registry_node
 */

typedef ht_registry_data* (*create_empty_registry_data_func)();

typedef uint ht_registry_node_type;

class ht_registry_node_type_desc: public Object {
public:
	char *name;
	ht_registry_node_type type;
	create_empty_registry_data_func create_empty_registry_data;
	
	ht_registry_node_type_desc(ht_registry_node_type t, const char *name, create_empty_registry_data_func c);
	ht_registry_node_type_desc(BuildCtorArg&a): Object(a) {};
	virtual ~ht_registry_node_type_desc();
	virtual int compareTo(const Object *) const;
	virtual	void load(ObjectStream &f);
	virtual	ObjectID getObjectID() const;
	virtual	void store(ObjectStream &f) const;
};

#define RNT_INVALID		0	/* returned by some functions */
// these are predefined
#define RNT_SUBDIR		1
#define RNT_SYMLINK		2
#define RNT_DWORD  		3
#define RNT_STRING 		4
#define RNT_RAW		5

#define RNT_USER    	0x100
// the rest may be allocated dynamically

class ht_registry_node: public Object {
public:
	char *name;
	ht_registry_node_type type;
	ht_registry_data *data;

	ht_registry_node(ht_registry_node_type type, const char *name, ht_registry_data *data);
	ht_registry_node(BuildCtorArg&a): Object(a) {};
	virtual ~ht_registry_node();
/* overwritten */
	virtual int compareTo(const Object *) const;
	virtual	void load(ObjectStream &f);
	virtual	void store(ObjectStream &f) const;
	virtual	ObjectID getObjectID() const;
};

/*
 *	CLASS ht_registry
 */

#define MAX_SYMLINK_REC_DEPTH 20

class ht_registry: public Object {
protected:
	ht_registry_node *root;
	uint rec_depth;

			ht_registry_node *find_entry_i(Container **dir, const char *key, bool follow_symlinks);
			ht_registry_node *find_entry_get_node(Container *dir, const char *nodename);
			ht_registry_node *find_entry_get_subdir(Container *dir, const char *nodename);
			ht_registry_node *find_entry_get_data(Container *dir, const char *nodename, bool follow_symlinks);
			bool splitfind(const char *key, const char **name, ht_registry_node **node);
public:
	Container *node_types;

		ht_registry() {};
		ht_registry(BuildCtorArg&a): Object(a) {};
		void init();
	virtual	void done();
/* new */
		int create_node(const char *key, ht_registry_node_type type);
		int create_subdir(const char *key);
		int delete_node(const char *key);
		ht_registry_node *enum_next(const char *dir, ht_registry_node *prevkey);
		ht_registry_node *enum_prev(const char *dir, ht_registry_node *nextkey);
			
		bool find_any_entry(const char *key, ht_registry_node **node);
		bool find_data_entry(const char *key, ht_registry_node **node, bool follow_symlinks, Container **dir = NULL);
		/* node type*/
		ht_registry_node_type lookup_node_type(const char *identifier);
		ht_registry_node_type_desc *get_node_type_desc(ht_registry_node_type t, const char **identifier);
		ht_registry_node_type have_node_type(const char *identifier, create_empty_registry_data_func create_empty_registry_data);
		ht_registry_node_type register_node_type(const char *identifier, create_empty_registry_data_func create_empty_registry_data);
		/**/
		int set_dword(const char *key, uint32 d);
		int set_raw(const char *key, const void *data, uint size);
		int set_node(const char *key, ht_registry_node_type type, ht_registry_data *data);
		int set_string(const char *key, const char *string);
		int set_symlink(const char *key, const char *dest);
		bool valid_nodename(const char *nodename);
/* overwritten */
	virtual	void load(ObjectStream &f);
	virtual	void store(ObjectStream &f) const;
	virtual	ObjectID getObjectID() const;
/* debug */
			void debug_dump();
			void debug_dump_i(FILE *f, Container *t, int ident);
};

uint32 get_config_dword(const char *ident, uint32 default_value=0);
char *get_config_string(const char *ident);

extern ht_registry *registry;

/*
 *	INIT
 */

bool init_registry();

/*
 *	DONE
 */

void done_registry();

#endif /* __HTREG_H__ */
ht-2.0.22/COPYING0000644000175000017500000004325412127651416010201 00000000000000                    GNU GENERAL PUBLIC LICENSE
                       Version 2, June 1991

 Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.

                            Preamble

  The licenses for most software are designed to take away your
freedom to share and change it.  By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.  This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it.  (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.)  You can apply it to
your programs, too.

  When we speak of free software, we are referring to freedom, not
price.  Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

  To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

  For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have.  You must make sure that they, too, receive or can get the
source code.  And you must show them these terms so they know their
rights.

  We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

  Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software.  If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

  Finally, any free program is threatened constantly by software
patents.  We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary.  To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

  The precise terms and conditions for copying, distribution and
modification follow.

                    GNU GENERAL PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License.  The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language.  (Hereinafter, translation is included without limitation in
the term "modification".)  Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope.  The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

  1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

  2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

    a) You must cause the modified files to carry prominent notices
    stating that you changed the files and the date of any change.

    b) You must cause any work that you distribute or publish, that in
    whole or in part contains or is derived from the Program or any
    part thereof, to be licensed as a whole at no charge to all third
    parties under the terms of this License.

    c) If the modified program normally reads commands interactively
    when run, you must cause it, when started running for such
    interactive use in the most ordinary way, to print or display an
    announcement including an appropriate copyright notice and a
    notice that there is no warranty (or else, saying that you provide
    a warranty) and that users may redistribute the program under
    these conditions, and telling the user how to view a copy of this
    License.  (Exception: if the Program itself is interactive but
    does not normally print such an announcement, your work based on
    the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole.  If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works.  But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

  3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

    a) Accompany it with the complete corresponding machine-readable
    source code, which must be distributed under the terms of Sections
    1 and 2 above on a medium customarily used for software interchange; or,

    b) Accompany it with a written offer, valid for at least three
    years, to give any third party, for a charge no more than your
    cost of physically performing source distribution, a complete
    machine-readable copy of the corresponding source code, to be
    distributed under the terms of Sections 1 and 2 above on a medium
    customarily used for software interchange; or,

    c) Accompany it with the information you received as to the offer
    to distribute corresponding source code.  (This alternative is
    allowed only for noncommercial distribution and only if you
    received the program in object code or executable form with such
    an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it.  For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable.  However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

  4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License.  Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

  5. You are not required to accept this License, since you have not
signed it.  However, nothing else grants you permission to modify or
distribute the Program or its derivative works.  These actions are
prohibited by law if you do not accept this License.  Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

  6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions.  You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

  7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License.  If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all.  For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices.  Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

  8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded.  In such case, this License incorporates
the limitation as if written in the body of this License.

  9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time.  Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number.  If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation.  If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

  10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission.  For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this.  Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

                            NO WARRANTY

  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

                     END OF TERMS AND CONDITIONS

            How to Apply These Terms to Your New Programs

  If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

  To do so, attach the following notices to the program.  It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

    
    Copyright (C)   

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

    Gnomovision version 69, Copyright (C) year name of author
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
    This is free software, and you are welcome to redistribute it
    under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License.  Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary.  Here is a sample; alter the names:

  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  `Gnomovision' (which makes passes at compilers) written by James Hacker.

  , 1 April 1989
  Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs.  If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library.  If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
ht-2.0.22/htleobj.h0000644000175000001440000000152610206756710010735 00000000000000/* 
 *	HT Editor
 *	htleobj.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTLEOBJ_H__
#define __HTLEOBJ_H__

#include "formats.h"

extern format_viewer_if htleobjects_if;

#endif /* !__HTLEIMG_H__ */

ht-2.0.22/htpeil.h0000644000175000001440000000304610615341623010567 00000000000000/* 
 *	HT Editor
 *	htpeil.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTPEIL_H__
#define __HTPEIL_H__

#include "data.h"
#include "formats.h"
#include "ilstruct.h"

extern format_viewer_if htpeil_if;

class ht_il_metadata_entry: public Object {
public:
	char *name;
	uint32 offset;
	uint32 size;
	ht_il_metadata_entry(const char *name, uint32 offset, uint32 size);
	~ht_il_metadata_entry();
};

class ht_pe_il: public Object {
public:
	PE_IL_DIRECTORY dir;
	IL_METADATA_SECTION metadata;
	Container *entries;
	uint32 string_pool_size;
	char *string_pool;
};

/*
 *	CLASS ht_pe_header_viewer
 */

class ht_pe_il_viewer: public ht_uformat_viewer {
public:
		void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *group);
	virtual void done();
};

int ILunpackDword(uint32 &result, const byte *buf, int len);
int ILunpackToken(uint32 &result, const byte *buf, int len);

#endif /* !__HTPEIL_H__ */
ht-2.0.22/htperes.h0000644000175000001440000000232310615341624010752 00000000000000/* 
 *	HT Editor
 *	htperes.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTPERES_H__
#define __HTPERES_H__

#include "httree.h"

/*
 *	CLASS ht_pe_resource_viewer
 */

class ht_pe_resource_viewer: public ht_static_treeview {
private:
/* new */
	virtual	Object *vstate_create();
		bool vstate_save();
	virtual	void vstate_restore(Object *d);
public:
		void init(Bounds *b, const char *desc);
	virtual	void done();
/* overwritten */
	virtual	void	handlemsg(htmsg *msg);
	virtual	void	select_node(void *node);
};

extern format_viewer_if htperesources_if;

#endif /* __HTPERES_H__ */
ht-2.0.22/tools.cc0000644000175000017500000000665211724443116010614 00000000000000/*
 *	HT Editor
 *	tools.cc
 *
 *	Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "tools.h"

#include "data.h"
#include "htdebug.h"
#include 
#include 
#include 
#include 

uint32 delinearize(uint32 d)
{
	return d*0x8088405+1;	/* there's magic in here... */
}

uint64 delinearize64(uint64 d)
{
	return (uint64(delinearize(d))<<32)| delinearize(d>>32); /* there's less magic in here... */
}

int compare_keys_uint_delinear(Object *key_a, Object *key_b)
{
	uint a = delinearize(((UInt*)key_a)->value);
	uint b = delinearize(((UInt*)key_b)->value);
	if (a>b) return 1; else if (a

#include "cmds.h"
#include "endianess.h"
#include "htctrl.h"
#include "htiobox.h"
#include "hthex.h"
#include "htmenu.h"
#include "htsearch.h"
#include "snprintf.h"
#include "stream.h"
#include "tools.h"

extern "C" {
#include "evalx.h"
#include "regex.h"
}

ht_view *hthex_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_hex_viewer *v = new ht_hex_viewer();
	v->init(b, DESC_HEX, VC_EDIT | VC_GOTO | VC_SEARCH | VC_REPLACE | VC_RESIZE, file, group);

	v->search_caps |= SEARCHMODE_BIN | SEARCHMODE_EVALSTR | SEARCHMODE_EXPR;

	v->h = new ht_hex_file_sub();
	v->h->init(file, 0, file->getSize(), 16, 0);

	v->insertsub(v->h);
	return v;
}

format_viewer_if hthex_if = {
	hthex_init,
	0
};

/*
 *	CLASS ht_hex_viewer
 */

int ht_hex_viewer::get_pindicator_str(char *buf, int max_len)
{
	FileOfs o;
	if (get_current_offset(&o)) {
		FileOfs sel_start, sel_end;
		pselect_get(&sel_start, &sel_end);
		char ttemp[1024];
		if (sel_end-sel_start > 0) {
			ht_snprintf(ttemp, sizeof ttemp, "selection %qxh-%qxh (%qd byte%s) ", sel_start, sel_end-1, sel_end-sel_start, sel_end-sel_start==1?"":"s");
		} else {
			ttemp[0] = 0;
		}
		return ht_snprintf(buf, max_len, " %s %qxh/%qu %s", edit() ? "edit" : "view", o, o, ttemp);
	} else {
		return ht_snprintf(buf, max_len, " ? ");
	}
}
	
bool ht_hex_viewer::get_vscrollbar_pos(int *pstart, int *psize)
{
	FileOfs s = file->getSize();
	if (s) {
		uint ll = h->get_line_length();
		FileOfs o = top.line_id.id2 + (uint64(top.line_id.id1) << 32);
		sint64 z = MIN(size.h * ll, s - o);
		return scrollbar_pos(o, z, s, pstart, psize);
	}
	return false;
}

void ht_hex_viewer::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
	case msg_filesize_changed:
		htmsg m;
		m.msg = msg_filesize_changed;
		m.type = mt_broadcast;
		sendsubmsg(&m);

		uf_initialized = false;
		complete_init();

		dirtyview();
		return;
	case cmd_hex_entropy: {
		FileOfs ofs;
		if (get_current_offset(&ofs)) {
			byte buf[64];
			if (pread(ofs, buf, 64)==64) {
				int e = calc_entropy2(buf, 64);
				infobox("64-byte entropy at offset 0x%08qx: %d %%", ofs, e);
			}
		}
		clearmsg(msg);
		return;
	}
	case cmd_hex_display_bytes: {
		char result[256];
		sprintf(result, "%d", h->get_line_length());
		if (inputbox("Change display width", "~Line length (Bytes)", result, 256)) {
			int ll = strtoul(result, NULL, 10);
			if (ll > 0 && ll <= 32) {
				FileOfs ofs = -1ULL;
				get_current_offset(&ofs);
				int disp = h->get_disp();
				if (disp >= ll) {
					h->set_disp(0);
				}
				h->set_line_length(ll);
				viewer_pos p;
				if (ofs != -1ULL && offset_to_pos(ofs, &p) && goto_pos(p, this)) {
					focus_cursor();
				}
			} else {
				errorbox("Line length must be > 0 and <= 32!");
			}
		}
		clearmsg(msg);
		return;
	}
	case cmd_hex_display_disp: {
		char result[256];
		sprintf(result, "%d", h->get_disp());
		if (inputbox("Change display displacement", "~Displacement (Bytes)", result, 256)) {
			int ll = h->get_line_length();
			int disp = strtoul(result, NULL, 10);
			if (disp >= 0 && disp < ll) {
				FileOfs ofs = -1ULL;
				get_current_offset(&ofs);
				h->set_disp(disp);
				viewer_pos p;
				if (ofs != -1ULL && offset_to_pos(ofs, &p) && goto_pos(p, this)) {
					focus_cursor();
				}
			} else {
				errorbox("Displacement must be >= 0 and < line length (%d)!", ll);
			}
		}
		clearmsg(msg);
		return;
	}
	case msg_contextmenuquery: {
		ht_static_context_menu *m = new ht_static_context_menu();
		m->init("~Local-Hex");
		m->insert_entry("~Block operations", "Ctrl+B", cmd_file_blockop, K_Control_B, 1);
		m->insert_entry("~Replace", "Ctrl+E", cmd_file_replace, K_Control_E, 1);
		m->insert_entry("~Entropy", "Ctrl+T", cmd_hex_entropy, K_Control_T, 1);
		m->insert_entry("Change display ~width...", "Ctrl+O", cmd_hex_display_bytes, K_Control_O, 1);
		m->insert_entry("Change display ~displacement...", "Ctrl+U", cmd_hex_display_disp, K_Control_U, 1);

		msg->msg = msg_retval;
		msg->data1.ptr = m;
		return;
	}
	}
	ht_uformat_viewer::handlemsg(msg);
}

bool ht_hex_viewer::pos_to_offset(viewer_pos p, FileOfs *ofs)
{
	*ofs = (uint64(p.u.line_id.id1) << 32) + p.u.line_id.id2 + p.u.tag_idx;
	return true;
}

bool ht_hex_viewer::offset_to_pos(FileOfs ofs, viewer_pos *p)
{
	uint ll = h->get_line_length();
	uint disp = h->get_disp();
	clear_viewer_pos(p);
	p->u.sub = first_sub;
	FileOfs id;
	if (ofs < disp) {
		id = 0;
		p->u.tag_idx = ofs;
	} else {
		id = ofs - ((ofs - disp) % ll);
		p->u.tag_idx = (ofs - disp) % ll;
	}
	p->u.line_id.id1 = id >> 32;
	p->u.line_id.id2 = id;
	return true;
}

bool ht_hex_viewer::qword_to_pos(uint64 q, viewer_pos *p)
{
	uint ll = h->get_line_length();
	uint disp = h->get_disp();
	ht_linear_sub *s = (ht_linear_sub*)cursor.sub;
	FileOfs ofs = q;
	clear_viewer_pos(p);
	p->u.sub = s;
	if (ofs < disp) {
		p->u.tag_idx = ofs;
	} else {
		p->u.tag_idx = (ofs - disp) % ll;
	}
	return s->convert_ofs_to_id(ofs, &p->u.line_id);
}

static bool readao(eval_scalar *result, ht_hex_viewer *h, int size, Endianess e, bool sign, FileOfs ofs)
{
	byte buf[8];
	File *file = h->get_file();
	try {
		file->seek(ofs);
		file->readx(&buf, size);
	} catch (const IOException&) {
		set_eval_error("i/o error (couldn't read %d bytes from ofs %qd (0x%qx))", size, ofs, ofs);
		return false;
	}
	uint64 v = createHostInt64(buf, size, e);
	if (sign) {
		switch (size) {
		case 1: v = sint64(sint8(v));
		case 2: v = sint64(sint16(v));
		case 4: v = sint64(sint32(v));
		}
	}
	scalar_create_int_q(result, v);	
	return true;
}

static bool reada(eval_scalar *result, ht_hex_viewer *h, int size, Endianess e, bool sign)
{
	FileOfs ofs;
	if (!h->get_current_offset(&ofs)) return false;
	return readao(result, h, size, e, sign, ofs);
}

bool ht_hex_viewer::symbol_handler(eval_scalar *result, char *name)
{
	if (strcmp(name, "$") == 0 || strcmp(name, "o") == 0) {
		FileOfs ofs;
		viewer_pos vp;
		vp.u = cursor;
		if (!pos_to_offset(vp, &ofs)) return false;
		scalar_create_int_q(result, ofs);
		return true;
	}
	if (strcmp(name, "first") == 0) {scalar_create_int_q(result, 0); return true;}
	if (strcmp(name, "last") == 0) {scalar_create_int_q(result, file->getSize() - 1); return true;}
	if (strcmp(name, "u8") == 0) return reada(result, this, 1, little_endian, false);
	if (strcmp(name, "u16") == 0) return reada(result, this, 2, little_endian, false);
	if (strcmp(name, "u32") == 0) return reada(result, this, 4, little_endian, false);
	if (strcmp(name, "u64") == 0) return reada(result, this, 8, little_endian, false);
	if (strcmp(name, "s8") == 0) return reada(result, this, 1, little_endian, true);
	if (strcmp(name, "s16") == 0) return reada(result, this, 2, little_endian, true);
	if (strcmp(name, "s32") == 0) return reada(result, this, 4, little_endian, true);
	if (strcmp(name, "u16be") == 0) return reada(result, this, 2, big_endian, false);
	if (strcmp(name, "u32be") == 0) return reada(result, this, 4, big_endian, false);
	if (strcmp(name, "u64be") == 0) return reada(result, this, 8, big_endian, false);
	if (strcmp(name, "s16be") == 0) return reada(result, this, 2, big_endian, true);
	if (strcmp(name, "s32be") == 0) return reada(result, this, 4, big_endian, true);
	return ht_uformat_viewer::symbol_handler(result, name);
}

static int func_readint(eval_scalar *result, eval_int *offset, int size, Endianess e)
{
	ht_hex_viewer *v = (ht_hex_viewer*)eval_get_context();
	return readao(result, v, size, e, false, offset->value);
}

static int func_readbyte(eval_scalar *result, eval_int *offset)
{
	return func_readint(result, offset, 1, little_endian);
}

static int func_read16le(eval_scalar *result, eval_int *offset)
{
	return func_readint(result, offset, 2, little_endian);
}

static int func_read32le(eval_scalar *result, eval_int *offset)
{
	return func_readint(result, offset, 4, little_endian);
}

static int func_read64le(eval_scalar *result, eval_int *offset)
{
	return func_readint(result, offset, 8, little_endian);
}

static int func_read16be(eval_scalar *result, eval_int *offset)
{
	return func_readint(result, offset, 2, big_endian);
}

static int func_read32be(eval_scalar *result, eval_int *offset)
{
	return func_readint(result, offset, 4, big_endian);
}

static int func_read64be(eval_scalar *result, eval_int *offset)
{
	return func_readint(result, offset, 8, big_endian);
}


bool ht_hex_viewer::func_handler(eval_scalar *result, char *name, eval_scalarlist *params)
{
	eval_func myfuncs[] = {
		{"$", 0, {SCALAR_INT}, "current offset"},
		{"o", 0, {SCALAR_INT}, "current offset"},
		{"first", 0, {SCALAR_INT}, "first offset"},
		{"last", 0, {SCALAR_INT}, "last offset"},
		{"u8", 0, {SCALAR_INT}, "byte at cursor"},
		{"u16", 0, {SCALAR_INT}, "little endian 16 bit word at cursor"},
		{"u32", 0, {SCALAR_INT}, "little endian 32 bit word at cursor"},
		{"u64", 0, {SCALAR_INT}, "little endian 64 bit word at cursor"},
		{"s8", 0, {SCALAR_INT}, "signed byte at cursor"},
		{"s16", 0, {SCALAR_INT}, "signed little endian 16 bit word at cursor"},
		{"s32", 0, {SCALAR_INT}, "signed little endian 32 bit word at cursor"},
		{"u16be", 0, {SCALAR_INT}, "big endian 16 bit word at cursor"},
		{"u32be", 0, {SCALAR_INT}, "big endian 32 bit word at cursor"},
		{"u64be", 0, {SCALAR_INT}, "big endian 64 bit word at cursor"},
		{"s16be", 0, {SCALAR_INT}, "signed big endian 16 bit word at cursor"},
		{"s32be", 0, {SCALAR_INT}, "signed big endian 32 bit word at cursor"},
		{"readbyte", (void*)&func_readbyte, {SCALAR_INT}, "read byte from offset"},
		{"read16le", (void*)&func_read16le, {SCALAR_INT}, "read little endian 16 bit word from offset"},
		{"read32le", (void*)&func_read32le, {SCALAR_INT}, "read little endian 32 bit word from offset"},
		{"read64le", (void*)&func_read64le, {SCALAR_INT}, "read little endian 64 bit word from offset"},
		{"read16be", (void*)&func_read16be, {SCALAR_INT}, "read big endian 16 bit word from offset"},
		{"read32be", (void*)&func_read32be, {SCALAR_INT}, "read big endian 32 bit word from offset"},
		{"read64be", (void*)&func_read64be, {SCALAR_INT}, "read big endian 64 bit word from offset"},
//		{"readstring", (void*)&func_readstring, {SCALAR_INT, SCALAR_INT}, "read string (offset, length)"},
		{NULL},
	};
	return std_eval_func_handler(result, name, params, myfuncs);
}

/*
 *	CLASS ht_hex_file_sub
 */

void ht_hex_file_sub::handlemsg(htmsg *msg)
{
	if (msg->msg == msg_filesize_changed) {
		fsize = file->getSize();
		return;
	}
	ht_hex_sub::handlemsg(msg);
}

ht-2.0.22/htelfshs.h0000644000175000001440000000157410206756707011137 00000000000000/* 
 *	HT Editor
 *	htelfshs.h
 *
 *	Copyright (C) 1999, 2000, 2001 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTELFSHS_H__
#define __HTELFSHS_H__

#include "htobj.h"
#include "formats.h"

extern format_viewer_if htelfsectionheaders_if;

#endif /* !__HTELFSHS_H__ */

ht-2.0.22/htneimg.h0000644000175000001440000000237110615341623010735 00000000000000/* 
 *	HT Editor
 *	htneimg.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTNEIMG_H__
#define __HTNEIMG_H__

#include "htanaly.h"
#include "htne.h"
#include "formats.h"

extern format_viewer_if htneimage_if;

/*
 *	CLASS ht_ne_aviewer
 */

class ht_ne_aviewer: public ht_aviewer {
public:
	ht_ne_shared_data *ne_shared;
	File *file;
	
		void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Analyser *Analyser, ht_ne_shared_data *ne_shared);
/* overwritten */
	virtual const char *func(uint i, bool execute);
	virtual void setAnalyser(Analyser *a);
};

#endif /* !__HTNEIMG_H__ */

ht-2.0.22/htpedimp.h0000644000175000001440000000202610615341623011111 00000000000000/* 
 *	HT Editor
 *	htpedimp.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTPEDIMP_H__
#define __HTPEDIMP_H__

#include "data.h"
#include "formats.h"

extern format_viewer_if htpedelayimports_if;

/*
 *	CLASS ht_pe_dimport_viewer
 */

class ht_pe_dimport_viewer: public ht_pe_import_viewer {
public:
/* overwritten */
	virtual	bool select_entry(void *entry);
};

#endif /* !__HTPEDIMP_H__ */
ht-2.0.22/store.cc0000644000175000001440000003167510615341624010606 00000000000000/*
 *	HT Editor
 *	store.cc
 *
 *	Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include 
#include 

#include "atom.h"
#include "htdebug.h"
#include "endianess.h"
#include "language.h"
#include "snprintf.h"
#include "store.h"
#include "strtools.h"
#include "tools.h"

static char hexchars[] = "0123456789abcdef";

char oidchar(ObjectID oID, int byte)
{
	unsigned char c = (oID >> (byte*8)) & 0xff;
	if ((c<32) || (c>0x7f)) c = '?';
	return c;
}

void putIDComment(ObjectStream &o, uint32 id)
{
	char buf[64];
	char id_str[4];
	id_str[3] = id&0xff;
	id_str[2] = (id>>8)&0xff;
	id_str[1] = (id>>16)&0xff;
	id_str[0] = (id>>24)&0xff;
	escape_special(buf, sizeof buf, id_str, 4);
	o.putComment(buf);
}

ObjectNotRegisteredException::ObjectNotRegisteredException(ObjectID aID)
	: MsgfException("Object %x/%c%c%c-%x not registered.", aID,
	  oidchar(aID, 3), oidchar(aID, 2), oidchar(aID, 1), aID & 0xff)
{
}

/*
 *	ObjectStreamInter
 */
 
ObjectStreamInter::ObjectStreamInter(Stream *s, bool own_s)
 : ObjectStream(s, own_s)
{
}

Object *ObjectStreamInter::getObjectInternal(const char *name, ObjectID id)
{
	if (id == OBJID_INVALID) {
		GET_INT32X(*this, id);
		if (!id) {
			return NULL;
		}
	}
	object_builder build = (object_builder)getAtomValue(id);
	if (!build) throw ObjectNotRegisteredException(id);
	Object *o = build();
	o->load(*this);
	return o;
}

void	ObjectStreamInter::putObject(const Object *object, const char *name, ObjectID id)
{
	if (!object) {
		if (id == OBJID_INVALID) {
			PUTX_INT32X(*this, 0, "id");
			return;
		} else {
			throw IllegalArgumentException(HERE);
		}
	}
	if (id == OBJID_INVALID) {
		id = object->getObjectID();
		putIDComment(*this, id);
		PUTX_INT32X(*this, id, "id");
	}
	if (!getAtomValue(id)) {
		throw ObjectNotRegisteredException(id);
	}
	object->store(*this);
}

/*
 *	ObjectStreamBin
 */
 
ObjectStreamBin::ObjectStreamBin(Stream *s, bool own_s)
 : ObjectStreamInter(s, own_s)
{
}
 
void ObjectStreamBin::getBinary(void *buf, uint size, const char *desc)
{
	mStream->readx(buf, size);
}

bool ObjectStreamBin::getBool(const char *desc)
{
	bool b;
	mStream->readx(&b, 1);
	return b;
}

uint64 ObjectStreamBin::getInt(uint size, const char *desc)
{
	assert(size <= 8);
	byte neta[8];
	mStream->readx(&neta, size);
	return createHostInt64(neta, size, big_endian);
}

char *ObjectStreamBin::getString(const char *desc)
{
	return mStream->readstrz();
}

byte *ObjectStreamBin::getLenString(int &length, const char *desc)
{
	byte b;
	mStream->readx(&b, 1);
	switch (b) {
    	case 0xfe: {
		byte neta[2];
		mStream->readx(&neta, 2);
		length = createHostInt(neta, 2, big_endian);
		break;
	}
	case 0xff: {
		byte neta[4];
		mStream->readx(&neta, 4);
		length = createHostInt(neta, 4, big_endian);
		break;
	}
	default:
		length = b;
		break;
	}
	if (length==0) return NULL;
	byte *p = ht_malloc(length);
	mStream->readx(p, length);
	return p;
}

void ObjectStreamBin::putBinary(const void *mem, uint size, const char *desc)
{
	mStream->writex(mem, size);
}

void ObjectStreamBin::putBool(bool b, const char *desc)
{
	b = (b) ? 1 : 0;
	mStream->writex(&b, 1);
}

void ObjectStreamBin::putCommentf(const char *comment_format, ...)
{
	// NOP
}

void ObjectStreamBin::putComment(const char *comment)
{
	// NOP
}

void ObjectStreamBin::putInt(uint64 i, uint size, const char *desc, uint int_fmt_hint)
{
	assert(size <= 8);
	byte neta[8];
	createForeignInt64(neta, i, size, big_endian);
	mStream->writex(neta, size);
}

void ObjectStreamBin::putSeparator()
{
	// NOP
}

void ObjectStreamBin::putString(const char *string, const char *desc)
{
	mStream->writestrz(string);
}

void ObjectStreamBin::putLenString(const byte *string, int len, const char *desc)
{
	byte bLen;
	if (len < 0xfe) {
		bLen = len;
		mStream->writex(&bLen, 1);
	} else if (len <= 0xffff) {
		byte neta[2];
		createForeignInt(neta, len, 2, big_endian);
		bLen = 0xfe;
		mStream->writex(&bLen, 1);
		mStream->writex(neta, 2);
	} else {
		byte neta[4];
		createForeignInt(neta, len, 4, big_endian);
		bLen = 0xff;
		mStream->writex(&bLen, 1);
		mStream->writex(neta, 4);
	}
	mStream->writex(string, len);
}

void	ObjectStreamBin::corrupt()
{
	throw MsgfException("corrupt file");
}

/*
 *	ObjectStreamText
 */
 
ObjectStreamText::ObjectStreamText(Stream *s, bool own_s)
 : ObjectStreamInter(s, own_s)
{
	indent = 0;
	cur = ' ';	// must be initialized to a whitespace char
	line = 1;
	errorline = 0;
}

void	ObjectStreamText::getBinary(void *buf, uint size, const char *desc)
{
	readDesc(desc);
	expect('=');
	expect('[');
	byte *pp=(byte *)buf;
	for (uint i=0; i= 39) setSyntaxError();
		readChar();
	} while (mapchar[(byte)cur]=='0' || mapchar[(byte)cur]=='A');
	*s=0;
	uint64 a;
	if (!str2int(str, a)) setSyntaxError();
	return a;
}

Object *ObjectStreamText::getObjectInternal(const char *name, ObjectID id)
{
	readDesc(name);
	expect('=');
	expect('{');
	Object *o = ObjectStreamInter::getObjectInternal(name, id);
	expect('}');
	return o;
}

char *ObjectStreamText::getString(const char *desc)
{
	readDesc(desc);
	expect('=');
	skipWhite();
	if (cur == '"') {
		String s;
		readChar();
		while (cur != '"') {
			s += cur;
			if (cur == '\\') {
				readChar();
				s += cur;
				cur = 0; // hackish
			}
			readChar();
		}
		readChar();
		s.unescape();
		return s.grabContentChar();
	} else {
		readDesc("NULL");
		return NULL;
	}
}

byte *ObjectStreamText::getLenString(int &len, const char *desc)
{
	readDesc(desc);
	expect('=');
	skipWhite();
	if (cur == '"') {
		String s;
		readChar();
		while (cur != '"') {
			s += cur;
			if (cur == '\\') {
				readChar();
				s += cur;
				cur = 0; // hackish
			}
			readChar();
		}
		readChar();
		s.unescape();
		len = s.length();
		return s.grabContent();
	} else {
		readDesc("NULL");
		return NULL;
	}
}

void ObjectStreamText::putBinary(const void *mem, uint size, const char *desc)
{
	putDesc(desc);
	putChar('[');
	for (uint i=0; i < size; i++) {
		byte a = *((byte *)mem+i);
		putChar(hexchars[(a & 0xf0) >> 4]);
		putChar(hexchars[(a & 0x0f)]);
		if (i+1 < size) putChar(' ');
	}
	putS("]\n");
}

void ObjectStreamText::putBool(bool b, const char *desc)
{
	putDesc(desc);
	if (b) putS("true"); else putS("false");
	putChar('\n');
}

void ObjectStreamText::putComment(const char *comment)
{
	putIndent();
	putS("# ");
	putS(comment);
	putChar('\n');
}

void ObjectStreamText::putInt(uint64 i, uint size, const char *desc, uint int_fmt_hint)
{
	putDesc(desc);
	char number[40];
	switch (int_fmt_hint) {
		case OS_FMT_DEC:
			ht_snprintf(number, sizeof number, "%qd\n", i);
			break;
		case OS_FMT_HEX:
		default:
			ht_snprintf(number, sizeof number, "0x%qx\n", i);
			break;
	}
	putS(number);
}

void ObjectStreamText::putObject(const Object *object, const char *name, ObjectID id)
{
	putDesc(name);
	putS("{\n");
	indent++;
	ObjectStreamInter::putObject(object, name, id);
	indent--;
	putIndent();
	putS("}\n");
}

void ObjectStreamText::putSeparator()
{
	putIndent();
	putS("# ------------------------ \n");
}

void ObjectStreamText::putString(const char *string, const char *desc)
{
	putDesc(desc);
	if (string) {
		String s(string);
		putChar('"');
		s.escape("\"", true);
		putS(s.contentChar());
		putChar('"');
	} else {
		putS("NULL");
	}
	putChar('\n');
}

void ObjectStreamText::putLenString(const byte *string, int len, const char *desc)
{
	putDesc(desc);
	if (string) {
		int strl=len*4+1;
		char *str = ht_malloc(strl);
		putChar('"');
		escape_special(str, strl, string, len, "\"");
		putS(str);
		putChar('"');
		free(str);
	} else {
		putS("NULL");
	}
	putChar('\n');
}

class TextSyntaxError: public MsgfException {
public:
	TextSyntaxError(uint line)
		: MsgfException("syntax error in line %d", line)
	{
	}
};

void	ObjectStreamText::setSyntaxError()
{
	// FIXME: errorline still usable ?
	if (!errorline) {
		errorline = line;
		throw TextSyntaxError(line);
	}
}

int	ObjectStreamText::getErrorLine()
{
	return errorline;
}

void	ObjectStreamText::expect(char c)
{
	skipWhite();
	if (cur != c) setSyntaxError();
	readChar();
}

void	ObjectStreamText::skipWhite()
{
	while (1) {
		switch (mapchar[(byte)cur]) {
		case '\n':
			line++;  // fallthrough
		case ' ':
			readChar();
			break;
		case '#':
			do {
				readChar();
			} while (cur != '\n');
			break;
		default: return;
		}
	}
}

char ObjectStreamText::readChar()
{
	mStream->readx(&cur, 1);
	return cur;
}

void ObjectStreamText::readDesc(const char *desc)
{
	skipWhite();
	if (!desc) desc = "data";
	while (*desc) {
		if (*desc != cur) setSyntaxError();
		readChar();
		desc++;
	}
}

void ObjectStreamText::putDesc(const char *desc)
{
	putIndent();
	putS(desc ? desc : "data");
	putChar('=');
}

void ObjectStreamText::putIndent()
{
	for(int i=0; i < indent; i++) putChar(' ');
}

void ObjectStreamText::putChar(char c)
{
	mStream->writex(&c, 1);
}

void ObjectStreamText::putS(const char *s)
{
	uint len=strlen(s);
	if (mStream->write(s, len) != len) setSyntaxError();
}

void	ObjectStreamText::corrupt()
{
	errorline = line;
	throw MsgfException("corrupt format near line %d", line);
}

/*
 *	ObjectStreamNative View:set/getData() methods
 *	(endian-dependend)
 */

ObjectStreamNative::ObjectStreamNative(Stream *s, bool own_s, bool d)
: ObjectStream(s, own_s), duplicate(d), allocd(true)
{
}

void *ObjectStreamNative::duppa(const void *p, int size)
{
	if (duplicate) {
		MemArea *m = new MemArea(p, size, true);
		allocd += m;
		return m->ptr;
	} else {
		// FIXME: un-const'ing p
		return const_cast(p);
	}
}

void ObjectStreamNative::getBinary(void *buf, uint size, const char *desc)
{
	void *pp;
	mStream->readx(&pp, sizeof pp);
	memcpy(buf, pp, size);
}

bool ObjectStreamNative::getBool(const char *desc)
{
	bool b;
	mStream->readx(&b, sizeof b);
	return b;
}

uint64 ObjectStreamNative::getInt(uint size, const char *desc)
{
	switch (size) {
	case 1: {
		uint8 i;
		mStream->readx(&i, size);
		return i;
	}
	case 2: {
		uint16 i;
		mStream->readx(&i, size);
		return i;
	}
	case 4: {
		uint32 i;
		mStream->readx(&i, size);
		return i;
	}
	case 8: {
		uint64 i;
		mStream->readx(&i, size);
		return i;
	}
	}
	throw IllegalArgumentException(HERE);
}

Object *ObjectStreamNative::getObjectInternal(const char *name, ObjectID id)
{
	Object *pp;
	mStream->readx(&pp, sizeof pp);
	return pp;
}

char	*ObjectStreamNative::getString(const char *desc)
{
	char *pp;
	mStream->readx(&pp, sizeof pp);
	return pp;
}

byte	*ObjectStreamNative::getLenString(int &len, const char *desc)
{
	byte *pp;
	mStream->readx(&pp, sizeof pp);
	// FIXME?
	if (pp) len = strlen((char*)pp); else len = 0;
	return pp;
}

void	ObjectStreamNative::putBinary(const void *mem, uint size, const char *desc)
{
	void *pp = mem ? duppa(mem, size) : NULL;
	mStream->writex(&pp, sizeof pp);
}

void	ObjectStreamNative::putBool(bool b, const char *desc)
{
	mStream->writex(&b, sizeof b);
}

void	ObjectStreamNative::putComment(const char *comment)
{
	// NOP
}

void	ObjectStreamNative::putInt(uint64 i, uint size, const char *desc, uint int_fmt_hint)
{
	switch (size) {
	case 1: {
		uint8 x = i;
		mStream->writex(&x, size);
		return;
	}
	case 2: {
		uint16 x = i;
		mStream->writex(&x, size);
		return;
	}
	case 4: {
		uint32 x = i;
		mStream->writex(&x, size);
		return;
	}
	case 8:
		mStream->writex(&i, size);
		return;
	}
	throw IllegalArgumentException(HERE);
}

void ObjectStreamNative::putObject(const Object *object, const char *name, ObjectID id)
{
	Object *d = duplicate ? d->clone() : d;
	mStream->write(&d, sizeof d);
}

void	ObjectStreamNative::putSeparator()
{
	// NOP
}

void	ObjectStreamNative::putString(const char *string, const char *desc)
{
	const char *pp = string ? (const char*)duppa(string, strlen(string)+1) : NULL;
	mStream->write(&pp, sizeof pp);
}

void	ObjectStreamNative::putLenString(const byte *string, int len, const char *desc)
{
	const char *pp = string ? (const char*)duppa(string, len+1) : NULL;
	mStream->write(&pp, sizeof pp);
}

void	ObjectStreamNative::corrupt()
{
}
ht-2.0.22/coff_s.cc0000644000175000001440000000435010615341616010700 00000000000000/* 
 *	HT Editor
 *	coff_s.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "coff_s.h"
#include "endianess.h"

byte COFF_HEADER_struct[] = {
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	0
};

byte COFF_OPTIONAL_HEADER32_struct[] = {
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	0
};

byte COFF_OPTIONAL_HEADER64_struct[] = {
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	0
};

byte COFF_SECTION_HEADER_struct[] = {
	COFF_SIZEOF_SHORT_NAME,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	0
};


ht-2.0.22/htiobox.h0000644000175000001440000000467110634246753010774 00000000000000/* 
 *	HT Editor
 *	htiobox.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTIOBOX_H__
#define __HTIOBOX_H__

#include "htdialog.h"

/* buttonmask */
#define btmask_ok			1
#define btmask_cancel		2
#define btmask_yes			4
#define btmask_no			8
#define btmask_skip			16
#define btmask_all			32
#define btmask_none			64

int msgbox(int buttonmask, const char *title, bool modal, statictext_align align, const char *format, ...);
int msgboxrect(Bounds *b, int buttonmask, const char *title, bool modal, statictext_align align, const char *format, ...);

#define errorbox(a...) msgbox(btmask_ok, "error", false, align_center, a)
#define infobox(a...) msgbox(btmask_ok, "information", false, align_center, a)
#define warnbox(a...) msgbox(btmask_ok, "warning", false, align_center, a)
#define confirmbox(a...) msgbox(btmask_yes+btmask_no, "confirmation", false, align_center, a)

#define errorbox_c(a...) msgbox(btmask_ok, "error", false, align_custom, a)
#define infobox_c(a...) msgbox(btmask_ok, "information", false, align_custom, a)
#define warnbox_c(a...) msgbox(btmask_ok, "warning", false, align_custom, a)
#define confirmbox_c(a...) msgbox(btmask_yes+btmask_no, "confirmation", false, align_custom, a)

#define errorbox_modal(a...) msgbox(btmask_ok, "error", true, align_center, a)
#define infobox_modal(a...) msgbox(btmask_ok, "information", true, align_center, a)
#define warnbox_modal(a...) msgbox(btmask_ok, "warning", true, align_center, a)
#define confirmbox_modal(a...) msgbox(btmask_yes+btmask_no, "confirmation", true, align_center, a)

bool inputbox(const char *title, const char *label, char *result, int limit, uint32 histid = 0);
bool inputboxrect(Bounds *b, const char *title, const char *label, char *result, int limit, uint32 histid = 0);

void get_std_progress_indicator_metrics(Bounds *b);

#endif /* __HTIOBOX_H__ */

ht-2.0.22/vfsview.cc0000644000175000017500000003667212127651420011147 00000000000000/*
 *	HT Editor
 *	vfsview.cc
 *
 *	Copyright (C) 1999-2003 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include 
#include 
#include 

#include "strtools.h"
#include "snprintf.h"
#include "vfsview.h"

static vfs_extra *make_vfs_extra(const char *name, pstat_t s)
{
	vfs_extra *e = ht_malloc(sizeof *e);
	e->stat = s;
	e->name = strdup(name);
	return e;
}

static void free_vfs_extra(vfs_extra *e)
{
	free(e->name);
	free(e);
}

static Vfs *vfslistbox_vfs;

static int vfslistbox_fncmp(const char *a, const char *b)
{
	if (strchr("/ *@=#+", *a) && (*b != *a)) {
		if (*a == '/') return -1;
		if (*b == '/') return 1;
		return *b-*a;
	}
	return vfslistbox_vfs->compareFilenames(a,b);
}

/*
 *	class VfsListbox
 */

#define VFSV_FORMAT_NAME	0
#define VFSV_FORMAT_SIZE	1
#define VFSV_FORMAT_BSIZE	2
#define VFSV_FORMAT_TYPE	3
#define VFSV_FORMAT_MTIME	4
#define VFSV_FORMAT_ATIME	5
#define VFSV_FORMAT_CTIME	6
#define VFSV_FORMAT_PERM	7
#define VFSV_FORMAT_MODE	8
#define VFSV_FORMAT_NLINK	9
#define VFSV_FORMAT_NGID	10
#define VFSV_FORMAT_NUID	11
#define VFSV_FORMAT_OWNER	12
#define VFSV_FORMAT_GROUP	13
#define VFSV_FORMAT_INODE	14
#define VFSV_FORMAT_SPACE	15
#define VFSV_FORMAT_MARK	16
#define VFSV_FORMAT_SEPARATOR	17
#define VFSV_FORMAT_DESC	18
#define VFSV_FORMAT_RMTIME	19
#define VFSV_FORMAT_RATIME	20
#define VFSV_FORMAT_RCTIME	21

static const char *format_property[VFSV_FORMAT_PROPERTIES]={
	"name",		"size",
	"bsize",	"type",
	"mtime",	"atime",
	"ctime",	"perm",
	"mode",		"nlink",
	"ngid",		"nuid",
	"owner",	"group",
	"inode",	"space",
	"mark",		"|",
	"desc",		"rmtime",
	"ratime",	"rctime"
};

#define MAKE_DISPLAY_FORMAT(type) MAKE_DISPLAY_FORMAT_MIN_WIDTH(type, 0)
#define MAKE_DISPLAY_FORMAT_MIN_WIDTH(type, width) (((width) << 16) | (type))
#define MAKE_DISPLAY_FORMAT_FIXED_WIDTH(type, width) ((((width) | 0x8000) << 16) | (type))

#define GET_DISPLAY_FORMAT_TYPE(dfmt) ((dfmt) & 0xffff)
#define GET_DISPLAY_FORMAT_SIZE(dfmt) (((dfmt)>>16) & 0x7fff)
#define GET_DISPLAY_FORMAT_IS_FIXED_SIZE(dfmt) ((dfmt) & 0x80000000)
#define GET_DISPLAY_FORMAT_IS_MIN_SIZE(dfmt) (!GET_DISPLAY_FORMAT_IS_FIXED_SIZE(dfmt))

void VfsListbox::init(Bounds *b, Container *vl, ht_text *sp)
{
	cvfs = NULL;
	show_pos = sp;
	cdir[0] = 0;
	cproto[0] = 0;
	vfs_list = vl;
	ht_itext_listbox::init(b);
	config_changed();
}

void VfsListbox::done()
{
	ht_itext_listbox::done();
}

int VfsListbox::changeDir(const char *dir)
{
	char url[VFS_URL_MAX];
	ht_snprintf(url, sizeof url, "%s:%s", cproto, dir);
	return changeURL(url);
}

int VfsListbox::changeURL(const char *url)
{
	int c = vfs_list->count();
	const char *pend = strchr(url, ':');
	Vfs *newVfs = NULL;
	const char *pathptr = url;
	if (pend) {
		/* find matching protocol */
		char protoname[VFS_PROTO_MAX+1];
		if (pend-url > VFS_PROTO_MAX) return EINVAL;
		ht_strlcpy(protoname, url, pend-url+1);
		for (int i = 0; i < c; i++) {
			Vfs *v = (Vfs*)(*vfs_list)[i];
			if (strcmp(protoname, v->getProtoName()) == 0) {
				newVfs = v;
				break;
			}
		}
		if (!newVfs) return EINVAL;
		pathptr = pend+1;
	} else {
		/* no proto mentioned, default to first in list */
		if (!c) return EINVAL;
		newVfs = (Vfs*)vfs_list->get(0);
	}
	char path[VFS_DIR_MAX+1];
	if (sys_common_canonicalize(path, sizeof path, pathptr, NULL, newVfs->isPathDelim()) !=0) return EINVAL;

	/* add trailing path delimiter if needed */
	int l = strlen(path)-1;
	if (l == -1 || !newVfs->isPathDelim()(path[l])) {
		char delim = newVfs->isPathDelim()('/') ? '/' : '\\';
		if (l+2 >= (int)sizeof path) return EINVAL;
		path[l+1] = delim;
		path[l+2] = 0;
	}

	/* stat and find out if its a dir*/
	pstat_t s;
	int e;
	if ((e = newVfs->pstat(&s, path)) != 0) return e;
	if (!(s.caps & pstat_mode_type) || !(HT_S_ISDIR(s.mode))) return ENOTDIR;

	/* code to position cursor when doing "cd .." */
	char spath[VFS_DIR_MAX+1];
	char spath2[VFS_DIR_MAX+1];
	strcpy(spath, cdir);
	char *p = ht_strend(spath)-2;
	bool cdpp = false;
	while (p >= spath) {
		if (newVfs->isPathDelim()(*p)) {
			strcpy(spath2, p+1);
			*(ht_strend(spath2)-1) = 0;
			*(p+1) = 0;
			if (newVfs->compareFilenames(path, spath) == 0) {
				cdpp = true;
			}
			break;
		}
		p--;
	}
	
	/* everything ok, set current to this */
	ht_strlcpy(cproto, newVfs->getProtoName(), sizeof cproto);
	ht_strlcpy(cdir, path, sizeof cdir);
	cvfs = newVfs;

	reread();
	/**/
	update();
	if (dfmt_quickfind != -1) {
		ht_text_listbox_sort_order so[1];
		vfslistbox_vfs = cvfs;
		so[0].col = dfmt_quickfind;
		so[0].compare_func = vfslistbox_fncmp;
		sort(1, so);
	} /*else update();*/
	
	gotoItemByPosition(0);
	/* code to position cursor when doing "cd .." (part II) */
	if (cdpp) {
		ht_text_listbox_item *i = (ht_text_listbox_item*)getFirst();
		while (i) {
			vfs_extra *x = (vfs_extra*)i->extra_data;
			if (newVfs->compareFilenames(x->name, spath2) == 0) {
				gotoItemByEntry(i);
				break;
			}
			i = (ht_text_listbox_item*)getNext(i);
		}
	}
	rearrangeColumns();

	return 0;
}

void VfsListbox::config_changed()
{
	ht_text_listbox::config_changed();
	char *dfmt = get_config_string("misc/vfs display format");
	setDisplayFormat(dfmt ? dfmt : (char*)"name");
	free(dfmt);
}

int VfsListbox::cursorAdjust()
{
	return 1;
}

void VfsListbox::freeExtraData(void *extra_data)
{
	if (extra_data) {
		free_vfs_extra((vfs_extra*)extra_data);
	}
}

const char *VfsListbox::getCurDir()
{
	return cdir;
}

const char *VfsListbox::getCurProto()
{
	return cproto;
}

Vfs *VfsListbox::getCurVfs()
{
	return cvfs;
}

void VfsListbox::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
	case msg_keypressed:
		switch (msg->data1.integer) {
		case K_Return:
			if (count && selectEntry(e_cursor)) {
				clearmsg(msg);
				return;
			}
			break;
		}
		break;
	}
	return ht_text_listbox::handlemsg(msg);
}

void VfsListbox::setDisplayFormat(char *fmt)
{
/*	int dfmt_cols;
	int dfmt_props;
	int dfmt_prop2colidx[VFSV_FORMAT_MAX_COLS];
	int dfmt_prop[VFSV_FORMAT_MAX_COLS];*/
	int type;
	dfmt_cols = 0;
	dfmt_props = 0;
	dfmt_quickfind = -1;
	while ((fmt = translateProp(fmt, &type))) {
		if (type == VFSV_FORMAT_SEPARATOR) {
			if (++dfmt_cols == VFSV_FORMAT_MAX_COLS) break;
		} else {
			if (*fmt == ':') {
				fmt++;
				unsigned int width = strtoul(fmt, &fmt, 10);
				if (*fmt == '+') {
					fmt++;
					dfmt_prop[dfmt_props] = MAKE_DISPLAY_FORMAT_MIN_WIDTH(type, width);
				} else {
					dfmt_prop[dfmt_props] = MAKE_DISPLAY_FORMAT_FIXED_WIDTH(type, width);
				}
			} else {
				dfmt_prop[dfmt_props] = MAKE_DISPLAY_FORMAT(type);
			}
			dfmt_prop2colidx[dfmt_props] = dfmt_cols;
			if (++dfmt_props == VFSV_FORMAT_MAX_COLS) break;
		}

		while ((*fmt == ',') || (*fmt == ' ')) fmt++;

		if ((type == VFSV_FORMAT_NAME) && (dfmt_quickfind == -1)) {
			dfmt_quickfind = dfmt_cols;
		}
	}
	++dfmt_cols;
	cols = dfmt_cols;
	if (dfmt_quickfind != -1) keycol = dfmt_quickfind;
		else keycol = 0;
	rearrangeColumns();
}

bool VfsListbox::selectEntry(void *entry)
{
	ht_text_listbox_item *i = (ht_text_listbox_item*)entry;
	if (i->extra_data) {
		vfs_extra *e = (vfs_extra*)i->extra_data;
		if (e->stat.caps & pstat_mode_type) {
			if (HT_S_ISDIR(e->stat.mode)) {
				char d[VFS_DIR_MAX];
				ht_snprintf(d, sizeof d, "%s%s", cdir, e->name);
				changeDir(d);
				update();
				return true;
			}
		}
	}
	return false;
}

char *VfsListbox::translateProp(char *fmt, int *type)
{
	for (int i=0; ifindFirst(cdir, &f)) {
		do {
			if (strcmp(f.name, ".") != 0) {
				for (int i=0; ifindNext(&f));
	}
	cvfs->findClose(&f);
	for (int i=0; idata[keycol];
			i = (i && *i) ? i+1 : i;
		}
		while (item && (compare_strn(i, s, slen)!=0)) {
			item = item->next;
			if (item) {
				i = item->data[keycol];
				i = (i && *i) ? i+1 : i;
			}
		}
		if (item) return item;
		item = first;
	}
	return NULL;
}

char *VfsListbox::quickfindCompletition(const char *s)
{
	ht_text_listbox_item *item = first;
	char *res = NULL;
	int slen = strlen(s);
	char *i = NULL;
	if (item) {
		i = item->data[keycol];
		i = (i && *i) ? i+1 : i;
	}
	while (item) {
		if (compare_strn(i, s, slen)==0) {
			if (!res) {
				res = ht_strdup(item->data[keycol]+1);
			} else {
				int a = compare_ccomm(item->data[keycol]+1, res);
				res[a] = 0;
			}
		}
		item = item->next;
		if (item) {
			i = item->data[keycol];
			i = (i && *i) ? i+1 : i;
		}
	}
	return res;
}

void VfsListbox::update()
{
	if (show_pos) {
		char curl[VFS_URL_MAX];
		ht_snprintf(curl, sizeof curl, "%s:%s", cproto, cdir);
		show_pos->settext(curl);
	}

	ht_text_listbox::update();
}

void VfsListbox::renderEntry(char *buf, int bufsize, int dfmt, const char *filename, pstat_t stat)
{
	buf[0] = 0;
	int timei = 0;
	switch (GET_DISPLAY_FORMAT_TYPE(dfmt)) {
		case VFSV_FORMAT_NAME: {
			ht_snprintf(buf, bufsize, "%s", filename);
			break;
		}
		case VFSV_FORMAT_SIZE:
			if (stat.caps & pstat_size) {
				ht_snprintf(buf, bufsize, "%qu", stat.size);
			}
			break;
		case VFSV_FORMAT_BSIZE:
			if (HT_S_ISDIR(stat.mode)) {
				if (strcmp(filename, "..")==0) {
					ht_snprintf(buf, bufsize,"", stat.size);
				} else {
					ht_snprintf(buf, bufsize,"", stat.size);
				}
			} else if (stat.caps & pstat_size) {
				ht_snprintf(buf, bufsize, "%qu", stat.size);
			}
			break;
		case VFSV_FORMAT_TYPE:
			if (bufsize > 1) {
				if (stat.caps & pstat_mode_type) {
					if (HT_S_ISDIR(stat.mode)) {
						buf[0] = '/';
					} else if (HT_S_ISBLK(stat.mode)) {
						buf[0] = '+';
					} else if (HT_S_ISCHR(stat.mode)) {
						buf[0] = '#';
					} else if (HT_S_ISFIFO(stat.mode)) {
						buf[0] = '|';
					} else if (HT_S_ISLNK(stat.mode)) {
						buf[0] = '@';
					} else if (HT_S_ISSOCK(stat.mode)) {
						buf[0] = '=';
					} else if (stat.mode & HT_S_IXUSR) {
						buf[0] = '*';
					} else {
						buf[0] = ' ';
					}
					buf[1] = 0;
				}
			}
			break;
		case VFSV_FORMAT_MTIME: timei++;
		case VFSV_FORMAT_ATIME: timei++;
		case VFSV_FORMAT_CTIME: timei++;
		case VFSV_FORMAT_RMTIME: timei++;
		case VFSV_FORMAT_RATIME: timei++;
		case VFSV_FORMAT_RCTIME: {
			time_t q;
			bool avail = false;
			bool reltime = false;

			switch (timei) {
				case 2: reltime = true;
				case 5:
					if (stat.caps & pstat_mtime) {
						q = stat.mtime;
						avail = true;
					}
					break;
				case 1: reltime = true;
				case 4:
					if (stat.caps & pstat_atime) {
						q = stat.atime;
						avail = true;
					}
					break;
				case 0: reltime = true;
				case 3:
					if (stat.caps & pstat_ctime) {
						q = stat.ctime;
						avail = true;
					}
					break;
			}
			if (avail) {
				tm *pt = gmtime(&q);
				if (!pt) {
					q = 0;
					pt = gmtime(&q);
				}
				tm t = *pt;

				time_t ct;
				time(&ct);
				tm *pc = gmtime(&ct);
				if (!pc) {
					ct = 0;
					pc = gmtime(&ct);
				}
				tm c = *pc;
				char *line = buf;
									   
				const char *months[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
				if ((reltime) && ((uint)ct-q<=60*60*24*28)) {
					if ((uint)ct-q<=60*60*24) {
						line += ht_snprintf(line, bufsize-(line-buf), "now ");
					} else if ((uint)ct-q<=60*60*24*2) {
						line += ht_snprintf(line, bufsize-(line-buf), "now ");
					} else {
						line += ht_snprintf(line, bufsize-(line-buf), "%s-%uday", ((uint)(ct-q)/(60*60*24)>10) ? "" : " ", (uint)(ct-q)/(60*60*24));
					}
				} else {
					line += ht_snprintf(line, bufsize-(line-buf), "%s %02d", months[t.tm_mon], t.tm_mday);
				}
				if (t.tm_year==c.tm_year) {
					if ((reltime) && ((uint)ct-q<=60*60*24)) {
						if ((uint)ct-q<=60*60) {
							line += ht_snprintf(line, bufsize-(line-buf), "-%umin", (uint)(ct-q)/60);
						} else {
							line += ht_snprintf(line, bufsize-(line-buf), "-%um:%u", (uint)(ct-q)/60/60, (uint)(ct-q)/60%60);
						}
					} else {
						line += ht_snprintf(line, bufsize-(line-buf), " %02d:%02d:%02d", t.tm_hour, t.tm_min, t.tm_sec);
					}
				} else {
					line += ht_snprintf(line, bufsize-(line-buf), "  %04d", t.tm_year+1900);
					line += ht_snprintf(line, bufsize-(line-buf), " %02d:%02d:%02d", t.tm_hour, t.tm_min, t.tm_sec);
				}
			}
			break;
		}
		case VFSV_FORMAT_PERM: {
			if (bufsize>3) {
				char *line = buf;
				if (stat.caps & pstat_mode_type) {
					*(line++)=HT_S_ISDIR(stat.mode) ? 'd' : '-';
				}
					
				if (stat.caps & pstat_mode_oth) {
					*(line++)=(stat.mode & HT_S_IROTH) ? 'r' : '-';
					*(line++)=(stat.mode & HT_S_IWOTH) ? 'w' : '-';
					*(line++)=(stat.mode & HT_S_IXOTH) ? 'x' : '-';
				}
					
				if (stat.caps & pstat_mode_grp) {
					*(line++)=(stat.mode & HT_S_IRGRP) ? 'r' : '-';
					*(line++)=(stat.mode & HT_S_IWGRP) ? 'w' : '-';
					*(line++)=(stat.mode & HT_S_IXGRP) ? 'x' : '-';
				}
					
				if (stat.caps & pstat_mode_usr) {
					*(line++)=(stat.mode & HT_S_IRUSR) ? 'r' : '-';
					*(line++)=(stat.mode & HT_S_IWUSR) ? 'w' : '-';
					*(line++)=(stat.mode & HT_S_IXUSR) ? 'x' : '-';
				}
				*line = 0;
			}
			break;
		}
		case VFSV_FORMAT_MODE:
			if (stat.caps & pstat_mode_all) {
				ht_snprintf(buf, bufsize, "%o", stat.mode & ((1<<9)-1));
			}
			break;
		case VFSV_FORMAT_NLINK:
			break;
		case VFSV_FORMAT_NGID:
			if (stat.caps & pstat_gid) {
				ht_snprintf(buf, bufsize, "%u", stat.gid);
			}
			break;
		case VFSV_FORMAT_NUID:
			if (stat.caps & pstat_uid) {
				ht_snprintf(buf, bufsize, "%u", stat.uid);
			}
			break;
		case VFSV_FORMAT_OWNER:
			break;
		case VFSV_FORMAT_GROUP:
			break;
		case VFSV_FORMAT_INODE:
			if (stat.caps & pstat_inode) {
				ht_snprintf(buf, bufsize, "%u", stat.inode);
			}
			break;
		case VFSV_FORMAT_SPACE:
			if (bufsize>1) {
				buf[0] = ' ';
				buf[1] = 0;
			}
			break;
		case VFSV_FORMAT_MARK:
			break;
		case VFSV_FORMAT_DESC:
			if (stat.caps & pstat_desc) {
/*				tag_strcpy(line, stat.desc);
				line+=tag_strlen(line);
				alignright=0;*/
			}
			break;
	}
}

/*
 *	class VfsListbox2
 */

bool VfsListbox2::selectEntry(void *entry)
{
	if (VfsListbox::selectEntry(entry)) return true;
	ht_text_listbox_item *i = (ht_text_listbox_item*)entry;
	if (i->extra_data) {
		vfs_extra *e = (vfs_extra*)i->extra_data;
		char path[VFS_URL_MAX];
		ht_snprintf(path, sizeof path, "%s%s", cdir, e->name);
		cvfs->open(path, 1);
		return true;
	}
	return false;
}
ht-2.0.22/htmachoimg.cc0000644000175000001440000001034010660124267011556 00000000000000/*
 *	HT Editor
 *	htmachoimg.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "log.h"
#include "htmachoimg.h"
#include "htpal.h"
#include "strtools.h"
#include "formats.h"
#include "snprintf.h"
#include "tools.h"

#include "machostruc.h"
#include "macho_analy.h"

static ht_view *htmachoimage_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_macho_shared_data &macho_shared = *(ht_macho_shared_data *)group->get_shared_data();

	String fn;
	file->getFilename(fn);
	LOG("%y: Mach-O: loading image (starting analyser)...", &fn);
	MachoAnalyser *p = new MachoAnalyser();
	p->init(&macho_shared, file);

	Bounds c = *b;
	ht_group *g = new ht_group();
	g->init(&c, VO_RESIZE, DESC_MACHO_IMAGE"-g");

	c.y += 2;
	c.h -= 2;
	ht_macho_aviewer *v = new ht_macho_aviewer();
	v->init(&c, DESC_MACHO_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, p, &macho_shared);

	c.y -= 2;
	c.h = 2;
	AnalyInfoline *head = new AnalyInfoline();
	head->init(&c, v, ANALY_STATUS_DEFAULT);

	v->attachInfoline(head);

	/* find lowest/highest address */
	Address *low = NULL;
	Address *high = NULL;

	MACHOAddress l, h;
	l = -1ULL;
	h = 0;
	MACHO_SECTION_U *s = macho_shared.sections;
	for (uint i=0; i < macho_shared.section_count; i++) {
		if (macho_valid_section(s)) {
			if (s->_64) {
				if (s->s64.vmaddr < l) l = s->s64.vmaddr;
				if (s->s64.vmaddr+s->s64.vmsize > h && s->s64.vmsize) h = s->s64.vmaddr + s->s64.vmsize - 1;
			} else {
				if (s->s.vmaddr < l) l = s->s.vmaddr;
				if (s->s.vmaddr+s->s.vmsize > h && s->s.vmsize) h = s->s.vmaddr + s->s.vmsize - 1;
			}
		}
		s++;
	}
	if (macho_shared._64) {
		low = p->createAddress64(l);
		high = p->createAddress64(h);
	} else {
		low = p->createAddress32(l);
		high = p->createAddress32(h);
	}

	ht_analy_sub *analy = new ht_analy_sub();

	if (low->compareTo(high) < 0) {
		analy->init(file, v, p, low, high);
		v->analy_sub = analy;
		v->insertsub(analy);
	} else {
		delete analy;
		v->done();
		delete v;
		head->done();          
		delete head;
		g->done();
		delete g;
		delete high;
		delete low;
		return NULL;
	}
	
	delete high;
	delete low;

	v->sendmsg(msg_complete_init, 0);

	MACHO_COMMAND_U **pp = macho_shared.cmds.cmds;
	for (uint i=0; i < macho_shared.cmds.count; i++) {
		if ((*pp)->cmd.cmd == LC_UNIXTHREAD || (*pp)->cmd.cmd == LC_THREAD) {
			MACHO_THREAD_COMMAND *s = (MACHO_THREAD_COMMAND*)*pp;
			uint64 e = 0;
			switch (macho_shared.header.cputype) {
			case MACHO_CPU_TYPE_ARM:
				e = s->state.state_arm.pc;
				break;
			case MACHO_CPU_TYPE_POWERPC:
				e = s->state.state_ppc.srr[0];
				break;
			case MACHO_CPU_TYPE_I386:
				e = s->state.state_i386.eip;
				break;
			case MACHO_CPU_TYPE_X86_64:
				e = s->state.state_x86_64.rip;
				break;
			case MACHO_CPU_TYPE_POWERPC64:
				e = s->state.state_ppc64.srr[0];
				break;
			default: assert(0);
			}
			Address *entry;
			if (macho_shared._64) {
				entry = p->createAddress64(e);
			} else {
				entry = p->createAddress32(e);
			}
			v->gotoAddress(entry, NULL);
			delete entry;
			break;
		}
		pp++;
	}

	g->insert(head);
	g->insert(v);

	g->setpalette(palkey_generic_window_default);

	return g;
}

format_viewer_if htmachoimage_if = {
	htmachoimage_init,
	0
};

/*
 *	CLASS ht_macho_aviewer
 */
void ht_macho_aviewer::init(Bounds *b, const char *desc, int caps, File *File, ht_format_group *format_group, Analyser *Analy, ht_macho_shared_data *MACHO_shared)
{
	ht_aviewer::init(b, desc, caps, File, format_group, Analy);
	macho_shared = MACHO_shared;
}

void ht_macho_aviewer::setAnalyser(Analyser *a)
{
	((MachoAnalyser *)a)->macho_shared = macho_shared;
	((MachoAnalyser *)a)->file = file;
	analy = a;
	analy_sub->setAnalyser(a);
}
ht-2.0.22/snprintf.cc0000644000175000001440000005667710615341624011326 00000000000000/*
 * Copyright Patrick Powell 1995
 * This code is based on code written by Patrick Powell (papowell@astart.com)
 * It may be used for any purpose as long as this notice remains intact
 * on all source code distributions
 */

/**************************************************************
 * Original:
 * Patrick Powell Tue Apr 11 09:48:21 PDT 1995
 * A bombproof version of doprnt (dopr) included.
 * Sigh.  This sort of thing is always nasty do deal with.  Note that
 * the version here does not include floating point...
 *
 * snprintf() is used instead of sprintf() as it does limit checks
 * for string length.  This covers a nasty loophole.
 *
 * The other functions are there to prevent NULL pointers from
 * causing nast effects.
 *
 * More Recently:
 *  Brandon Long  9/15/96 for mutt 0.43
 *  This was ugly.  It is still ugly.  I opted out of floating point
 *  numbers, but the formatter understands just about everything
 *  from the normal C string format, at least as far as I can tell from
 *  the Solaris 2.5 printf(3S) man page.
 *
 *  Brandon Long  10/22/97 for mutt 0.87.1
 *    Ok, added some minimal floating point support, which means this
 *    probably requires libm on most operating systems.  Don't yet
 *    support the exponent (e,E) and sigfig (g,G).  Also, fmtint()
 *    was pretty badly broken, it just wasn't being exercised in ways
 *    which showed it, so that's been fixed.  Also, formated the code
 *    to mutt conventions, and removed dead code left over from the
 *    original.  Also, there is now a builtin-test, just compile with:
 *           gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
 *    and run snprintf for results.
 * 
 *  Thomas Roessler  01/27/98 for mutt 0.89i
 *    The PGP code was using unsigned hexadecimal formats. 
 *    Unfortunately, unsigned formats simply didn't work.
 *
 *  Michael Elkins  03/05/98 for mutt 0.90.8
 *    The original code assumed that both snprintf() and vsnprintf() were
 *    missing.  Some systems only have snprintf() but not vsnprintf(), so
 *    the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF.
 *
 *  Andrew Tridgell (tridge@samba.org) Oct 1998
 *    fixed handling of %.0f
 *    added test for HAVE_LONG_DOUBLE
 *
 * tridge@samba.org, idra@samba.org, April 2001
 *    got rid of fcvt code (twas buggy and made testing harder)
 *    added C99 semantics
 *
 * HT authors
 *    * ht_snprintf/ht_vsnprintf return number of characters actually
 *      written instead of the number of characters that would
 *      have been written.
 *    * added '%y' to allow object output using Object's toString() method.
 *    * added '%q[dioux]' for formatting qwords.
 *    * added '%b' for formatting in binary notation.
 **************************************************************/

#include 
#include 
#include 
#include 
#include 
#include 

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "io/types.h"
#include "data.h"

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#ifndef MIN
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif

#ifdef HAVE_LONG_DOUBLE
#define LDOUBLE long double
#else
#define LDOUBLE double
#endif

#ifdef HAVE_LONG_LONG
#define LLONG long long
#else
#define LLONG long
#endif

static size_t dopr(char *buffer, size_t maxlen, const char *format, 
			    va_list args);
static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
				const char *value, int flags, int min, int max);
static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
				long value, int base, int min, int max, int flags);
static void fmtqword(char *buffer, size_t *currlen, size_t maxlen,
				sint64 value, int base, int min, int max, int flags);
static void fmtfp(char *buffer, size_t *currlen, size_t maxlen,
			    LDOUBLE fvalue, int min, int max, int flags);
static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);

/*
 * dopr(): poor man's version of doprintf
 */

/* format read states */
#define DP_S_DEFAULT 0
#define DP_S_FLAGS   1
#define DP_S_MIN     2
#define DP_S_DOT     3
#define DP_S_MAX     4
#define DP_S_MOD     5
#define DP_S_CONV    6
#define DP_S_DONE    7

/* format flags - Bits */
#define DP_F_MINUS      (1 << 0)
#define DP_F_PLUS       (1 << 1)
#define DP_F_SPACE      (1 << 2)
#define DP_F_NUM        (1 << 3)
#define DP_F_ZERO       (1 << 4)
#define DP_F_UP         (1 << 5)
#define DP_F_UNSIGNED   (1 << 6)

/* Conversion Flags */
#define DP_C_SHORT   1
#define DP_C_LONG    2
#define DP_C_LDOUBLE 3
#define DP_C_LLONG   4
#define DP_C_QWORD   5

#define char_to_int(p) ((p)- '0')
#ifndef MAX
#define MAX(p,q) (((p) >= (q)) ? (p) : (q))
#endif

static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args)
{
	char ch;
	LLONG value;
	LDOUBLE fvalue;
	const char *strvalue;
	int min;
	int max;
	int state;
	int flags;
	int cflags;
	size_t currlen;

	state = DP_S_DEFAULT;
	currlen = flags = cflags = min = 0;
	max = -1;
	ch = *format++;

	while (state != DP_S_DONE) {
		if (ch == '\0') state = DP_S_DONE;

		switch(state) {
			case DP_S_DEFAULT:
				if (ch == '%') {
					state = DP_S_FLAGS;
				} else {
					dopr_outch(buffer, &currlen, maxlen, ch);
				}
				ch = *format++;
				break;
			case DP_S_FLAGS:
				switch (ch) {
					case '-':
						flags |= DP_F_MINUS;
						ch = *format++;
						break;
					case '+':
						flags |= DP_F_PLUS;
						ch = *format++;
						break;
					case ' ':
						flags |= DP_F_SPACE;
						ch = *format++;
						break;
					case '#':
						flags |= DP_F_NUM;
						ch = *format++;
						break;
					case '0':
						flags |= DP_F_ZERO;
						ch = *format++;
						break;
					default:
						state = DP_S_MIN;
						break;
				}
				break;
			case DP_S_MIN:
				if (isdigit((unsigned char)ch)) {
					min = 10*min + char_to_int (ch);
					ch = *format++;
				} else if (ch == '*') {
					min = va_arg (args, int);
					ch = *format++;
					state = DP_S_DOT;
				} else {
					state = DP_S_DOT;
				}
				break;
			case DP_S_DOT:
				if (ch == '.') {
					state = DP_S_MAX;
					ch = *format++;
				} else {
					state = DP_S_MOD;
				}
				break;
			case DP_S_MAX:
				if (isdigit((unsigned char)ch)) {
					if (max < 0) max = 0;
					max = 10*max + char_to_int (ch);
					ch = *format++;
				} else if (ch == '*') {
					max = va_arg (args, int);
					ch = *format++;
					state = DP_S_MOD;
				} else {
					state = DP_S_MOD;
				}
				break;
			case DP_S_MOD:
				switch (ch) {
					case 'h':
						cflags = DP_C_SHORT;
						ch = *format++;
						break;
					case 'l':
						cflags = DP_C_LONG;
						ch = *format++;
						if (ch == 'l') {        /* It's a long long */
							cflags = DP_C_LLONG;
							ch = *format++;
						}
						break;
					case 'L':
						cflags = DP_C_LDOUBLE;
						ch = *format++;
						break;
					case 'q':
						cflags = DP_C_QWORD;
						ch = *format++;
						break;
					default:
					break;
				}
				state = DP_S_CONV;
				break;
			case DP_S_CONV:
				switch (ch) {
					case 'b':
						flags |= DP_F_UNSIGNED;
						if (cflags == DP_C_SHORT) {
							value = va_arg (args, unsigned int);
						} else if (cflags == DP_C_LONG) {
							value = (long)va_arg (args, unsigned long int);
						} else if (cflags == DP_C_LLONG) {
							value = (LLONG)va_arg (args, unsigned LLONG);
						} else if (cflags == DP_C_QWORD) {
							sint64 q = va_arg (args, sint64);
							fmtqword(buffer, &currlen, maxlen, q, 2, min, max, flags);
							break;
						} else {
						   value = (long)va_arg (args, unsigned int);
						}
						fmtint (buffer, &currlen, maxlen, value, 2, min, max, flags);
						break;
					case 'd':
					case 'i':
						if (cflags == DP_C_SHORT) {
							value = va_arg (args, int);
						} else if (cflags == DP_C_LONG) {
							value = va_arg (args, long int);
						} else if (cflags == DP_C_LLONG) {
							value = va_arg (args, LLONG);
						} else if (cflags == DP_C_QWORD) {
							sint64 q = va_arg (args, sint64);
							fmtqword(buffer, &currlen, maxlen, q, 10, min, max, flags);
							break;
						} else {
							value = va_arg (args, int);
						}
						fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
						break;
					case 'o':
						flags |= DP_F_UNSIGNED;
						if (cflags == DP_C_SHORT) {
							value = va_arg (args, unsigned int);
						} else if (cflags == DP_C_LONG) {
							value = (long)va_arg (args, unsigned long int);
						} else if (cflags == DP_C_LLONG) {
							value = (long)va_arg (args, unsigned LLONG);
						} else if (cflags == DP_C_QWORD) {
							sint64 q = va_arg (args, sint64);
							fmtqword(buffer, &currlen, maxlen, q, 8, min, max, flags);
							break;
						} else {
							value = (long)va_arg (args, unsigned int);
						}
						fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags);
						break;
					case 'u':
						flags |= DP_F_UNSIGNED;
						if (cflags == DP_C_SHORT) {
							value = va_arg (args, unsigned int);
						} else if (cflags == DP_C_LONG) {
							value = (long)va_arg (args, unsigned long int);
						} else if (cflags == DP_C_LLONG) {
							value = (LLONG)va_arg (args, unsigned LLONG);
						} else if (cflags == DP_C_QWORD) {
							sint64 q = va_arg (args, sint64);
							fmtqword(buffer, &currlen, maxlen, q, 10, min, max, flags);
							break;
						} else {
							value = (long)va_arg (args, unsigned int);
						}
						fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
						break;
					case 'X':
						flags |= DP_F_UP;
					case 'x':
						flags |= DP_F_UNSIGNED;
						if (cflags == DP_C_SHORT) {
							value = va_arg (args, unsigned int);
						} else if (cflags == DP_C_LONG) {
							value = (long)va_arg (args, unsigned long int);
						} else if (cflags == DP_C_LLONG) {
							value = (LLONG)va_arg (args, unsigned LLONG);
						} else if (cflags == DP_C_QWORD) {
							sint64 q = va_arg (args, sint64);
							fmtqword(buffer, &currlen, maxlen, q, 16, min, max, flags);
							break;
						} else {
							value = (long)va_arg (args, unsigned int);
						}
						fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags);
						break;
					case 'f':
						if (cflags == DP_C_LDOUBLE)
							fvalue = va_arg (args, LDOUBLE);
						else
							fvalue = va_arg (args, double);
						/* um, floating point? */
						fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
						break;
					case 'E':
						flags |= DP_F_UP;
					case 'e':
						if (cflags == DP_C_LDOUBLE)
							fvalue = va_arg (args, LDOUBLE);
						else
							fvalue = va_arg (args, double);
						break;
					case 'G':
						flags |= DP_F_UP;
					case 'g':
						if (cflags == DP_C_LDOUBLE)
							fvalue = va_arg (args, LDOUBLE);
						else
							fvalue = va_arg (args, double);
						break;
					case 'c':
						dopr_outch(buffer, &currlen, maxlen, va_arg (args, int));
						break;
					case 's':
						strvalue = va_arg (args, char *);
						if (!strvalue) strvalue = "(null)";
						if (max == -1) {
							max = strlen(strvalue);
						}
						if (min > 0 && max >= 0 && min > max) max = min;
						fmtstr(buffer, &currlen, maxlen, strvalue, flags, min, max);
						break;
					case 'p':
						strvalue = va_arg (args, char *);
						fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags);
						break;
					case 'n':
						if (cflags == DP_C_SHORT) {
							short int *num;
							num = va_arg (args, short int *);
							*num = currlen;
						} else if (cflags == DP_C_LONG) {
							long int *num;
							num = va_arg (args, long int *);
							*num = (long int)currlen;
						} else if (cflags == DP_C_LLONG) {
							LLONG *num;
							num = va_arg (args, LLONG *);
							*num = (LLONG)currlen;
						} else {
							int *num;
							num = va_arg (args, int *);
							*num = currlen;
						}
						break;
					case '%':
						dopr_outch(buffer, &currlen, maxlen, ch);
						break;
					case 'w':
						/* not supported yet, treat as next char */
						ch = *format++;
						break;
					case 'y': {
						/* object */
						Object *obj = va_arg (args, Object *);
						if (obj) {
							currlen += obj->toString(buffer+currlen, maxlen - currlen);
						} else {
							strvalue = "(null)";
							if (max == -1) {
								max = strlen(strvalue);
							}
							if (min > 0 && max >= 0 && min > max) max = min;
							fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max);
						}
						break;
					}
					default:
						/* Unknown, skip */
						break;
				}
				ch = *format++;
				state = DP_S_DEFAULT;
				flags = cflags = min = 0;
				max = -1;
				break;
			case DP_S_DONE:
				break;
			default:
				/* hmm? */
				break; /* some picky compilers need this */
		}
	}
	if (maxlen != 0) {
		if (currlen < maxlen - 1)
			buffer[currlen] = '\0';
		else if (maxlen > 0)
			buffer[maxlen - 1] = '\0';
	}

	return currlen;
}

static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
				const char *value, int flags, int min, int max)
{
	int padlen, strln;     /* amount to pad */
	int cnt = 0;

#ifdef DEBUG_SNPRINTF
	printf("fmtstr min=%d max=%d s=[%s]\n", min, max, value);
#endif

	for (strln = 0; value[strln]; ++strln); /* strlen */
	padlen = min - strln;
	if (padlen < 0)
		padlen = 0;
	if (flags & DP_F_MINUS)
		padlen = -padlen; /* Left Justify */

	while ((padlen > 0) && (cnt < max)) {
		dopr_outch(buffer, currlen, maxlen, ' ');
		--padlen;
		++cnt;
	}
	while (*value && (cnt < max)) {
		dopr_outch(buffer, currlen, maxlen, *value++);
		++cnt;
	}
	while ((padlen < 0) && (cnt < max)) {
		dopr_outch(buffer, currlen, maxlen, ' ');
		++padlen;
		++cnt;
	}
}

/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */

static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
				long value, int base, int min, int max, int flags)
{
#define MAX_CONVERT_PLACES 40
	int signvalue = 0;
	unsigned long uvalue;
	char convert[MAX_CONVERT_PLACES];
	int place = 0;
	int spadlen = 0; /* amount to space pad */
	int zpadlen = 0; /* amount to zero pad */
	int caps = 0;

	if (max < 0)
		max = 0;

	uvalue = value;

	if (!(flags & DP_F_UNSIGNED)) {
		if (value < 0) {
			signvalue = '-';
			uvalue = -value;
		} else {
			if (flags & DP_F_PLUS)  /* Do a sign (+/i) */
				signvalue = '+';
			else if (flags & DP_F_SPACE)
				signvalue = ' ';
		}
	}

	if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */

	do {
		convert[place++] =
			(caps? "0123456789ABCDEF":"0123456789abcdef")[uvalue % (unsigned)base];
		uvalue = (uvalue / (unsigned)base );
	} while (uvalue && (place < MAX_CONVERT_PLACES));
	if (place == MAX_CONVERT_PLACES) place--;
	convert[place] = 0;

	zpadlen = max - place;
	spadlen = min - MAX (max, place) - (signvalue ? 1 : 0);
	if (zpadlen < 0) zpadlen = 0;
	if (spadlen < 0) spadlen = 0;
	if (flags & DP_F_ZERO) {
		zpadlen = MAX(zpadlen, spadlen);
		spadlen = 0;
	}
	if (flags & DP_F_MINUS)
		spadlen = -spadlen; /* Left Justifty */

#ifdef DEBUG_SNPRINTF
	printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
	zpadlen, spadlen, min, max, place);
#endif

	/* Spaces */
	while (spadlen > 0) {
		dopr_outch(buffer, currlen, maxlen, ' ');
		--spadlen;
	}

	/* Sign */
	if (signvalue) dopr_outch(buffer, currlen, maxlen, signvalue);

	/* Zeros */
	if (zpadlen > 0) {
		while (zpadlen > 0) {
			dopr_outch(buffer, currlen, maxlen, '0');
			--zpadlen;
		}
	}

	/* Digits */
	while (place > 0) dopr_outch(buffer, currlen, maxlen, convert[--place]);

	/* Left Justified spaces */
	while (spadlen < 0) {
		dopr_outch(buffer, currlen, maxlen, ' ');
		++spadlen;
	}
}

static void fmtqword(char *buffer, size_t *currlen, size_t maxlen,
				sint64 value, int base, int min, int max, int flags)
{
#undef MAX_CONVERT_PLACES
#define MAX_CONVERT_PLACES 80
	int signvalue = 0;
	uint64 uvalue;
	char convert[MAX_CONVERT_PLACES];
	int place = 0;
	int spadlen = 0; /* amount to space pad */
	int zpadlen = 0; /* amount to zero pad */
	int caps = 0;

	if (max < 0) max = 0;

	uvalue = value;

	if (!(flags & DP_F_UNSIGNED)) {
		if (value < 0) {
			signvalue = '-';
			uvalue = -uvalue;
		} else {
			if (flags & DP_F_PLUS) /* Do a sign (+/i) */
				signvalue = '+';
			else if (flags & DP_F_SPACE)
				signvalue = ' ';
		}
	}

	if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */

	do {
		uint64 uv = uvalue % (uint64)base;
		convert[place++] =
			(caps? "0123456789ABCDEF":"0123456789abcdef")[uv];
		uvalue = (uvalue / (uint64)base);
	} while ((uvalue != 0) && (place < MAX_CONVERT_PLACES));
	if (place == MAX_CONVERT_PLACES) place--;
	convert[place] = 0;

	zpadlen = max - place;
	spadlen = min - MAX (max, place) - (signvalue ? 1 : 0);
	if (zpadlen < 0) zpadlen = 0;
	if (spadlen < 0) spadlen = 0;
	if (flags & DP_F_ZERO) {
		zpadlen = MAX(zpadlen, spadlen);
		spadlen = 0;
	}
	if (flags & DP_F_MINUS) spadlen = -spadlen; /* Left Justifty */

#ifdef DEBUG_SNPRINTF
	printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
	zpadlen, spadlen, min, max, place);
#endif

	/* Spaces */
	while (spadlen > 0) {
		dopr_outch(buffer, currlen, maxlen, ' ');
		--spadlen;
	}

	/* Sign */
	if (signvalue) dopr_outch(buffer, currlen, maxlen, signvalue);

	/* Zeros */
	if (zpadlen > 0) {
		while (zpadlen > 0) {
			dopr_outch(buffer, currlen, maxlen, '0');
			--zpadlen;
		}
	}

	/* Digits */
	while (place > 0) dopr_outch(buffer, currlen, maxlen, convert[--place]);

	/* Left Justified spaces */
	while (spadlen < 0) {
		dopr_outch(buffer, currlen, maxlen, ' ');
		++spadlen;
	}
}

static LDOUBLE abs_val(LDOUBLE value)
{
	return (value < 0) ? -value : value;
}

static LDOUBLE POW10(int exp)
{
	LDOUBLE result = 1;
	   
	while (exp) {
		result *= 10;
		exp--;
	}
  
	return result;
}

static LLONG ROUND(LDOUBLE value)
{
	LLONG intpart;

	intpart = (LLONG)value;
	value = value - intpart;
	if (value >= 0.5) intpart++;

	return intpart;
}

/* a replacement for modf that doesn't need the math library. Should
   be portable, but slow */
static double my_modf(double x0, double *iptr)
{
	int i;
	long l;
	double x = x0;
	double f = 1.0;

	for (i=0;i<100;i++) {
		l = (long)x;
		if (l <= (x+1) && l >= (x-1)) break;
		x *= 0.1;
		f *= 10.0;
	}

	if (i == 100) {
		/* yikes! the number is beyond what we can handle. What do we do? */
		(*iptr) = 0;
		return 0;
	}

	if (i != 0) {
		double i2;
		double ret;

		ret = my_modf(x0-l*f, &i2);
		(*iptr) = l*f + i2;
		return ret;
	}

	(*iptr) = l;
	return x - (*iptr);
}


static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
			    LDOUBLE fvalue, int min, int max, int flags)
{
	   int signvalue = 0;
	   double ufvalue;
	   char iconvert[311];
	   char fconvert[311];
	   int iplace = 0;
	   int fplace = 0;
	   int padlen = 0; /* amount to pad */
	   int zpadlen = 0; 
	   int caps = 0;
	   int index;
	   double intpart;
	   double fracpart;
	   double temp;
  
	   /* 
	    * AIX manpage says the default is 0, but Solaris says the default
	    * is 6, and sprintf on AIX defaults to 6
	    */
	   if (max < 0)
			 max = 6;

	   ufvalue = abs_val (fvalue);

	   if (fvalue < 0) {
			 signvalue = '-';
	   } else {
			 if (flags & DP_F_PLUS) { /* Do a sign (+/i) */
				    signvalue = '+';
			 } else {
				    if (flags & DP_F_SPACE)
						  signvalue = ' ';
			 }
	   }

#if 0
	   if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
#endif

#if 0
	    if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */
#endif

	   /* 
	    * Sorry, we only support 16 digits past the decimal because of our 
	    * conversion method
	    */
	   if (max > 16)
			 max = 16;

	   /* We "cheat" by converting the fractional part to integer by
	    * multiplying by a factor of 10
	    */

	   temp = ufvalue;
	   my_modf(temp, &intpart);

	   fracpart = ROUND((POW10(max)) * (ufvalue - intpart));
	   
	   if (fracpart >= POW10(max)) {
			 intpart++;
			 fracpart -= POW10(max);
	   }


	   /* Convert integer part */
	   do {
			 temp = intpart;
			 my_modf(intpart*0.1, &intpart);
			 temp = temp*0.1;
			 index = (int) ((temp -intpart +0.05)* 10.0);
			 /* index = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */
			 /* printf ("%llf, %f, %x\n", temp, intpart, index); */
			 iconvert[iplace++] =
				    (caps? "0123456789ABCDEF":"0123456789abcdef")[index];
	   } while (intpart && (iplace < 311));
	   if (iplace == 311) iplace--;
	   iconvert[iplace] = 0;

	   /* Convert fractional part */
	   if (fracpart)
	   {
			 do {
				    temp = fracpart;
				    my_modf(fracpart*0.1, &fracpart);
				    temp = temp*0.1;
				    index = (int) ((temp -fracpart +0.05)* 10.0);
				    /* index = (int) ((((temp/10) -fracpart) +0.05) *10); */
				    /* printf ("%lf, %lf, %ld\n", temp, fracpart, index); */
				    fconvert[fplace++] =
				    (caps? "0123456789ABCDEF":"0123456789abcdef")[index];
			 } while(fracpart && (fplace < 311));
			 if (fplace == 311) fplace--;
	   }
	   fconvert[fplace] = 0;
  
	   /* -1 for decimal point, another -1 if we are printing a sign */
	   padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0); 
	   zpadlen = max - fplace;
	   if (zpadlen < 0) zpadlen = 0;
	   if (padlen < 0) 
			 padlen = 0;
	   if (flags & DP_F_MINUS) 
			 padlen = -padlen; /* Left Justifty */
	   
	   if ((flags & DP_F_ZERO) && (padlen > 0)) {
			 if (signvalue) {
				    dopr_outch(buffer, currlen, maxlen, signvalue);
				    --padlen;
				    signvalue = 0;
			 }
			 while (padlen > 0) {
				    dopr_outch(buffer, currlen, maxlen, '0');
				    --padlen;
			 }
	   }
	   while (padlen > 0) {
			 dopr_outch(buffer, currlen, maxlen, ' ');
			 --padlen;
	   }
	   if (signvalue) 
			 dopr_outch(buffer, currlen, maxlen, signvalue);
	   
	   while (iplace > 0) 
			 dopr_outch(buffer, currlen, maxlen, iconvert[--iplace]);

#ifdef DEBUG_SNPRINTF
	   printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen);
#endif

	   /*
	    * Decimal point.  This should probably use locale to find the correct
	    * char to print out.
	    */
	   if (max > 0) {
			 dopr_outch(buffer, currlen, maxlen, '.');
			 
			 while (fplace > 0) 
				    dopr_outch(buffer, currlen, maxlen, fconvert[--fplace]);
	   }
	   
	   while (zpadlen > 0) {
			 dopr_outch(buffer, currlen, maxlen, '0');
			 --zpadlen;
	   }

	   while (padlen < 0) {
			 dopr_outch(buffer, currlen, maxlen, ' ');
			 ++padlen;
	   }
}

static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
{
	if (*currlen < maxlen) {
		buffer[(*currlen)] = c;
	}
	(*currlen)++;
}

int ht_vsnprintf (char *str, size_t count, const char *fmt, va_list args)
{
	if ((int)count < 0) count = 0;
	int res = dopr(str, count, fmt, args);
	if (count) count--;
	return str ? MIN(res, (int)count) : count;
}

int ht_snprintf(char *str, size_t count, const char *fmt,...)
{
	int ret;
	va_list ap;

	va_start(ap, fmt);
	ret = ht_vsnprintf(str, count, fmt, ap);
	va_end(ap);
	return ret;
}

int ht_vasprintf(char **ptr, const char *format, va_list ap)
{
	int ret;

	ret = dopr(NULL, 0, format, ap);
	if (ret <= 0) {
		*ptr = NULL;
		return 0;
	}

	(*ptr) = ht_malloc(ret+1);
	if (!*ptr) return 0;
	ret = ht_vsnprintf(*ptr, ret+1, format, ap);

	return ret;
}


int ht_asprintf(char **ptr, const char *format, ...)
{
	va_list ap;
	int ret;

	va_start(ap, format);
	ret = ht_vasprintf(ptr, format, ap);
	va_end(ap);

	return ret;
}

int ht_vfprintf(FILE *file, const char *fmt, va_list args)
{
#if 0
	char *buf;
	int ret = ht_vasprintf(&buf, fmt, args);
	fputs(buf, file);
	free(buf);
#else
	char buf[10024];
	int ret = ht_vsnprintf(buf, sizeof buf, fmt, args);
	fputs(buf, file);
#endif
	return ret;
}

int ht_fprintf(FILE *file, const char *fmt, ...)
{
	va_list ap;
	int ret;

	va_start(ap, fmt);
	ret = ht_vfprintf(file, fmt, ap);
	va_end(ap);

	return ret;
}


int ht_vprintf(const char *fmt, va_list args)
{
	return ht_vfprintf(stdout, fmt, args);
}

int ht_printf(const char *fmt, ...)
{
	va_list ap;
	int ret;

	va_start(ap, fmt);
	ret = ht_vprintf(fmt, ap);
	va_end(ap);

	return ret;
}


ht-2.0.22/htxeximg.h0000644000175000001440000000242710615345251011142 00000000000000/* 
 *	HT Editor
 *	htxeximg.h
 *
 *	Copyright (C) 2006 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTXEXIMG_H__
#define __HTXEXIMG_H__

#include "htanaly.h"
#include "htxex.h"
#include "formats.h"

extern format_viewer_if htxeximage_if;

/*
 *	CLASS ht_xex_aviewer
 */

class ht_xex_aviewer: public ht_aviewer {
public:
	ht_xex_shared_data *xex_shared;
		void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Analyser *Analyser, ht_xex_shared_data *xex_shared);
//	virtual bool func_handler(eval_scalar *result, char *name, eval_scalarlist *params);
	virtual void setAnalyser(Analyser *a);
};

#endif /* !__HTXEXIMG_H__ */
ht-2.0.22/KNOWNBUGS0000644000175000001440000000071610036542040010423 00000000000000  KnownBugs
=============

- x86: ea19000090 in use16 disassembles incorrectly

- big-endian ELF: section header flag details dont work...
- analyser: 'follow' is always 32-bit, little-endian.

- Cursor misplacement in */image (F4)
- Help / features / configuration PgDn
- cancelling search yields "not found"
- window resize + cursor position
- going to lines with ofs % 16 !=0 (+clipboard)
- some problems when run on non-x86 systems... (Sparc bus error e.g.)
ht-2.0.22/htlepage.h0000644000175000001440000000153310206756710011075 00000000000000/* 
 *	HT Editor
 *	htlepage.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTLEPAGE_H__
#define __HTLEPAGE_H__

#include "formats.h"

extern format_viewer_if htlepagemaps_if;

#endif /* !__HTLEPAGE_H__ */

ht-2.0.22/htformat.h0000644000175000017500000004253312127651417011143 00000000000000/*
 *	HT Editor
 *	htformat.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTFORMAT_H__
#define __HTFORMAT_H__

class ht_format_group;

#include "evalx.h"
#include "data.h"
#include "htobj.h"
#include "strtools.h"
#include "formats.h"

class ht_sub;

struct LINE_ID {
	ID id1;
	ID id2;
	ID id3;
	ID id4;
	ID id5;
};

struct uformat_viewer_pos {
	/* which line ? */
	ht_sub *sub;
	LINE_ID line_id;
	/* which tag ? */
	int tag_group;
	int tag_idx;
};

union viewer_pos {
	uformat_viewer_pos u;
};

// search classes
#define SC_PHYSICAL			0    // search in underlying binary data
#define SC_VISUAL			1    // search in displayed text

/*
 *	CLASS ht_search_request
 */
 
class ht_search_request: public Object {
public:
	uint search_class;
	uint type;
	uint flags;
	
		ht_search_request(uint search_class, uint type, uint flags);
	virtual ht_search_request *clone() const = 0;
};

/*
 *	CLASS ht_search_result
 */
 
class ht_search_result: public Object {
public:
	uint search_class;

	ht_search_result(uint asearch_class): search_class(asearch_class) {}
};

/*
 *	CLASS ht_physical_search_result
 */
 
class ht_physical_search_result: public ht_search_result {
public:
	FileOfs offset;
	uint size;
	
	ht_physical_search_result(): ht_search_result(SC_PHYSICAL) {}
};

/*
 *	CLASS ht_visual_search_result
 */
 
class ht_visual_search_result: public ht_search_result {
public:
	viewer_pos pos;
	uint xpos;
	uint length;
	
	ht_visual_search_result(): ht_search_result(SC_VISUAL) {}
};

/*
 *	formats
 */

class ht_format_loc: public Object {
public:
	const char *name;
	FileOfs start;
	FileOfs length;
};

/*
 *	CLASS ht_viewer
 */

/* caps */
#define VC_NULL		0x0000
#define VC_EDIT		0x0001
#define VC_GOTO		0x0002
#define VC_SEARCH		0x0004
#define VC_REPLACE		0x0008
#define VC_RESIZE		0x0010

class ht_viewer: public ht_view {
protected:
	uint caps;

/* new */
	virtual	const char *func(uint i, bool execute);
public:
		void init(Bounds *b, const char *desc, uint caps);
/* overwritten */
	virtual	void handlemsg(htmsg *msg);
};

/*
 *	CLASS ht_format_viewer
 */

class ht_format_viewer: public ht_viewer {
protected:
	File *file;
// last search (request)
	ht_search_request *last_search_request;
	bool last_search_physical;
	union {
		FileOfs last_search_end_ofs;
		viewer_pos last_search_end_pos;
	};

/* new */
	virtual	bool compeq_viewer_pos(viewer_pos *a, viewer_pos *b);

	virtual	void vstate_restore(Object *view_state);
	virtual	Object *vstate_create();
	
	virtual	bool next_logical_pos(viewer_pos pos, viewer_pos *npos);
	virtual	bool next_logical_offset(FileOfs ofs, FileOfs *nofs);
public:
	ht_format_group *format_group;

		void init(Bounds *b, const char *desc, uint caps, File *file, ht_format_group *format_group);
	virtual	void done();
/* overwritten */
	virtual	void handlemsg(htmsg *msg);
/* new */
	virtual	bool pos_to_offset(viewer_pos pos, FileOfs *ofs);
	virtual	bool offset_to_pos(FileOfs ofs, viewer_pos *pos);
	/* position indicator string */
	virtual	int get_pindicator_str(char *buf, int max_len);
	/* scrollbar pos */
	virtual	bool get_hscrollbar_pos(int *pstart, int *psize);
	virtual	bool get_vscrollbar_pos(int *pstart, int *psize);
	/* physical file location(s) */
	virtual	void loc_enum_start();
	virtual	bool loc_enum_next(ht_format_loc *loc);

	/* physical address (offset) functions */
	virtual	bool get_current_offset(FileOfs *ofs);
	virtual	bool goto_offset(FileOfs ofs, bool save_vstate);
	virtual	uint pread(FileOfs ofs, void *buf, uint size);
	virtual	ht_search_result *psearch(ht_search_request *search, FileOfs start, FileOfs end);
	virtual	void pselect_add(FileOfs start, FileOfs end);
	virtual	void pselect_get(FileOfs *start, FileOfs *end);
	virtual	void pselect_set(FileOfs start, FileOfs end);
	virtual	uint pwrite(FileOfs ofs, void *buf, uint size);
	virtual	bool string_to_offset(char *string, FileOfs *ofs);
	virtual	bool qword_to_offset(uint64 q, FileOfs *ofs);

	virtual	bool get_current_real_offset(FileOfs *ofs);

	/* visual address (viewer pos) functions */
	virtual	bool get_current_pos(viewer_pos *pos);
	virtual	bool goto_pos(viewer_pos pos, bool save_vstate);
	virtual	uint vread(viewer_pos pos, void *buf, uint size);
	virtual	ht_search_result *vsearch(ht_search_request *search, viewer_pos start, viewer_pos end);
	virtual	void vselect_add(viewer_pos start, viewer_pos end);
	virtual	void vselect_get(viewer_pos *start, viewer_pos *end);
	virtual	void vselect_set(viewer_pos start, viewer_pos end);
	virtual	uint vwrite(viewer_pos pos, void *buf, uint size);
	virtual	bool string_to_pos(const char *string, viewer_pos *pos);
	virtual	bool qword_to_pos(uint64 q, viewer_pos *pos);

	/* string evaluation */
	virtual	bool func_handler(eval_scalar *result, char *name, eval_scalarlist *params);
	virtual	bool symbol_handler(eval_scalar *result, char *name);

	/* search related */
		bool continue_search();
	virtual	bool show_search_result(ht_search_result *result);
	/* misc */
		void clear_viewer_pos(viewer_pos *p);
		File *get_file();
		bool string_to_qword(const char *string, uint64 *q);
		bool vstate_save();
};

/*
 *	CLASS ht_format_viewer_entry
 */

class ht_format_viewer_entry: public Object {
public:
	ht_view *instance;
	format_viewer_if *interface;
};

/*
 *	CLASS ht_format_group
 */

class ht_format_group: public ht_format_viewer {
protected:
	Container *format_views;
	void *shared_data;
	bool editable_file;
	bool own_file;
	ht_xgroup *xgroup;

/* new */
		void init_ifs(format_viewer_if **ifs);
		void done_ifs();
			
		bool init_if(format_viewer_if *i);
		bool done_if(format_viewer_if *i, ht_view *v);
			
		bool edit();
public:
		void init(Bounds *b, int options, const char *desc, File *file, bool own_file, bool editable_file, format_viewer_if **ifs, ht_format_group *format_group);
	virtual	void done();
/* overwritten */
	virtual	int childcount() const;
	virtual	bool focus(ht_view *view);
	virtual	const char *func(uint i, bool execute);
		void getbounds(Bounds *b);
	virtual ht_view *getfirstchild();
	virtual	ht_view *getselected();
	virtual	int get_pindicator_str(char *buf, int max_len);
	virtual	bool get_hscrollbar_pos(int *pstart, int *psize);
	virtual	bool get_vscrollbar_pos(int *pstart, int *psize);
	virtual	void handlemsg(htmsg *msg);
	virtual	void move(int x, int y);
	virtual	void receivefocus();
	virtual	void redraw();
	virtual	void releasefocus();
	virtual	void resize(int rw, int rh);
	virtual	void setgroup(ht_group *group);
	virtual	bool func_handler(eval_scalar *result, char *name, eval_scalarlist *params);
	virtual	bool symbol_handler(eval_scalar *result, char *name);
/* new */
	virtual	void insert(ht_view *view);
		void remove(ht_view *view);
		void *get_shared_data();
};

/*
 *	CLASS ht_uformat_viewer
 */

#define cursor_state_visible		0
#define cursor_state_invisible	1
#define cursor_state_disabled		2

class ht_uformat_viewer: public ht_format_viewer {
protected:
	ht_sub *first_sub, *last_sub;
/* top line position */
	uformat_viewer_pos top;
/* cursor line and state and tag position */
	uformat_viewer_pos cursor;
	int cursor_ypos;
	int cursor_state;
	bool cursor_select;
	FileOfs cursor_select_start;
	uint32 cursor_select_cursor_length;
	int cursor_tag_micropos;
/* selection*/
	FileOfs sel_start;
	FileOfs sel_end;
/* visual info */
	int cursor_visual_xpos;
	int cursor_visual_length;
/* misc info */
	int cursor_tag_class;
//	union {
		FileOfs cursor_tag_offset;
		struct {
			LINE_ID id;
		} cursor_tag_id;
//	};
	char cursor_line[1024];
/* tag palettes */
	palette tagpal;
/**/
	int xscroll;

	bool uf_initialized;

	bool isdirty_cursor_line;
	int scroll_offset;

/* overwritten */
	virtual	const char *func(uint i, bool execute);
	virtual	bool next_logical_pos(viewer_pos pos, viewer_pos *npos);
	virtual	bool next_logical_offset(FileOfs ofs, FileOfs *nofs);
	virtual	Object *vstate_create();
	virtual	void vstate_restore(Object *view_state);
/* new */
	int address_input(const char *title, char *buf, int buflen, uint32 histid);
	void adjust_cursor_group();
	void adjust_cursor_idx();
	int center_view(viewer_pos p);
	void clear_subs();
	bool compeq_viewer_pos(uformat_viewer_pos *a, uformat_viewer_pos *b);
	void check_cursor_visibility();
	void clear_viewer_pos(uformat_viewer_pos *p);
	int cursor_left();
	int cursor_right();
	int cursor_down(int n);
	int cursor_up(int n);
	int cursor_home();
	int cursor_end();
	void cursor_tab();
	void cursorline_dirty();
	void cursorline_get();
	virtual int cursormicro_forward();
	virtual int cursormicro_backward();
	virtual int cursormicroedit_forward();
	bool edit_end();
	bool edit_input(byte b);
	int edit_input_c2h(byte b);
	int edit_input_c2d(byte b);
	void edit_input_correctpos();
	bool edit_start();
	bool edit_update();
	bool edit();
	bool find_first_tag(uformat_viewer_pos *p, int limit);
	bool find_first_edit_tag_with_offset(uformat_viewer_pos *p, int limit, FileOfs offset);
	void focus_cursor();
	vcp getcolor_tag(uint pal_index);
	bool get_current_tag(char **tag);
	bool get_current_tag_size(uint32 *size);
	vcp get_tag_color_edit(FileOfs tag_offset, uint size, bool atcursoroffset, bool iscursor);
	int next_line(uformat_viewer_pos *p, int n);
	int prev_line(uformat_viewer_pos *p, int n);
	void print_tagstring(int x, int y, int maxlen, int xscroll, char *tagstring, bool cursor_in_line);
	virtual bool ref();
	bool ref_desc(ID id, FileOfs offset, uint size, bool bigendian);
	bool ref_flags(ID id, FileOfs offset);
	virtual bool ref_sel(LINE_ID *id);
	virtual void reloadpalette();
	uint render_tagstring(char *chars, vcp *colors, uint maxlen, char *tagstring, bool cursor_in_line);
	void render_tagstring_desc(const char **string, int *length, vcp *tag_color, char *tag, uint size, bool bigendian, bool is_cursor);
	uint render_tagstring_single(char *chars, vcp *colors, uint maxlen, uint offset, const char *text, uint len, vcp color);
	void scroll_up(int n);
	void scroll_down(int n);
	void select_mode_off();
	void select_mode_on();
	void select_mode_pre();
	void select_mode_post(bool lastpos);
	bool set_cursor(uformat_viewer_pos p);
	void update_micropos();
	void update_misc_info();
	void update_visual_info();
	void update_ypos();
public:
	uint search_caps;
	
		void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group);
	virtual	void done();
/* overwritten */
	virtual	void config_changed();
	virtual	void clear_viewer_pos(viewer_pos *p);
	virtual	void draw();
	virtual	bool get_current_offset(FileOfs *offset);
	virtual	bool get_current_pos(viewer_pos *pos);
	virtual	bool goto_offset(FileOfs offset, bool save_vstate);
	virtual	bool goto_pos(viewer_pos pos, bool save_vstate);
	virtual	void handlemsg(htmsg *msg);
	virtual	ht_search_result *psearch(ht_search_request *search, FileOfs start, FileOfs end);
	virtual	void pselect_add(FileOfs start, FileOfs end);
	virtual	void pselect_get(FileOfs *start, FileOfs *end);
	virtual	void pselect_set(FileOfs start, FileOfs end);
	virtual	uint pwrite(FileOfs ofs, void *buf, uint size);
	virtual	bool qword_to_offset(uint64 q, FileOfs *ofs);
	virtual	ht_search_result *vsearch(ht_search_request *search, viewer_pos start, viewer_pos end);
/* new */
	virtual	bool compeq_viewer_pos(viewer_pos *a, viewer_pos *b);
		void complete_init();
	virtual	void insertsub(ht_sub *sub);
		void sendsubmsg(int msg);
		void sendsubmsg(htmsg *msg);
};

/*
 *	CLASS ht_sub
 */

/* search results */
#define SR_NOT_FOUND		0
#define SR_FOUND			1
#define SR_NOT_SUPPORTED		2

class ht_sub: public Object {
protected:
	File *file;
public:
	ht_uformat_viewer *uformat_viewer;
	ht_sub *prev, *next;

		void init(File *file);
/* new */
	virtual	bool convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id);
	virtual	bool convert_id_to_ofs(const LINE_ID line_id, FileOfs *offset);
	virtual	bool closest_line_id(LINE_ID *line_id);
	virtual	void first_line_id(LINE_ID *line_id);
	virtual	bool getline(char *line, int maxlen, const LINE_ID line_id);
	virtual	void handlemsg(htmsg *msg);
	virtual	void last_line_id(LINE_ID *line_id);
	virtual	int next_line_id(LINE_ID *line_id, int n);
	virtual	int prev_line_id(LINE_ID *line_id, int n);
	virtual	bool ref(LINE_ID *id);
	virtual	ht_search_result *search(ht_search_request *search, FileOfs start, FileOfs end);
};

/*
 *	CLASS ht_linear_sub
 */

class ht_linear_sub: public ht_sub {
protected:
	FileOfs fofs;
	FileOfs fsize;
public:
		void init(File *file, FileOfs offset, FileOfs size);
/* overwritten */
	virtual	void handlemsg(htmsg *msg);
	virtual	ht_search_result *search(ht_search_request *search, FileOfs start, FileOfs end);
};

/*
 *	CLASS ht_hex_sub
 */

class ht_hex_sub: public ht_linear_sub {
protected:
	uint disp;
	uint line_length;
	uint uid;
public:
		void init(File *file, FileOfs ofs, FileOfs size, uint line_length, uint uid, int disp=-1);
		int  get_line_length();
		void set_line_length(uint line_length);
		int  get_disp();
		void set_disp(uint disp);
	/* overwritten */
	virtual	bool convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id);
	virtual	bool convert_id_to_ofs(const LINE_ID line_id, FileOfs *offset);
	virtual	void first_line_id(LINE_ID *line_id);
	virtual	bool getline(char *line, int maxlen, const LINE_ID line_id);
	virtual	void last_line_id(LINE_ID *line_id);
	virtual	int next_line_id(LINE_ID *line_id, int n);
	virtual	int prev_line_id(LINE_ID *line_id, int n);
};

/*
 *	CLASS ht_mask_sub
 */

struct ht_mask_ptable {
	const char *desc;
	const char *fields;
};
 
class ht_mask_sub: public ht_sub {
protected:
	Array masks;
	uint uid;
public:
		ht_mask_sub(): masks(true) {}
 
		void init(File *file, uint uid);
/* overwritten */
	virtual	void first_line_id(LINE_ID *line_id);
	virtual	bool getline(char *line, int maxlen, const LINE_ID line_id);
	virtual	void last_line_id(LINE_ID *line_id);
	virtual	int next_line_id(LINE_ID *line_id, int n);
	virtual	int prev_line_id(LINE_ID *line_id, int n);
/* new */
	virtual	void add_mask(const char *tagstr);
	virtual	void add_mask_table(char **tagstr);
	virtual	void add_staticmask(const char *statictag_str, FileOfs reloc, bool std_bigendian);
	virtual	void add_staticmask_table(char **statictag_table, FileOfs reloc, bool std_bigendian);
	virtual	void add_staticmask_ptable(ht_mask_ptable *statictag_ptable, FileOfs reloc, bool std_bigendian);
};

/*
 *	CLASS ht_layer_sub
 */

class ht_layer_sub: public ht_sub {
protected:
	ht_sub *sub;
	bool own_sub;
public:
		void init(File *file, ht_sub *sub, bool own_sub = true);
	virtual	void done();
/* overwritten */
	virtual	bool convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id);
	virtual	bool convert_id_to_ofs(const LINE_ID line_id, FileOfs *offset);
	virtual	bool closest_line_id(LINE_ID *line_id);
	virtual	void first_line_id(LINE_ID *line_id);
	virtual	bool getline(char *line, int maxlen, const LINE_ID line_id);
	virtual	void handlemsg(htmsg *msg);
	virtual	void last_line_id(LINE_ID *line_id);
	virtual	int next_line_id(LINE_ID *line_id, int n);
	virtual	int prev_line_id(LINE_ID *line_id, int n);
	virtual	bool ref(LINE_ID *id);
	virtual	ht_search_result *search(ht_search_request *search, FileOfs start, FileOfs end);
};

/*
 *	CLASS ht_collapsable_sub
 */

class ht_collapsable_sub: public ht_layer_sub {
protected:
	char *nodestring;
	bool collapsed;
	LINE_ID fid;
	LINE_ID myfid;
public:
		void init(File *file, ht_sub *sub, bool own_sub, const char *nodename, bool collapsed);
	virtual	void done();
/* new */
	virtual	bool convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id);
	virtual	bool convert_id_to_ofs(const LINE_ID line_id, FileOfs *offset);
	virtual	void first_line_id(LINE_ID *line_id);
	virtual	bool getline(char *line, int maxlen, const LINE_ID line_id);
	virtual	void last_line_id(LINE_ID *line_id);
	virtual	int next_line_id(LINE_ID *line_id, int n);
	virtual	int prev_line_id(LINE_ID *line_id, int n);
	virtual	bool ref(LINE_ID *id);
	virtual	ht_search_result *search(ht_search_request *search, FileOfs start, FileOfs end);
};

/*
 *	CLASS ht_group_sub
 */

class ht_group_sub: public ht_sub {
protected:
	Container *subs;
public:
		void init(File *file);
	virtual	void done();
/* overwritten */
	virtual	bool convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id);
	virtual	bool convert_id_to_ofs(const LINE_ID line_id, FileOfs *offset);
	virtual	void first_line_id(LINE_ID *line_id);
	virtual	bool getline(char *line, int maxlen, const LINE_ID line_id);
	virtual	void handlemsg(htmsg *msg);
	virtual	void last_line_id(LINE_ID *line_id);
	virtual	int next_line_id(LINE_ID *line_id, int n);
	virtual	int prev_line_id(LINE_ID *line_id, int n);
	virtual	bool ref(LINE_ID *id);
	virtual	ht_search_result *search(ht_search_request *search, FileOfs start, FileOfs end);
/* new */
		void insertsub(ht_sub *sub);
};

ht_search_result *linear_expr_search(ht_search_request *search, FileOfs start, FileOfs end, ht_sub *sub, ht_uformat_viewer *ufv, FileOfs fofs, FileOfs fsize);
ht_search_result *linear_bin_search(ht_search_request *search, FileOfs start, FileOfs end, File *file, FileOfs fofs, FileOfs fsize);

void clear_line_id(LINE_ID *l);
bool compeq_line_id(const LINE_ID &a, const LINE_ID &b);

#endif /* __HTFORMAT_H__ */

ht-2.0.22/install-sh0000644000175000001440000001266507530222242011136 00000000000000#!/bin/sh
#
# install - install a program, script, or datafile
# This comes from X11R5 (mit/util/scripts/install.sh).
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission.  M.I.T. makes no representations about the
# suitability of this software for any purpose.  It is provided "as is"
# without express or implied warranty.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.  It can only install one file at a time, a restriction
# shared with many OS's install programs.


# set DOITPROG to echo to test this script

# Don't use :- since 4.3BSD and earlier shells don't like it.
doit="${DOITPROG-}"


# put in absolute paths if you don't have them in your path; or use env. vars.

mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"
mkdirprog="${MKDIRPROG-mkdir}"

transformbasename=""
transform_arg=""
instcmd="$mvprog"
chmodcmd="$chmodprog 0755"
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
dir_arg=""

while [ x"$1" != x ]; do
    case $1 in
	-c) instcmd="$cpprog"
	    shift
	    continue;;

	-d) dir_arg=true
	    shift
	    continue;;

	-m) chmodcmd="$chmodprog $2"
	    shift
	    shift
	    continue;;

	-o) chowncmd="$chownprog $2"
	    shift
	    shift
	    continue;;

	-g) chgrpcmd="$chgrpprog $2"
	    shift
	    shift
	    continue;;

	-s) stripcmd="$stripprog"
	    shift
	    continue;;

	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
	    shift
	    continue;;

	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
	    shift
	    continue;;

	*)  if [ x"$src" = x ]
	    then
		src=$1
	    else
		# this colon is to work around a 386BSD /bin/sh bug
		:
		dst=$1
	    fi
	    shift
	    continue;;
    esac
done

if [ x"$src" = x ]
then
	echo "install:	no input file specified"
	exit 1
else
	:
fi

if [ x"$dir_arg" != x ]; then
	dst=$src
	src=""
	
	if [ -d $dst ]; then
		instcmd=:
		chmodcmd=""
	else
		instcmd=$mkdirprog
	fi
else

# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad 
# if $src (and thus $dsttmp) contains '*'.

	if [ -f $src -o -d $src ]
	then
		:
	else
		echo "install:  $src does not exist"
		exit 1
	fi
	
	if [ x"$dst" = x ]
	then
		echo "install:	no destination specified"
		exit 1
	else
		:
	fi

# If destination is a directory, append the input filename; if your system
# does not like double slashes in filenames, you may need to add some logic

	if [ -d $dst ]
	then
		dst="$dst"/`basename $src`
	else
		:
	fi
fi

## this sed command emulates the dirname command
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`

# Make sure that the destination directory exists.
#  this part is taken from Noah Friedman's mkinstalldirs script

# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
	'
IFS="${IFS-${defaultIFS}}"

oIFS="${IFS}"
# Some sh's can't handle IFS=/ for some reason.
IFS='%'
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
IFS="${oIFS}"

pathcomp=''

while [ $# -ne 0 ] ; do
	pathcomp="${pathcomp}${1}"
	shift

	if [ ! -d "${pathcomp}" ] ;
	   then
		$mkdirprog "${pathcomp}"
	else
		:
	fi

	pathcomp="${pathcomp}/"
done
fi

if [ x"$dir_arg" != x ]
then
	$doit $instcmd $dst &&

	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
else

# If we're going to rename the final executable, determine the name now.

	if [ x"$transformarg" = x ] 
	then
		dstfile=`basename $dst`
	else
		dstfile=`basename $dst $transformbasename | 
			sed $transformarg`$transformbasename
	fi

# don't allow the sed command to completely eliminate the filename

	if [ x"$dstfile" = x ] 
	then
		dstfile=`basename $dst`
	else
		:
	fi

# Make a temp file name in the proper directory.

	dsttmp=$dstdir/#inst.$$#

# Move or copy the file name to the temp name

	$doit $instcmd $src $dsttmp &&

	trap "rm -f ${dsttmp}" 0 &&

# and set any options; do chmod last to preserve setuid bits

# If any of these fail, we abort the whole thing.  If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $instcmd $src $dsttmp" command.

	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&

# Now rename the file to the real destination.

	$doit $rmcmd -f $dstdir/$dstfile &&
	$doit $mvcmd $dsttmp $dstdir/$dstfile 

fi &&


exit 0
ht-2.0.22/htmz.h0000644000175000001440000000250110615341620010254 00000000000000/* 
 *	HT Editor
 *	htmz.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTMZ_H__
#define __HTMZ_H__

#include "formats.h"

#include "mzstruct.h"

#define DESC_MZ "mz - dos exe"
#define DESC_MZ_HEADER "mz/header"
#define DESC_MZ_REL "mz/relocations"
#define DESC_MZ_IMAGE "mz/image"

extern format_viewer_if htmz_if;

struct ht_mz_shared_data {
	IMAGE_MZ_HEADER header;
};

class ht_mz: public ht_format_group {
protected:
	bool loc_enum;
public:

			void	init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group);
	virtual	void done();
/* overwritten */
	virtual   void loc_enum_start();
	virtual   bool loc_enum_next(ht_format_loc *loc);
};

#endif /* !__HTMZ_H__ */
ht-2.0.22/htclipboard.cc0000644000175000001440000001533511014121240011720 00000000000000/*
 *	HT Editor
 *	htclipboard.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "htclipboard.h"
#include "htctrl.h"
#include "htsearch.h"
#include "strtools.h"
#include "snprintf.h"
#include "tools.h"
#include "io/file.h"

#include 
#include 

ht_clipboard *clipboard;

class ht_clipboard_copy_history: public Object {
public:
	char *source;
	FileOfs start;
	FileOfs size;
	time_t time;

	ht_clipboard_copy_history(const char *aSource, FileOfs aStart, FileOfs aSize, time_t aTime)
	{
		source = ht_strdup(aSource);
		start = aStart;
		size = aSize;
		time = aTime;
	}
	
	virtual ~ht_clipboard_copy_history() {
		free(source);
	}
};

/*
 *	CLASS ht_clipboard
 */

ht_clipboard::ht_clipboard()
	: MemoryFile(0, 0, IOAM_READ | IOAM_WRITE)
{
	copy_history = new Array(true);
	select_start = 0;
	select_len = 0;
}

ht_clipboard::~ht_clipboard()
{
	delete copy_history;
}

void ht_clipboard::clear()
{
	truncate(0);
	copy_history->delAll();
	htmsg m;
	m.msg = msg_file_changed;
	m.data1.ptr = this;
	m.type = mt_broadcast;
	app->sendmsg(&m);
}

uint	ht_clipboard::write(const void *buf, uint size)
{
	htmsg m;
	m.msg = msg_file_changed;
	m.data1.ptr = this;
	m.type = mt_broadcast;
	app->sendmsg(&m);
	return MemoryFile::write(buf, size);
}

/*
 *	CLASS ht_clipboard_viewer
 */

void ht_clipboard_viewer::init(Bounds *b, const char *desc, int caps, ht_clipboard *clipb, ht_format_group *format_group)
{
	ht_uformat_viewer::init(b, desc, caps, clipboard, format_group);
	
	search_caps |= SEARCHMODE_BIN | SEARCHMODE_EVALSTR | SEARCHMODE_EXPR;

	lastentrycount = 999999999;
	update_content();
}

void ht_clipboard_viewer::draw()
{
	update_content();
	ht_uformat_viewer::draw();
}

void ht_clipboard_viewer::handlemsg(htmsg *msg)
{
	if (msg->msg == msg_file_changed) {
		if (msg->data1.ptr == clipboard) {
			dirtyview();
			clearmsg(msg);
			return;
		}
	}
	ht_uformat_viewer::handlemsg(msg);
}

void ht_clipboard_viewer::pselect_add(FileOfs start, FileOfs end)
{
	ht_uformat_viewer::pselect_add(start, end);
	selection_changed();
}

void ht_clipboard_viewer::pselect_set(FileOfs start, FileOfs end)
{
	ht_uformat_viewer::pselect_set(start, end);
	selection_changed();
}

void ht_clipboard_viewer::selection_changed()
{
	FileOfs s, e;
	pselect_get(&s, &e);
	clipboard->select_start=s;
	clipboard->select_len=e-s;
}

void ht_clipboard_viewer::update_content()
{
	if (clipboard->copy_history->count() == lastentrycount) return;
	clear_subs();
	ht_clipboard *clipboard = (ht_clipboard*)file;
	int c = clipboard->copy_history->count();
	char title[512];	/* secure */
	
	uint uid = 0;
	for (int i = 0; i < c; i++) {
		ht_clipboard_copy_history *j = (ht_clipboard_copy_history*)(*clipboard->copy_history)[i];

		tm *t = localtime(&j->time);
		ht_snprintf(title, sizeof title, "*** %02d:%02d:%02d, size %qd(%qxh), from %s", t->tm_hour, t->tm_min, t->tm_sec, j->size, j->size, j->source);

		ht_mask_sub *m = new ht_mask_sub();
		m->init(clipboard, uid++);
		m->add_mask(title);
		insertsub(m);

		ht_hex_sub *h = new ht_hex_sub();
		h->init(clipboard, j->start, j->size, 16, uid++, -1);
		insertsub(h);
	}
	pselect_set(clipboard->select_start, clipboard->select_start+clipboard->select_len);
	lastentrycount = clipboard->copy_history->count();

	sendmsg(msg_complete_init, 0);
}

int ht_clipboard_viewer::get_pindicator_str(char *buf, int max_len)
{
	FileOfs o;
	if (get_current_offset(&o)) {
		FileOfs sel_start, sel_end;
		pselect_get(&sel_start, &sel_end);
		char ttemp[1024];
		if (sel_end-sel_start > 0) {
			ht_snprintf(ttemp, sizeof ttemp, "selection %qxh-%qxh (%qd byte%s) ", sel_start, sel_end-1, sel_end-sel_start, sel_end-sel_start==1?"":"s");
		} else {
			ttemp[0] = 0;
		}
		return ht_snprintf(buf, max_len, " %s %qxh/%qu %s", edit() ? "edit" : "view", o, o, ttemp);
	} else {
		return ht_snprintf(buf, max_len, "?");
	}
}

/* clipboard functions */

void clipboard_add_copy_history_entry(const char *source, FileOfs start, FileOfs size, time_t time)
{
	clipboard->copy_history->insert(new ht_clipboard_copy_history(source, start, size, time));
}

#define CLIPBOARD_TRANSFER_BUF_SIZE	32*1024
//#define CLIPBOARD_TRANSFER_BUF_SIZE	2

FileOfs clipboard_copy(const char *source_desc, void *buf, uint len)
{
	uint r = 0;
	if (len) {
		FileOfs size = clipboard->getSize();
		clipboard->seek(size);
		r = clipboard->write(buf, len);
		clipboard->select_start = size;
		clipboard->select_len = r;
		clipboard_add_copy_history_entry(source_desc, size, r, time(0));
	}		
	return r;
}

FileOfs clipboard_copy(const char *source_desc, File *file, FileOfs offset, FileOfs len)
{
	if (!len) return 0;

	FileOfs size = clipboard->getSize();
	FileOfs oldpos = file->tell();
	FileOfs cpos = size;
	FileOfs spos = offset;
	byte *buf = ht_malloc(CLIPBOARD_TRANSFER_BUF_SIZE);
	FileOfs l = len, r = 0;

	while (len && l) {
		l = len;
		if (l > CLIPBOARD_TRANSFER_BUF_SIZE) l = CLIPBOARD_TRANSFER_BUF_SIZE;
		file->seek(spos);
		l = file->read(buf, l);
		spos += l;
		clipboard->seek(cpos);
		clipboard->write(buf, l);
		cpos += l;
		len -= l;
		r += l;
	}
	file->seek(oldpos);
	clipboard->select_start = size;
	clipboard->select_len = r;
	clipboard_add_copy_history_entry(source_desc, size, r, time(0));
	free(buf);
	return r;
}

FileOfs clipboard_paste(void *buf, FileOfs maxlen)
{
	clipboard->seek(clipboard->select_start);
	return clipboard->read(buf, MIN(clipboard->select_len, maxlen));
}

FileOfs clipboard_paste(File *file, FileOfs offset)
{
	FileOfs len = clipboard->select_len;
	FileOfs oldpos = file->tell();
	FileOfs cpos = clipboard->select_start, spos=offset;
	byte *buf = ht_malloc(CLIPBOARD_TRANSFER_BUF_SIZE);
	FileOfs l = len, r = 0;
	while (len && l) {
		l = len;
		if (l > CLIPBOARD_TRANSFER_BUF_SIZE) l=CLIPBOARD_TRANSFER_BUF_SIZE;
		clipboard->seek(cpos);
		l = clipboard->read(buf, l);
		cpos += l;
		file->seek(spos);
		file->write(buf, l);
		spos += l;
		len -= l;
		r += l;
	}
	file->seek(oldpos);
	free(buf);
	return r;
}

bool clipboard_clear()
{
	clipboard->clear();
	return true;
}

FileOfs clipboard_getsize()
{
	return clipboard->select_len;
}

/*
 *	INIT
 */

bool init_clipboard()
{
	clipboard = new ht_clipboard();
	return true;
}

/*
 *	DONE
 */

void done_clipboard()
{
	delete clipboard;
}


ht-2.0.22/xbestruct.cc0000644000175000001440000001341710615341625011470 00000000000000/* 
 *	HT Editor
 *	xbestruct.cc
 *
 *	Copyright (C) 2003 Stefan Esser
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */


#include "endianess.h"
#include "xbestruct.h"

/* we do not need to swap the digital signature anyway */
byte XBE_IMAGE_HEADER_struct[] = {

	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	0
};

byte XBE_CERTIFICATE_struct[] = {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,

	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,

	0 /* rest are only byte structs */
};

byte XBE_SECTION_HEADER_struct[] = {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	0 
	/* SHA signature must not be swapped */
};

byte XBE_LIBRARY_VERSION_struct[] = {
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	0
};

byte XBE_TLS_DIRECTORY_struct[] = {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	0
};
ht-2.0.22/htdoc.h0000644000175000001440000000016612156423375010412 00000000000000#ifndef __HTDOC_H
#define __HTDOC_H

extern
#ifdef __cplusplus
"C"
#endif
char htinfo[15375];

#endif /* __HTDOC_H */
ht-2.0.22/strtools.h0000755000175000001440000000603210615345252011176 00000000000000/* 
 *	HT Editor
 *	strtools.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
 *	Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __STRTOOLS_H__
#define __STRTOOLS_H__

#include "io/types.h"
#include "data.h"

#include 

char *ht_strdup(const char *str);
char *ht_strndup(const char *str, size_t maxlen);
size_t ht_strlcpy(char *s1, const char *s2, size_t maxlen);
size_t ht_strlcat(char *s1, const char *s2, size_t maxlen);
int ht_strncmp(const char *s1, const char *s2, size_t max);
int ht_strnicmp(const char *s1, const char *s2, size_t max);
int ht_stricmp(const char *s1, const char *s2);

size_t ht_strcicomm(const char *s1, const char *s2);
size_t ht_strccomm(const char *s1, const char *s2);

static inline char *ht_strend(char *s) 
{
	return s+strlen(s);
}
static inline const char *ht_strend(const char *s)
{
	return s+strlen(s);
}

int escape_special_str(char *result, int resultmaxlen, const char *s, const char *specialchars = NULL, bool bit7 = true);
int escape_special(char *result, int resultmaxlen, const void *s, int len, const char *specialchars = NULL, bool bit7 = true);
int unescape_special_str(char *result, int resultmaxlen, const char *s);
int unescape_special(void *result, int resultmaxlen, const char *s);
int bin2str(char *result, const void *s, int len);
void wide_char_to_multi_byte(char *result, const byte *unicode, int maxlen);

void memdowncase(byte *buf, int len);
byte *ht_memmem(const byte *haystack, int haystack_len, const byte *needle, int needle_len);

/* common string parsing functions */
bool is_whitespace(char c);
void non_whitespaces(const char *&str);
void whitespaces(const char *&str);
bool waitforchar(const char *&str, char b);

/* string evaluation functions */
bool parseIntStr(char *&str, uint64 &u64, int defaultbase);
bool parseIntStr(const char *&str, uint64 &u64, int defaultbase);
bool str2int(const char *str, uint64 &u64, int defaultbase = 10);

/* hex/string functions */
int hexdigit(char a);

bool hexb_ex(uint8 &result, const char *s);
bool hexw_ex(uint16 &result, const char *s);
bool hexd_ex(uint32 &result, const char *s);

/*
 *	ht_string_list
 */
class ht_string_list: public Array {
public:
	ht_string_list()
		: Array(true)
	{
	}

	/* new */
	const char *get_string(uint i)
	{
		return ((String *)get(findByIdx(i)))->contentChar();
	}

	void insert_string(const char *s)
	{
		insert(new String(s));
	}
};

#endif /* !__STRTOOLS_H__ */
ht-2.0.22/htmzrel.h0000644000175000001440000000151410206756710010770 00000000000000/* 
 *	HT Editor
 *	htmzrel.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTMZREL_H__
#define __HTMZREL_H__

#include "htobj.h"

//extern viewer_int htmzrel_int;

#endif /* !__HTMZREL_H__ */
ht-2.0.22/htpefhd.h0000644000175000001440000000155110206756710010726 00000000000000/* 
 *	HT Editor
 *	htpefhd.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTPEFHD_H__
#define __HTPEFHD_H__

#include "htobj.h"
#include "formats.h"

extern format_viewer_if htpefheader_if;

#endif /* !__HTPEFHD_H__ */

ht-2.0.22/htelfshs.cc0000644000175000017500000001433011705332140011255 00000000000000/* 
 *	HT Editor
 *	htelfshs.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "elfstruc.h"
#include "atom.h"
#include "except.h"
#include "htelf.h"
#include "htelfshs.h"
#include "httag.h"
#include "formats.h"
#include "snprintf.h"

static ht_mask_ptable elfsectionheader32[]=
{
	{"name string index",	STATICTAG_EDIT_DWORD_VE("00000000")},
	{"type",				STATICTAG_EDIT_DWORD_VE("00000004")" ("STATICTAG_DESC_DWORD_VE("00000004", ATOM_ELF_SH_TYPE_STR)")"},
	{"flags",				STATICTAG_EDIT_DWORD_VE("00000008")" "STATICTAG_FLAGS("00000008", ATOM_ELF_SH_FLAGS_STR)},
	{"address",			STATICTAG_EDIT_DWORD_VE("0000000c")},
	{"offset",			STATICTAG_EDIT_DWORD_VE("00000010")},
	{"size",				STATICTAG_EDIT_DWORD_VE("00000014")},
	{"link",				STATICTAG_EDIT_DWORD_VE("00000018")},
	{"info",				STATICTAG_EDIT_DWORD_VE("0000001c")},
	{"alignment",			STATICTAG_EDIT_DWORD_VE("00000020")},
	{"entsize",			STATICTAG_EDIT_DWORD_VE("00000024")},
	{0, 0}
};

static ht_mask_ptable elfsectionheader64[]=
{
	{"name string index",	STATICTAG_EDIT_DWORD_VE("00000000")},
	{"type",				STATICTAG_EDIT_DWORD_VE("00000004")" ("STATICTAG_DESC_DWORD_VE("00000004", ATOM_ELF_SH_TYPE_STR)")"},
	{"flags",				STATICTAG_EDIT_QWORD_VE("00000008")" "STATICTAG_FLAGS("00000008", ATOM_ELF_SH_FLAGS_STR)},
	{"address",			STATICTAG_EDIT_QWORD_VE("00000010")},
	{"offset",			STATICTAG_EDIT_QWORD_VE("00000018")},
	{"size",				STATICTAG_EDIT_QWORD_VE("00000020")},
	{"link",				STATICTAG_EDIT_QWORD_VE("00000028")},
	{"info",				STATICTAG_EDIT_QWORD_VE("00000030")},
	{"alignment",			STATICTAG_EDIT_DWORD_VE("00000038")},
	{"entsize",			STATICTAG_EDIT_DWORD_VE("0000003c")},
	{0, 0}
};

static int_hash elf_sh_type[] =
{
	{ELF_SHT_NULL, 		"null"},
	{ELF_SHT_PROGBITS,	"progbits"},
	{ELF_SHT_SYMTAB,	"symbol table"},
	{ELF_SHT_STRTAB,	"string table"},
	{ELF_SHT_RELA,		"relocation table + addends"},
	{ELF_SHT_HASH,		"symbol hash table"},
	{ELF_SHT_DYNAMIC,	"dynamic linking information"},
	{ELF_SHT_NOTE,		"note"},
	{ELF_SHT_NOBITS,	"nobits"},
	{ELF_SHT_REL,		"relocation table"},
	{ELF_SHT_SHLIB,		"shlib"},
	{ELF_SHT_DYNSYM,	"dynamic linking symbol table"},
	{ELF_SHT_INIT_ARRAY,	"init array"},
	{ELF_SHT_FINI_ARRAY,	"fini array"},
	{ELF_SHT_PREINIT_ARRAY,	"preinit array"},
	{0, 0}
};

static ht_tag_flags_s elf_sh_flags[] =
{
	{0,  "[00] writable"},
	{1,  "[01] alloc"},
	{2,  "[02] executable"},
	{3,  "[03] ???"},
	{4,  "[04] merge"},
	{5,  "[05] strings"},
	{6,  "[06] info link"},
	{7,  "[07] link order"},
	{8,  "[08] OS non-conforming"},
	{0, 0}
};

static ht_view *htelfsectionheaders_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_elf_shared_data *elf_shared=(ht_elf_shared_data *)group->get_shared_data();

	if (elf_shared->sheaders.count == 0) {
		return NULL;
	}

	ht_uformat_viewer *v = NULL;
	bool elf_bigendian = elf_shared->ident.e_ident[ELF_EI_DATA]==ELFDATA2MSB;
	if (elf_shared->ident.e_ident[ELF_EI_CLASS] == ELFCLASS32) {
		v = new ht_uformat_viewer();
		v->init(b, DESC_ELF_SECTION_HEADERS, VC_EDIT, file, group);

		registerAtom(ATOM_ELF_SH_TYPE, elf_sh_type);
		registerAtom(ATOM_ELF_SH_FLAGS, elf_sh_flags);

		FileOfs h = elf_shared->header32.e_shoff;

		ht_mask_sub *m = new ht_mask_sub();
		m->init(file, 0);

		char info[128];
		ht_snprintf(info, sizeof info, "* ELF section headers at offset 0x%08qx", h);

		m->add_mask(info);

		v->insertsub(m);

		elf_shared->shnames = ht_malloc(elf_shared->sheaders.count * sizeof *elf_shared->shnames);
		FileOfs so;
		if (elf_shared->header32.e_shstrndx < elf_shared->sheaders.count) {
			so = elf_shared->sheaders.sheaders32[elf_shared->header32.e_shstrndx].sh_offset;
		} else {
			so = -1;
		}
		String s;
		for (uint i=0; i < elf_shared->sheaders.count; i++) {
			s = "?";

			try {
				if (so != -1) {
					file->seek(so + elf_shared->sheaders.sheaders32[i].sh_name);
					file->readStringz(s);
				}
			} catch (const Exception &x) {
				// and now?
			}

			char t[1024];
			ht_snprintf(t, sizeof t, "section %d: %y", i, &s);
			elf_shared->shnames[i] = ht_strdup(s.contentChar());

			ht_mask_sub *n = new ht_mask_sub();
			n->init(file, i);

			n->add_staticmask_ptable(elfsectionheader32, h+i*elf_shared->header32.e_shentsize, elf_bigendian);

			ht_collapsable_sub *cn = new ht_collapsable_sub();
			cn->init(file, n, 1, t, 1);

			v->insertsub(cn);
		}
	} else if (elf_shared->ident.e_ident[ELF_EI_CLASS]==ELFCLASS64) {
		v = new ht_uformat_viewer();
		v->init(b, DESC_ELF_SECTION_HEADERS, VC_EDIT, file, group);

		registerAtom(ATOM_ELF_SH_TYPE, elf_sh_type);
		registerAtom(ATOM_ELF_SH_FLAGS, elf_sh_flags);

		/* FIXME: 64-bit */
		FileOfs h = elf_shared->header64.e_shoff;

		ht_mask_sub *m=new ht_mask_sub();
		m->init(file, 0);

		char info[128];
		ht_snprintf(info, sizeof info, "* ELF section headers at offset 0x%08qx", h);

		m->add_mask(info);

		v->insertsub(m);

		elf_shared->shnames = ht_malloc(elf_shared->sheaders.count * sizeof *elf_shared->shnames);

		FileOfs so = elf_shared->sheaders.sheaders64[elf_shared->header64.e_shstrndx].sh_offset;
		for (uint i=0; i < elf_shared->sheaders.count; i++) {
			char *s;
			try {
				file->seek(so+elf_shared->sheaders.sheaders64[i].sh_name);
				s = file->fgetstrz();
			} catch (const EOFException &) {
				s = ht_strdup("?");
			}
			char t[1024];
			ht_snprintf(t, sizeof t, "section %d: %s", i, s);
			elf_shared->shnames[i]=s;

			ht_mask_sub *n=new ht_mask_sub();
			n->init(file, i);

			n->add_staticmask_ptable(elfsectionheader64, h+i*elf_shared->header64.e_shentsize, elf_bigendian);

			ht_collapsable_sub *cn=new ht_collapsable_sub();
			cn->init(file, n, 1, t, 1);

			v->insertsub(cn);
		}
	}

	return v;
}

format_viewer_if htelfsectionheaders_if = {
	htelfsectionheaders_init,
	0
};
ht-2.0.22/elfstruc.cc0000644000175000001440000001122210615341616011264 00000000000000/* 
 *	HT Editor
 *	elfstruc.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "elfstruc.h"
#include "endianess.h"

byte ELF_HEADER32_struct[]= {
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	0
};

byte ELF_HEADER64_struct[]= {
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	0
};

byte ELF_SECTION_HEADER32_struct[]= {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	0
};

byte ELF_SECTION_HEADER64_struct[]= {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	0
};
 
byte ELF_PROGRAM_HEADER32_struct[]= {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	0
};

byte ELF_PROGRAM_HEADER64_struct[]= {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	0
};

static byte ELF_NHEADER32_struct[] = {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	0
};

byte ELF_SYMBOL32_struct[]= {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	0
};

byte ELF_SYMBOL64_struct[]= {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	0
};

byte ELF_REL32_struct[]= {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	0
};

byte ELF_REL64_struct[]= {
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	0
};

byte ELF_RELA32_struct[]= {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	0
};

byte ELF_RELA64_struct[]= {
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST,
	0
};

ht-2.0.22/htmachohd.h0000644000175000001440000000156310206756710011246 00000000000000/* 
 *	HT Editor
 *	htmachohd.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTMACHOHD_H__
#define __HTMACHOHD_H__

#include "htobj.h"
#include "formats.h"

extern format_viewer_if htmachoheader_if;

#endif /* !__HTMACHOHD_H__ */

ht-2.0.22/htelfsym.cc0000644000175000017500000002105512127651417011304 00000000000000/* 
 *	HT Editor
 *	htelfsym.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "elfstruc.h"
#include "atom.h"
#include "except.h"
#include "htelf.h"
#include "htelfsym.h"
#include "httag.h"
#include "formats.h"
#include "snprintf.h"

#include 

static int_hash elf_st_bind[] =
{
	{ELF_STB_LOCAL, 	"local"},
	{ELF_STB_GLOBAL, 	"global"},
	{ELF_STB_WEAK, 		"weak"},
	{0, 0}
};

static int_hash elf_st_type[] =
{
	{ELF_STT_NOTYPE,	"no type"},
	{ELF_STT_OBJECT,	"object"},
	{ELF_STT_FUNC,		"func"},
	{ELF_STT_SECTION,	"section"},
	{ELF_STT_FILE,		"file"},
	{ELF_STT_COMMON,	"common"},
	{0, 0}
};

static ht_view *htelfsymboltable_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_elf_shared_data *elf_shared=(ht_elf_shared_data *)group->get_shared_data();

	if (elf_shared->ident.e_ident[ELF_EI_CLASS]!=ELFCLASS32 &&
		elf_shared->ident.e_ident[ELF_EI_CLASS]!=ELFCLASS64) return 0;

	bool elf32 = elf_shared->ident.e_ident[ELF_EI_CLASS] == ELFCLASS32;
	uint skip = elf_shared->symtables;
	uint symtab_shidx = ELF_SHN_UNDEF;
	for (uint i=1; isheaders.count; i++) {
		if (elf32 ?
			(elf_shared->sheaders.sheaders32[i].sh_type == ELF_SHT_SYMTAB) || (elf_shared->sheaders.sheaders32[i].sh_type==ELF_SHT_DYNSYM) :
			(elf_shared->sheaders.sheaders64[i].sh_type == ELF_SHT_SYMTAB) || (elf_shared->sheaders.sheaders64[i].sh_type==ELF_SHT_DYNSYM) ) {
			if (!skip--) {
				symtab_shidx = i;
				break;
			}
		}
	}
	if (!isValidELFSectionIdx(elf_shared, symtab_shidx)) return NULL;

	FileOfs h = elf32 ? elf_shared->sheaders.sheaders32[symtab_shidx].sh_offset : elf_shared->sheaders.sheaders64[symtab_shidx].sh_offset;

	/* associated string table offset (from sh_link) */
	FileOfs sto = elf32 ?
		elf_shared->sheaders.sheaders32[elf_shared->sheaders.sheaders32[symtab_shidx].sh_link].sh_offset :
		elf_shared->sheaders.sheaders64[elf_shared->sheaders.sheaders64[symtab_shidx].sh_link].sh_offset;

	String symtab_name("?");
	if (elf32)
	{
		if (isValidELFSectionIdx(elf_shared, elf_shared->header32.e_shstrndx)) {
			file->seek(elf_shared->sheaders.sheaders32[elf_shared->header32.e_shstrndx].sh_offset
				+ elf_shared->sheaders.sheaders32[symtab_shidx].sh_name);
			file->readStringz(symtab_name);
		}
	} else {
		if (isValidELFSectionIdx(elf_shared, elf_shared->header64.e_shstrndx)) {
			file->seek(elf_shared->sheaders.sheaders64[elf_shared->header64.e_shstrndx].sh_offset
				+ elf_shared->sheaders.sheaders64[symtab_shidx].sh_name);
			file->readStringz(symtab_name);
		}
	}

	char desc[128];
	ht_snprintf(desc, sizeof desc, DESC_ELF_SYMTAB, &symtab_name, symtab_shidx);

	ht_uformat_viewer *v=new ht_uformat_viewer();
	v->init(b, desc, VC_EDIT | VC_SEARCH, file, group);

	ht_mask_sub *m = new ht_mask_sub();
	m->init(file, 0);

	registerAtom(ATOM_ELF_ST_BIND, elf_st_bind);

	char t[256];
	ht_snprintf(t, sizeof t, "* ELF symtab at offset %08qx", h);

	m->add_mask(t);

	bool elf_bigendian = (elf_shared->ident.e_ident[ELF_EI_DATA] == ELFDATA2MSB);
	uint symnum = elf32 ?
		elf_shared->sheaders.sheaders32[symtab_shidx].sh_size / sizeof (ELF_SYMBOL32) :
		elf_shared->sheaders.sheaders64[symtab_shidx].sh_size / sizeof (ELF_SYMBOL64);

	/* find maximum section name length */
	uint msnl = 0;
	for (uint i=0; i < symnum; i++) {
		elf64_quarter st_shndx;
		if (elf32)
		{
			ELF_SYMBOL32 sym;
			file->seek(h+i*sizeof (ELF_SYMBOL32));
			file->readx(&sym, sizeof sym);
			createHostStruct(&sym, ELF_SYMBOL32_struct, elf_shared->byte_order);
			file->seek(sto+sym.st_name);
			st_shndx = sym.st_shndx;
		} else {
			ELF_SYMBOL64 sym;
			file->seek(h+i*sizeof (ELF_SYMBOL64));
			file->readx(&sym, sizeof sym);
			createHostStruct(&sym, ELF_SYMBOL64_struct, elf_shared->byte_order);
			file->seek(sto+sym.st_name);
			st_shndx = sym.st_shndx;
		}

		char *name = file->fgetstrz();
		/* FIXME: error handling (also in elf_analy.cc) */
		if (!name) continue;

		uint len = 0;
		switch (st_shndx) {
		case ELF_SHN_UNDEF:
			len = strlen("*undefined");
			break;
		case ELF_SHN_ABS:
			len = strlen("*absolute");
			break;
		case ELF_SHN_COMMON:
			len = strlen("*common");
			break;
		default:
			if (isValidELFSectionIdx(elf_shared, st_shndx)) {
				String s("");
				FileOfs so, no;
				if (elf32)
				{
					so = elf_shared->sheaders.sheaders32[elf_shared->header32.e_shstrndx].sh_offset;
					no = elf_shared->sheaders.sheaders32[st_shndx].sh_name;
				} else {
					so = elf_shared->sheaders.sheaders64[elf_shared->header64.e_shstrndx].sh_offset;
					no = elf_shared->sheaders.sheaders64[st_shndx].sh_name;
				}
				file->seek(so + no);
				file->readStringz(s);

				len = s.length();
			}
			break;
		}

		if (len > msnl)
			msnl = len;

		free(name);
	}

	/* create format string for section column */
	char secstrfmt[10];
	snprintf(secstrfmt, sizeof secstrfmt, "%%-%ds  ", msnl);

	char *tt = t;
#define tt_end sizeof t - (tt-t)
	if (elf32) {
		tt += ht_snprintf(t, tt_end, "idx  binding  type     value    size     ");
	} else {
		tt += ht_snprintf(t, tt_end, "idx  binding  type     value            size             ");
	}
	tt += ht_snprintf(tt, tt_end, secstrfmt, "section");
	tt += ht_snprintf(tt, tt_end, "name");
	m->add_mask(t);

	for (uint i=0; i < symnum; i++) {
		elf64_quarter st_shndx;
		int st_bind;
		int st_type;
		if (elf32)
		{
			ELF_SYMBOL32 sym;
			file->seek(h+i*sizeof (ELF_SYMBOL32));
			file->readx(&sym, sizeof sym);
			createHostStruct(&sym, ELF_SYMBOL32_struct, elf_shared->byte_order);
			file->seek(sto+sym.st_name);
			st_shndx = sym.st_shndx;
			st_bind = ELF32_ST_BIND(sym.st_info);
			st_type = ELF32_ST_TYPE(sym.st_info);
		} else {
			ELF_SYMBOL64 sym;
			file->seek(h+i*sizeof (ELF_SYMBOL64));
			file->readx(&sym, sizeof sym);
			createHostStruct(&sym, ELF_SYMBOL64_struct, elf_shared->byte_order);
			file->seek(sto+sym.st_name);
			st_shndx = sym.st_shndx;
			st_bind = ELF64_ST_BIND(sym.st_info);
			st_type = ELF64_ST_TYPE(sym.st_info);
		}
		char *name = file->fgetstrz();
		/* FIXME: error handling (also in elf_analy.cc) */
		if (!name) continue;

		char *tt = t;
#define tt_end sizeof t - (tt-t)

		tt += ht_snprintf(tt, tt_end, "%04x ", i);

		const char *bind = matchhash(st_bind, elf_st_bind);
		if (bind) {
			tt += ht_snprintf(tt, tt_end, "%-8s ", bind);
		} else {
			tt += ht_snprintf(tt, tt_end, "? (%d) ", st_bind);
		}

		const char *type = matchhash(st_type, elf_st_type);
		if (type) {
			tt += ht_snprintf(tt, tt_end, "%-8s ", type);
		} else {
			tt += ht_snprintf(tt, tt_end, "? (%d) ", st_type);
		}

		FileOfs so;
		if (elf32) {
			so = elf_shared->sheaders.sheaders32[elf_shared->header32.e_shstrndx].sh_offset;
			tt = tag_make_edit_dword(tt, tt_end, h + i*sizeof (ELF_SYMBOL32) + 4,
				elf_bigendian ? tag_endian_big : tag_endian_little);
			tt += ht_snprintf(tt, tt_end, " ");
			tt = tag_make_edit_dword(tt, tt_end, h + i*sizeof (ELF_SYMBOL32) + 8,
				elf_bigendian ? tag_endian_big : tag_endian_little);
			tt += ht_snprintf(tt, tt_end, " ");
		} else {
			so = elf_shared->sheaders.sheaders64[elf_shared->header64.e_shstrndx].sh_offset;
			tt = tag_make_edit_qword(tt, tt_end, h+i*sizeof (ELF_SYMBOL64) + 8,
				elf_bigendian ? tag_endian_big : tag_endian_little);
			tt += ht_snprintf(tt, tt_end, " ");
			tt = tag_make_edit_qword(tt, tt_end, h+i*sizeof (ELF_SYMBOL64) + 16,
				elf_bigendian ? tag_endian_big : tag_endian_little);
			tt += ht_snprintf(tt, tt_end, " ");
		}

		String s("?");
		switch (st_shndx) {
		case ELF_SHN_UNDEF:
			s.assign("*undefined");
			break;
		case ELF_SHN_ABS:
			s.assign("*absolute");
			break;
		case ELF_SHN_COMMON:
			s.assign("*common");
			break;
		default:
			if (isValidELFSectionIdx(elf_shared, st_shndx)) {
				FileOfs no = elf32 ? elf_shared->sheaders.sheaders32[st_shndx].sh_name : elf_shared->sheaders.sheaders64[st_shndx].sh_name;
				file->seek(so + no);
				file->readStringz(s);
			}
			break;
		}
		tt += ht_snprintf(tt, tt_end, secstrfmt, s.contentChar());

		tt += ht_snprintf(tt, tt_end, "%s", name);
		free(name);
		m->add_mask(t);
	}

	v->insertsub(m);
	return v;
}

format_viewer_if htelfsymboltable_if = {
	htelfsymboltable_init,
	0
};
ht-2.0.22/htxbeimp.h0000644000175000001440000000332110615341624011117 00000000000000/* 
 *	HT Editor
 *	htxbeimp.h
 *
 *	Copyright (C) 2003 Stefan Esser
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTXBEIMP_H__
#define __HTXBEIMP_H__

#include "formats.h"
#include "xbestruct.h"
#include "htdialog.h"

extern format_viewer_if htxbeimports_if;

/*
 *	ht_xbe_import_function
 */
class ht_xbe_import_function: public Object {
public:
	uint libidx;
	bool byname;
	union {
		uint ordinal;
		struct {
			char *name;
			uint hint;
		} name;
	};
	RVA address;

	ht_xbe_import_function(RVA address, uint ordinal);
	ht_xbe_import_function(RVA address, char *name, uint hint);
	~ht_xbe_import_function();
};

struct ht_xbe_import {
	Container *funcs;
	Container *libs;
};

/*
 *	ht_xbe_import_viewer
 */
class ht_xbe_import_viewer: public ht_itext_listbox {
protected:
	ht_format_group *format_group;
	bool grouplib;
	uint sortby;
	/* new */
		void dosort();
public:
		void init(Bounds *b, const char *desc, ht_format_group *fg);
	virtual	void done();
	/* overwritten */
	virtual	void handlemsg(htmsg *msg);
	virtual	bool select_entry(void *entry);
	/* new */
		const char *func(uint i, bool execute);
};

#endif /* !__HTXBEIMP_H__ */
ht-2.0.22/mzstruct.h0000644000175000001440000000257010615341624011177 00000000000000/* 
 *	HT Editor
 *	mzstruct.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __MZSTRUCT_H_
#define __MZSTRUCT_H_

#include "io/types.h"
#include "tools.h"

#define IMAGE_MZ_MAGIC0	'M'
#define IMAGE_MZ_MAGIC1 'Z'

struct IMAGE_MZ_HEADER {
	uint16 magic PACKED;
	uint16 sizelp PACKED;
	uint16 sizep PACKED;
	uint16 reloc_count PACKED;
	uint16 header_size PACKED;
	uint16 minalloc PACKED;
	uint16 maxalloc PACKED;
	uint16 ss PACKED;
	uint16 sp PACKED;
	uint16 checksum PACKED;
	uint16 ip PACKED;
	uint16 cs PACKED;
	uint16 reloc_ofs PACKED;
	uint16 overlay_num PACKED;
	uint16 res[4] PACKED;
	uint16 oemid PACKED;
	uint16 oeminfo PACKED;
	uint16 res2[10] PACKED;
	uint32 newexe_ofs PACKED;
};

extern byte MZ_HEADER_struct[];

#endif /* __MZSTRUCT_H_ */
ht-2.0.22/NEWS0000644000175000001440000000004307530222242007617 00000000000000  NEWS
=========
    see ChangeLog
ht-2.0.22/htxbeimg.h0000644000175000001440000000237110615341624011112 00000000000000/* 
 *	HT Editor
 *	htxbeimg.h
 *
 *	Copyright (C) 2003 Stefan Esser
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTXBEIMG_H__
#define __HTXBEIMG_H__

#include "htanaly.h"
#include "htxbe.h"
#include "formats.h"

extern format_viewer_if htxbeimage_if;

/*
 *	ht_xbe_aviewer
 */
class ht_xbe_aviewer: public ht_aviewer {
public:
	ht_xbe_shared_data *xbe_shared;

		void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Analyser *Analyser, ht_xbe_shared_data *xbe_shared);
	virtual bool func_handler(eval_scalar *result, char *name, eval_scalarlist *params);
	virtual void setAnalyser(Analyser *a);
};

#endif /* !__HTXBEIMG_H__ */
ht-2.0.22/textfile.cc0000644000175000001440000004367710620177260011302 00000000000000/*
 *	HT Editor
 *	textfile.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include 
#include 
#include 

#include "except.h"
#include "htdebug.h"
#include "textfile.h"
#include "tools.h"

#define TEXTFILE_READSIZE				256
#define TEXTFILE_MAX_LINELEN				512

#define TEXTFILE_MAX_LINEENDLEN			2

//#define TEXTFILE_MAX_UPDATE_PARSE_STEPS		64

/*
 *	CLASS ht_textfile
 */
ht_textfile::ht_textfile(File *file, bool own_file)
	: FileLayer(file, own_file)
{
}

/*
 *	CLASS ht_layer_textfile
 */
 
ht_layer_textfile::ht_layer_textfile(ht_textfile *textfile, bool own_textfile)
	: ht_textfile(textfile, own_textfile)
{
}

bool ht_layer_textfile::convert_ofs2line(FileOfs o, uint *line, uint *pofs) const
{
	return ((ht_textfile*)mFile)->convert_ofs2line(o, line, pofs);
}

bool ht_layer_textfile::convert_line2ofs(uint line, uint pofs, FileOfs *o) const
{
	return ((ht_textfile*)mFile)->convert_line2ofs(line, pofs, o);
}

void ht_layer_textfile::delete_lines(uint line, uint count)
{
	((ht_textfile*)mFile)->delete_lines(line, count);
}

void ht_layer_textfile::delete_chars(uint line, uint ofs, uint count)
{
	((ht_textfile*)mFile)->delete_chars(line, ofs, count);
}

bool ht_layer_textfile::get_char(uint line, char *ch, uint pos)
{
	return ((ht_textfile*)mFile)->get_char(line, ch, pos);
}

bool ht_layer_textfile::getline(uint line, uint pofs, void *buf, uint buflen, uint *retlen, lexer_state *state)
{
	return ((ht_textfile*)mFile)->getline(line, pofs, buf, buflen, retlen, state);
}

uint ht_layer_textfile::getlinelength(uint line) const
{
	return ((ht_textfile*)mFile)->getlinelength(line);
}

void ht_layer_textfile::insert_lines(uint before, uint count, void **line_ends, int *line_end_lens)
{
	((ht_textfile*)mFile)->insert_lines(before, count, line_ends, line_end_lens);
}

void ht_layer_textfile::insert_chars(uint line, uint ofs, void *chars, uint len)
{
	((ht_textfile*)mFile)->insert_chars(line, ofs, chars, len);
}

bool ht_layer_textfile::has_line(uint line)
{
	return ((ht_textfile*)mFile)->has_line(line);
}

uint ht_layer_textfile::linecount() const
{
	return ((ht_textfile*)mFile)->linecount();
}

void ht_layer_textfile::set_layered_assume(File *s, bool ownNewLayered, bool changes_applied)
{
/*	File *q = streamfile->get_layered();
	if (q)*/ ((ht_textfile*)mFile)->set_layered_assume(s, ownNewLayered, changes_applied);
/*     else
		streamfile = s;*/
}

void ht_layer_textfile::set_lexer(ht_syntax_lexer *lexer)
{
	((ht_textfile*)mFile)->set_lexer(lexer);
}

/*
 *	CLASS ht_ltextfile_line
 */

ht_ltextfile_line::~ht_ltextfile_line()
{
	if (is_in_memory) free(in_memory.data);
}

/*
 *	CLASS ht_ltextfile
 */
 
ht_ltextfile::ht_ltextfile(File *streamfile, bool own_streamfile, ht_syntax_lexer *l)
	: ht_textfile(streamfile, own_streamfile)
{
	lexer = l;
	lines = new Array(true);
	orig_lines = new Array(true);
	reread();
	first_parse_dirty_line = linecount();
	first_nofs_dirty_line = linecount();
	dirty = false;
	ofs = 0;
}

ht_ltextfile::~ht_ltextfile()
{
	delete lines;
	delete orig_lines;
}

void ht_ltextfile::cache_invd()
{
	lines->delAll();
	foreach(ht_ltextfile_line, l, *orig_lines, {
		lines->insert(new ht_ltextfile_line(*l));
	});
	dirty_parse(0);
/*	reread();*/
	dirty = false;
}

void ht_ltextfile::cache_flush()
{
}

bool ht_ltextfile::convert_line2ofs(uint line, uint pofs, FileOfs *o) const
{
	ht_ltextfile_line *x;
	x=fetch_line_nofs_ok(line);
	if (x) {
		uint m=getlinelength_i(x);
		if (pofsnofs+pofs;
		} else {
			*o=x->nofs+m;
		}
		return true;
	}
	return false;
}

bool ht_ltextfile::convert_ofs2line(FileOfs o, uint *line, uint *pofs) const
{
	uint l=0, r=linecount();
	if (!r) return 0; else r--;
	uint m=0;
	ht_ltextfile_line *x, *y;
	while (l<=r) {
		m=(l+r) / 2;
		x=fetch_line_nofs_ok(m);
		y=fetch_line_nofs_ok(m+1);
		if ((x->nofs < o) && ((y && (y->nofs <= o)) || !y)) l=m+1; else
		if (x->nofs > o) r=m-1; else break;
	}
	
	/* FIXME: debug */
	x=fetch_line_nofs_ok(m);
	if (x) assert(o>=x->nofs);
	x=fetch_line_nofs_ok(m+1);
	if (x) assert(onofs);
	/**/

	x=fetch_line_nofs_ok(m);
	
	*line=m;
	*pofs=o - x->nofs;
	return true;
}

FileOfs ht_ltextfile::copyAllTo(Stream *stream)
{
/*	uint c=linecount();
	char buf[TEXTFILE_MAX_LINELEN+1];
	for (uint i=0; iwrite(buf, s);
			stream->write(e->lineend, e->lineendlen);
		}
	}*/
#define STREAM_COPYBUF_SIZE (64*1024)
	const uint bufsize=STREAM_COPYBUF_SIZE;
	byte *buf = ht_malloc(bufsize);
	uint r;
	FileOfs res = 0;
	do {
		r = read(buf, bufsize);
		stream->writex(buf, r);
		res += r;
	} while (r);
	free(buf);
	return res;
}

void ht_ltextfile::delete_chars(uint line, uint ofs, uint count)
{
	ht_ltextfile_line *e=fetch_line_into_memory(line);
	if (e) {
		char *ostr = e->in_memory.data;
		uint olen = e->in_memory.len;
		
		if (ofs < olen) {
			if (ofs+count>olen) count=olen-ofs;
			char *nstr = ht_malloc(olen-count);
			memcpy(nstr, ostr, ofs);
			memcpy(nstr+ofs, ostr+ofs+count, olen-ofs-count);
			free(ostr);
			e->in_memory.data=nstr;
			e->in_memory.len=olen-count;
			dirty_parse(line+1);
			dirty_nofs(line+1);
			dirty=true;
		}
	}
}

void ht_ltextfile::delete_lines(uint line, uint count)
{
	if (count) {
		lines->delRange(line, line+count-1);
		dirty_parse(line);
		dirty_nofs(line);
		dirty=true;
	}
}

void ht_ltextfile::dirty_parse(uint line)
{
	if (lineTEXTFILE_READSIZE) ? TEXTFILE_READSIZE : maxbuflen;
	byte *bufp;
	uint s;
	uint len = 0;
	
	if (le_len) *le_len = 0;
	do {
		mFile->seek(ofs);
		s = mFile->read(buf, readlen);
		int l;
		bufp = match_lineend_forwd(buf, s, &l);
		if (bufp) {
			len += bufp-buf+l;
			if (le_len) *le_len = l;
			break;
		}
		if (s != readlen) {
			len += s;
			break;
		}
		/* make sure current and next read overlap
		   to guarantee proper lineend-matching */
		if (s > (TEXTFILE_MAX_LINEENDLEN-1)) {
			len += s-(TEXTFILE_MAX_LINEENDLEN-1);
		}
		ofs += s-(TEXTFILE_MAX_LINEENDLEN-1);
	} while (s == readlen);
	if (len > TEXTFILE_MAX_LINELEN) {
		len = TEXTFILE_MAX_LINELEN;
		if (le_len) *le_len = 0;
	}
	return len;
}

ht_ltextfile_line *ht_ltextfile::fetch_line_into_memory(uint line)
{
	ht_ltextfile_line *e=fetch_line(line);
	if (e) {
		if (!e->is_in_memory) {
			char *data = ht_malloc(e->on_disk.len);
			mFile->seek(e->on_disk.ofs);
			uint x=mFile->read(data, e->on_disk.len);

			e->is_in_memory=true;
			e->in_memory.data=data;
			e->in_memory.len=x/*e->data.on_disk.len*/;
		}
	}
	return e;
}

FileOfs	ht_ltextfile::getSize() const
{
	int line = linecount()-1;
	FileOfs o = 0;
	convert_line2ofs(line, getlinelength(line), &o);
	return o;
}

bool ht_ltextfile::get_char(uint line, char *ch, uint pos)
{
	ht_ltextfile_line *e=fetch_line(line);
	if (e) {
		if (e->is_in_memory) {
			if (posin_memory.len) {
				*ch=e->in_memory.data[pos];
				return true;
			}
		} else {
			if (poson_disk.len) {
				mFile->seek(e->on_disk.ofs);
				mFile->readx(ch, 1);
				return true;
			}
		}
	}
	return false;
}


bool ht_ltextfile::getline(uint line, uint pofs, void *buf, uint buflen, uint *retlen, lexer_state *state)
{
/*  */
/*	bool debug=false;
	if (line & 0x80000000) {
		debug=true;
		line&=0x7fffffff;
	}*/
/*  */

	ht_ltextfile_line *e=fetch_line(line);

	if (e) {
		if (is_dirty_parse(line)) update_parse(line);
		if (is_dirty_nofs(line)) update_nofs(line);

/*  */
/*		if (debug) {
			buf+=sprintf(buf, "%5d:", e->nofs);
			maxbuflen-=9;
		}*/

/*  */

		uint ret;
		if (e->is_in_memory) {
			uint l=e->in_memory.len;
			if (l>buflen-1) l=buflen-1;
			if (pofs>l) l=0; else l-=pofs;
			memcpy(buf, e->in_memory.data+pofs, l);
			ret=l;
		} else {
			uint l=e->on_disk.len;
			if (l>buflen-1) l=buflen-1;
			if (pofs>l) l=0; else l-=pofs;
			mFile->seek(e->on_disk.ofs+pofs);
			mFile->read(buf, l);
			ret=l;
		}
		if (state) *state=e->instate;
		*retlen=ret;
		return true;
	}
	return false;
}

uint ht_ltextfile::getlinelength(uint line) const
{
	ht_ltextfile_line *e=fetch_line(line);
	return getlinelength_i(e);
}

uint ht_ltextfile::getlinelength_i(ht_ltextfile_line *e) const
{
	if (e) {
		if (e->is_in_memory) {
			return e->in_memory.len;
		} else {
			return e->on_disk.len;
		}
	}
	return 0;
}

void ht_ltextfile::insert_lines(uint before, uint count, void **line_ends, int *line_end_lens)
{
	ht_ltextfile_line *e = fetch_line(before);
	int instate = e->instate;
	while (count--) {
		e = new ht_ltextfile_line();
		e->is_in_memory = true;
		e->instate = instate;
		e->on_disk.ofs = 0xffffffff;
		e->on_disk.len = 0;
		e->in_memory.data = ht_malloc(1);
		e->in_memory.len = 0;
		e->nofs = 0;
		if (line_ends && line_end_lens) {
			e->lineendlen = *line_end_lens++;
			memcpy(e->lineend, *line_ends++, e->lineendlen);
		} else {
			e->lineendlen = 1;
			e->lineend[0] = '\n';
		}
		lines->insertBefore(before, e);
	}
	dirty_parse(before);
	dirty_nofs(before);
	dirty = true;
}

void ht_ltextfile::insert_chars(uint line, uint ofs, void *chars, uint len)
{
	ht_ltextfile_line *e=fetch_line(line);
	if (e) {
		uint olen=e->is_in_memory ? e->in_memory.len : e->on_disk.len;
		if (ofs<=olen) {
			e=fetch_line_into_memory(line);
			char *ostr=e->in_memory.data;

			char *nstr;
			uint nlen=olen;

			uint clen=len;

			if (ofs>nlen) nlen=ofs;
			nlen+=clen;
			nstr = ht_malloc(nlen);

			memcpy(nstr, ostr, ofs);
			memcpy(nstr+ofs, chars, clen);
			memcpy(nstr+ofs+clen, ostr+ofs, olen-ofs);

			e->in_memory.data=nstr;
			e->in_memory.len=nlen;
			dirty_parse(line+1);
			dirty_nofs(line+1);
			dirty=true;
			free(ostr);
		}			
	}
}

bool ht_ltextfile::has_line(uint line)
{
	return (fetch_line(line)!=NULL);
}

bool ht_ltextfile::is_dirty_nofs(uint line) const
{
	return (line >= first_nofs_dirty_line);
}

bool ht_ltextfile::is_dirty_parse(uint line) const
{
	return (line >= first_parse_dirty_line);
}

uint ht_ltextfile::linecount() const
{
	return lines->count();
}

byte *ht_ltextfile::match_lineend_forwd(byte *buf, uint buflen, int *le_len)
{
	byte *result=NULL;
	
	byte *n=(byte*)memchr(buf, '\n', buflen);
	if (n) {
		if ((n>buf) && (n[-1] == '\r')) {
			*le_len=2;
			result=n-1;
		} else {
			*le_len=1;
			result=n;
		}
	}
	return result;
}

lexer_state ht_ltextfile::next_instate(uint line)
{
	byte buf[TEXTFILE_MAX_LINELEN+1];
	lexer_state state = 0;

	uint buflen;
	if (!getline(line, 0, buf, TEXTFILE_MAX_LINELEN, &buflen, &state)) return state;
	buf[buflen] = 0;
	
	if (lexer) {
		text_pos p;
		char *bufp = (char*)buf;
		uint toklen;
		bool start_of_line = true;
		p.line = line;
		p.pofs = 0;
		int bufplen = buflen;
		int prev_bufplen = -1;
		while ((lexer->gettoken(bufp, bufplen, p, start_of_line, &state, &toklen))) {
			bufp += toklen;
			p.pofs += toklen;
			bufplen -= toklen;
			start_of_line = false;
			if (!bufplen && !prev_bufplen) break;
			prev_bufplen = bufplen;
		}
	}
	return state;
}

FileOfs ht_ltextfile::next_nofs(ht_ltextfile_line *l) const
{
	if (l) {
		if (l->is_in_memory) return l->nofs+l->in_memory.len+l->lineendlen; else
			return l->nofs+l->on_disk.len+l->lineendlen;
	}
	return 0;
}

void	ht_ltextfile::pstat(pstat_t &s) const
{
	mFile->pstat(s);
	s.size = getSize();
}

uint	ht_ltextfile::read(void *buf, uint size)
{
	FileOfs o=tell();
	uint line;
	uint pofs;
	uint c=0;
	byte *b=(byte*)buf;
	
	if (convert_ofs2line(o, &line, &pofs)) while (size) {
		ht_ltextfile_line *l=fetch_line(line);
		if (!l)
			break;
		uint q;
		if (l->is_in_memory) {
			q=l->in_memory.len;
			uint s=q;
			if (s>pofs) {
				s-=pofs;
				s=MIN(size, s);
				memcpy(b+c, l->in_memory.data+pofs, s);
				size-=s;
				c+=s;
				pofs+=s;
			}
		} else {
			q=l->on_disk.len;
			uint r;
			uint s=q;
			if (s>pofs) {
				s-=pofs;
				s=MIN(size, s);
				mFile->seek(l->on_disk.ofs+pofs);
				r = mFile->read(b+c, s);
				if (r!=s) break;
				size-=s;
				c+=s;
				pofs+=s;
			}
		}
		uint s=l->lineendlen;
		if ((q+s>pofs) && (pofs >= q)) {
			s-=pofs-q;
			s=MIN(size, s);
			memcpy(b+c, l->lineend+(pofs-q), s);
			size-=s;
			c+=s;
		}
		line++;
		pofs=0;
	}
	ofs += c;
	return c;
}

void ht_ltextfile::reread()
{
	lines->delAll();
	orig_lines->delAll();
	dirty = false;
	FileOfs ofs=0;
	int ll, pll=-1, ln=0;
	bool firstline = true;
	byte buf[TEXTFILE_MAX_LINELEN+1];

	lexer_state state=0;
	ht_ltextfile_line *e, *ce;

	if (lexer) state=lexer->getinitstate();

	uint l=0;
	while ((l=find_linelen_forwd(buf, sizeof buf, ofs, &ll))) {
		mFile->seek(ofs);
		uint x = mFile->read(buf, l-ll);
		buf[x]=0;

		e=new ht_ltextfile_line();
		e->is_in_memory=false;
		e->instate=state;
		e->on_disk.ofs=ofs;
		e->on_disk.len=l-ll;
		e->nofs=ofs;
		e->lineendlen=ll;
		assert( (uint)ll <= sizeof e->lineend);
		mFile->read(e->lineend, ll);
		lines->insert(e);
		ce=new ht_ltextfile_line();
		*ce = *e;
		orig_lines->insert(ce);

		if (lexer) {
			text_pos p;
			char *bufp=(char*)buf;
			uint toklen;
			bool start_of_line=true;
			p.line=ln;
			p.pofs=0;
			while (lexer->gettoken(bufp, l-ll-(bufp-(char*)buf), p, start_of_line, &state, &toklen)) {
				bufp+=toklen;
				p.pofs+=toklen;
				start_of_line=false;
			}
		}

		ofs+=l;
		pll=ll;
		firstline=false;
		ln++;
	}

	if (pll || firstline) {
		ll=0;
		e=new ht_ltextfile_line();
		e->is_in_memory=false;
		e->instate=state;
		e->on_disk.ofs=ofs;
		e->on_disk.len=l-ll;
		e->nofs=ofs;
		e->lineendlen=ll;
		lines->insert(e);
		ce=new ht_ltextfile_line();
		*ce = *e;
		orig_lines->insert(ce);
	}
}

void ht_ltextfile::split_line(uint a, uint pos, void *line_end, int line_end_len)
{
	if (pos == 0) {
		insert_lines(a, 1, &line_end, &line_end_len);
	} else {
		uint l=getlinelength(a);
		if (pos > l) pos = l;
		char *aline = ht_malloc(pos+1);
		uint alinelen;
		getline(a, 0, aline, pos+1, &alinelen, NULL);
	
		insert_lines(a, 1, &line_end, &line_end_len);
		insert_chars(a, 0, aline, alinelen);

		delete_chars(a+1, 0, pos);
		free(aline);
	}
}

void ht_ltextfile::seek(FileOfs offset)
{
	ofs = offset;
}

void ht_ltextfile::setLayered(File *streamfile, bool ownNewLayered)
{
	FileLayer::setLayered(streamfile, ownNewLayered);
	reread();
}

void ht_ltextfile::set_layered_assume(File *streamfile, bool ownNewLayered, bool changes_applied)
{
	if (changes_applied) {
		orig_lines->delAll();
		uint c = lines->count();
		for (uint i=0; ion_disk.ofs = l->nofs;
			if (l->is_in_memory) {
				l->on_disk.len = l->in_memory.len;
				free(l->in_memory.data);
				l->is_in_memory = false;
			}
			*m = *l;
			orig_lines->insert(m);
		}
		cache_invd();
	}
	FileLayer::setLayered(streamfile, ownNewLayered);
}

void ht_ltextfile::set_lexer(ht_syntax_lexer *l)
{
	if (lexer != l) {
		lexer = l;
		dirty_parse(0);
	}
}

FileOfs ht_ltextfile::tell() const
{
	return ofs;
}

void	ht_ltextfile::truncate(FileOfs newsize)
{
	/* FIXME: nyi */
	throw IOException(ENOSYS);
}

void ht_ltextfile::update_parse(uint target)
{
	ht_ltextfile_line *e;
	uint line = first_parse_dirty_line;

	lexer_state instate=0;
	if (line) {
		instate = next_instate(line-1);
// FIXME: function help works with this already...
/*		e = fetch_line(line);
		instate = e->instate;*/
	} else {
		if (lexer) instate = lexer->getinitstate();
	}

	while (line<=target) {
		e = fetch_line(line);
		if (!e) break;
//		if (e->instate==instate) break;	/* FIXME: valid simplification ?!... */
		e->instate = instate;
		first_parse_dirty_line = line+1;
		instate = next_instate(line);
		line++;
	}
	e = fetch_line(line);
	if (e) e->instate = instate;
}

void ht_ltextfile::update_nofs(uint target) const
{
	ht_ltextfile_line *e;
	uint line=first_nofs_dirty_line;

	FileOfs nofs;
	if (line) {
		e=fetch_line(line-1);
		nofs=next_nofs(e);
	} else {
		nofs=0;
	}

	while (line<=target) {
		e=fetch_line(line);
		if (!e) break;
		e->nofs=nofs;
		first_nofs_dirty_line=line+1;
		nofs=next_nofs(e);
		line++;
	}
}

int ht_ltextfile::vcntl(uint cmd, va_list vargs)
{
	switch (cmd) {
	case FCNTL_MODS_INVD:
		cache_invd();
		return 0;
	case FCNTL_MODS_FLUSH:
		cache_flush();
		return 0;
	case FCNTL_MODS_IS_DIRTY: {
		FileOfs o = va_arg(vargs, FileOfs);
		FileOfs s = va_arg(vargs, FileOfs);
		bool *b = va_arg(vargs, bool*);
		*b = dirty;
		o = 0;	// gcc warns otherwise
		s = 0;    // gcc warns otherwise
		return 0;
	}
	case FCNTL_MODS_CLEAR_DIRTY_RANGE: {
		FileOfs o = va_arg(vargs, FileOfs);
		FileOfs s = va_arg(vargs, FileOfs);
		dirty = false;
		o = s = 0;
		return 0;
	}
	}
	return ht_textfile::vcntl(cmd, vargs);
}

uint	ht_ltextfile::write(const void *buf, uint size)
{
	FileOfs o = tell();
	uint line;
	uint pofs;
	byte *b = (byte*)buf;
	uint r = 0;
	if (convert_ofs2line(o, &line, &pofs)) {
		r = size;
		while (size) {
			int lelen;
			uint s;
			byte *c = match_lineend_forwd(b, size, &lelen);
			if (c) {
				s = c-b;
				split_line(line, pofs, c, lelen);
			} else {
				s = size;
				lelen = 0;
			}
			insert_chars(line, pofs, b, s);
			s += lelen;
			b += s;
			size -= s;
			line++;
			pofs = 0;
		}
	}
	ofs += r;
	return r;
}
ht-2.0.22/htelfphs.cc0000644000175000001440000001177110615341616011263 00000000000000/* 
 *	HT Editor
 *	htelfphs.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "elfstruc.h"
#include "atom.h"
#include "htelf.h"
#include "htelfphs.h"
#include "httag.h"
#include "formats.h"
#include "snprintf.h"

static ht_mask_ptable elfprogramheader32[]=
{
	{"type",		STATICTAG_EDIT_DWORD_VE("00000000")" ("STATICTAG_DESC_DWORD_VE("00000000", ATOM_ELF_PH_TYPE_STR)")"},
	{"offset",		STATICTAG_EDIT_DWORD_VE("00000004")},
	{"virtual address",	STATICTAG_EDIT_DWORD_VE("00000008")},
	{"physical address",	STATICTAG_EDIT_DWORD_VE("0000000c")},
	{"in file size",	STATICTAG_EDIT_DWORD_VE("00000010")},
	{"in memory size",	STATICTAG_EDIT_DWORD_VE("00000014")},
	{"flags",		STATICTAG_EDIT_DWORD_VE("00000018")" "STATICTAG_FLAGS("00000018", ATOM_ELF_PH_FLAGS_STR)},
	{"alignment",		STATICTAG_EDIT_DWORD_VE("0000001c")},
	{0, 0}
};

static ht_mask_ptable elfprogramheader64[]=
{
	{"type",		STATICTAG_EDIT_DWORD_VE("00000000")" ("STATICTAG_DESC_DWORD_VE("00000000", ATOM_ELF_PH_TYPE_STR)")"},
	{"flags",		STATICTAG_EDIT_DWORD_VE("00000004")" "STATICTAG_FLAGS("00000004", ATOM_ELF_PH_FLAGS_STR)},
	{"offset",		STATICTAG_EDIT_QWORD_VE("00000008")},
	{"virtual address",	STATICTAG_EDIT_QWORD_VE("00000010")},
	{"physical address",	STATICTAG_EDIT_QWORD_VE("00000018")},
	{"in file size",	STATICTAG_EDIT_QWORD_VE("00000020")},
	{"in memory size",	STATICTAG_EDIT_QWORD_VE("00000028")},
	{"alignment",		STATICTAG_EDIT_QWORD_VE("00000030")},
	{0, 0}
};

static int_hash elf_ph_type[] =
{
	{ELF_PT_NULL, 		"null"},
	{ELF_PT_LOAD,		"load"},
	{ELF_PT_DYNAMIC,	"dynamic"},
	{ELF_PT_INTERP,		"interp"},
	{ELF_PT_NOTE,		"note"},
	{ELF_PT_SHLIB,		"shlib"},
	{ELF_PT_PHDR,		"phdr"},
	{ELF_PT_TLS,		"tls"},
	{ELF_PT_NUM,		"num"},
	{ELF_PT_GNU_EH_FRAME,	"gnu eh frame"},
	{ELF_PT_GNU_STACK,	"gnu stack"},
	{ELF_PT_GNU_RELRO,	"gnu relro"},
	{ELF_PT_PAX_FLAGS,	"pax flags"},
	{0, 0}
};

static ht_tag_flags_s elf_ph_flags[] =
{
	{0,  "[00] executable"},
	{1,  "[01] writable"},
	{2,  "[02] readable"},
	{0, 0}
};

static ht_view *htelfprogramheaders_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_elf_shared_data *elf_shared = (ht_elf_shared_data *)group->get_shared_data();

	if (!elf_shared->pheaders.count) return NULL;

	bool elf_bigendian = (elf_shared->ident.e_ident[ELF_EI_DATA] == ELFDATA2MSB);
	ht_uformat_viewer *v = NULL;
	if (elf_shared->ident.e_ident[ELF_EI_CLASS]==ELFCLASS32) {
		v = new ht_uformat_viewer();
		v->init(b, DESC_ELF_PROGRAM_HEADERS, VC_EDIT, file, group);
	
		registerAtom(ATOM_ELF_PH_TYPE, elf_ph_type);
		registerAtom(ATOM_ELF_PH_FLAGS, elf_ph_flags);
	
		FileOfs h = elf_shared->header32.e_phoff;
	
		ht_mask_sub *m = new ht_mask_sub();
		m->init(file, 0);
	
		char info[128];
		ht_snprintf(info, sizeof info, "* ELF program headers at offset %08qx", h);
	
		m->add_mask(info);

		v->insertsub(m);
		for (uint i=0; i < elf_shared->pheaders.count; i++) {
		
			ht_mask_sub *n = new ht_mask_sub();
			n->init(file, i);
		
			char t[32];
			const char *etype = matchhash(elf_shared->pheaders.pheaders32[i].p_type, elf_ph_type);
			if (!etype) etype = "?";
			ht_snprintf(t, sizeof t, "entry %d (%s)", i, etype);
		
			n->add_staticmask_ptable(elfprogramheader32, h+i*elf_shared->header32.e_phentsize, elf_bigendian);
		
			ht_collapsable_sub *cn=new ht_collapsable_sub();
			cn->init(file, n, 1, t, 1);
	
			v->insertsub(cn);
		}
	} else if (elf_shared->ident.e_ident[ELF_EI_CLASS]==ELFCLASS64) {
		v = new ht_uformat_viewer();
		v->init(b, DESC_ELF_PROGRAM_HEADERS, VC_EDIT, file, group);
	
		registerAtom(ATOM_ELF_PH_TYPE, elf_ph_type);
		registerAtom(ATOM_ELF_PH_FLAGS, elf_ph_flags);

		FileOfs h = elf_shared->header64.e_phoff;
	
		ht_mask_sub *m=new ht_mask_sub();
		m->init(file, 0);
	
		char info[128];
		ht_snprintf(info, sizeof info, "* ELF program headers at offset 0x%08qx", h);
	
		m->add_mask(info);

		v->insertsub(m);
		for (uint i=0; ipheaders.count; i++) {
		
			ht_mask_sub *n=new ht_mask_sub();
			n->init(file, i);
		
			char t[32];
			const char *etype=matchhash(elf_shared->pheaders.pheaders64[i].p_type, elf_ph_type);
			if (!etype) etype="?";
			ht_snprintf(t, sizeof t, "entry %d (%s)", i, etype);
		
			n->add_staticmask_ptable(elfprogramheader64, h+i*elf_shared->header64.e_phentsize, elf_bigendian);
		
			ht_collapsable_sub *cn=new ht_collapsable_sub();
			cn->init(file, n, 1, t, 1);
	
			v->insertsub(cn);
		}
	}
	
	return v;
}

format_viewer_if htelfprogramheaders_if = {
	htelfprogramheaders_init,
	0
};
ht-2.0.22/htnehead.cc0000644000175000001440000001037710615341620011222 00000000000000/* 
 *	HT Editor
 *	htnehead.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "atom.h"
#include "htne.h"
#include "httag.h"
#include "formats.h"
#include "snprintf.h"

static ht_mask_ptable neheader[]=
{
	{"magic",							STATICTAG_EDIT_WORD_LE("00000000")},
	{"version",						STATICTAG_EDIT_BYTE("00000002")},
	{"revision",						STATICTAG_EDIT_BYTE("00000003")},
	{"offset of entry table",			STATICTAG_EDIT_WORD_LE("00000004")},
	{"size of entry table",				STATICTAG_EDIT_WORD_LE("00000006")},
	{"crc",							STATICTAG_EDIT_DWORD_LE("00000008")},
	{"flags",							STATICTAG_EDIT_WORD_LE("0000000c")" "STATICTAG_FLAGS("0000000c", ATOM_NE_FLAGS_STR)},
	{"autodata",						STATICTAG_EDIT_WORD_LE("0000000e")},
	{"heap min",						STATICTAG_EDIT_WORD_LE("00000010")},
	{"stack min",						STATICTAG_EDIT_WORD_LE("00000012")},
	{"CS:IP",							STATICTAG_EDIT_WORD_LE("00000016")":"STATICTAG_EDIT_WORD_LE("00000014")},
	{"SS:SP",							STATICTAG_EDIT_WORD_LE("0000001a")":"STATICTAG_EDIT_WORD_LE("00000018")},
	{"number of segments",				STATICTAG_EDIT_WORD_LE("0000001c")},
	{"number of module references",		STATICTAG_EDIT_WORD_LE("0000001e")},
	{"size of non-resident name table",	STATICTAG_EDIT_WORD_LE("00000020")},
	{"offset of segment table",			STATICTAG_EDIT_WORD_LE("00000022")},
	{"offset of resource table",			STATICTAG_EDIT_WORD_LE("00000024")},
	{"offset of resident names table",		STATICTAG_EDIT_WORD_LE("00000026")},
	{"offset of module reference table",	STATICTAG_EDIT_WORD_LE("00000028")},
	{"offset of imported names table",		STATICTAG_EDIT_WORD_LE("0000002a")},
	{"offset of non-resident names table",	STATICTAG_EDIT_DWORD_LE("0000002c")},
	{"number of movable entries",			STATICTAG_EDIT_WORD_LE("00000030")},
	{"segment alignment shift count",		STATICTAG_EDIT_WORD_LE("00000032")},
	{"number of resource segments",		STATICTAG_EDIT_WORD_LE("00000034")},
	{"target os",						STATICTAG_EDIT_BYTE("00000036")" "STATICTAG_DESC_BYTE("00000036", ATOM_NE_OS_STR)},
	{"additional flags",				STATICTAG_EDIT_BYTE("00000037")},
	{"offset of return thunks",			STATICTAG_EDIT_WORD_LE("00000038")},
	{"offset of segment reference bytes",	STATICTAG_EDIT_WORD_LE("0000003a")},
	{"minimum code swap area size",		STATICTAG_EDIT_WORD_LE("0000003c")},
	{"expected os version",				STATICTAG_EDIT_WORD_LE("0000003e")},
	{0, 0}
};

static int_hash ne_os[] =
{
	{NE_OS_UNKNOWN, "all"},
	{NE_OS_OS2, "OS/2"},
	{NE_OS_WINDOWS, "Windows"},
	{NE_OS_DOS4, "DOS 4.x"},
	{0, 0}
};

static ht_tag_flags_s ne_flags[] =
{
	{-1, "NE - file characteristics"},
	{0,  "[00] solo data"},
	{1,  "[01] instance data"},
	{2,  "[02] per-process library initialization"},
	{3,  "[03] protected mode only"},
	{4,  "[04] 8086 instructions"},
	{5,  "[05] 80286 instructions"},
	{6,  "[06] 80386 instructions"},
	{7,  "[07] fpu instructions"},
	{8,  "[08] w0"},
	{9,  "[09] w1"},
	{10, "[10] w2"},
	{11, "[11] bound as family app"},
	{12, "[12] reserved"},
	{13, "[13] errors in image"},
	{14, "[14] reserved"},
	{15, "[15] not a process"},
	{0, 0}
};

static ht_view *htneheader_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_ne_shared_data *ne_shared=(ht_ne_shared_data *)group->get_shared_data();

	int h=ne_shared->hdr_ofs;
	ht_uformat_viewer *v=new ht_uformat_viewer();
	v->init(b, DESC_NE_HEADER, VC_EDIT | VC_SEARCH, file, group);
	ht_mask_sub *m=new ht_mask_sub();
	m->init(file, 0);

	registerAtom(ATOM_NE_OS, ne_os);
	registerAtom(ATOM_NE_FLAGS, ne_flags);

	char info[128];
	ht_snprintf(info, sizeof info, "* NE header at offset 0x%08qx", ne_shared->hdr_ofs);
	m->add_mask(info);
	m->add_staticmask_ptable(neheader, h, false);
	v->insertsub(m);

	return v;
}

format_viewer_if htneheader_if = {
	htneheader_init,
	0
};
ht-2.0.22/htxbe.h0000644000175000001440000000565310615341624010423 00000000000000/* 
 *	HT Editor
 *	htxbe.h
 *
 *	Copyright (C) 2003 Stefan Esser
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTXBE_H__
#define __HTXBE_H__

#include "formats.h"
#include "xbestruct.h"
#include "htxbeimp.h"

#define DESC_XBE "xbe - XBOX executable"
#define DESC_XBE_HEADER "xbe/header"
#define DESC_XBE_IMAGE "xbe/image"
#define DESC_XBE_IMPORTS "xbe/imports"


#define ATOM_XBE_INIT_FLAGS 			0x58420000
#define ATOM_XBE_INIT_FLAGS_STR			 "58420000"

#define ATOM_XBE_SECTION_FLAGS 			0x58420001
#define ATOM_XBE_SECTION_FLAGS_STR 		 "58420001"

#define ATOM_XBE_MEDIA_FLAGS 			0x58420002
#define ATOM_XBE_MEDIA_FLAGS_STR 		 "58420002"

#define ATOM_XBE_REGION 			0x58420003
#define ATOM_XBE_REGION_STR 			 "58420003"

#define ATOM_XBE_LIBRARY_FLAGS 			0x58420004
#define ATOM_XBE_LIBRARY_FLAGS_STR 		 "58420004"


extern format_viewer_if htxbe_if;

struct xbe_section_headers {
	uint32	number_of_sections;
	uint32	base_address;
	XBE_SECTION_HEADER *sections;
};

struct ht_xbe_shared_data {
	XBE_IMAGE_HEADER header;
	XBE_CERTIFICATE certificate;
	XBE_LIBRARY_VERSION *libraries;

	char *headerspace;
	xbe_section_headers sections;

	ht_xbe_import imports;


	ht_format_viewer *v_header;
	ht_view *v_exports;
	ht_view *v_imports;
	ht_view *v_dimports;
	ht_view *v_resources;
	ht_view *v_il;
	ht_format_viewer *v_image;	
};

/*
 *	ht_xbe
 */
class ht_xbe: public ht_format_group {
protected:
	bool loc_enum;
public:
		void init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs);
	virtual	void done();
	/* overwritten */
	virtual   void loc_enum_start();
	virtual   bool loc_enum_next(ht_format_loc *loc);
};

bool xbe_rva_to_section(xbe_section_headers *section_headers, RVA rva, int *section);
bool xbe_rva_to_ofs(xbe_section_headers *section_headers, RVA rva, FileOfs *ofs);
bool xbe_rva_is_valid(xbe_section_headers *section_headers, RVA rva);
bool xbe_rva_is_physical(xbe_section_headers *section_headers, RVA rva);

bool xbe_ofs_to_rva(xbe_section_headers *section_headers, FileOfs ofs, RVA *rva);
bool xbe_ofs_to_section(xbe_section_headers *section_headers, FileOfs ofs, int *section);
bool xbe_ofs_to_rva_and_section(xbe_section_headers *section_headers, FileOfs ofs, RVA *rva, int *section);

bool xbe_section_name_to_section(xbe_section_headers *section_headers, const char *name, int *section);

#endif /* !__HTXBE_H__ */
ht-2.0.22/htxbe.cc0000644000175000001440000002046010615341624010552 00000000000000/*
 *	HT Editor
 *	htxbe.cc
 *
 *	Copyright (C) 2003 Stefan Esser
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "log.h"
#include "endianess.h"
#include "htxbe.h"
#include "htxbehead.h"
#include "htxbeimg.h"
#include "stream.h"
#include "tools.h"

#include 
#include 

static format_viewer_if *htxbe_ifs[] = {
	&htxbeheader_if,
	&htxbeimports_if,
	&htxbeimage_if,
	0
};

static ht_view *htxbe_init(Bounds *b, File *file, ht_format_group *format_group)
{
	byte xbemagic[4];

	file->seek(0);
	file->read(xbemagic, 4);
	if ((xbemagic[0]!=XBE_MAGIC0) || (xbemagic[1]!=XBE_MAGIC1) ||
	   (xbemagic[2]!=XBE_MAGIC2) || (xbemagic[3]!=XBE_MAGIC3)) return 0;

	ht_xbe *g=new ht_xbe();
	g->init(b, file, htxbe_ifs, format_group, 0);
	return g;
}

format_viewer_if htxbe_if = {
	htxbe_init,
	0
};

/*
 *	CLASS ht_xbe
 */
void ht_xbe::init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs)
{
	ht_format_group::init(b, VO_BROWSABLE | VO_SELECTABLE | VO_RESIZE, DESC_XBE, file, false, true, 0, format_group);
	VIEW_DEBUG_NAME("ht_xbe");

	ht_xbe_shared_data *xbe_shared = ht_malloc(sizeof (ht_xbe_shared_data));
	shared_data = xbe_shared;

	xbe_shared->imports.funcs = new Array(true);

	xbe_shared->v_image = NULL;
	xbe_shared->v_imports = NULL;
	xbe_shared->v_header = NULL;

	/* read header */
	file->seek(0);
	file->read(&xbe_shared->header, sizeof xbe_shared->header);
	createHostStruct(&xbe_shared->header.base_address, XBE_IMAGE_HEADER_struct, little_endian);
	
	/* decode entrypoint - XXX: only RETAILs*/
	xbe_shared->header.entry_point ^= 0xA8FC57AB;
	xbe_shared->header.kernel_image_thunk_address ^= 0x5B6D40B6;

	/* read headerspace XXX: UGLY*/
	file->seek(0);
	xbe_shared->headerspace = ht_malloc(xbe_shared->header.size_of_headers+4);
	file->read(xbe_shared->headerspace, xbe_shared->header.size_of_headers);
	xbe_shared->headerspace[xbe_shared->header.size_of_headers]=0;
	xbe_shared->headerspace[xbe_shared->header.size_of_headers+1]=0;
	xbe_shared->headerspace[xbe_shared->header.size_of_headers+2]=0;
	xbe_shared->headerspace[xbe_shared->header.size_of_headers+3]=0;

	/* read certificate */	
	file->seek(xbe_shared->header.certificate_address-xbe_shared->header.base_address);
	file->read(&xbe_shared->certificate, sizeof xbe_shared->certificate);
	createHostStruct(&xbe_shared->certificate, XBE_CERTIFICATE_struct, little_endian);

	/* read library versions */
	file->seek(xbe_shared->header.library_versions_address-xbe_shared->header.base_address);
	
	xbe_shared->libraries = ht_malloc(xbe_shared->header.number_of_library_versions * sizeof *xbe_shared->libraries);
	file->read(xbe_shared->libraries, xbe_shared->header.number_of_library_versions * sizeof *xbe_shared->libraries);

	for (uint i=0; iheader.number_of_library_versions; i++) {
		createHostStruct(&xbe_shared->libraries[i], XBE_LIBRARY_VERSION_struct, little_endian);
	}

	/* read section headers */
	file->seek(xbe_shared->header.section_header_address-xbe_shared->header.base_address);
	
	xbe_shared->sections.sections = ht_malloc(xbe_shared->header.number_of_sections * sizeof *xbe_shared->sections.sections);
	file->read(xbe_shared->sections.sections, xbe_shared->header.number_of_sections * sizeof *xbe_shared->sections.sections);

	xbe_shared->sections.number_of_sections = xbe_shared->header.number_of_sections;
	xbe_shared->sections.base_address = xbe_shared->header.base_address;

	for (uint i=0; iheader.number_of_sections; i++) {
		createHostStruct(&xbe_shared->sections.sections[i], XBE_SECTION_HEADER_struct, little_endian);
		
		// XXX: this is crashable!!!
		xbe_shared->sections.sections[i].section_name_address += (unsigned long) xbe_shared->headerspace - xbe_shared->header.base_address;
		xbe_shared->sections.sections[i].virtual_address -= xbe_shared->header.base_address;
	}

	shared_data = xbe_shared;
	
	xbe_shared->header.tls_address -= xbe_shared->header.base_address;

	ht_format_group::init_ifs(ifs);
}

void ht_xbe::done()
{
	ht_format_group::done();

	ht_xbe_shared_data *xbe_shared = (ht_xbe_shared_data*)shared_data;

/*
	if (pe_shared->exports.funcs) {
		pe_shared->exports.funcs->destroy();
		delete pe_shared->exports.funcs;
	}
	if (pe_shared->dimports.funcs) {
		pe_shared->dimports.funcs->destroy();
		delete pe_shared->dimports.funcs;
	}
	if (pe_shared->dimports.libs) {
		pe_shared->dimports.libs->destroy();
		delete pe_shared->dimports.libs;
	}
	if (pe_shared->imports.funcs) {
		pe_shared->imports.funcs->destroy();
		delete pe_shared->imports.funcs;
	}
	if (pe_shared->imports.libs) {
		pe_shared->imports.libs->destroy();
		delete pe_shared->imports.libs;
	}
*/
	free(xbe_shared->sections.sections);

	free(shared_data);
}

void ht_xbe::loc_enum_start()
{
/*
	ht_pe_shared_data *sh=(ht_pe_shared_data*)shared_data;
	if (sh->opt_magic==COFF_OPTMAGIC_PE32) {
		loc_enum=1;
	} else {
		loc_enum=0;
	}
*/
}

bool ht_xbe::loc_enum_next(ht_format_loc *loc)
{
	return false;
}

/*
 *	rva conversion routines
 */

bool xbe_rva_to_ofs(xbe_section_headers *section_headers, RVA rva, FileOfs *ofs)
{
	XBE_SECTION_HEADER *s=section_headers->sections;
	
	for (uint i=0; inumber_of_sections; i++) {
		if ((rva>=s->virtual_address) &&
		(rvavirtual_address+s->raw_size)) {
			*ofs=rva-s->virtual_address+s->raw_address;
			return true;
		}
		s++;
	}
	return false;
}

bool xbe_rva_to_section(xbe_section_headers *section_headers, RVA rva, int *section)
{
	XBE_SECTION_HEADER *s=section_headers->sections;

	for (uint i=0; inumber_of_sections; i++) {
		if ((rva>=s->virtual_address) &&
		(rvavirtual_address+MAX(s->virtual_size, s->raw_size))) {
			*section=i;
			return true;
		}
		s++;
	}
	return false;
}

bool xbe_rva_is_valid(xbe_section_headers *section_headers, RVA rva)
{
	XBE_SECTION_HEADER *s=section_headers->sections;
	for (uint i=0; inumber_of_sections; i++) {
		if ((rva>=s->virtual_address) &&
		(rvavirtual_address+MAX(s->virtual_size, s->raw_size))) {
			return true;
		}
		s++;
	}
	return false;
}

bool xbe_rva_is_physical(xbe_section_headers *section_headers, RVA rva)
{
	XBE_SECTION_HEADER *s=section_headers->sections;

	for (uint i=0; inumber_of_sections; i++) {
		if ((rva>=s->virtual_address) &&
		(rvavirtual_address+s->raw_size)) {
			return true;
		}
		s++;
	}
	return false;
}

/*
 *	ofs conversion routines
 */

bool xbe_ofs_to_rva(xbe_section_headers *section_headers, FileOfs ofs, RVA *rva)
{
	XBE_SECTION_HEADER *s=section_headers->sections;
	for (uint i=0; inumber_of_sections; i++) {
		if ((ofs>=s->raw_address) &&
		(ofsraw_address+s->raw_size)) {
			*rva=ofs-s->raw_address+s->virtual_address;
			return true;
		}
		s++;
	}
	return false;
}

bool xbe_ofs_to_section(xbe_section_headers *section_headers, FileOfs ofs, int *section)
{
	XBE_SECTION_HEADER *s=section_headers->sections;
	for (uint i=0; inumber_of_sections; i++) {
		if ((ofs>=s->raw_address) &&
		(ofsraw_address+s->raw_size)) {
			*section=i;
			return true;
		}
		s++;
	}
	return false;
}

bool xbe_ofs_to_rva_and_section(xbe_section_headers *section_headers, FileOfs ofs, RVA *rva, int *section)
{
	bool r = xbe_ofs_to_rva(section_headers, ofs, rva);
	if (r) {
		r = xbe_ofs_to_section(section_headers, ofs, section);
	}
	return r;
}

bool xbe_ofs_is_valid(xbe_section_headers *section_headers, FileOfs ofs)
{
	RVA rva;
	return xbe_ofs_to_rva(section_headers, ofs, &rva);
}

/*
 *
 */
 
bool xbe_section_name_to_section(xbe_section_headers *section_headers, const char *name, int *section)
{
	XBE_SECTION_HEADER *s = section_headers->sections;
	int slen = strlen(name);

	for (uint i=0; i < section_headers->number_of_sections; i++) {
		if (ht_strncmp(name, (char *)s->section_name_address, slen) == 0) {
			*section = i;
			return true;
		}
		s++;
	}
	return false;
}
ht-2.0.22/htcoff.h0000644000175000001440000000535610615341616010563 00000000000000/* 
 *	HT Editor
 *	htcoff.h
 *
 *	Copyright (C) 1999-2003 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTCOFF_H__
#define __HTCOFF_H__

#include "formats.h"
#include "coff_s.h"
#include "htcoffhd.h"
#include "endianess.h"

#define DESC_COFF			"coff - unix common obj file"
#define DESC_COFF_HEADER		"coff/header"
#define DESC_COFF_IMAGE			"coff/image"

#define ATOM_COFF_MACHINES 			0xf0450000
#define ATOM_COFF_MACHINES_STR			"f0450000"

#define ATOM_COFF_OPTIONAL_MAGICS 		0xf0450001
#define ATOM_COFF_OPTIONAL_MAGICS_STR 		 "f0450001"

#define ATOM_COFF_OPTIONAL_SIZES 		0xf0450002
#define ATOM_COFF_OPTIONAL_SIZES_STR 		 "f0450002"

#define ATOM_COFF_CHARACTERISTICS		0xf0450003
#define ATOM_COFF_CHARACTERISTICS_STR		 "f0450003"

#define ATOM_COFF_SECTION_CHARACTERISTICS	0xf0450004
#define ATOM_COFF_SECTION_CHARACTERISTICS_STR	 "f0450004"

extern format_viewer_if htcoff_if;

struct coff_section_headers {
	uint hdr_ofs;		// duplicate of ht_coff_shared_data.hdr_ofs (!)
	uint section_count;
	COFF_SECTION_HEADER *sections;
};

struct ht_coff_shared_data {
	uint32 hdr_ofs;
	COFF_HEADER coffheader;
	uint16 opt_magic;
	Endianess endian;
	union {
		COFF_OPTIONAL_HEADER32 coff32header;
	};
	coff_section_headers sections;
	ht_viewer *v_header;
	ht_viewer *v_image;
};

/*
 *	CLASS ht_coff
 */

class ht_coff: public ht_format_group {
private:
	ht_coff_shared_data *coff_shared;
public:
		void init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs, Endianess end);
	virtual	void done();
};

bool coff_rva_to_section(coff_section_headers *section_headers, RVA rva, int *section);
bool coff_rva_to_ofs(coff_section_headers *section_headers, RVA rva, FileOfs *ofs);
bool coff_rva_is_valid(coff_section_headers *section_headers, RVA rva);
bool coff_rva_is_physical(coff_section_headers *section_headers, RVA rva);

bool coff_ofs_to_rva(coff_section_headers *section_headers, uint32 ofs, RVA *rva);
bool coff_ofs_to_section(coff_section_headers *section_headers, uint32 ofs, uint *section);
int coff_ofs_to_rva_and_section(coff_section_headers *section_headers, uint32 ofs, RVA *rva, uint *section);

#endif /* !__HTCOFF_H__ */
ht-2.0.22/htlehead.h0000644000175000001440000000153010206756710011057 00000000000000/* 
 *	HT Editor
 *	htlehead.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTLEHEAD_H__
#define __HTLEHEAD_H__

#include "formats.h"

extern format_viewer_if htleheader_if;

#endif /* !__HTLEHEAD_H__ */
ht-2.0.22/classview.cc0000644000175000001440000005020611724451477011453 00000000000000/*
 *	HT Editor
 *	classview.cc
 *
 *	Copyright (C) 2001 Stanley Gambarin 
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include 

#include "class.h"
#include "classimg.h"
#include "atom.h"
#include "httag.h"
#include "snprintf.h"
#include "stream.h"

#define ATOM_CLS_ACCESS     0xcafebab0
#define ATOM_CLS_ACCESS_STR  "cafebab0"
#define ATOM_CLS_CPOOL      0xcafebab1
#define ATOM_CLS_CPOOL_STR   "cafebab1"

ht_tag_flags_s access_flags[] = 
{
	{ -1,  "access flags"},
	{8+0,  "[0x0001] public"},
	{8+1,  "[0x0002] private"},
	{8+2,  "[0x0004] protected"},
	{8+3,  "[0x0008] static"},
	{8+4,  "[0x0010] final"},
	{8+5,  "[0x0020] synchronized"},
	{8+6,  "[0x0040] volatile"},
	{8+7,  "[0x0080] transient"},
	{0,    "[0x0100] native"},
	{1,    "[0x0200] interface"},
	{2,    "[0x0400] abstract"},
	{3,    "[0x0800] strict"},
	{0, 0}
};
int_hash cpool_tags [] = 
{
	{ 1, "utf8"},
	{ 2, "unknown type"},
	{ 3, "integer"},
	{ 4, "float"},
	{ 5, "long"},
	{ 6, "double"},
	{ 7, "class"},
	{ 8, "string"},
	{ 9, "fieldref"},
	{10, "methodref"},
	{11, "interfacemethodref"},
	{12, "nameandtype"},
	{0, 0}
};
ht_mask_ptable cls_class1_hdr[] = 
{
	{"magic",                      STATICTAG_EDIT_DWORD_BE("00000000")},
	{"minor version",              STATICTAG_EDIT_WORD_BE ("00000004")},
	{"major version",              STATICTAG_EDIT_WORD_BE ("00000006")},
	{"constant pool count",        STATICTAG_EDIT_WORD_BE ("00000008")},
	{0, 0}
};
ht_mask_ptable cls_class2_hdr[] = 
{
	{"access flags",               STATICTAG_EDIT_WORD_BE ("00000000")
                                       " "STATICTAG_FLAGS("00000000", ATOM_CLS_ACCESS_STR)},
	{"this class",                 STATICTAG_EDIT_WORD_BE ("00000002")},
	{"super class",                STATICTAG_EDIT_WORD_BE ("00000004")},
	{"interfaces count",           STATICTAG_EDIT_WORD_BE ("00000006")},
	{0, 0}
};
ht_mask_ptable cpool_class[] = 
{
	{"name index",                 STATICTAG_EDIT_WORD_BE("00000001")},
	{0, 0}
};
ht_mask_ptable cpool_fmi[] =
{
	{"class index",                STATICTAG_EDIT_WORD_BE("00000001")},
	{"name and type index",        STATICTAG_EDIT_WORD_BE("00000003")},
	{0, 0}
};
ht_mask_ptable cpool_str[] =
{
	{"string index",               STATICTAG_EDIT_WORD_BE("00000001")},
	{0, 0}
};
ht_mask_ptable cpool_if[] = 
{
	{"bytes",                      STATICTAG_EDIT_DWORD_BE("00000001")},
	{0, 0}
};
ht_mask_ptable cpool_ld[] = 
{
	{"high bytes",                 STATICTAG_EDIT_DWORD_BE("00000001")},
	{"low bytes",                  STATICTAG_EDIT_DWORD_BE("00000005")},
	{0, 0}
};
ht_mask_ptable cpool_nat[] = 
{
	{"name index",                 STATICTAG_EDIT_WORD_BE("00000001")},
	{"descriptor index",           STATICTAG_EDIT_WORD_BE("00000003")},
	{0, 0}
};
ht_mask_ptable cpool_utf8[] = 
{
	{"length",                     STATICTAG_EDIT_WORD_BE("00000001")},
	{0, 0}
};
ht_mask_ptable cpool_hdr[] = 
{ 
	{"tag",                        STATICTAG_EDIT_BYTE("00000000")
" "STATICTAG_DESC_BYTE("00000000", ATOM_CLS_CPOOL_STR)},
	{0, 0}
};
ht_mask_ptable iface_hdr[] = 
{
	{"class name index",           STATICTAG_EDIT_WORD_BE("00000000")},
	{0, 0}
};
ht_mask_ptable field_hdr[] = 
{
	{"fields count",               STATICTAG_EDIT_WORD_BE("00000000")},
	{0, 0}
};
ht_mask_ptable method_hdr[] = 
{
	{"methods count",              STATICTAG_EDIT_WORD_BE("00000000")},
	{0, 0}
};
ht_mask_ptable mf_hdr[] = 
{
	{"access flags",               STATICTAG_EDIT_WORD_BE ("00000000")
" "STATICTAG_FLAGS("00000000", ATOM_CLS_ACCESS_STR)},
	{"name index",                 STATICTAG_EDIT_WORD_BE ("00000002")},
	{"descriptor index",           STATICTAG_EDIT_WORD_BE ("00000004")},
	{"attributes count",           STATICTAG_EDIT_WORD_BE ("00000006")},
	{0, 0}
};
ht_mask_ptable atr_hdr[] = 
{
	{"attributes count",           STATICTAG_EDIT_WORD_BE("00000000")},
	{0, 0}
};
ht_mask_ptable aexpt_hdr[] = 
{
	{"exception table length",     STATICTAG_EDIT_WORD_BE("00000000")},
	{0, 0}
};
ht_mask_ptable aexpt_info[] = 
{
	{"start pc",                   STATICTAG_EDIT_WORD_BE("00000000")},
	{"end pc",                     STATICTAG_EDIT_WORD_BE("00000002")},
	{"handler pc",                 STATICTAG_EDIT_WORD_BE("00000004")},
	{"catch type",                 STATICTAG_EDIT_WORD_BE("00000006")},
	{0, 0}
}; 
ht_mask_ptable ainn_info[] = 
{
	{"inner class info index",     STATICTAG_EDIT_WORD_BE("00000000")},
	{"outer class info index",     STATICTAG_EDIT_WORD_BE("00000002")},
	{"inner name index",           STATICTAG_EDIT_WORD_BE("00000004")},
	{"inner class access flags",   STATICTAG_EDIT_WORD_BE("00000006")
                                       " "STATICTAG_FLAGS("00000006", ATOM_CLS_ACCESS_STR)},
	{0, 0}
};
ht_mask_ptable aline_info[] = 
{
	{"start pc",                   STATICTAG_EDIT_WORD_BE("00000000")},
	{"line number",                STATICTAG_EDIT_WORD_BE("00000002")},
	{0, 0}
}; 
ht_mask_ptable aloc_info[] = 
{
	{"start pc",                   STATICTAG_EDIT_WORD_BE("00000000")},
	{"length",                     STATICTAG_EDIT_WORD_BE("00000002")},
	{"name index",                 STATICTAG_EDIT_WORD_BE("00000004")},
	{"descriptor index",           STATICTAG_EDIT_WORD_BE("00000006")},
	{"index",                      STATICTAG_EDIT_WORD_BE("00000008")},
	{0, 0}
};
ht_mask_ptable axpt_info[] = 
{
	{"exception",                  STATICTAG_EDIT_WORD_BE("00000000")},
	{0, 0}
};
ht_mask_ptable attrib_hdr[] = 
{
	{"attribute name index",       STATICTAG_EDIT_WORD_BE("00000000")},
	{"attribute length",           STATICTAG_EDIT_DWORD_BE("00000002")},
	{0, 0}
};
ht_mask_ptable aconst_hdr[] = 
{
	{"constantvalue index",        STATICTAG_EDIT_WORD_BE("00000006")},
	{0, 0}
};
ht_mask_ptable acode_hdr[] = 
{
	{"max stack",                  STATICTAG_EDIT_WORD_BE("00000006")},
	{"max locals",                 STATICTAG_EDIT_WORD_BE("00000008")},
	{"code length",                STATICTAG_EDIT_DWORD_BE("0000000a")},
	{0, 0}
};
ht_mask_ptable axpt_hdr[] = 
{
	{"number of exceptions",       STATICTAG_EDIT_WORD_BE("00000006")},
	{0, 0}
};
ht_mask_ptable ainn_hdr[] = 
{
	{"number of classes",          STATICTAG_EDIT_WORD_BE("00000006")},
	{0, 0}
};
ht_mask_ptable asrc_hdr[] = 
{
	{"sourcefile index",           STATICTAG_EDIT_WORD_BE("00000006")},
	{0, 0}
};
ht_mask_ptable alin_hdr[] = 
{
	{"line_number table length",   STATICTAG_EDIT_WORD_BE("00000006")},
	{0, 0}
};
ht_mask_ptable aloc_hdr[] = 
{
	{"local variable table length",STATICTAG_EDIT_WORD_BE("00000006")},
	{0, 0}
};
ht_mask_ptable asignature_hdr[] = 
{
	{"signature",                  STATICTAG_EDIT_WORD_BE("00000006")},
	{0, 0}
};

static void attrib_view(ht_group_sub *g, File *f,
		  unsigned *idx, classfile *c, attrib_info *a)
{
	ht_group_sub *g2, *g3;
	ht_mask_sub *s, *s2;
	ht_collapsable_sub *cs, *cs2;
	attrib_info *atr;
	u4 code_len = 0;
	u2 tabl_len = 0;
	u1 inp[4];
	unsigned i, j;
	char info[128];

	s = new ht_mask_sub();
	s->init(f, (*idx)++);
	s->add_staticmask_ptable(attrib_hdr, a->offset, true);
	g->insertsub(s);
	switch (a->tag) {
	case ATTRIB_SourceFile:
		s->add_staticmask_ptable(asrc_hdr, a->offset, true);
		break;
	case ATTRIB_Code:
		s->add_staticmask_ptable(acode_hdr, a->offset, true);
		j = a->offset + 10;
		f->seek(j);
		f->read(inp, 4);
		j += 4;
		code_len = (((((((u4)inp[0]<<8)|inp[1])<<8)|inp[2])<<8)|inp[3]);
		j += code_len;

		s2 = new ht_mask_sub();
		s2->init(f, (*idx)++);
		s2->add_staticmask_ptable(aexpt_hdr, j, true);
		g->insertsub(s2);
		f->seek(j);
		f->read(inp, 2);
		j += 2;
		tabl_len = (((u2)inp[0]<<8)|inp[1]);
		g2 = new ht_group_sub();
		g2->init(f);
		if (!tabl_len) {
			s2 = new ht_mask_sub();
			s2->init(f, (*idx)++);
			s2->add_mask("");
			g2->insertsub(s2);
		}
		for (i=0; i < tabl_len; i++) {
			s2 = new ht_mask_sub();
			s2->init(f, (*idx)++);
			s2->add_staticmask_ptable(aexpt_info, j+i*8, true);
			cs = new ht_collapsable_sub();
			ht_snprintf(info, sizeof info, "exception table entry [%08x]:", i);
			cs->init(f, s2, 1, info, 1);
			g2->insertsub(cs);
		}
		j += tabl_len * 8;
		cs2 = new ht_collapsable_sub();
		cs2->init(f, g2, 1, "exception table", 1);
		g->insertsub(cs2);

		s2 = new ht_mask_sub();
		s2->init(f, (*idx)++);
		s2->add_staticmask_ptable(atr_hdr, j, true);
		g->insertsub(s2);
		f->seek(j);
		f->read(inp, 2);
		j += 2;
		tabl_len = (((u2)inp[0]<<8)|inp[1]);
		g2 = new ht_group_sub();
		g2->init(f);
		if (!tabl_len) {
			s2 = new ht_mask_sub();
			s2->init(f, (*idx)++);
			s2->add_mask("");
			g2->insertsub(s2);
		}
		for (i=0; iinit(f);
			f->seek(j);
			atr = attribute_read(f, c);
			atr->offset = j;
			j += atr->len + 6;
			attrib_view(g3, f, idx, c, atr);
			cs = new ht_collapsable_sub();
			ht_snprintf(info, sizeof info, "attribute entry [%08x]: %s", i,
				c->cpool[atr->name]->value.string); 
			free(atr);
			cs->init(f, g3, 1, info, 1);
			g2->insertsub(cs);
		}
		cs2 = new ht_collapsable_sub();
		cs2->init(f, g2, 1, "attributes", 1);
		g->insertsub(cs2);
		break;
	case ATTRIB_Signature:
		s->add_staticmask_ptable(asignature_hdr, a->offset, true);
		break;
	case ATTRIB_ConstantValue:
		s->add_staticmask_ptable(aconst_hdr, a->offset, true);
		break;
	case ATTRIB_LineNumberTable:
		s->add_staticmask_ptable(alin_hdr, a->offset, true);
		f->seek(a->offset+6);
		f->read(inp, 2);
		j = a->offset + 6 + 2;
		tabl_len = (((u2)inp[0]<<8)|inp[1]);
		g2 = new ht_group_sub();
		g2->init(f);
		if (!tabl_len) {
			s2 = new ht_mask_sub();
			s2->init(f, (*idx)++);
			s2->add_mask("");
			g2->insertsub(s2);
		}
		for (i=0; iinit(f, (*idx)++);
			s2->add_staticmask_ptable(aline_info, j+i*4, true);
			cs = new ht_collapsable_sub();
			ht_snprintf(info, sizeof info, "line number table entry [%08x]:", i);
			cs->init(f, s2, 1, info, 1);
			g2->insertsub(cs);
		}
		cs2 = new ht_collapsable_sub();
		cs2->init(f, g2, 1, "line number table", 1);
		g->insertsub(cs2);
		break;
	case ATTRIB_InnerClasses:
		s->add_staticmask_ptable(ainn_hdr, a->offset, true);
		f->seek(a->offset+6);
		f->read(inp, 2);
		j = a->offset + 6 + 2;
		tabl_len = (((u2)inp[0]<<8)|inp[1]);
		g2 = new ht_group_sub();
		g2->init(f);
		if (!tabl_len) {
			s2 = new ht_mask_sub();
			s2->init(f, (*idx)++);
			s2->add_mask("");
			g2->insertsub(s2);
		}
		for (i=0; iinit(f, (*idx)++);
			s2->add_staticmask_ptable(ainn_info, j+i*8, true);
			cs = new ht_collapsable_sub();
			ht_snprintf(info, sizeof info, "classes entry [%08x]:", i);
			cs->init(f, s2, 1, info, 1);
			g2->insertsub(cs);
		}
		cs2 = new ht_collapsable_sub();
		cs2->init(f, g2, 1, "classes", 1);
		g->insertsub(cs2);
		break;
	case ATTRIB_Exceptions:
		s->add_staticmask_ptable(axpt_hdr, a->offset, true);
		f->seek(a->offset+6);
		f->read(inp, 2);
		j = a->offset + 6 + 2;
		tabl_len = (((u2)inp[0]<<8)|inp[1]);
		g2 = new ht_group_sub();
		g2->init(f);
		if (!tabl_len) {
			s2 = new ht_mask_sub();
			s2->init(f, (*idx)++);
			s2->add_mask("");
			g2->insertsub(s2);
		}
		for (i=0; iinit(f, (*idx)++);
			s2->add_staticmask_ptable(ainn_info, j+i*2, true);
			cs = new ht_collapsable_sub();
			ht_snprintf(info, sizeof info, "exception index table entry [%08x]:", i);
			cs->init(f, s2, 1, info, 1);
			g2->insertsub(cs);
		}
		cs2 = new ht_collapsable_sub();
		cs2->init(f, g2, 1, "exception index table", 1);
		g->insertsub(cs2);
		break;
	case ATTRIB_LocalVariableTable:
		s->add_staticmask_ptable(aloc_hdr, a->offset, true);
		f->seek(a->offset+6);
		f->read(inp, 2);
		j = a->offset + 6 + 2;
		tabl_len = (((u2)inp[0]<<8)|inp[1]);
		g2 = new ht_group_sub();
		g2->init(f);
		if (!tabl_len) {
			s2 = new ht_mask_sub();
			s2->init(f, (*idx)++);
			s2->add_mask("");
			g2->insertsub(s2);
		}
		for (i=0; iinit(f, (*idx)++);
			s2->add_staticmask_ptable(aloc_info, j+i*10, true);
			cs = new ht_collapsable_sub();
			ht_snprintf(info, sizeof info, "local variable table entry [%08x]:", i);
			cs->init(f, s2, 1, info, 1);
			g2->insertsub(cs);
		}
		cs2 = new ht_collapsable_sub();
		cs2->init(f, g2, 1, "local variable table", 1);
		g->insertsub(cs2);
		break;
	case ATTRIB_Synthetic:
	case ATTRIB_Deprecated:
	default:
		break;
	}
}

static void mf_view(ht_group_sub *g, File *f,
	   unsigned *idx, classfile *c, mf_info *mf)
{
	ht_group_sub *g2, *g3;
	ht_mask_sub *s;
	ht_collapsable_sub *cs, *cs2;
	char info[128];

	s = new ht_mask_sub();
	s->init(f, (*idx)++);
	s->add_staticmask_ptable(mf_hdr, mf->offset, true);
	g->insertsub(s);

	g2 = new ht_group_sub();
	g2->init(f);
	if (!mf->attribs_count) {
		s = new ht_mask_sub();
		s->init(f, (*idx)++);
		s->add_mask("");
		g2->insertsub(s);
	}
	for (uint i=0; iattribs_count; i++) {
		g3 = new ht_group_sub();
		g3->init(f);
		attrib_view(g3, f, idx, c, mf->attribs[i]);
		cs = new ht_collapsable_sub();
		ht_snprintf(info, sizeof info, "attribute entry [%08x]: %s", i, c->cpool[mf->attribs[i]->name]->value.string);
		cs->init(f, g3, 1, info, 1);
		g2->insertsub(cs);
	}
	cs2 = new ht_collapsable_sub();
	cs2->init(f, g2, 1, "attributes", 1);
	g->insertsub(cs2);
}

static ht_view *class_view(Bounds *b, File *file, ht_format_group *group)
{
	ht_mask_sub *s;
	ht_collapsable_sub *cs, *cs2;
	ht_group_sub *g, *g2, *g3;
	classfile *clazz;
	char info[128];
	unsigned i, j, idx = 0;

	clazz = ((ht_class_shared_data *)group->get_shared_data())->file;
	if (clazz) {
		ht_uformat_viewer *v = new ht_uformat_viewer();
		v->init(b, DESC_JAVA_HEADERS, VC_EDIT, file, group);
		registerAtom(ATOM_CLS_ACCESS, access_flags);
		registerAtom(ATOM_CLS_CPOOL,  cpool_tags);

		g = new ht_group_sub();
		g->init(file);
  
		s = new ht_mask_sub();
		s->init(file, idx++);
		s->add_staticmask_ptable(cls_class1_hdr, clazz->offset, true);
		g->insertsub(s);

		g2 = new ht_group_sub();
		g2->init(file);
		for (i=1; i < clazz->cpool_count; i++) {
			s = new ht_mask_sub();
			s->init(file, idx++);
			s->add_staticmask_ptable(cpool_hdr, clazz->cpool[i]->offset, true);
			switch (clazz->cpool[i]->tag) {
			case CONSTANT_Utf8:
				s->add_staticmask_ptable(cpool_utf8, clazz->cpool[i]->offset, true);
				break;
			case CONSTANT_Integer:
			case CONSTANT_Float:
				s->add_staticmask_ptable(cpool_if, clazz->cpool[i]->offset, true);
				break;
			case CONSTANT_Long:
			case CONSTANT_Double:
				s->add_staticmask_ptable(cpool_ld, clazz->cpool[i]->offset, true);
				break;
			case CONSTANT_Class:
				s->add_staticmask_ptable(cpool_class, clazz->cpool[i]->offset, true);
				break;
			case CONSTANT_String:
				s->add_staticmask_ptable(cpool_str, clazz->cpool[i]->offset, true);
				break;
			case CONSTANT_Fieldref:
			case CONSTANT_Methodref:
			case CONSTANT_InterfaceMethodref:
				s->add_staticmask_ptable(cpool_fmi, clazz->cpool[i]->offset, true);
				break;
			case CONSTANT_NameAndType:
				s->add_staticmask_ptable(cpool_nat, clazz->cpool[i]->offset, true);
				break;
			}
			cs = new ht_collapsable_sub();
			ht_snprintf(info, sizeof info, "constant pool entry [%08x]: %s", i,
					(clazz->cpool[i]->tag == CONSTANT_Utf8) 
					? clazz->cpool[i]->value.string : "");
			cs->init(file, s, 1, info, 1);
			g2->insertsub(cs);
			if (clazz->cpool[i]->tag == CONSTANT_Long
			 || clazz->cpool[i]->tag == CONSTANT_Double) {
				i++;
			}
		}
		cs2 = new ht_collapsable_sub();
		cs2->init(file, g2, 1, "constant pool", 1);
		g->insertsub(cs2);

		s = new ht_mask_sub();
		s->init(file, idx++);
		s->add_staticmask_ptable(cls_class2_hdr, clazz->coffset, true);
		g->insertsub(s);

		g2 = new ht_group_sub();
		g2->init(file);
		if (!clazz->interfaces_count) {
			s = new ht_mask_sub();
			s->init(file, idx++);
			s->add_mask("");
			g2->insertsub(s);
		}
		for (i=0; i < clazz->interfaces_count; i++) {
			s = new ht_mask_sub();
			s->init(file, idx++);
			s->add_staticmask_ptable(iface_hdr, clazz->coffset+8+i*2, true);
			cs = new ht_collapsable_sub();
			j = clazz->cpool[clazz->interfaces[i]]->value.llval[0];
			ht_snprintf(info, sizeof info, "interface entry [%08x]: %s", i,
				clazz->cpool[j]->value.string);
			cs->init(file, s, 1, info, 1);
			g2->insertsub(cs);
		}
		cs2 = new ht_collapsable_sub();
		cs2->init(file, g2, 1, "interfaces", 1);
		g->insertsub(cs2);

		s = new ht_mask_sub();
		s->init(file, idx++);
		s->add_staticmask_ptable(field_hdr, clazz->foffset, true);
		g->insertsub(s);
		g2 = new ht_group_sub();
		g2->init(file);
		if (!clazz->fields_count) {
			s = new ht_mask_sub();
			s->init(file, idx++);
			s->add_mask("");
			g2->insertsub(s);
		}
		for (i=0; i < clazz->fields_count; i++) {
			g3 = new ht_group_sub();
			g3->init(file);
			mf_view(g3, file, &idx, clazz, clazz->fields[i]);
			cs = new ht_collapsable_sub();
			ht_snprintf(info, sizeof info, "field entry [%08x]: %s", i, clazz->fields[i]->name);
				cs->init(file, g3, 1, info, 1);
			g2->insertsub(cs);
		}
		cs2 = new ht_collapsable_sub();
		cs2->init(file, g2, 1, "fields", 1);
		g->insertsub(cs2);

		s = new ht_mask_sub();
		s->init(file, idx++);
		s->add_staticmask_ptable(method_hdr, clazz->moffset, true);
		g->insertsub(s);
		g2 = new ht_group_sub();
		g2->init(file);
		if (!clazz->methods_count) {
			s = new ht_mask_sub();
			s->init(file, idx++);
			s->add_mask("");
			g2->insertsub(s);
		}
		for (i=0; imethods_count; i++) {
			g3 = new ht_group_sub();
			g3->init(file);
			mf_view(g3, file, &idx, clazz, clazz->methods[i]);
			cs = new ht_collapsable_sub();
			ht_snprintf(info, sizeof info, "method entry [%08x]: %s", i, clazz->methods[i]->name);
			cs->init(file, g3, 1, info, 1);
			g2->insertsub(cs);
		}
		cs2 = new ht_collapsable_sub();
		cs2->init(file, g2, 1, "methods", 1);
		g->insertsub(cs2);

		s = new ht_mask_sub();
		s->init(file, idx++);
		s->add_staticmask_ptable(atr_hdr, clazz->aoffset, true);
		g->insertsub(s);
		g2 = new ht_group_sub();
		g2->init(file);
		if (!clazz->attribs_count) {
			s = new ht_mask_sub();
			s->init(file, idx++);
			s->add_mask("");
			g2->insertsub(s);
		}
		for (i = 0; i < clazz->attribs_count; i++) {
			g3 = new ht_group_sub();
			g3->init(file);
			attrib_view(g3, file, &idx, clazz, clazz->attribs[i]);
			cs = new ht_collapsable_sub();
			j = clazz->attribs[i]->name;
			ht_snprintf(info, sizeof info, "attribute entry [%08x]: %s", i,
			    clazz->cpool[j]->value.string);
			cs->init(file, g3, 1, info, 1);
			g2->insertsub(cs);
		}
		cs2 = new ht_collapsable_sub();
		cs2->init(file, g2, 1, "attributes", 1);
		g->insertsub(cs2);

		v->insertsub(g);
		return v;
	} else {
		return NULL;
	}
}

void cview::init(Bounds *b, File *f, format_viewer_if **ifs,
		  ht_format_group *g, FileOfs header_ofs, void *shared)
{
	ht_format_group::init(b, VO_SELECTABLE | VO_BROWSABLE | VO_RESIZE, DESC_JAVA, f, false, true, 0, g);

	shared_data = shared;
	ht_format_group::init_ifs(ifs);
}

void cview::done()
{
	ht_format_group::done();
	ht_class_shared_data *clazz = (ht_class_shared_data *)shared_data;
	if (clazz) {
		class_unread(clazz);
	}
}

static format_viewer_if htcls_cview = {
	&class_view,
	0
};

static format_viewer_if *htcls_ifs[] = {
	&htcls_cview,
	&htclassimage_if,
	0
};

static ht_view *class_init(Bounds *b, File *file, ht_format_group *group)
{
	u1 magic[4];
	u1 extra_magic[4];

	try {
		file->seek(0);
		file->readx(magic, 4);
		file->readx(extra_magic, 4);
	} catch (...) {
		return NULL;
	}
	// Mach-O binaries also use 0xcafebabe here.  The second byte is the
	// number of architectures; if there's more than 10 it's probably
	// a Java class file instead.
	if (magic[0] == 0xca && magic[1] == 0xfe
	 && magic[2] == 0xba && magic[3] == 0xbe && extra_magic[3] > 10) {
		file->seek(0);
		void *shared_data = (void*)class_read(file);
		if (!shared_data) return NULL;
		cview *c = new cview();
		c->init(b, file, htcls_ifs, group, 0, shared_data);
		return c;
	}
	return NULL;
}

format_viewer_if htcls_if = {
	&class_init,
	0
};

ht-2.0.22/htlehead.cc0000644000175000001440000001476510615341620011225 00000000000000/* 
 *	HT Editor
 *	htlehead.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "atom.h"
#include "htnewexe.h"
#include "htle.h"
#include "htlehead.h"
#include "httag.h"
#include "snprintf.h"
#include "formats.h"

#include "lestruct.h"

static int_hash le_machines[] =
{
	{ LE_CPU_286,	"Intel 286" },
	{ LE_CPU_386,	"Intel 386" },
	{ LE_CPU_486,	"Intel 486" },
	{ LE_CPU_586,	"Intel 586" },
	{ LE_CPU_N10,	"Intel i860(N10)" },
	{ LE_CPU_N11,	"Intel N11" },
	{ LE_CPU_R2000, "MIPS R2000"	},
	{ LE_CPU_R6000, "MIPS R6000"	},
	{ LE_CPU_R4000, "MIPS R4000"	},
	{0, 0}
};

static int_hash le_os[] =
{
	{ LE_OS_OS2, "OS/2"},
	{ LE_OS_WIN, "Windows"},
	{ LE_OS_DOS4,	"DOS 4.x"},
	{ LE_OS_WIN386, "Windows 386" },
	{0, 0}
};

static ht_tag_flags_s le_flags[] =
{
	{-1, "LE - module flags"},
	{0,  "[00] ?"},
	{1,  "[01] ?"},
	{2,  "[02] per-process library initialization"},
	{3,  "[03] ?"},
	{4,  "[04] no internal fixups"},
	{5,  "[05] no external fixups"},
	{6,  "[06] ?"},
	{7,  "[07] ?"},
	{8,  "[08] w0"},
	{9,  "[09] w1"},
	{10, "[10] w2"},
	{11, "[11] ?"},
	{12, "[12] ?"},
	{13, "[13] errors in image"},
	{14, "[14] ?"},
	{15, "[15] is library"},
	{0, 0}
};

static ht_mask_ptable leheader[]=
{
	{"magic",							STATICTAG_EDIT_WORD_LE("00000000")},
	{"byte order",						STATICTAG_EDIT_BYTE("00000002")},
	{"word order",						STATICTAG_EDIT_BYTE("00000003")},
	{"level",							STATICTAG_EDIT_DWORD_LE("00000004")},
	{"cpu type",						STATICTAG_EDIT_WORD_LE("00000008")" "STATICTAG_DESC_WORD_LE("00000008", ATOM_LE_MACHINE_STR)},
	{"os type",						STATICTAG_EDIT_WORD_LE("0000000a")" "STATICTAG_DESC_WORD_LE("0000000a", ATOM_LE_OS_STR)},
	{"module version",					STATICTAG_EDIT_DWORD_LE("0000000c")},
	{"module flags",					STATICTAG_EDIT_DWORD_LE("00000010")" "STATICTAG_FLAGS("00000010", ATOM_LE_FLAGS_STR)},
	{"number of pages",					STATICTAG_EDIT_DWORD_LE("00000014")},
	{"logical cs",						STATICTAG_EDIT_DWORD_LE("00000018")},
	{"eip",							STATICTAG_EDIT_DWORD_LE("0000001c")},
	{"logical ss",						STATICTAG_EDIT_DWORD_LE("00000020")},
	{"esp",							STATICTAG_EDIT_DWORD_LE("00000024")},
	{"memory page size",				STATICTAG_EDIT_DWORD_LE("00000028")},
	{"last page size",					STATICTAG_EDIT_DWORD_LE("0000002c")},
	{"fixup section size",				STATICTAG_EDIT_DWORD_LE("00000030")},
	{"fixup section checksum",			STATICTAG_EDIT_DWORD_LE("00000034")},
	{"loader section size",				STATICTAG_EDIT_DWORD_LE("00000038")},
	{"loader section checksum",			STATICTAG_EDIT_DWORD_LE("0000003c")},
	{"offset of object table",			STATICTAG_EDIT_DWORD_LE("00000040")},
	{"number of objects",				STATICTAG_EDIT_DWORD_LE("00000044")},
	{"offset page map",					STATICTAG_EDIT_DWORD_LE("00000048")},
	{"offset iterated data",				STATICTAG_EDIT_DWORD_LE("0000004c")},
	{"offset of resource table",			STATICTAG_EDIT_DWORD_LE("00000050")},
	{"number of resource entries",		STATICTAG_EDIT_DWORD_LE("00000054")},
	{"offset of resident name table",		STATICTAG_EDIT_DWORD_LE("00000058")},
	{"offset of entry table",			STATICTAG_EDIT_DWORD_LE("0000005c")},
	{"offset of module directive table",	STATICTAG_EDIT_DWORD_LE("00000060")},
	{"number of module directives",		STATICTAG_EDIT_DWORD_LE("00000064")},
	{"offset of fixup page table",		STATICTAG_EDIT_DWORD_LE("00000068")},
	{"offset of fixup record table",		STATICTAG_EDIT_DWORD_LE("0000006c")},
	{"offset of import module name table",	STATICTAG_EDIT_DWORD_LE("00000070")},
	{"number of imported modules",		STATICTAG_EDIT_DWORD_LE("00000074")},
	{"offset of import procedure name table", STATICTAG_EDIT_DWORD_LE("00000078")},
	{"offset of per-page checksum table",	STATICTAG_EDIT_DWORD_LE("0000007c")},
	{"offset of enumerated data pages",	STATICTAG_EDIT_DWORD_LE("00000080")},
	{"number of preload pages",			STATICTAG_EDIT_DWORD_LE("00000084")},
	{"offset of non-resident names table",	STATICTAG_EDIT_DWORD_LE("00000088")},
	{"size of non-resident names table",	STATICTAG_EDIT_DWORD_LE("0000008c")},
	{"non-resident name table checksum",	STATICTAG_EDIT_DWORD_LE("00000090")},
	{"auto data object number",			STATICTAG_EDIT_DWORD_LE("00000094")},
	{"offset of debug info",				STATICTAG_EDIT_DWORD_LE("00000098")},
	{"size of debug info",				STATICTAG_EDIT_DWORD_LE("0000009c")},
	{"pages in preload section", 			STATICTAG_EDIT_DWORD_LE("000000a0")},
	{"pages in demand load section", 		STATICTAG_EDIT_DWORD_LE("000000a4")},
	{"size of heap (16-bit)", 			STATICTAG_EDIT_DWORD_LE("000000a8")},
	{"reserved (12 bytes)", 				STATICTAG_EDIT_BYTE("000000ac")" "STATICTAG_EDIT_BYTE("000000ad")" "STATICTAG_EDIT_BYTE("000000ae")" "STATICTAG_EDIT_BYTE("000000af")},
	{0, 								STATICTAG_EDIT_BYTE("000000b0")" "STATICTAG_EDIT_BYTE("000000b1")" "STATICTAG_EDIT_BYTE("000000b2")" "STATICTAG_EDIT_BYTE("000000b3")},
	{0, 								STATICTAG_EDIT_BYTE("000000b4")" "STATICTAG_EDIT_BYTE("000000b5")" "STATICTAG_EDIT_BYTE("000000b6")" "STATICTAG_EDIT_BYTE("000000b7")},
	{"--- VxD only ---", 0},
	{"offset of win-resource data",		STATICTAG_EDIT_DWORD_LE("000000b8")},
	{"size of win-resource data",			STATICTAG_EDIT_DWORD_LE("000000bc")},
	{"device id",						STATICTAG_EDIT_WORD_LE("000000c0")},
	{"ddk version",					STATICTAG_EDIT_WORD_LE("000000c2")},
	{0, 0}
};

static ht_view *htleheader_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_le_shared_data *le_shared=(ht_le_shared_data *)group->get_shared_data();

	/* FIXME: */
	bool le_bigendian = false;

	FileOfs h = le_shared->hdr_ofs;
	ht_uformat_viewer *v = new ht_uformat_viewer();
	v->init(b, DESC_LE_HEADER, VC_EDIT | VC_SEARCH, file, group);
	ht_mask_sub *m = new ht_mask_sub();
	m->init(file, 0);

	registerAtom(ATOM_LE_FLAGS, le_flags);
	registerAtom(ATOM_LE_MACHINE, le_machines);
	registerAtom(ATOM_LE_OS, le_os);

	char info[128];
	ht_snprintf(info, sizeof info, "* LE header at offset 0x%08qx", le_shared->hdr_ofs);
	m->add_mask(info);
	m->add_staticmask_ptable(leheader, h, le_bigendian);
	v->insertsub(m);

	le_shared->v_header = v;
	return v;
}

format_viewer_if htleheader_if = {
	htleheader_init,
	0
};
ht-2.0.22/htneent.cc0000644000175000001440000001073010771304342011103 00000000000000/* 
 *	HT Editor
 *	htneent.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "atom.h"
#include "htctrl.h"
#include "endianess.h"
#include "htiobox.h"
#include "htne.h"
#include "htneent.h"
#include "httag.h"
#include "formats.h"
#include "snprintf.h"

static ht_tag_flags_s ne_entflags[] =
{
	{-1, "NE - entrypoint flags"},
	{0,  "[00] exported"},
	{1,  "[01] single data"},
	{2,  "[02] reserved"},
	{0, 0}
};

static ht_view *htneentrypoints_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_ne_shared_data *ne_shared = (ht_ne_shared_data *)group->get_shared_data();

	FileOfs h = ne_shared->hdr_ofs;
	ht_ne_entrypoint_viewer *v = new ht_ne_entrypoint_viewer();
	v->init(b, DESC_NE_ENTRYPOINTS, VC_EDIT | VC_SEARCH, file, group);
	ht_mask_sub *m = new ht_mask_sub();
	m->init(file, 0);

	registerAtom(ATOM_NE_ENTFLAGS, ne_entflags);

	char line[1024];
	ht_snprintf(line, sizeof line, "* NE entrypoint table at offset 0x%08qx", h+ne_shared->hdr.enttab);
	m->add_mask(line);

	FileOfs o = h + ne_shared->hdr.enttab;
	NE_ENTRYPOINT_HEADER e;

	uint32 index = 1;
	while (o + sizeof e < h+ne_shared->hdr.enttab+ne_shared->hdr.cbenttab) {
		file->seek(o);
		file->read(&e, sizeof e);
		createHostStruct(&e, NE_ENTRYPOINT_HEADER_struct, little_endian);
		o += sizeof e;

		if (e.seg_index==0) {
/*			sprintf(line, "null entries [%d]", e.entry_count);
			m->add_mask(line);*/
		} else if (e.seg_index==0xff) {
			ht_snprintf(line, sizeof line, "entrypoints for movable segment [%d entries]", e.entry_count);
			m->add_mask(line);
		} else {
			ht_snprintf(line, sizeof line, "entrypoints for fixed segment %d [%d entries]", e.seg_index, e.entry_count);
			m->add_mask(line);
		}
		// FIXME: dont use sprintf
		for (int i=0; iadd_mask(line);
				o += sizeof (NE_ENTRYPOINT_MOVABLE);
			} else {
				char *l = line;
				char *l_end = line+sizeof line - 1;
				l += ht_snprintf(l, l_end-l, "%04x:    ", index);
				l = tag_make_edit_word(l, l_end-l, o+1, tag_endian_little);
				l += ht_snprintf(l, l_end-l, " ");
				l = tag_make_ref(l, l_end-l, o, e.seg_index, 0, 0, "goto");
				l += ht_snprintf(l, l_end-l, " flags=");
				l = tag_make_edit_byte(l, l_end-l, o);
				l += ht_snprintf(l, l_end-l, " ");
				l = tag_make_flags(l, l_end-l, ATOM_NE_ENTFLAGS, o);
				*l = 0;
				m->add_mask(line);
				o += sizeof (NE_ENTRYPOINT_FIXED);
			}
			index++;
		}
	}

	v->insertsub(m);

	return v;
}

format_viewer_if htneentrypoints_if = {
	htneentrypoints_init,
	NULL
};

/*
 *	CLASS ht_ne_entrypoint_viewer
 */

bool ht_ne_entrypoint_viewer::ref_sel(LINE_ID *id)
{
/*   FIXNEW
	uint seg = id_high;
	FileOfs o = id_low;
	ADDR a;
	if (seg == 0xff) {
		NE_ENTRYPOINT_MOVABLE e;
		file->seek(o);
		file->read(&e, sizeof e);
		createHostStruct(&e, NE_ENTRYPOINT_MOVABLE_struct, little_endian);
		a = NE_MAKE_ADDR(e.seg, e.offset);
	} else {
		NE_ENTRYPOINT_FIXED e;
		file->seek(o);
		file->read(&e, sizeof e);
		createHostStruct(&e, NE_ENTRYPOINT_FIXED_struct, little_endian);
		a = NE_MAKE_ADDR(seg, e.offset);
	}

	ht_ne_shared_data *ne_shared=(ht_ne_shared_data *)format_group->get_shared_data();

	if (ne_shared->v_image->goto_address2(a, this)) {
		app->focus(ne_shared->v_image);
	} else errorbox("can't follow: address %y is not valid!", a);
	return 1;*/
	return false;
}
ht-2.0.22/textedit.cc0000644000175000017500000016755012127651420011310 00000000000000/*
 *	HT Editor
 *	textedit.cc
 *
 *	Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net)
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "evalx.h"
#include "cmds.h"
#include "htctrl.h"
#include "htdialog.h"
#include "htmenu.h"
#include "htobj.h"
#include "htpal.h"
#include "htclipboard.h"
#include "htiobox.h"
#include "textedit.h"
#include "tools.h"
#include "snprintf.h"

#include 
#include 
#include 
#include 
#include 

/**/
#include "atom.h"
#include "hthist.h"
#include "htsearch.h"

static ht_search_request* create_request_hexascii(text_search_pos *start, text_search_pos *end, ht_view *f, uint search_class)
{
	ht_hexascii_search_form *form=(ht_hexascii_search_form*)f;
	ht_hexascii_search_form_data d;
	ViewDataBuf vdb(form, &d, sizeof d);
	
	ht_fxbin_search_request *request;
	
	if (!d.str.textlen) {
		throw MsgfException("%s: string is empty", "hex/ascii");
	}
/*	if (test_str_to_ofs(&start->offset, d.start.text, d.start.textlen, format, "start-offset")
	&& test_str_to_ofs(&end->offset, d.end.text, d.end.textlen, format, "end-offset")) {*/
		request = new ht_fxbin_search_request(search_class,
			d.options.state & 1 ? SF_FXBIN_CASEINSENSITIVE: 0,
			d.str.textlen, d.str.text);
/*	} else {
		request = NULL;
	}*/
	return request;
}

typedef ht_search_request* (*create_request_func)(text_search_pos *ret_start, text_search_pos *ret_end, ht_view *form, uint search_class);

struct ht_text_search_method {
	const char *name;
	uint search_class;			// SC_*
	uint search_mode_mask;		// SEARCHMODE_*
	uint histid;
	create_form_func create_form;
	create_request_func create_request;
	create_desc_func create_desc;
};

static ht_text_search_method text_search_methods[] =
{
	{ "bin: hex/ascii", SC_PHYSICAL, SEARCHMODE_BIN, HISTATOM_SEARCH_BIN,
		create_form_hexascii, create_request_hexascii, create_desc_hexascii }
};

ht_search_request *text_search_dialog(ht_text_viewer *text_viewer, uint searchmodes, const text_viewer_pos *end_pos)
{
	ht_search_request *result = NULL;
	Bounds b;
	b.w = 50;
	b.h = 15;
	b.x = (screen->w - b.w)/2;
	b.y = (screen->h - b.h)/2;
	ht_search_dialog *dialog = new ht_search_dialog();
	dialog->init(&b, "search");

	Bounds k;
	dialog->search_mode_xgroup->getbounds(&k);

	k.x = 0;
	k.y = 0;

	int modes = 0;
	int i = 0;
	ht_text_search_method *q = text_search_methods;
	while (q->name) {
		if (q->search_mode_mask & searchmodes) {
			Bounds v = k;
			ht_view *form = q->create_form(&v, q->histid);
			dialog->insert_search_mode(i, q->name, form);
			modes++;
		}
		q++;
		i++;
	}
	
//	dialog->select_search_mode(lastsearchmodeid);
	
	if (dialog->run(false)) {
		int modeid = dialog->get_search_modeid();
//		lastsearchmodeid = modeid;

		ht_text_search_method *s = &text_search_methods[modeid];
		ht_view *form = dialog->get_search_modeform();

		text_search_pos start, end;

		try {
			/* create history entry */
			if (s->create_desc) {
				char hist_desc[1024];
				s->create_desc(hist_desc, sizeof hist_desc, form);
				insert_history_entry((List*)getAtomValue(s->histid), hist_desc, form);
			}
			/* search */
			switch (s->search_class) {
				case SC_PHYSICAL: {
					text_viewer_pos cursor;
					text_viewer->get_cursor_pos(&cursor);
					start.offset = 0;
					text_viewer->pos_to_offset(&cursor, &start.offset);
					end.offset = 0xffffffff;
					break;
				}
			}
			result = s->create_request(&start, &end, form, s->search_class);
		} catch (const Exception &e) {
			errorbox("error: %y", &e);
		}
	}
	dialog->done();
	delete dialog;
	return result;
}

/*
 *	CLASS ht_undo_data
 */
bool ht_undo_data::combine(ht_undo_data *ud)
{
	return false;
}

/*
 *	CLASS ht_undo_data_delete_string
 */

ht_undo_data_delete_string::ht_undo_data_delete_string(text_viewer_pos *APos, text_viewer_pos *BPos, void *String, uint Len)
{
	apos = *APos;
	bpos = *BPos;
	if (Len) {
		string = malloc(Len);
		memcpy(string, String, Len);
	} else {
		string = NULL;
	}
	len = Len;
}

ht_undo_data_delete_string::~ht_undo_data_delete_string()
{
	free(string);
}

bool ht_undo_data_delete_string::combine(ht_undo_data *ud)
{
	if (ud->getObjectID() == getObjectID()) {
		ht_undo_data_delete_string *ud2 = (ht_undo_data_delete_string *)ud;
		if (ud2->apos.line == apos.line) {
			if (ud2->bpos.pofs + ud2->len == bpos.pofs) {
				string = realloc(string, len+ud2->len);
				memmove((byte*)string+ud2->len, string, len);
				memcpy(string, ud2->string, ud2->len);
				len += ud2->len;
				bpos = ud2->bpos;
				return true;
			}
		}
	}
	return false;
}

uint ht_undo_data_delete_string::getsize()
{
	return len + sizeof *this;
}

void ht_undo_data_delete_string::gettext(char *text, uint maxlen)
{
	char *buf = ht_malloc(len+1);
	bin2str(buf, string, len);
	ht_snprintf(text, maxlen, "deletion of '%s' at %d:%d", buf, bpos.line+1, bpos.pofs+1);
	free(buf);
}

ObjectID ht_undo_data_delete_string::getObjectID() const
{
	return ATOM_HT_UNDO_DATA_DELETE;
}

void ht_undo_data_delete_string::apply(ht_text_editor *te)
{
	te->goto_line(apos.line);
	te->cursor_pput(apos.pofs);
	te->delete_chars(bpos.line, bpos.pofs, len);
	te->goto_line(bpos.line);
	te->cursor_pput(bpos.pofs);
}

void ht_undo_data_delete_string::unapply(ht_text_editor *te, bool *goto_only)
{
	if (*goto_only && (bpos.line != te->top_line + te->cursory || te->physical_cursorx()!=bpos.pofs)) {
		te->goto_line(apos.line);
		te->cursor_pput(apos.pofs);
		te->goto_line(bpos.line);
		te->cursor_pput(bpos.pofs);
		return;
	}
	*goto_only = false;
	if (string) {
		te->insert_chars(bpos.line, bpos.pofs, string, len);
	}
	te->goto_line(apos.line);
	te->cursor_pput(apos.pofs);
}

/*
 *	CLASS ht_undo_data_delete_string2
 */

ht_undo_data_delete_string2::ht_undo_data_delete_string2(text_viewer_pos *APos, text_viewer_pos *BPos, void *String, uint Len)
{
	apos = *APos;
	bpos = *BPos;
	if (Len) {
		string = malloc(Len);
		memcpy(string, String, Len);
	} else {
		string = NULL;
	}
	len = Len;
}

ht_undo_data_delete_string2::~ht_undo_data_delete_string2()
{
	free(string);
}

bool ht_undo_data_delete_string2::combine(ht_undo_data *ud)
{
	if (ud->getObjectID() == getObjectID()) {
		ht_undo_data_delete_string2 *ud2 = (ht_undo_data_delete_string2 *)ud;
		if (ud2->apos.line == apos.line) {
			if (ud2->apos.pofs == apos.pofs) {
				string = realloc(string, len+ud2->len);
				memcpy((byte*)string+len, ud2->string, ud2->len);
				len += ud2->len;
				return true;
			}
		}
	}
	return false;
}

uint ht_undo_data_delete_string2::getsize()
{
	return len + sizeof *this;
}

void ht_undo_data_delete_string2::gettext(char *text, uint maxlen)
{
	char *buf = ht_malloc(len+1);
	bin2str(buf, string, len);
	ht_snprintf(text, maxlen, "deletion of '%s' at %d:%d", buf, apos.line+1, apos.pofs+1);
	free(buf);
}

ObjectID ht_undo_data_delete_string2::getObjectID() const
{
	return ATOM_HT_UNDO_DATA_DELETE2;
}

void ht_undo_data_delete_string2::apply(ht_text_editor *te)
{
	te->goto_line(bpos.line);
	te->cursor_pput(bpos.pofs);
	te->delete_chars(apos.line, apos.pofs, len);
	te->goto_line(apos.line);
	te->cursor_pput(apos.pofs);
}

void ht_undo_data_delete_string2::unapply(ht_text_editor *te, bool *goto_only)
{
	if (*goto_only && (apos.line != te->top_line + te->cursory || te->physical_cursorx()!=apos.pofs)) {
		te->goto_line(bpos.line);
		te->cursor_pput(bpos.pofs);
		te->goto_line(apos.line);
		te->cursor_pput(apos.pofs);
		return;
	}
	te->goto_line(apos.line);
	te->cursor_pput(apos.pofs);
	*goto_only = false;
	if (string) {
		te->insert_chars(apos.line, apos.pofs, string, len);
	}
}

/*
 *	CLASS ht_undo_data_insert_string
 */

ht_undo_data_insert_string::ht_undo_data_insert_string(text_viewer_pos *APos, text_viewer_pos *BPos, void *String, uint Len)
{
	apos = *APos;
	bpos = *BPos;
	if (Len) {
		string = malloc(Len);
		memcpy(string, String, Len);
	} else {
		string = NULL;
	}
	len = Len;
}

ht_undo_data_insert_string::~ht_undo_data_insert_string()
{
	free(string);
}

bool ht_undo_data_insert_string::combine(ht_undo_data *ud)
{
	if (ud->getObjectID() == getObjectID()) {
		ht_undo_data_insert_string *ud2 = (ht_undo_data_insert_string *)ud;
		if (ud2->cpos.line == cpos.line) {
			if (ud2->apos.pofs == apos.pofs + len) {
				string = realloc(string, len + ud2->len);
				memcpy((byte*)string+len, ud2->string, ud2->len);
				len += ud2->len;
				bpos = ud2->bpos;
				return true;
			}
		}
	}
	return false;
}

uint ht_undo_data_insert_string::getsize()
{
	return len + sizeof *this;
}

void ht_undo_data_insert_string::gettext(char *text, uint maxlen)
{
	char *buf = ht_malloc(len+1);
	bin2str(buf, string, len);
	ht_snprintf(text, maxlen, "insertion of '%s' at %d:%d", buf, apos.line+1, apos.pofs+1);
	free(buf);
}

ObjectID ht_undo_data_insert_string::getObjectID() const
{
	return ATOM_HT_UNDO_DATA_INSERT;
}

void ht_undo_data_insert_string::apply(ht_text_editor *te)
{
	te->goto_line(apos.line);
	te->cursor_pput(apos.pofs);
	if (string) {
		uint l = te->get_line_length(apos.line);
		cpos.line = apos.line;
		if (apos.pofs > l) {
			uint k = apos.pofs - l;               
			te->indent(apos.line, l, k);
			cpos.pofs = l;
		} else {
			cpos.pofs = apos.pofs;
		}
		te->insert_chars(apos.line, apos.pofs, string, len);
	}
	te->goto_line(bpos.line);
	te->cursor_pput(bpos.pofs);
}

void ht_undo_data_insert_string::unapply(ht_text_editor *te, bool *goto_only)
{
	if (*goto_only && (bpos.line != te->top_line + te->cursory || te->physical_cursorx()!=bpos.pofs)) {
		te->goto_line(apos.line);
		te->cursor_pput(apos.pofs);
		te->goto_line(bpos.line);
		te->cursor_pput(bpos.pofs);
		return;
	}
	*goto_only = false;
	te->unindent(cpos.line, cpos.pofs, bpos.pofs-cpos.pofs);
	te->goto_line(apos.line);
	te->cursor_pput(apos.pofs);
}

/*
 *	CLASS ht_undo_data_overwrite_string
 */
ht_undo_data_overwrite_string::ht_undo_data_overwrite_string(text_viewer_pos *APos, text_viewer_pos *BPos, void *String, uint Len, void *String2, uint Len2)
{
	apos = *APos;
	bpos = *BPos;
	if (Len) {
		string = malloc(Len);
		memcpy(string, String, Len);
	} else {
		string = NULL;
	}
	len = Len;
	if (Len2) {
		string2 = malloc(Len2);
		memcpy(string2, String2, Len2);
	} else {
		string2 = NULL;
	}
	len2 = Len2;
}

ht_undo_data_overwrite_string::~ht_undo_data_overwrite_string()
{
	free(string);
	free(string2);
}

bool ht_undo_data_overwrite_string::combine(ht_undo_data *ud)
{
	if (ud->getObjectID()==getObjectID()) {
		ht_undo_data_overwrite_string *ud2 = (ht_undo_data_overwrite_string *)ud;
		if (ud2->cpos.line == cpos.line) {
			if (ud2->apos.pofs == apos.pofs + len) {
				string = realloc(string, len + ud2->len);
				memcpy((byte*)string+len, ud2->string, ud2->len);
				len += ud2->len;
				bpos = ud2->bpos;
				if (ud2->len2) {
					if (!len2) {
						string2 = malloc(ud2->len2);
						memcpy(string2, ud2->string2, ud2->len2);
					} else {
						string2 = realloc(string2, len2 + ud2->len2);
						memcpy((byte*)string2+len2, ud2->string2, ud2->len2);
					}
					len2 += ud2->len;
				}
				return true;
			}
		}
	}
	return false;
}

uint ht_undo_data_overwrite_string::getsize()
{
	return len + len2 + sizeof(*this);
}

void ht_undo_data_overwrite_string::gettext(char *text, uint maxlen)
{
	char *buf = ht_malloc(len+1);
	bin2str(buf, string, len);
	ht_snprintf(text, maxlen, "insertion of '%s' at %d:%d", buf, apos.line+1, apos.pofs+1);
	free(buf);
}

ObjectID ht_undo_data_overwrite_string::getObjectID() const
{
	return ATOM_HT_UNDO_DATA_OVERWRITE;
}

void ht_undo_data_overwrite_string::apply(ht_text_editor *te)
{
	if (len2) te->delete_chars(apos.line, apos.pofs, len2);
	te->goto_line(apos.line);
	te->cursor_pput(apos.pofs);
	if (string) {
		uint l = te->get_line_length(apos.line);
		cpos.line = apos.line;
		if (apos.pofs > l) {
			uint k = apos.pofs - l;               
			te->indent(apos.line, l, k);
			cpos.pofs = l;
		} else {
			cpos.pofs = apos.pofs;
		}
		te->insert_chars(apos.line, apos.pofs, string, len);
	}
	te->goto_line(bpos.line);
	te->cursor_pput(bpos.pofs);
}

void ht_undo_data_overwrite_string::unapply(ht_text_editor *te, bool *goto_only)
{
	if (*goto_only && (bpos.line != te->top_line + te->cursory || te->physical_cursorx()!=bpos.pofs)) {
		te->goto_line(apos.line);
		te->cursor_pput(apos.pofs);
		te->goto_line(bpos.line);
		te->cursor_pput(bpos.pofs);
		return;
	}
	*goto_only = false;
	te->unindent(cpos.line, cpos.pofs, bpos.pofs-cpos.pofs);
	if (len2) te->insert_chars(apos.line, apos.pofs, string2, len2);
	te->goto_line(apos.line);
	te->cursor_pput(apos.pofs);
}

/*
 *	CLASS ht_undo_data_split_line
 */
ht_undo_data_split_line::ht_undo_data_split_line(text_viewer_pos *APos, text_viewer_pos *BPos, uint Indent)
{
	apos = *APos;
	bpos = *BPos;
	indent = Indent;
}

uint ht_undo_data_split_line::getsize()
{
	return sizeof *this;
}

void ht_undo_data_split_line::gettext(char *text, uint maxlen)
{
	ht_snprintf(text, maxlen, "split line at %d:%d", apos.line+1, apos.pofs+1);
}

ObjectID ht_undo_data_split_line::getObjectID() const
{
	return ATOM_HT_UNDO_DATA_SPLIT_LINE;
}

void ht_undo_data_split_line::apply(ht_text_editor *te)
{
	te->split_line(apos.line, apos.pofs);
	if (indent) te->indent(bpos.line, 0, indent);
	te->goto_line(bpos.line);
	te->cursor_pput(bpos.pofs);
}

void ht_undo_data_split_line::unapply(ht_text_editor *te, bool *goto_only)
{
	if (*goto_only && (bpos.line != te->top_line + te->cursory || te->physical_cursorx()!=bpos.pofs)) {
		te->goto_line(apos.line);
		te->cursor_pput(apos.pofs);
		te->goto_line(bpos.line);
		te->cursor_pput(bpos.pofs);
		return;
	}
	*goto_only = false;
	if (indent) te->unindent(bpos.line, 0, indent);
	te->concat_lines(apos.line);
	te->goto_line(apos.line);
	te->cursor_pput(apos.pofs);
}

/*
 *	CLASS ht_undo_data_join_line
 */
ht_undo_data_join_line::ht_undo_data_join_line(text_viewer_pos *APos, text_viewer_pos *BPos)
{
	apos = *APos;
	bpos = *BPos;
}

uint ht_undo_data_join_line::getsize()
{
	return sizeof *this;
}

void ht_undo_data_join_line::gettext(char *text, uint maxlen)
{
	ht_snprintf(text, maxlen, "join lines %d and %d", bpos.line+1, bpos.line+2);
}

ObjectID ht_undo_data_join_line::getObjectID() const
{
	return ATOM_HT_UNDO_DATA_JOIN_LINE;
}

void ht_undo_data_join_line::apply(ht_text_editor *te)
{
	uint l = te->get_line_length(apos.line);
	cpos.line = apos.line;
	if (apos.pofs > l) {
		uint k = apos.pofs - l;
		te->indent(apos.line, l, k);
		cpos.pofs = l;
	} else {
		cpos.pofs = apos.pofs;
	}
	    
	te->concat_lines(bpos.line);
	te->goto_line(bpos.line);
	te->cursor_pput(bpos.pofs);
}

void ht_undo_data_join_line::unapply(ht_text_editor *te, bool *goto_only)
{
	if (*goto_only && (bpos.line != te->top_line + te->cursory || te->physical_cursorx()!=bpos.pofs)) {
		te->goto_line(bpos.line);
		te->cursor_pput(bpos.pofs);
		return;     
	}
	*goto_only = false;
	te->split_line(bpos.line, bpos.pofs);
	if (cpos.line == bpos.line) te->unindent(cpos.line, cpos.pofs, bpos.pofs-cpos.pofs);
	te->goto_line(apos.line);
	te->cursor_pput(apos.pofs);
}

/*
 *	INSERT/DELETE BLOCK
 */

text_viewer_pos insert_text_block(ht_text_editor *te, text_viewer_pos apos, text_viewer_pos bpos, void *block, uint size)
{
	text_viewer_pos cpos;

	te->goto_line(apos.line);
	te->cursor_pput(apos.pofs);

	ht_textfile *textfile = te->get_textfile();
	FileOfs o;
	
	textfile->convert_line2ofs(apos.line, apos.pofs, &o);

	uint l = te->get_line_length(apos.line);
	cpos.line = apos.line;
	if (apos.pofs > l) {
		uint k = apos.pofs - l;
		te->indent(apos.line, l, k);
		cpos.pofs = l;
		o += k;
	} else {
		cpos.pofs = apos.pofs;
	}

	textfile->seek(o);
	textfile->write(block, size);

	uint s = size;
	text_viewer_pos start, end;
	textfile->convert_ofs2line(o, &start.line, &start.pofs);
	textfile->convert_ofs2line(o+s, &end.line, &end.pofs);
	te->select_set(&start, &end);
	te->goto_line(bpos.line);
	te->cursor_pput(bpos.pofs);

	return cpos;
}

void delete_text_block(ht_text_editor *te, text_viewer_pos apos, text_viewer_pos bpos, text_viewer_pos cpos, text_viewer_pos sel_start, text_viewer_pos sel_end, bool copy, void **block, uint *size)
{
	ht_textfile *textfile = te->get_textfile();

	FileOfs s, e;
	if (textfile->convert_line2ofs(sel_start.line, sel_start.pofs, &s) &&
	textfile->convert_line2ofs(sel_end.line, sel_end.pofs, &e) && copy) {
		uint sz = e-s;
		void *bl = malloc(sz);
		textfile->seek(s);
		textfile->read(bl, sz);
		*block = bl;
		*size = sz;
	}

	int k=0;
	if (sel_start.line < sel_end.line) {
		k=textfile->getlinelength(sel_start.line)-sel_start.pofs;
	} else {
		k=sel_end.pofs-sel_start.pofs;
	}
	te->delete_chars(sel_start.line, sel_start.pofs, k);
	if (sel_start.line < sel_end.line) {
		te->delete_chars(sel_end.line, 0, sel_end.pofs);
		if (sel_start.line+1 < sel_end.line) {
			te->delete_lines(sel_start.line+1, sel_end.line-sel_start.line-1);
		}
		te->concat_lines(sel_start.line);
	}
	te->unindent(cpos.line, cpos.pofs, apos.pofs-cpos.pofs);

	te->goto_line(apos.line);
	te->cursor_pput(apos.pofs);
	te->select_clear();

	te->goto_line(bpos.line);
	te->cursor_pput(bpos.pofs);
}

/*
 *	CLASS ht_undo_data_insert_block
 */

ht_undo_data_insert_block::ht_undo_data_insert_block(text_viewer_pos *Apos, text_viewer_pos *Bpos, void *Block, uint Size)
{
	apos = *Apos;
	bpos = *Bpos;
	sel_start.line = sel_end.line = 0;
	sel_start.pofs = sel_end.pofs = 0;
	size = Size;
	block = malloc(size);
	memcpy(block, Block, size);
}

ht_undo_data_insert_block::~ht_undo_data_insert_block()
{
	free(block);
}

uint ht_undo_data_insert_block::getsize()
{
	return (sizeof *this)+size;
}

void ht_undo_data_insert_block::gettext(char *text, uint maxlen)
{
	ht_snprintf(text, maxlen, "insert block ...");
}

ObjectID ht_undo_data_insert_block::getObjectID() const
{
	return ATOM_HT_UNDO_DATA_INSERT_BLOCK;
}

void ht_undo_data_insert_block::apply(ht_text_editor *te)
{
	cpos = insert_text_block(te, apos, bpos, block, size);
	if (text_viewer_pos_compare(&sel_start, &sel_end) == 0) {
		te->get_selection(&sel_start, &sel_end);
	}
}

void ht_undo_data_insert_block::unapply(ht_text_editor *te, bool *goto_only)
{
	if (*goto_only && (bpos.line != te->top_line + te->cursory || te->physical_cursorx()!=bpos.pofs)) {
		te->goto_line(apos.line);
		te->cursor_pput(apos.pofs);
		te->goto_line(bpos.line);
		te->cursor_pput(bpos.pofs);
		return;
	}
	*goto_only = false;
	delete_text_block(te, bpos, apos, cpos, sel_start, sel_end, false, NULL, NULL);
}

/*
 *	CLASS ht_undo_data_delete_block
 */

ht_undo_data_delete_block::ht_undo_data_delete_block(text_viewer_pos *Apos, text_viewer_pos *Bpos, text_viewer_pos *Sel_start, text_viewer_pos *Sel_end)
{
	apos = *Apos;
	bpos = *Bpos;
	sel_start = *Sel_start;
	sel_end = *Sel_end;
	size = 0;
	block = NULL;
}

ht_undo_data_delete_block::~ht_undo_data_delete_block()
{
	free(block);
}

uint ht_undo_data_delete_block::getsize()
{
	return (sizeof *this)+size;
}

void ht_undo_data_delete_block::gettext(char *text, uint maxlen)
{
	// FIXME
	ht_snprintf(text, maxlen, "delete block ...");
}

ObjectID ht_undo_data_delete_block::getObjectID() const
{
	return ATOM_HT_UNDO_DATA_DELETE_BLOCK;
}

void ht_undo_data_delete_block::apply(ht_text_editor *te)
{
	free(block);
	delete_text_block(te, apos, bpos, apos, sel_start, sel_end, true, &block, &size);
}

void ht_undo_data_delete_block::unapply(ht_text_editor *te, bool *goto_only)
{
	if (*goto_only && (bpos.line != te->top_line + te->cursory || te->physical_cursorx()!=bpos.pofs)) {
		te->goto_line(sel_end.line);
		te->cursor_pput(sel_end.pofs);
		te->goto_line(bpos.line);
		te->cursor_pput(bpos.pofs);
		return;
	}
	*goto_only = false;
	insert_text_block(te, bpos, sel_end, block, size);
}

/*
 *	CLASS ht_text_editor_undo
 */
ht_text_editor_undo::ht_text_editor_undo(uint max_undo_size)
	: Array(true)
{
	size = 0;
	max_size = max_undo_size;
	clean_state = 0;
	goto_state = true;
	current_position = 0;
}

int ht_text_editor_undo::get_current_position()
{
	   return current_position;
}

void ht_text_editor_undo::insert_undo(ht_text_editor *tv, ht_undo_data *undo)
{
	if (undo) {
		if (current_position != (int)count()) {
			// remove all pending redo's
			uint test = count();
			for (uint i = current_position; i < test; i++) {
				ht_undo_data *u = (ht_undo_data*)get(findByIdx(current_position));
				size -= u->getsize();
				del(findByIdx(current_position));
			}
			assert(current_position == (int)count());
			// clean_state eventually becomes unreachable
			if (clean_state > current_position) {
				clean_state = -1;
			}
		}
		undo->apply(tv);
		uint gsize = undo->getsize();
		while (size + gsize > max_size) {
			if (clean_state > -1) clean_state--;
			if (isEmpty()) {
				size -= ((ht_undo_data*)get(findFirst()))->getsize();
				del(findFirst());
				if (current_position) current_position--;
			} else {
				delete undo;
				return;
			}
		}
		if (!isEmpty() && !is_clean()) {
			ht_undo_data *u = (ht_undo_data*)get(findLast());
			uint zsize = u->getsize();
			if (u->combine(undo)) {
				size -= zsize;
				size += u->getsize();
				delete undo;
				return;
			}
		}
		current_position++;
		insert(undo);
		size+=gsize;
	}
	goto_state = true;
}

void ht_text_editor_undo::mark_clean()
{
	clean_state = current_position;
	goto_state = true;
}

bool ht_text_editor_undo::is_clean()
{
	return clean_state == current_position;
}

bool ht_text_editor_undo::is_clean(int i)
{
	return clean_state == i;
}

void ht_text_editor_undo::redo(ht_text_editor *te)
{
	goto_state = true;
	if (current_position < (int)count()) {
		ht_undo_data *u = (ht_undo_data*)get(findByIdx(current_position));
		u->apply(te);
		current_position++;
	}
}

void ht_text_editor_undo::undo(ht_text_editor *te, bool place_cursor_first)
{
	if (current_position) {
		ht_undo_data *u = (ht_undo_data*)get(findByIdx(current_position-1));
		bool goto_state_test = place_cursor_first ? goto_state : false;
		u->unapply(te, &goto_state_test);
		if (!goto_state_test) {
			current_position--;
		}
		goto_state = !goto_state_test;
	}
}

/*
 *
 */
int text_viewer_pos_compare(text_viewer_pos *a, text_viewer_pos *b)
{
	if (a->line==b->line) {
		return a->pofs-b->pofs;
	}
	return a->line-b->line;
}

/*
 *	CLASS ht_text_viewer
 */

void ht_text_viewer::init(Bounds *b, bool own_t, ht_textfile *t, Container *l)
{
	ht_view::init(b, VO_OWNBUFFER | VO_SELECTABLE | VO_RESIZE, "text viewer");
	VIEW_DEBUG_NAME("ht_text_viewer");

	growmode = MK_GM(GMH_FIT, GMV_FIT);

	own_textfile = false;
	textfile = NULL;
	set_textfile(t, own_t);

	own_lexer = false;
	lexer = NULL;
//	set_lexer(l, own_l);
	lexers = l;

	top_line = 0;
	xofs = 0;
	cursorx = 0;
	cursory = 0;
	select_clear();

	selectcursor = false;
	
	EOL_string = NULL;
	EOF_string = NULL;

	show_EOL = false;
	show_EOF = false;
	highlight_wrap = true;

	last_search_request = NULL;

	config_changed();
}

void ht_text_viewer::done()
{
	delete last_search_request;

	if (own_textfile) delete textfile;

	if (own_lexer && lexer) {
		lexer->done();
		delete lexer;
	}

	free(EOL_string);
	free(EOF_string);

	ht_view::done();
}

uint ht_text_viewer::char_vsize(char c, uint x)
{
	if (c=='\t') return tab_size - x % tab_size;
	return 1;
}

void ht_text_viewer::clipboard_copy_cmd()
{
	if (text_viewer_pos_compare(&sel_start, &sel_end)<0) {
		FileOfs s, e;
		if (textfile->convert_line2ofs(sel_start.line, sel_start.pofs, &s)
		   && textfile->convert_line2ofs(sel_end.line, sel_end.pofs, &e)) {
			char dsc[1024];
			String fn;
			ht_snprintf(dsc, sizeof dsc, "%y::%s", &textfile->getDesc(fn), desc);
			clipboard_copy(dsc, textfile, s, e-s);
		}
	}
}

void ht_text_viewer::config_changed()
{
	free(EOL_string);
	free(EOF_string);
	EOL_string = get_config_string("editor/EOL");
	EOF_string = get_config_string("editor/EOF");
	tab_size = get_config_dword("editor/tab size");
	tab_size = MIN(MAX(tab_size, 1), 16);

	if (lexer) lexer->config_changed();
	ht_view::config_changed();
}

bool ht_text_viewer::continue_search()
{
	if (last_search_request) {
		ht_search_result *r = NULL;
		FileOfs o, no;
		text_viewer_pos cursor;
		get_cursor_pos(&cursor);
		o = 0;
		pos_to_offset(&cursor, &o);
		no = o+1;
		try {
			if (last_search_request->search_class == SC_PHYSICAL) {
				text_search_pos start, end;
				start.offset = no;
				end.offset = last_search_end_ofs;
				r = search(last_search_request, &start, &end);
			}
		} catch (const Exception &e) {
			errorbox("error: %y", &e);
		}
		
		if (r) return show_search_result(r);
	}
	return false;
}

uint ht_text_viewer::cursor_up(uint n)
{
	if (cursory>n) cursory-=n; else {
		n=scroll_up(n-cursory);
		cursory=0;
	}
	return n;
}

uint ht_text_viewer::cursor_down(uint n)
{
	uint lmh=textfile->linecount()-top_line;
	if (lmh>(uint)size.h) lmh=size.h;
	if (cursory+n>lmh-1) {
		uint k = scroll_down(cursory+n-(lmh-1));
		lmh = textfile->linecount()-top_line;
		if (lmh>(uint)size.h) lmh = size.h;
		n = k+(lmh-1)-cursory;
		cursory = lmh-1;
	} else cursory+=n;
	return n;
}

uint ht_text_viewer::cursor_left(uint n)
{
	uint p;
	if (cursorx+xofs>n) p=cursorx+xofs-n; else p=0;
	cursor_vput(p);
	return 1;
}

uint ht_text_viewer::cursor_right(uint n)
{
	cursor_vput(cursorx+xofs+n);
	return 1;
}

void ht_text_viewer::cursor_home()
{
	cursor_vput(0);
}

void ht_text_viewer::cursor_end()
{
	cursor_vput(get_line_vlength(top_line+cursory));
}

void ht_text_viewer::cursor_pput(uint dx)
{
	uint vx = 0, px = 0;
	char line[1024];
	char *linep=line;

	uint linelen;
	if (!textfile->getline(top_line+cursory, 0, line, sizeof line, &linelen, NULL)) return;

	while (linelen--) {
		if (px==dx) break;
		int k = char_vsize(*(linep++), vx);
		vx += k;
		px++;
	}
	vx += dx-px;
	if (xofs > vx) {
		cursorx = 0;
		xofs = vx;
	} else {
		cursorx = vx-xofs;
		if (cursorx > (uint)size.w-1) {
			xofs += cursorx-(size.w-1);
			cursorx = size.w-1;
		}
	}
}

void ht_text_viewer::cursor_set(text_viewer_pos *pos)
{
	goto_line(pos->line);
	cursor_pput(pos->pofs);
}

void ht_text_viewer::cursor_vput(uint vx)
{
	if ((vx>=xofs) && (vx(uint)size.w-1) {
		xofs=vx-(size.w-1);
		cursorx=size.w-1;
	} else {
		xofs=0;
		cursorx=vx;
	}
}

void ht_text_viewer::draw()
{
//#define TIME_DRAW
#ifdef TIME_DRAW
	timer_handle h=new_timer();
	start_timer(h);
#endif /* TIME_DRAW */
	if (!textfile) return;

	vcp bgcolor = get_bgcolor();
	vcp metacolor = lexer ? lexer->getcolor_syntax(palidx_syntax_meta) :
			VCP(VCP_BACKGROUND(bgcolor), VCP_BACKGROUND(bgcolor));
	bool drawmeta = (lexer != NULL);
	clear(bgcolor);
	char line[1024];
	text_viewer_pos pos;
	pos.line = top_line;
	int y;
	for (y=0; y < size.h; y++) {
		lexer_state state;

		pos.pofs = 0;

//FIXME:debug:		if (!textfile->getline((top_line+y)|0x80000000, line, sizeof line, &state)) break;
		uint linelen;
		if (!textfile->getline(top_line+y, 0, line, sizeof line, &linelen, &state)) break;
		line[linelen] = 0;

		uint x=0;
		if (lexer) {
			char *linep=(char*)line;
			uint toklen;
			lexer_token tok;
			bool start_of_line=true;
			text_pos p;
			p.line=pos.line;
			p.pofs=pos.pofs;
			int prev_linelen = -1;
			while ((tok = lexer->gettoken(linep, linelen, p, start_of_line, &state, &toklen)) || (!*linep && (linelen>0))) {
				uint k, i;
				uint vtoklen=toklen;
				bool print=true;
				bool is_tab=((toklen==1) && (*linep=='\t'));
				vcp color=lexer->gettoken_color(tok);

				if (is_tab) vtoklen=tab_size-x%tab_size;

				if (x >= xofs) {
					k = x-xofs;
					i = 0;
					if (k > (uint)size.w-1) {
						break;
					}
				} else if (x+vtoklen >= xofs) {
					k=0;
					i=xofs-x;
				} else {
					print=false;
				}
				if (print) {
					if (is_tab) {
						char tab[17];
						uint z;
						for (z=0; z=xofs) {
					if (x-xofs>(uint)size.w-1) break;
					if (*linep=='\t') {
						vcp c=bgcolor;
						char tab[17];
						uint z;
						for (z=0; znprint(x-xofs, y, c, tab, z);
					} else {
						vcp c=bgcolor;
						render_str_color(&c, &pos);
						buf->printChar(x-xofs, y, c, *linep);
					}
				}
				x+=vtoklen;
				linep++;
				pos.pofs++;
			}
			if (drawmeta) render_meta(x-xofs, y, &pos, metacolor);
		}
		if (highlight_wrap && pos.line < sel_end.line
		 && pos.line >= sel_start.line) {
			int q = (drawmeta && show_EOL) ? strlen(EOL_string) : 0;
			int p = (x+q>xofs) ? x+q-xofs : 0;
			fill(p, y, size.w-p, 1, getcolor(palidx_generic_input_selected), ' ');
		}
		pos.line++;
	}
	if (focused) setcursor(cursorx, cursory, get_cursor_mode());

#ifdef TIME_DRAW
	stop_timer(h);
	int tix=get_timer_tick(h);
	delete_timer(h);
	buf_printf(40, 0, bgcolor, "%dtix", tix);
#endif /* TIME_DRAW */
}

const char *ht_text_viewer::func(uint i, bool execute)
{
	switch (i) {
		case 5: {
			if (execute) {
				sendmsg(cmd_text_viewer_goto);
			}
			return "goto";
		}
		case 7: {
			if (execute) {
				text_viewer_pos end_pos;
				uint search_caps = SEARCHMODE_BIN;
				ht_search_request *request = text_search_dialog(this, search_caps, &end_pos);
				ht_search_result *result = NULL;
				if (request) {
					text_search_pos start, end;
					text_viewer_pos cursor;
					get_cursor_pos(&cursor);
					pos_to_offset(&cursor, &start.offset);
					end.offset = 0xffffffff;
					result = search(request, &start, &end);
					if (result) {
						// FIXME: !!!!!!!!?
						if (!show_search_result(result)) infobox("couldn't display result (internal error)");
						delete result;
					} else infobox("not found");
				}
			}
			return "search";
		}
		default:
			return NULL;
	}
	return NULL;
}

vcp ht_text_viewer::get_bgcolor()
{
	return getcolor(palidx_generic_body);
}

void ht_text_viewer::get_cursor_pos(text_viewer_pos *cursor)
{
	cursor->pofs = physical_cursorx();
	cursor->line = top_line+cursory;
}

CursorMode ht_text_viewer::get_cursor_mode()
{
	return CURSOR_NORMAL;
}

ht_syntax_lexer *ht_text_viewer::get_lexer()
{
	return lexer;
}

/*
 * 0xffffffff --> ignore this line
 */
uint ht_text_viewer::get_line_indent(uint line)
{
	char s[1024];
	uint i, r, j;
	textfile->getline(line, 0, s, 1024, &i, NULL);     
	if (i==0) return 0xffffffff;
	j = r = 0;
	while (i && (s[j]==' ' || s[j]=='\t')) {
		r += char_vsize(s[j], r);
		j++;
		i--;
	}

	if (i==0) return 0xffffffff;
	
	return r;
}

uint ht_text_viewer::get_line_length(uint line)
{
	return textfile->getlinelength(line);
}

uint ht_text_viewer::get_line_vlength(uint line)
{
	char l[1024];
	char *linep=l;
	uint vl=0;

	uint linelen;
	if (!textfile->getline(line, 0, l, sizeof l, &linelen, NULL)) return 0;
	
	while (linelen--) vl+=char_vsize(*(linep++), vl);
	
	return vl;
}

int ht_text_viewer::get_pindicator_str(char *buf, int max_len)
{
	ht_syntax_lexer *l = get_lexer();
	const char *ln = l ? l->getname() : NULL;
	if (ln) {
		return ht_snprintf(buf, max_len, " %d:%d (%s) ", top_line+cursory+1, xofs+cursorx+1, ln);
	} else {
		return ht_snprintf(buf, max_len, " %d:%d ", top_line+cursory+1, xofs+cursorx+1);
	}
}

bool ht_text_viewer::get_vscrollbar_pos(int *pstart, int *psize)
{
	return (scrollbar_pos(top_line, size.h, textfile->linecount(), pstart, psize));
}

void ht_text_viewer::get_selection(text_viewer_pos *start, text_viewer_pos *end)
{
	*start = sel_start;
	*end = sel_end;
}

ht_textfile *ht_text_viewer::get_textfile()
{
	return textfile;
}

bool ht_text_viewer::get_hscrollbar_pos(int *pstart, int *psize)
{
	return false;
}

bool ht_text_viewer::goto_line(uint line)
{
	if (line >= textfile->linecount()) {
		return false;
	}
	if ((line >= top_line) && (line - top_line < (uint)size.h)) {
		cursory = line - top_line;
	} else {
		cursory = 0;
		if (line > top_line) {
			top_line = line;
			cursor_down(cursor_up(size.h));
		} else {
			top_line = line;
			cursor_up(cursor_down(size.h));
		}
	}
	return true;
}

void ht_text_viewer::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
		case msg_keypressed: {
			int k=msg->data1.integer;
			bool sel;
			switch (k) {
				case K_Meta_S:
					selectcursor=!selectcursor;
					clearmsg(msg);
					return;
				case K_Control_Shift_Right:
				case K_Control_Right: {
					sel=(k==K_Control_Shift_Right) != selectcursor;
					char line[1024];
					uint linelen;
					uint i=0;
					uint px=physical_cursorx();
					bool phase = true;
					while (1) {
						if (!textfile->getline(top_line+cursory+i, 0, line, sizeof line, &linelen, NULL)) return;
						if (!linelen) {
							phase = false;
						} else while (px < linelen) {
							if (phase ^ ((line[px]>='0' && line[px]<='9') || (line[px]>='A' && line[px]<='Z') || (line[px]>='a' && line[px]<='z') || line[px]=='_')) {
								phase = !phase;
								if (phase) {
									if (sel) select_start();
									goto_line(top_line+cursory+i);
									cursor_pput(px);
									if (sel) select_end();
									dirtyview();
									clearmsg(msg);
									return;
								}
							}
							px++;
						}
						phase = false;
						px = 0;
						i++;
					}
				}
				case K_Control_Shift_Left:
				case K_Control_Left: {
					sel=(k==K_Control_Shift_Left) != selectcursor;
					char line[1024];
					uint linelen;
					int i=top_line+cursory;
					uint px=physical_cursorx();
					bool phase = true;
					while (i >= 0) {
						if (!textfile->getline(i, 0, line, sizeof line, &linelen, NULL)) return;
						if (px > linelen) px = linelen;
						while (px > 0) {
							if (phase ^ !((line[px-1]>='0' && line[px-1]<='9') || (line[px-1]>='A' && line[px-1]<='Z') || (line[px-1]>='a' && line[px-1]<='z') || line[px-1]=='_')) {
								phase = !phase;
								if (phase) goto bloed3;
							}
							px--;
						}
						if (!px && !phase) goto bloed3;
						px = (uint)-1;
						i--;
					}
					return;
					bloed3:
					if (sel) select_start();
					goto_line(i);
					cursor_pput(px);
					if (sel) select_end();
					dirtyview();
					clearmsg(msg);
					return;
				}
				case K_Control_J:
					sendmsg(cmd_text_viewer_goto);
					clearmsg(msg);
					return;
				case K_Up:
				case K_Shift_Up:
					sel=(k==K_Shift_Up) != selectcursor;
					if (sel) select_start();
					cursor_up(1);
					if (sel) select_end();
					dirtyview();
					clearmsg(msg);
					return;
				case K_Down:
				case K_Shift_Down:
					sel=(k==K_Shift_Down) != selectcursor;
					if (sel) select_start();
					cursor_down(1);
					if (sel) select_end();
					dirtyview();
					clearmsg(msg);
					return;
				case K_Left:
				case K_Shift_Left:
					sel=(k==K_Shift_Left) != selectcursor;
					if (sel) select_start();
					cursor_left(1);
					if (sel) select_end();
					dirtyview();
					clearmsg(msg);
					return;
				case K_Right:
				case K_Shift_Right:
					sel=(k==K_Shift_Right) != selectcursor;
					if (sel) select_start();
					cursor_right(1);
					if (sel) select_end();
					dirtyview();
					clearmsg(msg);
					return;
				case K_PageUp:
				case K_Shift_PageUp:
					sel=(k==K_Shift_PageUp) != selectcursor;
					if (sel) select_start();
					scroll_up(size.h-1);
					if (sel) select_end();
					dirtyview();
					clearmsg(msg);
					return;
				case K_PageDown:
				case K_Shift_PageDown:
					sel=(k==K_Shift_PageDown) != selectcursor;
					if (sel) select_start();
					scroll_down(size.h-1);
					if (sel) select_end();
					dirtyview();
					clearmsg(msg);
					return;
				case K_Home:
				case K_Shift_Home:
					sel=(k==K_Shift_Home) != selectcursor;
					if (sel) select_start();
					cursor_home();
					if (sel) select_end();
					dirtyview();
					clearmsg(msg);
					return;
				case K_End:
				case K_Shift_End:
					sel=(k==K_Shift_End) != selectcursor;
					if (sel) select_start();
					cursor_end();
					if (sel) select_end();
					dirtyview();
					clearmsg(msg);
					return;
				case K_Control_PageUp:
					sel=selectcursor;
					if (sel) select_start();
					top_line=0;
					cursorx=0;
					cursory=0;
					if (sel) select_end();
					dirtyview();
					clearmsg(msg);
					return;
				case K_Control_PageDown:
					sel=selectcursor;
					if (sel) select_start();
					top_line=textfile->linecount()-1;
					cursory=0;
					cursor_pput(0);
					scroll_down(size.h-1);
					scroll_up(size.h-1);
					cursor_down(size.h-1);
					if (sel) select_end();
					dirtyview();
					clearmsg(msg);
					return;
				case K_Meta_C:
				case K_Control_Insert:
					sendmsg(cmd_edit_copy);
					clearmsg(msg);
					return;
				case K_Control_L:
				case K_Shift_F7:
					if (!continue_search()) infobox("no further matches");
					dirtyview();
					clearmsg(msg);
					return;
			}
			break;
		}
		case cmd_edit_copy: {
			clipboard_copy_cmd();
			clearmsg(msg);
			return;
		}
		case cmd_text_viewer_goto: {          
			char line[1024];
			line[0]=0;
			if (inputbox("goto", "line", line, 1024)) {
				eval_scalar r;
				if (eval(&r, line, NULL, NULL, NULL)) {
					eval_int i;
					scalar_context_int(&r, &i);
					if (!i.value || !goto_line(i.value - 1)) {
						errorbox("no such line: %qd!", i.value);
					}
				}
			}
			return;
		}
		case cmd_text_viewer_change_highlight: {
			popup_change_highlight();
			dirtyview();
			clearmsg(msg);
			return;
		}
		case msg_get_pindicator: {
			msg->data1.integer = get_pindicator_str((char*)msg->data2.ptr, msg->data1.integer);
			clearmsg(msg);
			return;
		}
		case msg_get_scrollinfo: {
			switch (msg->data1.integer) {
				case gsi_hscrollbar: {
					gsi_scrollbar_t *p=(gsi_scrollbar_t*)msg->data2.ptr;
					if (!get_hscrollbar_pos(&p->pstart, &p->psize)) {
						p->pstart = 0;
						p->psize = 100;
					}
					clearmsg(msg);
					return;
				}
				case gsi_vscrollbar: {
					gsi_scrollbar_t *p=(gsi_scrollbar_t*)msg->data2.ptr;
					if (!get_vscrollbar_pos(&p->pstart, &p->psize)) {
						p->pstart = 0;
						p->psize = 100;
					}
					clearmsg(msg);
					return;
				}
			}
			break;
		}
		case msg_funcexec:
			if (func(msg->data1.integer, 1)) {
				clearmsg(msg);
				return;
			}
			break;
		case msg_funcquery: {
			const char *s=func(msg->data1.integer, 0);
			if (s) {
				msg->msg=msg_retval;
				msg->data1.cstr=s;
			}
			break;
		}
	}
	ht_view::handlemsg(msg);
}

void ht_text_viewer::make_pos_physical(text_viewer_pos *p)
{
	uint l=textfile->getlinelength(p->line);
	if (p->pofs > l) p->pofs=l;
}

void ht_text_viewer::normalize_selection()
{
	if (text_viewer_pos_compare(&sel_end, &sel_start) <= 0) {
		sel_start.line = 0;
		sel_start.pofs = 0;
		sel_end.line = 0;
		sel_end.pofs = 0;
	}
}

uint ht_text_viewer::physical_cursorx()
{
	int vx=0, px=0, v=cursorx+xofs;
	char line[1024];
	char *linep=line;

	uint linelen;
	if (!textfile->getline(top_line+cursory, 0, line, sizeof line, &linelen, NULL)) return 0;
	
	while (linelen--) {
		int k=char_vsize(*(linep++), vx);
		vx+=k;
		v-=k;
		if (v<0) break;
		px++;
	}
	if (v>0) px+=v;
	
	return px;
}

void ht_text_viewer::popup_change_highlight()
{
	Bounds b, c;
	
	app->getbounds(&b);

	b.x = (b.w - 40) / 2,
	b.y = (b.h - 8) / 2;
	b.w = 40;
	b.h = 8;
	
	ht_dialog *d = new ht_dialog();
	d->init(&b, "change highlighting mode", FS_KILLER | FS_TITLE | FS_MOVE | FS_RESIZE);
	
	b.x = 0;
	b.y = 0;
		
	/* mode (input) */
	c = b;
	c.x = 0;
	c.y = 1;
	c.w = b.w-2-c.x;
	c.h = b.h-2-c.y;

	ht_itext_listbox *mode_input = new ht_itext_listbox();
	mode_input->init(&c);
	
	mode_input->insert_str(-1, "no highlighting");
	uint lc = lexers->count();
	int selected = -1;
	for (uint i=0; i < lc; i++) {
		ht_syntax_lexer *l = (ht_syntax_lexer*)(*lexers)[i];
		mode_input->insert_str(i, l->getname());
		if (lexer && (strcmp(lexer->getname(), l->getname()) == 0)) {
			selected = i+1;
		}
	}
	mode_input->update();
	if (selected >= 0) mode_input->gotoItemByPosition(selected);
	d->insert(mode_input);
	
	/* mode (text) */
	c = b;
	c.x = 0;
	c.y = 0;
	c.w = 30;
	c.h = 1;

	ht_label *mode_text = new ht_label();
	mode_text->init(&c, "choose ~highlighting mode", mode_input);

	d->insert(mode_text);
	
	if (d->run(false)) {
		ht_listbox_data type;

		ViewDataBuf vdb(mode_input, &type, sizeof type);

		ht_syntax_lexer *l = (ht_syntax_lexer*)(*lexers)[
			mode_input->getID(type.data->cursor_ptr)];
		set_lexer(l, false);
	}
	
	d->done();
	delete d;
}

bool ht_text_viewer::pos_to_offset(text_viewer_pos *pos, FileOfs *ofs)
{
	return textfile->convert_line2ofs(pos->line, pos->pofs, ofs);
}

int ht_text_viewer::ppos_str(char *buf, uint bufsize, text_viewer_pos *ppos)
{
	return ht_snprintf(buf, bufsize, "some pos");
}

void ht_text_viewer::render_meta(uint x, uint y, text_viewer_pos *pos, vcp color)
{
	text_viewer_pos p = *pos;
	render_str_color(&color, &p);
	if (pos->line == textfile->linecount()-1) {
		if (show_EOF && EOF_string) buf->print(x, y, color, EOF_string);
	} else {
		if (show_EOL && EOL_string) buf->print(x, y, color, EOL_string);
	}
}

void ht_text_viewer::render_str(int x, int y, vcp color, text_viewer_pos *pos, uint len, char *str, bool multi)
{
	if ((pos->line == sel_start.line || pos->line == sel_end.line)
	 && text_viewer_pos_compare(&sel_start, &sel_end) != 0) {
		text_viewer_pos p=*pos;
		vcp c;
		while (len--) {
			c = color;
			render_str_color(&c, &p);
			buf_lprint0(x++, y, c, 1, str);
			str++;
			if (multi) p.pofs++;
		}
	} else {
		render_str_color(&color, pos);
		buf_lprint0(x, y, color, len, str);
	}
}

int ht_text_viewer::buf_lprint0(int x, int y, int c, int l, char *text)
{
	while (l--) {
		char s = *text;
		if (!s) s = ' ';
		buf->printChar(x++, y, c, s);
		text++;
	}
	return l;
}

void ht_text_viewer::render_str_color(vcp *color, text_viewer_pos *pos)
{
	if (text_viewer_pos_compare(pos, &sel_start) >= 0
	 && text_viewer_pos_compare(pos, &sel_end) < 0) {
		vcp selcolor = getcolor(palidx_generic_input_selected);
		*color = VCP(*color, selcolor);
	}
}

void ht_text_viewer::resize(int rw, int rh)
{
	ht_view::resize(rw, rh);
	if ((int)cursorx > size.w-1) {
		xofs += (int)cursorx-(size.w-1);
		cursorx = size.w-1;
	}
	if ((int)cursory > size.h-1) {
		top_line += (int)cursory-(size.h-1);
		cursory = size.h-1;
	}
}

uint ht_text_viewer::scroll_up(uint n)
{
	if (top_line > n) top_line -= n; else {
		int q = top_line;
		top_line = 0;
		cursory = 0;
		return q;
	}
	return n;
}

uint ht_text_viewer::scroll_down(uint n)
{
	uint lc=textfile->linecount();
	if (top_line+n+size.h <= lc) {
		top_line += n;
	} else {
		if (lc-top_line >= (uint)size.h) {
			int q = top_line;
			top_line = lc-size.h;
			cursory = size.h-1;
			return top_line-q;
		}
		cursory = lc-top_line-1;
		return 0;
	}
	return n;
}

uint ht_text_viewer::scroll_left(uint n)
{
	if (xofs > n) xofs -= n; else xofs = 0;
	return n;
}

uint ht_text_viewer::scroll_right(uint n)
{
	xofs += n;
	return n;
}

ht_search_result *ht_text_viewer::search(ht_search_request *request, text_search_pos *s, text_search_pos *e)
{
	if (request != last_search_request) {
		delete last_search_request;
		last_search_request = request->clone();
	}
	last_search_end_ofs = e->offset;

	switch (request->search_class) {
		case SC_PHYSICAL: {
			FileOfs start = s->offset, end = e->offset;
			return linear_bin_search(request, start, end, textfile, 0, 0xffffffff);
		}
	}
	return NULL;
}

void ht_text_viewer::select_add(text_viewer_pos *s, text_viewer_pos *e)
{
	text_viewer_pos start=*s, end=*e;
	make_pos_physical(&start);
	make_pos_physical(&end);
	bool downward = true;
	if (text_viewer_pos_compare(&start, &end)>0) {
		text_viewer_pos temp=start;
		downward = false;
		start=end;
		end=temp;
	}

	if ((text_viewer_pos_compare(&end, &sel_end)==0) && !downward) {
		sel_end=start;
	} else if ((text_viewer_pos_compare(&start, &sel_end)==0) && downward) {
		sel_end=end;
	} else if ((text_viewer_pos_compare(&end, &sel_start)==0) && !downward) {
		sel_start=start;
	} else if ((text_viewer_pos_compare(&start, &sel_start)==0) && downward){
		sel_start=end;
	} else {
		sel_start=start;
		sel_end=end;
	}
	if (text_viewer_pos_compare(&sel_start, &sel_end)>0) {
		text_viewer_pos temp=sel_start;
		sel_start=sel_end;
		sel_end=temp;
	}
	normalize_selection();
}

void ht_text_viewer::select_clear()
{
	sel_start.line = 0;
	sel_start.pofs = 0;
	sel_end.line = 0;
	sel_end.pofs = 0;
}

void ht_text_viewer::select_set(text_viewer_pos *s, text_viewer_pos *e)
{
	sel_start = *s;
	sel_end = *e;
	normalize_selection();
}

void ht_text_viewer::select_start()
{
	selectmode = true;
	selectstart.line = top_line+cursory;
	selectstart.pofs = physical_cursorx();
}

void ht_text_viewer::select_end()
{
	text_viewer_pos p;
	selectmode = false;
	p.line = top_line+cursory;
	p.pofs = physical_cursorx();
	select_add(&selectstart, &p);
}

void ht_text_viewer::set_lexer(ht_syntax_lexer *l, bool own_l)
{
	if (own_lexer) {
		lexer->done();
		delete lexer;
	}
	// FIXME: is this "the right thing"?
	if (l) l->config_changed();
	lexer = l;
	own_lexer = own_l;
	textfile->set_lexer(l);
}

void ht_text_viewer::set_textfile(ht_textfile *t, bool own_t)
{
	if (own_textfile) delete textfile;
	textfile = t;
	own_textfile = own_t;
}

bool ht_text_viewer::show_search_result(ht_search_result *result)
{
	switch (result->search_class) {
	case SC_PHYSICAL: {
		ht_physical_search_result *r = (ht_physical_search_result*)result;
		text_viewer_pos start, end;
		textfile->convert_ofs2line(r->offset, &start.line, &start.pofs);
		textfile->convert_ofs2line(r->offset+r->size, &end.line, &end.pofs);
		select_set(&start, &end);
		cursor_set(&start);
	}
	}
	return true;
}

/*
 *	CLASS ht_text_editor
 */

void ht_text_editor::init(Bounds *b, bool own_t, ht_textfile *t, Container *l, uint e)
{
	ht_text_viewer::init(b, own_t, t, l);
	edit_options = e;
	if (edit_options & TEXTEDITOPT_UNDO) {
		undo_list = new ht_text_editor_undo(1024*1024);
	} else {
		undo_list = NULL;
	}
	overwrite_mode = false;

	show_EOL = true;
	show_EOF = true;
}

void ht_text_editor::done()
{
	delete undo_list;
	ht_text_viewer::done();
}

void ht_text_editor::clipboard_cut_cmd()
{
	clipboard_copy_cmd();
	clipboard_delete_cmd();
}

void ht_text_editor::clipboard_delete_cmd()
{
	if (sel_start.line || sel_start.pofs || sel_end.line || sel_end.pofs) {
		text_viewer_pos apos, bpos;
		uint px = physical_cursorx();
		apos.line = top_line+cursory;
		apos.pofs = px;
		bpos = sel_start;
		textoperation_apply(new ht_undo_data_delete_block(&apos, &bpos, &sel_start, &sel_end));
	}
}

void ht_text_editor::clipboard_paste_cmd()
{
	uint bsize = clipboard_getsize();
	void *block = malloc(bsize);
	clipboard_paste(block, bsize);

	text_viewer_pos apos, bpos;
	uint px = physical_cursorx();
	apos.line = bpos.line = top_line+cursory;
	apos.pofs = bpos.pofs = px;
	textoperation_apply(new ht_undo_data_insert_block(&apos, &bpos, block, bsize));
	free(block);
}

bool ht_text_editor::concat_lines(uint a)
{
	uint b = a+1;
	if (textfile->has_line(a) && textfile->has_line(b)) {
		uint alen = textfile->getlinelength(a);
		char *aline = ht_malloc(alen+1);
		uint alinelen;
		textfile->getline(a, 0, aline, alen+1, &alinelen, NULL);
	
		text_viewer_pos ss, se;

		ss=sel_start;
		se=sel_end;

		insert_chars(b, 0, aline, alinelen);

		free(aline);
	
		delete_lines(a, 1);

		if (b > ss.line) {
			if (b == se.line) {
				se.pofs += alen;
				se.line--;
			} else if (b < se.line) {
				se.line--;
			}
		} else {
			if (b == ss.line) {
				ss.pofs += alen;
			}
			ss.line--;
			se.line--;
		}

		sel_start = ss;
		sel_end = se;
		normalize_selection();
		return true;
	}
	return false;
}

void ht_text_editor::config_changed()
{
	auto_indent = get_config_dword("editor/auto indent");
	ht_text_viewer::config_changed();
}

void ht_text_editor::delete_chars(uint line, uint ofs, uint count)
{
	text_viewer_pos pos;
	pos.line=line;
	pos.pofs=ofs;
	if ((sel_end.line==pos.line) &&
	(text_viewer_pos_compare(&pos, &sel_start)>=0) &&
	(text_viewer_pos_compare(&pos, &sel_end)<0)) {
		sel_end.pofs-=count;
	} else if ((sel_start.line==pos.line) &&
	(text_viewer_pos_compare(&pos, &sel_start)<0)) {
		sel_start.pofs-=count;
		if (sel_end.line==pos.line) sel_end.pofs-=count;
	}
	textfile->delete_chars(line, ofs, count);
}

void ht_text_editor::delete_lines(uint line, uint count)
{
	if (sel_start.line+1>line) sel_start.line--;
	if (sel_end.line>line) sel_end.line--;
	normalize_selection();
	textfile->delete_lines(line, count);
}

const char *ht_text_editor::func(uint i, bool execute)
{
	switch (i) {
	case 2:
		if (execute) {
			String fn;
			if (!textfile->getFilename(fn).isEmpty()) {
				sendmsg(cmd_file_save);
			} else {
				app->sendmsg(cmd_file_saveas);
				bool dirty = true;
				FileOfs start = 0;
				FileOfs end = 0x7fffffff;
				textfile->cntl(FCNTL_MODS_IS_DIRTY, start, end, &dirty);
				if (undo_list && !dirty) {
					undo_list->mark_clean();
				}
			}
		}
		return "save";

	}
	return ht_text_viewer::func(i, execute);
}

vcp ht_text_editor::get_bgcolor()
{
	return getcolor(focused ? palidx_generic_input_focused :
			palidx_generic_input_unfocused);
}

CursorMode ht_text_editor::get_cursor_mode()
{
	return overwrite_mode ? CURSOR_BOLD : CURSOR_NORMAL;
}

int ht_text_editor::get_pindicator_str(char *buf, int max_len)
{
	ht_syntax_lexer *l = get_lexer();
	const char *ln = l ? l->getname() : NULL;
	bool dirty = true;
	textfile->cntl(FCNTL_MODS_IS_DIRTY, 0ULL, 0x7fffffffULL, &dirty);
	if (ln) {
		return ht_snprintf(buf, max_len, " %c%d:%d (%s) ", dirty ? '*' : ' ', top_line+cursory+1, xofs+cursorx+1, ln);
	} else {
		return ht_snprintf(buf, max_len, " %c%d:%d ", dirty ? '*' : ' ', top_line+cursory+1, xofs+cursorx+1);
	}
}

void ht_text_editor::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
		case msg_keypressed: {
			int k=msg->data1.integer;
			switch (k) {
				case K_Insert: {
					overwrite_mode = !overwrite_mode;
					dirtyview();
					clearmsg(msg);
					return;
				}
				case K_Return: {
					uint px=physical_cursorx();
					text_viewer_pos apos, bpos;
					apos.line = top_line+cursory;
					bpos.line = apos.line+1;
					apos.pofs = px;
					bpos.pofs = 0;
					if (auto_indent) {
						int i=0;
						bpos.pofs = 0xffffffff;
						while (bpos.pofs==0xffffffff && (apos.line-i) && (i<32)) {
							bpos.pofs = get_line_indent(apos.line-i);
							i++;
						}
						if (bpos.pofs == 0xffffffff) bpos.pofs = 0;
					}
					uint indent = bpos.pofs;
					if (px >= get_line_length(top_line+cursory)) indent = 0;
					textoperation_apply(new ht_undo_data_split_line(&apos, &bpos, indent));
					
					dirtyview();
					clearmsg(msg);
					return;
				}
				case K_Delete: {
					uint cx=physical_cursorx();
					if (cx < get_line_length(top_line+cursory)) {
						uint px=physical_cursorx();
						text_viewer_pos apos, bpos;
						char s[1024];
						apos.line = bpos.line = top_line+cursory;
						apos.pofs = px;
						bpos.pofs = px;
						uint i;
						textfile->getline(apos.line, 0, s, 1024, &i, NULL);
						textoperation_apply(new ht_undo_data_delete_string2(&apos, &bpos, &s[px], 1));
					} else if (textfile->has_line(top_line+cursory+1)) {
						uint px=physical_cursorx();
						text_viewer_pos apos, bpos;
						apos.line = top_line+cursory;
						apos.pofs = px;
						bpos.line = top_line+cursory;
						bpos.pofs = px;
						textoperation_apply(new ht_undo_data_join_line(&apos, &bpos));
					}
					dirtyview();
					clearmsg(msg);
					return;
				}
				case K_Backspace: {
					uint cx=physical_cursorx();
					if (cx) {
						if (cx <= textfile->getlinelength(top_line+cursory)) {
							uint px=physical_cursorx()-1;
							text_viewer_pos apos, bpos;
							char s[1024];
							apos.line = bpos.line = top_line+cursory;
							apos.pofs = cx;
							bpos.pofs = px;
							uint i;
							textfile->getline(apos.line, 0, s, 1024, &i, NULL);
							textoperation_apply(new ht_undo_data_delete_string(&apos, &bpos, &s[px], 1));
						} else {
							// place cursor only
							cursor_pput(cx-1);
						}               
					} else {
						if (top_line+cursory) {
							uint px=physical_cursorx();
							text_viewer_pos apos, bpos;
							apos.line = top_line+cursory;
							apos.pofs = px;
							bpos.line = apos.line-1;
							bpos.pofs = get_line_length(bpos.line);
							textoperation_apply(new ht_undo_data_join_line(&apos, &bpos));
						}
					}
					dirtyview();
					clearmsg(msg);
					return;
				}
				case K_Meta_U:
				case K_Meta_Backspace: {
					sendmsg(cmd_text_editor_undo);
					clearmsg(msg);
					return;
				}
				case K_Meta_R: {
					sendmsg(cmd_text_editor_redo);
					clearmsg(msg);
					return;
				}
				case K_Meta_V:
				case K_Shift_Insert:
					sendmsg(cmd_edit_paste);
					clearmsg(msg);
					return;
				case K_Meta_X:
				case K_Shift_Delete:
					sendmsg(cmd_edit_cut);
					clearmsg(msg);
					return;
				case K_Meta_D:
				case K_Control_Delete:
					sendmsg(cmd_edit_delete);
					clearmsg(msg);
					return;
				case K_Control_Y:
					sendmsg(cmd_text_editor_delete_line);
					clearmsg(msg);
					return;
				default: {
					int k=msg->data1.integer;
					if (((k>=' ') && (k<=255)) ||
					((k=='\t') && (edit_options & TEXTEDITOPT_INPUTTABS))) {
						char s=k;
						text_viewer_pos apos, bpos;
						uint px=physical_cursorx();
						apos.line = bpos.line = top_line+cursory;
						apos.pofs = px;
						bpos.pofs = px+1;
						if (overwrite_mode) {
							char old[1024];
							uint i, j=0;
							textfile->getline(apos.line, 0, old, 1024, &i, NULL);
							if (i>px) j = 1;
							textoperation_apply(new ht_undo_data_overwrite_string(&apos, &bpos, &s, 1, &old[px], j));
						} else {
							textoperation_apply(new ht_undo_data_insert_string(&apos, &bpos, &s, 1));
						}
						dirtyview();
						clearmsg(msg);
						return;
					}							
				}
			}
			break;
		}
		case msg_contextmenuquery: {
			ht_static_context_menu *m=new ht_static_context_menu();
			m->init("~Texteditor");
			if (undo_list) {
				char buf[30], buf2[20];
				// FIXME: implementme correctly/better
/*				if (undo_list->current_position) {
					((ht_undo_data*)undo_list->get(undo_list->current_position-1))->gettext(buf2, sizeof buf2);
				} else {
				}*/
				buf2[0] = 0;
				ht_snprintf(buf, sizeof buf, "~Undo %s", buf2);
			
				m->insert_entry(buf, "Alt+U", cmd_text_editor_undo, 0, 1);
				m->insert_entry("~Redo", "Alt+R", cmd_text_editor_redo, 0, 1);
				m->insert_entry("~Protocol", "Alt+P", cmd_text_editor_protocol, K_Meta_P, 1);
				m->insert_separator();
			}
			m->insert_entry("Change ~highlight", "", cmd_text_viewer_change_highlight, 0, 1);
			m->insert_separator();
			// FIXME: somewhat hacked
			m->insert_entry("~Delete line", "Control+Y", cmd_text_editor_delete_line, 0, 1);
			m->insert_separator();
			m->insert_entry("~Go to line", "", cmd_text_viewer_goto, 0, 1);
			msg->msg = msg_retval;
			msg->data1.ptr = m;
			return;
		}
		case cmd_edit_paste: {
			clipboard_paste_cmd();
			dirtyview();
			clearmsg(msg);
			return;
		}
		case cmd_edit_cut: {
			clipboard_cut_cmd();
			dirtyview();
			clearmsg(msg);
			return;
		}
		case cmd_edit_delete: {
			clipboard_delete_cmd();
			dirtyview();
			clearmsg(msg);
			return;
		}
		case cmd_file_save: {
			if (save()) clearmsg(msg);
			return;
		}
		case cmd_text_editor_undo: {
			undo(true);
			dirtyview();
			clearmsg(msg);
			return;
		}          
		case cmd_text_editor_redo: {
			redo();
			dirtyview();
			clearmsg(msg);
			return;
		}          
		case cmd_text_editor_protocol: {
			show_protocol();
			dirtyview();
			clearmsg(msg);
			return;
		}
		case cmd_text_editor_delete_line: {
			if (top_line+cursory <= textfile->linecount()-1) {
				text_viewer_pos apos, bpos, a, b;
				apos.line = top_line+cursory;
				apos.pofs = physical_cursorx();
				bpos.line = top_line+cursory;
				bpos.pofs = 0;
				a.line = top_line+cursory;
				a.pofs = 0;
				b = a;
				// if last line
				if (b.line+1 > textfile->linecount()-1) {
					b.pofs = textfile->getlinelength(b.line);
				} else {
					b.line++;
				}
				if ((a.line != b.line) || (a.pofs != b.pofs))
					textoperation_apply(new ht_undo_data_delete_block(&apos, &bpos, &a, &b));
			}
			dirtyview();
			clearmsg(msg);
			return;
		}
	}
	ht_text_viewer::handlemsg(msg);
}

void ht_text_editor::indent(uint line, uint start, uint size)
{
	char *w = ht_malloc(size);
	memset(w, ' ', size);
	textfile->insert_chars(line, start, w, size);
	free(w);
}

void ht_text_editor::unindent(uint line, uint start, uint size)
{
	textfile->delete_chars(line, start, size);
}

void ht_text_editor::insert_chars(uint line, uint ofs, void *chars, uint len)
{
	text_viewer_pos pos;
	pos.line=line;
	pos.pofs=ofs;
	if ((sel_end.line==pos.line) &&
	(text_viewer_pos_compare(&pos, &sel_start)>=0) &&
	(text_viewer_pos_compare(&pos, &sel_end)<0)) {
		sel_end.pofs+=len;
	} else if ((sel_start.line==pos.line) &&
	(text_viewer_pos_compare(&pos, &sel_start)<0)) {
		sel_start.pofs+=len;
		if (sel_end.line==pos.line) sel_end.pofs+=len;
	}
	textfile->insert_chars(line, ofs, chars, len);
}

void ht_text_editor::insert_lines(uint line, uint count)
{
	if (sel_start.line+1>line) sel_start.line++;
	if (sel_end.line>line) sel_end.line++;
	normalize_selection();
	textfile->insert_lines(line, count);
}

bool ht_text_editor::save()
{
//	asm(".byte 0xcc");
	String oldname;
	if (textfile->getFilename(oldname).isEmpty()) return false;
	dirtyview();

	TempFile temp(IOAM_READ | IOAM_WRITE);

	ht_ltextfile *old = dynamic_cast(textfile->getLayered());
	String blub;
	old->getDesc(blub);

	old->seek(0);
	old->copyAllTo(&temp);

	pstat_t st1, st2;
	old->pstat(st1);
	temp.pstat(st2);
	if (st1.size != st2.size) {
		errorbox("couldn't write backup file - file not saved. (o=%qd, t=%qd)", st1.size, st2.size);
		return false;
	}


	old->setAccessMode(IOAM_WRITE);
	
	File *f = old->getLayered();
	f->truncate(0);
	temp.seek(0);
	temp.copyAllTo(f);

	old->setAccessMode(IOAM_READ);
	old->reread();

//	textfile->set_layered_assume(old, true, true);

	if (undo_list) {
		undo_list->mark_clean();
	}
	return true;
}

void ht_text_editor::show_protocol()
{
	Bounds c, b;
	app->getbounds(&c);
	b.w=c.w*5/6;
	uint bh=b.h=c.h*5/6;
	b.x=(c.w-b.w)/2;
	b.y=(c.h-b.h)/2;
	ht_dialog *dialog;
	NEW_OBJECT(dialog, ht_dialog, &b, "protocol", FS_KILLER | FS_TITLE | FS_MOVE);
	b.assign(1, 0, b.w-4, 1);
	ht_statictext *text;
	NEW_OBJECT(text, ht_statictext, &b, " ", align_left);
	dialog->insert(text);
	b.y = 1;
	b.h = bh-5;
	ht_text_listbox *list;
	NEW_OBJECT(list, ht_text_listbox, &b, 2, 1);
	uint cp = undo_list->get_current_position();
	const char *od;
	if (undo_list->is_clean(0)) {
		od = "disk";
	} else {
		od = "    ";
	}
	list->insert_str(0, od, "--- initial state ---");
	for (uint i=0; icount(); i++) {
		char buf[1024];
		((ht_undo_data*)(*undo_list)[i])->gettext(buf, 1024);
		if (undo_list->is_clean(i+1)) {
			od = "disk";
		} else {
			od = "    ";
		}
		list->insert_str(i+1, od, buf);
	}
	list->update();
	list->gotoItemByPosition(cp);
	dialog->insert(list);
	if (dialog->run(false) == button_ok) {
		ht_listbox_data d;
		ViewDataBuf vdb(list, &d, sizeof d);
		int a = list->getID(d.data->cursor_ptr);
		int b = cp;

		if (a-b < 0) {
			for (int i=0; i < b-a; i++) {
				undo(false);
			}
		} else if (a-b > 0) {
			for (int i=0; i < a-b; i++) {
				redo();
			}
		}
	}
	dialog->done();
	delete dialog;
}

void ht_text_editor::split_line(uint a, uint pos)
{
	uint l=textfile->getlinelength(a);
	if (pos>l) pos=l;
	char *aline = ht_malloc(pos+1);
	uint alinelen;
	textfile->getline(a, 0, aline, pos+1, &alinelen, NULL);

	text_viewer_pos p, ss, se;
	p.line=a;
	p.pofs=pos;

	ss=sel_start;
	se=sel_end;

	insert_lines(a, 1);
	insert_chars(a, 0, aline, alinelen);

	delete_chars(a+1, 0, pos);
	free(aline);
	
	if (text_viewer_pos_compare(&p, &ss)>0) {
		if (text_viewer_pos_compare(&p, &se)<0) {
			if (se.line==p.line) {
				se.pofs-=pos;
			}
			se.line++;
		}
	} else {
		if (ss.line==p.line) {
			ss.pofs-=pos;
		}
		ss.line++;
		se.line++;
	}
	sel_start=ss;
	sel_end=se;
	normalize_selection();
}

void ht_text_editor::textoperation_apply(ht_undo_data *ud)
{
	if (undo_list) {
		undo_list->insert_undo(this, ud);
	} else {
		ud->apply(this);
		delete ud;
	}
}

void ht_text_editor::redo()
{
	if (undo_list) {
		undo_list->redo(this);
		if (undo_list->is_clean()) textfile->cntl(FCNTL_MODS_CLEAR_DIRTY_RANGE, 0ULL, 0ULL);
	}
}

void ht_text_editor::undo(bool place_cursor_first)
{
	if (undo_list) {
		undo_list->undo(this, place_cursor_first);
		if (undo_list->is_clean()) textfile->cntl(FCNTL_MODS_CLEAR_DIRTY_RANGE, 0ULL, 0ULL);
	}
}

ht-2.0.22/htelfphs.h0000644000175000001440000000156510206756707011134 00000000000000/* 
 *	HT Editor
 *	htelfphs.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTELFPHS_H__
#define __HTELFPHS_H__

#include "htobj.h"
#include "formats.h"

extern format_viewer_if htelfprogramheaders_if;

#endif /* !__HTELFPHS_H__ */

ht-2.0.22/data.h0000644000175000001440000010062310615344716010220 00000000000000/*
 *	HT Editor
 *	data.h
 *
 *	Copyright (C) 2002, 2003 Stefan Weyergraf (stefan@weyergraf.de)
 *	Copyright (C) 2002, 2003 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __DATA_H__
#define __DATA_H__

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "io/types.h"
#include 

typedef uint32 ObjectID;
typedef uint32 ID;

class ObjectStream;

struct BuildCtorArg {
};


template 
inline bool instanceOf(const T2 *o)
{
	return (dynamic_cast(o) != NULL);
} 

/*
 *	C style malloc support
 */

class HTMallocRes;
HTMallocRes ht_malloc(size_t);

class HTMallocRes
{
private:
	friend HTMallocRes ht_malloc(size_t);
	const size_t mSize;

	HTMallocRes(size_t size)
		: mSize(size)
	{
	}

	HTMallocRes operator=(const HTMallocRes &); // not implemented

public:
	template  operator T* () const
	{
		return static_cast(::malloc(mSize));
	}
};

inline HTMallocRes ht_malloc(size_t size)
{
	return HTMallocRes(size);
}


/**
 *	Macro for creating object build functions
 */
#define BUILDER(reg, obj, parent) Object *build_##obj(){BuildCtorArg a;return new obj(a);}
#define BUILDER2(reg, obj) Object *build_##obj(){BuildCtorArg a;return new obj(a);}

/**
 *	Registers builder function by object id.
 */
#define REGISTER(reg, obj) registerAtom(reg, (void*)build_##obj);

/**
 *	Unregisters builder function by object id.
 */
#define UNREGISTER(reg, obj) unregisterAtom(reg);

/* actually a str => bigendian-int */
/** used to define ObjectIDs */
#define MAGIC32(magic) (unsigned long)(((unsigned char)magic[0]<<24) | ((unsigned char)magic[1]<<16) | ((unsigned char)magic[2]<<8) | (unsigned char)magic[3])

/** No/invalid object */
#define OBJID_INVALID			((ObjectID)0)
/** A placeholder object id */
#define OBJID_TEMP			((ObjectID)-1)

#define OBJID_OBJECT			MAGIC32("DAT\x00")

#define OBJID_ARRAY			MAGIC32("DAT\x10")
#define OBJID_STACK			MAGIC32("DAT\x11")

#define OBJID_BINARY_TREE		MAGIC32("DAT\x20")
#define OBJID_AVL_TREE			MAGIC32("DAT\x21")
#define OBJID_SET			MAGIC32("DAT\x22")

#define OBJID_SLINKED_LIST		MAGIC32("DAT\x30")
#define OBJID_QUEUE			MAGIC32("DAT\x31")
#define OBJID_DLINKED_LIST		MAGIC32("DAT\x32")

#define OBJID_KEYVALUE			MAGIC32("DAT\x40")
#define OBJID_SINT			MAGIC32("DAT\x41")
#define OBJID_SINT64			MAGIC32("DAT\x42")
#define OBJID_UINT			MAGIC32("DAT\x43")
#define OBJID_UINT64			MAGIC32("DAT\x44")
#define OBJID_FLOAT			MAGIC32("DAT\x45")

#define OBJID_MEMAREA			MAGIC32("DAT\x48")

#define OBJID_STRING			MAGIC32("DAT\x50")
#define OBJID_ISTRING			MAGIC32("DAT\x51")

#define OBJID_AUTO_COMPARE		MAGIC32("DAT\xc0")

/**
 *	This is THE base class.
 */
class Object {
public:
				Object(BuildCtorArg&) {};
				Object() {};

	virtual			~Object() {};
		void		init() {};
	virtual	void		done() {};
/* new */

/**
 *	Standard object duplicator.
 *	@returns copy of object
 */
	virtual	Object *	clone() const;
/**
 *	Standard Object comparator.
 *	@param obj object to compare to
 *	@returns 0 for equality, negative number if |thisobj|
 */
	virtual	int		compareTo(const Object *obj) const;
/**
 *	Stringify object.
 *	Stringify object in string-buffer s. Never writes more than
 *	maxlen characters to s. If maxlen is > 0, a
 *	trailing zero-character is written.
 *
 *	@param buf pointer to buffer that receives object stringification
 *	@param buflen size of buffer that receives object stringification
 *	@returns number of characters written to s, not including the trailing zero
 */
	virtual	int		toString(char *buf, int buflen) const;
/**
 *	Standard Object idle function.
 *	Overwrite and register with htidle.cc::register_idle()
 *	(FIXME)
 *
 *	@returns true if working, false if really idle
 */
	virtual	bool		idle();
/**
 *	Load object from object stream.
 *
 *	@param s object stream to load this object from
 */
	virtual	void		load(ObjectStream &s);
/**
 *	@returns unique object id.
 */
	virtual	ObjectID	getObjectID() const;
/**
 *	stores object.
 *
 *	@param s object stream to store this object into
 */
	virtual	void		store(ObjectStream &s) const;
};

typedef int (*Comparator)(const Object *a, const Object *b);

int autoCompare(const Object *a, const Object *b);

typedef void* ObjHandle;
const ObjHandle invObjHandle = NULL;
const uint invIdx = ((uint)-1);

/**
 *	An Enumerator.
 */
class Enumerator: public Object {
public:
				Enumerator(BuildCtorArg&a): Object(a) {};
				Enumerator() {};
	/* extends Object */
	virtual Enumerator *	clone() const = 0;
	virtual	int		toString(char *buf, int buflen) const;
	/* new */

/**
 *	Count elements.
 *
 *	@returns number of objects contained in this structure
 *	@throws NotImplementedException if counting of elements is not supported
 */
	virtual	uint		count() const = 0;

/**
 *	Compare objects.
 *	Compare objects a and b and determine their (logical)
 *	linear order.
 *
 *	@param a object a
 *	@param b object b
 *	@returns 0 if a equals b,
 *	a value >0 if a is greater than b and
 *	a value <0 if a is less than b
 */
	virtual	int		compareObjects(const Object *a, const Object *b) const = 0;
/**
 *	Test if contained.
 *	Test if an object like obj is contained in this structure
 *
 *	@param obj signature of object to find
 *	@returns true if an object like obj is contained, false otherwise
 */
	inline	bool		contains(const Object *obj) const
	{
		return find(obj) != invObjHandle;
	}
/**
 *	Test if empty.
 *	@returns true if empty
 */
	inline bool		isEmpty() const
	{
		return count() == 0;
	}
/**
 *	Find equal object.
 *	Find first object equaling obj in this structure
 *	and if found return it's object handle.
 *
 *	@param obj signature of object to find
 *	@returns object handle of found object or invObjHandle if not found
 */
	virtual	ObjHandle	find(const Object *obj) const;
/**
 *	Find greater-or-equal object.
 *	Find lowest object being greater or equal compared to obj in this structure
 *	and if found return it's object handle. (lowest, greater and equal are
 *	defined via the compareTo method)
 *
 *	@param obj signature of object to find
 *	@returns object handle of found object or invObjHandle if not found
 */
	virtual	ObjHandle	findGE(const Object *obj) const;
/**
 *	Find greater object.
 *	Find lowest object being greater compared to obj in this structure
 *	and if found return it's object handle. (lowest and greater are
 *	defined via the compareTo method)
 *
 *	@param obj signature of object to find
 *	@returns object handle of found object or invObjHandle if not found
 */
	virtual	ObjHandle	findG(const Object *obj) const;
/**
 *	Find lower-or-equal object.
 *	Find greatest object being lower or equal compared to obj in this structure
 *	and if found return it's object handle. (greatest, lower and equal are
 *	defined via the compareTo method)
 *
 *	@param obj signature of object to find
 *	@returns object handle of found object or invObjHandle if not found
 */
	virtual	ObjHandle	findLE(const Object *obj) const;
/**
 *	Find lower object.
 *	Find greatest object being lower compared to obj in this structure
 *	and if found return it's object handle. (greatest and lower are
 *	defined via the compareTo method)
 *
 *	@param obj signature of object to find
 *	@returns object handle of found object or invObjHandle if not found
 */
	virtual	ObjHandle	findL(const Object *obj) const;
/**
 *	Find object's handle by index.
 *
 *	@param i index of object to find
 *	@returns object handle of found object or invObjHandle if not found
 */	
	virtual	ObjHandle	findByIdx(int i) const = 0;
/**
 *	Find (logically) last element's object handle.
 *
 *	@returns object handle of the last element or invObjHandle
 *	if the structure is empty
 */
	virtual	ObjHandle	findLast() const = 0;
/**
 *	Find (logically) previous element's object handle.
 *	Find logically previous element (predecessor) of the object identified
 *	by h. Predecessor of "the invalid object" is the last element
 *	in this structure by definition. (ie. findPrev(invObjHandle) :=
 *	findLast()).
 *
 *	@param h object handle to find a predecessor to
 *	@returns object handle of predecessor or invObjHandle if h
 *	identifies the first element.
 */
	virtual	ObjHandle	findPrev(ObjHandle h) const = 0;
/**
 *	Find (logically) first element's object handle.
 *
 *	@returns object handle of the first element or invObjHandle
 *	if this structure is empty
 */
	virtual	ObjHandle	findFirst() const = 0;
/**
 *	Find (logically) next element's object handle.
 *	Find logically next element (successor) of the object, identified
 *	by h. Successor of "the invalid object" is the first element
 *	in this structure by definition. (ie. findNext(invObjHandle) :=
 *	findFirst()).
 *
 *	@param h object handle to find a successor to
 *	@returns object handle of successor or invObjHandle if h
 *	identifies the last element.
 */
	virtual	ObjHandle	findNext(ObjHandle h) const = 0;
/**
 *	Get object pointer from object handle.
 *
 *	@param h object handle
 *	@returns object pointer if h is valid, NULL otherwise
 */
	virtual	Object *	get(ObjHandle h) const = 0;
/**
 *	Get object's index from its handle.
 *
 *	@param h object handle of object
 *	@returns index of object if h is valid, InvIdx otherwise.
 */
	virtual	uint		getObjIdx(ObjHandle h) const = 0;
/**
 *	Get element by index.
 *	Get the element with index idx (if possible).
 *
 *	@param idx index of element to get
 *	@returns pointer to the requested element or NULL if idx
 *	is invalid.
 */
		Object *	operator [] (int idx) const
		{
			return get(findByIdx(idx));
		}
};

#define foreach(XTYPE, X, E, code...)\
for (ObjHandle temp0815 = (E).findFirst(); temp0815 != invObjHandle;) {\
	XTYPE *X = (XTYPE*)(E).get(temp0815);                          \
	temp0815 = (E).findNext(temp0815);                             \
	{code;}                                                        \
}

#define foreachbwd(XTYPE, X, E, code...)\
for (ObjHandle temp0815 = (E).findLast(); temp0815 != invObjHandle;) {\
	XTYPE *X = (XTYPE*)(E).get(temp0815);                         \
	temp0815 = (E).findPrev(temp0815);                            \
	{code;}                                                       \
}

#define firstThat(XTYPE, X, E, condition) \
{                                         \
	XTYPE *Y = NULL;                  \
	foreach(XTYPE, X, E,              \
		if (condition) {          \
			Y = X;            \
			break;            \
		}                         \
	)                                 \
	X = Y;                            \
}

#define lastThat(XTYPE, X, E, condition)  \
{                                         \
	XTYPE *Y = NULL;                  \
	foreachbwd(XTYPE, X, E,           \
		if (condition) {          \
			Y = X;            \
			break;            \
		}                         \
	)                                 \
	X = Y;                            \
}

/**
 *	A Container.
 */
class Container: public Enumerator {
protected:
	ObjectID	hom_objid;

	virtual	void		notifyInsertOrSet(const Object *o);
public:
				Container(BuildCtorArg&a): Enumerator(a) {};
				Container();
				
	/* extends Enumerator */
	virtual Container *	clone() const = 0;

	/* new */
/**
 *	Delete all objects. (ie. remove and free all objects)
 */
	virtual	void		delAll() = 0;
/**
 *	Delete object.
 *	Delete (ie. remove and free) first object like sig in
 *	this structure (if possible).
 *
 *	@param sig signature of object to delete (may be inserted in the structure)
 *	@returns true if an object has been deleted, false otherwise
 */
	virtual	bool		delObj(Object *sig);
/**
 *	Delete object.
 *	Delete (ie. remove and free) object identified by h.
 *
 *	@param h object handle of the object to delete
 *	@returns true if the object has been deleted, false otherwise
 */
	virtual	bool		del(ObjHandle h) = 0;
/**
 *	Find or insert object.
 *	Find first object like obj and if that fails, insert obj.
 *	Ie. after call of this function it is guaranteed that contains(obj).
 *
 *	@param obj object to find similar one to or object to insert
 *	@param inserted indicates if obj has been inserted
 *	@returns object handle of existing or inserted object (never invObjHandle)
 */
	virtual	ObjHandle	findOrInsert(Object *obj, bool &inserted);
/**
 *	Insert object.
 *	Insert obj
 *
 *	@param obj object to insert
 *	@returns object handle of inserted object (never invObjHandle)
 */
	virtual	ObjHandle	insert(Object *obj) = 0;
/**
 *	Remove object.
 *	Remove first object like sig from this structure.
 *	Returned object must be freed explicitly.
 *
 *	@param sig signature of object to remove
 *	@returns removed object
 */
	virtual	Object *	removeObj(const Object *sig);
/**
 *	Remove object.
 *	Remove object identified by h.
 *	Returned object must be freed explicitly.
 *
 *	@param h object handle of object to remove
 *	@returns removed object
 */
	virtual	Object *	remove(ObjHandle h) = 0;
/**
 *	Insert object. (operator-form)
 */
	inline	ObjHandle	operator += (Object *obj) { return insert(obj); }
/**
 *	Delete object. (operator-form)
 */
	inline	bool		operator -= (ObjHandle h) { return del(h); }
/**
 *	Delete object. (operator-form)
 */
	inline	bool		operator -= (Object *sig) { return (*this -= find(sig)); }
/**
 *	Delete object by index.
 *
 *	@param idx index of object to delete
 *	@returns true if the object has been deleted, false otherwise
 */
	inline	bool		operator -= (int idx) { return (*this -= findByIdx(idx)); }
};

/**
 *   An abstract list
 */
class List: public Container {
public:
				List(BuildCtorArg&a): Container(a) {};
				List() {};
	/* extends Enumerator */
	virtual List *		clone() const = 0;
	
	/* new */

/**
 *	Insert object at position.
 *	Insert object obj at the position specified by h.
 *	if h does not specify a valid object handle (eg. invObjHandle),
 *	this function works like insert(obj).
 *
 *	@param h position to insert object at
 *	@param obj pointer to object to insert
 *	@returns true on success, false otherwise
 */
	virtual	void		insertAt(ObjHandle h, Object *obj) = 0;
/**
 *	Move element.
 *	Move element from position from to position to.
 *
 *	@param from position of element to move
 *	@param to position to move element to
 *	@returns true on success, false otherwise
 */
	virtual	bool		moveTo(ObjHandle from, ObjHandle to) = 0;
/**
 *	Prepend object.
 *	Prepend object obj.
 *
 *	@param obj pointer to object to prepend
 *	@returns object handle of inserted object (never invObjHandle)
 */
	inline	ObjHandle	prepend(Object *obj)
	{
		insertAt(findFirst(), obj);
		return findFirst();
	}
/**
 *	Set element.
 *	Replace element at position h with object obj
 *	and delete replaced object.
 *
 *	@param h object handle of element to replace
 *	@param obj object to replace element
 *	@returns true on success, false otherwise
 */
	virtual	bool		set(ObjHandle h, Object *obj) = 0;
/**
 *	Force: Set element by index.
 *	Set element at index i to object obj
 *	and delete object previously located at this index if the index is valid.
 *	If the index i does not specify a valid list-index,
 *	the list is extended, so that obj will be the last element
 *	and the newly created entries in the list will be NULLs.
 *
 *	@param i index at which to set
 *	@param obj object to set
 */
	virtual	void		forceSetByIdx(int idx, Object *obj) = 0;
/**
 *	Swap two element.
 *	Swap element at position h with element at position i.
 *
 *	@param h handle of one object
 *	@param i handle of the other object
 *	@returns true on success, false otherwise
 */
	virtual	bool		swap(ObjHandle h, ObjHandle i) = 0;
};

#define ARRAY_CONSTR_ALLOC_DEFAULT		4

/**
 *   An array
 */
class Array: public List {
private:
	bool own_objects;
	uint ecount;
	uint acount;
	Object **elems;

	virtual	int		calcNewBufferSize(int curbufsize, int min_newbufsize) const;
	virtual	void		checkShrink();
	virtual	void		freeObj(Object *obj);
		void		prepareWriteAccess(int i);
		void		realloc(int n);
	inline	bool		validHandle(ObjHandle h) const
	{
		return (handleToNative(h) < ecount);
	}
	inline	uint		handleToNative(ObjHandle h) const
	{
		return (Object**)h-elems;
	}
	inline	ObjHandle	nativeToHandle(int i) const
	{
		return elems+i;
	}
public:
				Array(BuildCtorArg &a): List(a) {};
				Array(bool own_objects, int prealloc = ARRAY_CONSTR_ALLOC_DEFAULT);
	virtual			~Array();
	/* extends Object */
	virtual	Array *		clone() const;
	virtual	void		load(ObjectStream &s);
	virtual	ObjectID	getObjectID() const;
	virtual	void		store(ObjectStream &s) const;
	/* extends Enumerator */
	virtual	uint		count() const
	{
		return ecount;
	}
	virtual	int		compareObjects(const Object *a, const Object *b) const;
	virtual	ObjHandle	findByIdx(int i) const;
	virtual	ObjHandle	findFirst() const;
	virtual	ObjHandle	findLast() const;
	virtual	ObjHandle	findNext(ObjHandle h) const;
	virtual	ObjHandle	findPrev(ObjHandle h) const;
	virtual	Object *	get(ObjHandle h) const;
	virtual	uint		getObjIdx(ObjHandle h) const;
	/* extends Container */
	virtual	void		delAll();
	virtual	bool		del(ObjHandle h);
	virtual	ObjHandle	insert(Object *obj);
	virtual	Object *	remove(ObjHandle h);
	/* extends List */
	virtual	void		forceSetByIdx(int idx, Object *obj);
	virtual	void		insertAt(ObjHandle h, Object *obj);
	virtual	bool		moveTo(ObjHandle from, ObjHandle to);
	virtual	bool		set(ObjHandle h, Object *obj);
	virtual	bool		swap(ObjHandle h, ObjHandle i);
	/* new */
/**
 *	Delete range of objects. (ie. remove and free all objects)
 *	@return number of objects deleted
 */
	virtual	int		delRange(int start, int end);

	inline void		insertBefore(int idx, Object *obj)
	{
		insertAt(findByIdx(idx), obj);
	}
};

/**
 *   A stack
 */
class Stack: public Array {
public:
				Stack(BuildCtorArg &a): Array(a) {};
				Stack(bool own_objects);
	/* new */
	virtual Object *	pop();
	virtual void		push(Object *obj);
	virtual	ObjectID	getObjectID() const;
};

/**
 *	SLinkedList's node structure
 */
struct SLinkedListNode {
	Object *obj;
	SLinkedListNode *next;
};

/**
 *	A (simply) linked list
 */
class SLinkedList: public List {
private:
	bool own_objects;
	uint ecount;
	SLinkedListNode *first, *last;

	virtual	SLinkedListNode *allocNode() const;
	virtual	void		deleteNode(SLinkedListNode *node) const;
	virtual	void		freeObj(Object *obj) const;
	inline	bool		validHandle(ObjHandle h) const;
	inline	SLinkedListNode *handleToNative(ObjHandle h) const;
	inline	ObjHandle	nativeToHandle(SLinkedListNode *n) const;
public:
				SLinkedList(BuildCtorArg&a): List(a) {};
				SLinkedList(bool own_objects);
	virtual			~SLinkedList();
	/* extends Object */
	virtual	SLinkedList *	clone() const;
	virtual	void		load(ObjectStream &s);
	virtual	ObjectID	getObjectID() const;
	virtual	void		store(ObjectStream &s) const;
	/* extends Enumerator */
	virtual	uint		count() const;
	virtual	int		compareObjects(const Object *a, const Object *b) const;
	virtual	ObjHandle	findByIdx(int i) const;
	virtual	ObjHandle	findFirst() const;
	virtual	ObjHandle	findLast() const;
	virtual	ObjHandle	findNext(ObjHandle h) const;
	virtual	ObjHandle	findPrev(ObjHandle h) const;
	virtual	Object *	get(ObjHandle h) const;
	virtual	uint		getObjIdx(ObjHandle h) const;
	/* extends Container */
	virtual	void		delAll();
	virtual	bool		del(ObjHandle h);
	virtual	ObjHandle	insert(Object *obj);
	virtual	Object *	remove(ObjHandle h);
	/* extends List */
	virtual	void		forceSetByIdx(int idx, Object *obj);
	virtual	void		insertAt(ObjHandle h, Object *obj);
	virtual	bool		moveTo(ObjHandle from, ObjHandle to);
	virtual	bool		set(ObjHandle h, Object *obj);
	virtual	bool		swap(ObjHandle h, ObjHandle i);
};

/**
 *   A queue
 */
class Queue: public SLinkedList {
public:
				Queue(BuildCtorArg&a): SLinkedList(a) {};
				Queue(bool own_objects);
/* new */

/**
 *	De-queue element.
 *	Remove and return next element of the queue.
 *
 *	@returns next element of the queue
 */
	inline	Object *	deQueue()
	{
		return remove(findFirst());
	}

/**
 *	En-queue element.
 *	Append element obj to the queue.
 *
 *	@param obj pointer to object to en-queue
 */
	inline	void		enQueue(Object *obj)
	{
		insert(obj);
	}

	virtual	ObjectID	getObjectID() const;
};

/**
 *	DLinkedList's node structure
 */
struct DLinkedListNode {
	Object *obj;
	DLinkedListNode *prev;
	DLinkedListNode *next;
};

/**
 *	A (doubly) linked list
 */
class DLinkedList: public List {
private:
	bool own_objects;
	uint ecount;
	DLinkedListNode *first, *last;

	virtual	DLinkedListNode *allocNode() const;
	virtual	void		deleteNode(DLinkedListNode *node) const;
	virtual	void		freeObj(Object *obj) const;
	inline	bool		validHandle(ObjHandle h) const;
	inline	DLinkedListNode *handleToNative(ObjHandle h) const;
	inline	ObjHandle	nativeToHandle(DLinkedListNode *n) const;
public:
				DLinkedList(BuildCtorArg&a): List(a) {};
				DLinkedList(bool own_objects);
	virtual			~DLinkedList();
	/* extends Object */
	virtual	DLinkedList *	clone() const;
	virtual	void		load(ObjectStream &s);
	virtual	ObjectID	getObjectID() const;
	virtual	void		store(ObjectStream &s) const;
	/* extends Enumerator */
	virtual	uint		count() const;
	virtual	int		compareObjects(const Object *a, const Object *b) const;
	virtual	ObjHandle	findByIdx(int i) const;
	virtual	ObjHandle	findFirst() const;
	virtual	ObjHandle	findLast() const;
	virtual	ObjHandle	findNext(ObjHandle h) const;
	virtual	ObjHandle	findPrev(ObjHandle h) const;
	virtual	Object *	get(ObjHandle h) const;
	virtual	uint		getObjIdx(ObjHandle h) const;
	/* extends Container */
	virtual	void		delAll();
	virtual	bool		del(ObjHandle h);
	virtual	ObjHandle	insert(Object *obj);
	virtual	Object *	remove(ObjHandle h);
	/* extends List */
	virtual	void		forceSetByIdx(int idx, Object *obj);
	virtual	void		insertAt(ObjHandle h, Object *obj);
	virtual	bool		moveTo(ObjHandle from, ObjHandle to);
	virtual	bool		set(ObjHandle h, Object *obj);
	virtual	bool		swap(ObjHandle h, ObjHandle i);
};

/**
 *   BinaryTree's node structure
 */
struct BinTreeNode {
	Object *key;
	BinTreeNode *left, *right;
	int unbalance;
};

/**
 *   A simple binary tree
 */
class BinaryTree: public Container {
protected:
	bool own_objects;
	uint ecount;
	BinTreeNode *root;
	Comparator compare;

		BinTreeNode *	allocNode() const;
		void		cloneR(BinTreeNode *node);
	virtual	void		deleteNode(BinTreeNode *node) const;
		BinTreeNode *	findNode(BinTreeNode *node, const Object *obj) const;
		BinTreeNode *	findNodeG(BinTreeNode *node, const Object *obj) const;
		BinTreeNode *	findNodeGE(BinTreeNode *node, const Object *obj) const;
		BinTreeNode *	findNodeL(BinTreeNode *node, const Object *obj) const;
		BinTreeNode *	findNodeLE(BinTreeNode *node, const Object *obj) const;
		BinTreeNode **	findNodePtr(BinTreeNode **nodeptr, const Object *obj) const;
		void		freeAll(BinTreeNode *n);
		void		freeObj(Object *obj) const;
		BinTreeNode *	getLeftmost(BinTreeNode *node) const;
		BinTreeNode *	getRightmost(BinTreeNode *node) const;
		BinTreeNode **	getLeftmostPtr(BinTreeNode **nodeptr) const;
		BinTreeNode **	getRightmostPtr(BinTreeNode **nodeptr) const;
		ObjHandle	findByIdxR(BinTreeNode *n, int &i) const;
		ObjHandle	insertR(BinTreeNode *&node, Object *obj);
		void 		loadR(ObjectStream &s, BinTreeNode **n, int l, int r);
		void 		storeR(ObjectStream &s, BinTreeNode *n) const;
	virtual	void		setNodeIdentity(BinTreeNode *node, BinTreeNode *newident);
	inline	bool		validHandle(ObjHandle h) const { return (h != invObjHandle); }
	inline	BinTreeNode *	handleToNative(ObjHandle h) const { return (BinTreeNode*)h; }
	inline	ObjHandle	nativeToHandle(BinTreeNode *n) const { return (ObjHandle*)n; }
public:
				BinaryTree(BuildCtorArg&a): Container(a) {};
				BinaryTree(bool own_objects, Comparator comparator = autoCompare);
	virtual			~BinaryTree();
	/* extends Object */
	virtual	BinaryTree *	clone() const;
	virtual	void		load(ObjectStream &s);
	virtual	ObjectID	getObjectID() const;
	virtual	void		store(ObjectStream &s) const;
	/* extends Enumerator */
	virtual	void		delAll();
	virtual	uint		count() const;
	virtual	int		compareObjects(const Object *a, const Object *b) const;
	virtual	ObjHandle	find(const Object *obj) const;
	virtual	ObjHandle	findG(const Object *obj) const;
	virtual	ObjHandle	findGE(const Object *obj) const;
	virtual	ObjHandle	findL(const Object *obj) const;
	virtual	ObjHandle	findLE(const Object *obj) const;
	virtual	ObjHandle	findByIdx(int i) const;
	virtual	ObjHandle	findFirst() const;
	virtual	ObjHandle	findLast() const;
	virtual	ObjHandle	findNext(ObjHandle h) const;
	virtual	ObjHandle	findPrev(ObjHandle h) const;
	virtual	Object *	get(ObjHandle h) const;
	virtual	uint		getObjIdx(ObjHandle h) const;
	/* extends Container */
	virtual	bool		del(ObjHandle h);
	virtual	ObjHandle	insert(Object *obj);
	virtual	Object *	remove(ObjHandle h);
};


/**
 *   A height-balanced binary tree (AVL)
 */
class AVLTree: public BinaryTree {
private:
		void		cloneR(BinTreeNode *node);
		BinTreeNode *	removeR(Object *key, BinTreeNode *&root, int &change, int cmp);
		int		loadR(ObjectStream &s, BinTreeNode *&n, int l, int r);
public:
				AVLTree(BuildCtorArg&a): BinaryTree(a) {};
				AVLTree(bool own_objects, Comparator comparator = autoCompare);

		void		debugOut();
		bool		expensiveCheck() const;
	/* extends Object */
	virtual	AVLTree *	clone() const;
	virtual	void		load(ObjectStream &s);
	virtual	ObjectID	getObjectID() const;
	/* extends Container */
	virtual	ObjHandle	insert(Object *obj);
	virtual	Object *	remove(ObjHandle h);
};

/**
 *   MRU Cache's node structure
 */
struct MRUCacheNode: public BinTreeNode {
	MRUCacheNode	*moreRU, *lessRU;
};

/**
 *   A most-recently-used (MRU) cache
 */
class MRUCache: public AVLTree {
private:
	MRUCacheNode *		mostRU;
	MRUCacheNode *		leastRU;

	virtual	MRUCacheNode *	allocNode() const;
		void		checkList() const;
	virtual	void		deleteNode(BinTreeNode *node) const;
	inline	MRUCacheNode *	handleToNative(ObjHandle h) const { return (MRUCacheNode*)h; }
	inline	ObjHandle	nativeToHandle(MRUCacheNode *n) const { return (ObjHandle)n; }
	virtual	void		setNodeIdentity(BinTreeNode *node, BinTreeNode *newident);
public:
				MRUCache(bool own_objects, Comparator comparator = autoCompare);

	/* extends Object */
	virtual	MRUCache *	clone() const;
	virtual	void		store(ObjectStream &s) const;
	/* extends Container */
	virtual	ObjHandle	insert(Object *obj);
	virtual	Object *	remove(ObjHandle h);
	/* extends AVLTree */
	virtual	void		delAll();
	/* new */
		void		propagate(ObjHandle h);
		ObjHandle	getLRU();
};

/**
 *	A finite set
 */
class Set: public AVLTree {
public:
				Set(BuildCtorArg&a):AVLTree(a) {};
				Set(bool own_objects);
	/* new */
			void	intersectWith(Set *b);
			void	unionWith(Set *b);
	inline	bool	operator &(Object *obj) const
	{
		return contains(obj);
	}

	virtual	ObjectID	getObjectID() const;
};

/*
 *	IntSet
 */

class IntSet: public Object {
protected:
	uint mMaxSetSize;	// in bits
	uint mSetSize;		// in bits
	byte *mSet;
	/* new */
	inline	uint	idx2ByteOfs(uint i) const;
	inline	uint	idx2BitMask(uint i) const;
		void	makeAccessible(uint i);
	inline	bool	isAccessible(uint i) const;
public:
			IntSet(uint aMaxSetSize);
	virtual		~IntSet();
	/* extends Object */
	virtual	IntSet *clone() const;
	virtual	int	compareTo(const Object *obj) const;
	virtual	int	toString(char *buf, int buflen) const;
	/* new */
		void	assign(const IntSet &from);
		bool	contains(uint i) const;
		void	del(uint i);
		void	delAll();
		bool	findFirst(uint &i, bool set) const;
		bool	findNext(uint &i, bool set) const;
		bool	findPrev(uint &i, bool set) const;
		void	insert(uint i);
};

/**
 *	Maintains a key-value pair for easy inserting objects with "simple" keys
 *	into Containers.
 *	Key and Value will be deleted in the destructor.
 */
class KeyValue: public Object {
public:
	Object		*mKey;
	Object		*mValue;

				KeyValue(BuildCtorArg&a): Object(a) {};
				KeyValue(Object *aKey, Object *aValue): mKey(aKey), mValue(aValue) {};
	virtual			~KeyValue();

	virtual	KeyValue *	clone() const;
	virtual	int		compareTo(const Object *obj) const;
	virtual	int		toString(char *buf, int buflen) const;
	virtual	void		load(ObjectStream &s);
	virtual	ObjectID	getObjectID() const;
	virtual	void		store(ObjectStream &s) const;
};

/**
 *	A signed Integer
 */
class SInt: public Object {
public:
	signed int value;

				SInt(BuildCtorArg&a): Object(a) {};
				SInt(signed int i): value(i) {};
	/* extends Object */
	virtual	SInt *		clone() const;
	virtual	int		compareTo(const Object *obj) const;
	virtual	int		toString(char *buf, int buflen) const;
	virtual	void		load(ObjectStream &s);
	virtual	ObjectID	getObjectID() const;
	virtual	void		store(ObjectStream &s) const;
};

typedef SInt Integer;

/**
 *	A signed Integer (64-bit)
 */
class SInt64: public Object {
public:
	sint64 value;

				SInt64(BuildCtorArg&a): Object(a) {};
				SInt64(sint64 i): value(i) {};
	/* extends Object */
	virtual	SInt64 *	clone() const;
	virtual	int		compareTo(const Object *obj) const;
	virtual	int		toString(char *buf, int buflen) const;
	virtual	void		load(ObjectStream &s);
	virtual	ObjectID	getObjectID() const;
	virtual	void		store(ObjectStream &s) const;
};

/**
 *	An unsigned Integer
 */
class UInt: public Object {
public:
	unsigned int value;

				UInt(BuildCtorArg&a): Object(a) {};
				UInt(unsigned int i): value(i) {};
	/* extends Object */
	virtual	UInt *		clone() const;
	virtual	int		compareTo(const Object *obj) const;
	virtual	int		toString(char *buf, int buflen) const;
	virtual	void		load(ObjectStream &s);
	virtual	ObjectID	getObjectID() const;
	virtual	void		store(ObjectStream &s) const;
};

/**
 *	An unsigned Integer (64-bit)
 */
class UInt64: public Object {
public:
	uint64 value;

				UInt64(BuildCtorArg&a): Object(a) {};
				UInt64(uint64 i): value(i) {};
	/* extends Object */
	virtual UInt64 *	clone() const;
	virtual	int		compareTo(const Object *obj) const;
	virtual	int		toString(char *buf, int buflen) const;
	virtual	void		load(ObjectStream &s);
	virtual	ObjectID	getObjectID() const;
	virtual	void		store(ObjectStream &s) const;
};

/**
 *	A floating-point number	(FIXME: no portable storage yet)
 */
class Float: public Object {
public:
	double value;

				Float(BuildCtorArg&a): Object(a) {};
				Float(double d): value(d) {};
	/* extends Object */
	virtual	Float *		clone() const;
	virtual	int		compareTo(const Object *obj) const;
	virtual	int		toString(char *buf, int buflen) const;
//	virtual	void		load(ObjectStream &s);
	virtual	ObjectID	getObjectID() const;
//	virtual	void		store(ObjectStream &s) const;
};

/**
 *	A pointer. Cannot be stored.
 */
class Pointer: public Object {
public:
	void *value;

	Pointer(void *p): value(p) {};
};

/**
 *	A memory area.
 */
class MemArea: public Object {
private:
	bool duplicate;
public:
	void *ptr;
	uint size;

				MemArea(BuildCtorArg&a): Object(a) {};
				MemArea(const void *p, uint size, bool duplicate = false);
				~MemArea();
	/* extends Object */
	virtual	MemArea *	clone() const;
	virtual	int		compareTo(const Object *obj) const;
	virtual	int		toString(char *buf, int buflen) const;
	virtual	void		load(ObjectStream &s);
	virtual	ObjectID	getObjectID() const;
	virtual	void		store(ObjectStream &s) const;
};

/*
 *	sorter
 */
bool quickSort(List &l);


/*
 *	char_set
 */

#define CS_SETSIZE 256

typedef struct char_set {
  unsigned char char_bits [((CS_SETSIZE) + 7) / 8];
} char_set;

#define CS_SET(n, p)    ((p)->char_bits[(n) / 8] |= (1 << ((n) & 7)))
#define CS_CLR(n, p)	((p)->char_bits[(n) / 8] &= ~(1 << ((n) & 7)))
#define CS_ISSET(n, p)	((p)->char_bits[(n) / 8] & (1 << ((n) & 7)))
#define CS_ZERO(p)	memset ((void *)(p), 0, sizeof (*(p)))

/*
 *
 */

#define BITMAP(a0, a1, a2, a3, a4, a5, a6, a7) (((a0)<<0) | ((a1)<<1) | ((a2)<<2) | ((a3)<<3) | ((a4)<<4) | ((a5)<<5) | ((a6)<<6) | ((a7)<<7))

#define BITBIT(bitmap, p) ((bitmap)>>(p)&1)

/*
 *	simple int hash
 */

struct int_hash {
	int value;
	const char *desc;
};

const char *matchhash(int value, int_hash *hash_table);

#include "stream.h"			// load/store need ObjectStream


/*
 *	Module Init/Done
 */

bool init_data();
void done_data();

#endif /* __DATA_H__ */
ht-2.0.22/ylwrap0000755000175000017500000001415411637714046010413 00000000000000#! /bin/sh
# ylwrap - wrapper for lex/yacc invocations.

scriptversion=2009-04-28.21; # UTC

# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005,
# 2007, 2009 Free Software Foundation, Inc.
#
# Written by Tom Tromey .
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.

# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.

# This file is maintained in Automake, please report
# bugs to  or send patches to
# .

case "$1" in
  '')
    echo "$0: No files given.  Try \`$0 --help' for more information." 1>&2
    exit 1
    ;;
  --basedir)
    basedir=$2
    shift 2
    ;;
  -h|--h*)
    cat <<\EOF
Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...

Wrapper for lex/yacc invocations, renaming files as desired.

  INPUT is the input file
  OUTPUT is one file PROG generates
  DESIRED is the file we actually want instead of OUTPUT
  PROGRAM is program to run
  ARGS are passed to PROG

Any number of OUTPUT,DESIRED pairs may be used.

Report bugs to .
EOF
    exit $?
    ;;
  -v|--v*)
    echo "ylwrap $scriptversion"
    exit $?
    ;;
esac


# The input.
input="$1"
shift
case "$input" in
  [\\/]* | ?:[\\/]*)
    # Absolute path; do nothing.
    ;;
  *)
    # Relative path.  Make it absolute.
    input="`pwd`/$input"
    ;;
esac

pairlist=
while test "$#" -ne 0; do
  if test "$1" = "--"; then
    shift
    break
  fi
  pairlist="$pairlist $1"
  shift
done

# The program to run.
prog="$1"
shift
# Make any relative path in $prog absolute.
case "$prog" in
  [\\/]* | ?:[\\/]*) ;;
  *[\\/]*) prog="`pwd`/$prog" ;;
esac

# FIXME: add hostname here for parallel makes that run commands on
# other machines.  But that might take us over the 14-char limit.
dirname=ylwrap$$
trap "cd '`pwd`'; rm -rf $dirname > /dev/null 2>&1" 1 2 3 15
mkdir $dirname || exit 1

cd $dirname

case $# in
  0) "$prog" "$input" ;;
  *) "$prog" "$@" "$input" ;;
esac
ret=$?

if test $ret -eq 0; then
  set X $pairlist
  shift
  first=yes
  # Since DOS filename conventions don't allow two dots,
  # the DOS version of Bison writes out y_tab.c instead of y.tab.c
  # and y_tab.h instead of y.tab.h. Test to see if this is the case.
  y_tab_nodot="no"
  if test -f y_tab.c || test -f y_tab.h; then
    y_tab_nodot="yes"
  fi

  # The directory holding the input.
  input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
  # Quote $INPUT_DIR so we can use it in a regexp.
  # FIXME: really we should care about more than `.' and `\'.
  input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'`

  while test "$#" -ne 0; do
    from="$1"
    # Handle y_tab.c and y_tab.h output by DOS
    if test $y_tab_nodot = "yes"; then
      if test $from = "y.tab.c"; then
    	from="y_tab.c"
      else
    	if test $from = "y.tab.h"; then
    	  from="y_tab.h"
    	fi
      fi
    fi
    if test -f "$from"; then
      # If $2 is an absolute path name, then just use that,
      # otherwise prepend `../'.
      case "$2" in
    	[\\/]* | ?:[\\/]*) target="$2";;
    	*) target="../$2";;
      esac

      # We do not want to overwrite a header file if it hasn't
      # changed.  This avoid useless recompilations.  However the
      # parser itself (the first file) should always be updated,
      # because it is the destination of the .y.c rule in the
      # Makefile.  Divert the output of all other files to a temporary
      # file so we can compare them to existing versions.
      if test $first = no; then
	realtarget="$target"
	target="tmp-`echo $target | sed s/.*[\\/]//g`"
      fi
      # Edit out `#line' or `#' directives.
      #
      # We don't want the resulting debug information to point at
      # an absolute srcdir; it is better for it to just mention the
      # .y file with no path.
      #
      # We want to use the real output file name, not yy.lex.c for
      # instance.
      #
      # We want the include guards to be adjusted too.
      FROM=`echo "$from" | sed \
            -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
            -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
      TARGET=`echo "$2" | sed \
            -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
            -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`

      sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
          -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?

      # Check whether header files must be updated.
      if test $first = no; then
	if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
	  echo "$2" is unchanged
	  rm -f "$target"
	else
          echo updating "$2"
          mv -f "$target" "$realtarget"
        fi
      fi
    else
      # A missing file is only an error for the first file.  This
      # is a blatant hack to let us support using "yacc -d".  If -d
      # is not specified, we don't want an error when the header
      # file is "missing".
      if test $first = yes; then
        ret=1
      fi
    fi
    shift
    shift
    first=no
  done
else
  ret=$?
fi

# Remove the directory.
cd ..
rm -rf $dirname

exit $ret

# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
ht-2.0.22/main.cc0000644000175000017500000002176412127651420010376 00000000000000/*
 *	HT Editor
 *	main.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include 
#include 
#include 

#include "analy_register.h"
#include "asm.h"
#include "htapp.h"
#include "atom.h"
#include "htcfg.h"
#include "htclipboard.h"
#include "display.h"
#include "except.h"
#include "hthist.h"
#include "htiobox.h"
#include "keyb.h"
#include "htidle.h"
#include "htmenu.h"
#include "htpal.h"
#include "htinfo.h"
#include "htreg.h"
#include "sys.h"
#include "snprintf.h"
#include "info/infoview.h"
#include "log.h"
#include "stddata.h"

const char *htcopyrights[]=
{
	ht_name" "ht_version" (%s) "__TIME__" on "__DATE__,
	ht_copyright1,
	ht_copyright2,
	NULL
};

static void add_file_history_entry(char *n)
{
	List *hist=(List*)getAtomValue(HISTATOM_FILE);
	if (hist) insert_history_entry(hist, n, 0);
}

typedef bool (*initfunc)();
typedef void (*donefunc)();

struct initdonefunc {
	initfunc i;
	donefunc d;
	const char *name;
};

#define INITDONE(name) { init_##name, done_##name, #name }

initdonefunc initdone[] = {
	INITDONE(system),
	INITDONE(atom),
	INITDONE(data),
	INITDONE(pal),
	INITDONE(registry),
	INITDONE(keyb),
	INITDONE(idle),
	INITDONE(menu),
	INITDONE(hist),
	INITDONE(clipboard),
	INITDONE(obj),
	INITDONE(analyser),
	INITDONE(asm),
	INITDONE(stddata),
	INITDONE(cfg),
	INITDONE(app)
};

int htstate;

static bool init()
{
	for (htstate=0; htstate<(int)(sizeof initdone / sizeof initdone[0]); htstate++) {
		if (!initdone[htstate].i()) return false;
	}
	return true;
}

static void done()
{
	for (htstate--; htstate>=0; htstate--) {
		initdone[htstate].d();
	}
}

static void load_file(char *fn, uint mode)
{
	char cfn[HT_NAME_MAX];
	char cwd[HT_NAME_MAX];

	cwd[0] = 0;
	getcwd(cwd, sizeof cwd);

	if (sys_common_canonicalize(cfn, sizeof cfn, fn, cwd, sys_is_path_delim)==0) {
		add_file_history_entry(cfn);
		((ht_app*)app)->create_window_file(cfn, mode, true);
	}
}

static void show_help()
{
	((ht_app*)app)->create_window_help(MAGIC_HT_HELP, "Top");
}

static void show_version()
{
	const char **copyrights = htcopyrights;
	while (*copyrights) {
		printf(*copyrights, sys_get_name());
		puts("");
		copyrights++;
	}
	exit(0);
}

static void params(int argc, char *argv[], bool started)
{
	int escaped_params_start = 0;
	// FIXME: FOM_AUTO should be the default
	int load_mode = FOM_BIN;
	bool showhelp = false;

#define PARAM_ERROR(a...) {if (started) LOG_EX(LOG_ERROR, a);}
#define EXPECT_PARAMEND(b) if ((j+1)!=len) { PARAM_ERROR("syntax error in options"); b;}
#define EXPECT_PARAMS(p, b) if (i+p+1 > argc) { PARAM_ERROR("syntax error in options"); b;}
#define NOTHING ((void)(0))
	for (int i = 1; i < argc; i++) {
		if (argv[i][0] == '-') {
			int len = strlen(argv[i]);
			if (len==1) PARAM_ERROR("unknown option: %s", argv[i]);
			if (argv[i][1] == '-') {
				if (len == 2) {
					// --
					escaped_params_start = i+1;
					break;
				}
				if (strcmp(argv[i], "--auto") == 0) {
					EXPECT_PARAMS(1, NOTHING) else {
						if (started) load_file(argv[i+1], FOM_AUTO);
						i++;
					}
				} else
				if (strcmp(argv[i], "--bin") == 0) {
					EXPECT_PARAMS(1, NOTHING) else {
						if (started) load_file(argv[i+1], FOM_BIN);
						i++;
					}
				} else
				if (strcmp(argv[i], "--help") == 0) {
					showhelp = true;
				} else
				if (strcmp(argv[i], "--project") == 0) {
					EXPECT_PARAMS(1, NOTHING) else {
						if (started) ((ht_app*)app)->project_opencreate(argv[i+1]);
						i++;
					}
				} else
				if (strcmp(argv[i], "--text") == 0) {
					EXPECT_PARAMS(1, NOTHING) else {
						if (started) load_file(argv[i+1], FOM_TEXT);
						i++;
					}
				} else
				if (strcmp(argv[i], "--version") == 0) {
					show_version();
				} else
				if (strcmp(argv[i], "--cfg-shared") == 0) {
					ht_cfg_use_homedir = false;
				} else
				{
					PARAM_ERROR("unknown option: %s", argv[i]);
				}
			} else {
				for (int j=1; jproject_opencreate(argv[i+1]);
						i++;
						break;
					case 't':
						EXPECT_PARAMEND(break);
						EXPECT_PARAMS(1, break);
						if (started) load_file(argv[i+1], FOM_TEXT);
						i++;
						break;
					case 'v':
						show_version();
						break;
					default:
						PARAM_ERROR("unknown option: -%c", argv[i][j]);
						break;
					}
				}
			}
		} else {
			if (started) {
				load_file(argv[i], load_mode);
			}
		}
	}
	if (escaped_params_start && started) {
		char **s = &argv[escaped_params_start];
		while (*s) {
			load_file(*s, load_mode);
			s++;
		}
	}
	if (showhelp && started) show_help();
}

#if defined(WIN32) || defined(__WIN32__)
#define LEAN_AND_MEAN
#include 
#endif


int main(int argc, char *argv[])
{
#if defined(WIN32) || defined(__WIN32__)
	HMODULE h = GetModuleHandle(NULL);
	GetModuleFileName(h, appname, sizeof appname-1);
#else
	ht_strlcpy(appname, argv[0], sizeof appname);
#endif

	params(argc, argv, false);
	
	if (!init()) {
		int init_failed = htstate;
		done();
		printf("init(): fatal error in init_%s\n", initdone[init_failed].name);
		return 1;
	}

	((ht_app*)app)->sendmsg(msg_draw);

	const char **copyrights = htcopyrights;
	while (*copyrights) {
		LOG(*copyrights, sys_get_name());
		copyrights++;
	}
	LOG("appname = %s", appname);
	LOG("config = %s", systemconfig_file);

	int systemconfig_version = 0;   // -1 for older and 1 for newer file found
	int systemconfig_magic = 0;     // !=0 meens wrong magic found

	loadstore_result load;
	int error_info;
	if (!load_systemconfig(&load, &error_info)) {
		switch (load) {
		case LS_OK:
			break;
		case LS_ERROR_NOT_FOUND:
			LOG_EX(LOG_WARN, "no configuration file found, using defaults");
			LOG_EX(LOG_WARN, "note that %s has no mouse support. Use the keyboard!", ht_name);
			break;
		case LS_ERROR_READ:
			LOG_EX(LOG_ERROR, "couldn't read configuration file...");
			infobox("couldn't read configuration file...");
			break;
		case LS_ERROR_MAGIC:
		case LS_ERROR_FORMAT:
			LOG_EX(LOG_ERROR, "%s %s %s...", "current configuration file ("SYSTEM_CONFIG_FILE_NAME") has", "invalid", "magic");
			systemconfig_magic = true;
			break;
		case LS_ERROR_VERSION:
			LOG_EX(LOG_ERROR, "%s %s %s...", "current configuration file ("SYSTEM_CONFIG_FILE_NAME") has", "wrong", "version");
			if (error_info < ht_systemconfig_fileversion) {
				systemconfig_version = -1;
			} else {
				systemconfig_version = 1;
			}
			break;
		case LS_ERROR_CORRUPTED:
//			done();
			delete screen;
			printf("\n\n\nfatal error loading configuration file (%s)", systemconfig_file);
			if (error_info) {
				printf(":\nerror near line %d\n", error_info);
			} else {
				printf(".\n");
			}
			printf("please try to delete it.\n");
			return 1;
		default: {assert(0);}
		}
	}

	try {
		params(argc, argv, true);
		ht_app *a = ((ht_app*)app);
		a->run(false);
	} catch (const Exception &x) {
		done();
		ht_fprintf(stderr, "\n\nFATAL: %s: %y\n", "unhandled exception", &x);
		return 1;
	} catch (...) {
		done();
		fprintf(stderr, "\n\nFATAL: unknown %s!?\n", "unhandled exception");
		return 1;
	}

	loadstore_result save = LS_OK;
	bool save_config = true;

	if (systemconfig_magic) {
		if (confirmbox_modal("%s %s %s...\noverwrite it?", "current configuration file ("SYSTEM_CONFIG_FILE_NAME") has", "wrong", "magic")!=button_ok) {
			save_config = false;
		}
	}

	if (systemconfig_version < 0) {
		if (confirmbox_modal("%s %s %s...\noverwrite it?", "current configuration file ("SYSTEM_CONFIG_FILE_NAME") has", "older", "version")!=button_ok) {
			save_config = false;
		}
	} else if (systemconfig_version > 0) {
		if (confirmbox_modal("%s %s %s...\noverwrite it?", "current configuration file ("SYSTEM_CONFIG_FILE_NAME") has", "NEWER", "version")!=button_ok) {
			save_config = false;
		}
	}

	String err;
	if (save_config) {
		LOG("saving config...");
		save = save_systemconfig(err);
	}
	LOG("exit.");
	done();
	if (save != LS_OK) {
		ht_printf("save_systemconfig(): error: %y\n", &err);
		return 1;
	}
	return 0;
}

ht-2.0.22/htpeimp.cc0000644000175000001440000003033410771304342011106 00000000000000/*
 *	HT Editor
 *	htpeimp.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "formats.h"
#include "htanaly.h"
#include "htctrl.h"
#include "data.h"
#include "endianess.h"
#include "htiobox.h"
#include "htnewexe.h"
#include "htpal.h"
#include "htpe.h"
#include "htpeimp.h"
#include "stream.h"
#include "strtools.h"
#include "httag.h"
#include "log.h"
#include "pe_analy.h"
#include "snprintf.h"
#include "tools.h"

#include 
#include 

static ht_view *htpeimports_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_pe_shared_data *pe_shared=(ht_pe_shared_data *)group->get_shared_data();

	if (pe_shared->opt_magic!=COFF_OPTMAGIC_PE32 && pe_shared->opt_magic!=COFF_OPTMAGIC_PE64) return NULL;

	bool pe32 = (pe_shared->opt_magic==COFF_OPTMAGIC_PE32);

	uint32 sec_rva, sec_size;
	if (pe32) {
		sec_rva = pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_IMPORT].address;
		sec_size = pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_IMPORT].size;
	} else {
		sec_rva = pe_shared->pe64.header_nt.directory[PE_DIRECTORY_ENTRY_IMPORT].address;
		sec_size = pe_shared->pe64.header_nt.directory[PE_DIRECTORY_ENTRY_IMPORT].size;
	}
	if (!sec_rva || !sec_size) return NULL;

	int h0=new_timer();
	start_timer(h0);

	ht_group *g;
	Bounds c;
	String fn, s, dllname;

	c=*b;
	g=new ht_group();
	g->init(&c, VO_RESIZE, DESC_PE_IMPORTS"-g");
	ht_statictext *head;

	int dll_count=0;
	int function_count=0;

	c.y++;
	c.h--;
	ht_pe_import_viewer *v=new ht_pe_import_viewer();
	v->init(&c, DESC_PE_IMPORTS, group);

	c.y--;
	c.h=1;

	PE_IMPORT_DESCRIPTOR import;
	FileOfs dofs;
	uint dll_index;
	char iline[256];
	
	/* get import directory offset */
	/* 1. get import directory rva */
	FileOfs iofs;
	RVA irva;
	uint isize;
	if (pe32) {
		irva = pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_IMPORT].address;
		isize = pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_IMPORT].size;
	} else {
		irva = pe_shared->pe64.header_nt.directory[PE_DIRECTORY_ENTRY_IMPORT].address;
		isize = pe_shared->pe64.header_nt.directory[PE_DIRECTORY_ENTRY_IMPORT].size;
	}
	/* 2. transform it into an offset */
	if (!pe_rva_to_ofs(&pe_shared->sections, irva, &iofs)) goto pe_read_error;
	LOG("%y: PE: reading import directory at offset 0x%08qx, rva 0x%08x, size 0x%08x...", &file->getFilename(fn), iofs, irva, isize);

	/* make a memfile out of the whole file */

	/* doesn't work because import information is NOT contained into
	   the import directory !!! only the import dir header. (I !love M$) */

	/*** read import directory ***/
	dofs = iofs;
	dll_index = 0;

	while (1) {
		file->seek(dofs);
		file->readx(&import, sizeof import);
		createHostStruct(&import, PE_IMPORT_DESCRIPTOR_struct, little_endian);
		if ((!import.characteristics) && (!import.name)) break;
		dofs = file->tell();
		/* get name of dll */
		FileOfs iname_ofs;
		if (!pe_rva_to_ofs(&pe_shared->sections, import.name, &iname_ofs)) {
			if (import.name >= file->getSize()) goto pe_read_error;
			file->seek(import.name);
		} else {
			if (iname_ofs >= file->getSize()) goto pe_read_error;
			file->seek(iname_ofs);
		}
		file->readStringz(dllname);
		dll_count++;

		/*** imported functions by name or by ordinal ***/

		/*
		 *	First thunk (FT)
		 *	The first thunk table will be overwritten by the system/loader with
		 *	the function entry-points. So the program will treat this table
		 *	as if it contained just imported addresses.
		 */
		RVA fthunk_rva = import.first_thunk;
		FileOfs fthunk_ofs;
		if (!pe_rva_to_ofs(&pe_shared->sections, fthunk_rva, &fthunk_ofs)) goto pe_read_error;
		/*
		 *	...and Original First Thunk (OFT)
		 * 	I saw executables that have the OFT ptr set to 0 and seem to
		 *	use the FT ptr instead, but also some that have both !=0 and use
		 *	the original one (bound executables).
		 */
		RVA thunk_rva;
		FileOfs thunk_ofs;
		if (import.original_first_thunk) {
			thunk_rva = import.original_first_thunk;
			if (!pe_rva_to_ofs(&pe_shared->sections, thunk_rva, &thunk_ofs)) goto pe_read_error;
		} else {
			thunk_rva = fthunk_rva;
			thunk_ofs = fthunk_ofs;
		}
		ht_pe_import_library *lib=new ht_pe_import_library(dllname.contentChar());
		pe_shared->imports.libs->insert(lib);

		PE_THUNK_DATA thunk;
		PE_THUNK_DATA_64 thunk64;
		uint thunk_count = 0;
		file->seek(thunk_ofs);
		while (1) {
			if (pe32) {
				file->readx(&thunk, sizeof thunk);
				createHostStruct(&thunk, PE_THUNK_DATA_struct, little_endian);
				if (!thunk.ordinal) break;
			} else {
				file->readx(&thunk64, sizeof thunk64);
				createHostStruct(&thunk64, PE_THUNK_DATA_64_struct, little_endian);
				if (!thunk64.ordinal) break;
			}
			thunk_count++;
		}

		PE_THUNK_DATA *thunk_table = NULL;
		PE_THUNK_DATA_64 *thunk_table64 = NULL;
		file->seek(thunk_ofs);
		if (thunk_count) {
			if (pe32) {
				thunk_table = ht_malloc(sizeof *thunk_table * thunk_count);
				file->readx(thunk_table, sizeof *thunk_table * thunk_count);
				// FIXME: ?
				for (uint i=0; ireadx(thunk_table64, sizeof *thunk_table64 * thunk_count);
				// FIXME: ?
				for (uint i=0; isections, thunk.function_desc_address, &function_desc_ofs)) {
						if (function_desc_ofs >= file->getSize()) goto pe_read_error;
						file->seek(function_desc_ofs);
					} else {
						if (thunk.function_desc_address >= file->getSize()) goto pe_read_error;
						file->seek(thunk.function_desc_address); 
					}
					file->readx(&hint, 2);
					hint = createHostInt(&hint, 2, little_endian);
					file->readStringz(s);
					func = new ht_pe_import_function(dll_index, fthunk_rva, s.contentChar(), hint);
				}
			} else {
				thunk64 = thunk_table64[i];

				// FIXME: is this correct ?
				if (thunk64.ordinal & 0x8000000000000000ULL) {
					/* by ordinal */
					func = new ht_pe_import_function(dll_index, fthunk_rva, thunk64.ordinal & 0xffff);
				} else {
					/* by name */
					FileOfs function_desc_ofs;
					uint16 hint = 0;
					if (!pe_rva_to_ofs(&pe_shared->sections, thunk64.function_desc_address, &function_desc_ofs)) goto pe_read_error;
					file->seek(function_desc_ofs);
					file->readx(&hint, 2);
					hint = createHostInt(&hint, 2, little_endian);
					file->readStringz(s);
					func = new ht_pe_import_function(dll_index, fthunk_rva, s.contentChar(), hint);
				}
			}
			pe_shared->imports.funcs->insert(func);

			if (pe32) {
				thunk_ofs+=4;
				thunk_rva+=4;
				fthunk_ofs+=4;
				fthunk_rva+=4;
			} else {
				thunk_ofs+=8;
				thunk_rva+=8;
				fthunk_ofs+=8;
				fthunk_rva+=8;
			}
		}

		dll_index++;

		if (pe32) {
			free(thunk_table);
		} else {
			free(thunk_table64);
		}			
	}

	stop_timer(h0);
//	LOG("%y: PE: %d ticks (%d msec) to read imports", file->get_name(), get_timer_tick(h0), get_timer_msec(h0));
	delete_timer(h0);

	ht_snprintf(iline, sizeof iline, "* PE import directory at offset %08qx (%d functions from %d libraries)", iofs, function_count, dll_count);
	head=new ht_statictext();
	head->init(&c, iline, align_left);

	g->insert(head);
	g->insert(v);
	//
	for (uint i=0; iimports.funcs->count(); i++) {
		ht_pe_import_function *func = (ht_pe_import_function*)(*pe_shared->imports.funcs)[i];
		assert(func);
		ht_pe_import_library *lib = (ht_pe_import_library*)(*pe_shared->imports.libs)[func->libidx];
		assert(lib);
		char addr[32], name[256];
		ht_snprintf(addr, sizeof addr, "%08x", func->address);
		if (func->byname) {
			ht_snprintf(name, sizeof name, "%s", func->name.name);
		} else {
			ht_snprintf(name, sizeof name, "%04x (by ordinal)", func->ordinal);
		}
		v->insert_str(i, lib->name, addr, name);
	}
	//
	v->update();

	g->setpalette(palkey_generic_window_default);

	pe_shared->v_imports=v;
	return g;
pe_read_error:
	delete_timer(h0);
	errorbox("%y: PE import section seems to be corrupted.", &file->getFilename(fn));
	g->done();
	delete g;
	v->done();
	delete v;
	return NULL;
}

format_viewer_if htpeimports_if = {
	htpeimports_init,
	NULL
};

/*
 *	class ht_pe_import_library
 */

ht_pe_import_library::ht_pe_import_library(const char *n)
{
	name = ht_strdup(n);
}

ht_pe_import_library::~ht_pe_import_library()
{
	free(name);
}

/*
 *	class ht_pe_import_function
 */

ht_pe_import_function::ht_pe_import_function(uint li, RVA a, uint o)
{
	libidx = li;
	ordinal = o;
	address = a;
	byname = false;
}

ht_pe_import_function::ht_pe_import_function(uint li, RVA a, const char *n, uint h)
{
	libidx= li;
	name.name = ht_strdup(n);
	name.hint = h;
	address = a;
	byname = true;
}

ht_pe_import_function::~ht_pe_import_function()
{
	if (byname) free(name.name);
}

/*
 *	CLASS ht_pe_import_viewer
 */

void	ht_pe_import_viewer::init(Bounds *b, const char *Desc, ht_format_group *fg)
{
	ht_text_listbox::init(b, 3, 2, LISTBOX_QUICKFIND);
	options |= VO_BROWSABLE;
	desc = strdup(Desc);
	format_group = fg;
	grouplib = false;
	sortby = 1;
	dosort();
}

void	ht_pe_import_viewer::done()
{
	ht_text_listbox::done();
}

void ht_pe_import_viewer::dosort()
{
	ht_text_listbox_sort_order sortord[2];
	uint l, s;
	if (grouplib) {
		l = 0;
		s = 1;
	} else {
		l = 1;
		s = 0;
	}
	sortord[l].col = 0;
	sortord[l].compare_func = strcmp;
	sortord[s].col = sortby;
	sortord[s].compare_func = strcmp;
	sort(2, sortord);
}

const char *ht_pe_import_viewer::func(uint i, bool execute)
{
	switch (i) {
		case 2:
			if (execute) {
				grouplib = !grouplib;
				dosort();
			}
			return grouplib ? (char*)"nbylib" : (char*)"bylib";
		case 4:
			if (execute) {
				if (sortby != 1) {
					sortby = 1;
					dosort();
				}
			}
			return "byaddr";
		case 5:
			if (execute) {
				if (sortby != 2) {
					sortby = 2;
					dosort();
				}
			}
			return "byname";
	}
	return NULL;
}

void ht_pe_import_viewer::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
	case msg_funcexec:
		if (func(msg->data1.integer, 1)) {
			clearmsg(msg);
			return;
		}
		break;
	case msg_funcquery: {
		const char *s=func(msg->data1.integer, 0);
		if (s) {
			msg->msg=msg_retval;
			msg->data1.cstr=s;
		}
		break;
	}
	case msg_keypressed: {
		if (msg->data1.integer == K_Return) {
			select_entry(e_cursor);
			clearmsg(msg);
		}
		break;
	}
	}
	ht_text_listbox::handlemsg(msg);
}

bool ht_pe_import_viewer::select_entry(void *entry)
{
	ht_text_listbox_item *i = (ht_text_listbox_item *)entry;

	ht_pe_shared_data *pe_shared=(ht_pe_shared_data *)format_group->get_shared_data();

	ht_pe_import_function *e = (ht_pe_import_function*)(*pe_shared->imports.funcs)[i->id];
	if (!e) return true;
	if (pe_shared->v_image) {
		ht_aviewer *av = (ht_aviewer*)pe_shared->v_image;
		PEAnalyser *a = (PEAnalyser*)av->analy;
		Address *addr;
		if (pe_shared->opt_magic == COFF_OPTMAGIC_PE32) {
			addr = a->createAddress32(e->address+pe_shared->pe32.header_nt.image_base);
		} else {
			addr = a->createAddress64(e->address+pe_shared->pe64.header_nt.image_base);
		}
		if (av->gotoAddress(addr, NULL)) {
			app->focus(av);
			vstate_save();
		} else {
			global_analyser_address_string_format = ADDRESS_STRING_FORMAT_COMPACT | ADDRESS_STRING_FORMAT_ADD_0X;
			errorbox("can't follow: %s %y is not valid!", "import address", addr);
		}
		delete addr;
	} else errorbox("can't follow: no image viewer");
	return true;
}


ht-2.0.22/atom.h0000644000175000001440000000202510615345250010236 00000000000000/* 
 *	HT Editor
 *	atom.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __ATOM_H__
#define __ATOM_H__

#include "io/types.h"

#define	invalid_atom_id	0

void *getAtomValue(uint id);
uint getAtomId(void *value);
bool registerAtom(uint id, void *data);
bool unregisterAtom(uint id);

/*
 *	Module Init/Done
 */

bool init_atom();
void done_atom();

#endif /* !__ATOM_H__ */

ht-2.0.22/cmds.cc0000644000175000001440000000332010206756706010371 00000000000000/* 
 *	HT Editor
 *	cmds.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "cmds.h"

#define CMD_NAME(n) {n, #n}
/*
cmd_name cmd_names[] = {
CMD_NAME(cmd_quit),
CMD_NAME(cmd_file_open),
CMD_NAME(cmd_file_new),
CMD_NAME(cmd_file_save),
CMD_NAME(cmd_file_saveas),

CMD_NAME(cmd_edit_cut),
CMD_NAME(cmd_edit_delete),
CMD_NAME(cmd_edit_copy),
CMD_NAME(cmd_edit_paste),
CMD_NAME(cmd_edit_show_clipboard),
CMD_NAME(cmd_edit_clear_clipboard),
CMD_NAME(cmd_edit_copy_from_file),
CMD_NAME(cmd_edit_paste_into_file),

CMD_NAME(cmd_window_resizemove),
CMD_NAME(cmd_window_switch_resizemove),
CMD_NAME(cmd_window_close),

CMD_NAME(cmd_popup_dialog_eval),
CMD_NAME(cmd_popup_dialog_view_list),
CMD_NAME(cmd_popup_dialog_window_list),
CMD_NAME(cmd_popup_window_log),
CMD_NAME(cmd_popup_window_help),

CMD_NAME(cmd_view_mode),
CMD_NAME(cmd_edit_mode),
CMD_NAME(cmd_view_mode_i),
CMD_NAME(cmd_edit_mode_i),
CMD_NAME(cmd_file_goto),
CMD_NAME(cmd_file_search),
CMD_NAME(cmd_file_replace),
CMD_NAME(cmd_file_blockop),
CMD_NAME(cmd_file_resize),
CMD_NAME(cmd_file_truncate),
CMD_NAME(cmd_file_extend),
{0, 0}
};
*/
ht-2.0.22/configure0000755000175000001440000065631212127657374011067 00000000000000#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for ht 2.0.22.
#
# Report bugs to .
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
#
#
# This configure script is free software; the Free Software Foundation
# gives unlimited permission to copy, distribute and modify it.
## -------------------- ##
## M4sh Initialization. ##
## -------------------- ##

# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
  emulate sh
  NULLCMD=:
  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
  # is contrary to our usage.  Disable this feature.
  alias -g '${1+"$@"}'='"$@"'
  setopt NO_GLOB_SUBST
else
  case `(set -o) 2>/dev/null` in #(
  *posix*) :
    set -o posix ;; #(
  *) :
     ;;
esac
fi


as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
# Prefer a ksh shell builtin over an external printf program on Solaris,
# but without wasting forks for bash or zsh.
if test -z "$BASH_VERSION$ZSH_VERSION" \
    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
  as_echo='print -r --'
  as_echo_n='print -rn --'
elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
  as_echo='printf %s\n'
  as_echo_n='printf %s'
else
  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
    as_echo_n='/usr/ucb/echo -n'
  else
    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
    as_echo_n_body='eval
      arg=$1;
      case $arg in #(
      *"$as_nl"*)
	expr "X$arg" : "X\\(.*\\)$as_nl";
	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
      esac;
      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
    '
    export as_echo_n_body
    as_echo_n='sh -c $as_echo_n_body as_echo'
  fi
  export as_echo_body
  as_echo='sh -c $as_echo_body as_echo'
fi

# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
  PATH_SEPARATOR=:
  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
      PATH_SEPARATOR=';'
  }
fi


# IFS
# We need space, tab and new line, in precisely that order.  Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" ""	$as_nl"

# Find who we are.  Look in the path if we contain no directory separator.
as_myself=
case $0 in #((
  *[\\/]* ) as_myself=$0 ;;
  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
  done
IFS=$as_save_IFS

     ;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
  as_myself=$0
fi
if test ! -f "$as_myself"; then
  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
  exit 1
fi

# Unset variables that we do not need and which cause bugs (e.g. in
# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
# suppresses any "Segmentation fault" message there.  '((' could
# trigger a bug in pdksh 5.2.14.
for as_var in BASH_ENV ENV MAIL MAILPATH
do eval test x\${$as_var+set} = xset \
  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
done
PS1='$ '
PS2='> '
PS4='+ '

# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE

# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH

# Use a proper internal environment variable to ensure we don't fall
  # into an infinite loop, continuously re-executing ourselves.
  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
    _as_can_reexec=no; export _as_can_reexec;
    # We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
case $- in # ((((
  *v*x* | *x*v* ) as_opts=-vx ;;
  *v* ) as_opts=-v ;;
  *x* ) as_opts=-x ;;
  * ) as_opts= ;;
esac
exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
# Admittedly, this is quite paranoid, since all the known shells bail
# out after a failed `exec'.
$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
as_fn_exit 255
  fi
  # We don't want this to propagate to other subprocesses.
          { _as_can_reexec=; unset _as_can_reexec;}
if test "x$CONFIG_SHELL" = x; then
  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
  emulate sh
  NULLCMD=:
  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
  # is contrary to our usage.  Disable this feature.
  alias -g '\${1+\"\$@\"}'='\"\$@\"'
  setopt NO_GLOB_SUBST
else
  case \`(set -o) 2>/dev/null\` in #(
  *posix*) :
    set -o posix ;; #(
  *) :
     ;;
esac
fi
"
  as_required="as_fn_return () { (exit \$1); }
as_fn_success () { as_fn_return 0; }
as_fn_failure () { as_fn_return 1; }
as_fn_ret_success () { return 0; }
as_fn_ret_failure () { return 1; }

exitcode=0
as_fn_success || { exitcode=1; echo as_fn_success failed.; }
as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :

else
  exitcode=1; echo positional parameters were not saved.
fi
test x\$exitcode = x0 || exit 1
test -x / || exit 1"
  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
test \$(( 1 + 1 )) = 2 || exit 1"
  if (eval "$as_required") 2>/dev/null; then :
  as_have_required=yes
else
  as_have_required=no
fi
  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :

else
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
as_found=false
for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
  as_found=:
  case $as_dir in #(
	 /*)
	   for as_base in sh bash ksh sh5; do
	     # Try only shells that exist, to save several forks.
	     as_shell=$as_dir/$as_base
	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
  CONFIG_SHELL=$as_shell as_have_required=yes
		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
  break 2
fi
fi
	   done;;
       esac
  as_found=false
done
$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
  CONFIG_SHELL=$SHELL as_have_required=yes
fi; }
IFS=$as_save_IFS


      if test "x$CONFIG_SHELL" != x; then :
  export CONFIG_SHELL
             # We cannot yet assume a decent shell, so we have to provide a
# neutralization value for shells without unset; and this also
# works around shells that cannot unset nonexistent variables.
# Preserve -v and -x to the replacement shell.
BASH_ENV=/dev/null
ENV=/dev/null
(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
case $- in # ((((
  *v*x* | *x*v* ) as_opts=-vx ;;
  *v* ) as_opts=-v ;;
  *x* ) as_opts=-x ;;
  * ) as_opts= ;;
esac
exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
# Admittedly, this is quite paranoid, since all the known shells bail
# out after a failed `exec'.
$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
exit 255
fi

    if test x$as_have_required = xno; then :
  $as_echo "$0: This script requires a shell more modern than all"
  $as_echo "$0: the shells that I found on your system."
  if test x${ZSH_VERSION+set} = xset ; then
    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
  else
    $as_echo "$0: Please tell bug-autoconf@gnu.org and
$0: https://sourceforge.net/tracker/?group_id=1066 about
$0: your system, including any error possibly output before
$0: this message. Then install a modern shell, or manually
$0: run the script under such a shell if you do have one."
  fi
  exit 1
fi
fi
fi
SHELL=${CONFIG_SHELL-/bin/sh}
export SHELL
# Unset more variables known to interfere with behavior of common tools.
CLICOLOR_FORCE= GREP_OPTIONS=
unset CLICOLOR_FORCE GREP_OPTIONS

## --------------------- ##
## M4sh Shell Functions. ##
## --------------------- ##
# as_fn_unset VAR
# ---------------
# Portably unset VAR.
as_fn_unset ()
{
  { eval $1=; unset $1;}
}
as_unset=as_fn_unset

# as_fn_set_status STATUS
# -----------------------
# Set $? to STATUS, without forking.
as_fn_set_status ()
{
  return $1
} # as_fn_set_status

# as_fn_exit STATUS
# -----------------
# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
as_fn_exit ()
{
  set +e
  as_fn_set_status $1
  exit $1
} # as_fn_exit

# as_fn_mkdir_p
# -------------
# Create "$as_dir" as a directory, including parents if necessary.
as_fn_mkdir_p ()
{

  case $as_dir in #(
  -*) as_dir=./$as_dir;;
  esac
  test -d "$as_dir" || eval $as_mkdir_p || {
    as_dirs=
    while :; do
      case $as_dir in #(
      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
      *) as_qdir=$as_dir;;
      esac
      as_dirs="'$as_qdir' $as_dirs"
      as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	 X"$as_dir" : 'X\(//\)[^/]' \| \
	 X"$as_dir" : 'X\(//\)$' \| \
	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)[^/].*/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`
      test -d "$as_dir" && break
    done
    test -z "$as_dirs" || eval "mkdir $as_dirs"
  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"


} # as_fn_mkdir_p

# as_fn_executable_p FILE
# -----------------------
# Test if FILE is an executable regular file.
as_fn_executable_p ()
{
  test -f "$1" && test -x "$1"
} # as_fn_executable_p
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
# advantage of any shell optimizations that allow amortized linear growth over
# repeated appends, instead of the typical quadratic growth present in naive
# implementations.
if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
  eval 'as_fn_append ()
  {
    eval $1+=\$2
  }'
else
  as_fn_append ()
  {
    eval $1=\$$1\$2
  }
fi # as_fn_append

# as_fn_arith ARG...
# ------------------
# Perform arithmetic evaluation on the ARGs, and store the result in the
# global $as_val. Take advantage of shells that can avoid forks. The arguments
# must be portable across $(()) and expr.
if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
  eval 'as_fn_arith ()
  {
    as_val=$(( $* ))
  }'
else
  as_fn_arith ()
  {
    as_val=`expr "$@" || test $? -eq 1`
  }
fi # as_fn_arith


# as_fn_error STATUS ERROR [LINENO LOG_FD]
# ----------------------------------------
# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
# script with STATUS, using 1 if that was 0.
as_fn_error ()
{
  as_status=$1; test $as_status -eq 0 && as_status=1
  if test "$4"; then
    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
  fi
  $as_echo "$as_me: error: $2" >&2
  as_fn_exit $as_status
} # as_fn_error

if expr a : '\(a\)' >/dev/null 2>&1 &&
   test "X`expr 00001 : '.*\(...\)'`" = X001; then
  as_expr=expr
else
  as_expr=false
fi

if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
  as_basename=basename
else
  as_basename=false
fi

if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
  as_dirname=dirname
else
  as_dirname=false
fi

as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
	 X"$0" : 'X\(//\)$' \| \
	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
    sed '/^.*\/\([^/][^/]*\)\/*$/{
	    s//\1/
	    q
	  }
	  /^X\/\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\/\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`

# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits


  as_lineno_1=$LINENO as_lineno_1a=$LINENO
  as_lineno_2=$LINENO as_lineno_2a=$LINENO
  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
  sed -n '
    p
    /[$]LINENO/=
  ' <$as_myself |
    sed '
      s/[$]LINENO.*/&-/
      t lineno
      b
      :lineno
      N
      :loop
      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
      t loop
      s/-\n.*//
    ' >$as_me.lineno &&
  chmod +x "$as_me.lineno" ||
    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }

  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
  # already done that, so ensure we don't try to do so again and fall
  # in an infinite loop.  This has already happened in practice.
  _as_can_reexec=no; export _as_can_reexec
  # Don't try to exec as it changes $[0], causing all sort of problems
  # (the dirname of $[0] is not the place where we might find the
  # original and so on.  Autoconf is especially sensitive to this).
  . "./$as_me.lineno"
  # Exit status is that of the last command.
  exit
}

ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in #(((((
-n*)
  case `echo 'xy\c'` in
  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
  xy)  ECHO_C='\c';;
  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
       ECHO_T='	';;
  esac;;
*)
  ECHO_N='-n';;
esac

rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
  rm -f conf$$.dir/conf$$.file
else
  rm -f conf$$.dir
  mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
  if ln -s conf$$.file conf$$ 2>/dev/null; then
    as_ln_s='ln -s'
    # ... but there are two gotchas:
    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
    # In both cases, we have to default to `cp -pR'.
    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
      as_ln_s='cp -pR'
  elif ln conf$$.file conf$$ 2>/dev/null; then
    as_ln_s=ln
  else
    as_ln_s='cp -pR'
  fi
else
  as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null

if mkdir -p . 2>/dev/null; then
  as_mkdir_p='mkdir -p "$as_dir"'
else
  test -d ./-p && rmdir ./-p
  as_mkdir_p=false
fi

as_test_x='test -x'
as_executable_p=as_fn_executable_p

# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"

# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"


test -n "$DJDIR" || exec 7<&0 &1

# Name of the host.
# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
# so uname gets run too.
ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`

#
# Initializations.
#
ac_default_prefix=/usr/local
ac_clean_files=
ac_config_libobj_dir=.
LIBOBJS=
cross_compiling=no
subdirs=
MFLAGS=
MAKEFLAGS=

# Identity of this package.
PACKAGE_NAME='ht'
PACKAGE_TARNAME='ht'
PACKAGE_VERSION='2.0.22'
PACKAGE_STRING='ht 2.0.22'
PACKAGE_BUGREPORT='https://sourceforge.net/tracker/?group_id=1066'
PACKAGE_URL=''

# Factoring default headers for most tests.
ac_includes_default="\
#include 
#ifdef HAVE_SYS_TYPES_H
# include 
#endif
#ifdef HAVE_SYS_STAT_H
# include 
#endif
#ifdef STDC_HEADERS
# include 
# include 
#else
# ifdef HAVE_STDLIB_H
#  include 
# endif
#endif
#ifdef HAVE_STRING_H
# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
#  include 
# endif
# include 
#endif
#ifdef HAVE_STRINGS_H
# include 
#endif
#ifdef HAVE_INTTYPES_H
# include 
#endif
#ifdef HAVE_STDINT_H
# include 
#endif
#ifdef HAVE_UNISTD_H
# include 
#endif"

ac_subst_vars='LTLIBOBJS
LIBOBJS
HT_LIBS
HT_LDFLAGS
IO_DIR
curses_LIBS
curses_CPPFLAGS
ncurses_config
ENABLE_INCLUDED_LZO_FALSE
ENABLE_INCLUDED_LZO_TRUE
USE_LZO_FALSE
USE_LZO_TRUE
EGREP
GREP
LZO_LIBS
AR
LEXLIB
LEX_OUTPUT_ROOT
LEX
YFLAGS
YACC
am__fastdepCXX_FALSE
am__fastdepCXX_TRUE
CXXDEPMODE
ac_ct_CXX
CXXFLAGS
CXX
CPP
am__fastdepCC_FALSE
am__fastdepCC_TRUE
CCDEPMODE
AMDEPBACKSLASH
AMDEP_FALSE
AMDEP_TRUE
am__quote
am__include
DEPDIR
OBJEXT
EXEEXT
ac_ct_CC
CPPFLAGS
LDFLAGS
CFLAGS
CC
MAKE
RANLIB
USE_WIN32_DIR_FALSE
USE_WIN32_DIR_TRUE
USE_DJGPP_DIR_FALSE
USE_DJGPP_DIR_TRUE
USE_POSIX_DIR_FALSE
USE_POSIX_DIR_TRUE
am__untar
am__tar
AMTAR
am__leading_dot
SET_MAKE
AWK
mkdir_p
MKDIR_P
INSTALL_STRIP_PROGRAM
STRIP
install_sh
MAKEINFO
AUTOHEADER
AUTOMAKE
AUTOCONF
ACLOCAL
VERSION
PACKAGE
CYGPATH_W
am__isrc
INSTALL_DATA
INSTALL_SCRIPT
INSTALL_PROGRAM
target_os
target_vendor
target_cpu
target
host_os
host_vendor
host_cpu
host
build_os
build_vendor
build_cpu
build
target_alias
host_alias
build_alias
LIBS
ECHO_T
ECHO_N
ECHO_C
DEFS
mandir
localedir
libdir
psdir
pdfdir
dvidir
htmldir
infodir
docdir
oldincludedir
includedir
localstatedir
sharedstatedir
sysconfdir
datadir
datarootdir
libexecdir
sbindir
bindir
program_transform_name
prefix
exec_prefix
PACKAGE_URL
PACKAGE_BUGREPORT
PACKAGE_STRING
PACKAGE_VERSION
PACKAGE_TARNAME
PACKAGE_NAME
PATH_SEPARATOR
SHELL'
ac_subst_files=''
ac_user_opts='
enable_option_checking
enable_x11_textmode
enable_maintainermode
enable_release
enable_profiling
enable_dependency_tracking
with_included_lzo
'
      ac_precious_vars='build_alias
host_alias
target_alias
CC
CFLAGS
LDFLAGS
LIBS
CPPFLAGS
CPP
CXX
CXXFLAGS
CCC
YACC
YFLAGS'


# Initialize some variables set by options.
ac_init_help=
ac_init_version=false
ac_unrecognized_opts=
ac_unrecognized_sep=
# The variables have the same names as the options, with
# dashes changed to underlines.
cache_file=/dev/null
exec_prefix=NONE
no_create=
no_recursion=
prefix=NONE
program_prefix=NONE
program_suffix=NONE
program_transform_name=s,x,x,
silent=
site=
srcdir=
verbose=
x_includes=NONE
x_libraries=NONE

# Installation directory options.
# These are left unexpanded so users can "make install exec_prefix=/foo"
# and all the variables that are supposed to be based on exec_prefix
# by default will actually change.
# Use braces instead of parens because sh, perl, etc. also accept them.
# (The list follows the same order as the GNU Coding Standards.)
bindir='${exec_prefix}/bin'
sbindir='${exec_prefix}/sbin'
libexecdir='${exec_prefix}/libexec'
datarootdir='${prefix}/share'
datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
infodir='${datarootdir}/info'
htmldir='${docdir}'
dvidir='${docdir}'
pdfdir='${docdir}'
psdir='${docdir}'
libdir='${exec_prefix}/lib'
localedir='${datarootdir}/locale'
mandir='${datarootdir}/man'

ac_prev=
ac_dashdash=
for ac_option
do
  # If the previous option needs an argument, assign it.
  if test -n "$ac_prev"; then
    eval $ac_prev=\$ac_option
    ac_prev=
    continue
  fi

  case $ac_option in
  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
  *=)   ac_optarg= ;;
  *)    ac_optarg=yes ;;
  esac

  # Accept the important Cygnus configure options, so we can diagnose typos.

  case $ac_dashdash$ac_option in
  --)
    ac_dashdash=yes ;;

  -bindir | --bindir | --bindi | --bind | --bin | --bi)
    ac_prev=bindir ;;
  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
    bindir=$ac_optarg ;;

  -build | --build | --buil | --bui | --bu)
    ac_prev=build_alias ;;
  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
    build_alias=$ac_optarg ;;

  -cache-file | --cache-file | --cache-fil | --cache-fi \
  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
    ac_prev=cache_file ;;
  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
    cache_file=$ac_optarg ;;

  --config-cache | -C)
    cache_file=config.cache ;;

  -datadir | --datadir | --datadi | --datad)
    ac_prev=datadir ;;
  -datadir=* | --datadir=* | --datadi=* | --datad=*)
    datadir=$ac_optarg ;;

  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
  | --dataroo | --dataro | --datar)
    ac_prev=datarootdir ;;
  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
    datarootdir=$ac_optarg ;;

  -disable-* | --disable-*)
    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
      as_fn_error $? "invalid feature name: $ac_useropt"
    ac_useropt_orig=$ac_useropt
    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
    case $ac_user_opts in
      *"
"enable_$ac_useropt"
"*) ;;
      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
	 ac_unrecognized_sep=', ';;
    esac
    eval enable_$ac_useropt=no ;;

  -docdir | --docdir | --docdi | --doc | --do)
    ac_prev=docdir ;;
  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
    docdir=$ac_optarg ;;

  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
    ac_prev=dvidir ;;
  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
    dvidir=$ac_optarg ;;

  -enable-* | --enable-*)
    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
      as_fn_error $? "invalid feature name: $ac_useropt"
    ac_useropt_orig=$ac_useropt
    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
    case $ac_user_opts in
      *"
"enable_$ac_useropt"
"*) ;;
      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
	 ac_unrecognized_sep=', ';;
    esac
    eval enable_$ac_useropt=\$ac_optarg ;;

  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
  | --exec | --exe | --ex)
    ac_prev=exec_prefix ;;
  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
  | --exec=* | --exe=* | --ex=*)
    exec_prefix=$ac_optarg ;;

  -gas | --gas | --ga | --g)
    # Obsolete; use --with-gas.
    with_gas=yes ;;

  -help | --help | --hel | --he | -h)
    ac_init_help=long ;;
  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
    ac_init_help=recursive ;;
  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
    ac_init_help=short ;;

  -host | --host | --hos | --ho)
    ac_prev=host_alias ;;
  -host=* | --host=* | --hos=* | --ho=*)
    host_alias=$ac_optarg ;;

  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
    ac_prev=htmldir ;;
  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
  | --ht=*)
    htmldir=$ac_optarg ;;

  -includedir | --includedir | --includedi | --included | --include \
  | --includ | --inclu | --incl | --inc)
    ac_prev=includedir ;;
  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
  | --includ=* | --inclu=* | --incl=* | --inc=*)
    includedir=$ac_optarg ;;

  -infodir | --infodir | --infodi | --infod | --info | --inf)
    ac_prev=infodir ;;
  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
    infodir=$ac_optarg ;;

  -libdir | --libdir | --libdi | --libd)
    ac_prev=libdir ;;
  -libdir=* | --libdir=* | --libdi=* | --libd=*)
    libdir=$ac_optarg ;;

  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
  | --libexe | --libex | --libe)
    ac_prev=libexecdir ;;
  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
  | --libexe=* | --libex=* | --libe=*)
    libexecdir=$ac_optarg ;;

  -localedir | --localedir | --localedi | --localed | --locale)
    ac_prev=localedir ;;
  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
    localedir=$ac_optarg ;;

  -localstatedir | --localstatedir | --localstatedi | --localstated \
  | --localstate | --localstat | --localsta | --localst | --locals)
    ac_prev=localstatedir ;;
  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
    localstatedir=$ac_optarg ;;

  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
    ac_prev=mandir ;;
  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
    mandir=$ac_optarg ;;

  -nfp | --nfp | --nf)
    # Obsolete; use --without-fp.
    with_fp=no ;;

  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
  | --no-cr | --no-c | -n)
    no_create=yes ;;

  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
    no_recursion=yes ;;

  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
  | --oldin | --oldi | --old | --ol | --o)
    ac_prev=oldincludedir ;;
  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
    oldincludedir=$ac_optarg ;;

  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
    ac_prev=prefix ;;
  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
    prefix=$ac_optarg ;;

  -program-prefix | --program-prefix | --program-prefi | --program-pref \
  | --program-pre | --program-pr | --program-p)
    ac_prev=program_prefix ;;
  -program-prefix=* | --program-prefix=* | --program-prefi=* \
  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
    program_prefix=$ac_optarg ;;

  -program-suffix | --program-suffix | --program-suffi | --program-suff \
  | --program-suf | --program-su | --program-s)
    ac_prev=program_suffix ;;
  -program-suffix=* | --program-suffix=* | --program-suffi=* \
  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
    program_suffix=$ac_optarg ;;

  -program-transform-name | --program-transform-name \
  | --program-transform-nam | --program-transform-na \
  | --program-transform-n | --program-transform- \
  | --program-transform | --program-transfor \
  | --program-transfo | --program-transf \
  | --program-trans | --program-tran \
  | --progr-tra | --program-tr | --program-t)
    ac_prev=program_transform_name ;;
  -program-transform-name=* | --program-transform-name=* \
  | --program-transform-nam=* | --program-transform-na=* \
  | --program-transform-n=* | --program-transform-=* \
  | --program-transform=* | --program-transfor=* \
  | --program-transfo=* | --program-transf=* \
  | --program-trans=* | --program-tran=* \
  | --progr-tra=* | --program-tr=* | --program-t=*)
    program_transform_name=$ac_optarg ;;

  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
    ac_prev=pdfdir ;;
  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
    pdfdir=$ac_optarg ;;

  -psdir | --psdir | --psdi | --psd | --ps)
    ac_prev=psdir ;;
  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
    psdir=$ac_optarg ;;

  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
  | -silent | --silent | --silen | --sile | --sil)
    silent=yes ;;

  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
    ac_prev=sbindir ;;
  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
  | --sbi=* | --sb=*)
    sbindir=$ac_optarg ;;

  -sharedstatedir | --sharedstatedir | --sharedstatedi \
  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
  | --sharedst | --shareds | --shared | --share | --shar \
  | --sha | --sh)
    ac_prev=sharedstatedir ;;
  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
  | --sha=* | --sh=*)
    sharedstatedir=$ac_optarg ;;

  -site | --site | --sit)
    ac_prev=site ;;
  -site=* | --site=* | --sit=*)
    site=$ac_optarg ;;

  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
    ac_prev=srcdir ;;
  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
    srcdir=$ac_optarg ;;

  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
  | --syscon | --sysco | --sysc | --sys | --sy)
    ac_prev=sysconfdir ;;
  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
    sysconfdir=$ac_optarg ;;

  -target | --target | --targe | --targ | --tar | --ta | --t)
    ac_prev=target_alias ;;
  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
    target_alias=$ac_optarg ;;

  -v | -verbose | --verbose | --verbos | --verbo | --verb)
    verbose=yes ;;

  -version | --version | --versio | --versi | --vers | -V)
    ac_init_version=: ;;

  -with-* | --with-*)
    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
      as_fn_error $? "invalid package name: $ac_useropt"
    ac_useropt_orig=$ac_useropt
    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
    case $ac_user_opts in
      *"
"with_$ac_useropt"
"*) ;;
      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
	 ac_unrecognized_sep=', ';;
    esac
    eval with_$ac_useropt=\$ac_optarg ;;

  -without-* | --without-*)
    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
    # Reject names that are not valid shell variable names.
    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
      as_fn_error $? "invalid package name: $ac_useropt"
    ac_useropt_orig=$ac_useropt
    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
    case $ac_user_opts in
      *"
"with_$ac_useropt"
"*) ;;
      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
	 ac_unrecognized_sep=', ';;
    esac
    eval with_$ac_useropt=no ;;

  --x)
    # Obsolete; use --with-x.
    with_x=yes ;;

  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
  | --x-incl | --x-inc | --x-in | --x-i)
    ac_prev=x_includes ;;
  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
    x_includes=$ac_optarg ;;

  -x-libraries | --x-libraries | --x-librarie | --x-librari \
  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
    ac_prev=x_libraries ;;
  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
    x_libraries=$ac_optarg ;;

  -*) as_fn_error $? "unrecognized option: \`$ac_option'
Try \`$0 --help' for more information"
    ;;

  *=*)
    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
    # Reject names that are not valid shell variable names.
    case $ac_envvar in #(
      '' | [0-9]* | *[!_$as_cr_alnum]* )
      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
    esac
    eval $ac_envvar=\$ac_optarg
    export $ac_envvar ;;

  *)
    # FIXME: should be removed in autoconf 3.0.
    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
    : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
    ;;

  esac
done

if test -n "$ac_prev"; then
  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
  as_fn_error $? "missing argument to $ac_option"
fi

if test -n "$ac_unrecognized_opts"; then
  case $enable_option_checking in
    no) ;;
    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
  esac
fi

# Check all directory arguments for consistency.
for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
		datadir sysconfdir sharedstatedir localstatedir includedir \
		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
		libdir localedir mandir
do
  eval ac_val=\$$ac_var
  # Remove trailing slashes.
  case $ac_val in
    */ )
      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
      eval $ac_var=\$ac_val;;
  esac
  # Be sure to have absolute directory names.
  case $ac_val in
    [\\/$]* | ?:[\\/]* )  continue;;
    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
  esac
  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
done

# There might be people who depend on the old broken behavior: `$host'
# used to hold the argument of --host etc.
# FIXME: To remove some day.
build=$build_alias
host=$host_alias
target=$target_alias

# FIXME: To remove some day.
if test "x$host_alias" != x; then
  if test "x$build_alias" = x; then
    cross_compiling=maybe
  elif test "x$build_alias" != "x$host_alias"; then
    cross_compiling=yes
  fi
fi

ac_tool_prefix=
test -n "$host_alias" && ac_tool_prefix=$host_alias-

test "$silent" = yes && exec 6>/dev/null


ac_pwd=`pwd` && test -n "$ac_pwd" &&
ac_ls_di=`ls -di .` &&
ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
  as_fn_error $? "working directory cannot be determined"
test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
  as_fn_error $? "pwd does not report name of working directory"


# Find the source files, if location was not specified.
if test -z "$srcdir"; then
  ac_srcdir_defaulted=yes
  # Try the directory containing this script, then the parent directory.
  ac_confdir=`$as_dirname -- "$as_myself" ||
$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	 X"$as_myself" : 'X\(//\)[^/]' \| \
	 X"$as_myself" : 'X\(//\)$' \| \
	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_myself" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)[^/].*/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`
  srcdir=$ac_confdir
  if test ! -r "$srcdir/$ac_unique_file"; then
    srcdir=..
  fi
else
  ac_srcdir_defaulted=no
fi
if test ! -r "$srcdir/$ac_unique_file"; then
  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
fi
ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
ac_abs_confdir=`(
	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
	pwd)`
# When building in place, set srcdir=.
if test "$ac_abs_confdir" = "$ac_pwd"; then
  srcdir=.
fi
# Remove unnecessary trailing slashes from srcdir.
# Double slashes in file names in object file debugging info
# mess up M-x gdb in Emacs.
case $srcdir in
*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
esac
for ac_var in $ac_precious_vars; do
  eval ac_env_${ac_var}_set=\${${ac_var}+set}
  eval ac_env_${ac_var}_value=\$${ac_var}
  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
  eval ac_cv_env_${ac_var}_value=\$${ac_var}
done

#
# Report the --help message.
#
if test "$ac_init_help" = "long"; then
  # Omit some internal or obsolete options to make the list less imposing.
  # This message is too long to be a string in the A/UX 3.1 sh.
  cat <<_ACEOF
\`configure' configures ht 2.0.22 to adapt to many kinds of systems.

Usage: $0 [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print \`checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for \`--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or \`..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [$ac_default_prefix]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, \`make install' will install all the files in
\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
an installation prefix other than \`$ac_default_prefix' using \`--prefix',
for instance \`--prefix=\$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/ht]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]
_ACEOF

  cat <<\_ACEOF

Program names:
  --program-prefix=PREFIX            prepend PREFIX to installed program names
  --program-suffix=SUFFIX            append SUFFIX to installed program names
  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  --target=TARGET   configure for building compilers for TARGET [HOST]
_ACEOF
fi

if test -n "$ac_init_help"; then
  case $ac_init_help in
     short | recursive ) echo "Configuration of ht 2.0.22:";;
   esac
  cat <<\_ACEOF

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-x11-textmode   build with x11 textmode support default=yes
  --enable-maintainermode minimise autodetection for package mantainers default=no
  --enable-release        make a release build default=yes
  --enable-profiling      make a profile build default=no
  --disable-dependency-tracking  speeds up one-time build
  --enable-dependency-tracking   do not reject slow dependency extractors

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-included-lzo     use included minilzo

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L if you have libraries in a
              nonstandard directory 
  LIBS        libraries to pass to the linker, e.g. -l
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I if
              you have headers in a nonstandard directory 
  CPP         C preprocessor
  CXX         C++ compiler command
  CXXFLAGS    C++ compiler flags
  YACC        The `Yet Another Compiler Compiler' implementation to use.
              Defaults to the first program found out of: `bison -y', `byacc',
              `yacc'.
  YFLAGS      The list of arguments that will be passed by default to $YACC.
              This script will default YFLAGS to the empty string to avoid a
              default value of `-d' given by some make applications.

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

Report bugs to .
_ACEOF
ac_status=$?
fi

if test "$ac_init_help" = "recursive"; then
  # If there are subdirs, report their specific --help.
  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
    test -d "$ac_dir" ||
      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
      continue
    ac_builddir=.

case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
  # A ".." for each directory in $ac_dir_suffix.
  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
  case $ac_top_builddir_sub in
  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
  esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix

case $srcdir in
  .)  # We are building in place.
    ac_srcdir=.
    ac_top_srcdir=$ac_top_builddir_sub
    ac_abs_top_srcdir=$ac_pwd ;;
  [\\/]* | ?:[\\/]* )  # Absolute name.
    ac_srcdir=$srcdir$ac_dir_suffix;
    ac_top_srcdir=$srcdir
    ac_abs_top_srcdir=$srcdir ;;
  *) # Relative name.
    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
    ac_top_srcdir=$ac_top_build_prefix$srcdir
    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix

    cd "$ac_dir" || { ac_status=$?; continue; }
    # Check for guested configure.
    if test -f "$ac_srcdir/configure.gnu"; then
      echo &&
      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
    elif test -f "$ac_srcdir/configure"; then
      echo &&
      $SHELL "$ac_srcdir/configure" --help=recursive
    else
      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
    fi || ac_status=$?
    cd "$ac_pwd" || { ac_status=$?; break; }
  done
fi

test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
  cat <<\_ACEOF
ht configure 2.0.22
generated by GNU Autoconf 2.69

Copyright (C) 2012 Free Software Foundation, Inc.
This configure script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it.
_ACEOF
  exit
fi

## ------------------------ ##
## Autoconf initialization. ##
## ------------------------ ##

# ac_fn_c_try_compile LINENO
# --------------------------
# Try to compile conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_compile ()
{
  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  rm -f conftest.$ac_objext
  if { { ac_try="$ac_compile"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_compile") 2>conftest.err
  ac_status=$?
  if test -s conftest.err; then
    grep -v '^ *+' conftest.err >conftest.er1
    cat conftest.er1 >&5
    mv -f conftest.er1 conftest.err
  fi
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; } && {
	 test -z "$ac_c_werror_flag" ||
	 test ! -s conftest.err
       } && test -s conftest.$ac_objext; then :
  ac_retval=0
else
  $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

	ac_retval=1
fi
  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
  as_fn_set_status $ac_retval

} # ac_fn_c_try_compile

# ac_fn_c_try_cpp LINENO
# ----------------------
# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_cpp ()
{
  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  if { { ac_try="$ac_cpp conftest.$ac_ext"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
  ac_status=$?
  if test -s conftest.err; then
    grep -v '^ *+' conftest.err >conftest.er1
    cat conftest.er1 >&5
    mv -f conftest.er1 conftest.err
  fi
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; } > conftest.i && {
	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
	 test ! -s conftest.err
       }; then :
  ac_retval=0
else
  $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

    ac_retval=1
fi
  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
  as_fn_set_status $ac_retval

} # ac_fn_c_try_cpp

# ac_fn_cxx_try_compile LINENO
# ----------------------------
# Try to compile conftest.$ac_ext, and return whether this succeeded.
ac_fn_cxx_try_compile ()
{
  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  rm -f conftest.$ac_objext
  if { { ac_try="$ac_compile"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_compile") 2>conftest.err
  ac_status=$?
  if test -s conftest.err; then
    grep -v '^ *+' conftest.err >conftest.er1
    cat conftest.er1 >&5
    mv -f conftest.er1 conftest.err
  fi
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; } && {
	 test -z "$ac_cxx_werror_flag" ||
	 test ! -s conftest.err
       } && test -s conftest.$ac_objext; then :
  ac_retval=0
else
  $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

	ac_retval=1
fi
  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
  as_fn_set_status $ac_retval

} # ac_fn_cxx_try_compile

# ac_fn_c_try_link LINENO
# -----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded.
ac_fn_c_try_link ()
{
  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  rm -f conftest.$ac_objext conftest$ac_exeext
  if { { ac_try="$ac_link"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_link") 2>conftest.err
  ac_status=$?
  if test -s conftest.err; then
    grep -v '^ *+' conftest.err >conftest.er1
    cat conftest.er1 >&5
    mv -f conftest.er1 conftest.err
  fi
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; } && {
	 test -z "$ac_c_werror_flag" ||
	 test ! -s conftest.err
       } && test -s conftest$ac_exeext && {
	 test "$cross_compiling" = yes ||
	 test -x conftest$ac_exeext
       }; then :
  ac_retval=0
else
  $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

	ac_retval=1
fi
  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
  # interfere with the next link command; also delete a directory that is
  # left behind by Apple's compiler.  We do this before executing the actions.
  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
  as_fn_set_status $ac_retval

} # ac_fn_c_try_link

# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists, giving a warning if it cannot be compiled using
# the include files in INCLUDES and setting the cache variable VAR
# accordingly.
ac_fn_c_check_header_mongrel ()
{
  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  if eval \${$3+:} false; then :
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
  $as_echo_n "(cached) " >&6
fi
eval ac_res=\$$3
	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
else
  # Is the header compilable?
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
$as_echo_n "checking $2 usability... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
$4
#include <$2>
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_header_compiler=yes
else
  ac_header_compiler=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
$as_echo "$ac_header_compiler" >&6; }

# Is the header present?
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
$as_echo_n "checking $2 presence... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include <$2>
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
  ac_header_preproc=yes
else
  ac_header_preproc=no
fi
rm -f conftest.err conftest.i conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
$as_echo "$ac_header_preproc" >&6; }

# So?  What about this header?
case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
  yes:no: )
    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
    ;;
  no:yes:* )
    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
( $as_echo "## ------------------------------------------------------------- ##
## Report this to https://sourceforge.net/tracker/?group_id=1066 ##
## ------------------------------------------------------------- ##"
     ) | sed "s/^/$as_me: WARNING:     /" >&2
    ;;
esac
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
  $as_echo_n "(cached) " >&6
else
  eval "$3=\$ac_header_compiler"
fi
eval ac_res=\$$3
	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
fi
  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno

} # ac_fn_c_check_header_mongrel

# ac_fn_c_try_run LINENO
# ----------------------
# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
# that executables *can* be run.
ac_fn_c_try_run ()
{
  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  if { { ac_try="$ac_link"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_link") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
  { { case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_try") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; }; then :
  ac_retval=0
else
  $as_echo "$as_me: program exited with status $ac_status" >&5
       $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

       ac_retval=$ac_status
fi
  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
  as_fn_set_status $ac_retval

} # ac_fn_c_try_run

# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
# -------------------------------------------------------
# Tests whether HEADER exists and can be compiled using the include files in
# INCLUDES, setting the cache variable VAR accordingly.
ac_fn_c_check_header_compile ()
{
  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
$4
#include <$2>
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  eval "$3=yes"
else
  eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
eval ac_res=\$$3
	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno

} # ac_fn_c_check_header_compile

# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
# --------------------------------------------
# Tries to find the compile-time value of EXPR in a program that includes
# INCLUDES, setting VAR accordingly. Returns whether the value could be
# computed
ac_fn_c_compute_int ()
{
  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
  if test "$cross_compiling" = yes; then
    # Depending upon the size, compute the lo and hi bounds.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) >= 0)];
test_array [0] = 0;
return test_array [0];

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_lo=0 ac_mid=0
  while :; do
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) <= $ac_mid)];
test_array [0] = 0;
return test_array [0];

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_hi=$ac_mid; break
else
  as_fn_arith $ac_mid + 1 && ac_lo=$as_val
			if test $ac_lo -le $ac_mid; then
			  ac_lo= ac_hi=
			  break
			fi
			as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
  done
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) < 0)];
test_array [0] = 0;
return test_array [0];

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_hi=-1 ac_mid=-1
  while :; do
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) >= $ac_mid)];
test_array [0] = 0;
return test_array [0];

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_lo=$ac_mid; break
else
  as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
			if test $ac_mid -le $ac_hi; then
			  ac_lo= ac_hi=
			  break
			fi
			as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
  done
else
  ac_lo= ac_hi=
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
# Binary search between lo and hi bounds.
while test "x$ac_lo" != "x$ac_hi"; do
  as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) <= $ac_mid)];
test_array [0] = 0;
return test_array [0];

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_hi=$ac_mid
else
  as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
case $ac_lo in #((
?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
'') ac_retval=1 ;;
esac
  else
    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
$4
static long int longval () { return $2; }
static unsigned long int ulongval () { return $2; }
#include 
#include 
int
main ()
{

  FILE *f = fopen ("conftest.val", "w");
  if (! f)
    return 1;
  if (($2) < 0)
    {
      long int i = longval ();
      if (i != ($2))
	return 1;
      fprintf (f, "%ld", i);
    }
  else
    {
      unsigned long int i = ulongval ();
      if (i != ($2))
	return 1;
      fprintf (f, "%lu", i);
    }
  /* Do not output a trailing newline, as this causes \r\n confusion
     on some platforms.  */
  return ferror (f) || fclose (f) != 0;

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
  echo >>conftest.val; read $3 &5
$as_echo_n "checking for $2... " >&6; }
if eval \${$3+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
/* Define $2 to an innocuous variant, in case  declares $2.
   For example, HP-UX 11i  declares gettimeofday.  */
#define $2 innocuous_$2

/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char $2 (); below.
    Prefer  to  if __STDC__ is defined, since
     exists even on freestanding compilers.  */

#ifdef __STDC__
# include 
#else
# include 
#endif

#undef $2

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char $2 ();
/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined __stub_$2 || defined __stub___$2
choke me
#endif

int
main ()
{
return $2 ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  eval "$3=yes"
else
  eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
fi
eval ac_res=\$$3
	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno

} # ac_fn_c_check_func
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by ht $as_me 2.0.22, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  $ $0 $@

_ACEOF
exec 5>>config.log
{
cat <<_ASUNAME
## --------- ##
## Platform. ##
## --------- ##

hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
uname -m = `(uname -m) 2>/dev/null || echo unknown`
uname -r = `(uname -r) 2>/dev/null || echo unknown`
uname -s = `(uname -s) 2>/dev/null || echo unknown`
uname -v = `(uname -v) 2>/dev/null || echo unknown`

/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`

/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`

_ASUNAME

as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    $as_echo "PATH: $as_dir"
  done
IFS=$as_save_IFS

} >&5

cat >&5 <<_ACEOF


## ----------- ##
## Core tests. ##
## ----------- ##

_ACEOF


# Keep a trace of the command line.
# Strip out --no-create and --no-recursion so they do not pile up.
# Strip out --silent because we don't want to record it for future runs.
# Also quote any args containing shell meta-characters.
# Make two passes to allow for proper duplicate-argument suppression.
ac_configure_args=
ac_configure_args0=
ac_configure_args1=
ac_must_keep_next=false
for ac_pass in 1 2
do
  for ac_arg
  do
    case $ac_arg in
    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
    | -silent | --silent | --silen | --sile | --sil)
      continue ;;
    *\'*)
      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
    esac
    case $ac_pass in
    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
    2)
      as_fn_append ac_configure_args1 " '$ac_arg'"
      if test $ac_must_keep_next = true; then
	ac_must_keep_next=false # Got value, back to normal.
      else
	case $ac_arg in
	  *=* | --config-cache | -C | -disable-* | --disable-* \
	  | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
	  | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
	  | -with-* | --with-* | -without-* | --without-* | --x)
	    case "$ac_configure_args0 " in
	      "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
	    esac
	    ;;
	  -* ) ac_must_keep_next=true ;;
	esac
      fi
      as_fn_append ac_configure_args " '$ac_arg'"
      ;;
    esac
  done
done
{ ac_configure_args0=; unset ac_configure_args0;}
{ ac_configure_args1=; unset ac_configure_args1;}

# When interrupted or exit'd, cleanup temporary files, and complete
# config.log.  We remove comments because anyway the quotes in there
# would cause problems or look ugly.
# WARNING: Use '\'' to represent an apostrophe within the trap.
# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
trap 'exit_status=$?
  # Save into config.log some information that might help in debugging.
  {
    echo

    $as_echo "## ---------------- ##
## Cache variables. ##
## ---------------- ##"
    echo
    # The following way of writing the cache mishandles newlines in values,
(
  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
    eval ac_val=\$$ac_var
    case $ac_val in #(
    *${as_nl}*)
      case $ac_var in #(
      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
      esac
      case $ac_var in #(
      _ | IFS | as_nl) ;; #(
      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
      *) { eval $ac_var=; unset $ac_var;} ;;
      esac ;;
    esac
  done
  (set) 2>&1 |
    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
    *${as_nl}ac_space=\ *)
      sed -n \
	"s/'\''/'\''\\\\'\'''\''/g;
	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
      ;; #(
    *)
      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
      ;;
    esac |
    sort
)
    echo

    $as_echo "## ----------------- ##
## Output variables. ##
## ----------------- ##"
    echo
    for ac_var in $ac_subst_vars
    do
      eval ac_val=\$$ac_var
      case $ac_val in
      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
      esac
      $as_echo "$ac_var='\''$ac_val'\''"
    done | sort
    echo

    if test -n "$ac_subst_files"; then
      $as_echo "## ------------------- ##
## File substitutions. ##
## ------------------- ##"
      echo
      for ac_var in $ac_subst_files
      do
	eval ac_val=\$$ac_var
	case $ac_val in
	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
	esac
	$as_echo "$ac_var='\''$ac_val'\''"
      done | sort
      echo
    fi

    if test -s confdefs.h; then
      $as_echo "## ----------- ##
## confdefs.h. ##
## ----------- ##"
      echo
      cat confdefs.h
      echo
    fi
    test "$ac_signal" != 0 &&
      $as_echo "$as_me: caught signal $ac_signal"
    $as_echo "$as_me: exit $exit_status"
  } >&5
  rm -f core *.core core.conftest.* &&
    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
    exit $exit_status
' 0
for ac_signal in 1 2 13 15; do
  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
done
ac_signal=0

# confdefs.h avoids OS command line length limits that DEFS can exceed.
rm -f -r conftest* confdefs.h

$as_echo "/* confdefs.h */" > confdefs.h

# Predefined preprocessor variables.

cat >>confdefs.h <<_ACEOF
#define PACKAGE_NAME "$PACKAGE_NAME"
_ACEOF

cat >>confdefs.h <<_ACEOF
#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
_ACEOF

cat >>confdefs.h <<_ACEOF
#define PACKAGE_VERSION "$PACKAGE_VERSION"
_ACEOF

cat >>confdefs.h <<_ACEOF
#define PACKAGE_STRING "$PACKAGE_STRING"
_ACEOF

cat >>confdefs.h <<_ACEOF
#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
_ACEOF

cat >>confdefs.h <<_ACEOF
#define PACKAGE_URL "$PACKAGE_URL"
_ACEOF


# Let the site file select an alternate cache file if it wants to.
# Prefer an explicitly selected file to automatically selected ones.
ac_site_file1=NONE
ac_site_file2=NONE
if test -n "$CONFIG_SITE"; then
  # We do not want a PATH search for config.site.
  case $CONFIG_SITE in #((
    -*)  ac_site_file1=./$CONFIG_SITE;;
    */*) ac_site_file1=$CONFIG_SITE;;
    *)   ac_site_file1=./$CONFIG_SITE;;
  esac
elif test "x$prefix" != xNONE; then
  ac_site_file1=$prefix/share/config.site
  ac_site_file2=$prefix/etc/config.site
else
  ac_site_file1=$ac_default_prefix/share/config.site
  ac_site_file2=$ac_default_prefix/etc/config.site
fi
for ac_site_file in "$ac_site_file1" "$ac_site_file2"
do
  test "x$ac_site_file" = xNONE && continue
  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
$as_echo "$as_me: loading site script $ac_site_file" >&6;}
    sed 's/^/| /' "$ac_site_file" >&5
    . "$ac_site_file" \
      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "failed to load site script $ac_site_file
See \`config.log' for more details" "$LINENO" 5; }
  fi
done

if test -r "$cache_file"; then
  # Some versions of bash will fail to source /dev/null (special files
  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
$as_echo "$as_me: loading cache $cache_file" >&6;}
    case $cache_file in
      [\\/]* | ?:[\\/]* ) . "$cache_file";;
      *)                      . "./$cache_file";;
    esac
  fi
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
$as_echo "$as_me: creating cache $cache_file" >&6;}
  >$cache_file
fi

# Check that the precious variables saved in the cache have kept the same
# value.
ac_cache_corrupted=false
for ac_var in $ac_precious_vars; do
  eval ac_old_set=\$ac_cv_env_${ac_var}_set
  eval ac_new_set=\$ac_env_${ac_var}_set
  eval ac_old_val=\$ac_cv_env_${ac_var}_value
  eval ac_new_val=\$ac_env_${ac_var}_value
  case $ac_old_set,$ac_new_set in
    set,)
      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
      ac_cache_corrupted=: ;;
    ,set)
      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
      ac_cache_corrupted=: ;;
    ,);;
    *)
      if test "x$ac_old_val" != "x$ac_new_val"; then
	# differences in whitespace do not lead to failure.
	ac_old_val_w=`echo x $ac_old_val`
	ac_new_val_w=`echo x $ac_new_val`
	if test "$ac_old_val_w" != "$ac_new_val_w"; then
	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
	  ac_cache_corrupted=:
	else
	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
	  eval $ac_var=\$ac_old_val
	fi
	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
      fi;;
  esac
  # Pass precious variables to config.status.
  if test "$ac_new_set" = set; then
    case $ac_new_val in
    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
    *) ac_arg=$ac_var=$ac_new_val ;;
    esac
    case " $ac_configure_args " in
      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
    esac
  fi
done
if $ac_cache_corrupted; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
fi
## -------------------- ##
## Main body of script. ##
## -------------------- ##

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu




ac_aux_dir=
for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
  if test -f "$ac_dir/install-sh"; then
    ac_aux_dir=$ac_dir
    ac_install_sh="$ac_aux_dir/install-sh -c"
    break
  elif test -f "$ac_dir/install.sh"; then
    ac_aux_dir=$ac_dir
    ac_install_sh="$ac_aux_dir/install.sh -c"
    break
  elif test -f "$ac_dir/shtool"; then
    ac_aux_dir=$ac_dir
    ac_install_sh="$ac_aux_dir/shtool install -c"
    break
  fi
done
if test -z "$ac_aux_dir"; then
  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
fi

# These three variables are undocumented and unsupported,
# and are intended to be withdrawn in a future Autoconf release.
# They can cause serious problems if a builder's source tree is in a directory
# whose full name contains unusual characters.
ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.


# Make sure we can run config.sub.
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
$as_echo_n "checking build system type... " >&6; }
if ${ac_cv_build+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_build_alias=$build_alias
test "x$ac_build_alias" = x &&
  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
test "x$ac_build_alias" = x &&
  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
$as_echo "$ac_cv_build" >&6; }
case $ac_cv_build in
*-*-*) ;;
*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
esac
build=$ac_cv_build
ac_save_IFS=$IFS; IFS='-'
set x $ac_cv_build
shift
build_cpu=$1
build_vendor=$2
shift; shift
# Remember, the first character of IFS is used to create $*,
# except with old shells:
build_os=$*
IFS=$ac_save_IFS
case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
$as_echo_n "checking host system type... " >&6; }
if ${ac_cv_host+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test "x$host_alias" = x; then
  ac_cv_host=$ac_cv_build
else
  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
$as_echo "$ac_cv_host" >&6; }
case $ac_cv_host in
*-*-*) ;;
*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
esac
host=$ac_cv_host
ac_save_IFS=$IFS; IFS='-'
set x $ac_cv_host
shift
host_cpu=$1
host_vendor=$2
shift; shift
# Remember, the first character of IFS is used to create $*,
# except with old shells:
host_os=$*
IFS=$ac_save_IFS
case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking target system type" >&5
$as_echo_n "checking target system type... " >&6; }
if ${ac_cv_target+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test "x$target_alias" = x; then
  ac_cv_target=$ac_cv_host
else
  ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` ||
    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $target_alias failed" "$LINENO" 5
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_target" >&5
$as_echo "$ac_cv_target" >&6; }
case $ac_cv_target in
*-*-*) ;;
*) as_fn_error $? "invalid value of canonical target" "$LINENO" 5;;
esac
target=$ac_cv_target
ac_save_IFS=$IFS; IFS='-'
set x $ac_cv_target
shift
target_cpu=$1
target_vendor=$2
shift; shift
# Remember, the first character of IFS is used to create $*,
# except with old shells:
target_os=$*
IFS=$ac_save_IFS
case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac


# The aliases save the names the user supplied, while $host etc.
# will get canonicalized.
test -n "$target_alias" &&
  test "$program_prefix$program_suffix$program_transform_name" = \
    NONENONEs,x,x, &&
  program_prefix=${target_alias}-


# Check whether --enable-x11-textmode was given.
if test "${enable_x11_textmode+set}" = set; then :
  enableval=$enable_x11_textmode;
else
  enable_x11_textmode="yes"
fi

# Check whether --enable-maintainermode was given.
if test "${enable_maintainermode+set}" = set; then :
  enableval=$enable_maintainermode;
else
  enable_maintainermode="no"
fi

# Check whether --enable-release was given.
if test "${enable_release+set}" = set; then :
  enableval=$enable_release;
else
  enable_release="yes"
fi

# Check whether --enable-profiling was given.
if test "${enable_profiling+set}" = set; then :
  enableval=$enable_profiling;
else
  enable_profiling="no"
fi


# Certain flags that shall always be present even if user does make CFLAGS=""
my_CPPFLAGS="-DNOMACROS"
my_CFLAGS="-Wall -fsigned-char"
my_CXXFLAGS="-Wall -Woverloaded-virtual -Wnon-virtual-dtor -fsigned-char"

if test "x$enable_maintainermode" = "xno"; then
if test "x$enable_release" = "xyes"; then
    default_user_CFLAGS="-O3 -Wall -fomit-frame-pointer"
else
    default_user_CFLAGS="-ggdb3 -O0 -Wall"
fi

if test "x$enable_profiling" = "xyes"; then
    default_user_CFLAGS="$default_user_CFLAGS -pg -g"
fi
fi
CFLAGS="$default_user_CFLAGS"
CXXFLAGS="$default_user_CFLAGS"

am__api_version='1.10'

# Find a good install program.  We prefer a C program (faster),
# so one script is as good as another.  But avoid the broken or
# incompatible versions:
# SysV /etc/install, /usr/sbin/install
# SunOS /usr/etc/install
# IRIX /sbin/install
# AIX /bin/install
# AmigaOS /C/install, which installs bootblocks on floppy discs
# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
# AFS /usr/afsws/bin/install, which mishandles nonexistent args
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# OS/2's system install, which has a completely different semantic
# ./install, which can be erroneously created by make from ./install.sh.
# Reject install programs that cannot install multiple files.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
$as_echo_n "checking for a BSD-compatible install... " >&6; }
if test -z "$INSTALL"; then
if ${ac_cv_path_install+:} false; then :
  $as_echo_n "(cached) " >&6
else
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    # Account for people who put trailing slashes in PATH elements.
case $as_dir/ in #((
  ./ | .// | /[cC]/* | \
  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
  /usr/ucb/* ) ;;
  *)
    # OSF1 and SCO ODT 3.0 have their own names for install.
    # Don't use installbsd from OSF since it installs stuff as root
    # by default.
    for ac_prog in ginstall scoinst install; do
      for ac_exec_ext in '' $ac_executable_extensions; do
	if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
	  if test $ac_prog = install &&
	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
	    # AIX install.  It has an incompatible calling convention.
	    :
	  elif test $ac_prog = install &&
	    grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
	    # program-specific install script used by HP pwplus--don't use.
	    :
	  else
	    rm -rf conftest.one conftest.two conftest.dir
	    echo one > conftest.one
	    echo two > conftest.two
	    mkdir conftest.dir
	    if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
	      test -s conftest.one && test -s conftest.two &&
	      test -s conftest.dir/conftest.one &&
	      test -s conftest.dir/conftest.two
	    then
	      ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
	      break 3
	    fi
	  fi
	fi
      done
    done
    ;;
esac

  done
IFS=$as_save_IFS

rm -rf conftest.one conftest.two conftest.dir

fi
  if test "${ac_cv_path_install+set}" = set; then
    INSTALL=$ac_cv_path_install
  else
    # As a last resort, use the slow shell script.  Don't cache a
    # value for INSTALL within a source directory, because that will
    # break other packages using the cache if that directory is
    # removed, or if the value is a relative name.
    INSTALL=$ac_install_sh
  fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
$as_echo "$INSTALL" >&6; }

# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
# It thinks the first close brace ends the variable substitution.
test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'

test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'

test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
$as_echo_n "checking whether build environment is sane... " >&6; }
# Just in case
sleep 1
echo timestamp > conftest.file
# Do `set' in a subshell so we don't clobber the current shell's
# arguments.  Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
   if test "$*" = "X"; then
      # -L didn't work.
      set X `ls -t $srcdir/configure conftest.file`
   fi
   rm -f conftest.file
   if test "$*" != "X $srcdir/configure conftest.file" \
      && test "$*" != "X conftest.file $srcdir/configure"; then

      # If neither matched, then we have a broken ls.  This can happen
      # if, for instance, CONFIG_SHELL is bash and it inherits a
      # broken ls alias from the environment.  This has actually
      # happened.  Such a system could not be considered "sane".
      as_fn_error $? "ls -t appears to fail.  Make sure there is not a broken
alias in your environment" "$LINENO" 5
   fi

   test "$2" = conftest.file
   )
then
   # Ok.
   :
else
   as_fn_error $? "newly created file is older than distributed files!
Check your system clock" "$LINENO" 5
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
test "$program_prefix" != NONE &&
  program_transform_name="s&^&$program_prefix&;$program_transform_name"
# Use a double $ so make ignores it.
test "$program_suffix" != NONE &&
  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
# Double any \ or $.
# By default was `s,x,x', remove it if useless.
ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`

# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`

test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
# Use eval to expand $SHELL
if eval "$MISSING --run true"; then
  am_missing_run="$MISSING --run "
else
  am_missing_run=
  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5
$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
fi

install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}

# Installed binaries are usually stripped using `strip' when the user
# run `make install-strip'.  However `strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the `STRIP' environment variable to overrule this program.
if test "$cross_compiling" != no; then
  if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
set dummy ${ac_tool_prefix}strip; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_STRIP+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$STRIP"; then
  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
STRIP=$ac_cv_prog_STRIP
if test -n "$STRIP"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
$as_echo "$STRIP" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_STRIP"; then
  ac_ct_STRIP=$STRIP
  # Extract the first word of "strip", so it can be a program name with args.
set dummy strip; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_STRIP"; then
  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_STRIP="strip"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
if test -n "$ac_ct_STRIP"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
$as_echo "$ac_ct_STRIP" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_STRIP" = x; then
    STRIP=":"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    STRIP=$ac_ct_STRIP
  fi
else
  STRIP="$ac_cv_prog_STRIP"
fi

fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
if test -z "$MKDIR_P"; then
  if ${ac_cv_path_mkdir+:} false; then :
  $as_echo_n "(cached) " >&6
else
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_prog in mkdir gmkdir; do
	 for ac_exec_ext in '' $ac_executable_extensions; do
	   as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
	   case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
	     'mkdir (GNU coreutils) '* | \
	     'mkdir (coreutils) '* | \
	     'mkdir (fileutils) '4.1*)
	       ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
	       break 3;;
	   esac
	 done
       done
  done
IFS=$as_save_IFS

fi

  test -d ./--version && rmdir ./--version
  if test "${ac_cv_path_mkdir+set}" = set; then
    MKDIR_P="$ac_cv_path_mkdir -p"
  else
    # As a last resort, use the slow shell script.  Don't cache a
    # value for MKDIR_P within a source directory, because that will
    # break other packages using the cache if that directory is
    # removed, or if the value is a relative name.
    MKDIR_P="$ac_install_sh -d"
  fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
$as_echo "$MKDIR_P" >&6; }

mkdir_p="$MKDIR_P"
case $mkdir_p in
  [\\/$]* | ?:[\\/]*) ;;
  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
esac

for ac_prog in gawk mawk nawk awk
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_AWK+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$AWK"; then
  ac_cv_prog_AWK="$AWK" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_AWK="$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
AWK=$ac_cv_prog_AWK
if test -n "$AWK"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
$as_echo "$AWK" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


  test -n "$AWK" && break
done

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
set x ${MAKE-make}
ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat >conftest.make <<\_ACEOF
SHELL = /bin/sh
all:
	@echo '@@@%%%=$(MAKE)=@@@%%%'
_ACEOF
# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
case `${MAKE-make} -f conftest.make 2>/dev/null` in
  *@@@%%%=?*=@@@%%%*)
    eval ac_cv_prog_make_${ac_make}_set=yes;;
  *)
    eval ac_cv_prog_make_${ac_make}_set=no;;
esac
rm -f conftest.make
fi
if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
  SET_MAKE=
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
  SET_MAKE="MAKE=${MAKE-make}"
fi

rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
  am__leading_dot=.
else
  am__leading_dot=_
fi
rmdir .tst 2>/dev/null

if test "`cd $srcdir && pwd`" != "`pwd`"; then
  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
  # is not polluted with repeated "-I."
  am__isrc=' -I$(srcdir)'
  # test to see if srcdir already configured
  if test -f $srcdir/config.status; then
    as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
  fi
fi

# test whether we have cygpath
if test -z "$CYGPATH_W"; then
  if (cygpath --version) >/dev/null 2>/dev/null; then
    CYGPATH_W='cygpath -w'
  else
    CYGPATH_W=echo
  fi
fi


# Define the identity of the package.
 PACKAGE='ht'
 VERSION='2.0.22'


cat >>confdefs.h <<_ACEOF
#define PACKAGE "$PACKAGE"
_ACEOF


cat >>confdefs.h <<_ACEOF
#define VERSION "$VERSION"
_ACEOF

# Some tools Automake needs.

ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}


AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}


AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}


AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}


MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}

# We need awk for the "check" target.  The system "awk" is bad on
# some platforms.
# Always define AMTAR for backward compatibility.

AMTAR=${AMTAR-"${am_missing_run}tar"}

am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'





ac_config_headers="$ac_config_headers config.h"



NEED_CURSES=0
HAVE_PIPE=0
HT_X11BASE="-L/usr/X11/lib -L/usr/X11R6/lib"

case "$target_os" in
linux*)
	IO_DIR=posix
	echo "*** LINUX, building POSIX version. we need (n)curses." 1>&2
	NEED_CURSES=1
	HAVE_PIPE=1
	HT_LIBS="$HT_LIBS -lm"
	my_CPPFLAGS="$my_CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
;;
*freebsd*)
	IO_DIR=posix
	echo "*** FREEBSD, building native FreeBSD version. we need (n)curses." 1>&2
	NEED_CURSES=1
	HAVE_PIPE=1
	my_CPPFLAGS="$my_CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
;;
*openbsd*)
	IO_DIR=posix
	echo "*** OpenBSD, building native OpenBSD version. we need (n)curses." 1>&2
	NEED_CURSES=1
	HAVE_PIPE=1
	HT_X11BASE="-L${X11BASE}/lib"
	my_CPPFLAGS="$my_CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
;;
cygwin*)
	IO_DIR=win32
	echo "*** CYGWIN, building native Win32 version (no cygwin.dll)" 1>&2
	my_CFLAGS="$my_CFLAGS -mno-cygwin"
	NEED_CURSES=0
	HAVE_PIPE=1
;;
mingw32*)
	IO_DIR=win32
	echo "*** MINGW32, building native Win32 version" 1>&2
	HT_LDFLAGS="$HT_LDFLAGS -static-libgcc -static-libstdc++"
	NEED_CURSES=0
	HAVE_PIPE=1
;;
*)
	echo "configure: warning: $target_os: unknown target OS, assuming POSIX-compatible..." 1>&2
	IO_DIR=posix
	echo "*** POSIX-generic, we need (n)curses, '-pipe' disabled for safety" 1>&2
	NEED_CURSES=1
	HAVE_PIPE=0
	my_CPPFLAGS="$my_CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
;;
esac

if test "x$HAVE_PIPE" = "x1"; then
	my_CFLAGS="$my_CFLAGS -pipe";
fi


cat >>confdefs.h <<_ACEOF
#define SYSTEM_OSAPI_SPECIFIC_TYPES_HDR "io/$IO_DIR/types.h"
_ACEOF


 if test x$IO_DIR = xposix; then
  USE_POSIX_DIR_TRUE=
  USE_POSIX_DIR_FALSE='#'
else
  USE_POSIX_DIR_TRUE='#'
  USE_POSIX_DIR_FALSE=
fi

 if test x$IO_DIR = xdjgpp; then
  USE_DJGPP_DIR_TRUE=
  USE_DJGPP_DIR_FALSE='#'
else
  USE_DJGPP_DIR_TRUE='#'
  USE_DJGPP_DIR_FALSE=
fi

 if test x$IO_DIR = xwin32; then
  USE_WIN32_DIR_TRUE=
  USE_WIN32_DIR_FALSE='#'
else
  USE_WIN32_DIR_TRUE='#'
  USE_WIN32_DIR_FALSE=
fi


if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_RANLIB+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$RANLIB"; then
  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
RANLIB=$ac_cv_prog_RANLIB
if test -n "$RANLIB"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
$as_echo "$RANLIB" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_RANLIB"; then
  ac_ct_RANLIB=$RANLIB
  # Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_RANLIB"; then
  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_RANLIB="ranlib"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
if test -n "$ac_ct_RANLIB"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
$as_echo "$ac_ct_RANLIB" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_RANLIB" = x; then
    RANLIB=":"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    RANLIB=$ac_ct_RANLIB
  fi
else
  RANLIB="$ac_cv_prog_RANLIB"
fi

for ac_prog in gmake make
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_MAKE+:} false; then :
  $as_echo_n "(cached) " >&6
else
  case $MAKE in
  [\\/]* | ?:[\\/]*)
  ac_cv_path_MAKE="$MAKE" # Let the user override the test with a path.
  ;;
  *)
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_path_MAKE="$as_dir/$ac_word$ac_exec_ext"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

  ;;
esac
fi
MAKE=$ac_cv_path_MAKE
if test -n "$MAKE"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAKE" >&5
$as_echo "$MAKE" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


  test -n "$MAKE" && break
done
test -n "$MAKE" || MAKE=":"

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
set x ${MAKE-make}
ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat >conftest.make <<\_ACEOF
SHELL = /bin/sh
all:
	@echo '@@@%%%=$(MAKE)=@@@%%%'
_ACEOF
# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
case `${MAKE-make} -f conftest.make 2>/dev/null` in
  *@@@%%%=?*=@@@%%%*)
    eval ac_cv_prog_make_${ac_make}_set=yes;;
  *)
    eval ac_cv_prog_make_${ac_make}_set=no;;
esac
rm -f conftest.make
fi
if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
  SET_MAKE=
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
  SET_MAKE="MAKE=${MAKE-make}"
fi

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test -n "$ac_tool_prefix"; then
  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
set dummy ${ac_tool_prefix}gcc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_CC="${ac_tool_prefix}gcc"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$ac_cv_prog_CC"; then
  ac_ct_CC=$CC
  # Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_CC+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_CC"; then
  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_CC="gcc"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi

  if test "x$ac_ct_CC" = x; then
    CC=""
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    CC=$ac_ct_CC
  fi
else
  CC="$ac_cv_prog_CC"
fi

if test -z "$CC"; then
          if test -n "$ac_tool_prefix"; then
    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
set dummy ${ac_tool_prefix}cc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_CC="${ac_tool_prefix}cc"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


  fi
fi
if test -z "$CC"; then
  # Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
  ac_prog_rejected=no
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
       ac_prog_rejected=yes
       continue
     fi
    ac_cv_prog_CC="cc"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

if test $ac_prog_rejected = yes; then
  # We found a bogon in the path, so make sure we never use it.
  set dummy $ac_cv_prog_CC
  shift
  if test $# != 0; then
    # We chose a different compiler from the bogus one.
    # However, it has the same basename, so the bogon will be chosen
    # first if we set CC to just the basename; use the full file name.
    shift
    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
  fi
fi
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


fi
if test -z "$CC"; then
  if test -n "$ac_tool_prefix"; then
  for ac_prog in cl.exe
  do
    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CC+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$CC"; then
  ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
$as_echo "$CC" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


    test -n "$CC" && break
  done
fi
if test -z "$CC"; then
  ac_ct_CC=$CC
  for ac_prog in cl.exe
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_CC+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_CC"; then
  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_CC="$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
$as_echo "$ac_ct_CC" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


  test -n "$ac_ct_CC" && break
done

  if test "x$ac_ct_CC" = x; then
    CC=""
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    CC=$ac_ct_CC
  fi
fi

fi


test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "no acceptable C compiler found in \$PATH
See \`config.log' for more details" "$LINENO" 5; }

# Provide some information about the compiler.
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
set X $ac_compile
ac_compiler=$2
for ac_option in --version -v -V -qversion; do
  { { ac_try="$ac_compiler $ac_option >&5"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
  ac_status=$?
  if test -s conftest.err; then
    sed '10a\
... rest of stderr output deleted ...
         10q' conftest.err >conftest.er1
    cat conftest.er1 >&5
  fi
  rm -f conftest.er1 conftest.err
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }
done

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
# Try to create an executable without -o first, disregard a.out.
# It will help us diagnose broken compilers, and finding out an intuition
# of exeext.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
$as_echo_n "checking whether the C compiler works... " >&6; }
ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`

# The possible output files:
ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"

ac_rmfiles=
for ac_file in $ac_files
do
  case $ac_file in
    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
  esac
done
rm -f $ac_rmfiles

if { { ac_try="$ac_link_default"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_link_default") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; then :
  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
# in a Makefile.  We should not override ac_cv_exeext if it was cached,
# so that the user can short-circuit this test for compilers unknown to
# Autoconf.
for ac_file in $ac_files ''
do
  test -f "$ac_file" || continue
  case $ac_file in
    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
	;;
    [ab].out )
	# We found the default executable, but exeext='' is most
	# certainly right.
	break;;
    *.* )
	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
	then :; else
	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
	fi
	# We set ac_cv_exeext here because the later test for it is not
	# safe: cross compilers may not add the suffix if given an `-o'
	# argument, so we may need to know it at that point already.
	# Even if this section looks crufty: it has the advantage of
	# actually working.
	break;;
    * )
	break;;
  esac
done
test "$ac_cv_exeext" = no && ac_cv_exeext=

else
  ac_file=''
fi
if test -z "$ac_file"; then :
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "C compiler cannot create executables
See \`config.log' for more details" "$LINENO" 5; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
$as_echo_n "checking for C compiler default output file name... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
$as_echo "$ac_file" >&6; }
ac_exeext=$ac_cv_exeext

rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
ac_clean_files=$ac_clean_files_save
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
$as_echo_n "checking for suffix of executables... " >&6; }
if { { ac_try="$ac_link"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_link") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; then :
  # If both `conftest.exe' and `conftest' are `present' (well, observable)
# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
# work properly (i.e., refer to `conftest.exe'), while it won't with
# `rm'.
for ac_file in conftest.exe conftest conftest.*; do
  test -f "$ac_file" || continue
  case $ac_file in
    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
	  break;;
    * ) break;;
  esac
done
else
  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of executables: cannot compile and link
See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest conftest$ac_cv_exeext
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
$as_echo "$ac_cv_exeext" >&6; }

rm -f conftest.$ac_ext
EXEEXT=$ac_cv_exeext
ac_exeext=$EXEEXT
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
int
main ()
{
FILE *f = fopen ("conftest.out", "w");
 return ferror (f) || fclose (f) != 0;

  ;
  return 0;
}
_ACEOF
ac_clean_files="$ac_clean_files conftest.out"
# Check that the compiler produces executables we can run.  If not, either
# the compiler is broken, or we cross compile.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
$as_echo_n "checking whether we are cross compiling... " >&6; }
if test "$cross_compiling" != yes; then
  { { ac_try="$ac_link"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_link") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }
  if { ac_try='./conftest$ac_cv_exeext'
  { { case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_try") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; }; then
    cross_compiling=no
  else
    if test "$cross_compiling" = maybe; then
	cross_compiling=yes
    else
	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot run C compiled programs.
If you meant to cross compile, use \`--host'.
See \`config.log' for more details" "$LINENO" 5; }
    fi
  fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
$as_echo "$cross_compiling" >&6; }

rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
ac_clean_files=$ac_clean_files_save
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
$as_echo_n "checking for suffix of object files... " >&6; }
if ${ac_cv_objext+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
rm -f conftest.o conftest.obj
if { { ac_try="$ac_compile"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_compile") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }; then :
  for ac_file in conftest.o conftest.obj conftest.*; do
  test -f "$ac_file" || continue;
  case $ac_file in
    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
       break;;
  esac
done
else
  $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5

{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "cannot compute suffix of object files: cannot compile
See \`config.log' for more details" "$LINENO" 5; }
fi
rm -f conftest.$ac_cv_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
$as_echo "$ac_cv_objext" >&6; }
OBJEXT=$ac_cv_objext
ac_objext=$OBJEXT
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
if ${ac_cv_c_compiler_gnu+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{
#ifndef __GNUC__
       choke me
#endif

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_compiler_gnu=yes
else
  ac_compiler_gnu=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_cv_c_compiler_gnu=$ac_compiler_gnu

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
$as_echo "$ac_cv_c_compiler_gnu" >&6; }
if test $ac_compiler_gnu = yes; then
  GCC=yes
else
  GCC=
fi
ac_test_CFLAGS=${CFLAGS+set}
ac_save_CFLAGS=$CFLAGS
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
$as_echo_n "checking whether $CC accepts -g... " >&6; }
if ${ac_cv_prog_cc_g+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_save_c_werror_flag=$ac_c_werror_flag
   ac_c_werror_flag=yes
   ac_cv_prog_cc_g=no
   CFLAGS="-g"
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_cv_prog_cc_g=yes
else
  CFLAGS=""
      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :

else
  ac_c_werror_flag=$ac_save_c_werror_flag
	 CFLAGS="-g"
	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_cv_prog_cc_g=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
   ac_c_werror_flag=$ac_save_c_werror_flag
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
$as_echo "$ac_cv_prog_cc_g" >&6; }
if test "$ac_test_CFLAGS" = set; then
  CFLAGS=$ac_save_CFLAGS
elif test $ac_cv_prog_cc_g = yes; then
  if test "$GCC" = yes; then
    CFLAGS="-g -O2"
  else
    CFLAGS="-g"
  fi
else
  if test "$GCC" = yes; then
    CFLAGS="-O2"
  else
    CFLAGS=
  fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
if ${ac_cv_prog_cc_c89+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_cv_prog_cc_c89=no
ac_save_CC=$CC
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
#include 
struct stat;
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
static char *e (p, i)
     char **p;
     int i;
{
  return p[i];
}
static char *f (char * (*g) (char **, int), char **p, ...)
{
  char *s;
  va_list v;
  va_start (v,p);
  s = g (p, va_arg (v,int));
  va_end (v);
  return s;
}

/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
   function prototypes and stuff, but not '\xHH' hex character constants.
   These don't provoke an error unfortunately, instead are silently treated
   as 'x'.  The following induces an error, until -std is added to get
   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
   array size at least.  It's necessary to write '\x00'==0 to get something
   that's true only with -std.  */
int osf4_cc_array ['\x00' == 0 ? 1 : -1];

/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
   inside strings and character constants.  */
#define FOO(x) 'x'
int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];

int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};
int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
int argc;
char **argv;
int
main ()
{
return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
  ;
  return 0;
}
_ACEOF
for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
do
  CC="$ac_save_CC $ac_arg"
  if ac_fn_c_try_compile "$LINENO"; then :
  ac_cv_prog_cc_c89=$ac_arg
fi
rm -f core conftest.err conftest.$ac_objext
  test "x$ac_cv_prog_cc_c89" != "xno" && break
done
rm -f conftest.$ac_ext
CC=$ac_save_CC

fi
# AC_CACHE_VAL
case "x$ac_cv_prog_cc_c89" in
  x)
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
$as_echo "none needed" >&6; } ;;
  xno)
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
$as_echo "unsupported" >&6; } ;;
  *)
    CC="$CC $ac_cv_prog_cc_c89"
    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
esac
if test "x$ac_cv_prog_cc_c89" != xno; then :

fi

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
DEPDIR="${am__leading_dot}deps"

ac_config_commands="$ac_config_commands depfiles"


am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
	@echo done
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
$as_echo_n "checking for style of include used by $am_make... " >&6; }
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# We grep out `Entering directory' and `Leaving directory'
# messages which can occur if `w' ends up in MAKEFLAGS.
# In particular we don't look at `^make:' because GNU make might
# be invoked under some other name (usually "gmake"), in which
# case it prints its new name instead of `make'.
if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
   am__include=include
   am__quote=
   _am_result=GNU
fi
# Now try BSD make style include.
if test "$am__include" = "#"; then
   echo '.include "confinc"' > confmf
   if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
      am__include=.include
      am__quote="\""
      _am_result=BSD
   fi
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
$as_echo "$_am_result" >&6; }
rm -f confinc confmf

# Check whether --enable-dependency-tracking was given.
if test "${enable_dependency_tracking+set}" = set; then :
  enableval=$enable_dependency_tracking;
fi

if test "x$enable_dependency_tracking" != xno; then
  am_depcomp="$ac_aux_dir/depcomp"
  AMDEPBACKSLASH='\'
fi
 if test "x$enable_dependency_tracking" != xno; then
  AMDEP_TRUE=
  AMDEP_FALSE='#'
else
  AMDEP_TRUE='#'
  AMDEP_FALSE=
fi



depcc="$CC"   am_compiler_list=

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
$as_echo_n "checking dependency style of $depcc... " >&6; }
if ${am_cv_CC_dependencies_compiler_type+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
  # We make a subdir and do the tests there.  Otherwise we can end up
  # making bogus files that we don't know about and never remove.  For
  # instance it was reported that on HP-UX the gcc test will end up
  # making a dummy file named `D' -- because `-MD' means `put the output
  # in D'.
  mkdir conftest.dir
  # Copy depcomp to subdir because otherwise we won't find it if we're
  # using a relative directory.
  cp "$am_depcomp" conftest.dir
  cd conftest.dir
  # We will build objects and dependencies in a subdirectory because
  # it helps to detect inapplicable dependency modes.  For instance
  # both Tru64's cc and ICC support -MD to output dependencies as a
  # side effect of compilation, but ICC will put the dependencies in
  # the current directory while Tru64 will put them in the object
  # directory.
  mkdir sub

  am_cv_CC_dependencies_compiler_type=none
  if test "$am_compiler_list" = ""; then
     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
  fi
  am__universal=false
  case " $depcc " in #(
     *\ -arch\ *\ -arch\ *) am__universal=true ;;
     esac

  for depmode in $am_compiler_list; do
    # Setup a source with many dependencies, because some compilers
    # like to wrap large dependency lists on column 80 (with \), and
    # we should not choose a depcomp mode which is confused by this.
    #
    # We need to recreate these files for each test, as the compiler may
    # overwrite some of them when testing with obscure command lines.
    # This happens at least with the AIX C compiler.
    : > sub/conftest.c
    for i in 1 2 3 4 5 6; do
      echo '#include "conftst'$i'.h"' >> sub/conftest.c
      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
      # Solaris 8's {/usr,}/bin/sh.
      touch sub/conftst$i.h
    done
    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf

    # We check with `-c' and `-o' for the sake of the "dashmstdout"
    # mode.  It turns out that the SunPro C++ compiler does not properly
    # handle `-M -o', and we need to detect this.  Also, some Intel
    # versions had trouble with output in subdirs
    am__obj=sub/conftest.${OBJEXT-o}
    am__minus_obj="-o $am__obj"
    case $depmode in
    gcc)
      # This depmode causes a compiler race in universal mode.
      test "$am__universal" = false || continue
      ;;
    nosideeffect)
      # after this tag, mechanisms are not by side-effect, so they'll
      # only be used when explicitly requested
      if test "x$enable_dependency_tracking" = xyes; then
	continue
      else
	break
      fi
      ;;
    msvisualcpp | msvcmsys)
      # This compiler won't grok `-c -o', but also, the minuso test has
      # not run yet.  These depmodes are late enough in the game, and
      # so weak that their functioning should not be impacted.
      am__obj=conftest.${OBJEXT-o}
      am__minus_obj=
      ;;
    none) break ;;
    esac
    if depmode=$depmode \
       source=sub/conftest.c object=$am__obj \
       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
         >/dev/null 2>conftest.err &&
       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
      # icc doesn't choke on unknown options, it will just issue warnings
      # or remarks (even with -Werror).  So we grep stderr for any message
      # that says an option was ignored or not supported.
      # When given -MP, icc 7.0 and 7.1 complain thusly:
      #   icc: Command line warning: ignoring option '-M'; no argument required
      # The diagnosis changed in icc 8.0:
      #   icc: Command line remark: option '-MP' not supported
      if (grep 'ignoring option' conftest.err ||
          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
        am_cv_CC_dependencies_compiler_type=$depmode
        break
      fi
    fi
  done

  cd ..
  rm -rf conftest.dir
else
  am_cv_CC_dependencies_compiler_type=none
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type

 if
  test "x$enable_dependency_tracking" != xno \
  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
  am__fastdepCC_TRUE=
  am__fastdepCC_FALSE='#'
else
  am__fastdepCC_TRUE='#'
  am__fastdepCC_FALSE=
fi


ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
$as_echo_n "checking how to run the C preprocessor... " >&6; }
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
  CPP=
fi
if test -z "$CPP"; then
  if ${ac_cv_prog_CPP+:} false; then :
  $as_echo_n "(cached) " >&6
else
      # Double quotes because CPP needs to be expanded
    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
    do
      ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
  # Use a header file that comes with gcc, so configuring glibc
  # with a fresh cross-compiler works.
  # Prefer  to  if __STDC__ is defined, since
  #  exists even on freestanding compilers.
  # On the NeXT, cc -E runs the code through the compiler's parser,
  # not just through cpp. "Syntax error" is here to catch this case.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#ifdef __STDC__
# include 
#else
# include 
#endif
		     Syntax error
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :

else
  # Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.i conftest.$ac_ext

  # OK, works on sane cases.  Now check whether nonexistent headers
  # can be detected and how.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
  # Broken: success on invalid input.
continue
else
  # Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.i conftest.$ac_ext

done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.i conftest.err conftest.$ac_ext
if $ac_preproc_ok; then :
  break
fi

    done
    ac_cv_prog_CPP=$CPP

fi
  CPP=$ac_cv_prog_CPP
else
  ac_cv_prog_CPP=$CPP
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
$as_echo "$CPP" >&6; }
ac_preproc_ok=false
for ac_c_preproc_warn_flag in '' yes
do
  # Use a header file that comes with gcc, so configuring glibc
  # with a fresh cross-compiler works.
  # Prefer  to  if __STDC__ is defined, since
  #  exists even on freestanding compilers.
  # On the NeXT, cc -E runs the code through the compiler's parser,
  # not just through cpp. "Syntax error" is here to catch this case.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#ifdef __STDC__
# include 
#else
# include 
#endif
		     Syntax error
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :

else
  # Broken: fails on valid input.
continue
fi
rm -f conftest.err conftest.i conftest.$ac_ext

  # OK, works on sane cases.  Now check whether nonexistent headers
  # can be detected and how.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
_ACEOF
if ac_fn_c_try_cpp "$LINENO"; then :
  # Broken: success on invalid input.
continue
else
  # Passes both tests.
ac_preproc_ok=:
break
fi
rm -f conftest.err conftest.i conftest.$ac_ext

done
# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
rm -f conftest.i conftest.err conftest.$ac_ext
if $ac_preproc_ok; then :

else
  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
See \`config.log' for more details" "$LINENO" 5; }
fi

ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
if test -z "$CXX"; then
  if test -n "$CCC"; then
    CXX=$CCC
  else
    if test -n "$ac_tool_prefix"; then
  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
  do
    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_CXX+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$CXX"; then
  ac_cv_prog_CXX="$CXX" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
CXX=$ac_cv_prog_CXX
if test -n "$CXX"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
$as_echo "$CXX" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


    test -n "$CXX" && break
  done
fi
if test -z "$CXX"; then
  ac_ct_CXX=$CXX
  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ac_ct_CXX+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ac_ct_CXX"; then
  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ac_ct_CXX="$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
if test -n "$ac_ct_CXX"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
$as_echo "$ac_ct_CXX" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


  test -n "$ac_ct_CXX" && break
done

  if test "x$ac_ct_CXX" = x; then
    CXX="g++"
  else
    case $cross_compiling:$ac_tool_warned in
yes:)
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
    CXX=$ac_ct_CXX
  fi
fi

  fi
fi
# Provide some information about the compiler.
$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
set X $ac_compile
ac_compiler=$2
for ac_option in --version -v -V -qversion; do
  { { ac_try="$ac_compiler $ac_option >&5"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
  ac_status=$?
  if test -s conftest.err; then
    sed '10a\
... rest of stderr output deleted ...
         10q' conftest.err >conftest.er1
    cat conftest.er1 >&5
  fi
  rm -f conftest.er1 conftest.err
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }
done

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
if ${ac_cv_cxx_compiler_gnu+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{
#ifndef __GNUC__
       choke me
#endif

  ;
  return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
  ac_compiler_gnu=yes
else
  ac_compiler_gnu=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_cv_cxx_compiler_gnu=$ac_compiler_gnu

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
if test $ac_compiler_gnu = yes; then
  GXX=yes
else
  GXX=
fi
ac_test_CXXFLAGS=${CXXFLAGS+set}
ac_save_CXXFLAGS=$CXXFLAGS
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
$as_echo_n "checking whether $CXX accepts -g... " >&6; }
if ${ac_cv_prog_cxx_g+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
   ac_cxx_werror_flag=yes
   ac_cv_prog_cxx_g=no
   CXXFLAGS="-g"
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
  ac_cv_prog_cxx_g=yes
else
  CXXFLAGS=""
      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :

else
  ac_cxx_werror_flag=$ac_save_cxx_werror_flag
	 CXXFLAGS="-g"
	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
  ac_cv_prog_cxx_g=yes
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
$as_echo "$ac_cv_prog_cxx_g" >&6; }
if test "$ac_test_CXXFLAGS" = set; then
  CXXFLAGS=$ac_save_CXXFLAGS
elif test $ac_cv_prog_cxx_g = yes; then
  if test "$GXX" = yes; then
    CXXFLAGS="-g -O2"
  else
    CXXFLAGS="-g"
  fi
else
  if test "$GXX" = yes; then
    CXXFLAGS="-O2"
  else
    CXXFLAGS=
  fi
fi
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

depcc="$CXX"  am_compiler_list=

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
$as_echo_n "checking dependency style of $depcc... " >&6; }
if ${am_cv_CXX_dependencies_compiler_type+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
  # We make a subdir and do the tests there.  Otherwise we can end up
  # making bogus files that we don't know about and never remove.  For
  # instance it was reported that on HP-UX the gcc test will end up
  # making a dummy file named `D' -- because `-MD' means `put the output
  # in D'.
  mkdir conftest.dir
  # Copy depcomp to subdir because otherwise we won't find it if we're
  # using a relative directory.
  cp "$am_depcomp" conftest.dir
  cd conftest.dir
  # We will build objects and dependencies in a subdirectory because
  # it helps to detect inapplicable dependency modes.  For instance
  # both Tru64's cc and ICC support -MD to output dependencies as a
  # side effect of compilation, but ICC will put the dependencies in
  # the current directory while Tru64 will put them in the object
  # directory.
  mkdir sub

  am_cv_CXX_dependencies_compiler_type=none
  if test "$am_compiler_list" = ""; then
     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
  fi
  am__universal=false
  case " $depcc " in #(
     *\ -arch\ *\ -arch\ *) am__universal=true ;;
     esac

  for depmode in $am_compiler_list; do
    # Setup a source with many dependencies, because some compilers
    # like to wrap large dependency lists on column 80 (with \), and
    # we should not choose a depcomp mode which is confused by this.
    #
    # We need to recreate these files for each test, as the compiler may
    # overwrite some of them when testing with obscure command lines.
    # This happens at least with the AIX C compiler.
    : > sub/conftest.c
    for i in 1 2 3 4 5 6; do
      echo '#include "conftst'$i'.h"' >> sub/conftest.c
      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
      # Solaris 8's {/usr,}/bin/sh.
      touch sub/conftst$i.h
    done
    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf

    # We check with `-c' and `-o' for the sake of the "dashmstdout"
    # mode.  It turns out that the SunPro C++ compiler does not properly
    # handle `-M -o', and we need to detect this.  Also, some Intel
    # versions had trouble with output in subdirs
    am__obj=sub/conftest.${OBJEXT-o}
    am__minus_obj="-o $am__obj"
    case $depmode in
    gcc)
      # This depmode causes a compiler race in universal mode.
      test "$am__universal" = false || continue
      ;;
    nosideeffect)
      # after this tag, mechanisms are not by side-effect, so they'll
      # only be used when explicitly requested
      if test "x$enable_dependency_tracking" = xyes; then
	continue
      else
	break
      fi
      ;;
    msvisualcpp | msvcmsys)
      # This compiler won't grok `-c -o', but also, the minuso test has
      # not run yet.  These depmodes are late enough in the game, and
      # so weak that their functioning should not be impacted.
      am__obj=conftest.${OBJEXT-o}
      am__minus_obj=
      ;;
    none) break ;;
    esac
    if depmode=$depmode \
       source=sub/conftest.c object=$am__obj \
       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
         >/dev/null 2>conftest.err &&
       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
      # icc doesn't choke on unknown options, it will just issue warnings
      # or remarks (even with -Werror).  So we grep stderr for any message
      # that says an option was ignored or not supported.
      # When given -MP, icc 7.0 and 7.1 complain thusly:
      #   icc: Command line warning: ignoring option '-M'; no argument required
      # The diagnosis changed in icc 8.0:
      #   icc: Command line remark: option '-MP' not supported
      if (grep 'ignoring option' conftest.err ||
          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
        am_cv_CXX_dependencies_compiler_type=$depmode
        break
      fi
    fi
  done

  cd ..
  rm -rf conftest.dir
else
  am_cv_CXX_dependencies_compiler_type=none
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type

 if
  test "x$enable_dependency_tracking" != xno \
  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
  am__fastdepCXX_TRUE=
  am__fastdepCXX_FALSE='#'
else
  am__fastdepCXX_TRUE='#'
  am__fastdepCXX_FALSE=
fi


for ac_prog in 'bison -y' byacc
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_YACC+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$YACC"; then
  ac_cv_prog_YACC="$YACC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_YACC="$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
YACC=$ac_cv_prog_YACC
if test -n "$YACC"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $YACC" >&5
$as_echo "$YACC" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


  test -n "$YACC" && break
done
test -n "$YACC" || YACC="yacc"


for ac_prog in flex lex
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_LEX+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$LEX"; then
  ac_cv_prog_LEX="$LEX" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_LEX="$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
LEX=$ac_cv_prog_LEX
if test -n "$LEX"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LEX" >&5
$as_echo "$LEX" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


  test -n "$LEX" && break
done
test -n "$LEX" || LEX=":"

if test "x$LEX" != "x:"; then
  cat >conftest.l <<_ACEOF
%%
a { ECHO; }
b { REJECT; }
c { yymore (); }
d { yyless (1); }
e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument.  */
    yyless ((input () != 0)); }
f { unput (yytext[0]); }
. { BEGIN INITIAL; }
%%
#ifdef YYTEXT_POINTER
extern char *yytext;
#endif
int
main (void)
{
  return ! yylex () + ! yywrap ();
}
_ACEOF
{ { ac_try="$LEX conftest.l"
case "(($ac_try" in
  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
  *) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
  (eval "$LEX conftest.l") 2>&5
  ac_status=$?
  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
  test $ac_status = 0; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking lex output file root" >&5
$as_echo_n "checking lex output file root... " >&6; }
if ${ac_cv_prog_lex_root+:} false; then :
  $as_echo_n "(cached) " >&6
else

if test -f lex.yy.c; then
  ac_cv_prog_lex_root=lex.yy
elif test -f lexyy.c; then
  ac_cv_prog_lex_root=lexyy
else
  as_fn_error $? "cannot find output from $LEX; giving up" "$LINENO" 5
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_root" >&5
$as_echo "$ac_cv_prog_lex_root" >&6; }
LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root

if test -z "${LEXLIB+set}"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking lex library" >&5
$as_echo_n "checking lex library... " >&6; }
if ${ac_cv_lib_lex+:} false; then :
  $as_echo_n "(cached) " >&6
else

    ac_save_LIBS=$LIBS
    ac_cv_lib_lex='none needed'
    for ac_lib in '' -lfl -ll; do
      LIBS="$ac_lib $ac_save_LIBS"
      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
`cat $LEX_OUTPUT_ROOT.c`
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_lex=$ac_lib
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
      test "$ac_cv_lib_lex" != 'none needed' && break
    done
    LIBS=$ac_save_LIBS

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lex" >&5
$as_echo "$ac_cv_lib_lex" >&6; }
  test "$ac_cv_lib_lex" != 'none needed' && LEXLIB=$ac_cv_lib_lex
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether yytext is a pointer" >&5
$as_echo_n "checking whether yytext is a pointer... " >&6; }
if ${ac_cv_prog_lex_yytext_pointer+:} false; then :
  $as_echo_n "(cached) " >&6
else
  # POSIX says lex can declare yytext either as a pointer or an array; the
# default is implementation-dependent.  Figure out which it is, since
# not all implementations provide the %pointer and %array declarations.
ac_cv_prog_lex_yytext_pointer=no
ac_save_LIBS=$LIBS
LIBS="$LEXLIB $ac_save_LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

  #define YYTEXT_POINTER 1
`cat $LEX_OUTPUT_ROOT.c`
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_prog_lex_yytext_pointer=yes
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_save_LIBS

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_lex_yytext_pointer" >&5
$as_echo "$ac_cv_prog_lex_yytext_pointer" >&6; }
if test $ac_cv_prog_lex_yytext_pointer = yes; then

$as_echo "#define YYTEXT_POINTER 1" >>confdefs.h

fi
rm -f conftest.l $LEX_OUTPUT_ROOT.c

fi
if test "$LEX" = :; then
  LEX=${am_missing_run}flex
fi
# Extract the first word of "ar", so it can be a program name with args.
set dummy ar; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_AR+:} false; then :
  $as_echo_n "(cached) " >&6
else
  case $AR in
  [\\/]* | ?:[\\/]*)
  ac_cv_path_AR="$AR" # Let the user override the test with a path.
  ;;
  *)
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_path_AR="$as_dir/$ac_word$ac_exec_ext"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

  ;;
esac
fi
AR=$ac_cv_path_AR
if test -n "$AR"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
$as_echo "$AR" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


# Extract the first word of "gar", so it can be a program name with args.
set dummy gar; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_AR+:} false; then :
  $as_echo_n "(cached) " >&6
else
  case $AR in
  [\\/]* | ?:[\\/]*)
  ac_cv_path_AR="$AR" # Let the user override the test with a path.
  ;;
  *)
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_path_AR="$as_dir/$ac_word$ac_exec_ext"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

  ;;
esac
fi
AR=$ac_cv_path_AR
if test -n "$AR"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
$as_echo "$AR" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi



if test "x$AR" = "x"; then
	   as_fn_error $? "*** 'ar' and 'gar' missing, please install one of them or fix your \$PATH ***" "$LINENO" 5
fi

if test "x$enable_maintainermode" = "xno"; then
if test "${GXX}" = yes; then
	gxx_version=`${CXX} -v 2>&1 | grep "^.*g.. version" | \\
	sed -e 's/^.*g.. version *//'`
	case ${gxx_version} in
	1.*|2.*|3.*|4.0|4.1|4.2|4.3)
	;;
	*)
	;;
	esac
fi
fi


minilzo_enabled=no


# Check whether --with-included-lzo was given.
if test "${with_included_lzo+set}" = set; then :
  withval=$with_included_lzo; minilzo_enabled=$withval
else
  minilzo_enabled=no
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use the included lzo compression library" >&5
$as_echo_n "checking whether to use the included lzo compression library... " >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $minilzo_enabled" >&5
$as_echo "$minilzo_enabled" >&6; }

LZO_LIBS=
if test "$minilzo_enabled" != "yes"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lzo1x_1_compress in -llzo2" >&5
$as_echo_n "checking for lzo1x_1_compress in -llzo2... " >&6; }
if ${ac_cv_lib_lzo2_lzo1x_1_compress+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-llzo2  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char lzo1x_1_compress ();
int
main ()
{
return lzo1x_1_compress ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_lzo2_lzo1x_1_compress=yes
else
  ac_cv_lib_lzo2_lzo1x_1_compress=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzo2_lzo1x_1_compress" >&5
$as_echo "$ac_cv_lib_lzo2_lzo1x_1_compress" >&6; }
if test "x$ac_cv_lib_lzo2_lzo1x_1_compress" = xyes; then :
  LZO_LIBS=-llzo2
fi

  if test "$LZO_LIBS" = ""; then
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for lzo1x_1_compress in -llzo" >&5
$as_echo_n "checking for lzo1x_1_compress in -llzo... " >&6; }
if ${ac_cv_lib_lzo_lzo1x_1_compress+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-llzo  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char lzo1x_1_compress ();
int
main ()
{
return lzo1x_1_compress ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_lzo_lzo1x_1_compress=yes
else
  ac_cv_lib_lzo_lzo1x_1_compress=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_lzo_lzo1x_1_compress" >&5
$as_echo "$ac_cv_lib_lzo_lzo1x_1_compress" >&6; }
if test "x$ac_cv_lib_lzo_lzo1x_1_compress" = xyes; then :
  LZO_LIBS=-llzo
else

      minilzo_enabled=yes
      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: ***
*** Could not find liblzo or liblzo2. Will use the included minilzo.
" >&5
$as_echo "$as_me: WARNING: ***
*** Could not find liblzo or liblzo2. Will use the included minilzo.
" >&2;}

fi

  fi
fi


if test "$LZO_LIBS" = "-llzo"; then

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
if ${ac_cv_path_GREP+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -z "$GREP"; then
  ac_path_GREP_found=false
  # Loop through the user's path and test for each of PROGNAME-LIST
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_prog in grep ggrep; do
    for ac_exec_ext in '' $ac_executable_extensions; do
      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
      as_fn_executable_p "$ac_path_GREP" || continue
# Check for GNU ac_path_GREP and select it if it is found.
  # Check for GNU $ac_path_GREP
case `"$ac_path_GREP" --version 2>&1` in
*GNU*)
  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
*)
  ac_count=0
  $as_echo_n 0123456789 >"conftest.in"
  while :
  do
    cat "conftest.in" "conftest.in" >"conftest.tmp"
    mv "conftest.tmp" "conftest.in"
    cp "conftest.in" "conftest.nl"
    $as_echo 'GREP' >> "conftest.nl"
    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
    as_fn_arith $ac_count + 1 && ac_count=$as_val
    if test $ac_count -gt ${ac_path_GREP_max-0}; then
      # Best one so far, save it but keep looking for a better one
      ac_cv_path_GREP="$ac_path_GREP"
      ac_path_GREP_max=$ac_count
    fi
    # 10*(2^10) chars as input seems more than enough
    test $ac_count -gt 10 && break
  done
  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac

      $ac_path_GREP_found && break 3
    done
  done
  done
IFS=$as_save_IFS
  if test -z "$ac_cv_path_GREP"; then
    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
  fi
else
  ac_cv_path_GREP=$GREP
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
$as_echo "$ac_cv_path_GREP" >&6; }
 GREP="$ac_cv_path_GREP"


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
$as_echo_n "checking for egrep... " >&6; }
if ${ac_cv_path_EGREP+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
   then ac_cv_path_EGREP="$GREP -E"
   else
     if test -z "$EGREP"; then
  ac_path_EGREP_found=false
  # Loop through the user's path and test for each of PROGNAME-LIST
  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_prog in egrep; do
    for ac_exec_ext in '' $ac_executable_extensions; do
      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
      as_fn_executable_p "$ac_path_EGREP" || continue
# Check for GNU ac_path_EGREP and select it if it is found.
  # Check for GNU $ac_path_EGREP
case `"$ac_path_EGREP" --version 2>&1` in
*GNU*)
  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
*)
  ac_count=0
  $as_echo_n 0123456789 >"conftest.in"
  while :
  do
    cat "conftest.in" "conftest.in" >"conftest.tmp"
    mv "conftest.tmp" "conftest.in"
    cp "conftest.in" "conftest.nl"
    $as_echo 'EGREP' >> "conftest.nl"
    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
    as_fn_arith $ac_count + 1 && ac_count=$as_val
    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
      # Best one so far, save it but keep looking for a better one
      ac_cv_path_EGREP="$ac_path_EGREP"
      ac_path_EGREP_max=$ac_count
    fi
    # 10*(2^10) chars as input seems more than enough
    test $ac_count -gt 10 && break
  done
  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
esac

      $ac_path_EGREP_found && break 3
    done
  done
  done
IFS=$as_save_IFS
  if test -z "$ac_cv_path_EGREP"; then
    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
  fi
else
  ac_cv_path_EGREP=$EGREP
fi

   fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
$as_echo "$ac_cv_path_EGREP" >&6; }
 EGREP="$ac_cv_path_EGREP"


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
if ${ac_cv_header_stdc+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
#include 
#include 
#include 

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_cv_header_stdc=yes
else
  ac_cv_header_stdc=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

if test $ac_cv_header_stdc = yes; then
  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 

_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
  $EGREP "memchr" >/dev/null 2>&1; then :

else
  ac_cv_header_stdc=no
fi
rm -f conftest*

fi

if test $ac_cv_header_stdc = yes; then
  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 

_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
  $EGREP "free" >/dev/null 2>&1; then :

else
  ac_cv_header_stdc=no
fi
rm -f conftest*

fi

if test $ac_cv_header_stdc = yes; then
  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
  if test "$cross_compiling" = yes; then :
  :
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
#include 
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) \
		   (('a' <= (c) && (c) <= 'i') \
		     || ('j' <= (c) && (c) <= 'r') \
		     || ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif

#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
  int i;
  for (i = 0; i < 256; i++)
    if (XOR (islower (i), ISLOWER (i))
	|| toupper (i) != TOUPPER (i))
      return 2;
  return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :

else
  ac_cv_header_stdc=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
  conftest.$ac_objext conftest.beam conftest.$ac_ext
fi

fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
$as_echo "$ac_cv_header_stdc" >&6; }
if test $ac_cv_header_stdc = yes; then

$as_echo "#define STDC_HEADERS 1" >>confdefs.h

fi

# On IRIX 5.3, sys/types and inttypes.h are conflicting.
for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
		  inttypes.h stdint.h unistd.h
do :
  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
"
if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
  cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF

fi

done


for ac_header in lzo1x.h
do :
  ac_fn_c_check_header_mongrel "$LINENO" "lzo1x.h" "ac_cv_header_lzo1x_h" "$ac_includes_default"
if test "x$ac_cv_header_lzo1x_h" = xyes; then :
  cat >>confdefs.h <<_ACEOF
#define HAVE_LZO1X_H 1
_ACEOF

fi

done

elif test "$LZO_LIBS" = "-llzo2"; then
  for ac_header in lzo/lzo1x.h
do :
  ac_fn_c_check_header_mongrel "$LINENO" "lzo/lzo1x.h" "ac_cv_header_lzo_lzo1x_h" "$ac_includes_default"
if test "x$ac_cv_header_lzo_lzo1x_h" = xyes; then :
  cat >>confdefs.h <<_ACEOF
#define HAVE_LZO_LZO1X_H 1
_ACEOF

fi

done

fi

if test "$minilzo_enabled" = "yes"; then

$as_echo "#define USE_MINILZO 1" >>confdefs.h

fi

 if test "$use_lzo" = "yes"; then
  USE_LZO_TRUE=
  USE_LZO_FALSE='#'
else
  USE_LZO_TRUE='#'
  USE_LZO_FALSE=
fi

 if test "$minilzo_enabled" = "yes"; then
  ENABLE_INCLUDED_LZO_TRUE=
  ENABLE_INCLUDED_LZO_FALSE='#'
else
  ENABLE_INCLUDED_LZO_TRUE='#'
  ENABLE_INCLUDED_LZO_FALSE=
fi


HAVE_X11=0

if test "x$enable_x11_textmode" = "xyes"; then
	TEMP_LDFLAGS=$LDFLAGS
	LDFLAGS="$HT_LDFLAGS $HT_X11BASE"
	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for XOpenDisplay in -lX11" >&5
$as_echo_n "checking for XOpenDisplay in -lX11... " >&6; }
if ${ac_cv_lib_X11_XOpenDisplay+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_check_lib_save_LIBS=$LIBS
LIBS="-lX11  $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char XOpenDisplay ();
int
main ()
{
return XOpenDisplay ();
  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_lib_X11_XOpenDisplay=yes
else
  ac_cv_lib_X11_XOpenDisplay=no
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_X11_XOpenDisplay" >&5
$as_echo "$ac_cv_lib_X11_XOpenDisplay" >&6; }
if test "x$ac_cv_lib_X11_XOpenDisplay" = xyes; then :
  HAVE_X11=1
fi

	LDFLAGS=$TEMP_LDFLAGS
	if test "x$HAVE_X11" = "x1"; then

$as_echo "#define HAVE_TEXTMODE_X11 1" >>confdefs.h

		HT_LIBS="$HT_LIBS -lX11"
		HT_LDFLAGS="$HT_LDFLAGS $HT_X11BASE"
	fi
fi

{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
$as_echo_n "checking for ANSI C header files... " >&6; }
if ${ac_cv_header_stdc+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
#include 
#include 
#include 

int
main ()
{

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_cv_header_stdc=yes
else
  ac_cv_header_stdc=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext

if test $ac_cv_header_stdc = yes; then
  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 

_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
  $EGREP "memchr" >/dev/null 2>&1; then :

else
  ac_cv_header_stdc=no
fi
rm -f conftest*

fi

if test $ac_cv_header_stdc = yes; then
  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 

_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
  $EGREP "free" >/dev/null 2>&1; then :

else
  ac_cv_header_stdc=no
fi
rm -f conftest*

fi

if test $ac_cv_header_stdc = yes; then
  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
  if test "$cross_compiling" = yes; then :
  :
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */
#include 
#include 
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) \
		   (('a' <= (c) && (c) <= 'i') \
		     || ('j' <= (c) && (c) <= 'r') \
		     || ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif

#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
  int i;
  for (i = 0; i < 256; i++)
    if (XOR (islower (i), ISLOWER (i))
	|| toupper (i) != TOUPPER (i))
      return 2;
  return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :

else
  ac_cv_header_stdc=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
  conftest.$ac_objext conftest.beam conftest.$ac_ext
fi

fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
$as_echo "$ac_cv_header_stdc" >&6; }
if test $ac_cv_header_stdc = yes; then

$as_echo "#define STDC_HEADERS 1" >>confdefs.h

fi

for ac_header in stdlib.h
do :
  ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default"
if test "x$ac_cv_header_stdlib_h" = xyes; then :
  cat >>confdefs.h <<_ACEOF
#define HAVE_STDLIB_H 1
_ACEOF

fi

done

for ac_header in string.h
do :
  ac_fn_c_check_header_mongrel "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default"
if test "x$ac_cv_header_string_h" = xyes; then :
  cat >>confdefs.h <<_ACEOF
#define HAVE_STRING_H 1
_ACEOF

fi

done

for ac_header in stdint.h
do :
  ac_fn_c_check_header_mongrel "$LINENO" "stdint.h" "ac_cv_header_stdint_h" "$ac_includes_default"
if test "x$ac_cv_header_stdint_h" = xyes; then :
  cat >>confdefs.h <<_ACEOF
#define HAVE_STDINT_H 1
_ACEOF

fi

done


CURSES_LIB=
if test "x$NEED_CURSES" = "x1"; then
	for ac_prog in ncursesw6-config ncursesw5-config ncurses6-config ncurses5-config
do
  # Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_prog_ncurses_config+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if test -n "$ncurses_config"; then
  ac_cv_prog_ncurses_config="$ncurses_config" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    for ac_exec_ext in '' $ac_executable_extensions; do
  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    ac_cv_prog_ncurses_config="$ac_prog"
    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    break 2
  fi
done
  done
IFS=$as_save_IFS

fi
fi
ncurses_config=$ac_cv_prog_ncurses_config
if test -n "$ncurses_config"; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ncurses_config" >&5
$as_echo "$ncurses_config" >&6; }
else
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi


  test -n "$ncurses_config" && break
done

	if test "x$ncurses_config" != "x"; then
		curses_CPPFLAGS="$($ncurses_config --cflags)"
		curses_LIBS="$($ncurses_config --libs)"

$as_echo "#define CURSES_HDR " >>confdefs.h

	else
		{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing initscr" >&5
$as_echo_n "checking for library containing initscr... " >&6; }
if ${ac_cv_search_initscr+:} false; then :
  $as_echo_n "(cached) " >&6
else
  ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char initscr ();
int
main ()
{
return initscr ();
  ;
  return 0;
}
_ACEOF
for ac_lib in '' ncursesw ncurses curses; do
  if test -z "$ac_lib"; then
    ac_res="none required"
  else
    ac_res=-l$ac_lib
    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
  fi
  if ac_fn_c_try_link "$LINENO"; then :
  ac_cv_search_initscr=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
    conftest$ac_exeext
  if ${ac_cv_search_initscr+:} false; then :
  break
fi
done
if ${ac_cv_search_initscr+:} false; then :

else
  ac_cv_search_initscr=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_initscr" >&5
$as_echo "$ac_cv_search_initscr" >&6; }
ac_res=$ac_cv_search_initscr
if test "$ac_res" != no; then :
  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
  curses_LIBS="$LIBS"; LIBS=""
fi

		for ac_header in curses.h
do :
  ac_fn_c_check_header_mongrel "$LINENO" "curses.h" "ac_cv_header_curses_h" "$ac_includes_default"
if test "x$ac_cv_header_curses_h" = xyes; then :
  cat >>confdefs.h <<_ACEOF
#define HAVE_CURSES_H 1
_ACEOF

$as_echo "#define CURSES_HDR " >>confdefs.h

fi

done

		for ac_header in ncurses.h
do :
  ac_fn_c_check_header_mongrel "$LINENO" "ncurses.h" "ac_cv_header_ncurses_h" "$ac_includes_default"
if test "x$ac_cv_header_ncurses_h" = xyes; then :
  cat >>confdefs.h <<_ACEOF
#define HAVE_NCURSES_H 1
_ACEOF

$as_echo "#define CURSES_HDR " >>confdefs.h

fi

done

	fi
	if test "x$curses_LIBS" = "x"; then
		   as_fn_error $? "*** (n)curses.h needed ***" "$LINENO" 5
	fi


fi





{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
$as_echo_n "checking for an ANSI C-conforming const... " >&6; }
if ${ac_cv_c_const+:} false; then :
  $as_echo_n "(cached) " >&6
else
  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h.  */

int
main ()
{

#ifndef __cplusplus
  /* Ultrix mips cc rejects this sort of thing.  */
  typedef int charset[2];
  const charset cs = { 0, 0 };
  /* SunOS 4.1.1 cc rejects this.  */
  char const *const *pcpcc;
  char **ppc;
  /* NEC SVR4.0.2 mips cc rejects this.  */
  struct point {int x, y;};
  static struct point const zero = {0,0};
  /* AIX XL C 1.02.0.0 rejects this.
     It does not let you subtract one const X* pointer from another in
     an arm of an if-expression whose if-part is not a constant
     expression */
  const char *g = "string";
  pcpcc = &g + (g ? g-g : 0);
  /* HPUX 7.0 cc rejects these. */
  ++pcpcc;
  ppc = (char**) pcpcc;
  pcpcc = (char const *const *) ppc;
  { /* SCO 3.2v4 cc rejects this sort of thing.  */
    char tx;
    char *t = &tx;
    char const *s = 0 ? (char *) 0 : (char const *) 0;

    *t++ = 0;
    if (s) return 0;
  }
  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
    int x[] = {25, 17};
    const int *foo = &x[0];
    ++foo;
  }
  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
    typedef const int *iptr;
    iptr p = 0;
    ++p;
  }
  { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying
       "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
    struct s { int j; const int *ap[3]; } bx;
    struct s *b = &bx; b->j = 5;
  }
  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
    const int foo = 10;
    if (!foo) return 0;
  }
  return !cs[0] && !zero.x;
#endif

  ;
  return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
  ac_cv_c_const=yes
else
  ac_cv_c_const=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5
$as_echo "$ac_cv_c_const" >&6; }
if test $ac_cv_c_const = no; then

$as_echo "#define const /**/" >>confdefs.h

fi


# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char" >&5
$as_echo_n "checking size of char... " >&6; }
if ${ac_cv_sizeof_char+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char))" "ac_cv_sizeof_char"        "$ac_includes_default"; then :

else
  if test "$ac_cv_type_char" = yes; then
     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (char)
See \`config.log' for more details" "$LINENO" 5; }
   else
     ac_cv_sizeof_char=0
   fi
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_char" >&5
$as_echo "$ac_cv_sizeof_char" >&6; }



cat >>confdefs.h <<_ACEOF
#define SIZEOF_CHAR $ac_cv_sizeof_char
_ACEOF


# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5
$as_echo_n "checking size of short... " >&6; }
if ${ac_cv_sizeof_short+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short"        "$ac_includes_default"; then :

else
  if test "$ac_cv_type_short" = yes; then
     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (short)
See \`config.log' for more details" "$LINENO" 5; }
   else
     ac_cv_sizeof_short=0
   fi
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5
$as_echo "$ac_cv_sizeof_short" >&6; }



cat >>confdefs.h <<_ACEOF
#define SIZEOF_SHORT $ac_cv_sizeof_short
_ACEOF


# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5
$as_echo_n "checking size of int... " >&6; }
if ${ac_cv_sizeof_int+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int"        "$ac_includes_default"; then :

else
  if test "$ac_cv_type_int" = yes; then
     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (int)
See \`config.log' for more details" "$LINENO" 5; }
   else
     ac_cv_sizeof_int=0
   fi
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5
$as_echo "$ac_cv_sizeof_int" >&6; }



cat >>confdefs.h <<_ACEOF
#define SIZEOF_INT $ac_cv_sizeof_int
_ACEOF


# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long int" >&5
$as_echo_n "checking size of long int... " >&6; }
if ${ac_cv_sizeof_long_int+:} false; then :
  $as_echo_n "(cached) " >&6
else
  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long int))" "ac_cv_sizeof_long_int"        "$ac_includes_default"; then :

else
  if test "$ac_cv_type_long_int" = yes; then
     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (long int)
See \`config.log' for more details" "$LINENO" 5; }
   else
     ac_cv_sizeof_long_int=0
   fi
fi

fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long_int" >&5
$as_echo "$ac_cv_sizeof_long_int" >&6; }



cat >>confdefs.h <<_ACEOF
#define SIZEOF_LONG_INT $ac_cv_sizeof_long_int
_ACEOF



for ac_func in asinh acosh atanh
do :
  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
  cat >>confdefs.h <<_ACEOF
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
_ACEOF

fi
done


ac_config_files="$ac_config_files Makefile analyser/Makefile asm/Makefile doc/Makefile eval/Makefile info/Makefile io/Makefile io/posix/Makefile io/djgpp/Makefile io/win32/Makefile minilzo/Makefile output/Makefile tools/Makefile"

cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
# scripts and configure runs, see configure's option --config-cache.
# It is not useful on other systems.  If it contains results you don't
# want to keep, you may remove or edit it.
#
# config.status only pays attention to the cache file if you give it
# the --recheck option to rerun configure.
#
# `ac_cv_env_foo' variables (set or unset) will be overridden when
# loading this file, other *unset* `ac_cv_foo' will be assigned the
# following values.

_ACEOF

# The following way of writing the cache mishandles newlines in values,
# but we know of no workaround that is simple, portable, and efficient.
# So, we kill variables containing newlines.
# Ultrix sh set writes to stderr and can't be redirected directly,
# and sets the high bit in the cache file unless we assign to the vars.
(
  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
    eval ac_val=\$$ac_var
    case $ac_val in #(
    *${as_nl}*)
      case $ac_var in #(
      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
      esac
      case $ac_var in #(
      _ | IFS | as_nl) ;; #(
      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
      *) { eval $ac_var=; unset $ac_var;} ;;
      esac ;;
    esac
  done

  (set) 2>&1 |
    case $as_nl`(ac_space=' '; set) 2>&1` in #(
    *${as_nl}ac_space=\ *)
      # `set' does not quote correctly, so add quotes: double-quote
      # substitution turns \\\\ into \\, and sed turns \\ into \.
      sed -n \
	"s/'/'\\\\''/g;
	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
      ;; #(
    *)
      # `set' quotes correctly as required by POSIX, so do not add quotes.
      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
      ;;
    esac |
    sort
) |
  sed '
     /^ac_cv_env_/b end
     t clear
     :clear
     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
     t end
     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
     :end' >>confcache
if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
  if test -w "$cache_file"; then
    if test "x$cache_file" != "x/dev/null"; then
      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
$as_echo "$as_me: updating cache $cache_file" >&6;}
      if test ! -f "$cache_file" || test -h "$cache_file"; then
	cat confcache >"$cache_file"
      else
        case $cache_file in #(
        */* | ?:*)
	  mv -f confcache "$cache_file"$$ &&
	  mv -f "$cache_file"$$ "$cache_file" ;; #(
        *)
	  mv -f confcache "$cache_file" ;;
	esac
      fi
    fi
  else
    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
  fi
fi
rm -f confcache

test "x$prefix" = xNONE && prefix=$ac_default_prefix
# Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'

DEFS=-DHAVE_CONFIG_H

ac_libobjs=
ac_ltlibobjs=
U=
for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
  # 1. Remove the extension, and $U if already installed.
  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
  #    will be set to the directory where LIBOBJS objects are built.
  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
done
LIBOBJS=$ac_libobjs

LTLIBOBJS=$ac_ltlibobjs


if test -z "${USE_POSIX_DIR_TRUE}" && test -z "${USE_POSIX_DIR_FALSE}"; then
  as_fn_error $? "conditional \"USE_POSIX_DIR\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${USE_DJGPP_DIR_TRUE}" && test -z "${USE_DJGPP_DIR_FALSE}"; then
  as_fn_error $? "conditional \"USE_DJGPP_DIR\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${USE_WIN32_DIR_TRUE}" && test -z "${USE_WIN32_DIR_FALSE}"; then
  as_fn_error $? "conditional \"USE_WIN32_DIR\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
  as_fn_error $? "conditional \"AMDEP\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
  as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
  as_fn_error $? "conditional \"am__fastdepCXX\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${USE_LZO_TRUE}" && test -z "${USE_LZO_FALSE}"; then
  as_fn_error $? "conditional \"USE_LZO\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${ENABLE_INCLUDED_LZO_TRUE}" && test -z "${ENABLE_INCLUDED_LZO_FALSE}"; then
  as_fn_error $? "conditional \"ENABLE_INCLUDED_LZO\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi

: "${CONFIG_STATUS=./config.status}"
ac_write_fail=0
ac_clean_files_save=$ac_clean_files
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
as_write_fail=0
cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
#! $SHELL
# Generated by $as_me.
# Run this file to recreate the current configuration.
# Compiler output produced by configure, useful for debugging
# configure, is in config.log if it exists.

debug=false
ac_cs_recheck=false
ac_cs_silent=false

SHELL=\${CONFIG_SHELL-$SHELL}
export SHELL
_ASEOF
cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
## -------------------- ##
## M4sh Initialization. ##
## -------------------- ##

# Be more Bourne compatible
DUALCASE=1; export DUALCASE # for MKS sh
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
  emulate sh
  NULLCMD=:
  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
  # is contrary to our usage.  Disable this feature.
  alias -g '${1+"$@"}'='"$@"'
  setopt NO_GLOB_SUBST
else
  case `(set -o) 2>/dev/null` in #(
  *posix*) :
    set -o posix ;; #(
  *) :
     ;;
esac
fi


as_nl='
'
export as_nl
# Printing a long string crashes Solaris 7 /usr/bin/printf.
as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
# Prefer a ksh shell builtin over an external printf program on Solaris,
# but without wasting forks for bash or zsh.
if test -z "$BASH_VERSION$ZSH_VERSION" \
    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
  as_echo='print -r --'
  as_echo_n='print -rn --'
elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
  as_echo='printf %s\n'
  as_echo_n='printf %s'
else
  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
    as_echo_n='/usr/ucb/echo -n'
  else
    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
    as_echo_n_body='eval
      arg=$1;
      case $arg in #(
      *"$as_nl"*)
	expr "X$arg" : "X\\(.*\\)$as_nl";
	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
      esac;
      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
    '
    export as_echo_n_body
    as_echo_n='sh -c $as_echo_n_body as_echo'
  fi
  export as_echo_body
  as_echo='sh -c $as_echo_body as_echo'
fi

# The user is always right.
if test "${PATH_SEPARATOR+set}" != set; then
  PATH_SEPARATOR=:
  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
      PATH_SEPARATOR=';'
  }
fi


# IFS
# We need space, tab and new line, in precisely that order.  Quoting is
# there to prevent editors from complaining about space-tab.
# (If _AS_PATH_WALK were called with IFS unset, it would disable word
# splitting by setting IFS to empty value.)
IFS=" ""	$as_nl"

# Find who we are.  Look in the path if we contain no directory separator.
as_myself=
case $0 in #((
  *[\\/]* ) as_myself=$0 ;;
  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
  IFS=$as_save_IFS
  test -z "$as_dir" && as_dir=.
    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
  done
IFS=$as_save_IFS

     ;;
esac
# We did not find ourselves, most probably we were run as `sh COMMAND'
# in which case we are not to be found in the path.
if test "x$as_myself" = x; then
  as_myself=$0
fi
if test ! -f "$as_myself"; then
  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
  exit 1
fi

# Unset variables that we do not need and which cause bugs (e.g. in
# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
# suppresses any "Segmentation fault" message there.  '((' could
# trigger a bug in pdksh 5.2.14.
for as_var in BASH_ENV ENV MAIL MAILPATH
do eval test x\${$as_var+set} = xset \
  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
done
PS1='$ '
PS2='> '
PS4='+ '

# NLS nuisances.
LC_ALL=C
export LC_ALL
LANGUAGE=C
export LANGUAGE

# CDPATH.
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH


# as_fn_error STATUS ERROR [LINENO LOG_FD]
# ----------------------------------------
# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
# script with STATUS, using 1 if that was 0.
as_fn_error ()
{
  as_status=$1; test $as_status -eq 0 && as_status=1
  if test "$4"; then
    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
  fi
  $as_echo "$as_me: error: $2" >&2
  as_fn_exit $as_status
} # as_fn_error


# as_fn_set_status STATUS
# -----------------------
# Set $? to STATUS, without forking.
as_fn_set_status ()
{
  return $1
} # as_fn_set_status

# as_fn_exit STATUS
# -----------------
# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
as_fn_exit ()
{
  set +e
  as_fn_set_status $1
  exit $1
} # as_fn_exit

# as_fn_unset VAR
# ---------------
# Portably unset VAR.
as_fn_unset ()
{
  { eval $1=; unset $1;}
}
as_unset=as_fn_unset
# as_fn_append VAR VALUE
# ----------------------
# Append the text in VALUE to the end of the definition contained in VAR. Take
# advantage of any shell optimizations that allow amortized linear growth over
# repeated appends, instead of the typical quadratic growth present in naive
# implementations.
if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
  eval 'as_fn_append ()
  {
    eval $1+=\$2
  }'
else
  as_fn_append ()
  {
    eval $1=\$$1\$2
  }
fi # as_fn_append

# as_fn_arith ARG...
# ------------------
# Perform arithmetic evaluation on the ARGs, and store the result in the
# global $as_val. Take advantage of shells that can avoid forks. The arguments
# must be portable across $(()) and expr.
if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
  eval 'as_fn_arith ()
  {
    as_val=$(( $* ))
  }'
else
  as_fn_arith ()
  {
    as_val=`expr "$@" || test $? -eq 1`
  }
fi # as_fn_arith


if expr a : '\(a\)' >/dev/null 2>&1 &&
   test "X`expr 00001 : '.*\(...\)'`" = X001; then
  as_expr=expr
else
  as_expr=false
fi

if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
  as_basename=basename
else
  as_basename=false
fi

if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
  as_dirname=dirname
else
  as_dirname=false
fi

as_me=`$as_basename -- "$0" ||
$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
	 X"$0" : 'X\(//\)$' \| \
	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X/"$0" |
    sed '/^.*\/\([^/][^/]*\)\/*$/{
	    s//\1/
	    q
	  }
	  /^X\/\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\/\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`

# Avoid depending upon Character Ranges.
as_cr_letters='abcdefghijklmnopqrstuvwxyz'
as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
as_cr_Letters=$as_cr_letters$as_cr_LETTERS
as_cr_digits='0123456789'
as_cr_alnum=$as_cr_Letters$as_cr_digits

ECHO_C= ECHO_N= ECHO_T=
case `echo -n x` in #(((((
-n*)
  case `echo 'xy\c'` in
  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
  xy)  ECHO_C='\c';;
  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
       ECHO_T='	';;
  esac;;
*)
  ECHO_N='-n';;
esac

rm -f conf$$ conf$$.exe conf$$.file
if test -d conf$$.dir; then
  rm -f conf$$.dir/conf$$.file
else
  rm -f conf$$.dir
  mkdir conf$$.dir 2>/dev/null
fi
if (echo >conf$$.file) 2>/dev/null; then
  if ln -s conf$$.file conf$$ 2>/dev/null; then
    as_ln_s='ln -s'
    # ... but there are two gotchas:
    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
    # In both cases, we have to default to `cp -pR'.
    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
      as_ln_s='cp -pR'
  elif ln conf$$.file conf$$ 2>/dev/null; then
    as_ln_s=ln
  else
    as_ln_s='cp -pR'
  fi
else
  as_ln_s='cp -pR'
fi
rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
rmdir conf$$.dir 2>/dev/null


# as_fn_mkdir_p
# -------------
# Create "$as_dir" as a directory, including parents if necessary.
as_fn_mkdir_p ()
{

  case $as_dir in #(
  -*) as_dir=./$as_dir;;
  esac
  test -d "$as_dir" || eval $as_mkdir_p || {
    as_dirs=
    while :; do
      case $as_dir in #(
      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
      *) as_qdir=$as_dir;;
      esac
      as_dirs="'$as_qdir' $as_dirs"
      as_dir=`$as_dirname -- "$as_dir" ||
$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	 X"$as_dir" : 'X\(//\)[^/]' \| \
	 X"$as_dir" : 'X\(//\)$' \| \
	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$as_dir" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)[^/].*/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`
      test -d "$as_dir" && break
    done
    test -z "$as_dirs" || eval "mkdir $as_dirs"
  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"


} # as_fn_mkdir_p
if mkdir -p . 2>/dev/null; then
  as_mkdir_p='mkdir -p "$as_dir"'
else
  test -d ./-p && rmdir ./-p
  as_mkdir_p=false
fi


# as_fn_executable_p FILE
# -----------------------
# Test if FILE is an executable regular file.
as_fn_executable_p ()
{
  test -f "$1" && test -x "$1"
} # as_fn_executable_p
as_test_x='test -x'
as_executable_p=as_fn_executable_p

# Sed expression to map a string onto a valid CPP name.
as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"

# Sed expression to map a string onto a valid variable name.
as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"


exec 6>&1
## ----------------------------------- ##
## Main body of $CONFIG_STATUS script. ##
## ----------------------------------- ##
_ASEOF
test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1

cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# Save the log message, to keep $0 and so on meaningful, and to
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by ht $as_me 2.0.22, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  CONFIG_FILES    = $CONFIG_FILES
  CONFIG_HEADERS  = $CONFIG_HEADERS
  CONFIG_LINKS    = $CONFIG_LINKS
  CONFIG_COMMANDS = $CONFIG_COMMANDS
  $ $0 $@

on `(hostname || uname -n) 2>/dev/null | sed 1q`
"

_ACEOF

case $ac_config_files in *"
"*) set x $ac_config_files; shift; ac_config_files=$*;;
esac

case $ac_config_headers in *"
"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
esac


cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
# Files that config.status was made for.
config_files="$ac_config_files"
config_headers="$ac_config_headers"
config_commands="$ac_config_commands"

_ACEOF

cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
ac_cs_usage="\
\`$as_me' instantiates files and other configuration actions
from templates according to the current configuration.  Unless the files
and actions are specified as TAGs, all are instantiated by default.

Usage: $0 [OPTION]... [TAG]...

  -h, --help       print this help, then exit
  -V, --version    print version number and configuration settings, then exit
      --config     print configuration, then exit
  -q, --quiet, --silent
                   do not print progress messages
  -d, --debug      don't remove temporary files
      --recheck    update $as_me by reconfiguring in the same conditions
      --file=FILE[:TEMPLATE]
                   instantiate the configuration file FILE
      --header=FILE[:TEMPLATE]
                   instantiate the configuration header FILE

Configuration files:
$config_files

Configuration headers:
$config_headers

Configuration commands:
$config_commands

Report bugs to ."

_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
ht config.status 2.0.22
configured by $0, generated by GNU Autoconf 2.69,
  with options \\"\$ac_cs_config\\"

Copyright (C) 2012 Free Software Foundation, Inc.
This config.status script is free software; the Free Software Foundation
gives unlimited permission to copy, distribute and modify it."

ac_pwd='$ac_pwd'
srcdir='$srcdir'
INSTALL='$INSTALL'
MKDIR_P='$MKDIR_P'
AWK='$AWK'
test -n "\$AWK" || AWK=awk
_ACEOF

cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# The default lists apply if the user does not specify any file.
ac_need_defaults=:
while test $# != 0
do
  case $1 in
  --*=?*)
    ac_option=`expr "X$1" : 'X\([^=]*\)='`
    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
    ac_shift=:
    ;;
  --*=)
    ac_option=`expr "X$1" : 'X\([^=]*\)='`
    ac_optarg=
    ac_shift=:
    ;;
  *)
    ac_option=$1
    ac_optarg=$2
    ac_shift=shift
    ;;
  esac

  case $ac_option in
  # Handling of the options.
  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
    ac_cs_recheck=: ;;
  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
    $as_echo "$ac_cs_version"; exit ;;
  --config | --confi | --conf | --con | --co | --c )
    $as_echo "$ac_cs_config"; exit ;;
  --debug | --debu | --deb | --de | --d | -d )
    debug=: ;;
  --file | --fil | --fi | --f )
    $ac_shift
    case $ac_optarg in
    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
    '') as_fn_error $? "missing file argument" ;;
    esac
    as_fn_append CONFIG_FILES " '$ac_optarg'"
    ac_need_defaults=false;;
  --header | --heade | --head | --hea )
    $ac_shift
    case $ac_optarg in
    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
    esac
    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
    ac_need_defaults=false;;
  --he | --h)
    # Conflict between --help and --header
    as_fn_error $? "ambiguous option: \`$1'
Try \`$0 --help' for more information.";;
  --help | --hel | -h )
    $as_echo "$ac_cs_usage"; exit ;;
  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
  | -silent | --silent | --silen | --sile | --sil | --si | --s)
    ac_cs_silent=: ;;

  # This is an error.
  -*) as_fn_error $? "unrecognized option: \`$1'
Try \`$0 --help' for more information." ;;

  *) as_fn_append ac_config_targets " $1"
     ac_need_defaults=false ;;

  esac
  shift
done

ac_configure_extra_args=

if $ac_cs_silent; then
  exec 6>/dev/null
  ac_configure_extra_args="$ac_configure_extra_args --silent"
fi

_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
if \$ac_cs_recheck; then
  set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
  shift
  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
  CONFIG_SHELL='$SHELL'
  export CONFIG_SHELL
  exec "\$@"
fi

_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
exec 5>>config.log
{
  echo
  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
## Running $as_me. ##
_ASBOX
  $as_echo "$ac_log"
} >&5

_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
#
# INIT-COMMANDS
#
AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"

_ACEOF

cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1

# Handling of arguments.
for ac_config_target in $ac_config_targets
do
  case $ac_config_target in
    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
    "analyser/Makefile") CONFIG_FILES="$CONFIG_FILES analyser/Makefile" ;;
    "asm/Makefile") CONFIG_FILES="$CONFIG_FILES asm/Makefile" ;;
    "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
    "eval/Makefile") CONFIG_FILES="$CONFIG_FILES eval/Makefile" ;;
    "info/Makefile") CONFIG_FILES="$CONFIG_FILES info/Makefile" ;;
    "io/Makefile") CONFIG_FILES="$CONFIG_FILES io/Makefile" ;;
    "io/posix/Makefile") CONFIG_FILES="$CONFIG_FILES io/posix/Makefile" ;;
    "io/djgpp/Makefile") CONFIG_FILES="$CONFIG_FILES io/djgpp/Makefile" ;;
    "io/win32/Makefile") CONFIG_FILES="$CONFIG_FILES io/win32/Makefile" ;;
    "minilzo/Makefile") CONFIG_FILES="$CONFIG_FILES minilzo/Makefile" ;;
    "output/Makefile") CONFIG_FILES="$CONFIG_FILES output/Makefile" ;;
    "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;;

  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
  esac
done


# If the user did not use the arguments to specify the items to instantiate,
# then the envvar interface is used.  Set only those that are not.
# We use the long form for the default assignment because of an extremely
# bizarre bug on SunOS 4.1.3.
if $ac_need_defaults; then
  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
fi

# Have a temporary directory for convenience.  Make it in the build tree
# simply because there is no reason against having it here, and in addition,
# creating and moving files from /tmp can sometimes cause problems.
# Hook for its removal unless debugging.
# Note that there is a small window in which the directory will not be cleaned:
# after its creation but before its name has been assigned to `$tmp'.
$debug ||
{
  tmp= ac_tmp=
  trap 'exit_status=$?
  : "${ac_tmp:=$tmp}"
  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
' 0
  trap 'as_fn_exit 1' 1 2 13 15
}
# Create a (secure) tmp directory for tmp files.

{
  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
  test -d "$tmp"
}  ||
{
  tmp=./conf$$-$RANDOM
  (umask 077 && mkdir "$tmp")
} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
ac_tmp=$tmp

# Set up the scripts for CONFIG_FILES section.
# No need to generate them if there are no CONFIG_FILES.
# This happens for instance with `./config.status config.h'.
if test -n "$CONFIG_FILES"; then


ac_cr=`echo X | tr X '\015'`
# On cygwin, bash can eat \r inside `` if the user requested igncr.
# But we know of no other shell where ac_cr would be empty at this
# point, so we can use a bashism as a fallback.
if test "x$ac_cr" = x; then
  eval ac_cr=\$\'\\r\'
fi
ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null`
if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
  ac_cs_awk_cr='\\r'
else
  ac_cs_awk_cr=$ac_cr
fi

echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
_ACEOF


{
  echo "cat >conf$$subs.awk <<_ACEOF" &&
  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
  echo "_ACEOF"
} >conf$$subs.sh ||
  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
ac_delim='%!_!# '
for ac_last_try in false false false false false :; do
  . ./conf$$subs.sh ||
    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5

  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
  if test $ac_delim_n = $ac_delim_num; then
    break
  elif $ac_last_try; then
    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
  else
    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
  fi
done
rm -f conf$$subs.sh

cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
_ACEOF
sed -n '
h
s/^/S["/; s/!.*/"]=/
p
g
s/^[^!]*!//
:repl
t repl
s/'"$ac_delim"'$//
t delim
:nl
h
s/\(.\{148\}\)..*/\1/
t more1
s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
p
n
b repl
:more1
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t nl
:delim
h
s/\(.\{148\}\)..*/\1/
t more2
s/["\\]/\\&/g; s/^/"/; s/$/"/
p
b
:more2
s/["\\]/\\&/g; s/^/"/; s/$/"\\/
p
g
s/.\{148\}//
t delim
' >$CONFIG_STATUS || ac_write_fail=1
rm -f conf$$subs.awk
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
_ACAWK
cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
  for (key in S) S_is_set[key] = 1
  FS = ""

}
{
  line = $ 0
  nfields = split(line, field, "@")
  substed = 0
  len = length(field[1])
  for (i = 2; i < nfields; i++) {
    key = field[i]
    keylen = length(key)
    if (S_is_set[key]) {
      value = S[key]
      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
      len += length(value) + length(field[++i])
      substed = 1
    } else
      len += 1 + keylen
  }

  print line
}

_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
else
  cat
fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
_ACEOF

# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
# trailing colons and then remove the whole line if VPATH becomes empty
# (actually we leave an empty line to preserve line numbers).
if test "x$srcdir" = x.; then
  ac_vpsub='/^[	 ]*VPATH[	 ]*=[	 ]*/{
h
s///
s/^/:/
s/[	 ]*$/:/
s/:\$(srcdir):/:/g
s/:\${srcdir}:/:/g
s/:@srcdir@:/:/g
s/^:*//
s/:*$//
x
s/\(=[	 ]*\).*/\1/
G
s/\n//
s/^[^=]*=[	 ]*$//
}'
fi

cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
fi # test -n "$CONFIG_FILES"

# Set up the scripts for CONFIG_HEADERS section.
# No need to generate them if there are no CONFIG_HEADERS.
# This happens for instance with `./config.status Makefile'.
if test -n "$CONFIG_HEADERS"; then
cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
BEGIN {
_ACEOF

# Transform confdefs.h into an awk script `defines.awk', embedded as
# here-document in config.status, that substitutes the proper values into
# config.h.in to produce config.h.

# Create a delimiter string that does not exist in confdefs.h, to ease
# handling of long lines.
ac_delim='%!_!# '
for ac_last_try in false false :; do
  ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
  if test -z "$ac_tt"; then
    break
  elif $ac_last_try; then
    as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
  else
    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
  fi
done

# For the awk script, D is an array of macro values keyed by name,
# likewise P contains macro parameters if any.  Preserve backslash
# newline sequences.

ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
sed -n '
s/.\{148\}/&'"$ac_delim"'/g
t rset
:rset
s/^[	 ]*#[	 ]*define[	 ][	 ]*/ /
t def
d
:def
s/\\$//
t bsnl
s/["\\]/\\&/g
s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
D["\1"]=" \3"/p
s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2"/p
d
:bsnl
s/["\\]/\\&/g
s/^ \('"$ac_word_re"'\)\(([^()]*)\)[	 ]*\(.*\)/P["\1"]="\2"\
D["\1"]=" \3\\\\\\n"\\/p
t cont
s/^ \('"$ac_word_re"'\)[	 ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
t cont
d
:cont
n
s/.\{148\}/&'"$ac_delim"'/g
t clear
:clear
s/\\$//
t bsnlc
s/["\\]/\\&/g; s/^/"/; s/$/"/p
d
:bsnlc
s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
b cont
' >$CONFIG_STATUS || ac_write_fail=1

cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
  for (key in D) D_is_set[key] = 1
  FS = ""
}
/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
  line = \$ 0
  split(line, arg, " ")
  if (arg[1] == "#") {
    defundef = arg[2]
    mac1 = arg[3]
  } else {
    defundef = substr(arg[1], 2)
    mac1 = arg[2]
  }
  split(mac1, mac2, "(") #)
  macro = mac2[1]
  prefix = substr(line, 1, index(line, defundef) - 1)
  if (D_is_set[macro]) {
    # Preserve the white space surrounding the "#".
    print prefix "define", macro P[macro] D[macro]
    next
  } else {
    # Replace #undef with comments.  This is necessary, for example,
    # in the case of _POSIX_SOURCE, which is predefined and required
    # on some systems where configure will not decide to define it.
    if (defundef == "undef") {
      print "/*", prefix defundef, macro, "*/"
      next
    }
  }
}
{ print }
_ACAWK
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
  as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
fi # test -n "$CONFIG_HEADERS"


eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
shift
for ac_tag
do
  case $ac_tag in
  :[FHLC]) ac_mode=$ac_tag; continue;;
  esac
  case $ac_mode$ac_tag in
  :[FHL]*:*);;
  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
  :[FH]-) ac_tag=-:-;;
  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
  esac
  ac_save_IFS=$IFS
  IFS=:
  set x $ac_tag
  IFS=$ac_save_IFS
  shift
  ac_file=$1
  shift

  case $ac_mode in
  :L) ac_source=$1;;
  :[FH])
    ac_file_inputs=
    for ac_f
    do
      case $ac_f in
      -) ac_f="$ac_tmp/stdin";;
      *) # Look for the file first in the build tree, then in the source tree
	 # (if the path is not absolute).  The absolute path cannot be DOS-style,
	 # because $ac_f cannot contain `:'.
	 test -f "$ac_f" ||
	   case $ac_f in
	   [\\/$]*) false;;
	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
	   esac ||
	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
      esac
      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
      as_fn_append ac_file_inputs " '$ac_f'"
    done

    # Let's still pretend it is `configure' which instantiates (i.e., don't
    # use $as_me), people would be surprised to read:
    #    /* config.h.  Generated by config.status.  */
    configure_input='Generated from '`
	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
	`' by configure.'
    if test x"$ac_file" != x-; then
      configure_input="$ac_file.  $configure_input"
      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
$as_echo "$as_me: creating $ac_file" >&6;}
    fi
    # Neutralize special characters interpreted by sed in replacement strings.
    case $configure_input in #(
    *\&* | *\|* | *\\* )
       ac_sed_conf_input=`$as_echo "$configure_input" |
       sed 's/[\\\\&|]/\\\\&/g'`;; #(
    *) ac_sed_conf_input=$configure_input;;
    esac

    case $ac_tag in
    *:-:* | *:-) cat >"$ac_tmp/stdin" \
      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
    esac
    ;;
  esac

  ac_dir=`$as_dirname -- "$ac_file" ||
$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	 X"$ac_file" : 'X\(//\)[^/]' \| \
	 X"$ac_file" : 'X\(//\)$' \| \
	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$ac_file" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)[^/].*/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`
  as_dir="$ac_dir"; as_fn_mkdir_p
  ac_builddir=.

case "$ac_dir" in
.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
*)
  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
  # A ".." for each directory in $ac_dir_suffix.
  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
  case $ac_top_builddir_sub in
  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
  esac ;;
esac
ac_abs_top_builddir=$ac_pwd
ac_abs_builddir=$ac_pwd$ac_dir_suffix
# for backward compatibility:
ac_top_builddir=$ac_top_build_prefix

case $srcdir in
  .)  # We are building in place.
    ac_srcdir=.
    ac_top_srcdir=$ac_top_builddir_sub
    ac_abs_top_srcdir=$ac_pwd ;;
  [\\/]* | ?:[\\/]* )  # Absolute name.
    ac_srcdir=$srcdir$ac_dir_suffix;
    ac_top_srcdir=$srcdir
    ac_abs_top_srcdir=$srcdir ;;
  *) # Relative name.
    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
    ac_top_srcdir=$ac_top_build_prefix$srcdir
    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
esac
ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix


  case $ac_mode in
  :F)
  #
  # CONFIG_FILE
  #

  case $INSTALL in
  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
  esac
  ac_MKDIR_P=$MKDIR_P
  case $MKDIR_P in
  [\\/$]* | ?:[\\/]* ) ;;
  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
  esac
_ACEOF

cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# If the template does not know about datarootdir, expand it.
# FIXME: This hack should be removed a few years after 2.60.
ac_datarootdir_hack=; ac_datarootdir_seen=
ac_sed_dataroot='
/datarootdir/ {
  p
  q
}
/@datadir@/p
/@docdir@/p
/@infodir@/p
/@localedir@/p
/@mandir@/p'
case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
*datarootdir*) ac_datarootdir_seen=yes;;
*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
  ac_datarootdir_hack='
  s&@datadir@&$datadir&g
  s&@docdir@&$docdir&g
  s&@infodir@&$infodir&g
  s&@localedir@&$localedir&g
  s&@mandir@&$mandir&g
  s&\\\${datarootdir}&$datarootdir&g' ;;
esac
_ACEOF

# Neutralize VPATH when `$srcdir' = `.'.
# Shell code in configure.ac might set extrasub.
# FIXME: do we really want to maintain this feature?
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_sed_extra="$ac_vpsub
$extrasub
_ACEOF
cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
:t
/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
s|@configure_input@|$ac_sed_conf_input|;t t
s&@top_builddir@&$ac_top_builddir_sub&;t t
s&@top_build_prefix@&$ac_top_build_prefix&;t t
s&@srcdir@&$ac_srcdir&;t t
s&@abs_srcdir@&$ac_abs_srcdir&;t t
s&@top_srcdir@&$ac_top_srcdir&;t t
s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
s&@builddir@&$ac_builddir&;t t
s&@abs_builddir@&$ac_abs_builddir&;t t
s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
s&@INSTALL@&$ac_INSTALL&;t t
s&@MKDIR_P@&$ac_MKDIR_P&;t t
$ac_datarootdir_hack
"
eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5

test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \
      "$ac_tmp/out"`; test -z "$ac_out"; } &&
  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined.  Please make sure it is defined" >&5
$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
which seems to be undefined.  Please make sure it is defined" >&2;}

  rm -f "$ac_tmp/stdin"
  case $ac_file in
  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
  esac \
  || as_fn_error $? "could not create $ac_file" "$LINENO" 5
 ;;
  :H)
  #
  # CONFIG_HEADER
  #
  if test x"$ac_file" != x-; then
    {
      $as_echo "/* $configure_input  */" \
      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
    } >"$ac_tmp/config.h" \
      || as_fn_error $? "could not create $ac_file" "$LINENO" 5
    if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
$as_echo "$as_me: $ac_file is unchanged" >&6;}
    else
      rm -f "$ac_file"
      mv "$ac_tmp/config.h" "$ac_file" \
	|| as_fn_error $? "could not create $ac_file" "$LINENO" 5
    fi
  else
    $as_echo "/* $configure_input  */" \
      && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
      || as_fn_error $? "could not create -" "$LINENO" 5
  fi
# Compute "$ac_file"'s index in $config_headers.
_am_arg="$ac_file"
_am_stamp_count=1
for _am_header in $config_headers :; do
  case $_am_header in
    $_am_arg | $_am_arg:* )
      break ;;
    * )
      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
  esac
done
echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	 X"$_am_arg" : 'X\(//\)[^/]' \| \
	 X"$_am_arg" : 'X\(//\)$' \| \
	 X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$_am_arg" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)[^/].*/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`/stamp-h$_am_stamp_count
 ;;

  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
$as_echo "$as_me: executing $ac_file commands" >&6;}
 ;;
  esac


  case $ac_file$ac_mode in
    "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
  # Autoconf 2.62 quotes --file arguments for eval, but not when files
  # are listed without --file.  Let's play safe and only enable the eval
  # if we detect the quoting.
  case $CONFIG_FILES in
  *\'*) eval set x "$CONFIG_FILES" ;;
  *)   set x $CONFIG_FILES ;;
  esac
  shift
  for mf
  do
    # Strip MF so we end up with the name of the file.
    mf=`echo "$mf" | sed -e 's/:.*$//'`
    # Check whether this is an Automake generated Makefile or not.
    # We used to match only the files named `Makefile.in', but
    # some people rename them; so instead we look at the file content.
    # Grep'ing the first line is not enough: some people post-process
    # each Makefile.in and add a new line on top of each file to say so.
    # Grep'ing the whole file is not good either: AIX grep has a line
    # limit of 2048, but all sed's we know have understand at least 4000.
    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
      dirpart=`$as_dirname -- "$mf" ||
$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	 X"$mf" : 'X\(//\)[^/]' \| \
	 X"$mf" : 'X\(//\)$' \| \
	 X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$mf" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)[^/].*/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`
    else
      continue
    fi
    # Extract the definition of DEPDIR, am__include, and am__quote
    # from the Makefile without running `make'.
    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
    test -z "$DEPDIR" && continue
    am__include=`sed -n 's/^am__include = //p' < "$mf"`
    test -z "am__include" && continue
    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
    # When using ansi2knr, U may be empty or an underscore; expand it
    U=`sed -n 's/^U = //p' < "$mf"`
    # Find all dependency output files, they are included files with
    # $(DEPDIR) in their names.  We invoke sed twice because it is the
    # simplest approach to changing $(DEPDIR) to its actual value in the
    # expansion.
    for file in `sed -n "
      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
      # Make sure the directory exists.
      test -f "$dirpart/$file" && continue
      fdir=`$as_dirname -- "$file" ||
$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
	 X"$file" : 'X\(//\)[^/]' \| \
	 X"$file" : 'X\(//\)$' \| \
	 X"$file" : 'X\(/\)' \| . 2>/dev/null ||
$as_echo X"$file" |
    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)[^/].*/{
	    s//\1/
	    q
	  }
	  /^X\(\/\/\)$/{
	    s//\1/
	    q
	  }
	  /^X\(\/\).*/{
	    s//\1/
	    q
	  }
	  s/.*/./; q'`
      as_dir=$dirpart/$fdir; as_fn_mkdir_p
      # echo "creating $dirpart/$file"
      echo '# dummy' > "$dirpart/$file"
    done
  done
}
 ;;

  esac
done # for ac_tag


as_fn_exit 0
_ACEOF
ac_clean_files=$ac_clean_files_save

test $ac_write_fail = 0 ||
  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5


# configure is writing to config.log, and then calls config.status.
# config.status does its own redirection, appending to config.log.
# Unfortunately, on DOS this fails, as config.log is still kept open
# by configure, so config.status won't be able to write to it; its
# output is simply discarded.  So we exec the FD to /dev/null,
# effectively closing config.log, so it can be properly (re)opened and
# appended to by config.status.  When coming back to configure, we
# need to make the FD available again.
if test "$no_create" != yes; then
  ac_cs_success=:
  ac_config_status_args=
  test "$silent" = yes &&
    ac_config_status_args="$ac_config_status_args --quiet"
  exec 5>/dev/null
  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
  exec 5>>config.log
  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
  # would make configure fail if this is the last instruction.
  $ac_cs_success || as_fn_exit 1
fi
if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi


echo 1>&2
echo "$0 successful." 1>&2
echo 1>&2
echo "=====================" 1>&2
echo "Configuration summary" 1>&2
echo "=====================" 1>&2
echo 1>&2
if test "x$HAVE_X11" = "x1"; then
	echo "X11 textmode support available:   yes" 1>&2
else
	echo "X11 textmode support available:   no" 1>&2
fi
echo "enable profiling:                 $enable_profiling" 1>&2
echo "make a release build:             $enable_release" 1>&2
echo "using included minilzo:           $minilzo_enabled" 1>&2
ht-2.0.22/vxdserv.h0000644000175000001440000000616510206756711011014 00000000000000/* 
 *	HT Editor
 *	vxdserv.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __VXDSERV_H__
#define __VXDSERV_H__

extern vxd_service_desc vxd_vmm_services[];
extern vxd_service_desc vxd_debug_services[];
extern vxd_service_desc vxd_vpicd_services[];
extern vxd_service_desc vxd_vdmad_services[];
extern vxd_service_desc vxd_vtd_services[];
extern vxd_service_desc vxd_v86mmgr_services[];
extern vxd_service_desc vxd_pageswap_services[];
extern vxd_service_desc vxd_vdd_services[];
extern vxd_service_desc vxd_vsd_services[];
extern vxd_service_desc vxd_vmd_services[];
extern vxd_service_desc vxd_vkd_services[];
extern vxd_service_desc vxd_vcd_services[];
extern vxd_service_desc vxd_vpd_services[];
extern vxd_service_desc vxd_ios_services[];
extern vxd_service_desc vxd_vmcpd_services[];
extern vxd_service_desc vxd_ebios_services[];
extern vxd_service_desc vxd_vnetbios_services[];
extern vxd_service_desc vxd_dosmgr_services[];
extern vxd_service_desc vxd_shell_services[];
extern vxd_service_desc vxd_vmpool_services[];
extern vxd_service_desc vxd_dosnet_services[];
extern vxd_service_desc vxd_int13_services[];
extern vxd_service_desc vxd_pagefile_services[];
extern vxd_service_desc vxd_vpowerd_services[];
extern vxd_service_desc vxd_vxdldr_services[];
extern vxd_service_desc vxd_ndis_services[];
extern vxd_service_desc vxd_vwin32_services[];
extern vxd_service_desc vxd_vcomm_services[];
extern vxd_service_desc vxd_configmg_services[];
extern vxd_service_desc vxd_cm_services[];
extern vxd_service_desc vxd_vfbackup_services[];
extern vxd_service_desc vxd_vmini_services[];
extern vxd_service_desc vxd_vcond_services[];
extern vxd_service_desc vxd_wsock_services[];
extern vxd_service_desc vxd_ifsmgr_services[];
extern vxd_service_desc vxd_pci_services[];
extern vxd_service_desc vxd_perf_services[];
extern vxd_service_desc vxd_mtrr_services[];
extern vxd_service_desc vxd_ntkern_services[];
extern vxd_service_desc vxd_acpi_services[];
extern vxd_service_desc vxd_smclib_services[];
extern vxd_service_desc vxd_vflatd_services[];
extern vxd_service_desc vxd_vjoyd_services[];
extern vxd_service_desc vxd_mmdevldr_services[];
extern vxd_service_desc vxd_vnetsup_services[];
extern vxd_service_desc vxd_vredir_services[];
extern vxd_service_desc vxd_vshare_services[];
extern vxd_service_desc vxd_vtdi_services[];
extern vxd_service_desc vxd_vip_services[];
extern vxd_service_desc vxd_mstcp_services[];
extern vxd_service_desc vxd_vcache_services[];
extern vxd_service_desc vxd_pccard_services[];

#endif /* __VXDSERV_H_ */

ht-2.0.22/htapp.cc0000644000175000017500000022203212127651417010563 00000000000000/*
 *	HT Editor
 *	htapp.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "analy.h"
#include "cmds.h"
#include "log.h"
#include "mfile.h"
#include "htapp.h"
#include "atom.h"
#include "display.h"
#include "htcfg.h"
#include "htclipboard.h"
#include "htdialog.h"
#include "hteval.h"
#include "hthist.h"
#include "htidle.h"
#include "htinfo.h"
#include "htiobox.h"
#include "keyb.h"
#include "htmenu.h"
#include "htpal.h"
#include "htsearch.h"
#include "strtools.h"
#include "sys.h"
#include "httree.h"
#include "infoview.h"
#include "snprintf.h"
#include "stream.h"
#include "textedit.h"
#include "textfile.h"
#include "tools.h"

#include "vfsview.h"

#include "formats.h"

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

extern "C" {
#include "regex.h"
}

#define ATOM_HT_APP			MAGIC32("APP\x00")
#define ATOM_HT_PROJECT			MAGIC32("APP\x01")
#define ATOM_HT_PROJECT_ITEM		MAGIC32("APP\x02")
#define ATOM_COMPARE_KEYS_PROJECT_ITEM	MAGIC32("APP\x10")

#define HT_PROJECT_CONFIG_SUFFIX     	".htprj"
#define HT_FILE_CONFIG_SUFFIX 		".htcfg"

ht_log *loglines;

/*
 *	CLASS ht_help_window
 */

class ht_help_window : public ht_window {
public:
/* overwritten */
	virtual void handlemsg(htmsg *msg);
};

void ht_help_window::handlemsg(htmsg *msg)
{
	ht_window::handlemsg(msg);
	if (msg->msg == msg_keypressed) {
		switch (msg->data1.integer) {
		case K_Escape: {
			htmsg m;
			m.type = mt_empty;
			m.msg = cmd_window_close;
			((ht_app*)app)->queuemsg(app, m);
			clearmsg(msg);
			return;
		}				
		}				
	}
}

bool file_new_dialog(uint *mode)
{
	Bounds b, c;
	
	app->getbounds(&b);

	b.x = (b.w - 40) / 2,
	b.y = (b.h - 8) / 2;
	b.w = 40;
	b.h = 8;
	
	ht_dialog *d=new ht_dialog();
	d->init(&b, "create new file", FS_KILLER | FS_TITLE | FS_MOVE | FS_RESIZE);
	
	b.x=0;
	b.y=0;
		
	/* mode (input) */
	c=b;
	c.x=0;
	c.y=1;
	c.w=b.w-2-c.x;
	c.h=b.h-2-c.y;

	ht_text_listbox *mode_input = new ht_text_listbox();
	mode_input->init(&c);
	
	mode_input->insert_str(FOM_TEXT, "text");
	mode_input->insert_str(FOM_BIN, "binary");
	mode_input->update();

	d->insert(mode_input);
	
	/* mode (text) */
	c=b;
	c.x=0;
	c.y=0;
	c.w=12;
	c.h=1;

	ht_label *mode_text=new ht_label();
	mode_text->init(&c, "choose ~type", mode_input);

	d->insert(mode_text);

	bool retval = false;
	if (d->run(false)) {
		ht_listbox_data type;

		ViewDataBuf vdb(mode_input, &type, sizeof type);

		*mode = mode_input->getID(type.data->cursor_ptr);
		
		retval = true;
	}

	d->done();
	delete d;
	return retval;
}

/*
 *	class FileBrowserVfsListbox
 */
 
class FileBrowser;

#define FileBrowserVfsListboxData VfsListboxData

class FileBrowserVfsListbox: public VfsListbox {
protected:
	FileBrowser *file_browser;
public:
		void init(Bounds *b, List *vfs_list, ht_text *show_pos, FileBrowser *file_browser);
/* overwritten */
	virtual	void stateChanged();
};

/*
 *	class FileBrowser
 */
 
struct FileBrowserData {
	ht_strinputfield_data name;
	ht_listbox_data listbox;
};

class FileBrowser: public ht_dialog {
protected:
	ht_strinputfield *name_input;
	FileBrowserVfsListbox *listbox;
public:
	virtual	void init(Bounds *b, Bounds *clientarea, const char *title, const char *starturl);
	virtual void setstate(int state, int return_val);
	virtual	bool extract_url(char *buf);
	virtual	void listbox_changed();
};

/**/
void	FileBrowserVfsListbox::init(Bounds *b, List *vfs_list, ht_text *show_pos, FileBrowser *fb)
{
	file_browser = NULL;
	VfsListbox::init(b, vfs_list, show_pos);
	file_browser = fb;
}

void FileBrowserVfsListbox::stateChanged()
{
	if (file_browser) file_browser->listbox_changed();
	VfsListbox::stateChanged();
}

/**/
void FileBrowser::init(Bounds *n, Bounds *clientarea, const char *title, const char *starturl)
{
	ht_dialog::init(n, title, FS_KILLER | FS_TITLE | FS_MOVE | FS_RESIZE);
	Bounds b = *clientarea, c;

	/* name (input) */
	c = b;
	c.x = 1;
	c.y = 1;
	c.w -= 2;
	c.h = 1;

	List *hist = (List*)getAtomValue(HISTATOM_FILE);
	
	name_input = new ht_strinputfield();
	name_input->init(&c, 128, hist);

	insert(name_input);
	
	/* name (text) */
	c = b;
	c.x = 1;
	c.y = 0;
	c.w = 9;
	c.h = 1;

	ht_label *name_text = new ht_label();
	name_text->init(&c, "~name", name_input);

	insert(name_text);

	/* vfslistbox */
	c = b;
	c.x = 1;
	c.y = 4;
	c.w -= 2;
	c.h -= 4;
	listbox = new FileBrowserVfsListbox();
	listbox->init(&c, virtual_fs_list, NULL, this);
	listbox->changeURL(starturl);

	insert(listbox);

	/* vfslistbox (text) */
	c.assign(1, 3, 9, 1);

	ht_label *name_listbox = new ht_label();
	name_listbox->init(&c, "~files", listbox);

	insert(name_listbox);
}

bool FileBrowser::extract_url(char *buf)
{
	ht_strinputfield_data i;
	ViewDataBuf vdb(name_input, &i, sizeof i);
/*	ht_text_listbox_item *t = (ht_text_listbox_item*)listbox->getbyid(d.listbox.cursor_id);
	vfs_extra *x = (vfs_extra*)t->extra_data;*/
	Vfs *vfs = listbox->getCurVfs();
	if (vfs) {
		char fname[VFS_URL_MAX];
		String res;
		bin2str(fname, i.text, i.textlen);
		vfs->canonicalize(res, fname, listbox->getCurDir());
		int buflen = ht_snprintf(buf, VFS_URL_MAX, "%s:%y", listbox->getCurProto(), &res);
		return true;
	}
	return false;
}

void FileBrowser::listbox_changed()
{
	FileBrowserVfsListboxData l;
	ViewDataBuf vdb(listbox, &l, sizeof l);
	ht_text_listbox_item *t = (ht_text_listbox_item*)l.data->cursor_ptr;
	if (t) {
		vfs_extra *x = (vfs_extra*)t->extra_data;
		ht_strinputfield_data i;
		i.textlen = strlen(x->name);
		i.text = (byte*)x->name;
		name_input->databuf_set(&i, sizeof i);
	}
}

void FileBrowser::setstate(int state, int return_val)
{
	if (state == ds_term_ok) {
		ht_strinputfield_data i;
		ViewDataBuf vdb(name_input, &i, sizeof i);
		pstat_t s;
		String fn(i.text, i.textlen);
		int e = sys_pstat(s, fn.contentChar());
		if (e == 0 && (s.caps & pstat_mode_type) && (s.mode & HT_S_IFDIR)) {
			fn.prepend("local:");
			listbox->changeURL(fn.contentChar());
			return;
		}
	} 
	ht_dialog::setstate(state, return_val);
}

/**/

bool file_chooser(const char *title, char *buf, int bufsize)
{
	Bounds b, c;
	
	app->getbounds(&b);

	c = b;
	b.w = 60;
	b.h = 20;
	b.x = (c.w - b.w) / 2,
	b.y = (c.h - b.h) / 2;

	c = b;
	c.x = 0;
	c.y = 0;
	c.w -= 2;
	c.h -= 3;

	// FIXME: hacked!
	char cwd[HT_NAME_MAX];
	strcpy(cwd, "local:");
	if (!getcwd(cwd+6, (sizeof cwd)-6)) {
		cwd[6] = 0;
	}

	FileBrowser *d = new FileBrowser();
	d->init(&b, &c, title, cwd);

	List *hist = (List*)getAtomValue(HISTATOM_FILE);

	/* go! */
	if (d->run(false)) {
		char b[VFS_URL_MAX];
		d->extract_url(b);

		// FIXME: urls not fully supported...
		if (ht_strncmp(b, "local:", 6) == 0) {
			ht_strlcpy(buf, b+6, bufsize);
			if (hist) insert_history_entry(hist, buf, 0);

			d->done();
			delete d;
			return true;
		}
	}
	d->done();
	delete d;
	return false;
}
/**/

bool file_open_dialog(char **name, uint *mode)
{
	Bounds b, c;
	
	app->getbounds(&b);

	c = b;
	b.w = 60;
	b.h = 20;
	b.x = (c.w - b.w) / 2,
	b.y = (c.h - b.h) / 2;

	c = b;
	c.x = 0;
	c.y = 0;
	c.w -= 2;
	c.h -= 5;

	// FIXME: hacked!
	char cwd[HT_NAME_MAX];
	strcpy(cwd, "local:");
	if (!getcwd(cwd+6, (sizeof cwd)-6)) {
		cwd[6] = 0;
	}

	FileBrowser *d = new FileBrowser();
	d->init(&b, &c, "open file", cwd);
	
	List *hist = (List*)getAtomValue(HISTATOM_FILE);
	
	/* mode (input) */
	c = b;
	c.x = 6;
	c.y = b.h-4;
	c.w = 12;
	c.h = 1;

	ht_listpopup *mode_input = new ht_listpopup();
	mode_input->init(&c);
	
	mode_input->insertstring("autodetect");
	mode_input->insertstring("binary");
	mode_input->insertstring("text");
	
	mode_input->growmode = MK_GM(GMH_LEFT, GMV_BOTTOM);
	
	d->insert(mode_input);
	
	/* mode (text) */
	c = b;
	c.x = 1;
	c.y = b.h-4;
	c.w = 9;
	c.h = 1;

	ht_label *mode_text = new ht_label();
	mode_text->init(&c, "~mode", mode_input);
	mode_text->growmode = MK_GM(GMH_LEFT, GMV_BOTTOM);

	d->insert(mode_text);

	/* go! */
	if (d->run(false)) {
		struct {
			FileBrowserData browser;
			ht_listpopup_data mode;
		} data;

		ViewDataBuf vdb(d, &data, sizeof data);

		char buf[VFS_URL_MAX];
		d->extract_url(buf);

		// FIXME: urls not fully supported...
		if (ht_strncmp(buf, "local:", 6) == 0) {
			*name = ht_strdup(buf+6);

			if (hist) insert_history_entry(hist, *name, 0);

			switch (data.mode.cursor_pos) {
				case 0: *mode=FOM_AUTO; break;
				case 1: *mode=FOM_BIN; break;
				case 2: *mode=FOM_TEXT; break;
			}

			d->done();
			delete d;
			return true;
		}
	}
	d->done();
	delete d;
	return false;
}

static uint autodetect_file_open_mode(const char *filename)
{
#define AUTODETECT_SIZE	128
	FILE *f=fopen(filename, "rb");
	uint r=FOM_BIN;
	if (f) {
		byte buf[AUTODETECT_SIZE];
		int c=fread(buf, 1, AUTODETECT_SIZE, f);
		/* empty files are text files */
		if (!c) return FOM_TEXT;
		bool is_bin=false;
		uint prob_bin_chars=0;
		for (int i=0; i0xa9) {
				prob_bin_chars++;
			}
		}
		if (c) {
			if (prob_bin_chars*100/c>=50) is_bin=true;
		} else is_bin=true;
		if (!is_bin) r=FOM_TEXT;
		fclose(f);
		return r;
	}
	return FOM_BIN;
}

void file_window_load_fcfg_func(ObjectStream &f, void *context)
{
	ht_file_window *w = (ht_file_window*)context;

	pstat_t p;
	
	FileOfs oldsize = GETX_INT64D(f, "filesize");
	uint32 oldtime = GETX_INT32X(f, "filetime");
	FileOfs newsize = w->file->getSize();
	w->file->pstat(p);
	uint32 newtime = (p.caps & pstat_mtime) ? p.mtime : 0;
	
	if (newsize != oldsize || newtime != oldtime) {
		char s_oldtime[64], s_newtime[64];
		struct tm *t;
		time_t tt = newtime;
		t = localtime(&tt);
		strftime(s_newtime, sizeof s_newtime, "%X %d %b %Y", t);

		tt = oldtime;
		t = localtime(&tt);
		strftime(s_oldtime, sizeof s_oldtime, "%X %d %b %Y", t);

		String fn;
		if (confirmbox_c("\ecconfig file applies to different version of file '%y'.\n\n"
		    "\elcurrent: %10qd %s\n\elold:     %10qd %s\n\n"
		    "\ecload config file?", &w->file->getDesc(fn), newsize, s_newtime, oldsize, s_oldtime) != button_yes) {
			return;
		}
	}

	Analyser *a = f.getObject("analyser");

	htmsg m;
	m.msg = msg_set_analyser;
	m.type = mt_broadcast;
	m.data1.ptr = a;
	w->sendmsg(&m);
}

void file_window_store_fcfg_func(ObjectStream &f, void *context)
{
	ht_file_window *w = (ht_file_window*)context;
	htmsg m;
	m.msg = msg_get_analyser;
	m.type = mt_broadcast;
	m.data1.ptr = NULL;
	w->sendmsg(&m);
	if (m.msg == msg_retval && m.data1.ptr) {
		pstat_t s;
		w->file->pstat(s);
		uint32 t = (s.caps & pstat_mtime) ? s.mtime : 0;
		PUTX_INT64D(f, w->file->getSize(), "filesize");
		PUTX_INT32X(f, t, "filetime");
		
		Analyser *a = (Analyser*)m.data1.ptr;
		f.putObject(a, "analyser");
	}
}

void file_project_store_fcfg_func(ObjectStream &f, void *context)
{
	PUT_OBJECT(f, project);
}

void file_project_load_fcfg_func(ObjectStream &f, void *context)
{
	GET_OBJECT(f, project);
}

/*
 *   app_stream_error_func()
 */
#if 0
int app_stream_error_func(ht_stream *stream)
{
	int err=stream->get_error();
	const char *name = stream->get_desc();
	if (err & STERR_SYSTEM) {
		err=err&0xffff;
		switch (err) {
			case 4: {	/* EACCES*/
#ifdef DJGPP
				struct stat sbuf;

				stat(name, &sbuf);

				if (!(sbuf.st_mode & S_IWUSR)) {
					if (msgbox(btmask_yes | btmask_no, "title", 1, align_center, "%s: stream error (Permission denied), seems to be a (DOS) read-only file. Change attribute?", name)==button_yes) {
						if (chmod(name, S_IRUSR | S_IWUSR)) {
							errorbox_modal("%s: error (%04x) changing attribute", name, errno & 0xffff);
						} else {
							stat(name, &sbuf);

							if (!(sbuf.st_mode & S_IWUSR)) {
								errorbox_modal("%s: error (%04x) changing attribute", name, errno & 0xffff);
							} else {
								return SERR_RETRY;
							}
						}
					}
				}

				break;
#endif
			}
			default:
				errorbox_modal("%s: stream error %04x: %s", name, err, strerror(err));
		}
	} else {
		err=err&0xffff;
		errorbox_modal("%s: internal stream error %04x", name, err);
	}
	return SERR_FAIL;
}
#endif

/*
 *   app_out_of_memory_proc()
 */
void *app_memory_reserve = NULL;

int app_out_of_memory_proc(int size)
{
	if (app_memory_reserve) {
		free(app_memory_reserve);
		app_memory_reserve = 0;
		warnbox_modal("the memory is getting low...");
		return OUT_OF_MEMORY_RETRY;
	} else {
		return OUT_OF_MEMORY_FAIL;
	}
}

/*
 *	CLASS ht_project
 */

ht_project::ht_project(const char *fn)
	: AVLTree(true)
{
	filename = ht_strdup(fn);
}

ht_project::~ht_project()
{
	free(filename);
}

const char *ht_project::get_filename()
{
	return filename;
}

void ht_project::load(ObjectStream &s)
{
	// FIXME: probably not The Right Thing
	String fn;
	filename = ht_strdup(s.getDesc(fn).contentChar());
	AVLTree::load(s);
}

ObjectID ht_project::getObjectID() const
{
	return ATOM_HT_PROJECT;
}

void ht_project::store(ObjectStream &s) const
{
	AVLTree::store(s);
}

/*
 *	CLASS ht_project_item
 */

ht_project_item::ht_project_item(const char *f, const char *p)
{
	filename = ht_strdup(f);
	path = ht_strdup(p);
}

ht_project_item::~ht_project_item()
{
	free(filename);
	free(path);
}

const char *ht_project_item::get_filename() const
{
	return filename;
}

const char *ht_project_item::get_path() const
{
	return path;
}

int ht_project_item::compareTo(const Object *obj) const
{
	ht_project_item *b = (ht_project_item *)obj;
	int c = sys_filename_cmp(get_path(), b->get_path());
	return (c == 0) ? sys_filename_cmp(get_filename(), b->get_filename()) : c;
}

void ht_project_item::load(ObjectStream &s)
{
	GET_STRING(s, path);
	GET_STRING(s, filename);
}

ObjectID ht_project_item::getObjectID() const
{
	return ATOM_HT_PROJECT_ITEM;
}

void ht_project_item::store(ObjectStream &s) const
{
	PUT_STRING(s, path);
	PUT_STRING(s, filename);
}

/*
 *	CLASS ht_project_list
 */

void	ht_project_listbox::init(Bounds *b, ht_project *p)
{
	project = p;
	ht_listbox::init(b);
	colwidths[0] = 16;
	colwidths[1] = 16;
}

int  ht_project_listbox::calcCount()
{
	return project ? project->count() : 0;
}

void ht_project_listbox::draw()
{
	if (project) {
		ht_listbox::draw();
	} else {
	
		vcp fc = focused ? getcolor(palidx_generic_list_focused_unselected) :
			getcolor(palidx_generic_list_unfocused_unselected);

		clear(fc);
		buf->print(0, 0, fc, "");
	}
}

const char *ht_project_listbox::func(uint i, bool execute)
{
	return NULL;
}

void *ht_project_listbox::getFirst()
{
	if (project && project->count()) {
		return (void*)1;
	} else {
		return NULL;
	}
}

void *ht_project_listbox::getLast()
{
	if (project && project->count()) {
		return (void*)(project->count());
	} else {
		return NULL;
	}
}

void *ht_project_listbox::getNext(void *entry)
{
	unsigned long e=(unsigned long)entry;
	if (!e) return NULL;
	if (project && (e < project->count())) {
		return (void*)(e+1);
	} else {
		return NULL;
	}
}

void *ht_project_listbox::getPrev(void *entry)
{
	unsigned long e=(unsigned long)entry;
	if (e > 1) {
		return (void*)(e-1);
	} else {
		return NULL;
	}
}

const char *ht_project_listbox::getStr(int col, void *entry)
{
	static char mybuf[32];
	if (project) switch (col) {
		case 0:
			ht_snprintf(mybuf, sizeof mybuf, "%s", ((ht_project_item*)(*project)[(long)entry-1])->get_filename());
			break;
		case 1:
			ht_snprintf(mybuf, sizeof mybuf, "%s", ((ht_project_item*)(*project)[(long)entry-1])->get_path());
			break;
		default:
			strcpy(mybuf, "?");
	} else {
		strcpy(mybuf, "");
	}
	return mybuf;
}

void ht_project_listbox::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
		case cmd_project_add_item: {
			if (project) {
				char fn[FILENAME_MAX];
				if (file_chooser("Add project item", fn, sizeof fn)) {
					char ffn[HT_NAME_MAX];
					char *dir;
					if (sys_common_canonicalize(ffn, sizeof ffn, fn, NULL, sys_is_path_delim) == 0
					 && sys_basename(fn, ffn) == 0
					 && (dir = sys_dirname(ffn)) ) {
						ht_project_item *p = new ht_project_item(fn, dir);
						((ht_project*)project)->insert(p);
						app->sendmsg(msg_project_changed);
						free(dir);
					}
				}
			}
			clearmsg(msg);
			return;
		}
		case cmd_project_remove_item: {
			int p = pos;
			ht_project_item *pi = (ht_project_item*)(*project)[p];
			if (calcCount() && confirmbox("Really remove item '%s'?", pi->get_filename()) == button_ok) {
				cursorUp(1);
				project->delObj(pi);
				update();
				if (p) cursorDown(1);
				dirtyview();
				rearrangeColumns();
			}
			clearmsg(msg);
			return;
		}
		case msg_keypressed: {
			switch (msg->data1.integer) {
				case K_Return: {
					if (calcCount() && selectEntry(e_cursor)) {
						clearmsg(msg);
						return;
					}
				}
			}
			break;
		}
	}
	ht_listbox::handlemsg(msg);
}

int ht_project_listbox::numColumns()
{
	return 2;
}

void *ht_project_listbox::quickfind(const char *s)
{
	void *item = getFirst();
	int slen = strlen(s);
	while (item && (ht_strncmp(getStr(0, item), s, slen)!=0)) {
		item = getNext(item);
	}
	return item;
}

char	*ht_project_listbox::quickfindCompletition(const char *s)
{
	void *item = getFirst();
	char *res = NULL;
	int slen = strlen(s);
	while (item) {
		if (ht_strncmp(getStr(0, item), s, slen)==0) {
			if (!res) {
				res = ht_strdup(getStr(0, item));
			} else {
				int a = ht_strccomm(res, getStr(0, item));
				res[a] = 0;
			}
		}
		item = getNext(item);
	}
	return res;
}

bool ht_project_listbox::selectEntry(void *entry)
{
	int p = pos;
	ht_project_item *i = (ht_project_item *)(*project)[p];
	char fn[HT_NAME_MAX];
	if (sys_common_canonicalize(fn, sizeof fn, i->get_filename(), i->get_path(), sys_is_path_delim)==0) {
		((ht_app*)app)->create_window_file(fn, FOM_AUTO, false);
	}
	return true;
}

void ht_project_listbox::set_project(ht_project *p)
{
	project = p;
	update();
}

/*
 *	CLASS ht_project_window
 */

void ht_project_window::init(Bounds *b, const char *desc, uint framestyle, uint number, ht_project **p)
{
	ht_window::init(b, desc, framestyle, number);
	project = p;

	Bounds c = *b;
	c.x = 0;
	c.y = 0;
	c.w -= 2;
	c.h -= 2;
	plb = new ht_project_listbox();
	plb->init(&c, *p);

	insert(plb);
	sendmsg(msg_project_changed);
}

void ht_project_window::done()
{
	ht_window::done();
}

void ht_project_window::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
		case msg_project_changed: {
			const char *t = *project ? (*project)->get_filename() : NULL;
			if (t) {
				ht_snprintf(wtitle, sizeof wtitle, "project '%s'", t); 
			} else {
				strcpy(wtitle, "project window");
			}
			settitle(wtitle);
			plb->set_project(*project);
			break;
		}
		case msg_contextmenuquery: {
			ht_static_context_menu *projects = new ht_static_context_menu();
			projects->init("~Project");
			projects->insert_entry("~Add item", "Insert", cmd_project_add_item, K_Insert, 1);
			projects->insert_entry("~Remove item", "Delete", cmd_project_remove_item, K_Delete, 1);
//			projects->insert_entry("~Edit item", NULL, cmd_project_edit_item, 0, 1);

			msg->msg = msg_retval;
			msg->data1.ptr = projects;
			return;
		}
	}
	ht_window::handlemsg(msg);
}

/*
 *	CLASS ht_status
 */

void ht_status::init(Bounds *b)
{
	ht_view::init(b, VO_TRANSPARENT_CHARS | VO_RESIZE, 0);
	VIEW_DEBUG_NAME("ht_status");
	growmode = MK_GM(GMH_FIT, GMV_TOP);
	idle_count = 0;
	analy_ani = 0;
	clear_len = 0;
	format = get_config_string("misc/statusline");
	
	if (!format) {
		format = strdup(STATUS_DEFAULT_FORMAT);
	}
	
	render();
	register_idle_object(this);
}

void ht_status::done()
{
	unregister_idle_object(this);
	free(format);
	ht_view::done();
}

const char *ht_status::defaultpalette()
{
	return palkey_generic_menu_default;
}

void ht_status::draw()
{
	fill(size.w-clear_len, 0, clear_len, 1, getcolor(palidx_generic_text_focused), ' ');
	int len = strlen(workbuf);
	clear_len = len;
	buf->print(size.w-len, 0, getcolor(palidx_generic_text_focused), workbuf);
}

void ht_status::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
	case msg_config_changed:
		free(format);
		format = get_config_string("misc/statusline");
		break;
	}
	ht_view::handlemsg(msg);
}

void ht_status::getminbounds(int *width, int *height)
{
	*width = 1;
	*height = 1;
}

bool ht_status::idle()
{
	if (idle_count % 100 == 0) {
		char *oldstatus = ht_strdup(workbuf);
		render();
		if (strcmp(oldstatus, workbuf)) {
			dirtyview();
			redraw();
			screen->show();
		}
		free(oldstatus);
		
		analy_ani++;
		analy_ani &= 7;
	}
	idle_count++;
	return false;
}

void ht_status::render()
{
	char *f = format;
	char *buf = workbuf;
	if (f)
	while (*f) {
		if (*f == STATUS_ESCAPE) {
			switch (*(++f)) {
			case STATUS_ESCAPE:
				*(buf++) = STATUS_ESCAPE;
				break;
			case STATUS_ANALY_ACTIVE:
				if (some_analyser_active) {
					const char *analysers[] = {"Analy", "aNaly", "anAly", "anaLy", "analY", "anaLy", "anAly", "aNaly"};
					strcpy(buf, analysers[analy_ani]);
					buf += 5;
				}
				break;
			case STATUS_ANALY_LINES:
				if (some_analyser_active) {
					buf += sprintf(buf, "(%d)", num_ops_parsed);
				}
				break;
			case STATUS_TIME: {
				time_t Time;
				time(&Time);
				tm *t = localtime(&Time);
				buf += sprintf(buf, "%02d:%02d", t->tm_hour, t->tm_min);
				break;
			}
			case STATUS_DATE: {
				time_t Time;
				time(&Time);
				tm *t = localtime(&Time);
				buf += sprintf(buf, "%02d.%02d.%04d", t->tm_mday, t->tm_mon+1, t->tm_year+1900);
				break;
			}
			}
		} else {
			*(buf++) = *f;
		}
		f++;
	}
	*buf = 0;
}


/*
 *	CLASS ht_keyline
 */

void ht_keyline::init(Bounds *b)
{
	ht_view::init(b, VO_RESIZE, 0);
	VIEW_DEBUG_NAME("ht_keyline");
	growmode = MK_GM(GMH_FIT, GMV_BOTTOM);
}

void ht_keyline::done()
{
	ht_view::done();
}

const char *ht_keyline::defaultpalette()
{
	return palkey_generic_keys_default;
}

void ht_keyline::draw()
{
	clear(getcolor(palidx_generic_text_disabled));
	int x = 0;
	for (int i = 1; i <= 10; i++) {
		htmsg msg;
		msg.type = mt_empty;
		msg.msg = msg_funcquery;
		msg.data1.integer = i;
		baseview->sendmsg(&msg);
		buf->printChar(x, 0, getcolor(palidx_generic_text_shortcut), '0'+i%10);
		if (msg.msg == msg_retval) {
			char *s = msg.data1.str;
			if (s) {
				if (s[0]=='~') {
					buf->print(x+1, 0, getcolor(palidx_generic_text_disabled), s+1);
				} else {
					for (int j=0; jprint(x+j+1, 0, getcolor(palidx_generic_text_focused), " ");
					}
					buf->print(x+1, 0, getcolor(palidx_generic_text_focused), s);
				}
			}
		}
		x += size.w / 10;
	}
}

void ht_keyline::getminbounds(int *width, int *height)
{
	*width = 1;
	*height = 1;
}

/*
 *	CLASS ht_desktop
 */

void ht_desktop::init(Bounds *b)
{
	ht_view::init(b, VO_OWNBUFFER | VO_RESIZE, 0);
	VIEW_DEBUG_NAME("ht_desktop");
	growmode = MK_GM(GMV_FIT, GMH_FIT);
}

const char *ht_desktop::defaultpalette()
{
	return palkey_generic_desktop_default;
}

void ht_desktop::draw()
{
	fill(0, 0, size.w, size.h, getcolor(palidx_generic_body), GC_MEDIUM, CP_GRAPHICAL);
}

/*
 *	CLASS ht_log_msg
 */
 
ht_log_msg::ht_log_msg(vcp Color, char *Msg)
{
	color = Color;
	msg = ht_strdup(Msg);
}

ht_log_msg::~ht_log_msg()
{
	free(msg);
}

/*
 *	CLASS ht_log
 */

ht_log::ht_log()
	: Array(true)
{
	maxlinecount = 128;
}

void ht_log::deletefirstline()
{
	del(0);
}

void	ht_log::insertline(LogColor color, char *line)
{
	if (count() >= maxlinecount) deletefirstline();
	vcp c;
	switch (color) {
		case LOG_NORMAL: c = VCP(VC_WHITE, VC_TRANSPARENT); break;
		case LOG_WARN: c = VCP(VC_LIGHT(VC_YELLOW), VC_TRANSPARENT); break;
		case LOG_ERROR: c = VCP(VC_LIGHT(VC_RED), VC_TRANSPARENT); break;
		default: c = VCP(VC_WHITE, VC_TRANSPARENT); break;
	}
	insert(new ht_log_msg(c, line));
}

void ht_log::log(LogColor c, char *line)
{
	insertline(c, line);
}

/*
 *	CLASS ht_logviewer
 */

void ht_logviewer::init(Bounds *b, ht_window *w, ht_log *l, bool ol)
{
	ht_viewer::init(b, "log", 0);
	VIEW_DEBUG_NAME("ht_logviewer");
	ofs = 0;
	xofs = 0;
	window = w;
	lines = l;
	own_lines = ol;
	update();
}

void ht_logviewer::done()
{
	if (own_lines) {
		delete lines;
	}
	ht_viewer::done();
}

int ht_logviewer::cursor_up(int n)
{
	ofs -= n;
	if (ofs < 0) ofs = 0;
	return n;
}

int ht_logviewer::cursor_down(int n)
{
	int c = lines->count();
	if (c >= size.h) {
		ofs += n;
		if (ofs > c-size.h) ofs = c-size.h;
	}
	return n;
}

void ht_logviewer::draw()
{
	clear(getcolor(palidx_generic_body));
	int c = lines->count();
	for (int i=0; i < size.h; i++) {
		if (i+ofs >= c) break;
		ht_log_msg *msg = (ht_log_msg*)(*lines)[i+ofs];
		int l = strlen(msg->msg);
		if (xofs < l) buf->print(0, i, /*getcolor(palidx_generic_body)*/msg->color, msg->msg+xofs);
	}
}

bool ht_logviewer::get_vscrollbar_pos(int *pstart, int *psize)
{
	return scrollbar_pos(ofs, size.h, lines->count(), pstart, psize);
}


void ht_logviewer::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
		case msg_get_scrollinfo:
			switch (msg->data1.integer) {
			case gsi_vscrollbar: {
				gsi_scrollbar_t *p=(gsi_scrollbar_t*)msg->data2.ptr;
				if (!get_vscrollbar_pos(&p->pstart, &p->psize)) {
					p->pstart = 0;
					p->psize = 100;
				}
				clearmsg(msg);
				return;
			}
			}
			break;
		case msg_log_changed: {
			ofs = lines->count()-size.h;
			if (ofs < 0) ofs = 0;
			update();
			clearmsg(msg);
			return;
		}
		case msg_keypressed:
			switch (msg->data1.integer) {
			case K_Up:
				cursor_up(1);
				update();
				clearmsg(msg);
				return;
			case K_Down:
				cursor_down(1);
				update();
				clearmsg(msg);
				return;
			case K_PageUp:
				cursor_up(size.h);
				update();
				clearmsg(msg);
				return;
			case K_PageDown:
				cursor_down(size.h);
				update();
				clearmsg(msg);
				return;
			case K_Right: case K_Control_Right:
				xofs += 2;
				update();
				clearmsg(msg);
				return;
			case K_Left: case K_Control_Left:
				if (xofs-2 >= 0) xofs -= 2;
				update();
				clearmsg(msg);
				return;
			case K_Control_PageUp:
				ofs = 0;
				update();
				clearmsg(msg);
				return;
			case K_Control_PageDown:
				ofs = lines->count()-size.h;
				if (ofs < 0) ofs = 0;
				update();
				clearmsg(msg);
				return;
			}
			break;
	}
	ht_viewer::handlemsg(msg);
}

void ht_logviewer::update()
{
	dirtyview();
}

/*
 *	CLASS ht_app_window_entry
 */

ht_app_window_entry::ht_app_window_entry(ht_window *w, uint n, uint t, bool m, bool isf, FileLayer *l)
{
	window = w;
	number = n;
	type = t;
	minimized = m;
	isfile = isf;
	layer = l;
}

int ht_app_window_entry::compareTo(const Object *obj) const
{
	uint a = number;
	uint b = ((ht_app_window_entry*)obj)->number;
	if (a > b) return 1; else if (a < b) return -1;
	return 0;
}

/*
 *	CLASS ht_app
 */

static bool doFileChecks(File *file)
{
// FIXME: this is notify-user-only. should actually also take the actions it claims to...
//        (its done in stream.cc in ht_file::set_access_mode_internal()
	pstat_t s;
	file->pstat(s);
	if (s.caps & pstat_mode_type) {
		switch (s.mode & HT_S_IFMT) {
			case HT_S_IFREG: return true;
			default:
				LOG_EX(LOG_WARN, "file is not regular (but device, fifo or something...).");
				LOG_EX(LOG_WARN, "Write-access disabled for safety!");
				return true;
		}
	} else {
		LOG_EX(LOG_WARN, "can't determine file type (regular, device, directory...)! assuming non-regular...");
		LOG_EX(LOG_WARN, "file is not regular (but device, fifo or something...).");
		LOG_EX(LOG_WARN, "Write-access disabled for safety!");
		return true;
	}
	return false;
}

/*debug*/
//#define DRAW_TIMINGS
//#define NO_AVG
#define AVG_TIMINGS 10
int timings[AVG_TIMINGS];
int cur_timing=0, max_timing=0;
int h0;
/**/

void ht_app::init(Bounds *pq)
{
	ht_dialog::init(pq, 0, 0);
	menu = NULL;
	setframe(NULL);
	options |= VO_RESIZE;
	VIEW_DEBUG_NAME("ht_app");
	exit_program = false;
	focused = true;
	Bounds b;

	windows = new AVLTree(true);
	
	syntax_lexers = new Array(true);

	ht_c_syntax_lexer *c_lexer = new ht_c_syntax_lexer();
	c_lexer->init();

	syntax_lexers->insert(c_lexer);

	ht_html_syntax_lexer *html_lexer = new ht_html_syntax_lexer();
	html_lexer->init();

	syntax_lexers->insert(html_lexer);
	
	/* init timer */
	h0=new_timer();

	/* create menu */
	getbounds(&b);
	b.x=0;
	b.y=0;
	b.h=1;
	ht_menu *m=new ht_menu();
	m->init(&b);

	ht_static_context_menu *file=new ht_static_context_menu();
	file->init("~File");
	file->insert_entry("~New...", NULL, cmd_file_new, 0, 1);
	file->insert_entry("~Open...", "F3", cmd_file_open, 0, 1);
	file->insert_entry("~Save", NULL, cmd_file_save, 0, 1);
	file->insert_entry("Save ~As...", NULL, cmd_file_saveas, 0, 1);
	file->insert_separator();
	file->insert_entry("Open/Create ~project...", NULL, cmd_project_open, 0, 1);
	file->insert_entry("Close p~roject", NULL, cmd_project_close, 0, 1);
	file->insert_separator();
//	file->insert_entry("~Execute", "Alt+Z", cmd_file_exec_cmd, K_Meta_Z, 1);
	file->insert_entry("~Quit", "F10", cmd_quit, 0, 1);
	m->insert_menu(file);

	ht_static_context_menu *edit=new ht_static_context_menu();
	edit->init("~Edit");
	edit->insert_entry("Cu~t", "Shift+Del", cmd_edit_cut, 0, 1);
	edit->insert_entry("~Delete", "Ctrl+Del", cmd_edit_delete, 0, 1);
	edit->insert_entry("~Copy", "Ctrl+Ins", cmd_edit_copy, 0, 1);
	edit->insert_entry("~Paste", "Shift+Ins", cmd_edit_paste, 0, 1);
	edit->insert_entry("~Show clipboard", 0, cmd_edit_show_clipboard, 0, 1);
	edit->insert_entry("C~lear clipboard", 0, cmd_edit_clear_clipboard, 0, 1);
	edit->insert_separator();
	edit->insert_entry("Copy ~from file...", 0, cmd_edit_copy_from_file, 0, 1);
	edit->insert_entry("Paste ~into file...", 0, cmd_edit_paste_into_file, 0, 1);
	if (sys_get_caps() & SYSCAP_NATIVE_CLIPBOARD) {
		char s[100];
		edit->insert_separator();
		ht_snprintf(s, sizeof s, "Copy from %s", sys_native_clipboard_name());
		edit->insert_entry(s, 0, cmd_edit_copy_native, 0, 1);
		ht_snprintf(s, sizeof s, "Paste into %s", sys_native_clipboard_name());
		edit->insert_entry(s, 0, cmd_edit_paste_native, 0, 1);
	}
	edit->insert_separator();
	edit->insert_entry("~Evaluate...", 0, cmd_popup_dialog_eval, 0, 1);
	m->insert_menu(edit);

	ht_static_context_menu *windows=new ht_static_context_menu();
	windows->init("~Windows");
	windows->insert_entry("~Size/Move", "Alt+F5", cmd_window_resizemove, K_Meta_F5, 1);
	windows->insert_entry("~Close", "Alt+F3", cmd_window_close, K_Meta_F3, 1);
	windows->insert_entry("~Close (alt)", "Ctrl+W", cmd_window_close, K_Control_W, 1);
	windows->insert_entry("~List", "Alt+0", cmd_popup_dialog_window_list, K_Meta_0, 1);
	ht_static_context_menu *tile=new ht_static_context_menu();
	tile->init("~Tile");
	tile->insert_entry("~Vertically", NULL, cmd_window_tile_vertical, 0, 1);
	tile->insert_entry("~Horizontally", NULL, cmd_window_tile_horizontal, 0, 1);
	windows->insert_submenu(tile);
	windows->insert_separator();
	windows->insert_entry("Lo~g window", NULL, cmd_popup_window_log, 0, 1);
	windows->insert_entry("~Options", NULL, cmd_popup_window_options, 0, 1);
	windows->insert_entry("~Project", NULL, cmd_popup_window_project, 0, 1);
	m->insert_menu(windows);

	ht_static_context_menu *help=new ht_static_context_menu();
	help->init("~Help");
	help->insert_entry("~About "ht_name, "", cmd_about, 0, 1);
	help->insert_separator();
	help->insert_entry("~Help contents", "F1", cmd_popup_window_help, 0, 1);
	help->insert_entry("~Open info file...", NULL, cmd_popup_dialog_info_loader, 0, 1);
	m->insert_menu(help);

	m->insert_local_menu();

	menu = m;
	insert(menu);
	
	/* create status */
	/* the status should have the same Bounds as the menu */
	ht_status *status = new ht_status();
	status->init(&b);
	status->setpalette(menu->getpalette());
	insert(status);
	
	/* create desktop */
	getbounds(&b);
	b.x = 0;
	b.y = 1;
	b.h -= 2;
	desktop = new ht_desktop();
	desktop->init(&b);
	insert(desktop);
	
	/* create keyline */
	getbounds(&b);
	b.x = 0;
	b.y = b.h-1;
	b.h = 1;
	keyline = new ht_keyline();
	keyline->init(&b);
	insert(keyline);

	/* create battlefield */
	getbounds(&b);
	b.x = 0;
	b.y = 1;
	b.h -= 2;

	battlefield = new ht_group();
	battlefield->init(&b, VO_TRANSPARENT_CHARS | VO_RESIZE, "battlefield");
	battlefield->growmode = MK_GM(GMH_FIT, GMV_FIT);
	insert(battlefield);

	create_window_log();
}

void ht_app::done()
{
	delete_timer(h0);

	delete syntax_lexers;
	delete windows;

	ht_dialog::done();
}

bool ht_app::accept_close_all_windows()
{
	foreach(ht_app_window_entry, e, *windows, {
		htmsg m;
		m.msg = msg_accept_close;
		m.type = mt_empty;
		e->window->sendmsg(&m);
		if (m.msg != msg_accept_close) return false;
	});
	return true;
}

ht_window *ht_app::create_window_log()
{
	ht_window *w = get_window_by_type(AWT_LOG);
	if (w) {
		focus(w);
	} else {
		Bounds b;
/*		battlefield->getbounds(&b);
		b.x = 0;
		b.y = 0;*/
		get_stdbounds_file(&b);

		ht_window *logwindow=new ht_window();
		logwindow->init(&b, "log window", FS_KILLER | FS_TITLE | FS_NUMBER | FS_MOVE | FS_RESIZE, 0);
		
		Bounds k=b;
		k.x=b.w-2;
		k.y=0;
		k.w=1;
		k.h-=2;
		ht_scrollbar *hs=new ht_scrollbar();
		hs->init(&k, &logwindow->pal, true);

		logwindow->setvscrollbar(hs);

		b.x=0;
		b.y=0;
		b.w-=2;
		b.h-=2;
		ht_logviewer *logviewer=new ht_logviewer();
		logviewer->init(&b, logwindow, loglines, false);
		logwindow->insert(logviewer);
		
		insert_window(logwindow, AWT_LOG, 0, false, NULL);
	}
	return w;
}

ht_window *ht_app::create_window_term(const char *cmd)
{
	ht_window *w = get_window_by_type(AWT_TERM);
	if (w) {
		focus(w);
	} else {
		Bounds b;
		get_stdbounds_file(&b);

		ht_window *termwindow=new ht_window();
		termwindow->init(&b, "terminal", FS_KILLER | FS_TITLE | FS_NUMBER | FS_MOVE | FS_RESIZE, 0);
		
		Bounds k=b;
		k.x=3;
		k.y=k.h-2;
		k.w-=7;
		k.h=1;
		ht_statictext *ind=new ht_statictext();
		ind->init(&k, NULL, align_left, false, true);
		ind->disable_buffering();
		ind->growmode = MK_GM(GMH_FIT, GMV_BOTTOM);

		termwindow->setpindicator(ind);

		k=b;
		k.x=b.w-2;
		k.y=0;
		k.w=1;
		k.h-=2;
		ht_scrollbar *hs=new ht_scrollbar();
		hs->init(&k, &termwindow->pal, true);

		termwindow->setvscrollbar(hs);

/*FIXPORT
		File *in, *out, *err;
		int handle;
		int e;
		if ((e = sys_ipc_exec(&in, &out, &err, &handle, cmd, 0)) == 0) {
			Terminal *terminal = new Terminal();
			terminal->init(in, out, err, handle);

			b.x=0;
			b.y=0;
			b.w-=2;
			b.h-=2;
			TerminalViewer *termviewer=new TerminalViewer();
			termviewer->init(&b, terminal, true);
			termwindow->insert(termviewer);
		
			insert_window(termwindow, AWT_LOG, 0, false, NULL);
		} else {
			errorbox("couldn't create child-process (%d)", e);
			return NULL;
		}*/
	}
	return w;
}

ht_window *ht_app::create_window_clipboard()
{
	ht_window *w = get_window_by_type(AWT_CLIPBOARD);
	if (w) {
		focus(w);
		return w;
	} else {
		Bounds b;
		get_stdbounds_file(&b);
/*		ht_file_window *window=new ht_file_window();
		window->init(&b, "clipboard", FS_KILLER | FS_TITLE | FS_NUMBER | FS_MOVE | FS_RESIZE, 0, clipboard);*/
		ht_window *window = new ht_window();
		window->init(&b, "clipboard", FS_KILLER | FS_TITLE | FS_NUMBER | FS_MOVE | FS_RESIZE, 0);
		
/*		Bounds k=b;
		k.x=b.w-2;
		k.y=0;
		k.w=1;
		k.h-=2;
		ht_scrollbar *hs=new ht_scrollbar();
		hs->init(&k, &window->pal, true);

		window->setvscrollbar(hs);*/

		Bounds k;
		k = b;
		k.x=3;
		k.y=k.h-2;
		k.w-=7;
		k.h=1;
		ht_statictext *ind = new ht_statictext();
		ind->init(&k, NULL, align_left, false, true);
		ind->disable_buffering();
		ind->growmode = MK_GM(GMH_FIT, GMV_BOTTOM);

		window->setpindicator(ind);

		b.x=0;
		b.y=0;
		b.w-=2;
		b.h-=2;
		ht_clipboard_viewer *v = new ht_clipboard_viewer();
		v->init(&b, "clipboard", VC_EDIT | VC_GOTO | VC_SEARCH, clipboard, 0);

		window->insert(v);
		// FIXME: needs wrapper (layer)
		//insert_window(window, AWT_CLIPBOARD, 0, false, clipboard);
		insert_window(window, AWT_CLIPBOARD, 0, false, NULL);
	}
	return NULL;
}

ht_window *ht_app::create_window_file(const char *filename, uint mode, bool allow_duplicates)
{
	if (mode == FOM_AUTO) mode = autodetect_file_open_mode(filename);
	switch (mode) {
		case FOM_BIN: return create_window_file_bin(filename, allow_duplicates);
		case FOM_TEXT: return create_window_file_text(filename, allow_duplicates);
	}
	return NULL;
}

ht_window *ht_app::create_window_file_bin(const char *filename, bool allow_duplicates)
{
	Bounds b;
	get_stdbounds_file(&b);
	int e;
	char *fullfilename;
	if ((e = sys_canonicalize(&fullfilename, filename))) {
		LOG_EX(LOG_ERROR, "error loading file %s: %s", filename, strerror(e));
		return NULL;
	}
	String f(fullfilename);
	free(fullfilename);

	ht_window *w;
	if (!allow_duplicates && ((w = get_window_by_filename(f.contentChar())))) {
		focus(w);
		return w;
	}

	File *emfile = NULL;
	FileModificator *mfile = NULL;
	FileLayer *file = NULL;
	try {
		emfile = new LocalFile(f, IOAM_READ, FOM_EXISTS);
	    	if (!doFileChecks(emfile)) {
			delete emfile;
			return NULL;
		}
		mfile = new FileModificator(emfile, true);
		file = new FileLayer(mfile, true);
	} catch (const IOException &e) {
		LOG_EX(LOG_ERROR, "error loading file %y: %y", &f, &e);
		if (file) delete file;
		else if (mfile) delete mfile;
		else delete emfile;
		return NULL;
	}

	LOG("loading binary file %y...", &f);

	return create_window_file_bin(&b, file, f.contentChar(), true);
}

ht_window *ht_app::create_window_file_bin(Bounds *b, FileLayer *file, const char *title, bool isfile)
{
	ht_file_window *window = new ht_file_window();
	window->init(b, title, FS_KILLER | FS_TITLE | FS_NUMBER | FS_MOVE | FS_RESIZE, 0, file);

	Bounds k=*b;
	k.x=b->w-2;
	k.y=0;
	k.w=1;
	k.h-=2;
	ht_scrollbar *hs=new ht_scrollbar();
	hs->init(&k, &window->pal, true);

	window->setvscrollbar(hs);

	k=*b;
	k.x=3;
	k.y=k.h-2;
	k.w-=7;
	k.h=1;
	ht_statictext *ind=new ht_statictext();
	ind->init(&k, NULL, align_left, false, true);
	ind->disable_buffering();
	ind->growmode = MK_GM(GMH_FIT, GMV_BOTTOM);

	window->setpindicator(ind);

	k=*b;
	k.x=0;
	k.y=0;
	k.w-=2;
	k.h-=2;
	ht_format_group *format_group=new ht_format_group();
	format_group->init(&k, VO_SELECTABLE | VO_RESIZE, VIEWERGROUP_NAME, file, true, true, format_viewer_ifs, NULL);

	window->insert(format_group);

	/**/
	if (isfile) {
		char cfgfilename[FILENAME_MAX];
		strcpy(cfgfilename, title);
		strcat(cfgfilename, HT_FILE_CONFIG_SUFFIX);

		String einfo;
		LOG("%s: loading config file...", cfgfilename);
		loadstore_result lsr = load_fileconfig(cfgfilename, ht_fileconfig_magic, ht_fileconfig_fileversion, file_window_load_fcfg_func, window, einfo);
		if (lsr == LS_ERROR_CORRUPTED) {
			LOG_EX(LOG_ERROR, "%s: error: ", cfgfilename, &einfo);
			errorbox("%s: error: %y", cfgfilename, &einfo);
		} else if (lsr == LS_ERROR_MAGIC || lsr == LS_ERROR_FORMAT) {
			LOG_EX(LOG_ERROR, "%s: wrong magic/format", cfgfilename);
			errorbox("%s: wrong magic/format", cfgfilename);
		} else if (lsr == LS_ERROR_VERSION) {
			LOG_EX(LOG_ERROR, "%s: wrong version", cfgfilename);
			errorbox("%s: wrong version", cfgfilename);
		} else if (lsr == LS_ERROR_NOT_FOUND) {
			LOG("%s: not found", cfgfilename);
		} else if (lsr != LS_OK) {
			LOG_EX(LOG_ERROR, "%s: error: %y", cfgfilename, &einfo);
			errorbox("%s: error: %y", cfgfilename, &einfo);
		} else {
			LOG("%s: ok", cfgfilename);
		}
	}

	/**/
	if (isfile) LOG("%s: done.", title);

	htmsg m;
	m.msg = msg_postinit;
	m.type = mt_broadcast;
	window->sendmsg(&m);

	insert_window(window, AWT_FILE, 0, isfile, file);
	return window;
}

ht_window *ht_app::create_window_file_text(const char *filename, bool allow_duplicates)
{
	Bounds b, c;
	get_stdbounds_file(&c);
	b = c;
	int e;
	char *fullfilename;
	if ((e = sys_canonicalize(&fullfilename, filename))) {
		LOG_EX(LOG_ERROR, "error loading file %s: %s", filename, strerror(e));
		return NULL;
	}
	String f(fullfilename);
	free(fullfilename);
	
	ht_window *w;
	if (!allow_duplicates && ((w = get_window_by_filename(f.contentChar())))) {
		focus(w);
		return w;
	}

	File *emfile = NULL;
	ht_ltextfile *tfile = NULL;
	FileLayer *file = NULL;
	try {
		File *emfile = new LocalFile(f, IOAM_READ, FOM_EXISTS);

		if (!doFileChecks(emfile)) {
			delete emfile;
			return NULL;
		}
		tfile = new ht_ltextfile(emfile, true, NULL);
		file = new ht_layer_textfile(tfile, true);
	} catch (const IOException &e) {
		LOG_EX(LOG_ERROR, "error loading file %y: %y", &f, &e);
		if (file) delete file;
		else if (tfile) delete tfile;
		else delete emfile;
		return NULL;
	}

	LOG("loading text file %y...", &f);

	return create_window_file_text(&b, file, f.contentChar(), true);
}

ht_window *ht_app::create_window_file_text(Bounds *c, FileLayer *f, const char *title, bool isfile)
{
	Bounds b=*c;

	ht_layer_textfile *file = (ht_layer_textfile *)f;
	
	ht_file_window *window = new ht_file_window();
	window->init(&b, title, FS_KILLER | FS_TITLE | FS_NUMBER | FS_MOVE | FS_RESIZE, 0, file);

	b.x=0;
	b.y=0;
	b.w-=2;
	b.h-=2;
	ht_text_editor *text_editor=new ht_text_editor();
	text_editor->init(&b, true, file, syntax_lexers, TEXTEDITOPT_INPUTTABS|TEXTEDITOPT_UNDO);

	IString fn, base, fn_suf;
	file->getFilename(fn);
	if (fn.rightSplit('.', base, fn_suf)) {
		if (fn_suf == "c" || fn_suf == "cc"
		 || fn_suf == "cpp"
		 || fn_suf == "h" || fn_suf == "hpp") {
			text_editor->set_lexer((ht_syntax_lexer*)(*syntax_lexers)[0], false);
		}
#ifdef HT_HTML_SYNTAX_LEXER
		if (fn_suf == "htm" || fn_suf == "html") {
			text_editor->set_lexer((ht_syntax_lexer*)(*syntax_lexers)[1], false);
		}
#endif
	}

	Bounds k=*c;
	k.x=k.w-2;
	k.y=0;
	k.w=1;
	k.h-=2;
	ht_scrollbar *hs=new ht_scrollbar();
	hs->init(&k, &window->pal, true);

	window->setvscrollbar(hs);

	k=*c;
	k.x=3;
	k.y=k.h-2;
	k.w-=7;
	k.h=1;
	
	ht_statictext *ind=new ht_statictext();
	ind->init(&k, NULL, align_left, false, true);
	ind->disable_buffering();
	ind->growmode = MK_GM(GMH_FIT, GMV_BOTTOM);

	window->setpindicator(ind);

	window->insert(text_editor);
	if (isfile) LOG("%s: done.", title);

	insert_window(window, AWT_FILE, 0, isfile, file);
	return window;
}

ht_window *ht_app::create_window_help(const char *file, const char *node)
{
	ht_window *w = get_window_by_type(AWT_HELP);
	if (w) {
		focus(w);
		return w;
	} else {
		Bounds b, c;
		battlefield->getbounds(&c);
		b.w=c.w*7/8;
		b.h=c.h*7/8;
		b.x=(c.w-b.w)/2;
		b.y=(c.h-b.h)/2;
		Bounds k = b;

		ht_help_window *window=new ht_help_window();
		window->init(&b, "help", FS_KILLER | FS_TITLE | FS_NUMBER | FS_MOVE | FS_RESIZE, 0);

		b.x=0;
		b.y=0;
		b.w-=2;
		b.h-=2;
		c=b;

		b=c;
		b.x+=b.w;
		b.w=1;
		ht_scrollbar *scrollbar=new ht_scrollbar();
		scrollbar->init(&b, &window->pal, true);
		scrollbar->enable();
		window->setvscrollbar(scrollbar);

		k.x=3;
		k.y=k.h-2;
		k.w-=7;
		k.h=1;
		ht_statictext *ind=new ht_statictext();
		ind->init(&k, NULL, align_left, false, true);
		ind->disable_buffering();
		ind->growmode = MK_GM(GMH_FIT, GMV_BOTTOM);

		window->setpindicator(ind);

		b=c;
		ht_info_viewer *infoviewer=new ht_info_viewer();
		infoviewer->init(&b);
		window->insert(infoviewer);

		char ff[HT_NAME_MAX], cwd[HT_NAME_MAX];

		cwd[0] = 0;
		getcwd(cwd, sizeof cwd);
		if (strcmp(file, "hthelp.info")) {
			sys_common_canonicalize(ff, sizeof ff, file, cwd, sys_is_path_delim);
		} else {
			strcpy(ff, file);
		}
		if (infoviewer->gotonode(ff, node)) {
			insert_window(window, AWT_HELP, 0, false, NULL);
			
			window->setpalette(palkey_generic_cyan);
			return window;
		}
		errorbox("help topic '(%s)%s' not found", file, node);
		window->done();
		delete window;
	}
	return NULL;
}

ht_window *ht_app::create_window_project()
{
	ht_window *w = get_window_by_type(AWT_PROJECT);
	if (w) {
		focus(w);
		return w;
	} else {
		Bounds b;
		get_stdbounds_tool(&b);

		ht_project_window *project_window=new ht_project_window();
		project_window->init(&b, "project window", FS_KILLER | FS_TITLE | FS_NUMBER | FS_MOVE | FS_RESIZE, 0, (ht_project**)&project);

		Bounds k = b;
		k.x = b.w-2;
		k.y = 0;
		k.w = 1;
		k.h -= 2;
		ht_scrollbar *hs = new ht_scrollbar();
		hs->init(&k, &project_window->pal, true);

		project_window->sethscrollbar(hs);

/*		b.x = 0;
		b.y = 0;
		b.w -= 2;
		b.h -= 2;
		ht_project_listbox *project_viewer = new ht_project_listbox();
		project_viewer->init(&b, project);
		project_window->insert(project_viewer);*/

		insert_window(project_window, AWT_PROJECT, 0, false, NULL);
		
		project_window->setpalette(palkey_generic_cyan);
		return project_window;
	}
}

#if 0
ht_view *create_ofm_single(Bounds *c, char *url, ht_vfs_viewer **x)
{
	Bounds b=*c;
	b.h-=2;
	ht_group *g=new ht_group();
	g->init(&b, VO_SELECTABLE, 0);

	Bounds d=b;
	
	b.x=0;
	b.y=0;
	b.h=1;
	ht_vfs_viewer_status *vst=new ht_vfs_viewer_status();
	vst->init(&b);
	   
	d.x=0;
	d.y=1;
	d.h--;
	ht_vfs_viewer *v=new ht_vfs_viewer();
	v->init(&d, "vfs viewer", 0, 0, 0, vst);
	   
	g->insert(v);

	g->insert(vst);

	ht_vfs_sub *vs=new ht_vfs_sub();
	vs->init(url);

	v->insertsub(vs);

	v->sendmsg(msg_complete_init, 0);

	*x=v;
	return g;
}
#endif

ht_window *ht_app::create_window_ofm(const char *url1, const char *url2)
{
	Bounds b;
	get_stdbounds_file(&b);

	ht_window *window=new ht_window();
	window->init(&b, "file manager", FS_KILLER | FS_TITLE | FS_NUMBER | FS_MOVE | FS_RESIZE, 0);
#if 1
	b.w-=2;
	b.h-=2;

	VfsListbox2 *l = new VfsListbox2();
	l->init(&b, virtual_fs_list, window->getframe());

//	l->changeURL("local:/bp/././..");
	l->changeURL(url1);

	window->insert(l);
#else
	Bounds b1, b2, b3;

	ht_vfs_viewer *v1, *v2=NULL;

	b.w-=2;

	b1=b;
	b1.w/=2;
	b1.w--;
	window->insert(create_ofm_single(&b1, url1, &v1));

	if (url2) {
		b2=b;
		b2.w/=2;
		b2.x=b2.w-1;
		b2.w=1;
		b2.h-=2;
		ht_vbar *x=new ht_vbar();
		x->init(&b2, 0, 0);
		window->insert(x);

		b3=b;
		b3.w/=2;
		b3.x=b3.w;
		window->insert(create_ofm_single(&b3, url2, &v2));
	}

	if (v2) {
		v1->set_assoc_vfs_viewer(v2);
		v2->set_assoc_vfs_viewer(v1);
	}
#endif
	insert_window(window, AWT_OFM, 0, false, NULL);
	return window;
}

const char *ht_app::defaultpalette()
{
	return NULL;
}

const char *ht_app::defaultpaletteclass()
{
	return NULL;
}

int analy_id = 0;
void ht_app::draw()
{
/* show draw timings */
#ifdef DRAW_TIMING
	int xyz=get_timer_1024tick(h0);
	buf->printf(17, 1, 7, "cur: %d (%d msec)", xyz*1024, get_timer_msec(h0));
#ifndef NO_AVG
	if (cur_timing>=AVG_TIMINGS-1) cur_timing=0;
	timings[cur_timing++]=xyz;
	if (cur_timing>max_timing) max_timing=cur_timing;
	int avg=0;
	for (int i=0; iprintf(57, 1, 7, "avg%d: %d", max_timing+1, avg*1024);
#endif
#endif
}

void ht_app::delete_window(ht_window *window)
{
	ObjHandle oh = get_window_listindex(window);
	if (oh != invObjHandle) {
		battlefield->remove(window);

		windows->del(oh);

		window->done();
		delete window;
	}
}

uint ht_app::find_free_window_number()
{
	ht_app_window_entry e(NULL, 1, 0, false, false, NULL);
	ObjHandle oh;
	while ((oh = windows->find(&e)) != invObjHandle) {
		e.number++;
	}
	return e.number;
}

bool ht_app::focus(ht_view *view)
{
	return ht_dialog::focus(view);
}

const char *ht_app::func(uint i, bool execute)
{
	switch (i) {
		case 1:
			if (execute) sendmsg(cmd_popup_window_help);
			return "help";
		case 3:
			if (execute) sendmsg(cmd_file_open);
			return "open";
		case 6:
			if (execute) sendmsg(cmd_popup_dialog_view_list);
			return "mode";
		/* FIXME: experimental */
/*		case 9:
			if (execute) {
				create_window_term("make");
			}
			return "make";*/
		case 10:
			if (execute) sendmsg(cmd_quit);
			return "quit";
	}
	return 0;
}

void ht_app::get_stdbounds_file(Bounds *b)
{
	if (project) {
		Bounds c;
		get_stdbounds_tool(&c);
		battlefield->getbounds(b);
		b->x = 0;
		b->y = 0;
		b->h -= c.h;
	} else {
		battlefield->getbounds(b);
		b->x = 0;
		b->y = 0;
	}
}

void ht_app::get_stdbounds_tool(Bounds *b)
{
	uint h = MAX(size.h/4, 3);
	battlefield->getbounds(b);
	b->x = 0;
	b->y = b->h - h;
	b->h = h;
}

ht_window *ht_app::get_window_by_filename(const char *filename)
{
	foreach(ht_app_window_entry, e, *windows, {
		// FIXME: filename_compare (taking into account slash/backslash, and case)
		if (strcmp(e->window->desc, filename) == 0) return e->window;
	});
	return NULL;
}

ht_window *ht_app::get_window_by_number(uint number)
{
	ht_app_window_entry *e;
	firstThat(ht_app_window_entry, e, *windows, e->number==number);
	return e ? e->window : NULL;
}

ht_window *ht_app::get_window_by_type(uint type)
{
	ht_app_window_entry *e;
	firstThat(ht_app_window_entry, e, *windows, e->type==type);
	return e ? e->window : NULL;
}

uint ht_app::get_window_number(ht_window *window)
{
	ht_app_window_entry *e;
	firstThat(ht_app_window_entry, e, *windows, e->window==window);
	return e ? e->number : 0;
}

ObjHandle ht_app::get_window_listindex(ht_window *window)
{
	ObjHandle oh;
	for (oh = windows->findFirst(); oh != invObjHandle; ) {
		ht_app_window_entry *e = (ht_app_window_entry*)windows->get(oh);
		if (e->window == window) break;
		oh = windows->findNext(oh);
	}
	return oh;
}

#include "cstream.h"
void ht_app::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
		case cmd_edit_copy_native: {
			int dz = sys_native_clipboard_get_size();
			if (dz) {
				void *data = ht_malloc(dz);
				if ((dz = sys_native_clipboard_read(data, dz))) {
					clipboard_copy(sys_native_clipboard_name(), data, dz);
				}
				free(data);
			}
			break;
		}
		case cmd_edit_paste_native: {
			int maxsize = clipboard_getsize();
			if (maxsize) {
				byte *buf = ht_malloc(maxsize);
				int r = clipboard_paste(buf, maxsize);
				if (r) {
					sys_native_clipboard_write(buf, r);
				}
				free(buf);
			}
			break;
		}
		case cmd_file_save: {
			ObjHandle oh = get_window_listindex((ht_window*)battlefield->current);
			ht_app_window_entry *e = (ht_app_window_entry*)windows->get(oh);
			if (e && e->layer && e->isfile) break;
		}
		case cmd_file_saveas: {
			ObjHandle oh = get_window_listindex((ht_window*)battlefield->current);
			ht_app_window_entry *e = (ht_app_window_entry*)windows->get(oh);
			if (e && e->layer) {
				char fn[HT_NAME_MAX];
				fn[0] = 0;
				if (file_chooser("Save as", fn, sizeof fn)) {
					bool work = true;

					if (access(fn, F_OK) == 0) {
						work = (confirmbox("File '%s' already exists. Overwrite?", fn) == button_yes);
					}

					if (work) {
						LocalFile *f = NULL;
						try {
							String n(fn);
							f = new LocalFile(n, IOAM_WRITE, FOM_CREATE);
							e->layer->seek(0);
							e->layer->copyAllTo(f);
						} catch (const IOException &e) {
							LOG_EX(LOG_ERROR, "error saving file %s: %y", fn, &e);
							errorbox("error saving file %s: %y", fn, &e);
							delete f;
							return;
						}
//						asm(".byte 0xcc");

						File *old = e->layer->getLayered();

						if (f->setAccessMode(old->getAccessMode()) == 0) {
							FileLayer *l;
							// FIXME: UGLY hack
							if (dynamic_cast(old)) {
								l = new ht_ltextfile(f, true, NULL);
							} else {
								l = new FileModificator(f, true);
							}
							e->layer->setLayered(l, true);
							e->isfile = true;

							delete old;

							char *fullfn;
							if (sys_canonicalize(&fullfn, fn)==0) {
								e->window->settitle(fullfn);
								free(fullfn);
							} else {
								e->window->settitle(fn);
							}
							clearmsg(msg);
						} else {
							String s1, s2;
							errorbox("couldn't inherit access_mode from '%y' to '%y'", &old->getDesc(s1), &f->getDesc(s2));
						}
					}
				}
			}
			return;
		}
		case msg_kill: {
			htmsg m;
			ht_window *w = (ht_window*)msg->data1.ptr;
			m.msg = msg_accept_close;
			m.type = mt_broadcast;
			m.data1.ptr = NULL;
			m.data2.ptr = NULL;
			w->sendmsg(&m);
			if (m.msg == msg_accept_close) delete_window(w);
			clearmsg(msg);
			return;
		}
	}
	if (msg->msg == msg_draw) {
		start_timer(h0);
		if (msg->type == mt_broadcast) {
			ht_view *v = first;
			while (v) {
				v->handlemsg(msg);
				v = v->next;
			}
		} else {
			current->handlemsg(msg);
		}
		stop_timer(h0);
		draw();
		screen->show();
	} else {
		ht_group::handlemsg(msg);
	}
	switch (msg->msg) {
		case msg_keypressed: {
			int i=0;
			switch (msg->data1.integer) {
				case K_Meta_9: i++;
				case K_Meta_8: i++;
				case K_Meta_7: i++;
				case K_Meta_6: i++;
				case K_Meta_5: i++;
				case K_Meta_4: i++;
				case K_Meta_3: i++;
				case K_Meta_2: i++;
				case K_Meta_1: i++;
					focus(get_window_by_number(i));
					clearmsg(msg);
					return;
				case K_F12: i++;
				case K_F11: i++;
				case K_F10: i++;
				case K_F9: i++;
				case K_F8: i++;
				case K_F7: i++;
				case K_F6: i++;
				case K_F5: i++;
				case K_F4: i++;
				case K_F3: i++;
				case K_F2: i++;
				case K_F1:
					i++;
					htmsg m;
					m.msg=msg_funcquery;
					m.type=mt_empty;
					m.data1.integer=i;
					sendmsg(&m);
					if (m.msg==msg_retval) {
						sendmsg(msg_funcexec, i);
						clearmsg(msg);
						return;
					}
					break;
/*					
				case K_Meta_R: {
					const char *n = "ht.reg";
					LocalFile f(n, IOAM_WRITE, FOM_CREATE);
					CompressedStream c(&f, false);
//					StreamLayer c(&f, false);
					ObjectStreamBin b(&c, false);

					b.putObject(registry, NULL);

					infobox("registry dumped to '%s'", n);
					
					clearmsg(msg);
					return;
				}
*/
#if 0
				/* FIXME: experimental */
				case K_Control_F9:
					((ht_app*)app)->create_window_term("main.exe");
					clearmsg(msg);
					return;
				case K_Meta_T:
					create_window_ofm("reg:/", "local:/");
					clearmsg(msg);
					return;*/
				case K_Control_A:
					create_window_help("/HT/res/info/intidx.info", "Top");
//					create_window_help("c:/djgpp/projects/enew/res/info/ibnidx.info", "Interrupts By Number");
					dirtyview();
					clearmsg(msg);
					return;
#endif
				case K_Space:
					sendmsg(cmd_popup_dialog_view_list);
					clearmsg(msg);
					return;
			}
			break;
		}
		case cmd_about:
			msgbox(btmask_ok, "About "ht_name, 0, align_custom, "\n"
				"\ec"ht_name" "ht_version" (%s)\n\n"
				"\el"ht_copyright1"\n"ht_copyright2"\n\n"
				"This program is GPL'd. See Help for more information.", sys_get_name());
			break;
		case msg_funcexec:
			if (func(msg->data1.integer, 1)) {
				clearmsg(msg);
				return;
			}
			break;
		case msg_funcquery: {
			const char *s = func(msg->data1.integer, 0);
			if (s) {
				msg->msg = msg_retval;
				msg->data1.cstr = s;
			} else clearmsg(msg);
			return;
		}
		case cmd_file_exec_cmd: {
			char cmd[HT_NAME_MAX];
			cmd[0] = 0;
			if (inputbox("execute shell command (experimental!)",
			    (sys_get_caps() & SYSCAP_NBIPC) ? "command"
			    : "non-interactive (!) command",
			    cmd, sizeof cmd, HISTATOM_FILE) == button_ok) {
				if (cmd[0]) create_window_term(cmd);
			}
			clearmsg(msg);
			return;
		}
		case cmd_file_extend: {
			File *f = (File *)msg->data1.ptr;
			FileOfs s = msg->data2.q;
			// don't ask. only for truncates
//			if (confirmbox("really extend %s to offset %08qx/%qd?", f->get_filename(), s, s) == button_ok) {
				IOAccessMode oam = f->getAccessMode();
				if (!(oam & IOAM_WRITE)) f->setAccessMode(oam | IOAM_WRITE);
				try {
					f->extend(s);
				} catch (const IOException &e) {
					errorbox("couldn't extend file to offset 0x%08qx/%qd: %y", s, s, &e);
				}
				if (!(oam & IOAM_WRITE)) f->setAccessMode(oam);
//			}
			clearmsg(msg);
			return;
		}
		case cmd_file_truncate: {
			File *f = (File *)msg->data1.ptr;
			FileOfs s = msg->data2.q;
/*			ht_app_window_entry *e;
			if ((e = windows->enum_first())) {
				do {
					if (e->type == AWT_FILE && (File*)e->data == f) {
						check_collide();
					}
				} while ((e = windows->enum_next()));
			}*/
			String fn;
			if (confirmbox("really truncate %y at offset 0x%08qx/%qd?", &f->getFilename(fn), s, s) == button_ok) {
				f->truncate(s);
			}
			clearmsg(msg);
			return;
		}
		case cmd_quit:
			if (accept_close_all_windows()) {
				LOG("terminating...");
				exit_program = true;
				sendmsg(cmd_project_close);
				clearmsg(msg);
			}
			return;
		case cmd_file_open: {
			char *name;
			uint mode;
			if (file_open_dialog(&name, &mode)) {
				if (name[0]) create_window_file(name, mode, true);
				free(name);
			}
			clearmsg(msg);
			return;
		}
		case cmd_file_new: {
			Bounds b;
			get_stdbounds_file(&b);
			
			uint mode;
			
			if (file_new_dialog(&mode)) {
				MemoryFile *mfile = new MemoryFile();
				switch (mode) {
				case FOM_TEXT: {
					ht_syntax_lexer *lexer = NULL;

					ht_ltextfile *tfile = new ht_ltextfile(mfile, true, lexer);
					ht_layer_textfile *file = new ht_layer_textfile(tfile, true);

					create_window_file_text(&b, file, "Untitled", false/* because mem_file is underlying, not ht_file, etc.*/);
					break;
				}
				case FOM_BIN: {
					FileModificator *modfile = new FileModificator(mfile, true);
					FileLayer *file = new FileLayer(modfile, true);

					ht_window *w = create_window_file_bin(&b, file, "Untitled", false);
					htmsg m;
					m.msg = cmd_file_resize;
					m.type = mt_empty;
					w->sendmsg(&m);
				}
				}
			}
			clearmsg(msg);
			return;
		}
		case cmd_edit_show_clipboard: {
			create_window_clipboard();
			clearmsg(msg);
			return;
		}
		case cmd_edit_clear_clipboard: {
			if (confirmbox("Do you really want to delete the clipboard?")==button_ok) {
				clipboard_clear();
			}
			clearmsg(msg);
			return;
		}
		case cmd_edit_paste_into_file: {
			char filename[HT_NAME_MAX];
			filename[0] = 0;
			if (file_chooser("clipboard - paste into file", filename, sizeof filename)) {
				try {
					String fn(filename);
					LocalFile f(fn, IOAM_WRITE, FOM_CREATE);
					clipboard_paste(&f, 0);
				} catch (const IOException &e) {
					errorbox("error writing: '%s': '%y'", filename, &e);
				}
			}
			clearmsg(msg);
			return;
		}
		case cmd_edit_copy_from_file: {
			char filename[HT_NAME_MAX];
			filename[0] = 0;
			if (file_chooser("clipboard - copy from file", filename, sizeof filename)) {
				char desc[HT_NAME_MAX+5];
				try {
					String fn(filename);
					LocalFile f(fn, IOAM_READ, FOM_EXISTS);
					ht_snprintf(desc, sizeof desc, "file %s", filename);
					clipboard_copy(desc, &f, 0, f.getSize());
				} catch (const IOException &e) {
					errorbox("error reading: '%s': '%y'", filename, &e);
				}
			}
			clearmsg(msg);
			return;
		}
		case cmd_project_open: {
			char fn[HT_NAME_MAX];
			fn[0] = 0;
			if (file_chooser("Open project", fn, sizeof fn)) {
				sendmsg(cmd_project_close);
				project_opencreate(fn);
			}
			clearmsg(msg);
			return;
		}
		case cmd_project_close: {
			if (project) {
				const char *fn = ((ht_project*)project)->get_filename();
				LOG("%s: saving project", fn);
				do {
					String err;
					if (save_fileconfig(fn, ht_projectconfig_magic, ht_projectconfig_fileversion, file_project_store_fcfg_func, NULL, err) != LS_OK) {
						String e;
						e.assignFormat("Couldn't save '%y': %y\n\nRetry?", &fn, &err);
						switch (msgbox(btmask_yes+btmask_no+btmask_cancel, "confirmation", 0, align_center, e.contentChar())) {
						case button_ok: continue;
						case button_cancel: return;
						}
						LOG("%s: failed", fn);
					} else {
						LOG("%s: done", fn);
					}
					break;
				} while (1);
				delete ((ht_project*)project);
				project = NULL;
				htmsg m;
				m.type = mt_broadcast;
				m.msg = msg_project_changed;
				sendmsg(&m);
			}
			clearmsg(msg);
			return;
		}
		case cmd_window_close:
			if (battlefield->current) sendmsg(msg_kill, battlefield->current);
			clearmsg(msg);
			return;
		case cmd_window_tile_vertical:
			tile(true);
			clearmsg(msg);
			return;
		case cmd_window_tile_horizontal:
			tile(false);
			clearmsg(msg);
			return;
		case cmd_popup_dialog_eval: {
			eval_dialog(NULL, NULL, NULL);
			clearmsg(msg);
			return;
		}
		case cmd_popup_dialog_view_list: {
			ht_view *v = popup_view_list("select mode");
			if (v) focus(v);
			clearmsg(msg);
			return;
		}
		case cmd_popup_dialog_window_list: {
			ht_window *w = popup_window_list("select window");
			if (w) focus(w);
			clearmsg(msg);
			return;
		}
		case cmd_popup_dialog_info_loader: {
			char file[256];
			file[0] = 0;
			if (inputbox("open info file", "filename", file, sizeof file, HISTATOM_FILE) == button_ok) {
				char node[256];
				strcpy(node, "Top");
				if (inputbox("open info file", "nodename", node, sizeof node, HISTATOM_GOTO) == button_ok) {
					create_window_help(file, node);
					dirtyview();
				}
			}
			clearmsg(msg);
			return;
		}
		case cmd_popup_window_log:
			create_window_log();
			clearmsg(msg);
			return;
		case cmd_popup_window_project:
			create_window_project();
			clearmsg(msg);
			return;
		case cmd_popup_window_options:
			create_window_ofm("reg:/", NULL);
			clearmsg(msg);
			return;
		case cmd_popup_window_help:
			create_window_help(MAGIC_HT_HELP, "Top");
			clearmsg(msg);
			return;
		case msg_project_changed: {
			ht_window *w = ((ht_app*)app)->get_window_by_type(AWT_PROJECT);
			if (w) w->sendmsg(msg_dirtyview);
			app->sendmsg(msg_draw);
			return;
		}
	}
}

void	ht_app::insert_window(ht_window *window, uint type, bool minimized, bool isfile, FileLayer *layer)
{
	uint n=find_free_window_number();
	ht_app_window_entry *e=new ht_app_window_entry(window, n, type, minimized, isfile, layer);
	windows->insert(e);
	window->setnumber(n);
	battlefield->insert(window);
	focus(window);
}

void ht_app::load(ObjectStream &f)
{
	ht_registry *tmp = registry;
	GET_OBJECT(f, registry);

	if (tmp) {
		tmp->done();
		delete tmp;
	}
	
	load_history(f);
	
	htmsg m;
	m.msg = msg_config_changed;
	m.type = mt_broadcast;
	app->sendmsg(&m);
}

ObjectID ht_app::getObjectID() const
{
	return ATOM_HT_APP;
}

static int my_compare_func(const char *a, const char *b)
{
	return strcmp(a, b);
}

ht_view *ht_app::popup_view_list(const char *dialog_title)
{
	if (!battlefield->current) return NULL;
	Bounds b, c;
	getbounds(&b);
	b.x=b.w/4;
	b.y=b.h/4;
	b.w/=2;
	b.h/=2;
	ht_dialog *dialog=new ht_dialog();
	dialog->init(&b, dialog_title, FS_KILLER | FS_TITLE | FS_MOVE);

	/* create listbox */
	c=b;
	c.x=0;
	c.y=0;
	c.w-=2;
	c.h-=2;
	ht_text_listbox *listbox=new ht_text_listbox();
	listbox->init(&c, 1, 0, LISTBOX_NORMAL);

	/* insert all browsable views */
	Array structure(false);

	int index=0;
/*	int count=*/popup_view_list_dump(battlefield->current, listbox, &structure, 0, &index, battlefield->getselected());
/* and seek to the currently selected one */
	listbox->update();
	listbox->gotoItemByPosition(index);

	ht_text_listbox_sort_order so[1];
	so[0].col = 0;
	so[0].compare_func = my_compare_func;
/*	so[1].col = 1;
	so[1].compare_func = my_compare_func;*/
	
//	listbox->sort(1, so);

	dialog->insert(listbox);
	dialog->setpalette(palkey_generic_special);

	ht_view *result = NULL;
	if (dialog->run(false)) {
		ht_listbox_data data;
		ViewDataBuf vdb(listbox, &data, sizeof data);
		result = (ht_view*)structure[listbox->getID(data.data->cursor_ptr)];
	}

	dialog->done();
	delete dialog;
	return result;
}

int ht_app::popup_view_list_dump(ht_view *view, ht_text_listbox *listbox, List *structure, int depth, int *currenti, ht_view *currentv)
{
	if (!view) return 0;
	char str[256];	/* secure */
	char *s=str;
	if (!(view->options & VO_BROWSABLE)) {
		depth--;
	}

	for (int i=0; ichildcount();
	int count=0;
	for (int i=0; igetfirstchild();
		while (v) {
			if (v->browse_idx == i) break;
			v = v->next;
		}
		if (!v) return count;

		// FIXME: "viewergroup": dirty hack !!!
		if (v->desc && (strcmp(v->desc, VIEWERGROUP_NAME)) && (v->options & VO_BROWSABLE)) {
			ht_snprintf(s, sizeof str-(s-str), "- %s", v->desc);
			structure->insert(v);
			if (v==currentv)
				*currenti=structure->count()-1;
			listbox->insert_str(structure->count()-1, str);
			count++;
		}
		count += popup_view_list_dump(v, listbox, structure, depth+1, currenti, currentv);
	}
	return count;
}

ht_window *ht_app::popup_window_list(const char *dialog_title)
{
	Bounds b, c;
	getbounds(&b);
	c=b;
	b.w=b.w*2/3;
	b.h=b.h*2/3;
	b.x=(c.w-b.w)/2;
	b.y=(c.h-b.h)/2;
	ht_dialog *dialog=new ht_dialog();
	dialog->init(&b, dialog_title, FS_KILLER | FS_TITLE | FS_MOVE);

	/* create listbox */
	c=b;
	c.x=0;
	c.y=0;
	c.w-=2;
	c.h-=2;
	ht_text_listbox *listbox=new ht_itext_listbox();
	listbox->init(&c, 2, 1);

	foreach(ht_app_window_entry, e, *windows, {
		char l[16];	/* secure */
		ht_snprintf(l, sizeof l, " %2d", e->number);
		listbox->insert_str(e->number, l, e->window->desc);		
	});
	listbox->update();
	if (battlefield->current) listbox->gotoItemByPosition(battlefield->current->getnumber()-1);

	dialog->insert(listbox);
	dialog->setpalette(palkey_generic_special);

	ht_window *result = NULL;
	if (dialog->run(false)) {
		ht_listbox_data data;
		ViewDataBuf vdb(listbox, &data, sizeof data);
		result = get_window_by_number(listbox->getID(data.data->cursor_ptr));
	}
	dialog->done();
	delete dialog;
	return result;
}

void ht_app::project_opencreate(const char *filename)
{
	char fn[HT_NAME_MAX];
	char cwd[HT_NAME_MAX];
	getcwd(cwd, sizeof cwd);
	if (sys_common_canonicalize(fn, sizeof fn, filename, cwd, sys_is_path_delim) != 0) {
		LOG("%s: invalid filename", filename);
		return;
	}
	const char *suf = sys_filename_suffix(fn);
	/* append HT project file suffix if not already there */
	if (!(suf && (strcmp(suf, HT_PROJECT_CONFIG_SUFFIX+1)==0))) {
		strcat(fn, HT_PROJECT_CONFIG_SUFFIX);
	}

	Object *old_project = project;
	project = NULL;

	String einfo;
	LOG("%s: loading project file...", fn);
	bool error = true;
	loadstore_result lsr = load_fileconfig(fn, ht_projectconfig_magic, ht_projectconfig_fileversion, file_project_load_fcfg_func, NULL, einfo);
	if (lsr == LS_ERROR_CORRUPTED) {
		LOG_EX(LOG_ERROR, "%s: error: %y", fn, &einfo);
		errorbox("%s: error: %y", fn, &einfo);
	} else if (lsr == LS_ERROR_NOT_FOUND) {
		if (confirmbox("%s: no such project.\nDo you want to create this project?", fn) == button_yes) {
			project = new ht_project(fn);
			LOG("%s: new project created", fn);
			error = false;
		}
	} else if (lsr != LS_OK) {
		LOG_EX(LOG_ERROR, "%s: error: %y", fn, &einfo);
		errorbox("%s: error: %y", fn, &einfo);
	} else {
		LOG("%s: done", fn);
		error = false;
	}
	if (error) {
		// FIXME: free project ???
		project = old_project;
	} else {
		htmsg m;
		m.type = mt_broadcast;
		m.msg = msg_project_changed;
		sendmsg(&m);
		create_window_project();
	}
}

void ht_app::modal_resize()
{
	sys_set_winch_flag(0);
	int w, h;
	if (sys_get_screen_size(w, h)) {
		screen->resize(w - screen->w, h - screen->h);
		resize(w - size.w, h - size.h);
		sendmsg(msg_dirtyview);
		sendmsg(msg_draw);
	}
}

void do_modal_resize()
{
	((ht_app*)app)->modal_resize();
}

static uint isqr(uint u)
{
	uint a = 2;
	uint b = u/a;
	while (abs(a - b) > 1) {
		a = (a+b)/2;
		b = u/a;
        }
	return MIN(a, b);
}

static void mostEqualDivisors(int n, int &x, int &y)
{
	int i;

	i = isqr(n);
	if (n%i && n%(i+1)==0) {
		i++;
	}
	if (i < (n/i)) {
		i = n/i;
	}
	x = n/i;
	y = i;
}

static int dividerLoc(int lo, int hi, int num, int pos)
{
	return int(long(hi-lo)*pos/long(num)+lo);
}

static void calcTileRect(int pos, int numRows, int numCols, int leftOver, const Bounds &b, Bounds &nB)
{
	int x, y;

	int d = (numCols - leftOver) * numRows;
	if (pos <  d) {
		x = pos / numRows;
		y = pos % numRows;
	} else {
		x = (pos-d)/(numRows+1) + (numCols-leftOver);
		y = (pos-d)%(numRows+1);
	}
	nB.x = dividerLoc(b.x, b.x+b.w, numCols, x);
	nB.w = dividerLoc(b.x, b.x+b.w, numCols, x+1) - nB.x;
	if (pos >= d) {
		nB.y = dividerLoc(b.y, b.y+b.h, numRows+1, y);
		nB.h = dividerLoc(b.y, b.y+b.h, numRows+1, y+1) - nB.y;
	} else {
		nB.y = dividerLoc(b.y, b.y+b.h, numRows, y);
		nB.h = dividerLoc(b.y, b.y+b.h, numRows, y+1) - nB.y;
	}
}

void ht_app::tile(bool vertical)
{
	Bounds b, bf;
	get_stdbounds_file(&b);
	battlefield->getbounds(&bf);
	int numTileable = 0;
	foreach(ht_app_window_entry, e, *windows, {
		if (e->isfile) numTileable++;
	});
	// count
	if (numTileable > 0) {
		int numRows, numCols;
		if (vertical) {
			mostEqualDivisors(numTileable, numRows, numCols);
		} else {
			mostEqualDivisors(numTileable, numCols, numRows);
		}
		if (b.w/numCols==0 || b.h/numRows==0) {
			return;
		} else {
			int leftOver = numTileable % numCols;
			int tileNum = numTileable - 1;
			
			foreachbwd(ht_app_window_entry, e, *windows, {
				if (e->isfile) {
					Bounds nb, ob;
					calcTileRect(tileNum, numRows, numCols, leftOver, b, nb);
					e->window->getbounds(&ob);
					e->window->move(nb.x-(ob.x-bf.x), nb.y-(ob.y-bf.y));
					e->window->resize(nb.w-ob.w, nb.h-ob.h);
					tileNum--;
				}
			});
		}
	}
	sendmsg(msg_dirtyview);
}

int ht_app::run(bool modal)
{
	sendmsg(msg_draw, 0);
	while (!exit_program) {
		try {
			if (keyb_keypressed()) {
				ht_key k = keyb_getkey();
				sendmsg(msg_keypressed, k);
				sendmsg(msg_draw);
			}
			if (sys_get_winch_flag()) {
				modal_resize();
			}
			ht_queued_msg *q;
			while ((q = dequeuemsg())) {
				htmsg m = q->msg;
				q->target->sendmsg(&m);
				sendmsg(msg_draw);
				delete q;
			}
			do_idle();
		} catch (const Exception &x) {
			errorbox("unhandled exception: %y", &x);
		} catch (const std::exception &x) {
			errorbox("unhandled exception: %s", x.what());
		} catch (...) {
			errorbox("unhandled exception: unknown");
		}
	}
	return 0;
}

void ht_app::store(ObjectStream &f) const
{
	PUT_OBJECT(f, registry);
	store_history(f);
}

/*
 *	CLASS ht_vstate_history_entry
 */

ht_vstate_history_entry::ht_vstate_history_entry(Object *Data, ht_view *View)
{
	data = Data;
	view = View;
}

ht_vstate_history_entry::~ht_vstate_history_entry()
{
	data->done();
	delete data;
}

/*
 *	CLASS ht_file_window
 */
ht_file_window::ht_file_window()
	: vstate_history(true)
{
}

void ht_file_window::init(Bounds *b, const char *desc, uint framestyle, uint number, File *f)
{
	ht_window::init(b, desc, framestyle, number);
	file = f;
	vstate_history_pos = 0;
}

void ht_file_window::done()
{
	ht_window::done();
}

void ht_file_window::add_vstate_history(ht_vstate_history_entry *e)
{
	int c = vstate_history.count();
	if (c > vstate_history_pos) {
		vstate_history.delRange(vstate_history_pos, c);
	}
	vstate_history += e;
	vstate_history_pos++;
}

void ht_file_window::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
	case cmd_vstate_restore:
		if (vstate_history_pos) {
			vstate_history_pos--;
			ht_vstate_history_entry *e = (ht_vstate_history_entry*)
				vstate_history[vstate_history_pos];
			htmsg m;
			m.msg = msg_vstate_restore;
			m.type = mt_empty;
			m.data1.ptr = e->data;
			e->view->sendmsg(&m);
			focus(e->view);
		}
		clearmsg(msg);
		return;
	case msg_vstate_save: {
		Object *data = (Object*)msg->data1.ptr;
		ht_view *view = (ht_view*)msg->data2.ptr;
		add_vstate_history(new ht_vstate_history_entry(data, view));
		break;
	}
	case msg_accept_close: if (file) {
		bool modified = false;
		String fn;
		if (file->getFilename(fn).isEmpty()) {
			modified = true;
		} else {			
			FileOfs start = 0;
			file->cntl(FCNTL_MODS_IS_DIRTY, start, file->getSize(), &modified);
		}
		if (modified) {
			char q[1024];
			if (fn.isEmpty()) {
				ht_snprintf(q, sizeof q, "untitled file has been modified, save?");
			} else {
				ht_snprintf(q, sizeof q, "file %y has been modified, save?", &fn);
			}
			switch (msgbox(btmask_yes+btmask_no+btmask_cancel, "confirmation", 0, align_center, q)) {
			case button_yes: {
				app->focus(this);
				htmsg msg;
				msg.msg = cmd_file_save;
				msg.type = mt_empty;
				app->sendmsg(&msg);
				if ((uint)msg.msg != cmd_file_save) break;
			}
			case button_cancel:
				clearmsg(msg);
				return;
			}
		}
		// flush so that cmd_analyser_save get correct mtime
		file->cntl(FCNTL_FLUSH_STAT);

		Analyser *a;
		htmsg m;
		m.msg = msg_get_analyser;
		m.type = mt_broadcast;
		m.data1.ptr = NULL;
		sendmsg(&m);
		a = (Analyser*)m.data1.ptr;
		if (m.msg == msg_retval && a && a->isDirty()) {
			sendmsg(cmd_analyser_save);
		}
		}
		break;
	case cmd_analyser_save: {
		String filename;
		file->getFilename(filename);
		filename += HT_FILE_CONFIG_SUFFIX;
		LOG("%y: saving config", &filename);
		do {
			String err;
			if (save_fileconfig(filename.contentChar(), ht_fileconfig_magic, ht_fileconfig_fileversion, file_window_store_fcfg_func, this, err) != LS_OK) {
				String e;
				e.assignFormat("Couldn't save '%y': %y\n\nRetry?", &filename, &err);
				switch (msgbox(btmask_yes+btmask_no+btmask_cancel, "confirmation", 0, align_center, e.contentChar())) {
				case button_ok: continue;
				case button_cancel: return;
				}
				LOG("%y: failed", &filename);
			} else {
				LOG("%y: done", &filename);
			}
			break;
		} while (1);
		clearmsg(msg);
		break;
	}
	}
	ht_window::handlemsg(msg);
	switch (msg->msg) {
	case msg_keypressed:
		switch (msg->data1.integer) {
		case K_Meta_Backspace:
		case K_Backspace:
			sendmsg(cmd_vstate_restore);
			clearmsg(msg);
			return;
		}
		break;
	}
}

/**/

List *build_vfs_list()
{
	/* build vfs list */
	List *vfslist = new Array(true);

#if 1
	/* LocalFS */
	LocalFs *localfs = new LocalFs();
	localfs->init();

	/* RegistryFS */
	RegistryFs *registryfs = new RegistryFs();
	registryfs->init();

	vfslist->insert(localfs);
	vfslist->insert(registryfs);
#else
	/* file_vfs */
	ht_file_vfs *file_vfs = new ht_file_vfs();
	file_vfs->init();

	/* reg_vfs */
	ht_reg_vfs *reg_vfs = new ht_reg_vfs();
	reg_vfs->init();

	vfslist->insert(file_vfs);
	vfslist->insert(reg_vfs);
#endif

	/**/
	return vfslist;
}

BUILDER(ATOM_HT_APP, ht_app, ht_dialog);
BUILDER(ATOM_HT_PROJECT, ht_project, AVLTree);
BUILDER(ATOM_HT_PROJECT_ITEM, ht_project_item, Object);

/*
 *	INIT
 */

bool init_app()
{
	Bounds b;
	screen = allocSystemDisplay(ht_name" "ht_version);

	loglines = new ht_log();
	loglines->init();

	virtual_fs_list = build_vfs_list();

	project = NULL;

	b.x = 0;
	b.y = 0;
	b.w = screen->w;
	b.h = screen->h;
	app = new ht_app();
	((ht_app*)app)->init(&b);
	baseview = app;

	app_memory_reserve = malloc(16384); // malloc, not smalloc
	out_of_memory_func = &app_out_of_memory_proc;

	REGISTER(ATOM_HT_APP, ht_app);
	REGISTER(ATOM_HT_PROJECT, ht_project);
	REGISTER(ATOM_HT_PROJECT_ITEM, ht_project_item);

	return true;
}

/*
 *	DONE
 */

void done_app()
{
	UNREGISTER(ATOM_HT_APP, ht_app);
	UNREGISTER(ATOM_HT_PROJECT, ht_project);
	UNREGISTER(ATOM_HT_PROJECT_ITEM, ht_project_item);
	
	out_of_memory_func = &out_of_memory;
	free(app_memory_reserve);

	delete (Object*)project;
	delete virtual_fs_list;

	delete loglines;

	if (app) {
		app->done();
		delete app;
	}
	
	delete screen;
}

ht-2.0.22/elfstruc.h0000644000175000017500000004133412156427737011154 00000000000000/* 
 *	HT Editor
 *	elfstruc.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/*	mostly assembled from TIS ELF 1.1g and BFD-ELF 	*/

#ifndef __ELFSTRUC_H__
#define __ELFSTRUC_H__

#include "io/types.h"

/* all architectures */
typedef unsigned char elf_unsigned_char;

/* 32bit architectures */
typedef uint32 elf32_addr;
typedef uint16 elf32_half;
typedef uint32 elf32_off;
typedef uint32 elf32_sword;
typedef uint32 elf32_word;

/* 64bit architectures */
typedef uint64 elf64_addr;
typedef uint64 elf64_off;
typedef uint64 elf64_sword;
typedef uint64 elf64_word;
typedef uint32 elf64_half;
typedef uint16 elf64_quarter;

/*
 *	ELF header
 */

/* e_ident */
#define ELF_EI_MAG0			0
#define ELF_EI_MAG1			1
#define ELF_EI_MAG2			2
#define ELF_EI_MAG3			3
#define ELF_EI_CLASS			4
#define ELF_EI_DATA			5
#define ELF_EI_VERSION			6
#define ELF_EI_OSABI			7
#define ELF_EI_ABIVERSION		8
#define ELF_EI_PAD			9

#define EI_NIDENT			16

#define ELFMAG0 0x7f
#define ELFMAG1 'E'
#define ELFMAG2 'L'
#define ELFMAG3 'F'

#define ELFCLASSNONE			0
#define ELFCLASS32			1
#define ELFCLASS64			2

#define ELFDATANONE			0
#define ELFDATA2LSB			1
#define ELFDATA2MSB			2

#define ELFOSABI_SYSV			0
#define ELFOSABI_HPUX			1
#define ELFOSABI_NETBSD			2
#define ELFOSABI_LINUX			3
#define ELFOSABI_HURD			4
#define ELFOSABI_86OPEN			5
#define ELFOSABI_SOLARIS		6
#define ELFOSABI_MONTEREY		7
#define ELFOSABI_IRIX			8
#define ELFOSABI_FREEBSD		9
#define ELFOSABI_TRU64			10
#define ELFOSABI_MODESTO		11
#define ELFOSABI_OPENBSD		12
#define ELFOSABI_ARM			97
#define ELFOSABI_STANDALONE		255

/* e_type */
#define ELF_ET_NONE			0
#define ELF_ET_REL			1
#define ELF_ET_EXEC			2
#define ELF_ET_DYN			3
#define ELF_ET_CORE			4
#define ELF_ET_LOOS			0xFE00
#define ELF_ET_HIOS			0xFEFF
#define ELF_ET_LOPROC			0xFF00
#define ELF_ET_HIPROC			0xFFFF

/* e_machine */
#define ELF_EM_NONE			0
#define ELF_EM_M32			1
#define ELF_EM_SPARC			2
#define ELF_EM_386			3
#define ELF_EM_68K			4
#define ELF_EM_88K			5
#define ELF_EM_486			6	/* Intel 80486 */
#define ELF_EM_860			7	/* Intel 80860 */
#define ELF_EM_MIPS			8	/* MIPS R3000 (officially, big-endian only) */
#define ELF_EM_S370			9	/* IBM System/370 */
#define ELF_EM_MIPS_RS4_BE		10	/* MIPS R4000 big-endian */ /* Depreciated */
#define ELF_EM_MIPS_RS3_LE		10	/* MIPS R3000 little-endian (Oct 4 1999 Draft)*/ /* Depreciated */

#define ELF_EM_PARISC			15	/* HPPA */

#define ELF_EM_VPP550			17	/* Fujitsu VPP500 */
#define ELF_EM_SPARC32PLUS		18	/* Sun's "v8plus" */
#define ELF_EM_960			19	/* Intel 80960 */
#define ELF_EM_PPC			20	/* PowerPC */
#define ELF_EM_PPC64			21	/* 64-bit PowerPC */
#define ELF_EM_S390                     22	/* IBM S/390 */
#define ELF_EM_SPU                      23	/* Sony/Toshiba/IBM SPU */

#define ELF_EM_V800			36	/* NEC V800 series */
#define ELF_EM_FR20			37	/* Fujitsu FR20 */
#define ELF_EM_RH32			38	/* TRW RH32 */
#define ELF_EM_MCORE			39	/* Motorola M*Core */ /* May also be taken by Fujitsu MMA */
#define ELF_EM_RCE			39	/* Old name for MCore */
#define ELF_EM_ARM			40	/* ARM */
#define ELF_EM_OLD_ALPHA		41	/* Digital Alpha */
#define ELF_EM_SH			42	/* Hitachi SH */
#define ELF_EM_SPARCV9			43	/* SPARC v9 64-bit */
#define ELF_EM_TRICORE			44	/* Siemens Tricore embedded processor */
#define ELF_EM_ARC			45	/* Argonaut RISC Core, Argonaut Technologies Inc. */
#define ELF_EM_H8_300			46	/* Hitachi H8/300 */
#define ELF_EM_H8_300H			47	/* Hitachi H8/300H */
#define ELF_EM_H8S			48	/* Hitachi H8S */
#define ELF_EM_H8_500			49	/* Hitachi H8/500 */
#define ELF_EM_IA_64			50	/* Intel IA-64 Processor */
#define ELF_EM_MIPS_X			51	/* Stanford MIPS-X */
#define ELF_EM_COLDFIRE			52	/* Motorola Coldfire */
#define ELF_EM_68HC12			53	/* Motorola M68HC12 */
#define ELF_EM_MMA			54	/* Fujitsu Multimedia Accelerator */
#define ELF_EM_PCP			55	/* Siemens PCP */
#define ELF_EM_NCPU			56	/* Sony nCPU embedded RISC processor */
#define ELF_EM_NDR1			57	/* Denso NDR1 microprocesspr */
#define ELF_EM_STARCORE			58	/* Motorola Star*Core processor */
#define ELF_EM_ME16			59	/* Toyota ME16 processor */
#define ELF_EM_ST100			60	/* STMicroelectronics ST100 processor */
#define ELF_EM_TINYJ			61	/* Advanced Logic Corp. TinyJ embedded processor */
#define ELF_EM_X86_64			62	/* X86-64 (AMD Opteron) */
#define ELF_EM_PDSP                     63	/* Sony DSP Processor */
#define ELF_EM_PDP10                    64	/* Digital Equipment Corp. PDP-10 */
#define ELF_EM_PDP11                    65	/* Digital Equipment Corp. PDP-11 */
#define ELF_EM_FX66			66	/* Siemens FX66 microcontroller */
#define ELF_EM_ST9PLUS			67	/* STMicroelectronics ST9+ 8/16 bit microcontroller */
#define ELF_EM_ST7			68	/* STMicroelectronics ST7 8-bit microcontroller */
#define ELF_EM_68HC16			69	/* Motorola MC68HC16 Microcontroller */
#define ELF_EM_68HC11			70	/* Motorola MC68HC11 Microcontroller */
#define ELF_EM_68HC08			71	/* Motorola MC68HC08 Microcontroller */
#define ELF_EM_68HC05			72	/* Motorola MC68HC05 Microcontroller */
#define ELF_EM_SVX			73	/* Silicon Graphics SVx */
#define ELF_EM_ST19			74	/* STMicroelectronics ST19 8-bit microcontroller */
#define ELF_EM_VAX			75	/* Digital VAX */
#define ELF_EM_CRIS		 76	/* Axis Communications 32-bit embedded processor */
#define ELF_EM_JAVELIN	 77	/* Infineon Technologies 32-bit embedded cpu */
#define ELF_EM_FIREPATH	 78	/* Element 14 64-bit DSP processor */
#define ELF_EM_ZSP		 79	/* LSI Logic's 16-bit DSP processor */
#define ELF_EM_MMIX		 80	/* Donald Knuth's educational 64-bit processor */
#define ELF_EM_HUANY	 81	/* Harvard's machine-independent format */
#define ELF_EM_PRISM	 82	/* SiTera Prism */
#define ELF_EM_AVR		 83	/* Atmel AVR 8-bit microcontroller */
#define ELF_EM_FR30		 84	/* Fujitsu FR30 */
#define ELF_EM_D10V		 85	/* Mitsubishi D10V */
#define ELF_EM_D30V		 86	/* Mitsubishi D30V */
#define ELF_EM_V850		 87	/* NEC v850 */
#define ELF_EM_M32R		 88	/* Renesas M32R (formerly Mitsubishi M32R) */
#define ELF_EM_MN10300	 89	/* Matsushita MN10300 */
#define ELF_EM_MN10200	 90	/* Matsushita MN10200 */
#define ELF_EM_PJ		 91	/* picoJava */
#define ELF_EM_OPENRISC	 92	/* OpenRISC 32-bit embedded processor */
#define ELF_EM_ARC_A5	 93	/* ARC Cores Tangent-A5 */
#define ELF_EM_XTENSA	 94	/* Tensilica Xtensa Architecture */
#define ELF_EM_VIDEOCORE	 95	/* Alphamosaic VideoCore processor */
#define ELF_EM_TMM_GPP	 96	/* Thompson Multimedia General Purpose Processor */
#define ELF_EM_NS32K	 97	/* National Semiconductor 32000 series */
#define ELF_EM_TPC		 98	/* Tenor Network TPC processor */
#define ELF_EM_SNP1K	 99	/* Trebia SNP 1000 processor */
#define ELF_EM_ST200	100	/* STMicroelectronics ST200 microcontroller */
#define ELF_EM_IP2K		101	/* Ubicom IP2022 micro controller */
#define ELF_EM_MAX		102	/* MAX Processor */
#define ELF_EM_CR		103	/* National Semiconductor CompactRISC */
#define ELF_EM_F2MC16	104	/* Fujitsu F2MC16 */
#define ELF_EM_MSP430	105	/* TI msp430 micro controller */
#define ELF_EM_BLACKFIN	106	/* ADI Blackfin */
#define ELF_EM_SE_C33	107	/* S1C33 Family of Seiko Epson processors */
#define ELF_EM_SEP		108	/* Sharp embedded microprocessor */
#define ELF_EM_ARCA		109	/* Arca RISC Microprocessor */
#define ELF_EM_UNICORE	110	/* Microprocessor series from PKU-Unity Ltd. and MPRC of Peking University */
#define ELF_EM_EXCESS	111	/* eXcess: 16/32/64-bit configurable embedded CPU */
#define ELF_EM_DXP		112	/* Icera Semiconductor Inc. Deep Execution Processor */
#define ELF_EM_ALTERA_NIOS2	113	/* Altera Nios II soft-core processor */
#define ELF_EM_CRX		114	/* National Semiconductor CRX */
#define ELF_EM_XGATE	115	/* Motorola XGATE embedded processor */
#define ELF_EM_C166		116	/* Infineon C16x/XC16x processor */
#define ELF_EM_M16C		117	/* Renesas M16C series microprocessors */
#define ELF_EM_DSPIC30F	118	/* Microchip Technology dsPIC30F Digital Signal Controller */
#define ELF_EM_CE		119	/* Freescale Communication Engine RISC core */
#define ELF_EM_M32C		120	/* Renesas M32C series microprocessors */

#define ELF_EM_TSK3000	131	/* Altium TSK3000 core */
#define ELF_EM_RS08		132	/* Freescale RS08 embedded processor */

#define ELF_EM_ECOG2	134	/* Cyan Technology eCOG2 microprocessor */
#define ELF_EM_SCORE        135     /* Sunplus Score */
#define ELF_EM_DSP24	136	/* New Japan Radio (NJR) 24-bit DSP Processor */
#define ELF_EM_VIDEOCORE3	137	/* Broadcom VideoCore III processor */
#define ELF_EM_LATTICEMICO32 138	/* RISC processor for Lattice FPGA architecture */
#define ELF_EM_SE_C17	139	/* Seiko Epson C17 family */

#define ELF_EM_MMDSP_PLUS	160	/* STMicroelectronics 64bit VLIW Data Signal Processor */
#define ELF_EM_CYPRESS_M8C	161	/* Cypress M8C microprocessor */
#define ELF_EM_R32C		162	/* Renesas R32C series microprocessors */
#define ELF_EM_TRIMEDIA	163	/* NXP Semiconductors TriMedia architecture family */
#define ELF_EM_QDSP6	164	/* QUALCOMM DSP6 Processor */
#define ELF_EM_8051		165	/* Intel 8051 and variants */
#define ELF_EM_STXP7X	166	/* STMicroelectronics STxP7x family */
#define ELF_EM_NDS32	167	/* Andes Technology compact code size embedded RISC processor family */
#define ELF_EM_ECOG1	168	/* Cyan Technology eCOG1X family */
#define ELF_EM_ECOG1X	168	/* Cyan Technology eCOG1X family */
#define ELF_EM_MAXQ30	169	/* Dallas Semiconductor MAXQ30 Core Micro-controllers */
#define ELF_EM_XIMO16	170	/* New Japan Radio (NJR) 16-bit DSP Processor */
#define ELF_EM_MANIK	171	/* M2000 Reconfigurable RISC Microprocessor */
#define ELF_EM_CRAYNV2	172	/* Cray Inc. NV2 vector architecture */
#define ELF_EM_RX		173	/* Renesas RX family */
#define ELF_EM_METAG	174	/* Imagination Technologies META processor architecture */
#define ELF_EM_MCST_ELBRUS	175	/* MCST Elbrus general purpose hardware architecture */
#define ELF_EM_ECOG16	176	/* Cyan Technology eCOG16 family */
#define ELF_EM_CR16	177	/* National Semiconductor CompactRISC 16-bit processor */
#define ELF_EM_ETPU	178	/* Freescale Extended Time Processing Unit */
#define ELF_EM_SLE9X	179	/* Infineon Technologies SLE9X core */
#define ELF_EM_L1OM	180	/* Intel L1OM */
#define ELF_EM_K1OM	181	/* Intel K1OM */
#define ELF_EM_INTEL182	182	/* Reserved by Intel */
#define ELF_EM_AARCH64	183	/* ARM 64-bit architecture */
#define ELF_EM_ARM184	184	/* Reserved by ARM */
#define EFL_EM_AVR32	185	/* Atmel Corporation 32-bit microprocessor family */
#define ELF_EM_ALPHA    0x9026


/* e_version */
#define ELF_EV_NONE			0
#define ELF_EV_CURRENT			1

struct ELF_HEADER {
	elf_unsigned_char e_ident[EI_NIDENT];
};

struct ELF_HEADER32 {
	elf32_half e_type;
	elf32_half e_machine;
	elf32_word e_version;
	elf32_addr e_entry;
	elf32_off e_phoff;
	elf32_off e_shoff;
	elf32_word e_flags;
	elf32_half e_ehsize;
	elf32_half e_phentsize;
	elf32_half e_phnum;
	elf32_half e_shentsize;
	elf32_half e_shnum;
	elf32_half e_shstrndx;
};

struct ELF_HEADER64 {
	elf64_quarter e_type;
	elf64_quarter e_machine;
	elf64_half e_version;
	elf64_addr e_entry;
	elf64_off e_phoff;
	elf64_off e_shoff;
	elf64_half e_flags;
	elf64_quarter e_ehsize;
	elf64_quarter e_phentsize;
	elf64_quarter e_phnum;
	elf64_quarter e_shentsize;
	elf64_quarter e_shnum;
	elf64_quarter e_shstrndx;
};

/*
 *	ELF section header
 */

/* indices */
#define ELF_SHN_UNDEF		0
#define ELF_SHN_ABS		0xfff1
#define ELF_SHN_COMMON		0xfff2

/* sh_type */
#define ELF_SHT_NULL		0
#define ELF_SHT_PROGBITS	1
#define ELF_SHT_SYMTAB		2
#define ELF_SHT_STRTAB		3
#define ELF_SHT_RELA		4
#define ELF_SHT_HASH		5
#define ELF_SHT_DYNAMIC		6
#define ELF_SHT_NOTE		7
#define ELF_SHT_NOBITS		8
#define ELF_SHT_REL		9
#define ELF_SHT_SHLIB		10
#define ELF_SHT_DYNSYM		11

#define ELF_SHT_INIT_ARRAY	14
#define ELF_SHT_FINI_ARRAY	15
#define ELF_SHT_PREINIT_ARRAY	16

/* sh_flags */
#define ELF_SHF_WRITE			(1<<0)
#define ELF_SHF_ALLOC			(1<<1)
#define ELF_SHF_EXECINSTR		(1<<2)
// 1<<3 missing
#define ELF_SHF_MERGE			(1<<4)
#define ELF_SHF_STRINGS			(1<<5)
#define ELF_SHF_INFO_LINK		(1<<6)
#define ELF_SHF_LINK_ORDER		(1<<7)
#define ELF_SHF_OS_NONCONFORMING	(1<<8)

struct ELF_SECTION_HEADER32 {
	elf32_word sh_name;
	elf32_word sh_type;
	elf32_word sh_flags;
	elf32_addr sh_addr;     
	elf32_off sh_offset;
	elf32_word sh_size;
	elf32_word sh_link;
	elf32_word sh_info;
	elf32_word sh_addralign;
	elf32_word sh_entsize;
};

struct ELF_SECTION_HEADER64 {
	elf64_half sh_name;
	elf64_half sh_type;
	elf64_word sh_flags;
	elf64_addr sh_addr;
	elf64_off sh_offset;
	elf64_word sh_size;
	elf64_half sh_link;
	elf64_half sh_info;
	elf64_word sh_addralign;
	elf64_word sh_entsize;
};

/*
 *	ELF program header
 */

#define ELF_PT_NULL		0
#define ELF_PT_LOAD		1
#define ELF_PT_DYNAMIC		2
#define ELF_PT_INTERP		3
#define ELF_PT_NOTE		4
#define ELF_PT_SHLIB		5
#define ELF_PT_PHDR		6
#define ELF_PT_TLS		7          /* Thread-local storage segment  */
#define ELF_PT_NUM		8          /* Number of defined types       */
#define ELF_PT_GNU_EH_FRAME	0x6474e550 /* GCC .eh_frame_hdr segment     */
#define ELF_PT_GNU_STACK	0x6474e551 /* Indicates stack executability */
#define ELF_PT_GNU_RELRO	0x6474e552 /* Read-only after relocation    */ 
#define ELF_PT_PAX_FLAGS	0x65041580 /* Indicates PaX flag markings */

struct ELF_PROGRAM_HEADER32 {
	elf32_word p_type;
	elf32_off p_offset;
	elf32_addr p_vaddr;
	elf32_addr p_paddr;
	elf32_word p_filesz;
	elf32_word p_memsz;
	elf32_word p_flags;
	elf32_word p_align;
} PACKED;

struct ELF_PROGRAM_HEADER64 {
	elf64_half p_type;
	elf64_half p_flags;
	elf64_off p_offset;
	elf64_addr p_vaddr;
	elf64_addr p_paddr;
	elf64_word p_filesz;
	elf64_word p_memsz;
	elf64_word p_align;
};

struct ELF_NHEADER32 {
	elf32_word n_descsz;
	elf32_word n_namesz;
	elf32_word n_type;
} PACKED;

/*
 *	ELF symbol
 */

#define ELF_STB_LOCAL		0
#define ELF_STB_GLOBAL		1
#define ELF_STB_WEAK		2

#define ELF_STT_NOTYPE		0
#define ELF_STT_OBJECT		1
#define ELF_STT_FUNC		2
#define ELF_STT_SECTION		3
#define ELF_STT_FILE		4
#define ELF_STT_COMMON		5

#define ELF32_ST_BIND(i)		((i)>>4)
#define ELF32_ST_TYPE(i)		((i)&0xf)
#define ELF32_ST_INFO(b,t)	(((b)>>4)|((t)&0xf))

#define ELF64_ST_BIND(i)		((i)>>4)
#define ELF64_ST_TYPE(i)		((i)&0xf)
#define ELF64_ST_INFO(b,t)	(((b)>>4)|((t)&0xf))

struct ELF_SYMBOL32 {
	elf32_word st_name;
	elf32_addr st_value;
	elf32_word st_size;
	elf_unsigned_char st_info;
	elf_unsigned_char st_other;
	elf32_half st_shndx;
} PACKED;

struct ELF_SYMBOL64 {
	elf64_half st_name;
	elf_unsigned_char st_info;
	elf_unsigned_char st_other;
	elf64_quarter st_shndx;
	elf64_word st_value;
	elf64_word st_size;
} PACKED;

/*
 *	ELF relocation
 */

#define ELF32_R_SYM(i)		((i)>>8)
#define ELF32_R_TYPE(i)		((unsigned char)(i))
#define ELF32_R_INFO(s,t)	(((s)<<8)+(unsigned char)(t))

#define ELF_R_386_NONE			0
#define ELF_R_386_32			1
#define ELF_R_386_PC32			2
#define ELF_R_386_GOT32			3
#define ELF_R_386_PLT32			4
#define ELF_R_386_COPY			5
#define ELF_R_386_GLOB_DAT		6
#define ELF_R_386_JMP_SLOT		7
#define ELF_R_386_RELATIVE		8
#define ELF_R_386_GOTOFF		9
#define ELF_R_386_GOTPC			10

#define ELF_R_X86_64_NONE		0
#define ELF_R_X86_64_64			1
#define ELF_R_X86_64_PC32		2
#define ELF_R_X86_64_GOT32		3
#define ELF_R_X86_64_PLT32		4
#define ELF_R_X86_64_COPY		5
#define ELF_R_X86_64_GLOB_DAT		6
#define ELF_R_X86_64_JUMP_SLOT		7
#define ELF_R_X86_64_RELATIVE		8
#define ELF_R_X86_64_GOTPCREL		9
#define ELF_R_X86_64_32			10
#define ELF_R_X86_64_32S		11
#define ELF_R_X86_64_16			12
#define ELF_R_X86_64_PC16		13
#define ELF_R_X86_64_8			14
#define ELF_R_X86_64_PC8		15

struct ELF_REL32 {
	elf32_addr	r_offset;
	elf32_word	r_info;
} PACKED;

struct ELF_REL64 {
	elf64_addr	r_offset;
	union {
		elf64_word	r_info;
		struct {
			elf64_half r_type;
			elf64_half r_sym;
		};
	};
} PACKED;

struct ELF_RELA32 {
	elf32_addr	r_offset;
	elf32_word	r_info;
	elf32_sword	r_addend;
} PACKED;

struct ELF_RELA64 {
	elf64_addr	r_offset;
	union {
		elf64_word	r_info;
		struct {
			elf64_half r_type;
			elf64_half r_sym;
		};
	};
	elf64_sword	r_addend;
} PACKED;

extern byte ELF_HEADER_struct[];
extern byte ELF_HEADER32_struct[];
extern byte ELF_SECTION_HEADER32_struct[];
extern byte ELF_PROGRAM_HEADER32_struct[];
extern byte ELF_SYMBOL32_struct[];
extern byte ELF_REL32_struct[];
extern byte ELF_RELA32_struct[];
extern byte ELF_HEADER64_struct[];
extern byte ELF_SECTION_HEADER64_struct[];
extern byte ELF_PROGRAM_HEADER64_struct[];
extern byte ELF_SYMBOL64_struct[];
extern byte ELF_REL64_struct[];
extern byte ELF_RELA64_struct[];

struct ELFAddress {
	union {
		uint32 a32;
		uint64 a64;
	};
};

#endif /* __ELFSTRUC_H__ */
ht-2.0.22/hthex.h0000644000175000001440000000313011010140021010367 00000000000000/* 
 *	HT Editor
 *	hthex.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTHEX_H__
#define __HTHEX_H__

#include "formats.h"

#define DESC_HEX "hex"

extern format_viewer_if hthex_if;

/*
 *	CLASS ht_hex_viewer
 */

class ht_hex_file_sub;
class ht_hex_viewer: public ht_uformat_viewer {
public:
	ht_hex_file_sub *h;
protected:
	virtual	int get_pindicator_str(char *buf, int max_len);
	virtual	bool get_vscrollbar_pos(int *pstart, int *psize);
	virtual	void handlemsg(htmsg *msg);
	virtual	bool offset_to_pos(FileOfs ofs, viewer_pos *p);
	virtual	bool pos_to_offset(viewer_pos p, FileOfs *ofs);
	virtual	bool qword_to_pos(uint64 q, viewer_pos *pos);
	virtual	bool func_handler(eval_scalar *result, char *name, eval_scalarlist *params);
	virtual	bool symbol_handler(eval_scalar *result, char *name);
};

/*
 *	CLASS ht_hex_file_sub
 */

class ht_hex_file_sub: public ht_hex_sub {
public:
/* overwritten */
	virtual	void handlemsg(htmsg *msg);
};

#endif /* !__HTHEX_H__ */

ht-2.0.22/htfinfo.h0000644000175000001440000000221210615341616010733 00000000000000/* 
 *	HT Editor
 *	htfinfo.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTFINFO_H__
#define __HTFINFO_H__

#include "formats.h"
#include "htdialog.h"

#define FINFO_DESC "file info"

extern format_viewer_if htfinfo_if;

/*
 *   ht_finfo_text
 */
 
class ht_finfo_text: public ht_statictext {
protected:
	File *file;
	const char *olddesc;
	
public:
		void	init(Bounds *b, File *file);
	virtual	void	done();
/* overwritten */
	virtual	int     gettext(char *text, int max_len);
};

#endif /* __HTFINFO_H__ */

ht-2.0.22/xbestruct.h0000644000175000001440000001117010615341625011324 00000000000000/* 
 *	HT Editor
 *	xbestruct.h
 *
 *	Copyright (C) 2003 Stefan Esser
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __XBESTRUCT_H_
#define __XBESTRUCT_H_

#include "io/types.h"
#include "tools.h"

typedef unsigned int RVA;

#define XBE_MAGIC_LENGTH 4
#define XBE_MAGIC0	'X'
#define XBE_MAGIC1	'B'
#define XBE_MAGIC2	'E'
#define XBE_MAGIC3	'H'

#define XBE_SIZE_OF_SIGNATURE	256

struct XBE_IMAGE_HEADER {
    byte	magic_id[XBE_MAGIC_LENGTH];
    byte	signature[XBE_SIZE_OF_SIGNATURE];
    uint32	base_address;
    uint32	size_of_headers;
    uint32	size_of_image;
    uint32	size_of_imageheader;
    uint32	timedate;
    uint32	certificate_address;
    uint32	number_of_sections;
    uint32	section_header_address;
    uint32	initialisation_flags;
    uint32	entry_point;
    uint32	tls_address;
    uint32	pe_stack_commit;
    uint32	pe_heap_reserve;
    uint32	pe_heap_commit;
    uint32	pe_base_address;
    uint32	pe_size_of_image;
    uint32	pe_checksum;
    uint32	pe_timedate;
    uint32	debug_pathname_address;
    uint32	debug_filename_address;
    uint32	debug_unicode_filename_address;
    uint32	kernel_image_thunk_address;
    uint32	non_kernel_import_directory_address;
    uint32	number_of_library_versions;
    uint32	library_versions_address;
    uint32	kernel_library_version_address;
    uint32	xapi_library_version_address;
    uint32	logo_bitmap_address;
    uint32	logo_bitmap_size;
} PACKED;


#define XBE_TITLE_NAME_LENGTH	40
#define XBE_NUM_ALTERNATE	16
#define XBE_LAN_KEY_LENGTH	16
#define XBE_SIGNATURE_KEY_LENGTH	16

#define XBE_MEDIA_TYPE_HARD_DISK		0x00000001
#define XBE_MEDIA_TYPE_DVD_X2			0x00000002
#define XBE_MEDIA_TYPE_DVD_CD			0x00000004
#define XBE_MEDIA_TYPE_CD			0x00000008
#define XBE_MEDIA_TYPE_DVD_5_RO			0x00000010
#define XBE_MEDIA_TYPE_DVD_9_RO			0x00000020
#define XBE_MEDIA_TYPE_DVD_5_RW			0x00000040
#define XBE_MEDIA_TYPE_DVD_9_RW			0x00000080
#define XBE_MEDIA_TYPE_DONGLE			0x00000100
#define XBE_MEDIA_TYPE_MEDIA_BOARD		0x00000200
#define XBE_MEDIA_TYPE_NONSECURE_HARD_DISK	0x40000000
#define XBE_MEDIA_TYPE_NONSECURE_MODE		0x80000000
#define XBE_MEDIA_TYPE_MEDIA_MASK		0x00FFFFFF

#define XBE_GAME_REGION_NA			0x00000001
#define XBE_GAME_REGION_JAPAN			0x00000002
#define XBE_GAME_REGION_RESTOFWORLD		0x00000004
#define XBE_GAME_REGION_MANUFACTURING		0x80000000

struct XBE_CERTIFICATE {
    uint32	size_of_certificate;
    uint32	timedate;
    uint32	title_id;
    uint16	title_name[XBE_TITLE_NAME_LENGTH];
    uint32	alternate_title_ids[XBE_NUM_ALTERNATE];
    uint32	allowed_media;
    uint32	game_region;
    uint32	game_ratings;
    uint32	disk_number;
    uint32	version;
    byte	lan_key[XBE_LAN_KEY_LENGTH];
    byte	signature_key[XBE_SIGNATURE_KEY_LENGTH];
    byte	alternate_signature_keys[XBE_NUM_ALTERNATE][XBE_SIGNATURE_KEY_LENGTH];    
} PACKED;


#define XBE_SECTION_FLAGS_WRITABLE	1
#define XBE_SECTION_FLAGS_PRELOAD	2
#define XBE_SECTION_FLAGS_EXECUTABLE	4
#define XBE_SECTION_FLAGS_INSERTEDFILE	8
#define XBE_SECTION_FLAGS_HEADPAGE_RO	16
#define XBE_SECTION_FLAGS_TAILPAGE_RO	32

#define XBE_SECTION_DIGEST_LENGTH	20

struct XBE_SECTION_HEADER {
    uint32	section_flags;
    uint32	virtual_address;
    uint32	virtual_size;
    uint32	raw_address;
    uint32	raw_size;
    uint32	section_name_address;
    uint32	section_name_ref_count;
    uint32	head_shared_page_ref_count_address;
    uint32	tail_shared_page_ref_count_address;
    byte	section_digest[XBE_SECTION_DIGEST_LENGTH];
} PACKED;

#define XBE_LIBRARY_NAME_LENGTH		8

struct XBE_LIBRARY_VERSION {
    byte	library_name[XBE_LIBRARY_NAME_LENGTH];
    uint16	major_version;
    uint16	minor_version;
    uint16	build_version;
    uint16	library_flags;
} PACKED;


struct XBE_TLS_DIRECTORY {
    uint32	data_start_address;
    uint32	data_end_address;
    uint32	tls_index_address;
    uint32	tls_callback_address;
    uint32	size_of_zero_fill;
    uint32	characteristics;
} PACKED;

extern byte XBE_IMAGE_HEADER_struct[];
extern byte XBE_CERTIFICATE_struct[];
extern byte XBE_SECTION_HEADER_struct[];
extern byte XBE_LIBRARY_VERSION_struct[];
extern byte XBE_TLS_DIRECTORY_struct[];


#endif
ht-2.0.22/log.h0000644000175000001440000000170710206756711010071 00000000000000/*
 *	HT Editor
 *	log.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __LOG_H__
#define __LOG_H__

void ht_logf(int color, const char *format, ...);

#define LOG_NORMAL 0
#define LOG_WARN 1
#define LOG_ERROR 2

#define LOG(a...) ht_logf(LOG_NORMAL, a);
#define LOG_EX(c, a...) ht_logf(c, a);

#endif /* __LOG_H__ */

ht-2.0.22/htle.h0000644000175000001440000001107610615341620010235 00000000000000/* 
 *	HT Editor
 *	htle.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTLE_H__
#define __HTLE_H__

#include "htobj.h"
#include "formats.h"
#include "relfile.h"

#include "lestruct.h"
#include "endianess.h"

#define DESC_LE "le - win,os2 linear exe"
#define DESC_LE_HEADER "le/header"
#define DESC_LE_VXD "le/vxd descriptor"
#define DESC_LE_OBJECTS "le/objects"
#define DESC_LE_PAGEMAP "le/page map"
#define DESC_LE_ENTRYPOINTS "le/entrypoints"
#define DESC_LE_IMAGE "le/image"

#define ATOM_LE_FLAGS			0x4c450000
#define ATOM_LE_FLAGS_STR		 "4c450000"

#define ATOM_LE_MACHINE			0x4c450001
#define ATOM_LE_MACHINE_STR		 "4c450001"

#define ATOM_LE_OS				0x4c450002
#define ATOM_LE_OS_STR			 "4c450002"

#define ATOM_LE_OBJFLAGS   		0x4c450003
#define ATOM_LE_OBJFLAGS_STR		 "4c450003"

#define ATOM_LE_ENTRY_FLAGS		0x4c450004
#define ATOM_LE_ENTRY_FLAGS_STR	 "4c450004"

#define ATOM_LE_ENTRY_BUNDLE_FLAGS		0x4c450005
#define ATOM_LE_ENTRY_BUNDLE_FLAGS_STR	 "4c450005"

#define LEAddress uint32

#define LE_ADDR_INVALID	0
#define LE_BASE_ADDR	0x400000

class ht_le_page_file;

struct ht_le_shared_data {
	Endianess byteorder;
	FileOfs hdr_ofs;
	LE_HEADER hdr;
	ht_viewer *v_header;
	ht_viewer *v_objects;
	ht_viewer *v_pagemaps;
	ht_viewer *v_image;
	ht_viewer *v_le_vxd;
	ht_le_objmap objmap;
	ht_le_pagemap pagemap;
	bool is_vxd;
	FileOfs vxd_desc_linear_ofs;
	LE_VXD_DESCRIPTOR vxd_desc;
	ht_le_page_file *linear_file;
	ht_reloc_file *reloc_file;
	LEAddress best_entrypoint;
};

class ht_le: public ht_format_group {
protected:
	bool loc_enum;

			void check_vxd();
			void do_fixups();
			void read_pagemap();
			void read_objects();
public:
			void init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs h);
	virtual	void done();
/* overwritten */
	virtual   void loc_enum_start();
	virtual   bool loc_enum_next(ht_format_loc *loc);
};

extern format_viewer_if htle_if;

/*
 *	CLASS ht_le_page_file
 */

class ht_le_page_file: public FileLayer {
protected:
	ht_le_pagemap *pagemap;
	uint32 pagemapsize;
	uint32 page_size;
	FileOfs ofs;
public:
			ht_le_page_file(File *file, bool own_file, ht_le_pagemap *pagemap, uint32 pagemapsize, uint32 page_size);
/* overwritten */
	virtual bool isdirty(FileOfs offset, FileOfs range);
	virtual uint read(void *buf, uint size);
	virtual void seek(FileOfs offset);
	virtual FileOfs tell() const;
	virtual int vcntl(uint cmd, va_list vargs);
	virtual uint write(const void *buf, uint size);
/* new */
	   bool map_ofs(uint32 lofs, FileOfs *pofs, FileOfs *maxsize);
	   bool unmap_ofs(FileOfs pofs, uint32 *lofs);
};

/*
 *	CLASS ht_le_reloc_entry
 */

class ht_le_reloc_entry: public Object {
public:
	uint ofs;	// FIXME: hack
	uint seg;
	LEAddress addr;
	uint8 address_type;
	uint8 reloc_type;

	ht_le_reloc_entry(uint ofs, uint seg, LEAddress addr, uint8 address_type, uint8 reloc_type);
};

/*
 *	CLASS ht_le_reloc_file
 */

class ht_le_reloc_file: public ht_reloc_file {
protected:
	ht_le_shared_data *data;
/* overwritten */
	virtual void	reloc_apply(Object *reloc, byte *data);
	virtual bool	reloc_unapply(Object *reloc, byte *data);
public:
			ht_le_reloc_file(File *streamfile, bool own_streamfile, ht_le_shared_data *data);
};

FileOfs LE_get_seg_ofs(ht_le_shared_data *LE_shared, uint i);
LEAddress LE_get_seg_addr(ht_le_shared_data *LE_shared, uint i);
uint LE_get_seg_psize(ht_le_shared_data *LE_shared, uint i);
uint LE_get_seg_vsize(ht_le_shared_data *LE_shared, uint i);

bool LE_addr_to_segment(ht_le_shared_data *LE_shared, LEAddress Addr, int *segment);
bool LE_addr_is_physical(ht_le_shared_data *LE_shared, LEAddress Addr);
bool LE_addr_to_ofs(ht_le_shared_data *LE_shared, LEAddress Addr, FileOfs *ofs);

bool LE_ofs_to_addr(ht_le_shared_data *LE_shared, FileOfs ofs, LEAddress *Addr);

LEAddress LE_MAKE_ADDR(ht_le_shared_data *LE_shared, uint16 seg, uint32 ofs);
uint16 LE_ADDR_SEG(ht_le_shared_data *LE_shared, LEAddress a);
uint32 LE_ADDR_OFS(ht_le_shared_data *LE_shared, LEAddress a);

#endif /* __HTLE_H__ */

ht-2.0.22/htmenu.cc0000644000175000001440000004404610615341620010742 00000000000000/*
 *	HT Editor
 *	htmenu.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include 

#include "htapp.h"		// for queuemsg
#include "htctrl.h"
#include "keyb.h"
#include "htmenu.h"
#include "htpal.h"
#include "htreg.h"
#include "strtools.h"
#include "stream.h"
#include "tools.h"

#define button_left	100
#define button_right	101

char *shortcut_str(char *str)
{
	while (*str) {
		if (*str=='~') {
			memmove(str, str+1, strlen(str));
			return str;
		}
		str++;
	}
	return NULL;
}

bool execute_submenu(int x, int y, ht_context_menu *m)
{
	int curentry=0;
	bool term=false;
	Bounds scr;
	app->getbounds(&scr);
	do {
		Bounds b;
		b.x=x+m->xpos-1;
		b.y=y;
		b.w=m->width+4;
		b.h=m->count()+2;
		if (b.y+b.h > scr.h) {
			if (scr.h > b.h) {
				b.y = scr.h - b.h;
				if (b.y >= 2) b.y -= 2;
			} else {
				b.y = 0;
			}
		}
		ht_menu_window *d = new ht_menu_window();
		d->init(&b, m);
		ht_menu_window_data a;
		a.selected = curentry;
		d->databuf_set(&a, sizeof a);
		b.x = 0;
		b.y = 0;
		ht_frame *frame = new ht_menu_frame();
		frame->init(&b, 0, FS_MOVE/*just for fun*/);
		d->setframe(frame);
		d->setpalette(palkey_generic_menu_default);
		int r = d->run(false);
		d->done();
		delete d;
		switch (r) {
		case button_ok: {
			return true;
		}
		default:
			term = true;
		}
	} while (!term);
	return false;
}

/*
 *	CLASS ht_context_menu
 */

void ht_context_menu::init(const char *Name)
{
	name = ht_strdup(Name);
	shortcut = shortcut_str(name);
	width = 0;
}

void ht_context_menu::done()
{
	free(name);
}

int ht_context_menu::count()
{
	return 0;
}

ht_context_menu_entry *ht_context_menu::enum_entry_first()
{
	return NULL;
}

ht_context_menu_entry *ht_context_menu::enum_entry_next()
{
	return NULL;
}

ht_context_menu_entry *ht_context_menu::get_entry(int n)
{
	ht_context_menu_entry *e=enum_entry_first();
	while (n-- && e) {
		e = enum_entry_next();
	}
	return e;
}

const char *ht_context_menu::get_name()
{
	return name;
}

const char *ht_context_menu::get_shortcut()
{
	return shortcut;
}

/*
 *	CLASS ht_static_context_menu
 */

void ht_static_context_menu::init(const char *name)
{
	ht_context_menu::init(name);
	context_menu_entry = new Array(true);
}

void ht_static_context_menu::done()
{
	delete context_menu_entry;
	ht_context_menu::done();
}

int ht_static_context_menu::count()
{
	return context_menu_entry->count();
}

ht_context_menu_entry *ht_static_context_menu::enum_entry_first()
{
	enum_idx = 0;
	ht_context_menu_entry *e = (ht_context_menu_entry*)(*context_menu_entry)[enum_idx];
	return e;
}

ht_context_menu_entry *ht_static_context_menu::enum_entry_next()
{
	enum_idx++;
	ht_context_menu_entry *e = (ht_context_menu_entry*)(*context_menu_entry)[enum_idx];
	return e;
}

void ht_static_context_menu::insert_entry(const char *Name, const char *Comment, int cmd, int k, bool a)
{
	char *name = ht_strdup(Name);
	char *comment = ht_strdup(Comment);
	char *shortcut = shortcut_str(name);
	int l = strlen(name);
	int cl = comment ? strlen(comment)+2 : 0;
	width = MAX(width, l+cl);
	ht_context_menu_entry *e = new ht_context_menu_entry();
	e->type = CME_ENTRY;
	e->entry.name = name;
	e->entry.shortcut = shortcut;
	e->entry.comment = comment;
	e->entry.command = cmd;
	e->entry.key = k;
	e->entry.active = a;
	context_menu_entry->insert(e);
}

void ht_static_context_menu::insert_separator()
{
	ht_context_menu_entry *entry = new ht_context_menu_entry();
	entry->type = CME_SEPARATOR;
	context_menu_entry->insert(entry);
}

void ht_static_context_menu::insert_submenu(ht_context_menu *submenu)
{
	ht_context_menu_entry *entry = new ht_context_menu_entry();
	entry->type = CME_SUBMENU;
	entry->submenu = submenu;
	submenu->xpos = 0;
	context_menu_entry->insert(entry);
}

/*
 *	CLASS ht_context_menu_entry
 */

ht_context_menu_entry::~ht_context_menu_entry()
{
	switch (type) {
	case CME_ENTRY:
		free(entry.name);
		free(entry.comment);
		break;
	case CME_SUBMENU:
		submenu->done();
		delete submenu;
		break;
	}
}

/*
 *	CLASS ht_menu
 */

void ht_menu::init(Bounds *b)
{
	ht_view::init(b, VO_OWNBUFFER | VO_POSTPROCESS | VO_RESIZE, "menu");
	VIEW_DEBUG_NAME("ht_menu");

	growmode = MK_GM(GMH_FIT, GMV_TOP);

	menu = new Array(true);
	lastmenux = 1;
	curmenu = -1;
	localmenu = -1;
	context_menu_hack = NULL;
	last_context_menu_hack = NULL;
	context_menu_hack2 = false;
}

void ht_menu::done()
{
	delete menu;
	ht_view::done();
}

const char *ht_menu::defaultpalette()
{
	return palkey_generic_menu_default;
}

const char *ht_menu::defaultpaletteclass()
{
	return palclasskey_generic;
}

ht_context_menu *ht_menu::get_context_menu(int i)
{
	ht_context_menu *q = (ht_context_menu*)(*menu)[i];
	if (context_menu_hack && (i == localmenu) && !q) return context_menu_hack;
	return q;
}

void ht_menu::getminbounds(int *width, int *height)
{
	*width = 1;
	*height = 1;
}

void ht_menu::draw()
{
	clear(getcolor(palidx_generic_body));
	int c = count();
	for (int i=0; i < c; i++) {
		ht_context_menu *c = get_context_menu(i);
		const char *n = c->get_name();
		const char *s = c->get_shortcut();
		if (i == curmenu) {
			buf->printChar(c->xpos-1, 0, getcolor(palidx_generic_text_selected), ' ');
			buf->print(c->xpos, 0, getcolor(palidx_generic_text_selected), n);
			buf->printChar(c->xpos+strlen(n), 0, getcolor(palidx_generic_text_selected), ' ');
			if (s) buf->printChar(c->xpos+(s - n), 0, getcolor(palidx_generic_text_shortcut_selected), *s);
		} else {
			buf->print(c->xpos, 0, getcolor(palidx_generic_text_focused), n);
			if (s) buf->printChar(c->xpos+(s - n), 0, getcolor(palidx_generic_text_shortcut), *s);
		}
	}
}

void ht_menu::execute_menu(int i)
{
	curmenu = i;
	int curentry = 0;
	bool term = false;
	dirtyview();
	do {
		ht_context_menu *m = get_context_menu(curmenu);
		Bounds b;
		b.x = m->xpos-1;
		b.y = 1;
		b.w = m->width + 4;
		b.h = m->count() + 2;
		ht_menu_window *d = new ht_menu_window();
		d->init(&b, m);
		ht_menu_window_data a;
		a.selected = curentry;
		d->databuf_set(&a, sizeof a);
		b.x = 0;
		b.y = 0;
		ht_frame *frame = new ht_menu_frame();
		frame->init(&b, 0, FS_MOVE);	// just for fun
		d->setframe(frame);
		d->setpalette(palkey_generic_menu_default);
		int r = d->run(false);
		switch (r) {
		case button_left:
			curmenu--;
			if (curmenu < 0) curmenu = count() - 1;
			curentry=0;
			dirtyview();
			break;
		case button_right:
			curmenu++;
			if (curmenu > (int)count()-1) curmenu = 0;
			curentry = 0;
			dirtyview();
			break;
		case button_ok: {
//			return true;
		}
		default:
			term = true;
		}
		d->done();
		delete d;
	} while (!term);
	curmenu = -1;
	dirtyview();
}

void ht_menu::handlemsg(htmsg *msg)
{
	if (msg->type == mt_postprocess) {
		if (msg->msg == msg_keypressed) {
			/* shortcuts */
			ht_key k = keyb_unmetakey((ht_key)msg->data1.integer);
			if (k != K_INVALID) {
				int c=count();
				for (int i=0; iget_shortcut();
					if (s >= 'A' && s <= 'Z') s += 'a'-'A';
					if (s == k) {
						if (last_context_menu_hack) {
							last_context_menu_hack->done();
							delete last_context_menu_hack;
							last_context_menu_hack = NULL;
						}
						if (localmenu != -1) {
							context_menu_hack = (ht_context_menu*)(*menu)[localmenu];
							last_context_menu_hack = NULL;
							if (context_menu_hack) {
								menu->remove(menu->findByIdx(localmenu));
							}
						}
						context_menu_hack2 = true;
						execute_menu(i);
						context_menu_hack2 = false;
						if (context_menu_hack) {
							context_menu_hack->done();
							delete context_menu_hack;
							context_menu_hack = NULL;
						}
						if (last_context_menu_hack) {
							set_local_menu(last_context_menu_hack);
							last_context_menu_hack = NULL;
						} else {
							delete_local_menu();
						}
						clearmsg(msg);
						return;
					}
				}
			}
			/* keys associated with menu entries */
			int c = count();
			for (int i=0; idata1.integer)) {
					clearmsg(msg);
					return;
				}
			}
		}
	}
	ht_view::handlemsg(msg);
}

bool ht_menu::handle_key_context_menu(ht_context_menu *a, int k)
{
	ht_context_menu_entry *e = a->enum_entry_first();
	while (e) {
		if (e->type == CME_ENTRY && e->entry.name && e->entry.key && k == e->entry.key) {
			htmsg m;
			m.msg = e->entry.command;
			m.type = mt_empty;
			((ht_app*)app)->queuemsg(app, m);
			return true;
		} else if (e->type == CME_SUBMENU) {
			if (handle_key_context_menu(e->submenu, k)) return true;
		}
		e = a->enum_entry_next();
	}
	return false;
}

int ht_menu::count()
{
	ht_context_menu *q = (ht_context_menu*)(*menu)[localmenu];
	if (context_menu_hack) return menu->count() + !!(localmenu != -1 && !q);
	return menu->count();
}

void ht_menu::delete_local_menu()
{
	if (localmenu != -1) {
/*		if (last_context_menu_hack) {
			last_context_menu_hack = false;
			if (last_context_menu) {
				last_context_menu->done();
				delete last_context_menu;
				last_context_menu = NULL;
			}
			return;*/
/*			ht_context_menu *q = (ht_context_menu*)menu->get(localmenu);
			if (q && (q == last_context_menu)) menu->remove(localmenu);
			return;*/
//		}
		if (context_menu_hack2 && last_context_menu_hack) {
			last_context_menu_hack->done();
			delete last_context_menu_hack;
			last_context_menu_hack = NULL;
		}
		menu->del(menu->findByIdx(localmenu));
	}		
}

void ht_menu::insert_local_menu()
{
	localmenu = menu->count();
}

void ht_menu::insert_menu(ht_context_menu *m)
{
	int namelen = strlen(m->get_name());

	m->xpos = lastmenux;
	menu->insert(m);

	lastmenux += namelen+1;
}

bool ht_menu::set_local_menu(ht_context_menu *m)
{
	if (localmenu == -1) return false;
	if (context_menu_hack2) {
		if (last_context_menu_hack) {
			last_context_menu_hack->done();
			delete last_context_menu_hack;
			last_context_menu_hack = NULL;
		}
		last_context_menu_hack = m;
	} else {
		ht_context_menu *p = (ht_context_menu*)(*menu)[localmenu-1];
		if (p) {
			lastmenux = p->xpos + strlen(p->get_name()) + 1; 
		} else {
			lastmenux = 1;
		}

		m->xpos = lastmenux;

		menu->forceSetByIdx(localmenu, m);

		lastmenux += strlen(m->get_name()) + 1;
	}
	return true;
}

/*
 *	CLASS ht_menu_frame
 */

void ht_menu_frame::init(Bounds *b, const char *desc, uint style, uint number)
{
	ht_frame::init(b, desc, style, number);
	VIEW_DEBUG_NAME("ht_menu_frame");
}

void ht_menu_frame::done()
{
	ht_frame::done();
}

const char *ht_menu_frame::defaultpalette()
{
	return palkey_generic_menu_default;
}

const char *ht_menu_frame::defaultpaletteclass()
{
	return palclasskey_generic;
}

int ht_menu_frame::getcurcol_normal()
{
	return ht_frame::getcurcol_normal();
}

int ht_menu_frame::getcurcol_killer()
{
	return 0;
}

/*
 *	CLASS ht_context_menu_window_body
 */

void ht_context_menu_window_body::init(Bounds *b, ht_context_menu *Menu)
{
	ht_view::init(b, VO_OWNBUFFER | VO_SELECTABLE, 0);
	VIEW_DEBUG_NAME("ht_context_menu_window_body");
	context_menu = Menu;
	selected = next_selectable(-1);
}

void ht_context_menu_window_body::done()
{
	ht_view::done();
}

const char *ht_context_menu_window_body::defaultpalette()
{
	return palkey_generic_menu_default;
}

const char *ht_context_menu_window_body::defaultpaletteclass()
{
	return palclasskey_generic;
}

void ht_context_menu_window_body::draw()
{
	clear(getcolor(palidx_generic_body));
	int c=context_menu->count();
	if (c>size.h) c=size.h;
	ht_context_menu_entry *e=context_menu->enum_entry_first();
	for (int i=0; itype) {
			case CME_ENTRY: if (i==selected) {
				if (e->entry.active) {
					vcp c = getcolor(palidx_generic_text_selected);
					fill(0, i, size.w, 1, c, ' ');
					buf->nprint(1, i, c, e->entry.name, size.w);
					if (e->entry.comment) buf->nprint(size.w-1-strlen(e->entry.comment), i, c, e->entry.comment, size.w);
					if (e->entry.shortcut) buf->printChar(e->entry.shortcut-e->entry.name+1, i, getcolor(palidx_generic_text_shortcut_selected), *e->entry.shortcut);
				} else {
					vcp c = getcolor(palidx_generic_text_disabled);
					fill(0, i, size.w, 1, c, ' ');
					buf->nprint(1, i, c, e->entry.name, size.w);
					if (e->entry.comment) buf->nprint(size.w-1-strlen(e->entry.comment), i, c, e->entry.comment, size.w);
				}
			} else {
				if (e->entry.active) {
					vcp c = getcolor(palidx_generic_text_focused);
					buf->nprint(1, i, c, e->entry.name, size.w);
					if (e->entry.comment) buf->nprint(size.w-1-strlen(e->entry.comment), i, c, e->entry.comment, size.w);
					if (e->entry.shortcut) buf->printChar(e->entry.shortcut-e->entry.name+1, i, getcolor(palidx_generic_text_shortcut), *e->entry.shortcut);
				} else {
					vcp c = getcolor(palidx_generic_text_disabled);
					buf->nprint(1, i, c, e->entry.name, size.w);
					if (e->entry.comment) buf->nprint(size.w-1-strlen(e->entry.comment), i, c, e->entry.comment, size.w);
				}
			}
			break;
			case CME_SEPARATOR:
				fill(0, i, size.w, 1, getcolor(palidx_generic_text_focused), GC_1HLINE, CP_GRAPHICAL);
				break;
			case CME_SUBMENU: {
				const char *n = e->submenu->get_name();
				const char *s = e->submenu->get_shortcut();
				vcp c;
				if (i == selected) {
					c = getcolor(palidx_generic_text_selected);
				} else {
					c = getcolor(palidx_generic_text_focused);
				}
				fill(0, i, size.w, 1, c, ' ');
				buf->nprint(1, i, c, n, size.w);
				if (s) buf->printChar(n-s+1, i, getcolor(palidx_generic_text_shortcut), *s);
				buf->printChar(size.w-2, i, c, GC_ARROW_RIGHT, CP_GRAPHICAL);
				break;
			}
		}
		e = context_menu->enum_entry_next();
	}
}

void ht_context_menu_window_body::handlemsg(htmsg *msg)
{
	if (msg->msg == msg_keypressed) {
		switch (msg->data1.integer) {
			case K_Up:
				selected = prev_selectable(selected);
				dirtyview();
				clearmsg(msg);
				return;
			case K_Down:
				selected = next_selectable(selected);
				dirtyview();
				clearmsg(msg);
				return;
			case K_Control_PageUp:
			case K_PageUp:
			case K_Home:
				selected = next_selectable(-1);
				dirtyview();
				clearmsg(msg);
				return;
			case K_Control_PageDown:
			case K_PageDown:
			case K_End:
				selected = prev_selectable(0);
				dirtyview();
				clearmsg(msg);
				return;
		}
		/* shortcuts */
		int k = msg->data1.integer;
//		int k = htalt2key(msg->data_int);
//		if (k != -1) {
			int c=context_menu->count();
			ht_context_menu_entry *e = context_menu->enum_entry_first();
			for (int i=0; i < c; i++) {
				const char *shortcut = NULL;
				if (e->type == CME_ENTRY && e->entry.shortcut) {
					shortcut = e->entry.shortcut;
				} else if (e->type == CME_SUBMENU && e->submenu->get_shortcut()) {
					shortcut = e->submenu->get_shortcut();
				}
				if (shortcut) {
					int s = *shortcut;
					if (s >= 'A' && s <= 'Z') s += 'a'-'A';
					if (s==k) {
						selected=i;
						((ht_dialog*)group->group)->sendmsg(msg_button_pressed, button_ok);
						dirtyview();
						clearmsg(msg);
						return;
					}
				}					
				e = context_menu->enum_entry_next();
			}
//		}
	}
	ht_view::handlemsg(msg);
}

int ht_context_menu_window_body::next_selectable(int to)
{
	int s=to+1;
	int c=context_menu->count();
	if (s>c-1) s=0;
	while (s!=to) {
		ht_context_menu_entry *e=context_menu->get_entry(s);
		if (e->type == CME_ENTRY || e->type == CME_SUBMENU) return s;
		s++;
		if (s > c-1) s=0;
	}
	return to;
}

int ht_context_menu_window_body::prev_selectable(int to)
{
	int s = to-1;
	int c = context_menu->count();
	if (s < 0) s = c-1;
	while (s != to) {
		ht_context_menu_entry *e=context_menu->get_entry(s);
		if (e->type == CME_ENTRY || e->type == CME_SUBMENU) return s;
		s--;
		if (s < 0) s = c-1;
	}
	return to;
}

void ht_context_menu_window_body::getdata(ObjectStream &s)
{
	PUT_INT32D(s, selected);
}

void ht_context_menu_window_body::setdata(ObjectStream &s)
{
	GET_INT32D(s, selected);
}

/*
 *	CLASS ht_menu_window
 */

void ht_menu_window::init(Bounds *b, ht_context_menu *m)
{
	ht_dialog::init(b, 0, 0);
	VIEW_DEBUG_NAME("ht_menu_window");

	Bounds c=*b;
	c.x=0;
	c.y=0;
	c.w-=2;
	c.h-=2;
	menu = m;
	body=new ht_menu_window_body();
	body->init(&c, menu);
	insert(body);
}

void ht_menu_window::done()
{
	ht_dialog::done();
}

void ht_menu_window::getdata(ObjectStream &s)
{
	body->getdata(s);
}

void ht_menu_window::handlemsg(htmsg *msg)
{
	if (msg->msg == msg_button_pressed) {
		switch (msg->data1.integer) {
			case button_ok: {
				ht_menu_window_data a;
				ViewDataBuf vdb(this, &a, sizeof a);
				int curentry = a.selected;
				ht_context_menu_entry *e = menu->get_entry(a.selected);
				if (e->type == CME_ENTRY && e->entry.active) {
					dirtyview();
					htmsg m;
					m.msg = e->entry.command;
					m.type = mt_empty;
					((ht_app*)app)->queuemsg(app, m);
//					app->sendmsg(e->entry.command);
				} else if (e->type == CME_SUBMENU) {
					if (execute_submenu(menu->xpos+2, 3+curentry, e->submenu)) {
						sendmsg(msg_button_pressed, button_cancel);
					}
					clearmsg(msg);
				}
				break;
			}
		}
	}
	ht_dialog::handlemsg(msg);
}

void ht_menu_window::setdata(ObjectStream &s)
{
	body->setdata(s);
}

/*
 *	CLASS ht_menu_window_body
 */

void ht_menu_window_body::init(Bounds *b, ht_context_menu *menu)
{
	ht_context_menu_window_body::init(b, menu);
	VIEW_DEBUG_NAME("ht_menu_window_body");
}

void ht_menu_window_body::done()
{
	ht_context_menu_window_body::done();
}

void ht_menu_window_body::handlemsg(htmsg *msg)
{
	if (msg->msg == msg_keypressed) {
		switch (msg->data1.integer) {
			case K_Left:
				((ht_dialog*)baseview)->setstate(ds_term_ok, button_left);
				dirtyview();
				clearmsg(msg);
				return;
			case K_Right:
				((ht_dialog*)baseview)->setstate(ds_term_ok, button_right);
				dirtyview();
				clearmsg(msg);
				return;
		}
	}
	ht_context_menu_window_body::handlemsg(msg);
}

/*
 *	INIT
 */

bool init_menu()
{
	return true;
}

/*
 *	DONE
 */

void done_menu()
{
}
ht-2.0.22/vfsview.h0000644000175000001440000000431310615341625010773 00000000000000/* 
 *	HT Editor
 *	vfsview.h
 *
 *	Copyright (C) 1999-2003 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __VFSVIEW_H__
#define __VFSVIEW_H__

#include "htdialog.h"
#include "vfs.h"

/*
 *	class VfsListbox
 */

struct vfs_extra {
	pstat_t stat;
	char *name;
};

#define VFSV_FORMAT_MAX_COLS		64
#define VFSV_FORMAT_PROPERTIES		22

#define VfsListboxData ht_itext_listbox_data

class VfsListbox: public ht_itext_listbox {
protected:
	Container *vfs_list;
	Vfs *cvfs;
	char cdir[VFS_DIR_MAX+1];
	char cproto[VFS_PROTO_MAX+1];
	/**/
	int dfmt_cols;
	int dfmt_props;
	int dfmt_prop2colidx[VFSV_FORMAT_MAX_COLS];
	int dfmt_prop[VFSV_FORMAT_MAX_COLS];
	int dfmt_quickfind;
	/**/
	ht_text *show_pos;

	virtual	void		freeExtraData(void *extra_data);
		void		renderEntry(char *buf, int bufsize, int dfmt, const char *filename, pstat_t stat);
		void		reread();
		void		setDisplayFormat(char *fmt);
	virtual	bool 		selectEntry(void *entry);
		char *		translateProp(char *fmt, int *type);
public:
		void		init(Bounds *b, Container *vfs_list, ht_text *show_pos);
	virtual	void		done();
	/* overwritten */
	virtual	void		config_changed();
	virtual	int		cursorAdjust();
	virtual	void		handlemsg(htmsg *msg);
	virtual	void *		quickfind(const char *s);
	virtual	char *		quickfindCompletition(const char *s);
	virtual	void		update();
	/* new */
		int		changeURL(const char *url);
		int		changeDir(const char *dir);
		const char *	getCurDir();
		const char *	getCurProto();
		Vfs *		getCurVfs();
};

/*
 *	class VfsListbox2
 */
class VfsListbox2: public VfsListbox {
public:
/**/
	virtual	bool selectEntry(void *entry);
};

#endif /* __VFSVIEW_H__ */
ht-2.0.22/strtools.cc0000755000175000001440000002333710776766224011361 00000000000000/*
 *	HT Editor
 *	strtools.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
 *	Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "atom.h"
#include "htdebug.h"
#include "except.h"
#include "snprintf.h"
#include "stream.h"
#include "strtools.h"
#include "tools.h"
#include "io/types.h"

#include 
#include 
#include 
#include 

char hexchars[17]="0123456789abcdef";

char *ht_strdup(const char *str)
{
	if (str) {
		int len = strlen(str)+1;
		char *s = ht_malloc(len);
		memcpy(s, str, len);
		return s;
	} else {
		return NULL;
	}
}


/**
 *	Like ht_strdup but dups a maximum of |maxlen| characters of |str|.
 *	@returns new string
 */
char *ht_strndup(const char *str, size_t maxlen)
{
	maxlen ++;
	if (str) {
		uint len = strlen(str)+1;
		len = MIN(len, maxlen);
		char *s = ht_malloc(len);
		memcpy(s, str, len);
		s[len-1] = 0;
		return s;
	} else {
		return NULL;
	}
}

/**
 *	Like strcpy but copies a maximum of |maxlen| characters
 *	(including trailing zero).
 *	The operation is performed in a way that the trailing zero
 *	is always written if maxlen is > 0.
 *	@returns number of characters copied (without trailing zero)
 */
size_t ht_strlcpy(char *s1, const char *s2, size_t maxlen)
{
	if (!maxlen) return 0;
	char *os1 = s1;
	while (true) {
		if (!--maxlen) {
			*s1 = 0;
			return s1 - os1;
		}
		*s1 = *s2;
		if (!*s2) return s1 - os1;
		s1++; s2++;
	}
}

size_t ht_strlcat(char *s1, const char *s2, size_t maxlen)
{
	char *os1 = s1;
	while (maxlen && *s1) {
		maxlen--;
		s1++;
	}
	if (!maxlen) return os1-s1;
	while (true) {
		if (!--maxlen) {
			*s1 = 0;
			return s1 - os1;
		}
		*s1 = *s2;
		if (!*s2) return s1 - os1;
		s1++; s2++;
	}
}

int ht_strncmp(const char *s1, const char *s2, size_t max)
{
	if (!s1) return s2 ? -1 : 0;
	if (!s2) return s1 ? 1 : 0;
	while (max--) {
		if (!*s1) return *s2 ? -1 : 0;
		if (!*s2) return *s1 ? 1 : 0;
		if (*s1>*s2) {
			return 1;
		} else if (*s1<*s2) {
			return -1;
		}
		s1++;s2++;
	}
	return 0;
}

int ht_strnicmp(const char *s1, const char *s2, size_t max)
{
	if (!s1) return s2 ? -1 : 0;
	if (!s2) return s1 ? 1 : 0;
	while (max--) {
		if (!*s1) return *s2 ? -1 : 0;
		if (!*s2) return *s1 ? 1 : 0;
		char c1=tolower(*s1), c2=tolower(*s2);
		if (c1>c2) {
			return 1;
		} else if (c1 c2) {
			return 1;
		} else if (c1 < c2) {
			return -1;
		}
		s1++; s2++;
	}
}

size_t ht_strccomm(const char *s1, const char *s2)
{
	if (!s1 || !s2) return 0;
	int r=0;
	while (*s1 && *s2 && *s1 == *s2) { s1++; s2++; r++; }
	return r;
}

size_t ht_strcicomm(const char *s1, const char *s2)
{
	if (!s1 || !s2) return 0;
	int r=0;
	while (*s1 && *s2 && tolower(*s1) == tolower(*s2)) { s1++; s2++; r++; }
	return r;
}

int escape_special_str(char *result, int resultmaxlen, const char *s, const char *specialchars, bool bit7)
{
	return escape_special(result, resultmaxlen, s, strlen(s), specialchars, bit7);
}

int escape_special(char *result, int resultmaxlen, const void *S, int len, const char *specialchars, bool bit7)
{
	byte *s = (byte*)S;
	if (!s) return 0;
	if (resultmaxlen <= 0) return 0;
	char *old = result;
	if (!specialchars) specialchars="";
	while (len--) {
		if (*s && strchr(specialchars, *s)) {
			*result++ = '\\';
			if (--resultmaxlen<2) break;
			*result++ = *s;
			if (--resultmaxlen<2) break;
		} else if (*s < 32 || (bit7 && (*s > 0x7f)) || *s=='\\') {
			*result++ = '\\';
			if (--resultmaxlen<2) break;
			switch (*s) {
				case '\0':
					*result++='0';
					break;
				case '\a':
					*result++='a';
					break;
				case '\b':
					*result++='b';
					break;
				case '\e':
					*result++='e';
					break;
				case '\f':
					*result++='f';
					break;
				case '\n':
					*result++='n';
					break;
				case '\r':
					*result++='r';
					break;
				case '\t':
					*result++='t';
					break;
				case '\v':
					*result++='v';
					break;
				case '\\':
					*result++='\\';
					break;
				case '\"':
					*result++='"';
					break;
				default:
					*result++='x';
					if (--resultmaxlen<2) break;
					*result++=hexchars[((*s & 0xf0) >> 4)];
					if (--resultmaxlen<2) break;
					*result++=hexchars[(*s & 0x0f)];
			}
			if (--resultmaxlen < 2) break;
		} else {
			*result++ = *s;
			if (--resultmaxlen < 2) break;
		}
		s++;
	}
	*result = 0;
	return result-old;
}

int unescape_special_str(char *result, int resultmaxlen, const char *s)
{
	int l=unescape_special(result, resultmaxlen-1, s);
	result[l]=0;
	return l;
}

int unescape_special(void *Result, int resultmaxlen, const char *s)
{
	char *result = (char*)Result;
	char *old = result;
	while (s && *s) {
		if (*s == '\\') {
			s++;
			switch (*s) {
			case '0':
				*result++='\0';
				break;
			case 'a':
				*result++='\a';
				break;
			case 'b':
				*result++='\b';
				break;
			case 'e':
				*result++='\e';
				break;
			case 'f':
				*result++='\f';
				break;
			case 'n':
				*result++='\n';
				break;
			case 'r':
				*result++='\r';
				break;
			case 't':
				*result++='\t';
				break;
			case 'v':
				*result++='\v';
				break;
			case '\\':
				*result++='\\';
				break;
			case '\"':
				*result++='"';
				break;
			case 'x':
				s++;
				byte v = hexdigit(*s) * 16;
				s++;
				v += hexdigit(*s);
				*result++ = (char)v;
			}
			if (!--resultmaxlen) break;
		} else {
			*result++ = *s;
			if (!--resultmaxlen) break;
		}
		s++;
	}
	return result-old;
}

int bin2str(char *result, const void *S, int len)
{
	byte *s = (byte*)S;
	while (len--) {
//		if (*s<32) *result=' '; else *result=*s;
		if (*s==0) *result=' '; else *result=*s;
		result++;
		s++;
	}
	*result=0;
	return len;
}

void wide_char_to_multi_byte(char *result, const byte *Unicode, int maxlen)
{
	if (!maxlen) return;
	struct doof {
		char c1;
		char c2;
	};
	doof *unicode = (doof*)Unicode;
	for (int i=0; i < maxlen - 1; i++) {
		if (unicode->c2) {
			*result++ = 0xff;
		} else {
			if (!unicode->c1) break;
			*result++ = unicode->c1;
		}
		unicode++;
	}
	*result=0;
}

void memdowncase(byte *buf, int len)
{
	for (int i=0; i < len; i++) {
		if (buf[i] >= 'A' && buf[i] <= 'Z') buf[i] += 32;
	}
}

byte *ht_memmem(const byte *haystack, int haystack_len, const byte *needle, int needle_len)
{
	while (haystack_len && haystack_len >= needle_len) {
		if (memcmp(haystack, needle, needle_len) == 0) return (byte*)haystack;
		haystack++;
		haystack_len--;
	}
	return NULL;
}

/* common string parsing functions */
bool is_whitespace(char c)
{
	return c && (unsigned char)c <= 32;
}

void whitespaces(const char *&str)
{
	while ((unsigned char)*str <= 32) {
		if (!*str) return;
		str++;
	}
}

void non_whitespaces(const char *&str)
{
	while ((unsigned char)*str > 32) {
		str++;
	}
}

bool waitforchar(const char *&str, char b)
{
	while (*str != b) {
		if (!*str) return false;
		str++;
	}
	return true;
}

static bool bnstr2bin(uint64 &u64, const char *&str, int base)
{
	u64 = 0;
	uint64 ubase = base;
	int i = 0;
	do {
		int c = hexdigit(*str);
		if (c == -1 || c >= base) return (i == 0) ? false : true;
		u64 *= ubase;
		u64 += c;
		str++;
		i++;
	} while (*str);
	return true;
}

bool parseIntStr(const char *&str, uint64 &u64, int defaultbase)
{
	int base = defaultbase;
	if (base == 10 && ht_strnicmp("0x", str, 2) == 0) {
		str += 2;
		base = 16;
	}
	return bnstr2bin(u64, str, base);
}

bool parseIntStr(char *&str, uint64 &u64, int defaultbase)
{
	int base = defaultbase;
	if (base == 10 && ht_strnicmp("0x", str, 2) == 0) {
		str += 2;
		base = 16;
	}
	return bnstr2bin(u64, (const char *&)str, base);
}

bool str2int(const char *str, uint64 &u64, int defaultbase)
{
	uint base = defaultbase;
	size_t len = strlen(str);
	if (!len) return false;
	bool n = false;
	if (defaultbase == 10) {
		if (ht_strnicmp("0x", str, 2) == 0) {
			str += 2;
			base = 16;
			len -= 2;
			if (!len) return false;
		} else {
			switch (tolower(str[len-1])) {
			case 'b': base = 2; break;
			case 'o': base = 8; break;
			case 'h': base = 16; break;
			default: goto skip;
			}
				len--;
				if (!len) return false;
			skip:
			if (str[0] == '-') {
				str++; len--;
				if (!len) return false;
				n = true;
			}
		}
	}
	u64 = 0;
	do {
		int c = hexdigit(str[0]);
		if (c == -1 || c >= int(base)) return false;
		u64 *= base;
		u64 += c;
		str++;
	} while (--len);
	if (n) u64 = -u64;
	return true;
}

/* hex/string functions */

int hexdigit(char a)
{
	if (a >= '0' && a <= '9') {
		return a-'0';
	} else if (a >= 'a' && a <= 'f') {
		return a-'a'+10;
	} else if (a >= 'A' && a <= 'F') {
		return a-'A'+10;
	}
	return -1;
}

bool hexb_ex(uint8 &result, const char *s)
{
	int v, w;
	v = hexdigit(s[0]);
	w = hexdigit(s[1]);
	if ((v < 0) || (w < 0)) return false;
	result = (v<<4) | w;
	return true;
}

bool hexw_ex(uint16 &result, const char *s)
{
	uint8 v, w;
	if (!hexb_ex(v, s) || !hexb_ex(w, s+2)) return false;
	result = (v<<8) | w;
	return true;
}

bool hexd_ex(uint32 &result, const char *s)
{
	uint16 v, w;
	if (!hexw_ex(v, s) || !hexw_ex(w, s+4)) return false;
	result = (v<<16) | w;
	return true;
}
ht-2.0.22/htxbeimp.cc0000644000175000001440000007446610771304342011276 00000000000000/*
 *	HT Editor
 *	htxbeimp.cc
 *
 *	Copyright (C) 2003 Stefan Esser
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "formats.h"
#include "htanaly.h"
#include "htctrl.h"
#include "data.h"
#include "endianess.h"
#include "htiobox.h"
#include "htpal.h"
#include "xbestruct.h"
#include "htxbe.h"
#include "htxbeimp.h"
#include "stream.h"
#include "strtools.h"
#include "httag.h"
#include "log.h"
#include "xbe_analy.h"
#include "snprintf.h"
#include "tools.h"

#include 
#include 

static const char *xbox_exports[] = {
	NULL,
	"AvGetSavedDataAddress",                         //   1  80000001
	"AvSendTVEncoderOption",                         //   2  80000002
	"AvSetDisplayMode",                              //   3  80000003
	"AvSetSavedDataAddress",                         //   4  80000004
	"DbgBreakPoint",                                 //   5  80000005
	"DbgBreakPointWithStatus",                       //   6  80000006
	"DbgLoadImageSymbols",                           //   7  80000007
	"DbgPrint",                                      //   8  80000008
	"HalReadSMCTrayState",                           //   9  80000009
	"DbgPrompt",                                     //  10  8000000A
	"DbgUnLoadImageSymbols",                         //  11  8000000B
	"ExAcquireReadWriteLockExclusive",               //  12  8000000C
	"ExAcquireReadWriteLockShared",                  //  13  8000000D
	"ExAllocatePool",                                //  14  8000000E
	"ExAllocatePoolWithTag",                         //  15  8000000F
	"ExEventObjectType",                             //  16  80000010
	"ExFreePool",                                    //  17  80000011
	"ExInitializeReadWriteLock",                     //  18  80000012
	"ExInterlockedAddLargeInteger",                  //  19  80000013
	"ExInterlockedAddLargeStatistic",                //  20  80000014
	"ExInterlockedCompareExchange64",                //  21  80000015
	"ExMutantObjectType",                            //  22  80000016
	"ExQueryPoolBlockSize",                          //  23  80000017
	"ExQueryNonVolatileSetting",                     //  24  80000018
	"ExReadWriteRefurbInfo",                         //  25  80000019
	"ExRaiseException",                              //  26  8000001A
	"ExRaiseStatus",                                 //  27  8000001B
	"ExReleaseReadWriteLock",                        //  28  8000001C
	"ExSaveNonVolatileSetting",                      //  29  8000001D
	"ExSemaphoreObjectType",                         //  30  8000001E
	"ExTimerObjectType",                             //  31  8000001F
	"ExfInterlockedInsertHeadList",                  //  32  80000020
	"ExfInterlockedInsertTailList",                  //  33  80000021
	"ExfInterlockedRemoveHeadList",                  //  34  80000022
	"FscGetCacheSize",                               //  35  80000023
	"FscInvalidateIdleBlocks",                       //  36  80000024
	"FscSetCacheSize",                               //  37  80000025
	"HalClearSoftwareInterrupt",                     //  38  80000026
	"HalDisableSystemInterrupt",                     //  39  80000027
	"HalDiskCachePartitionCount",                    //  40  80000028
	"HalDiskModelNumber",                            //  41  80000029
	"HalDiskSerialNumber",                           //  42  8000002A
	"HalEnableSystemInterrupt",                      //  43  8000002B
	"HalGetInterruptVector",                         //  44  8000002C
	"HalReadSMBusValue",                             //  45  8000002D
	"HalReadWritePCISpace",                          //  46  8000002E
	"HalRegisterShutdownNotification",               //  47  8000002F
	"HalRequestSoftwareInterrupt",                   //  48  80000030
	"HalReturnToFirmware",                           //  49  80000031
	"HalWriteSMBusValue",                            //  50  80000032
	"InterlockedCompareExchange",                    //  51  80000033
	"InterlockedDecrement",                          //  52  80000034
	"InterlockedIncrement",                          //  53  80000035
	"InterlockedExchange",                           //  54  80000036
	"InterlockedExchangeAdd",                        //  55  80000037
	"InterlockedFlushSList",                         //  56  80000038
	"InterlockedPopEntrySList",                      //  57  80000039
	"InterlockedPushEntrySList",                     //  58  8000003A
	"IoAllocateIrp",                                 //  59  8000003B
	"IoBuildAsynchronousFsdRequest",                 //  60  8000003C
	"IoBuildDeviceIoControlRequest",                 //  61  8000003D
	"IoBuildSynchronousFsdRequest",                  //  62  8000003E
	"IoCheckShareAccess",                            //  63  8000003F
	"IoCompletionObjectType",                        //  64  80000040
	"IoCreateDevice",                                //  65  80000041
	"IoCreateFile",                                  //  66  80000042
	"IoCreateSymbolicLink",                          //  67  80000043
	"IoDeleteDevice",                                //  68  80000044
	"IoDeleteSymbolicLink",                          //  69  80000045
	"IoDeviceObjectType",                            //  70  80000046
	"IoFileObjectType",                              //  71  80000047
	"IoFreeIrp",                                     //  72  80000048
	"IoInitializeIrp",                               //  73  80000049
	"IoInvalidDeviceRequest",                        //  74  8000004A
	"IoQueryFileInformation",                        //  75  8000004B
	"IoQueryVolumeInformation",                      //  76  8000004C
	"IoQueueThreadIrp",                              //  77  8000004D
	"IoRemoveShareAccess",                           //  78  8000004E
	"IoSetIoCompletion",                             //  79  8000004F
	"IoSetShareAccess",                              //  80  80000050
	"IoStartNextPacket",                             //  81  80000051
	"IoStartNextPacketByKey",                        //  82  80000052
	"IoStartPacket",                                 //  83  80000053
	"IoSynchronousDeviceIoControlRequest",           //  84  80000054
	"IoSynchronousFsdRequest",                       //  85  80000055
	"IofCallDriver",                                 //  86  80000056
	"IofCompleteRequest",                            //  87  80000057
	"KdDebuggerEnabled",                             //  88  80000058
	"KdDebuggerNotPresent",                          //  89  80000059
	"IoDismountVolume",                              //  90  8000005A
	"IoDismountVolumeByName",                        //  91  8000005B
	"KeAlertResumeThread",                           //  92  8000005C
	"KeAlertThread",                                 //  93  8000005D
	"KeBoostPriorityThread",                         //  94  8000005E
	"KeBugCheck",                                    //  95  8000005F
	"KeBugCheckEx",                                  //  96  80000060
	"KeCancelTimer",                                 //  97  80000061
	"KeConnectInterrupt",                            //  98  80000062
	"KeDelayExecutionThread",                        //  99  80000063
	"KeDisconnectInterrupt",                         // 100  80000064
	"KeEnterCriticalRegion",                         // 101  80000065
	"MmGlobalData",                                  // 102  80000066
	"KeGetCurrentIrql",                              // 103  80000067
	"KeGetCurrentThread",                            // 104  80000068
	"KeInitializeApc",                               // 105  80000069
	"KeInitializeDeviceQueue",                       // 106  8000006A
	"KeInitializeDpc",                               // 107  8000006B
	"KeInitializeEvent",                             // 108  8000006C
	"KeInitializeInterrupt",                         // 109  8000006D
	"KeInitializeMutant",                            // 110  8000006E
	"KeInitializeQueue",                             // 111  8000006F
	"KeInitializeSemaphore",                         // 112  80000070
	"KeInitializeTimerEx",                           // 113  80000071
	"KeInsertByKeyDeviceQueue",                      // 114  80000072
	"KeInsertDeviceQueue",                           // 115  80000073
	"KeInsertHeadQueue",                             // 116  80000074
	"KeInsertQueue",                                 // 117  80000075
	"KeInsertQueueApc",                              // 118  80000076
	"KeInsertQueueDpc",                              // 119  80000077
	"KeInterruptTime",                               // 120  80000078
	"KeIsExecutingDpc",                              // 121  80000079
	"KeLeaveCriticalRegion",                         // 122  8000007A
	"KePulseEvent",                                  // 123  8000007B
	"KeQueryBasePriorityThread",                     // 124  8000007C
	"KeQueryInterruptTime",                          // 125  8000007D
	"KeQueryPerformanceCounter",                     // 126  8000007E
	"KeQueryPerformanceFrequency",                   // 127  8000007F
	"KeQuerySystemTime",                             // 128  80000080
	"KeRaiseIrqlToDpcLevel",                         // 129  80000081
	"KeRaiseIrqlToSynchLevel",                       // 130  80000082
	"KeReleaseMutant",                               // 131  80000083
	"KeReleaseSemaphore",                            // 132  80000084
	"KeRemoveByKeyDeviceQueue",                      // 133  80000085
	"KeRemoveDeviceQueue",                           // 134  80000086
	"KeRemoveEntryDeviceQueue",                      // 135  80000087
	"KeRemoveQueue",                                 // 136  80000088
	"KeRemoveQueueDpc",                              // 137  80000089
	"KeResetEvent",                                  // 138  8000008A
	"KeRestoreFloatingPointState",                   // 139  8000008B
	"KeResumeThread",                                // 140  8000008C
	"KeRundownQueue",                                // 141  8000008D
	"KeSaveFloatingPointState",                      // 142  8000008E
	"KeSetBasePriorityThread",                       // 143  8000008F
	"KeSetDisableBoostThread",                       // 144  80000090
	"KeSetEvent",                                    // 145  80000091
	"KeSetEventBoostPriority",                       // 146  80000092
	"KeSetPriorityProcess",                          // 147  80000093
	"KeSetPriorityThread",                           // 148  80000094
	"KeSetTimer",                                    // 149  80000095
	"KeSetTimerEx",                                  // 150  80000096
	"KeStallExecutionProcessor",                     // 151  80000097
	"KeSuspendThread",                               // 152  80000098
	"KeSynchronizeExecution",                        // 153  80000099
	"KeSystemTime",                                  // 154  8000009A
	"KeTestAlertThread",                             // 155  8000009B
	"KeTickCount",                                   // 156  8000009C
	"KeTimeIncrement",                               // 157  8000009D
	"KeWaitForMultipleObjects",                      // 158  8000009E
	"KeWaitForSingleObject",                         // 159  8000009F
	"KfRaiseIrql",                                   // 160  800000A0
	"KfLowerIrql",                                   // 161  800000A1
	"KiBugCheckData",                                // 162  800000A2
	"KiUnlockDispatcherDatabase",                    // 163  800000A3
	"LaunchDataPage",                                // 164  800000A4
	"MmAllocateContiguousMemory",                    // 165  800000A5
	"MmAllocateContiguousMemoryEx",                  // 166  800000A6
	"MmAllocateSystemMemory",                        // 167  800000A7
	"MmClaimGpuInstanceMemory",                      // 168  800000A8
	"MmCreateKernelStack",                           // 169  800000A9
	"MmDeleteKernelStack",                           // 170  800000AA
	"MmFreeContiguousMemory",                        // 171  800000AB
	"MmFreeSystemMemory",                            // 172  800000AC
	"MmGetPhysicalAddress",                          // 173  800000AD
	"MmIsAddressValid",                              // 174  800000AE
	"MmLockUnlockBufferPages",                       // 175  800000AF
	"MmLockUnlockPhysicalPage",                      // 176  800000B0
	"MmMapIoSpace",                                  // 177  800000B1
	"MmPersistContiguousMemory",                     // 178  800000B2
	"MmQueryAddressProtect",                         // 179  800000B3
	"MmQueryAllocationSize",                         // 180  800000B4
	"MmQueryStatistics",                             // 181  800000B5
	"MmSetAddressProtect",                           // 182  800000B6
	"MmUnmapIoSpace",                                // 183  800000B7
	"NtAllocateVirtualMemory",                       // 184  800000B8
	"NtCancelTimer",                                 // 185  800000B9
	"NtClearEvent",                                  // 186  800000BA
	"NtClose",                                       // 187  800000BB
	"NtCreateDirectoryObject",                       // 188  800000BC
	"NtCreateEvent",                                 // 189  800000BD
	"NtCreateFile",                                  // 190  800000BE
	"NtCreateIoCompletion",                          // 191  800000BF
	"NtCreateMutant",                                // 192  800000C0
	"NtCreateSemaphore",                             // 193  800000C1
	"NtCreateTimer",                                 // 194  800000C2
	"NtDeleteFile",                                  // 195  800000C3
	"NtDeviceIoControlFile",                         // 196  800000C4
	"NtDuplicateObject",                             // 197  800000C5
	"NtFlushBuffersFile",                            // 198  800000C6
	"NtFreeVirtualMemory",                           // 199  800000C7
	"NtFsControlFile",                               // 200  800000C8
	"NtOpenDirectoryObject",                         // 201  800000C9
	"NtOpenFile",                                    // 202  800000CA
	"NtOpenSymbolicLinkObject",                      // 203  800000CB
	"NtProtectVirtualMemory",                        // 204  800000CC
	"NtPulseEvent",                                  // 205  800000CD
	"NtQueueApcThread",                              // 206  800000CE
	"NtQueryDirectoryFile",                          // 207  800000CF
	"NtQueryDirectoryObject",                        // 208  800000D0
	"NtQueryEvent",                                  // 209  800000D1
	"NtQueryFullAttributesFile",                     // 210  800000D2
	"NtQueryInformationFile",                        // 211  800000D3
	"NtQueryIoCompletion",                           // 212  800000D4
	"NtQueryMutant",                                 // 213  800000D5
	"NtQuerySemaphore",                              // 214  800000D6
	"NtQuerySymbolicLinkObject",                     // 215  800000D7
	"NtQueryTimer",                                  // 216  800000D8
	"NtQueryVirtualMemory",                          // 217  800000D9
	"NtQueryVolumeInformationFile",                  // 218  800000DA
	"NtReadFile",                                    // 219  800000DB
	"NtReadFileScatter",                             // 220  800000DC
	"NtReleaseMutant",                               // 221  800000DD
	"NtReleaseSemaphore",                            // 222  800000DE
	"NtRemoveIoCompletion",                          // 223  800000DF
	"NtResumeThread",                                // 224  800000E0
	"NtSetEvent",                                    // 225  800000E1
	"NtSetInformationFile",                          // 226  800000E2
	"NtSetIoCompletion",                             // 227  800000E3
	"NtSetSystemTime",                               // 228  800000E4
	"NtSetTimerEx",                                  // 229  800000E5
	"NtSignalAndWaitForSingleObjectEx",              // 230  800000E6
	"NtSuspendThread",                               // 231  800000E7
	"NtUserIoApcDispatcher",                         // 232  800000E8
	"NtWaitForSingleObject",                         // 233  800000E9
	"NtWaitForSingleObjectEx",                       // 234  800000EA
	"NtWaitForMultipleObjectsEx",                    // 235  800000EB
	"NtWriteFile",                                   // 236  800000EC
	"NtWriteFileGather",                             // 237  800000ED
	"NtYieldExecution",                              // 238  800000EE
	"ObCreateObject",                                // 239  800000EF
	"ObDirectoryObjectType",                         // 240  800000F0
	"ObInsertObject",                                // 241  800000F1
	"ObMakeTemporaryObject",                         // 242  800000F2
	"ObOpenObjectByName",                            // 243  800000F3
	"ObOpenObjectByPointer",                         // 244  800000F4
	"ObpObjectHandleTable",                          // 245  800000F5
	"ObReferenceObjectByHandle",                     // 246  800000F6
	"ObReferenceObjectByName",                       // 247  800000F7
	"ObReferenceObjectByPointer",                    // 248  800000F8
	"ObSymbolicLinkObjectType",                      // 249  800000F9
	"ObfDereferenceObject",                          // 250  800000FA
	"ObfReferenceObject",                            // 251  800000FB
	"PhyGetLinkState",                               // 252  800000FC
	"PhyInitialize",                                 // 253  800000FD
	"PsCreateSystemThread",                          // 254  800000FE
	"PsCreateSystemThreadEx",                        // 255  800000FF
	"PsQueryStatistics",                             // 256  80000100
	"PsSetCreateThreadNotifyRoutine",                // 257  80000101
	"PsTerminateSystemThread",                       // 258  80000102
	"PsThreadObjectType",                            // 259  80000103
	"RtlAnsiStringToUnicodeString",                  // 260  80000104
	"RtlAppendStringToString",                       // 261  80000105
	"RtlAppendUnicodeStringToString",                // 262  80000106
	"RtlAppendUnicodeToString",                      // 263  80000107
	"RtlAssert",                                     // 264  80000108
	"RtlCaptureContext",                             // 265  80000109
	"RtlCaptureStackBackTrace",                      // 266  8000010A
	"RtlCharToInteger",                              // 267  8000010B
	"RtlCompareMemory",                              // 268  8000010C
	"RtlCompareMemoryUlong",                         // 269  8000010D
	"RtlCompareString",                              // 270  8000010E
	"RtlCompareUnicodeString",                       // 271  8000010F
	"RtlCopyString",                                 // 272  80000110
	"RtlCopyUnicodeString",                          // 273  80000111
	"RtlCreateUnicodeString",                        // 274  80000112
	"RtlDowncaseUnicodeChar",                        // 275  80000113
	"RtlDowncaseUnicodeString",                      // 276  80000114
	"RtlEnterCriticalSection",                       // 277  80000115
	"RtlEnterCriticalSectionAndRegion",              // 278  80000116
	"RtlEqualString",                                // 279  80000117
	"RtlEqualUnicodeString",                         // 280  80000118
	"RtlExtendedIntegerMultiply",                    // 281  80000119
	"RtlExtendedLargeIntegerDivide",                 // 282  8000011A
	"RtlExtendedMagicDivide",                        // 283  8000011B
	"RtlFillMemory",                                 // 284  8000011C
	"RtlFillMemoryUlong",                            // 285  8000011D
	"RtlFreeAnsiString",                             // 286  8000011E
	"RtlFreeUnicodeString",                          // 287  8000011F
	"RtlGetCallersAddress",                          // 288  80000120
	"RtlInitAnsiString",                             // 289  80000121
	"RtlInitUnicodeString",                          // 290  80000122
	"RtlInitializeCriticalSection",                  // 291  80000123
	"RtlIntegerToChar",                              // 292  80000124
	"RtlIntegerToUnicodeString",                     // 293  80000125
	"RtlLeaveCriticalSection",                       // 294  80000126
	"RtlLeaveCriticalSectionAndRegion",              // 295  80000127
	"RtlLowerChar",                                  // 296  80000128
	"RtlMapGenericMask",                             // 297  80000129
	"RtlMoveMemory",                                 // 298  8000012A
	"RtlMultiByteToUnicodeN",                        // 299  8000012B
	"RtlMultiByteToUnicodeSize",                     // 300  8000012C
	"RtlNtStatusToDosError",                         // 301  8000012D
	"RtlRaiseException",                             // 302  8000012E
	"RtlRaiseStatus",                                // 303  8000012F
	"RtlTimeFieldsToTime",                           // 304  80000130
	"RtlTimeToTimeFields",                           // 305  80000131
	"RtlTryEnterCriticalSection",                    // 306  80000132
	"RtlUlongByteSwap",                              // 307  80000133
	"RtlUnicodeStringToAnsiString",                  // 308  80000134
	"RtlUnicodeStringToInteger",                     // 309  80000135
	"RtlUnicodeToMultiByteN",                        // 310  80000136
	"RtlUnicodeToMultiByteSize",                     // 311  80000137
	"RtlUnwind",                                     // 312  80000138
	"RtlUpcaseUnicodeChar",                          // 313  80000139
	"RtlUpcaseUnicodeString",                        // 314  8000013A
	"RtlUpcaseUnicodeToMultiByteN",                  // 315  8000013B
	"RtlUpperChar",                                  // 316  8000013C
	"RtlUpperString",                                // 317  8000013D
	"RtlUshortByteSwap",                             // 318  8000013E
	"RtlWalkFrameChain",                             // 319  8000013F
	"RtlZeroMemory",                                 // 320  80000140
	"XboxEEPROMKey",                                 // 321  80000141
	"XboxHardwareInfo",                              // 322  80000142
	"XboxHDKey",                                     // 323  80000143
	"XboxKrnlVersion",                               // 324  80000144
	"XboxSignatureKey",                              // 325  80000145
	"XeImageFileName",                               // 326  80000146
	"XeLoadSection",                                 // 327  80000147
	"XeUnloadSection",                               // 328  80000148
	"READ_PORT_BUFFER_UCHAR",                        // 329  80000149
	"READ_PORT_BUFFER_USHORT",                       // 330  8000014A
	"READ_PORT_BUFFER_ULONG",                        // 331  8000014B
	"WRITE_PORT_BUFFER_UCHAR",                       // 332  8000014C
	"WRITE_PORT_BUFFER_USHORT",                      // 333  8000014D
	"WRITE_PORT_BUFFER_ULONG",                       // 334  8000014E
	"XcSHAInit",                                     // 335  8000014F
	"XcSHAUpdate",                                   // 336  80000150
	"XcSHAFinal",                                    // 337  80000151
	"XcRC4Key",                                      // 338  80000152
	"XcRC4Crypt",                                    // 339  80000153
	"XcHMAC",                                        // 340  80000154
	"XcPKEncPublic",                                 // 341  80000155
	"XcPKDecPrivate",                                // 342  80000156
	"XcPKGetKeyLen",                                 // 343  80000157
	"XcVerifyPKCS1Signature",                        // 344  80000158
	"XcModExp",                                      // 345  80000159
	"XcDESKeyParity",                                // 346  8000015A
	"XcKeyTable",                                    // 347  8000015B
	"XcBlockCrypt",                                  // 348  8000015C
	"XcBlockCryptCBC",                               // 349  8000015D
	"XcCryptService",                                // 350  8000015E
	"XcUpdateCrypto",                                // 351  8000015F
	"RtlRip",                                        // 352  80000160
	"XboxLANKey",                                    // 353  80000161
	"XboxAlternateSignatureKeys",                    // 354  80000162
	"XePublicKeyData",                               // 355  80000163
	"HalBootSMCVideoMode",                           // 356  80000164
	"IdexChannelObject",                             // 357  80000165
	"HalIsResetOrShutdownPending",                   // 358  80000166
	"IoMarkIrpMustComplete",                         // 359  80000167
	"HalInitiateShutdown",                           // 360  80000168
	"snprintf",                                      // 361  80000169
	"sprintf",                                       // 362  8000016A
	"vsnprintf",                                     // 363  8000016B
	"vsprintf",                                      // 364  8000016C
	"HalEnableSecureTrayEject",                      // 365  8000016D
	"HalWriteSMCScratchRegister"                     // 366  8000016E
};

static ht_view *htxbeimports_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_xbe_shared_data *xbe_shared=(ht_xbe_shared_data *)group->get_shared_data();

	int h0=new_timer();
	start_timer(h0);

	ht_group *g;
	Bounds c;

	c=*b;
	g=new ht_group();
	g->init(&c, VO_RESIZE, DESC_XBE_IMPORTS"-g");
	ht_statictext *head;

	int function_count=0;

	c.y++;
	c.h--;
	ht_xbe_import_viewer *v=new ht_xbe_import_viewer();
	v->init(&c, DESC_XBE_IMPORTS, group);

	c.y--;
	c.h=1;

	FileOfs ofs;
	uint thunktablerva = xbe_shared->header.kernel_image_thunk_address - xbe_shared->header.base_address;
	uint *thunktable = ht_malloc(sizeof (xbox_exports));
	if (!thunktable) goto xbe_read_error;
	memset(thunktable, 0, sizeof(xbox_exports));

	if (!xbe_rva_to_ofs(&xbe_shared->sections, thunktablerva, &ofs))
		goto xbe_read_error;

	file->seek(ofs);
	if (file->read(thunktable, sizeof(xbox_exports)-4) != sizeof(xbox_exports)-4)
		goto xbe_read_error;

	for (; *thunktable; thunktable++, thunktablerva+=4) {
		uint ordinal;

		ordinal = createHostInt(thunktable, 4, little_endian);
		ht_xbe_import_function *func = new ht_xbe_import_function(thunktablerva, (char *)xbox_exports[ordinal & 0xfff], ordinal);
    		xbe_shared->imports.funcs->insert(func);
		function_count++;
	}
	

	stop_timer(h0);
//	LOG("%y: PE: %d ticks (%d msec) to read imports", file->get_name(), get_timer_tick(h0), get_timer_msec(h0));
	delete_timer(h0);

	char iline[256];
	ht_snprintf(iline, sizeof iline, "* XBE kernel thunk table at offset %08x (%d functions)", xbe_shared->header.kernel_image_thunk_address, function_count);
	head=new ht_statictext();
	head->init(&c, iline, align_left);

	g->insert(head);
	g->insert(v);
	//
	for (uint i=0; iimports.funcs->count(); i++) {
		ht_xbe_import_function *func = (ht_xbe_import_function*)(*xbe_shared->imports.funcs)[i];
		assert(func);
		char addr[32], name[256];
		ht_snprintf(addr, sizeof addr, "%08x", func->address);
		if (func->byname) {
			ht_snprintf(name, sizeof name, "%s", func->name.name);
		} else {
			ht_snprintf(name, sizeof name, "%04x (by ordinal)", func->ordinal);
		}
		v->insert_str(i, "NTOSKRNL.EXE", addr, name);
	}
	//
	v->update();

	g->setpalette(palkey_generic_window_default);

	xbe_shared->v_imports=v;
	return g;
xbe_read_error:
	delete_timer(h0);
	String fn;
	errorbox("%y: XBE import section seems to be corrupted.", &file->getFilename(fn));
	g->done();
	delete g;
	v->done();
	delete v;
	return NULL;
}

format_viewer_if htxbeimports_if = {
	htxbeimports_init,
	NULL
};

/*
 *	ht_xbe_import_function
 */
ht_xbe_import_function::ht_xbe_import_function(RVA a, uint o)
{
	ordinal = o;
	address = a;
	byname = false;
}

ht_xbe_import_function::ht_xbe_import_function(RVA a, char *n, uint h)
{
	name.name = ht_strdup(n);
	name.hint = h;
	address = a;
	byname = true;
}

ht_xbe_import_function::~ht_xbe_import_function()
{
	if (byname) free(name.name);
}

/*
 *	ht_xbe_import_viewer
 */
void ht_xbe_import_viewer::init(Bounds *b, const char *Desc, ht_format_group *fg)
{
	ht_text_listbox::init(b, 3, 2, LISTBOX_QUICKFIND);
	options |= VO_BROWSABLE;
	desc = strdup(Desc);
	format_group = fg;
	grouplib = false;
	sortby = 1;
	dosort();
}

void ht_xbe_import_viewer::done()
{
	ht_text_listbox::done();
}

void ht_xbe_import_viewer::dosort()
{
	ht_text_listbox_sort_order sortord[2];
	uint l, s;
	if (grouplib) {
		l = 0;
		s = 1;
	} else {
		l = 1;
		s = 0;
	}
	sortord[l].col = 0;
	sortord[l].compare_func = strcmp;
	sortord[s].col = sortby;
	sortord[s].compare_func = strcmp;
	sort(2, sortord);
}

const char *ht_xbe_import_viewer::func(uint i, bool execute)
{
	switch (i) {
		case 2:
			if (execute) {
				grouplib = !grouplib;
				dosort();
			}
			return grouplib ? (char*)"nbylib" : (char*)"bylib";
		case 4:
			if (execute) {
				if (sortby != 1) {
					sortby = 1;
					dosort();
				}
			}
			return "byaddr";
		case 5:
			if (execute) {
				if (sortby != 2) {
					sortby = 2;
					dosort();
				}
			}
			return "byname";
	}
	return NULL;
}

void ht_xbe_import_viewer::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
	case msg_funcexec:
		if (func(msg->data1.integer, 1)) {
			clearmsg(msg);
			return;
		}
		break;
	case msg_funcquery: {
		const char *s=func(msg->data1.integer, 0);
		if (s) {
			msg->msg=msg_retval;
			msg->data1.cstr=s;
		}
		break;
	}
	case msg_keypressed: {
		if (msg->data1.integer == K_Return) {
			select_entry(e_cursor);
			clearmsg(msg);
		}
		break;
	}
	}
	ht_text_listbox::handlemsg(msg);
}

bool ht_xbe_import_viewer::select_entry(void *entry)
{
	ht_text_listbox_item *i = (ht_text_listbox_item *)entry;

	ht_xbe_shared_data *xbe_shared=(ht_xbe_shared_data *)format_group->get_shared_data();

	ht_xbe_import_function *e = (ht_xbe_import_function*)(*xbe_shared->imports.funcs)[i->id];
	if (!e) return true;
	if (xbe_shared->v_image) {
		ht_aviewer *av = (ht_aviewer*)xbe_shared->v_image;
		XBEAnalyser *a = (XBEAnalyser*)av->analy;
		Address *addr;
		addr = a->createAddress32(e->address+xbe_shared->header.base_address);
		if (av->gotoAddress(addr, NULL)) {
			app->focus(av);
			vstate_save();
		} else {
			global_analyser_address_string_format = ADDRESS_STRING_FORMAT_COMPACT | ADDRESS_STRING_FORMAT_ADD_0X;
			errorbox("can't follow: %s %y is not valid!", "import address", addr);
		}
		delete addr;
	} else errorbox("can't follow: no image viewer");
	return true;
}
ht-2.0.22/htpefimp.cc0000644000175000001440000001645310771304342011262 00000000000000/*
 *	HT Editor
 *	htpefimp.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "formats.h"
#include "htanaly.h"
#include "htctrl.h"
#include "data.h"
#include "endianess.h"
#include "htiobox.h"
#include "htpal.h"
#include "htpef.h"
#include "htpefimp.h"
#include "stream.h"
#include "strtools.h"
#include "httag.h"
#include "log.h"
#include "pef_analy.h"
#include "snprintf.h"
#include "tools.h"

#include 
#include 

ht_view *htpefimports_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_pef_shared_data *pef_shared=(ht_pef_shared_data *)group->get_shared_data();

	if (!pef_shared->loader_info_header_ofs 
	|| !pef_shared->loader_info_header.importedLibraryCount 
	|| !pef_shared->loader_info_header.totalImportedSymbolCount) return NULL;
	
	FileOfs nametable = pef_shared->loader_info_header_ofs + pef_shared->loader_info_header.loaderStringsOffset;
	FileOfs functions_offset = pef_shared->loader_info_header_ofs 
			+ sizeof pef_shared->loader_info_header
			+ pef_shared->loader_info_header.importedLibraryCount
				* sizeof(PEF_ImportedLibrary);

	ht_group *g;
	Bounds c;

	c=*b;
	g=new ht_group();
	g->init(&c, VO_RESIZE, DESC_PEF_IMPORTS"-g");
	ht_statictext *head;

	int lib_count = pef_shared->loader_info_header.importedLibraryCount;
	int function_count = pef_shared->loader_info_header.totalImportedSymbolCount;

	c.y++;
	c.h--;
	ht_pef_import_viewer *v=new ht_pef_import_viewer();
	v->init(&c, DESC_PEF_IMPORTS, group);

	c.y--;
	c.h=1;

	int symbol_num = 0;
	for (uint i=0; i < pef_shared->loader_info_header.importedLibraryCount; i++) {
		file->seek(pef_shared->loader_info_header_ofs + sizeof pef_shared->loader_info_header
			+ i*sizeof(PEF_ImportedLibrary));

		PEF_ImportedLibrary lib;
		file->read(&lib, sizeof lib);
		createHostStruct(&lib, PEF_ImportedLibrary_struct, pef_shared->byte_order);

		file->seek(nametable + lib.nameOffset);
		char *libname = file->fgetstrz();

		ht_pef_import_library *library=new ht_pef_import_library(libname);
		pef_shared->imports.libs->insert(library);

		for (uint j=0; j < lib.importedSymbolCount; j++) {
			file->seek(functions_offset + 4 * (lib.firstImportedSymbol+j));
			uint32 entry;
			file->read(&entry, 4);
			entry = createHostInt(&entry, 4, pef_shared->byte_order);
			
			uint32 symbol_ofs = entry & 0x00ffffff;
			uint32 symbol_class = entry >> 24;

			file->seek(nametable+symbol_ofs);
			char *symbol_name = file->fgetstrz();

			ht_pef_import_function *func = new ht_pef_import_function(i, symbol_num, symbol_name, symbol_class);
			pef_shared->imports.funcs->insert(func);

			free(symbol_name);
			symbol_num++;
		}
		
		free(libname);
	}

	char iline[1024];
	ht_snprintf(iline, sizeof iline, "* PEF import library description at offset %08qx (%d functions from %d libraries)", 
		pef_shared->loader_info_header_ofs + sizeof pef_shared->loader_info_header, 
		function_count, lib_count);
		
	head=new ht_statictext();
	head->init(&c, iline, align_left);

	g->insert(head);
	g->insert(v);
	//
	for (uint i=0; i < pef_shared->imports.funcs->count(); i++) {
		ht_pef_import_function *func = (ht_pef_import_function*)(*pef_shared->imports.funcs)[i];
		assert(func);
		ht_pef_import_library *lib = (ht_pef_import_library*)(*pef_shared->imports.libs)[func->libidx];
		assert(lib);
		char addr[32], name[256];
		ht_snprintf(addr, sizeof addr, "%d", func->num);
		ht_snprintf(name, sizeof name, "%s", func->name);
		v->insert_str(i, lib->name, addr, name);
	}
	//
	v->update();

	g->setpalette(palkey_generic_window_default);

	pef_shared->v_imports = v;
	return g;
pef_read_error:
	String fn;
	errorbox("%y: PEF import library description seems to be corrupted.", &file->getFilename(fn));
	g->done();
	delete g;
	v->done();
	delete v;
	return NULL;
}

format_viewer_if htpefimports_if = {
	htpefimports_init,
	NULL
};

/*
 *	class ht_pef_import_library
 */

ht_pef_import_library::ht_pef_import_library(char *n)
{
	name = ht_strdup(n);
}

ht_pef_import_library::~ht_pef_import_library()
{
	free(name);
}

/*
 *	class ht_pe_import_function
 */

ht_pef_import_function::ht_pef_import_function(uint aLibidx, int aNum, const char *aName, uint aSym_class)
{
	libidx = aLibidx;
	name = ht_strdup(aName);
	num = aNum;
	sym_class = aSym_class;
}

ht_pef_import_function::~ht_pef_import_function()
{
	free(name);
}

/*
 *	CLASS ht_pef_import_viewer
 */

void ht_pef_import_viewer::init(Bounds *b, const char *Desc, ht_format_group *fg)
{
	ht_text_listbox::init(b, 3, 2, LISTBOX_QUICKFIND);
	options |= VO_BROWSABLE;
	desc = strdup(Desc);
	format_group = fg;
	grouplib = false;
	sortby = 1;
	dosort();
}

void	ht_pef_import_viewer::done()
{
	ht_text_listbox::done();
}

void ht_pef_import_viewer::dosort()
{
	ht_text_listbox_sort_order sortord[2];
	uint l, s;
	if (grouplib) {
		l = 0;
		s = 1;
	} else {
		l = 1;
		s = 0;
	}
	sortord[l].col = 0;
	sortord[l].compare_func = strcmp;
	sortord[s].col = sortby;
	sortord[s].compare_func = strcmp;
	sort(2, sortord);
}

const char *ht_pef_import_viewer::func(uint i, bool execute)
{
	switch (i) {
		case 2:
			if (execute) {
				grouplib = !grouplib;
				dosort();
			}
			return grouplib ? (char*)"nbylib" : (char*)"bylib";
		case 5:
			if (execute) {
				if (sortby != 2) {
					sortby = 2;
					dosort();
				}
			}
			return "byname";
	}
	return NULL;
}

void ht_pef_import_viewer::handlemsg(htmsg *msg)
{
	switch (msg->msg) {
	case msg_funcexec:
		if (func(msg->data1.integer, 1)) {
			clearmsg(msg);
			return;
		}
		break;
	case msg_funcquery: {
		const char *s=func(msg->data1.integer, 0);
		if (s) {
			msg->msg=msg_retval;
			msg->data1.cstr=s;
		}
		break;
	}
	case msg_keypressed: {
		if (msg->data1.integer == K_Return) {
			select_entry(e_cursor);
			clearmsg(msg);
		}
		break;
	}
	}
	ht_text_listbox::handlemsg(msg);
}

bool ht_pef_import_viewer::select_entry(void *entry)
{
/*	ht_text_listbox_item *i = (ht_text_listbox_item *)entry;

	ht_pef_shared_data *pef_shared=(ht_pef_shared_data *)format_group->get_shared_data();

	ht_pef_import_function *e = (ht_pef_import_function*)pef_shared->imports.funcs->get(i->id);
	if (!e) return true;
	if (pef_shared->v_image) {
		ht_aviewer *av = (ht_aviewer*)pef_shared->v_image;
		PEFAnalyser *a = (PEFAnalyser*)av->analy;
		Address *addr;
		if (pef_shared->opt_magic == COFF_OPTMAGIC_PE32) {
			addr = a->createAddress32(e->address+pe_shared->pe32.header_nt.image_base);
		} else {
			addr = a->createAddress64(to_qword(e->address)+pe_shared->pe64.header_nt.image_base);
		}
		if (av->gotoAddress(addr, NULL)) {
			app->focus(av);
			vstate_save();
		} else {
			global_analyser_address_string_format = ADDRESS_STRING_FORMAT_COMPACT | ADDRESS_STRING_FORMAT_ADD_0X;
			errorbox("can't follow: %s %y is not valid!", "import address", addr);
		}
		delete addr;
	} else errorbox("can't follow: no image viewer");*/
	return true;
}


ht-2.0.22/htdebug.cc0000644000175000001440000000747010615341616011071 00000000000000/* 
 *	HT Editor
 *	htdebug.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "htdebug.h"

#include 
#include 
#include 
#include 

// FIXME: auto-detect ?
#define CPU_CLOCK 500000000

void ht_assert_failed(const char *file, int line, const char *assertion)
{
	fprintf(stderr, "in file %s, line %d: assertion failed: %s\n", file, line, assertion);
#ifndef WIN32
#if 1
	fprintf(stderr, "sending SIGTRAP...");
	raise(SIGTRAP);
#endif
#endif
	exit(1);
}

void ht_error(const char *file, int line, const char *format,...)
{
	va_list arg;
	va_start(arg, format);
	fprintf(stderr, "in file %s, line %d: error: ", file, line);
	vfprintf(stderr, format, arg);
	fputc('\n', stderr);
	va_end(arg);
	exit(1);
}

void ht_trace(char *file, int line, char *format,...)
{
	FILE *ht_debug_file = stderr;
	va_list arg;
	va_start(arg, format);
	fprintf(ht_debug_file, "TRACE: %s.%d: ", file, line);
	vfprintf(ht_debug_file, format, arg);
	fputc('\n', ht_debug_file);
	va_end(arg);
}

void ht_warn(char *file, int line, char *format,...)
{
	va_list arg;
	va_start(arg, format);
	fprintf(stderr, "in file %s, line %d: warning: ", file, line);
	vfprintf(stderr, format, arg);
	fputc('\n', stderr);
	va_end(arg);
}

#ifdef DJGPP

#define MAX_TIMERS 20

timepoint timer_start[MAX_TIMERS];
timepoint timer_end[MAX_TIMERS];
int handle[MAX_TIMERS];
int handle_count=0;

timer_handle getfreetimerhandle()
{
	timer_handle i;
	for (i=0; ihandle_count)) return;
	uint32 s0, s1;
	asm("rdtsc" : "=a" (s0), "=d" (s1));
	timer_start[h].hi=s1;
	timer_start[h].lo=s0;
}

void stop_timer(timer_handle h)
{
	if ((h<0) || (h>handle_count)) return;
	uint32 e0, e1;
	asm("rdtsc" : "=a" (e0), "=d" (e1));
	timer_end[h].hi=e1;
	timer_end[h].lo=e0;
}

void delete_timer(timer_handle h)
{
	if ((h<0) || (h>handle_count)) return;
	handle[h]=0;
}

void get_timer_tick_internal(timer_handle h, timepoint *p)
{
	if ((h<0) || (h>handle_count)) {
		*p = to_qword(0);
		return;
	}
	*p = timer_end[h] - timer_start[h];
}

uint32 get_timer_sec(timer_handle h)
{
	if ((h<0) || (h>handle_count)) return 0;
	timepoint t;
	get_timer_tick_internal(h, &t);
	t = t / to_qword(CPU_CLOCK);
	if (t.hi) return 0xffffffff; else return t.lo;
}

uint32 get_timer_msec(timer_handle h)
{
	if ((h<0) || (h>handle_count)) return 0;
	timepoint t;
	get_timer_tick_internal(h, &t);
	t = t / to_qword(CPU_CLOCK/1000);
	if (t.hi) return 0xffffffff; else return t.lo;
}

uint32 get_timer_tick(timer_handle h)
{
	timepoint t;
	get_timer_tick_internal(h, &t);
	return t.lo;
}

#else

timer_handle new_timer()
{
	return -1;
}

void start_timer(timer_handle handle)
{
}

void stop_timer(timer_handle handle)
{
}

void delete_timer(timer_handle handle)
{
}

uint32 get_timer_sec(timer_handle handle)
{
	return 0;
}

uint32 get_timer_msec(timer_handle handle)
{
	return 0;
}

uint32 get_timer_tick(timer_handle h)
{
	return 0;
}

#endif
ht-2.0.22/defreg.c0000644000175000017500000002045612127651417010546 00000000000000/* generated by bin2c from ht.reg */

char default_reg[1605] = {
	0x00,0x00,0x18,' ', 0x00,0x00,0x06,'=', 
	0x00,0x1f,'R', 'E', 'G', 0x00,'D', 'A', 
	'T', '!', 'D', 'A', 'T', 0xc0,0x00,0x00,
	0x00,0x06,'R', 'E', 'G', 0x10,0x00,0x00,
	0x00,0x03,'d', 'w', 'o', 'r', 'd', 0x00,
	'R', 'E', 'G', '"', 0x00,0x00,0x01,0x00,
	'p', 'a', 'l', 'e', 't', 't', 'e', 0x00,
	'P', 'A', 'L', 't', 0x03,0x01,0x05,'r', 
	'a', 'w', 'l', 0x03,0x08,'$', 0x00,0x00,
	0x00,0x04,'s', 't', 'r', 'i', 'n', 'g', 
	'x', 0x01,0x09,'#', 0x00,0x00,0x00,0x01,
	's', 'u', 'b', 'd', 'i', 'r', 0x00,0xc0,
	0x00,0x05,0x02,'s', 'y', 'm', 'l', 'i', 
	'n', 'k', 'x', 0x03,0x02,'!', 'R', 'E', 
	'G', 0x01,'i', 0x04,'/', 'u', 0x01,0x02,
	')', 0xd5,0x01,0x02,0xe4,0x03,0x02,'c', 
	'o', 'n', 'f', 'i', 0x8c,0x09,'3', 'x', 
	0x00,0x03,'e', 'd', 'i', 't', 'o', 'r', 
	'.', 0xf5,0x00,0x05,0xd4,0x07,0x01,0x04,
	'E', 'O', 'F', 'l', 0x03,0x03,0x05,'<', 
	'E', 'O', 'F', '>', '`', 0x10,0x01,0x04,
	'E', 'O', 'L', 0x85,0x02,'.', 't', 0x01,
	0x09,0x03,'a', 'u', 't', 'o', ' ', 'i', 
	'n', 'd', 'e', 'n', 't', 'u', 0x02,0x03,
	'l', 0x11,'l', 0x1d,0x09,'s', 'c', 'r', 
	'o', 'l', 'l', ' ', 'o', 'f', 'f', 's', 
	'e', '\'','d', 0x00,'t', 0x03,0x06,0x03,
	't', 'a', 'b', ' ', 's', 'i', 'z', 'e', 
	0xf9,0x05,0x08,'h', 0x06,0x01,'m', 'i', 
	's', 'c', '`', 0x02,'*', 0x89,0x02,0x03,
	0xcd,0x10,0x03,0xa4,0x18,0x03,' ', 'f', 
	'o', 'r', 'm', 'a', '\'','-', 0x01,0x02,
	0xbc,'$', 0x04,'a', 't', 'u', 's', 'l', 
	'i', 'n', 0x94,0x09,0x0a,0x05,'%', 'a', 
	' ', '%', 'L', ' ', '%', 't', ' ', '%', 
	'd', 0x00,'x', 0x03,0x08,'v', 'f', 's', 
	' ', 'd', 'i', 's', 'p', 'l', 'a', 'y', 
	')', 0xf4,0x00,0x00,0x07,0x05,'t', 'y', 
	'p', 'e', ',', 'n', 'a', 'm', 'e', ':', 
	'2', '0', '+', ',', '|', ',', 'd', 'e', 
	's', 'c', ',', '|', ',', 'b', 't', 0x12,
	0x04,',', '|', ',', 'p', 'e', 'r', 'm', 
	'X', 0x01,0x03,'r', 'm', 't', 'i', 'm', 
	'e', '}', 0x08,0x01,0xe8,'5', 'H', '7', 
	'*', 0x81,0x02,0x04,0xc0,0x14,0x05,0x01,
	'a', 'n', 'a', 'l', 'y', 's', 'e', '/', 
	0x15,0x05,0x01,0xe0,0x04,0x03,'d', 'e', 
	'f', 'a', 'u', 'l', 0x8c,0x17,'*', 0x00,
	0x01,'e', 'C', 0x01,'l', 'A', 0x01,'c', 
	'o', 'm', 'm', 'd', '(', 'L', 'A', '`', 
	0x0e,0x02,0x00,0x00,0x00,0x07,0x08,'|', 
	0x02,0xfc,0x06,'(', ']', 0x00,0x82,0x9c,
	0x02,0x02,'l', 'a', 'b', 'e', 'l', 'd', 
	'G', 0xd5,0x05,0x86,0x94,0x02,0x03,'n', 
	'u', 'm', 'b', 'e', 'r', ')', 'Y', 0x00,
	0x03,0x98,0x02,0xd0,'I', '(', 0x0d,0x01,
	0x84,0xb8,0x02,0x0a,'y', 'm', 'b', 'o', 
	'l', '-', 'c', 'h', 'a', 'r', 'a', 'c', 
	't', '+', 0xdd,0x00,0x83,0x8c,'2', 0x03,
	'g', 'e', 'n', 'e', 'r', 'i', '/', 'Y', 
	0x06,0x0c,0xf0,0x1a,0x01,'b', 'l', 'a', 
	'c', 0x90,'P', '*', 'I', 0x03,0x1b,0xb4,
	0x03,0x03,0x01,0x00,'b', 'o', 'd', 'y', 
	')', ')', 0x02,0x07,'t', '<', 0x0c,0x00,
	'b', 'u', 't', 't', 'o', 'n', ' ', 'f', 
	'o', 'c', 'u', 's', 'e', 'd', ')', 'z', 
	0x00,0x87,0x02,'x', 0x1d,0xd8,0x03,0x03,
	's', 'h', 'a', 'd', 'o', 'w', ')', 'u', 
	0x00,0x00,0x80,0x16,'\'','t', 0x00,0x03,
	'o', 'r', 't', 'c', 'u', 't', '*', '|', 
	0x00,'*', 'r', 0x01,'u', 'n', '0', 'y', 
	0x01,0x00,0x98,0x0b,0x01,'c', 'l', 'u', 
	's', '@', 0x1d,'2', 0xf9,0x01,0x03,'x', 
	0x0f,0xfe,0x03,'s', 'h', '/', 0x85,0x01,
	0x86,'+', 0x80,0x00,'3', 0x88,0x01,0x84,
	0x04,0x02,'f', 'r', 'a', 'm', 'e', '1', 
	0x80,0x01,0xb8,'9', 0xb4,0x03,0x01,'k', 
	'i', 'l', 'l', '+', 0xb9,0x05,0x02,0x98,
	0x1b,0xb0,0x03,0x04,'m', 'o', 'v', 'e', 
	'-', 'r', 'e', 'h', 'Q', ')', 0x80,0x03,
	0xb4,'>', 0xa4,0x04,'2', 0xf0,0x01,0xb8,
	0x0b,0x07,'i', 'n', 'p', 'u', 't', ' ', 
	'c', 'l', 'i', 'p', 0x95,':', 's', '*', 
	0x00,0x01,0x98,'L', 0xa0,0x04,'0', 'y', 
	0x04,0x87,')', 't', 0x00,0x03,'s', 'e', 
	'l', 'e', 'c', 't', '1', 'p', 0x06,0xb0,
	0x07,'2', 0xf4,0x01,0xb8,0x07,0x01,'l', 
	'i', 's', 't', 0xe7,0x1f,' ', '&', ' ', 
	'2', 0x1c,0x01,0x98,0x0c,'-', 0x9e,0x00,
	'u', 'n', '1', 0xa4,0x00,0xb4,'E', 0x84,
	0x05,'\'',0xc0,0x01,'5', 'L', 0x01,0x88,
	'?', '/', 0xa4,0x00,'3', 'T', 0x01,'r', 
	'e', 0x01,0x00,0xa6,0x93,'b', 'a', '*', 
	0xa2,0x0c,0x00,0x07,'|', '?', 0x01,'t', 
	'e', 'x', 't', 0x7f,0x85,'a', 'b', 'l', 
	'+', 0xfd,0x03,0x07,0x88,';', 0x94,0x03,
	'0', 0xed,0x04,0x00,'(', 'p', 0x00,'1', 
	' ', 0x03,0xa8,0x0e,0x88,0x07,'1', 'T', 
	0x09,0xb8,0x1c,'+', 't', 0x00,'2', 0xdc,
	0x04,0xb4,'{', 0x98,0x04,'\'','4', 0x04,
	')', 'l', 0x07,'t', 'c', 0x02,0x00,0x01,
	'b', 'l', 'u', 0x90,0xa0,' ', 0x03,'1', 
	0x0e,0x03,0x80,'1', 0xdc,'i', '0', 'H', 
	0x03,' ', 0x1d,'0', 0x0e,0xb4,0x15,0xd0,
	0x0b,'3', 0xbc,0x02,' ', 0x1f,'0', 0x0e,
	0xb0,'*', 0xf4,'u', '3', 0x88,0x01,0x94,
	'B', 0xbc,'e', '1', '|', 0x03,')', 0xbc,
	0x0d,'/', '0', 0x0e,'*', 0xa8,0x0d,' ', 
	's', '1', 0x0e,0x81,0x88,'U', ' ', '"', 
	'0', 0x0e,0x9c,'V', 0x80,'g', 0xc7,'$', 
	' ', '&', ' ', '3', 0xd8,0x0c,0xb4,'E', 
	0x84,0x05,'\'',0xac,0x05,'4', '0', 0x0e,
	0xac,'a', '/', 0xa4,0x00,'9', 'T', 0x01,
	'2', '1', 0x0e,0x01,0x84,0x13,0x9b,']', 
	'd', 'i', 's', '.', '1', 0x0e,0x86,0x8c,
	'W', 0x94,0x03,0xdc,0x16,')', '(', 0x0c,
	')', 'p', 0x00,'1', '1', 0x0e,0x01,'(', 
	0xe8,0x00,'1', '1', 0x0e,0x00,'0', 't', 
	0x00,'2', '0', 0x0e,')', 0x98,0x00,'\'',
	'4', 0x04,')', 0x04,0x02,'l', 0xa1,0x03,
	0x00,0x01,'c', 'y', 'a', 'n', '.', '8', 
	'#', '6', 'd', 0x1c,0xb0,'&', 0xdc,'e', 
	'0', 'H', 0x03,' ', 0x7f,'0', 0x0e,' ', 
	0x1f,'e', 0x1c,0x87,' ', '=', '0', 0x0e,
	'r', 0xa3,0x01,0x00,0xb8,'e', ' ', 0xa3,
	'd', 0x1c,0xb4,'E', '/', 0x88,0x0d,'1', 
	0xb5,0x0b,0x87,0x98,'h', '/', 0xa4,0x00,
	'3', '0', 0x0e,0xb4,0x0a,'2', '0', 0x0e,
	0xb0,0x7f,0x98,'m', '1', '0', 0x0e,')', 
	0x00,0x1b,'0', 0xe4,0x0a,0xa8,'/', 0x88,
	0x07,'1', 'x', 0x02,'*', 't', 0x00,'1', 
	0xbc,'%', 0x94,'B', 0xac,0x07,0xd4,0x03,
	'2', '0', 0x0e,')', 0xbc,0x0f,'2', '0', 
	0x0e,'l', 0x0c,0x06,0x00,0x02,'d', 'e', 
	's', 'k', 't', 'o', 'p', '}', 'q', 0x05,
	'$', 0xcc,'*', 0x06,0x00,0x00,0x00,0x02,
	'd', 'i', 'a', 'l', 'o', '#', 'X', '4', 
	0x02,0x05,'g', 'r', 'a', 'y', 0x8c,0xca,
	0x80,0x01,'-', 0x90,'/', '7', 0xd8,0x0e,
	0x9c,0xb0,' ', 0x00,0xdf,0xd8,0x0e,'#', 
	'$', '#', 0x88,'l', 0xd8,'_', '6', 0x0c,
	0x1d,0xa0,'l', 0x84,0x05,'\'',0xa0,0x0a,
	'4', 0x0c,0x1d,' ', 'C', 0xd9,0x0e,0x80,
	'(', 't', 0x0d,0xdc,0x16,'*', 0x04,0x1b,
	'(', 'p', 0x00,'1', 0xd8,0x0e,'~', 0xdb,
	0x01,0x00,'+', '`', 0x0e,')', 0xec,0x00,
	'$', 0xec,'\'','+', 't', 0x00,'3', 0xd8,
	0x0e,'(', 0x88,0x01,'\'','4', 0x04,')', 
	0x14,0x01,0x99,'v', 0x01,'q', 'q', '2', 
	'p', 'v', ' ', 0x03,'D', '+', '$', 0x00,
	'/', ' ', 0x98,'4', 0x0e,0x95,0x8f,0x00,
	';', 'D', '+', 0x94,0xb9,'6', 'D', '+', 
	'f', '&', 0x01,0x00,0xb4,0x03,' ', '2', 
	'D', '+', 0xb8,0x0b,' ', 0x80,0x10,0x1d,
	' ', 'x', '4', 0x0e,0xbc,'\'',0x98,'b', 
	' ', '.', 0x10,0x1d,0x88,0x1e,0x80,0x0b,
	'1', 'E', '+', 0x04,'(', 0x98,0x0d,0xf4,
	0x03,'2', '4', 0x0e,')', 0x98,0x00,'7', 
	'4', 0x0e,0x01,0x02,'h', 'e', 'l', 0xa4,
	0xe8,'#', 'h', '+', 'c', 0xe8,'k', 'e', 
	'y', '\'',0xe0,'M', '(', 'X', 0x1d,0x01,
	'm', 'e', 'n', 'u', 'p', 'v', 0x91,0xea,
	'2', '|', 'Z', 0x05,0x02,'s', 'p', 'e', 
	'c', 'i', 'a', 'l', 0x94,0x02,'\'',0xf7,
	0x00,'w', 'i', 'n', '"', 0x8c,'G', 0x01,
	'R', 'E', 'G', 0x05,'#', 0xe4,':', '"', 
	0xc0,'6', 0x03,'s', 'y', 'n', 't', 'a', 
	'x', '|', 0x04,'*', 0xc8,0x0f,'\'',0x10,
	'M', '/', '$', 'J', '\'','d', 0x00,'&', 
	0x98,'L', '-', 0xe9,0x1e,0x0b,'&', ',', 
	'J', '6', 0x8e,'K', 0x01,0x00,'6', 0xe0,
	'M', 0x03,'f', 'l', 'o', 'a', 't', ' ', 
	'/', 'A', 'M', 0x81,0x85,'*', 'i', '"', 
	0xb7,'S', 'i', 'f', 'i', '+', 0x10,'G', 
	0xa8,0x9f,0x04,'i', 'n', 't', 'e', 'g', 
	'e', 'r', '0', 0xe5,0x00,0x85,0x84,0x07,
	0x01,'m', 'e', 't', 'a', ')', 0xa0,0x13,
	0xb8,0x09,0x06,'p', 'r', 'e', 'p', 'r', 
	'o', 'c', 'e', 's', '+', 0xc0,'F', 0x9c,
	0x05,0x03,'r', 'e', 's', 'e', 'r', 'v', 
	'+', '0', 'B', '$', 0xbc,',', '/', 'L', 
	'O', '"', 0xcb,'N', 0x01,0x00,'s', '#', 
	'L', 'O', ')', 0x84,0x01,0xb4,0x05,0x06,
	'w', 'h', 'i', 't', 'e', 's', 'p', 'a', 
	'c', '#', 0xb4,'Y', 's', '2', 0x00,0x00,
	0x00,'`', 0x16,0x03,0x00,0x01,'t', 'a', 
	'g', 's', '7', 0xc4,0x05,'5', ']', 0x05,
	0x09,0xfc,'*', '"', 0xec,'X', 0x01,'-', 
	't', 'a', 'g', ')', 0xc0,0x01,'$', '$', 
	'J', 0xe0,0x03,0x05,' ', 'c', 'u', 'r', 
	's', 'o', 'r', ' ', '|', 0x01,')', 0x92,
	0x00,0x87,0x04,'"', 0xb8,'E', 'p', 0x02,
	't', 0x07,0xf0,0x04,0xb4,0xcd,'?', 0x98,
	0x00,'2', 0x8c,0x0a,0xb8,0x1c,'\'','C', 
	0x01,'m', 'o', 'd', 'x', '3', '*', 0x80,
	'Q', '$', 0xcc,'S', '\'',0x84,0x00,0xac,
	0x0d,'+', 'a', 0x05,0x80,'#', '@', '\'',
	'@', 0x03,'l', 0x12,'*', 0x14,0x02,0x84,
	'1', 0xdc,0x02,0xec,0x15,'1', 0xd8,0x1c,
	0x80,0xb4,'-', 0x98,0x00,'2', 0xae,0x02,
	0x00,0x03,0x11,0x00,0x00
};
ht-2.0.22/fltstruc.cc0000644000175000001440000000272010615341616011306 00000000000000/* 
 *	HT Editor
 *	fltstruc.cc
 *
 *	Copyright (C) 2003 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "fltstruc.h"
#include "endianess.h"

byte FLAT_HEADER_struct[]= {
	STRUCT_ENDIAN_8,
	STRUCT_ENDIAN_8,
	STRUCT_ENDIAN_8,
	STRUCT_ENDIAN_8,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,

	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	0
};


ht-2.0.22/htflthd.h0000644000175000001440000000157007671115030010736 00000000000000/* 
 *	HT Editor
 *	htflthd.h
 *
 *	Copyright (C) 2003 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTFLTHD_H__
#define __HTFLTHD_H__

#include "htobj.h"
#include "formats.h"

extern format_viewer_if htfltheader_if;

#endif /* !__HTMACHOHD_H__ */

ht-2.0.22/nestruct.cc0000644000175000001440000000620710615341624011312 00000000000000/* 
 *	HT Editor
 *	nestruct.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */


#include "endianess.h"
#include "nestruct.h"

byte NE_HEADER_struct[] = {
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	0
};

byte NE_SEGMENT_struct[] = {
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	0
};

byte NE_ENTRYPOINT_HEADER_struct[] = {
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	0
};

byte NE_ENTRYPOINT_MOVABLE_struct[] = {
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	0
};

byte NE_ENTRYPOINT_FIXED_struct[] = {
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	0
};

byte NE_RELOC_HEADER_struct[] = {
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	0
};

byte NE_RELOC_INTERNAL_struct[] = {
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	0
};

byte NE_RELOC_IMPORT_struct[] = {
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	0
};

byte NE_RELOC_FIXUP_struct[] = {
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	0
};

ht-2.0.22/htnewexe.cc0000644000175000001440000000254610615341623011273 00000000000000/* 
 *	HT Editor
 *	htnewexe.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "htnewexe.h"

#include "mzstruct.h"
#include "endianess.h"

FileOfs get_newexe_header_ofs(File *file)
{
	/* look for mz magic */
	byte mzmagic[2];
	file->seek(0);
	file->read(mzmagic, 2);
	if ((mzmagic[0] != IMAGE_MZ_MAGIC0) || (mzmagic[1] != IMAGE_MZ_MAGIC1))
		return 0;
	/* test if reloc_ofs >= 0x40 */
	uint16 reloc_ofs;
	file->seek(24);
	file->read(&reloc_ofs, 2);
	reloc_ofs = createHostInt(&reloc_ofs, 2, little_endian);
	if (reloc_ofs && reloc_ofs < 0x40) return 0;
	/* ok seems to be a newexe */
	FileOfs newexe_ofs;
	file->seek(60);
	file->read(&newexe_ofs, 4);
	newexe_ofs = createHostInt(&newexe_ofs, 4, little_endian);
	return newexe_ofs;
}
ht-2.0.22/htmz.cc0000644000175000001440000000431710615341620010421 00000000000000/* 
 *	HT Editor
 *	htmz.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "endianess.h"
#include "htmz.h"
#include "htmzhead.h"
#include "htmzrel.h"
#include "htmzimg.h"
#include "mzstruct.h"
#include "stream.h"

static format_viewer_if *htmz_ifs[] = {
	&htmzheader_if,
//	&htmzrel_if,
	&htmzimage_if,
	0
};

static ht_view *htmz_init(Bounds *b, File *file, ht_format_group *format_group)
{
	byte magic[2];
	file->seek(0);
	if (file->read(magic, 2) != 2 
	 || magic[0] != IMAGE_MZ_MAGIC0 || magic[1] != IMAGE_MZ_MAGIC1)
		return NULL;

	ht_mz *g = new ht_mz();
	g->init(b, file, htmz_ifs, format_group);
	return g;
}

format_viewer_if htmz_if = {
	htmz_init,
	0
};

void ht_mz::init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group)
{
	ht_format_group::init(b, VO_SELECTABLE | VO_BROWSABLE | VO_RESIZE, DESC_MZ, file, false, true, 0, format_group);
	ht_mz_shared_data *mz_shared = ht_malloc(sizeof (ht_mz_shared_data));
	shared_data = mz_shared;
	file->seek(0);
	file->read(&mz_shared->header, sizeof mz_shared->header);
	createHostStruct(&mz_shared->header, MZ_HEADER_struct, little_endian);
	shared_data = mz_shared;
	ht_format_group::init_ifs(ifs);
}

void ht_mz::done()
{
	free(shared_data);
	ht_format_group::done();
}

void ht_mz::loc_enum_start()
{
	loc_enum=1;
}

bool ht_mz::loc_enum_next(ht_format_loc *loc)
{
	ht_mz_shared_data *sh=(ht_mz_shared_data*)shared_data;
	if (loc_enum) {
		loc->name = "mz";
		loc->start = 0;
		loc->length= sh->header.header_size*16+(sh->header.sizep-1)*512+
			     sh->header.sizelp;

		loc_enum = 0;
		return true;
	}
	return false;
}
ht-2.0.22/htcoff.cc0000644000175000001440000001763510615341616010724 00000000000000/*
 *	HT Editor
 *	htcoff.cc
 *
 *	Copyright (C) 1999-2003 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "coff_s.h"
#include "log.h"
#include "htcoff.h"
#include "htcoffhd.h"
#include "htcoffimg.h"
#include "endianess.h"
#include "mzstruct.h"
#include "stream.h"

#include 
#include 

format_viewer_if *htcoff_ifs[] = {
	&htcoffheader_if,
	&htcoffimage_if,
	0
};

static bool is_coff(File *file, Endianess &endian, FileOfs ofs)
{
	// unfortunately COFF has no magic (urgs). so we have to guess
	// a little bit.
	COFF_HEADER h;
	bool machine_found = false;
	Endianess end;

	// FIXME: I'm not sure little/big-endian assignment for CPUs is incorrect...

	// LITTLE-ENDIAN machines
	file->seek(ofs);
	if (file->read(&h, sizeof h) != sizeof h) return false;
	createHostStruct(&h, COFF_HEADER_struct, little_endian);
	switch (h.machine) {
		case COFF_MACHINE_I386:
		case COFF_MACHINE_I486:
		case COFF_MACHINE_I586:
		case COFF_MACHINE_R3000:
		case COFF_MACHINE_R4000:
		case COFF_MACHINE_R10000:
		case COFF_MACHINE_ALPHA:
		case COFF_MACHINE_SH3:
		case COFF_MACHINE_SH4:
		case COFF_MACHINE_ARM:
		case COFF_MACHINE_POWERPC_LE:
//		case COFF_MACHINE_IA64:		// COFF64 not supported
		case COFF_MACHINE_MIPS16:
		case COFF_MACHINE_68k:
//		case COFF_MACHINE_ALPHA_AXP_64:	// COFF64 not supported
		case COFF_MACHINE_MIPSf:
		case COFF_MACHINE_MIPS16f:
			end = little_endian;
			machine_found = true;
	}

	// BIG-ENDIAN machines
	if (!machine_found) {
		file->seek(ofs);
		if (file->read(&h, sizeof h)!=sizeof h) return 0;
		createHostStruct(&h, COFF_HEADER_struct, big_endian);
		switch (h.machine) {
			case COFF_MACHINE_R3000BE:
			case COFF_MACHINE_POWERPC_BE:
				end = big_endian;
				machine_found = true;
		}
	}
	if (!machine_found) return false;
	/* test symbol_table_offset */
//	if ((h.symbol_table_offset>=size) || (h.symbol_table_offset it's a COFF (probably) */
	endian = end;
	return true;
}

static ht_view *htcoff_init(Bounds *b, File *file, ht_format_group *format_group)
{
	FileOfs h;
	Endianess end;
	/* look for pure coff */
	if (!is_coff(file, end, h = 0)) {
		/* look for dj-coff */
		byte mz[2];
		file->seek(0);
		if (file->read(mz, 2) != 2) return 0;
		if ((mz[0] != IMAGE_MZ_MAGIC0) || (mz[1] != IMAGE_MZ_MAGIC1) ||
				(!is_coff(file, end, h = 0x800)))
				return 0;
	}

	ht_coff *g = new ht_coff();
	g->init(b, file, htcoff_ifs, format_group, h, end);
	return g;
}

format_viewer_if htcoff_if = {
	htcoff_init,
	0
};

/*
 *	CLASS ht_coff
 */
void ht_coff::init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs h, Endianess end)
{
	ht_format_group::init(b, VO_BROWSABLE | VO_SELECTABLE | VO_RESIZE, DESC_COFF, file, false, true, 0, format_group);
	VIEW_DEBUG_NAME("ht_coff");

	String fn;
	LOG("%y: COFF: found header at 0x%08qx", &file->getFilename(fn), h);
	coff_shared = ht_malloc(sizeof(*coff_shared));
	coff_shared->hdr_ofs = h;
	coff_shared->sections.hdr_ofs = h;
	coff_shared->v_image = NULL;
	coff_shared->v_header = NULL;
	coff_shared->endian = end;

	/* headers */
	file->seek(h);
	file->readx(&coff_shared->coffheader, sizeof coff_shared->coffheader);
	createHostStruct(&coff_shared->coffheader, COFF_HEADER_struct, end);
	coff_shared->opt_magic = 0;
	if (coff_shared->coffheader.optional_header_size >= 2) {
		file->readx(&coff_shared->opt_magic, sizeof coff_shared->opt_magic);
		file->seek(h + sizeof coff_shared->coffheader);
		coff_shared->opt_magic = createHostInt(&coff_shared->opt_magic, 2, end);
		switch (coff_shared->opt_magic) {
			case COFF_OPTMAGIC_COFF32:
				file->readx(&coff_shared->coff32header, sizeof coff_shared->coff32header);
				createHostStruct(&coff_shared->coff32header, COFF_OPTIONAL_HEADER32_struct, end);
				break;
		}
	}

	/* read section headers */
	int os = coff_shared->coffheader.optional_header_size;
	coff_shared->sections.section_count = coff_shared->coffheader.section_count;

	h -= 4;

	file->seek(h+os+24);
	if (coff_shared->sections.section_count) {
		coff_shared->sections.sections = ht_malloc(coff_shared->sections.section_count * sizeof *coff_shared->sections.sections);
		file->read(coff_shared->sections.sections, coff_shared->sections.section_count*sizeof *coff_shared->sections.sections);
		for (uint i=0; isections.section_count; i++) {
			createHostStruct(&coff_shared->sections.sections[i], COFF_SECTION_HEADER_struct, end);
		}
	} /* CHECK - sufficient */
	shared_data = coff_shared;

	ht_format_group::init_ifs(ifs);
}

void ht_coff::done()
{
	ht_format_group::done();
	free(shared_data);
}

/*
 *	rva conversion routines
 */

bool coff_rva_to_section(coff_section_headers *section_headers, RVA rva, int *section)
{
	COFF_SECTION_HEADER *s=section_headers->sections;
	for (uint i=0; isection_count; i++) {
		if ((rva >= s->data_address) && (rva < s->data_address+s->data_size)) {
			*section = i;
			return true;
		}
		s++;
	}
	return false;
}

bool coff_rva_to_ofs(coff_section_headers *section_headers, RVA rva, FileOfs *ofs)
{
	COFF_SECTION_HEADER *s = section_headers->sections;
	for (uint i = 0; i < section_headers->section_count; i++) {
		if (s->data_offset && rva >= s->data_address 
		&& rva < s->data_address+s->data_size) {
			*ofs = rva-s->data_address + s->data_offset + section_headers->hdr_ofs;
			return true;
		}
		s++;
	}
	return false;
}

bool coff_rva_is_valid(coff_section_headers *section_headers, RVA rva)
{
	COFF_SECTION_HEADER *s=section_headers->sections;
	for (uint i=0; isection_count; i++) {
		if ((rva >= s->data_address) && (rva < s->data_address+s->data_size)) {
			return true;
		}
		s++;
	}
	return false;
}

bool coff_rva_is_physical(coff_section_headers *section_headers, RVA rva)
{
	COFF_SECTION_HEADER *s=section_headers->sections;
	for (uint i=0; isection_count; i++) {
		if (s->data_offset && (rva >= s->data_address) &&
		(rva < s->data_address+s->data_size)) {
			return true;
		}
		s++;
	}
	return false;
}

/*
 *	ofs conversion routines
 */

bool coff_ofs_to_rva(coff_section_headers *section_headers, uint32 ofs, RVA *rva)
{
	COFF_SECTION_HEADER *s=section_headers->sections;
	for (uint i=0; isection_count; i++) {
		if ((ofs>=s->data_offset+section_headers->hdr_ofs) &&
		(ofsdata_offset+section_headers->hdr_ofs+s->data_size)) {
			*rva=ofs-(s->data_offset+section_headers->hdr_ofs)+s->data_address;
			return true;
		}
		s++;
	}
	return false;
}

bool coff_ofs_to_section(coff_section_headers *section_headers, uint32 ofs, uint *section)
{
	COFF_SECTION_HEADER *s=section_headers->sections;
	for (uint i=0; isection_count; i++) {
		if ((ofs>=s->data_offset+section_headers->hdr_ofs) &&
		(ofsdata_offset+section_headers->hdr_ofs+s->data_size)) {
			*section=i;
			return true;
		}
		s++;
	}
	return false;
}

int coff_ofs_to_rva_and_section(coff_section_headers *section_headers, uint32 ofs, RVA *rva, uint *section)
{
	int r = coff_ofs_to_rva(section_headers, ofs, rva);
	if (r) {
		r = coff_ofs_to_section(section_headers, ofs, section);
	}
	return r;
}

bool coff_ofs_is_valid(coff_section_headers *section_headers, uint32 ofs)
{
	RVA rva;
	return coff_ofs_to_rva(section_headers, ofs, &rva);
}
ht-2.0.22/vxd.cc0000644000175000001440000000767210615341625010254 00000000000000/* 
 *	HT Editor
 *	vxd.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "vxd.h"
#include "vxdserv.h"

vxd_t *find_vxd(vxd_desc *table, int key)
{
	while (table->key!=-1) {
		if (table->key==key) return &table->vxd;
		table++;
	}
	return 0;
}

const char *find_vxd_service(vxd_service_desc *table, int key)
{
	while (table->key!=-1) {
		if (table->key==key) return table->name;
		table++;
	}
	return 0;
}

vxd_desc vxds[] = {
		{ 0x0001,	{"VMM", vxd_vmm_services} },
		{ 0x0002,	{"DEBUG",	vxd_debug_services} },
		{ 0x0003,	{"VPICD",	vxd_vpicd_services} },
		{ 0x0004,	{"VDMAD",	vxd_vdmad_services} },
		{ 0x0005,	{"VTD", vxd_vtd_services} },
		{ 0x0006,	{"V86MMGR", vxd_v86mmgr_services} },
		{ 0x0007,	{"PAGESWAP", vxd_pageswap_services} },
		{ 0x0009,	{"REBOOT", 0} },
		{ 0x000a,	{"VDD", vxd_vdd_services} },
		{ 0x000b,	{"VSD", vxd_vsd_services} },
		{ 0x000c,	{"VMD", vxd_vmd_services} },
		{ 0x000d,	{"VKD", vxd_vkd_services} },
		{ 0x000e,	{"VCD", vxd_vcd_services} },
		{ 0x000f,	{"VPD", vxd_vpd_services} },
		{ 0x0010,	{"IOS", vxd_ios_services} },
		{ 0x0011,	{"VMCPD",	vxd_vmcpd_services} },
		{ 0x0012,	{"EBIOS",	vxd_ebios_services} },
		{ 0x0014,	{"VNETBIOS", vxd_vnetbios_services} },
		{ 0x0015,	{"DOSMGR", vxd_dosmgr_services} },
		{ 0x0017,	{"SHELL",	vxd_shell_services} },
		{ 0x0018,	{"VMPOOL", vxd_vmpool_services} },
		{ 0x001a,	{"DOSNET", vxd_dosnet_services} },
		{ 0x0020,	{"INT13",	vxd_int13_services} },
		{ 0x0021,	{"PAGEFILE", vxd_pagefile_services} },
		{ 0x0026,	{"VPOWERD", vxd_vpowerd_services} },
		{ 0x0027,	{"VXDLDR", vxd_vxdldr_services} },
		{ 0x0028,	{"NDIS", vxd_ndis_services} },
		{ 0x002a,	{"VWIN32", vxd_vwin32_services} },
		{ 0x002b,	{"VCOMM",	vxd_vcomm_services} },
		{ 0x002c,	{"SPOOLER", 0}	},
		{ 0x0031,	{"NETBEUI", 0}	},
		{ 0x0032,	{"VSERVER", 0}	},
		{ 0x0033,	{"CONFIGMG", vxd_configmg_services} },
		{ 0x0034,	{"CM", vxd_cm_services} },
		{ 0x0036,	{"VFBACKUP", vxd_vfbackup_services} },
		{ 0x0037,	{"VMINI",	vxd_vmini_services} },
		{ 0x0038,	{"VCOND",	vxd_vcond_services} },
		{ 0x003d,	{"BIOS", 0} },
		{ 0x003e,	{"WSOCK",	vxd_wsock_services} },
		{ 0x0040,	{"IFSMGR", vxd_ifsmgr_services} },
		{ 0x0041,	{"VCDFSD", 0} },
		{ 0x0043,	{"PCI", vxd_pci_services}	},
		{ 0x0048,	{"PERF", vxd_perf_services} },
		{ 0x004a,	{"MTRR", vxd_mtrr_services} },
		{ 0x004b,	{"NTKERN", vxd_ntkern_services} },
		{ 0x004c,	{"ACPI", vxd_acpi_services} },
		{ 0x004e,	{"SMCLIB", vxd_smclib_services} },
		{ 0x011f,	{"VFLATD", vxd_vflatd_services} },
		{ 0x0202,	{"SIWDEBUG", 0} },
		{ 0x0449,	{"VJOYD",	vxd_vjoyd_services} },
		{ 0x044a,	{"MMDEVLDR", vxd_mmdevldr_services} },
		{ 0x0480,	{"VNETSUP", vxd_vnetsup_services} },
		{ 0x0481,	{"VREDIR", vxd_vredir_services} },
		{ 0x0483,	{"VSHARE", vxd_vshare_services} },
		{ 0x0486,	{"VFAT", 0} },
		{ 0x0487,	{"NWLINK", 0} },
		{ 0x0488,	{"VTDI", vxd_vtdi_services} },
		{ 0x0489,	{"VIP", vxd_vip_services} },
		{ 0x048a,	{"MSTCP",	vxd_mstcp_services} },
		{ 0x048b,	{"VCACHE", vxd_vcache_services} },
		{ 0x048e,	{"NWREDIR", 0}	},
		{ 0x0491,	{"FILESEC", 0}	},
		{ 0x0492,	{"NWSERVER", 0} },
		{ 0x0496,	{"NDIS2SUP", 0} },
		{ 0x0497,	{"MSODISUP", 0} },
		{ 0x0498,	{"SPLITTER", 0} },
		{ 0x0499,	{"PPPMAC", 0} },
		{ 0x049a,	{"VDHCP",	0} },
		{ 0x049d,	{"LOGGER", 0} },
		{ 0x097c,	{"PCCARD", vxd_pccard_services} },
		{ 0x7a5f,	{"SIWVID", 0} },
		{ -1 }					/* Terminator */
};


ht-2.0.22/mfile.cc0000644000175000001440000005364010636175210010541 00000000000000/*
 *	HT Editor
 *	mfile.cc
 *
 *	Copyright (C) 1999-2003 Stefan Weyergraf (stefan@weyergraf.de)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include 
#include 
#include 

// 
#include "htdebug.h"
#include "snprintf.h"
// 

#include "except.h"
#include "mfile.h"

#define OBJID_MFA MAGIC32("FAr\0")
#define OBJID_CFA MAGIC32("FAr\1")

// "min condition" value, see makeAreaModified(...)
#define MIN_COND_MFA_SIZE	(16)

// absolute maximum size of a MFA
#define MAX_MFA_SIZE		(128)

/*
 *	File area (FA)
 */
FileArea::FileArea(FileOfs Start, FileOfs Size)
{
	start = Start;
	size = Size;
}

int FileArea::compareTo(const Object *obj) const
{
	const FileArea *l, *r;
	int sign = 1;
	l = (FileArea*)obj;
	r = this;
	if (r->start < l->start) {
		const FileArea *t = l;
		l = r;
		r = t;
		sign = -sign;
	}

	if (r->start < l->start + l->size) return 0;
	return sign;
}

/*
 *	Modified file area (MFA)
 */
ModifiedFileArea::ModifiedFileArea(FileOfs start, FileOfs size)
: FileArea(start, size)
{
	buf = ht_malloc(size);
}

ModifiedFileArea::~ModifiedFileArea()
{
	free(buf);
}

ObjectID ModifiedFileArea::getObjectID() const
{
	return OBJID_MFA;
}

/*
 *	Copied file area (CFA)
 */
CopiedFileArea::CopiedFileArea(FileOfs start, FileOfs size, FileOfs Src_start)
: FileArea(start, size)
{
	src_start = Src_start;
}

ObjectID CopiedFileArea::getObjectID() const
{
	return OBJID_CFA;
}

/*
 *	File modification layer (FML)
 *
 *	FML is a FileLayer, which adds efficient in-memory file modification
 *	abilities.
 *	To achieve this, FML uses a tree containing FileArea (FA) objects, that
 *	describe the differences between the modified and the original file.
 *
 *	'mods' (tree which contains FAs) rules:
 *	(1) all FAs together must exactly cover the area [0, getSize()-1]
 *	(2) no two FAs may overlap
 *	(3) MFAs size may not be less than 1 (but not necessarily less than
 *	    MIN_COND_MFA_SIZE, as the name might suggest !)
 *	(4) MFAs size may not be greater than MAX_MFA_SIZE
 *	(5) two adjacent MFAs must have the sum of their sizes > MAX_MFA_SIZE
 *
 *	(general) minimize both the number of FAs in 'mods' and the space wasted
 *	          by each FA (ie. make MFAs at least 48 bytes in 'size',
 *	          because malloc will always alloc this many bytes for
 *	          MFA->buf (~16 bytes), the MFA itself (~16 bytes) and it's
 *	          entry in AVLTree (~16 bytes) on most architectures)
 */
FileModificator::FileModificator(File *file, bool own_file)
: FileLayer(file, own_file), mods(true)
{
	mcount = 0;
	inv_mcount = 0;
	invalidateMods();
}

void FileModificator::checkSanity()
{
	FileOfs s = 0;
	FileArea *prevx = NULL;
	foreach(FileArea, x, mods,
//		bool iscopy = dynamic_cast(x) != NULL;
		bool ismod = dynamic_cast(x) != NULL;
		// rule (1) part 1 and rule (2)
		if (x->start != s)
			throw MsgfException("mfile-sanity: area starts at 0x%qx, should be 0x%qx", x->start, s);
		// rule (3)
		if (x->size < 1)
			throw MsgfException("mfile-sanity: area at 0x%qx, has size %qd (must be >= %d)", x->start, x->size, 1);
		// rule (4)
		if (x->size > MAX_MFA_SIZE && ismod)
			throw MsgfException("mfile-sanity: area at 0x%qx, has size %qd (must be <= %d)", x->start, x->size, MAX_MFA_SIZE);
		// rule (5)
/*		if (prevx && (dynamic_cast(prevx) != NULL)
		&& ismod && (((ModifiedFileArea*)prevx)->size + 
		((ModifiedFileArea*)x)->size <= MAX_MFA_SIZE))
			throw MsgException("mfile-sanity: two adjacent MFAs with sum of sizes <= MAX_MFA_SIZE = %d", MAX_MFA_SIZE);
*/		s += x->size;
		prevx = x;
	);
	// rule (1) part 2
	if (newsize != s)
		throw MsgfException("mfile-sanity: newsize = %qx != %qx = calculated_size", &newsize, &s);
}

void FileModificator::debug()
{
	FILE *f = stderr;
	fprintf(f, "\n");
	foreach(FileArea, x, mods,
		if (dynamic_cast(x)) {
			ModifiedFileArea *m = (ModifiedFileArea *)x;
			ht_fprintf(f, "\tmodify %08qx, %qd bytes", &x->start, &x->size);
			for (uint i=0; i < x->size; i++) {
				ht_fprintf(f, " %02x", m->buf[i]);
			}
			ht_fprintf(f, " '");
			for (uint i=0; isize; i++) {
				byte c = m->buf[i];
				if ((c<32) || (c>0x80)) c = 32;
				ht_fprintf(f, "%c", c);
			}
			ht_fprintf(f, "'\n");
		} else {
			CopiedFileArea *c = (CopiedFileArea *)x;
			ht_fprintf(f, "\tcopy   %08qx, %qd bytes, orig start %08qx\n", &x->start, &x->size, &c->src_start);
		}
	);
	fprintf(f, "\n");
	fprintf(f, "sanity:\n");
	checkSanity();
}

bool FileModificator::cut1(ObjHandle h, FileOfs rstart, FileOfs size)
{
	FileArea *a = (FileArea*)mods.get(h);
	bool have_head_gap = rstart != 0;
	bool have_tail_gap = a->size > rstart+size;
	if (!have_head_gap && !have_tail_gap) {
		mods -= h;
		return true;
	}
	if (a->getObjectID() == OBJID_CFA) {
		CopiedFileArea *c = (CopiedFileArea*)a;
		if (have_head_gap) {
			FileOfs csize = c->size;
			c->size = rstart;
			if (have_tail_gap) {
				mods += new CopiedFileArea(c->start + rstart, csize - rstart - size, c->src_start +rstart+size);
			}
		} else {
			c->size -= size;
			c->src_start += size;
		}
	} else {
		assert(a->getObjectID() == OBJID_MFA);
		ModifiedFileArea *m = (ModifiedFileArea*)a;
		memmove(m->buf + rstart, m->buf + rstart+size, m->size-rstart-size);
		m->size -= size;
		m->buf = (byte*)realloc(m->buf, m->size);
/*		if (have_head_gap) {
			byte *newbuf = ht_malloc(m->size);
			memcpy(newbuf, m->buf, rstart);
			memcpy(newbuf+rstart, m->buf+rstart+size, m->size-rstart);
			free(m->buf);
			m->buf = newbuf;
		} else {
			memmove(m->buf, m->buf + size, m->size);
			m->buf = (byte*)realloc(m->buf, m->size);
		}
*/
	}
	return false;
}

/*
 *	NOTE 1 (aka changing keys of already-inserted Tree-elements, see below)
 *	======
 *	this is bad code because we change the key
 *	of an already-inserted Tree-element, but here it is both
 *	fast and functional...
 */
#define STREAM_COPYBUF_SIZE	(64*1024)
FileOfs FileModificator::copyAllTo(Stream *stream)
{
	byte *buf = new byte[STREAM_COPYBUF_SIZE];
	FileOfs result = 0;
	uint r, t;
	do {
		uint k = STREAM_COPYBUF_SIZE;
		r = read(buf, k);
		assert(r <= k);
		t = stream->write(buf, r);
		assert(t <= r);
		result += t;
		if (t != k) break;
	} while (t);
	delete[] buf;
	return result;
}

FileOfs FileModificator::copyTo(Stream *stream, FileOfs count)
{
	byte *buf = new byte[STREAM_COPYBUF_SIZE];
	FileOfs result = 0;
	while (count) {
		FileOfs k = STREAM_COPYBUF_SIZE;
		if (k > count) k = count;
		uint r = read(buf, k);
		assert(r <= k);
		uint t = stream->write(buf, r);
		assert(t <= r);
		count -= t;
		result += t;
		if (t != k) break;
	}
	delete[] buf;
	return result;
}

void FileModificator::cut(FileOfs size)
{
	if (!(getAccessMode() & IOAM_WRITE)) throw IOException(EACCES);

	FileOfs o = tell();
	if (o + size > newsize) throw IOException(EINVAL);
	ObjHandle h = findArea(o);
	FileOfs ssize = size;

//	int i = 1;
	while (size) {
//		printf("it %d\n", i++);
		assert(h != invObjHandle)
		FileArea *a = (FileArea*)mods.get(h);
		FileOfs s = o - a->start;
		FileOfs z = a->size - s;
		if (z > size) z = size;
		ObjHandle hnext = mods.findNext(h);
		bool deleted = cut1(h, s, z);

		if (!deleted && o == a->start)
			a->start -= ssize-size;// see NOTE 1 above
		o += z;
		size -= z;
		newsize -= z;
		if (deleted) {
			h = findArea(o);
		} else {
			h = hnext;
		}			
	}
	while (h != invObjHandle) {
		FileArea *a = (FileArea*)mods.get(h);
		h = mods.findNext(h);
		a->start -= ssize;	// see NOTE 1 above
	}
	mcount++;
}

void FileModificator::extend(FileOfs Newsize)
{
	if (Newsize == newsize) return;
	if (Newsize < newsize) throw IOException(EINVAL);
	if (!(getAccessMode() & IOAM_WRITE)) throw IOException(EACCES);

	seek(0);
	// find last area
	ObjHandle h = (newsize!=0) ? findArea(newsize-1) : invObjHandle;
	FileOfs c = Newsize-newsize;
	if (h != invObjHandle) {
		FileArea *a = (FileArea*)mods.get(h);
		ModifiedFileArea *m = dynamic_cast(a);
		if (m) {
			// if its a modification, merge with the following modifications
			if (m->size < MAX_MFA_SIZE) {
				FileOfs s = m->size + c;
				if (s > MAX_MFA_SIZE) s = MAX_MFA_SIZE;
				m->buf = (byte*)realloc(m->buf, s);
				FileOfs d = s - m->size;
				memset(m->buf+m->size, 0, d);
				newsize += d;
				c -= d;
				m->size = s;
			}
		}
	}
	while (c != 0) {
		FileOfs s = c;
		if (s > MAX_MFA_SIZE) s = MAX_MFA_SIZE;
		ModifiedFileArea *a = new ModifiedFileArea(newsize, s);
		memset(a->buf, 0, s);
		mods += a;
		newsize += s;
		c -= s;
	}
	mcount++;
}

ObjHandle FileModificator::findArea(FileOfs o)
{
	ObjHandle h;
//	if (o != 0) {
		FileArea a(o, 1);
		h = mods.find(&a);
/*	} else {
		h = mods.findFirst();
	}*/
	return h;
}

String &FileModificator::getDesc(String &result) const
{
	mFile->getDesc(result);
	if (isModified()) result.prepend("in-memory modified ");
	return result;
}

FileOfs FileModificator::getSize() const
{
	return newsize;
}

void FileModificator::insert(const void *buf, FileOfs size)
{
	if (!(getAccessMode() & IOAM_WRITE)) throw IOException(EACCES);

	ObjHandle h;

	if (!size) return;
	FileOfs ssize = size;
	// (1) insert/merge or append MFAs
	FileOfs t = tell();
//	ht_printf("tell %qx\n", t);
	ObjHandle h_a = findArea(t);
	FileArea *a = (FileArea*)mods.get(h_a);

	// really insert or append ?
	if (a) {
		// yes, insert.

		// relocate all FAs after 'a'
		h = mods.findLast();
		while (h != h_a) {
			FileArea *a = (FileArea*)mods.get(h);
			h = mods.findPrev(h);
			a->start += ssize;	// see NOTE 1 above
		}
		if (a->start == t) {
			a->start += ssize;
			FileOfs start = t;
			while (ssize != 0) {
				FileOfs k = MAX_MFA_SIZE;
				if (k > ssize) k = ssize;
				mods += new ModifiedFileArea(start, k);
				ssize -= k;
				start += k;
			}
		} else if (a->getObjectID() == OBJID_CFA) {
			// split CFA at offset t, and relocate high (offset) part
			CopiedFileArea *c = (CopiedFileArea*)a;
			FileOfs d = t - a->start;
			// b becomes 'high' (offset) a
			FileArea *b = new CopiedFileArea(c->start + d + ssize, c->size -d, c->src_start+d);
			// a becomes 'low' (offset) a
			a->size = d;
			mods += b;

			// create new MFAs between 'a' and 'b'
			FileOfs start = t;
			while (ssize != 0) {
				FileOfs k = MAX_MFA_SIZE;
				if (k > ssize) k = ssize;
				mods += new ModifiedFileArea(start, k);
				ssize -= k;
				start += k;
			}
		} else {
			ModifiedFileArea *m = (ModifiedFileArea*)a;
			// FIXME: should merge existing MFA with new one(s)

			// split MFA at offset t and relocate high (offset) part
			FileOfs d = t - a->start;
			ModifiedFileArea *b = new ModifiedFileArea(m->start + d + ssize, m->size -d);
			memcpy(b->buf, m->buf+d, b->size);
			m->size = d;
			m->buf = (byte*)realloc(m->buf, d);

			mods += b;

			// create new MFAs between 'a' and 'b'
			FileOfs start = t;
			while (ssize != 0) {
				FileOfs k = MAX_MFA_SIZE;
				if (k > ssize) k = ssize;
				mods += new ModifiedFileArea(start, k);
				ssize -= k;
				start += k;
			}
		}
	} else {
		// no, append.
		FileOfs start = t;
		while (ssize != 0) {
			FileOfs k = MAX_MFA_SIZE;
			if (k > ssize) k = ssize;
			mods += new ModifiedFileArea(start, k);
			ssize -= k;
			start += k;
		}
	}
	
	// (2) write data
	const byte *b = (const byte*)buf;
	FileOfs o = t;
	h = findArea(o);
	while (size && (h != invObjHandle)) {
		FileArea *a = (FileArea*)mods.get(h);
		FileOfs s = o - a->start;
		FileOfs z = a->size - s;
		if (z > size) z = size;
		if (z > a->size) z = a->size;
//		ht_printf("%qx, now write %qx\n", a->start, z);
		write1(a, s, b, z);
		o += z;
		size -= z;
		b += z;
		h = mods.findNext(h);
	}
	newsize += o-t;
	seek(o);
	mcount++;
}

void FileModificator::makeAreaModified(ObjHandle h, FileOfs rstart, FileOfs size)
{
	FileArea *a = (FileArea*)mods.get(h);
	if (a->getObjectID() == OBJID_CFA) {
		// not marked modified, do something
		CopiedFileArea *c = (CopiedFileArea*)a;
		FileOfs csrc_start = c->src_start;
		FileOfs cstart = c->start;
		FileOfs csize = c->size;
		bool have_head_gap = rstart != 0;
		bool have_tail_gap = csize > rstart+size;
		ModifiedFileArea *prev_m = (ModifiedFileArea*)mods.get(mods.findPrev(h));
//		ASSERT(!prev_m || (prev_m->getObjectID() == OBJID_MFA));
		if (prev_m && (prev_m->getObjectID() != OBJID_MFA)) prev_m = NULL;
		ModifiedFileArea *next_m = (ModifiedFileArea*)mods.get(mods.findNext(h));
		if (next_m && (next_m->getObjectID() != OBJID_MFA)) next_m = NULL;
//		ASSERT(!next_m || (next_m->getObjectID() == OBJID_MFA));
		// "min condition"
		// ===============
		// trick for FA packing: we simply make modified areas bigger
		// than they would have to be. (either at least MIN_COND_MFA_SIZE
		// big or adjacent/mergable with another MFA)
		bool min_condition = (size < MIN_COND_MFA_SIZE) && (!prev_m || have_head_gap) && (!next_m || have_tail_gap);
		FileOfs min_addsize;
		FileOfs min_ofs;
		FileOfs min_src_ofs;
		if (min_condition) {
			// if the MFA we will create would be too small, make it bigger
			// (compare gap sizes, then try to reach boundary to
			// reduce number of FAs)
			if (rstart < csize-rstart-size) {
				// head gap is smaller than tail gap
				FileOfs z = rstart;
				if (z+size > MIN_COND_MFA_SIZE) z = MIN_COND_MFA_SIZE-size;
				min_addsize = z;
				min_ofs = cstart+rstart-z;
				min_src_ofs = csrc_start+rstart-z;
				rstart -= z;
			} else {
				// tail gap is smaller than head gap
				FileOfs z = csize-rstart-size;
				if (z+size > MIN_COND_MFA_SIZE) z = MIN_COND_MFA_SIZE-size;
				min_addsize = z;
				min_ofs = cstart+rstart+size;
				min_src_ofs = csrc_start+rstart+size;
			}
			size += min_addsize;
			have_head_gap = rstart != 0;
			have_tail_gap = csize > rstart+size;
		}
		if (have_head_gap) {
			c->size = rstart;
			cstart += rstart;
			csrc_start += rstart;
			csize -= rstart;
		} else {
			mods -= h;
		}			
		if (next_m && !have_tail_gap) {
			// merge with next MFA (successor)
			FileOfs nnsize = next_m->size + size;
			if (nnsize > MAX_MFA_SIZE) nnsize = MAX_MFA_SIZE;
			mods.removeObj(next_m);
			FileOfs rnnsize = nnsize - next_m->size;
			next_m->buf = (byte*)realloc(next_m->buf, nnsize);
			next_m->start -= rnnsize;
			memmove(next_m->buf+rnnsize, next_m->buf, next_m->size);
			next_m->size = nnsize;
			mods += next_m;
			csize -= rnnsize;
			size -= rnnsize;
		}
		if (prev_m && !have_head_gap) {
			// merge with previous MFA (predecessor)
			FileOfs pnsize = prev_m->size + size;
			if (pnsize > MAX_MFA_SIZE) pnsize = MAX_MFA_SIZE;
			FileOfs rpnsize = pnsize - prev_m->size;
			prev_m->size = pnsize;
			prev_m->buf = (byte*)realloc(prev_m->buf, pnsize);
			csrc_start += rpnsize;
			cstart += rpnsize;
			csize -= rpnsize;
			size -= rpnsize;
		}
		while (size != 0) {
			FileOfs k = MAX_MFA_SIZE;
			if (k > size) k = size;
			mods += new ModifiedFileArea(cstart, k);
			size -= k;
			csize -= k;
			cstart += k;
			csrc_start += k;
		}
		if (have_tail_gap) {
			mods += new CopiedFileArea(cstart, csize, csrc_start);
		}
		if (min_condition) {
			byte *buf = ht_malloc(min_addsize);
			mFile->seek(min_src_ofs);
			mFile->readx(buf, min_addsize);
			ObjHandle ha = findArea(min_ofs);
			while (min_addsize != 0) {
				FileArea *a = (FileArea*)mods.get(ha);
				assert(dynamic_cast(a));
				FileOfs k = min_addsize;
				if (k > a->size- (min_ofs-a->start)) k = a->size- (min_ofs-a->start);
				write1(a, min_ofs - a->start, buf, k);
				min_addsize -= k;
				min_ofs += k;
				ha = mods.findNext(ha);
			}
			free(buf);
		}
	}
}

void FileModificator::read1(FileArea *a, FileOfs rstart, byte *buf, uint count)
{
	CopiedFileArea *c;
	ModifiedFileArea *m;
	if ((m = dynamic_cast(a))) {
		memcpy(buf, m->buf + rstart, count);
	} else if ((c = dynamic_cast(a))) {
		mFile->seek(c->src_start+rstart);
		mFile->read(buf, count);
	} else assert(0);
}

uint FileModificator::read(void *buf, uint size)
{
	if (!(getAccessMode() & IOAM_READ)) throw IOException(EACCES);

	FileOfs t = tell();
	if (t == 0x00000000ULL) {
		int a = 1;
	}
	FileOfs o = t;
	ObjHandle h = findArea(o);
	byte *b = (byte*)buf;

	while (size && h != invObjHandle) {
		FileArea *a = (FileArea*)mods.get(h);
		FileOfs s = o - a->start;
		FileOfs z = a->size - s;
		if (z > size) z = size;
		h = mods.findNext(h);
		read1(a, s, b, z);
		o += z;
		size -= z;
		b += z;
	}
	seek(o);
	return o - t;
}

void FileModificator::seek(FileOfs offset)
{
	if (offset > newsize) throw IOException(EINVAL);
	pos = offset;
}

FileOfs FileModificator::tell() const
{
	return pos;
}

void FileModificator::truncate(FileOfs Newsize)
{
	if (Newsize == newsize) return;
	if (Newsize > newsize) throw IOException(EINVAL);
	if (!(getAccessMode() & IOAM_WRITE)) throw IOException(EACCES);
	seek(0);
	ObjHandle h = findArea(Newsize);
	FileArea *a = (FileArea*)mods.get(h);
	if (a->start < Newsize) {
		if (a->getObjectID() == OBJID_CFA) {
			CopiedFileArea *c = (CopiedFileArea*)a;
			c->size = Newsize - a->start;
		} else {
			ModifiedFileArea *m = (ModifiedFileArea*)a;
			m->size = Newsize - a->start;
			m->buf = (byte*)realloc(m->buf, m->size);
		}
		h = mods.findNext(h);
	}
	while (h != invObjHandle) {
		ObjHandle hnext = mods.findNext(h);
		FileArea *a = (FileArea*)mods.get(hnext);
		mods -= h;
		if (!a) break;
		h = findArea(a->start);
	}
	newsize = Newsize;
	mcount++;
}

void FileModificator::flushMods()
{
	// make sure we can read and write
	int e;
	IOAccessMode old_am = mFile->getAccessMode();
	e = mFile->setAccessMode(IOAM_READ | IOAM_WRITE);
	if (e) throw IOException(e);
	// start work
	if (newsize > mFile->getSize()) mFile->extend(newsize);
	// store CFAs with start > src_start in descending order
	foreachbwd(FileArea, fa, mods,
		if (fa->getObjectID() == OBJID_CFA) {
			CopiedFileArea *cfa = (CopiedFileArea*)fa;
			if (cfa->start > cfa->src_start) {
				mFile->move(cfa->src_start, cfa->start, cfa->size);
			}
		}
	);
	// store CFAs with start < src_start in ascending order
	foreach(FileArea, fa, mods,
		if (fa->getObjectID() == OBJID_CFA) {
			CopiedFileArea *cfa = (CopiedFileArea*)fa;
			if (cfa->start < cfa->src_start) {
				mFile->move(cfa->src_start, cfa->start, cfa->size);
			}
		}
	);
	// store MFAs
	foreach(FileArea, fa, mods,
		if (fa->getObjectID() == OBJID_MFA) {
			ModifiedFileArea *mfa = (ModifiedFileArea*)fa;
			mFile->seek(mfa->start);
			mFile->writex(mfa->buf, mfa->size);
		}
	);
	//
	if (newsize < mFile->getSize()) mFile->truncate(newsize);
	// restore old access mode
	e = mFile->setAccessMode(old_am);
	if (e) throw IOException(e);
	//
	inv_mcount = mcount;
	invalidateMods();
}

void FileModificator::invalidateMods()
{
	mods.delAll();
	newsize = mFile->getSize();
	if (newsize != 0) mods += new CopiedFileArea(0, newsize, 0);
	pos = 0;
	mcount = inv_mcount;
}

bool FileModificator::isModified() const
{
	if (newsize != mFile->getSize()) return true;
	foreach(FileArea, fa, mods,
		CopiedFileArea *cfa = dynamic_cast(fa);
		if (!cfa || (cfa->start != cfa->src_start)) return true;
	);
	return false;
}

bool FileModificator::isModifiedByte(FileOfs o)
{
	ObjHandle h = findArea(o);
	FileArea *fa = (FileArea*)mods.get(h);
	if (!fa) return true;
	if (fa->getObjectID() == OBJID_MFA) {
		ModifiedFileArea *mfa = (ModifiedFileArea*)fa;
		int pg_ofs = o - fa->start;
		byte b;
		mFile->seek(o);
		mFile->readx(&b, 1);
		return mfa->buf[pg_ofs] != b;
	} else if (fa->getObjectID() == OBJID_CFA) {
		CopiedFileArea *cfa = (CopiedFileArea*)fa;
		if (cfa->src_start == cfa->start) return false;
		int pg_ofs = o - fa->start;
		byte b1, b2;
		mFile->seek(o);
		mFile->readx(&b1, 1);
		mFile->seek(cfa->src_start + pg_ofs);
		mFile->readx(&b2, 1);
		return (b1 != b2);
	}
	return false;
}

int FileModificator::vcntl(uint cmd, va_list vargs)
{
	switch (cmd) {
	case FCNTL_MODS_INVD:
		invalidateMods();
		return 0;
	case FCNTL_MODS_FLUSH:
		flushMods();
		return 0;
	case FCNTL_MODS_CLEAR_DIRTY_RANGE: {
/*
		// BEFORE-IMPLEMENT: decl changed !
		FileOfs o = va_arg(vargs, FileOfs);
		uint s = va_arg(vargs, uint);
		uint i = 0;
		while (s--) {
			cleardirtybyte(o+i);
			i++;
		}
*/
		return 0;
	}
	case FCNTL_MODS_IS_DIRTY: {
		// const FileOfs offset, const FileOfs range, bool &isdirty
		FileOfs o = va_arg(vargs, FileOfs);
		FileOfs s = va_arg(vargs, FileOfs);
		bool &b = (bool&)*va_arg(vargs, bool*);
		if (o == 0 && s == newsize) {
			b = isModified();
		} else if (s <= 16) {
			try {
				bool bb = false;
				while (s--) {
					bb |= isModifiedByte(o++);
				}
				b = bb;
			} catch (const IOException &x) {
				return EIO;
			}
		} else {
			return ENOSYS;
		}
		return 0;
	}
	case FCNTL_GET_MOD_COUNT: {	// int &mcount
		int *mc = va_arg(vargs, int *);
		*mc = mcount;
		return 0;
	}		
	}
	return mFile->vcntl(cmd, vargs);
}

void FileModificator::write1(FileArea *a, FileOfs rstart, const byte *buf, uint count)
{
	assert(a->getObjectID() == OBJID_MFA);
//	ObjectID id = a->getObjectID();
	ModifiedFileArea *m = (ModifiedFileArea*)a;
	memcpy(m->buf+rstart, buf, count);
}

uint FileModificator::write(const void *buf, uint size)
{
	if (!(getAccessMode() & IOAM_WRITE)) throw IOException(EACCES);
	// (1) make areas modified
	FileOfs t = tell();
	FileOfs o = t;
	uint osize = size;
	while (size) {
		ObjHandle h = findArea(o);
		if (h == invObjHandle) break;
		FileArea *a = (FileArea*)mods.get(h);
		FileOfs s = o - a->start;
		FileOfs z = a->size - s;
		if (z > size) z = size;
		makeAreaModified(h, s, z);
		o += z;
		size -= z;
	}
	// (2) write data
	const byte *b = (const byte*)buf;
	o = t;
	size = osize;
	ObjHandle h = findArea(o);
	while (size && (h != invObjHandle)) {
		FileArea *a = (FileArea*)mods.get(h);
		FileOfs s = o - a->start;
		FileOfs z = a->size - s;
		if (z > size) z = size;
		if (z > a->size) z = a->size;
		write1(a, s, b, z);
		o += z;
		size -= z;
		b += z;
		h = mods.findNext(h);
	}
	seek(o);
	mcount++;
	return o - t;
}
ht-2.0.22/htle.cc0000644000175000001440000004640010615341620010372 00000000000000/* 
 *	HT Editor
 *	htle.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "errno.h"
#include 

#include "endianess.h"
#include "htle.h"
#include "htlehead.h"
#include "htleimg.h"
#include "htleobj.h"
#include "htleent.h"
#include "htlepage.h"
#include "htlevxd.h"
#include "htiobox.h"
#include "htnewexe.h"
#include "lestruct.h"
#include "log.h"
#include "tools.h"

#define LE_SEG_ADDR(i) (LE_shared->objmap.header[(i)].page_map_index-1) *\
			LE_shared->hdr.pagesize + LE_BASE_ADDR

static format_viewer_if *htle_ifs[] = {
	&htleheader_if,
	&htlevxd_if,
	&htlepagemaps_if,
	&htleobjects_if,
	&htleentrypoints_if,
	&htleimage_if,
	0
};

static ht_view *htle_init(Bounds *b, File *file, ht_format_group *format_group)
{
	byte lemagic[2];
	FileOfs h=get_newexe_header_ofs(file);
	file->seek(h);
	
	if (file->read(lemagic, 2) != 2 
	 || lemagic[0] != LE_MAGIC0 || lemagic[1] != LE_MAGIC1) return 0;

	ht_le *g=new ht_le();
	g->init(b, file, htle_ifs, format_group, h);
	return g;
}

format_viewer_if htle_if = {
	htle_init,
	0
};

void ht_le::init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs h)
{
	ht_format_group::init(b, VO_BROWSABLE | VO_SELECTABLE | VO_RESIZE, DESC_LE, file, false, true, 0, format_group);
	VIEW_DEBUG_NAME("ht_le");

	String fn;
	LOG("%y: LE: found header at 0x%08qx", &file->getFilename(fn), h);
	ht_le_shared_data *le_shared = ht_malloc(sizeof (ht_le_shared_data));
	shared_data = le_shared;
	le_shared->v_header = NULL;
	le_shared->v_objects = NULL;
	le_shared->v_pagemaps = NULL;
	le_shared->v_image = NULL;
	le_shared->v_le_vxd = NULL;
	le_shared->hdr_ofs = h;
	le_shared->linear_file = NULL;
	le_shared->reloc_file = NULL;
	le_shared->best_entrypoint = LE_ADDR_INVALID;

	// FIXME: byteorder handling...
	le_shared->byteorder = little_endian;

	/* read LE header */
	file->seek(h);
	file->readx(&le_shared->hdr, sizeof le_shared->hdr);
	createHostStruct(&le_shared->hdr, LE_HEADER_struct, le_shared->byteorder);

	le_shared->is_vxd = le_shared->hdr.winresoff 
		|| le_shared->hdr.winreslen
		|| le_shared->hdr.devid
		|| le_shared->hdr.ddkver;

	read_pagemap();
	read_objects();

	ht_le_page_file *lfile = new ht_le_page_file(file, false, &le_shared->pagemap, 
		le_shared->pagemap.count, le_shared->hdr.pagesize);
	le_shared->linear_file = lfile;

	do_fixups();
	check_vxd();

	ht_format_group::init_ifs(ifs);
}

void ht_le::done()
{
	ht_format_group::done();

	ht_le_shared_data *le_shared=(ht_le_shared_data*)shared_data;
	
	free(le_shared->objmap.header);
	free(le_shared->objmap.vsize);
	free(le_shared->objmap.psize);
	
	free(le_shared->pagemap.offset);
	free(le_shared->pagemap.vsize);
	free(le_shared->pagemap.psize);

	delete le_shared->linear_file;
	delete le_shared->reloc_file;

	free(le_shared);
}

void ht_le::do_fixups()
{
	ht_le_shared_data *le_shared = (ht_le_shared_data*)shared_data;
	FileOfs h = le_shared->hdr_ofs;

	uint32 *page_fixup_ofs = ht_malloc(sizeof (uint32) * (le_shared->hdr.pagecnt+1));
	uint32 *page_fixup_size = ht_malloc(sizeof (uint32) * (le_shared->hdr.pagecnt));

	file->seek(h+le_shared->hdr.fpagetab);
	for (uint i=0; ihdr.pagecnt+1; i++) {
		char buf[4];
		file->readx(buf, 4);
		uint32 ofs = createHostInt(buf, 4, little_endian);
		page_fixup_ofs[i] = ofs;
	}

	for (uint i=0; ihdr.pagecnt; i++) {
		page_fixup_size[i] = page_fixup_ofs[i+1] - page_fixup_ofs[i];
	}

	ht_le_reloc_file *rfile = new ht_le_reloc_file(le_shared->linear_file, 
					false, le_shared);

	le_shared->reloc_file = rfile;

	uint error_count = 0;

	for (uint i=0; i < le_shared->hdr.pagecnt; i++) {
		// size of fixup record table for segment
		uint32 size = page_fixup_size[i];
		uint obj_ofs = i * le_shared->hdr.pagesize;

		file->seek(h+le_shared->hdr.frectab+page_fixup_ofs[i]);
		bool error = false;
		while (size>0 && !error) {
			// addr_type + reloc_type
			LE_FIXUP f;
			if (sizeof f > size) { error = true; break; }
			size -= sizeof f;
			file->readx(&f, sizeof f);
			createHostStruct(&f, LE_FIXUP_struct, le_shared->byteorder);
			/* only internal references (16/32) supported for now... */
			if ((f.reloc_type != 0) && (f.reloc_type != 16)) {
				error = true;
				break;
			}

			// is address_type supported ?
			switch (f.address_type & LE_FIXUP_ADDR_TYPE_MASK) {
				case LE_FIXUP_ADDR_TYPE_0_8:
				case LE_FIXUP_ADDR_TYPE_16_0:
				case LE_FIXUP_ADDR_TYPE_16_16:
				case LE_FIXUP_ADDR_TYPE_0_16:
				case LE_FIXUP_ADDR_TYPE_16_32:
				case LE_FIXUP_ADDR_TYPE_0_32:
				case LE_FIXUP_ADDR_TYPE_REL32:
					break;
				default:
					error = true;
					break;
			}
			if (error) break;

			uint multi_count = 0;
			uint16 src_ofs;
			bool multi_ofs = (f.address_type & LE_FIXUP_ADDR_MULTIPLE);
			if (multi_ofs) {
				// number of entries in offset table
				char buf[1];
				if (sizeof buf > size) { error = true; break; }
				size -= sizeof buf;
				file->readx(buf, sizeof buf);
				multi_count = createHostInt(buf, 1, little_endian);
			} else {
				// single source offset
				char buf[2];
				if (sizeof buf > size) { error = true; break; }
				size -= sizeof buf;
				file->readx(buf, sizeof buf);
				src_ofs = createHostInt(buf, 2, little_endian);
			}

			switch (f.reloc_type & LE_FIXUP_RELOC_TYPE_MASK) {
				case LE_FIXUP_RELOC_TYPE_INTERNAL:
					uint16 target_seg;
					uint32 target_ofs;
					if (f.reloc_type & LE_FIXUP_RELOC_TARGET32) {
						LE_FIXUP_INTERNAL32 x;
						if (sizeof x > size) { error = true; break; }
						size -= sizeof x;
						file->readx(&x, sizeof x);
						createHostStruct(&x, LE_FIXUP_INTERNAL32_struct, le_shared->byteorder);
						target_seg = x.seg-1;
						target_ofs = x.ofs;
					} else {
						LE_FIXUP_INTERNAL16 x;
						if (sizeof x > size) { error = true; break; }
						size -= sizeof x;
						file->readx(&x, sizeof x);
						createHostStruct(&x, LE_FIXUP_INTERNAL16_struct, le_shared->byteorder);
						target_seg = x.seg-1;
						target_ofs = x.ofs;
					}

					if (multi_ofs) {
						for (uint j=0; j size) { error = true; break; }
							size -= sizeof buf;
							file->readx(buf, sizeof buf);
							src_ofs = createHostInt(buf, sizeof buf, little_endian);
							rfile->insert_reloc(obj_ofs + src_ofs, new ht_le_reloc_entry(obj_ofs + src_ofs, target_seg, LE_MAKE_ADDR(le_shared, target_seg, target_ofs), f.address_type, f.reloc_type));
						}
					} else {
						rfile->insert_reloc(obj_ofs + src_ofs, new ht_le_reloc_entry(obj_ofs + src_ofs, target_seg, LE_MAKE_ADDR(le_shared, target_seg, target_ofs), f.address_type, f.reloc_type));
					}
					break;
				case LE_FIXUP_RELOC_TYPE_IMPORT_ORD:
					error = true;
					break;
				case LE_FIXUP_RELOC_TYPE_IMPORT_NAME:
					error = true;
					break;
				case LE_FIXUP_RELOC_TYPE_OSFIXUP:
					error = true;
					break;
			}
		}
		if (error) error_count++;
	}

	free(page_fixup_ofs);
	free(page_fixup_size);

	if (error_count) {
		String fn;
		// FIXME: once complete:
		// "%s: NE relocations seem to be corrupted.", file->get_filename());
		LOG_EX(LOG_WARN, "%y: LE: invalid and/or unsupported relocations found.", &file->getFilename(fn));
		errorbox("%y: LE: invalid and/or unsupported relocations found.", &fn);
	} else {
		String fn;
		LOG("%y: LE: relocations present, relocation simulation layer enabled", &file->getFilename(fn));
	}
	rfile->finalize();
}

void ht_le::check_vxd()
{
	ht_le_shared_data *le_shared = (ht_le_shared_data*)shared_data;
	FileOfs h = le_shared->hdr_ofs;

	/* VxD */
	if (le_shared->is_vxd) {
		/* test if really VxD and find VxD descriptor */
		LE_ENTRYPOINT_BUNDLE b;
		file->seek(h+le_shared->hdr.enttab);
		file->readx(&b, sizeof b);
		le_shared->is_vxd = false;
		if ((b.entry_count == 1) && (b.flags & LE_ENTRYPOINT_BUNDLE_VALID) &&
		(b.flags & LE_ENTRYPOINT_BUNDLE_32BIT) && (b.obj_index == 1)) {
			LE_ENTRYPOINT32 e;
			file->readx(&e, sizeof e);
			createHostStruct(&e, LE_ENTRYPOINT32_struct, le_shared->byteorder);
			if (e.flags & LE_ENTRYPOINT_EXPORTED) {
				/* linearized address for ht_le_page_file */
				uint32 vxd_desc_ofs = (le_shared->objmap.header[0].
					page_map_index-1)*le_shared->hdr.pagesize + e.offset;

				le_shared->reloc_file->seek(vxd_desc_ofs);
				le_shared->reloc_file->readx(&le_shared->vxd_desc, sizeof le_shared->vxd_desc);
				createHostStruct(&le_shared->vxd_desc, LE_VXD_DESCRIPTOR_struct, le_shared->byteorder);

				le_shared->vxd_desc_linear_ofs = vxd_desc_ofs;
				le_shared->is_vxd = true;
			}
		}
	}
}

void ht_le::read_pagemap()
{
	ht_le_shared_data *le_shared = (ht_le_shared_data*)shared_data;
	FileOfs h = le_shared->hdr_ofs;

	le_shared->pagemap.count=le_shared->hdr.pagecnt;
	le_shared->pagemap.offset = ht_malloc(le_shared->pagemap.count*sizeof *le_shared->pagemap.offset);
	le_shared->pagemap.psize = ht_malloc(le_shared->pagemap.count*sizeof *le_shared->pagemap.psize);
	le_shared->pagemap.vsize = ht_malloc(le_shared->pagemap.count*sizeof *le_shared->pagemap.vsize);

	uint32 last_page_offset=0, last_page=0;
	for (uint32 i=0; ihdr.pagecnt; i++) {
		LE_PAGE_MAP_ENTRY e;
		file->seek(h+le_shared->hdr.pagemap+i*4);
		file->readx(&e, sizeof e);
		createHostStruct(&e, LE_PAGE_MAP_ENTRY_struct, le_shared->byteorder);
		
		/* FIXME: is this formula correct ? it comes straight from my docs... */
		uint32 eofs=(e.high+e.low-1)*le_shared->hdr.pagesize+le_shared->hdr.datapage;
		le_shared->pagemap.offset[i] = eofs;

		if (le_shared->pagemap.offset[i]>last_page_offset) {
			last_page_offset = le_shared->pagemap.offset[i];
			last_page = i;
		}
	}

	for (uint32 i=0; ihdr.pagecnt; i++) {
		le_shared->pagemap.vsize[i]=0;	/* filled by read_objects() */
		if (i==last_page)
			le_shared->pagemap.psize[i]=le_shared->hdr.lastpagesize;
		else
			le_shared->pagemap.psize[i]=le_shared->hdr.pagesize;
	}
}

void ht_le::read_objects()
{
	ht_le_shared_data *le_shared = (ht_le_shared_data*)shared_data;
	FileOfs h = le_shared->hdr_ofs;

	le_shared->objmap.count = le_shared->hdr.objcnt;
	le_shared->objmap.header = ht_malloc(le_shared->objmap.count*sizeof *le_shared->objmap.header);
	le_shared->objmap.vsize = ht_malloc(le_shared->objmap.count * sizeof *le_shared->objmap.vsize);
	le_shared->objmap.psize = ht_malloc(le_shared->objmap.count * sizeof *le_shared->objmap.psize);

	for (uint i=0; ihdr.objcnt; i++) {
		file->seek(h+le_shared->hdr.objtab+i*24);
		file->readx(&le_shared->objmap.header[i], sizeof *le_shared->objmap.header);
		createHostStruct(&le_shared->objmap.header[i], LE_OBJECT_HEADER_struct, le_shared->byteorder);

		/* sum up page sizes to find object's physical size */
		uint psize = 0;
		for (uint j=0; jobjmap.header[i].page_map_count; j++) {
			psize += le_shared->pagemap.psize[j+le_shared->objmap.header[i].page_map_index-1];
			/* FIXME: security hole: array-index uncontrolled */
			if (j == le_shared->objmap.header[i].page_map_count-1)
				le_shared->pagemap.vsize[j+le_shared->objmap.header[i].page_map_index-1]=le_shared->objmap.header[i].vsize % le_shared->hdr.pagesize;
			else
				le_shared->pagemap.vsize[j+le_shared->objmap.header[i].page_map_index-1]=le_shared->hdr.pagesize;
		}
// FIXME: alternative which one is right ???
#if 1
		le_shared->objmap.psize[i] = MIN(psize, le_shared->objmap.header[i].vsize);
		le_shared->objmap.vsize[i] = MIN(psize, le_shared->objmap.header[i].vsize);
#else
		le_shared->objmap.psize[i] = le_shared->objmap.header[i].vsize;
		le_shared->objmap.vsize[i] = le_shared->objmap.header[i].vsize;
#endif
	}

/* create temporary address space for LEAddress's */
/*	le_shared->le_addr = ht_malloc(sizeof *le_shared->le_addr * le_shared->objmap.count);
	uint a = 0;
	for (uint i = 0; iobjmap.count; i++) {
		le_shared->le_addr[i] = a;
		a += le_shared->objmap.header[i].page_map_count * le_shared->hdr.pagesize;
	}*/
}

void ht_le::loc_enum_start()
{
//	loc_enum=true;
}

bool ht_le::loc_enum_next(ht_format_loc *loc)
{
#if 0
	ht_le_shared_data *sh=(ht_le_shared_data*)shared_data;
	if (loc_enum) {
		loc->name="le";
		loc->start=sh->hdr_ofs;
		loc->length=file->get_size()-loc->start;	/* FIXME: ENOTOK */
		
		loc_enum=false;
		return true;
	}
#endif	
	return false;
}

/*
 *	CLASS ht_le_page_file
 */

ht_le_page_file::ht_le_page_file(File *file, bool own_file, ht_le_pagemap *pm, uint32 pms, uint32 ps)
	: FileLayer(file, own_file)
{
	pagemap = pm;
	pagemapsize = pms;
	page_size = ps;
	ofs = 0;
}

bool ht_le_page_file::isdirty(FileOfs offset, FileOfs range)
{
	FileOfs mofs;
	FileOfs msize;
	while (range) {
		FileOfs s = range;
		if (!map_ofs(offset, &mofs, &msize)) break;
		if (s > msize) s = msize;
		bool isdirty;
		mFile->cntl(FCNTL_MODS_IS_DIRTY, mofs, s, &isdirty);
		if (isdirty) return true;
		range -= s;
		ofs += s;
	}
	return false;
}

/**
 *	Map a paged and linearized LE offset to its corresponding
 *	physical file offset
 */
bool ht_le_page_file::map_ofs(uint32 lofs, FileOfs *pofs, FileOfs *maxsize)
{
	uint i = lofs / page_size, j = lofs % page_size;
	if (i < pagemapsize) {
		if (j < pagemap->vsize[i]) {
			*pofs = pagemap->offset[i]+j;
			*maxsize = pagemap->vsize[i]-j;
			return true;
		}
	}
	return false;
}

bool ht_le_page_file::unmap_ofs(FileOfs pofs, uint32 *lofs)
{
	for (uint i=0; i= pagemap->offset[i]) && (pofs < pagemap->offset[i]+pagemap->vsize[i])) {
			*lofs = pofs - pagemap->offset[i] + i*page_size;
			return true;
		}
	}
	return false;
}

uint ht_le_page_file::read(void *aBuf, uint size)
{
	FileOfs mofs;
	FileOfs msize;
	int c = 0;
	byte *buf = (byte *)aBuf;
	while (size) {
		uint s = size;
		if (!map_ofs(ofs, &mofs, &msize)) break;
		if (s > msize) s = msize;
		mFile->seek(mofs);
		s = mFile->read(buf, s);
		if (!s) break;
		buf += s;
		size -= s;
		c += s;
		ofs += s;
	}
	return c;
}

void ht_le_page_file::seek(FileOfs offset)
{
	ofs = offset;
}

FileOfs ht_le_page_file::tell() const
{
	return ofs;
}

int ht_le_page_file::vcntl(uint cmd, va_list vargs)
{
	switch (cmd) {
		case FCNTL_MODS_CLEAR_DIRTY_RANGE: {
			FileOfs o = va_arg(vargs, FileOfs);
			FileOfs s = va_arg(vargs, FileOfs);
			FileOfs ts, ms;
			int e;

			do {
				if (!map_ofs(o, &o, &ms)) return EINVAL;
				ts = (s < ms) ? s : ms;
				e = FileLayer::cntl(cmd, o, ts);
				if (e) return e;
				s -= ts;
			} while (s);
			return 0;
		}
		case FCNTL_MODS_IS_DIRTY: {
			FileOfs o = va_arg(vargs, FileOfs);
			FileOfs s = va_arg(vargs, FileOfs);
			bool *b = va_arg(vargs, bool*);
			FileOfs ts, ms;
			int e;

			*b = false;
			do {
				if (!map_ofs(o, &o, &ms)) return EINVAL;
				ts = (s < ms) ? s : ms;
				e = mFile->cntl(cmd, o, ts, b);
				if (e) return e;
				if (*b) break;
				s -= ts;
			} while (s);
			return 0;
		}
	}
	return FileLayer::vcntl(cmd, vargs);
}

uint ht_le_page_file::write(const void *aBuf, uint size)
{
	FileOfs mofs;
	FileOfs msize;
	int c = 0;
	const byte *buf = (const byte *)aBuf;
	while (size) {
		uint s = size;
		if (!map_ofs(ofs, &mofs, &msize)) break;
		if (s>msize) s = msize;
		mFile->seek(mofs);
		buf += mFile->write(buf, s);
		size -= s;
		c += s;
		ofs += s;
	}
	return c;
}

/*
 *	CLASS ht_le_reloc_entry
 */

ht_le_reloc_entry::ht_le_reloc_entry(uint o, uint s, LEAddress a, uint8 at, uint8 rt)
{
	ofs = o;
	seg = s;
	addr = a;
	address_type = at;
	reloc_type = rt;
}

/*
 *	CLASS ht_le_reloc_file
 */

ht_le_reloc_file::ht_le_reloc_file(File *s, bool os, ht_le_shared_data *d)
	: ht_reloc_file(s, os)
{
	data = d;
}

void ht_le_reloc_file::reloc_apply(Object *reloc, byte *data)
{
	ht_le_reloc_entry *e = (ht_le_reloc_entry*)reloc;

	switch (e->address_type & LE_FIXUP_ADDR_TYPE_MASK) {
		case LE_FIXUP_ADDR_TYPE_0_8:
			createForeignInt(data, e->addr, 1, little_endian);
			break;
		case LE_FIXUP_ADDR_TYPE_16_0:
			createForeignInt(data, e->seg, 2, little_endian);
			break;
		case LE_FIXUP_ADDR_TYPE_16_16:
			createForeignInt(data, e->addr, 2, little_endian);
			createForeignInt(data, e->seg, 2, little_endian);
			break;
		case LE_FIXUP_ADDR_TYPE_0_16:
			createForeignInt(data, e->addr, 2, little_endian);
			break;
		case LE_FIXUP_ADDR_TYPE_16_32:
			createForeignInt(data, e->addr, 4, little_endian);
			createForeignInt(data, e->seg, 2, little_endian);
			break;
		case LE_FIXUP_ADDR_TYPE_0_32:
			createForeignInt(data, e->addr, 4, little_endian);
			break;
		case LE_FIXUP_ADDR_TYPE_REL32:
			createForeignInt(data, e->addr - LE_BASE_ADDR - e->ofs - 4, 4, little_endian);
			break;
	}
}

bool ht_le_reloc_file::reloc_unapply(Object *reloc, byte *data)
{
	return false;
}

/*
 *
 */

FileOfs LE_get_seg_ofs(ht_le_shared_data *LE_shared, uint i)
{
	assert(iobjmap.count);
	return LE_SEG_ADDR(i) - LE_BASE_ADDR;
}

LEAddress LE_get_seg_addr(ht_le_shared_data *LE_shared, uint i)
{
	assert(iobjmap.count);
	return LE_SEG_ADDR(i);
}

uint LE_get_seg_psize(ht_le_shared_data *LE_shared, uint i)
{
	assert(iobjmap.count);
	return LE_shared->objmap.psize[i];
}

uint LE_get_seg_vsize(ht_le_shared_data *LE_shared, uint i)
{
	assert(iobjmap.count);
	return LE_shared->objmap.vsize[i];
}

bool LE_addr_to_segment(ht_le_shared_data *LE_shared, LEAddress Addr, int *segment)
{
	for (uint i = 0; i < LE_shared->objmap.count; i++) {
		LEAddress base = LE_get_seg_addr(LE_shared, i);
		uint evsize = MAX(LE_get_seg_vsize(LE_shared, i), LE_get_seg_psize(LE_shared, i));
		if ((Addr >= base) && (Addr < base + evsize)) {
			*segment = i;
			return true;
		}
	}
	return false;
}

bool LE_addr_is_physical(ht_le_shared_data *LE_shared, LEAddress Addr)
{
	for (uint i = 0; i < LE_shared->objmap.count; i++) {
		LEAddress base = LE_get_seg_addr(LE_shared, i);
		uint psize = LE_get_seg_psize(LE_shared, i);
		if ((Addr >= base) && (Addr < base + psize)) return true;
	}
	return false;
}

bool LE_addr_to_ofs(ht_le_shared_data *LE_shared, LEAddress Addr, FileOfs *ofs)
{
	for (uint i = 0; i < LE_shared->objmap.count; i++) {
		LEAddress base = LE_get_seg_addr(LE_shared, i);
		uint psize = LE_get_seg_psize(LE_shared, i);
		if ((Addr >= base) && (Addr < base + psize)) {
			*ofs = Addr - LE_BASE_ADDR;
			return true;
		}
	}
	return false;
}

bool LE_ofs_to_addr(ht_le_shared_data *LE_shared, FileOfs ofs, LEAddress *Addr)
{
	for (uint i = 0; i < LE_shared->objmap.count; i++) {
		FileOfs sofs = LE_get_seg_ofs(LE_shared, i);
		if ((ofs >= sofs) && (ofs < sofs + LE_get_seg_psize(LE_shared, i))) {
			*Addr = LE_BASE_ADDR + ofs;
			return true;
		}
	}
	return false;
}

LEAddress LE_MAKE_ADDR(ht_le_shared_data *LE_shared, uint16 seg, uint32 ofs)
{
	return LE_SEG_ADDR(seg) + ofs;
}

uint16 LE_ADDR_SEG(ht_le_shared_data *LE_shared, LEAddress a)
{
	for (uint i = 0; iobjmap.count; i++) {
		LEAddress addr = LE_SEG_ADDR(i);
		if ((a >= addr) && (a < addr + LE_shared->objmap.vsize[i])) {
			return i;
		}
	}
	return 0xffff;
}

uint32 LE_ADDR_OFS(ht_le_shared_data *LE_shared, LEAddress a)
{
	for (uint i = 0; iobjmap.count; i++) {
		LEAddress addr = LE_SEG_ADDR(i);
		if ((a >= addr) && (a < addr + LE_shared->objmap.vsize[i])) {
			return a-addr;
		}
	}
	return 0;
}

ht-2.0.22/ilstruct.h0000644000175000001440000000303510615341624011152 00000000000000/* 
 *	HT Editor
 *	ilstruct.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __ILSTRUCT_H_
#define __ILSTRUCT_H_

#include "io/types.h"

#define IL_MAGIC0_0	'B'
#define IL_MAGIC0_1	'S'
#define IL_MAGIC0_2	'J'
#define IL_MAGIC0_3	'B'

#define IL_MAGIC1_0	'C'
#define IL_MAGIC1_1	'O'
#define IL_MAGIC1_2	'M'
#define IL_MAGIC1_3	'+'

struct IL_METADATA_SECTION {
	uint32 magic PACKED;
	uint16 major_version PACKED;
	uint16 minor_version PACKED;
	// if (minor_version==1) {
	//    uint32 unkown PACKED;
	//    uint32 version_string_length PACKED;	
	//    char version_string[align(version_string_length, 4)];
	// }
	// byte zero1, zero2; 
	// uint16 number_of_entries; 
};

struct IL_METADATA_SECTION_ENTRY {
	uint32 offset PACKED;
	uint32 size PACKED;
	//char name[]; // zero_terminated
	// align(4)
	// uint32 ref ?;
};

extern byte IL_METADATA_SECTION_struct[];
extern byte IL_METADATA_SECTION_ENTRY_struct[];
#endif
ht-2.0.22/htxexhead.cc0000755000175000001440000003703510615345251011433 00000000000000/*
 *	HT Editor
 *	htxexhead.cc
 *
 *	Copyright (C) 2006 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include 

#include "formats.h"
#include "htapp.h"
#include "atom.h"
#include "htcoff.h"
#include "htctrl.h"
#include "endianess.h"
#include "hthex.h"
#include "htiobox.h"
#include "htnewexe.h"
#include "htxex.h"
#include "htxexhead.h"
#include "httag.h"
#include "strtools.h"
#include "snprintf.h"

#include "xexstruct.h"

static ht_tag_flags_s xbe_init_flags[] =
{
	{-1, "XBE - initialisation flags"},
	{0,  "[00] Mount Utility Drive"},
	{1,  "[01] Format Utility Drive"},
	{2,  "[02] Limit to 64MB"},
	{3,  "[03] Dont setup harddisk"},
	{0, 0}
};

static ht_mask_ptable xeximageheader[] = {
	{"magic",			STATICTAG_EDIT_CHAR("00000000")STATICTAG_EDIT_CHAR("00000001")STATICTAG_EDIT_CHAR("00000002")STATICTAG_EDIT_CHAR("00000003")},
	{"version",			STATICTAG_EDIT_DWORD_BE("00000004")},
	{"size of header",		STATICTAG_EDIT_DWORD_BE("00000008")},
	{"res",				STATICTAG_EDIT_DWORD_BE("0000000c")},
	{"offset of file header",	STATICTAG_EDIT_DWORD_BE("00000010")" "STATICTAG_REF("0000000100000000", "03", "raw")},
	{"info table entries",		STATICTAG_EDIT_DWORD_BE("00000014")},
	{0, 0}
};

/*
#define XEX_MEDIA_HD		0x00000001
#define XEX_MEDIA_DVD_X2	0x00000002
#define XEX_MEDIA_DVD_CD	0x00000004
#define XEX_MEDIA_DVD_5		0x00000008
#define XEX_MEDIA_DVD_9		0x00000010
#define XEX_MEDIA_FLASH		0x00000020
#define XEX_MEDIA_MEMORY_UNIT	0x00000080
#define XEX_MEDIA_MASS_STORAGE	0x00000100
#define XEX_MEDIA_SMB		0x00000200
#define XEX_MEDIA_RAM		0x00000400
#define XEX_MEDIA_INSECURE	0x01000000
#define XEX_MEDIA_SAVE_GAME	0x02000000
#define XEX_MEDIA_LOCAL		0x04000000
#define XEX_MEDIA_LIVE		0x08000000
#define XEX_MEDIA_XBOX		0x10000000
M    { 0x00000001, "hard disk"              },
    { 0x00000002, "DVD-X2"                 },
    { 0x00000004, "DVD/CD"                 },
    { 0x00000008, "DVD-5"                  },
    { 0x00000010, "DVD-9"                  },
    { 0x00000020, "system flash"           },
    { 0x00000080, "memory unit"            },
    { 0x00000100, "mass storage device"    },
    { 0x00000200, "SMB filesystem"         },
    { 0x00000400, "direct-from-RAM"        },
    { 0x01000000, "insecure package"       },
    { 0x02000000, "save game package"      },
    { 0x04000000, "locally signed package" },
    { 0x08000000, "Live-signed package"    },
    { 0x10000000, "Xbox platform package"  }

*/

static ht_tag_flags_s xex_media_flags[] =
{
	{-1, "XEX - media type mask"},
	{ 24, "[00] hard disk"              },
	{ 25, "[01] DVD-X2"                 },
	{ 26, "[02] DVD/CD"                 },
	{ 27, "[03] DVD-5"                  },
	{ 28, "[04] DVD-9"                  },
	{ 29, "[05] system flash"           },
	{ 30, "[06] memory unit"            },
	{ 31, "[07] mass storage device"    },
	{ 16, "[08] SMB filesystem"         },
	{ 17, "[09] direct-from-RAM"        },
	{  0, "[24] insecure package"       },
	{  1, "[25] save game package"      },
	{  2, "[26] locally signed package" },
	{  3, "[27] Live-signed package"    },
	{  4, "[28] Xbox platform package"  }
};

#define ATOM_XEX_INFO_CLASS_MAGICS 0x58455801
#define ATOM_XEX_INFO_CLASS_MAGICS_STR "58455801"

#define ATOM_XEX_MEDIA_FLAGS			0x58455802
#define ATOM_XEX_MEDIA_FLAGS_STR		 "58455802"

static ht_mask_sub *prep_sub(File *file, const char *desc, uint32 type, int i, ht_collapsable_sub **cs)
{
	char title[100];
	ht_snprintf(title, sizeof title, "%-22s  [0x%08x]", desc, type);
	ht_mask_sub *s = new ht_mask_sub();
	s->init(file, i+4);
	*cs = new ht_collapsable_sub();
	(*cs)->init(file, s, true, title, true);
	return s;
}

static ht_sub *add_resmap(File *file, const char *desc, ht_xex_shared_data &xex_shared, int i, FileOfs ofs)
{
	ht_collapsable_sub *cs;
	ht_mask_sub *s = prep_sub(file, desc, xex_shared.info_table_cooked[i].type, i, &cs);

	char b[200];
	char b2[200];
	ht_snprintf(b2, sizeof b2, STATICTAG_REF("00000000%08x", "08", "show raw"), i);
	ht_snprintf(b, sizeof b, 
                "type               "STATICTAG_EDIT_BYTE("00000000")STATICTAG_EDIT_BYTE("00000001")STATICTAG_EDIT_BYTE("00000002")STATICTAG_EDIT_BYTE("00000003")
		"                             %s", xex_shared.info_table_cooked[i].start ? b2 : "");
	
	s->add_staticmask(b, ofs, true);
	s->add_staticmask("value              "STATICTAG_EDIT_DWORD_BE("00000004")" ", ofs, true);
	
	return cs;
}


static ht_sub *add_loaderinfo(File *file, const char *desc, ht_xex_shared_data &xex_shared, int i, FileOfs ofs)
{
	ht_collapsable_sub *cs;
	ht_mask_sub *s = prep_sub(file, desc, xex_shared.info_table_cooked[i].type, i, &cs);
	
	ofs = xex_shared.info_table_cooked[i].start;

	if (xex_shared.info_table_cooked[i].size >= 4) {
		s->add_staticmask("crypted?           "STATICTAG_EDIT_WORD_BE("00000000"), ofs, true);
		s->add_staticmask("type of loader     "STATICTAG_EDIT_WORD_BE("00000002"), ofs, true);
		s->add_staticmask(" ---", ofs, true);
		switch (xex_shared.loader_info.type) {
		case XEX_LOADER_RAW: {
			int entries = (xex_shared.info_table_cooked[i].size-4)/8;
			ofs += 4;
			for (int i = 0; i < entries; i++) {
				s->add_staticmask("raw bytes          "STATICTAG_EDIT_DWORD_BE("00000000"), ofs, true);
				s->add_staticmask("pad                "STATICTAG_EDIT_DWORD_BE("00000004"), ofs, true);
				ofs += 8;
			}
			break;
		}
		case XEX_LOADER_COMPRESSED: {
			s->add_staticmask("compression window "STATICTAG_EDIT_DWORD_BE("00000004"), ofs, true);
			s->add_staticmask("size of loader     "STATICTAG_EDIT_DWORD_BE("00000008"), ofs, true);
			if (xex_shared.info_table_cooked[i].size >= 32) {
				String str("SHA1 hash loader   ");
				for (int j=0; j < 20; j++) {
					String str2;
					str2.assignFormat(STATICTAG_EDIT_BYTE("%08x"), 12+j);
					str.append(str2);
	    			}
				s->add_staticmask(str.contentChar(), ofs, true);
			}
			break;
		}
		}
		// FIXME: compressed vs. raw
	}
	return cs;
}

static ht_sub *add_filename(File *file, const char *desc, ht_xex_shared_data &xex_shared, int i, FileOfs ofs)
{
	return add_resmap(file, desc, xex_shared, i, ofs);
}

static ht_sub *add_single(File *file, const char *desc, ht_xex_shared_data &xex_shared, int i, FileOfs ofs)
{
	return add_resmap(file, desc, xex_shared, i, ofs);
}

static ht_sub *add_import(File *file, const char *desc, ht_xex_shared_data &xex_shared, int i, FileOfs ofs)
{
	return add_resmap(file, desc, xex_shared, i, ofs);
}

static ht_sub *add_ids(File *file, const char *desc, ht_xex_shared_data &xex_shared, int i, FileOfs ofs)
{
	ht_collapsable_sub *cs;
	ht_mask_sub *s = prep_sub(file, desc, xex_shared.info_table_cooked[i].type, i, &cs);
	
	ofs = xex_shared.info_table_cooked[i].start;
	s->add_staticmask("image checksum     "STATICTAG_EDIT_DWORD_BE("00000000"), ofs, true);
	s->add_staticmask("timestamp          "STATICTAG_EDIT_TIME_BE("00000004"), ofs, true);
	return cs;
}

static ht_sub *add_fileinfo(File *file, const char *desc, ht_xex_shared_data &xex_shared, int i, FileOfs ofs)
{
	ht_collapsable_sub *cs;
	ht_mask_sub *s = prep_sub(file, desc, xex_shared.info_table_cooked[i].type, i, &cs);
	
	ofs = xex_shared.info_table_cooked[i].start;
	s->add_staticmask("media ID           "STATICTAG_EDIT_DWORD_BE("00000000"), ofs, true);
	s->add_staticmask("xbox min version   "STATICTAG_EDIT_DWORD_BE("00000004"), ofs, true);
	s->add_staticmask("xbox max? version  "STATICTAG_EDIT_DWORD_BE("00000008"), ofs, true);
	s->add_staticmask("title ID           "STATICTAG_EDIT_DWORD_BE("0000000c"), ofs, true);
	s->add_staticmask("platform           "STATICTAG_EDIT_BYTE("00000010"), ofs, true);
	s->add_staticmask("executable type    "STATICTAG_EDIT_BYTE("00000011"), ofs, true);
	s->add_staticmask("disk number        "STATICTAG_EDIT_BYTE("00000012"), ofs, true);
	s->add_staticmask("disks total        "STATICTAG_EDIT_BYTE("00000013"), ofs, true);
	s->add_staticmask("save game ID       "STATICTAG_EDIT_DWORD_BE("00000014"), ofs, true);
	return cs;
}

static const char *mkkey(String &res, const char *prfx, FileOfs ofs, int size)
{
	res.assign(prfx);
	for (int j=0; j < size; j++) {
		String str2;
		str2.assignFormat(STATICTAG_EDIT_BYTE("%08qx"), ofs+j);
		res.append(str2);
	}
	return res.contentChar();
}

static ht_sub *add_fileheader(File *file, const char *desc, ht_xex_shared_data &xex_shared)
{
	ht_collapsable_sub *cs;
	ht_group_sub *gs = new ht_group_sub();
	ht_mask_sub *s = new ht_mask_sub();
	gs->init(file);
	s->init(file, 2);
	cs = new ht_collapsable_sub();
	cs->init(file, gs, true, desc, true);
	gs->insertsub(s);

	FileOfs ofs = xex_shared.header.file_header_offset;

	String str;
	s->add_staticmask("file header size     "STATICTAG_EDIT_DWORD_BE("00000000"), ofs, true);
	s->add_staticmask("image size           "STATICTAG_EDIT_DWORD_BE("00000004"), ofs, true);	
	s->add_staticmask("key                  "STATICTAG_REF("0000000100000001", "08", "show raw"), ofs, true);
	s->add_staticmask("length?              "STATICTAG_EDIT_DWORD_BE("00000108"), ofs, true);
	s->add_staticmask("image flags          "STATICTAG_EDIT_DWORD_BE("0000010c"), ofs, true);
	s->add_staticmask("load address         "STATICTAG_EDIT_DWORD_BE("00000110"), ofs, true);
	s->add_staticmask(mkkey(str, "hash?                ", 0x114, 20) , ofs, true);
	s->add_staticmask("unknown              "STATICTAG_EDIT_DWORD_BE("00000128"), ofs, true);
	s->add_staticmask(mkkey(str, "hash?                ", 0x12c, 20), ofs, true);
	s->add_staticmask(mkkey(str, "unknown              ", 0x140, 16), ofs, true);
	s->add_staticmask(mkkey(str, "crypted loader key   ", 0x150, 16), ofs, true);
	s->add_staticmask("unknown              "STATICTAG_EDIT_DWORD_BE("00000160"), ofs, true);
	s->add_staticmask(mkkey(str, "hash?                ", 0x164, 20) , ofs, true);
	s->add_staticmask("game region          "STATICTAG_EDIT_DWORD_BE("00000178"), ofs, true);
	s->add_staticmask("media type mask      "STATICTAG_EDIT_DWORD_BE("0000017c")"   "STATICTAG_FLAGS("0000017c", ATOM_XEX_MEDIA_FLAGS_STR), ofs, true);
	s->add_staticmask("", ofs, true);
	s->add_staticmask("page table entries   "STATICTAG_EDIT_DWORD_BE("00000180"), ofs, true);

	s = new ht_mask_sub();
	ht_collapsable_sub *cs2 = new ht_collapsable_sub();
	s->init(file, 3);
	cs2->init(file, s, true, "--- page table ---", true);
	gs->insertsub(cs2);

	ofs += 0x184;
	for (int i=0; i < xex_shared.file_header.pages; i++) {
		s->add_staticmask("flags?               "STATICTAG_EDIT_DWORD_BE("00000000"), ofs, true);
		s->add_staticmask(mkkey(str, "hash?                ", 0x4, 20) , ofs, true);
		ofs += 24;
	}
	return cs;
}

static ht_view *htxexheader_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_xex_shared_data &xex_shared = *(ht_xex_shared_data *)group->get_shared_data();

	ht_xex_header_viewer *v = new ht_xex_header_viewer();
	v->init(b, DESC_XEX_HEADER, VC_EDIT | VC_SEARCH, file, group);

	ht_mask_sub *s;
	ht_group_sub *gs;
	ht_collapsable_sub *cs;

	registerAtom(ATOM_XEX_MEDIA_FLAGS, xex_media_flags);
	
	s = new ht_mask_sub();
	s->init(file, 0);
	char info[128];
	ht_snprintf(info, sizeof info, "* XEX header");
	s->add_mask(info);
	v->insertsub(s);

	const bool xex_bigendian = true;
	
	s = new ht_mask_sub();
	s->init(file, 1);
	
	/* image header */
	s->add_staticmask_ptable(xeximageheader, 0x0, xex_bigendian);
	cs = new ht_collapsable_sub();
	cs->init(file, s, true, "image header", true);
	v->insertsub(cs);

	/* file header */
	v->insertsub(add_fileheader(file, "file header", xex_shared));
	
	gs = new ht_group_sub();
	gs->init(file);
	FileOfs ofs = sizeof xex_shared.header;
	for (uint i=0; i < xex_shared.header.number_of_sections; i++) {
		//STATICTAG_DESC_BYTE_LE("00000001", ATOM_XEX_INFO_CLASS_MAGICS_STR)
		switch (xex_shared.info_table_cooked[i].type) {
		case XEX_HEADER_FIELD_MODULES:
			gs->insertsub(add_resmap(file, "modules", xex_shared, i, ofs));
			break;
		case XEX_HEADER_FIELD_LOADERINFO:
			gs->insertsub(add_loaderinfo(file, "loader information", xex_shared, i, ofs));
			break;
		case XEX_HEADER_FIELD_FILENAME:
			gs->insertsub(add_filename(file, "file name", xex_shared, i, ofs));
			break;
		case XEX_HEADER_FIELD_LOADBASE:
			gs->insertsub(add_single(file, "original base address", xex_shared, i, ofs));
			break;
		case XEX_HEADER_FIELD_ENTRY:
			gs->insertsub(add_single(file, "entry point", xex_shared, i, ofs));
			break;
		case XEX_HEADER_FIELD_BASE:
			gs->insertsub(add_single(file, "image base address", xex_shared, i, ofs));
			break;
		case XEX_HEADER_FIELD_IMPORT:
			gs->insertsub(add_import(file, "imports", xex_shared, i, ofs));
			break;
		case XEX_HEADER_FIELD_IDS:
			gs->insertsub(add_ids(file, "IDs", xex_shared, i, ofs));
			break;
		case XEX_HEADER_FIELD_ORIG_FILENAME:
			gs->insertsub(add_filename(file, "original file name", xex_shared, i, ofs));
			break;
		case XEX_HEADER_FIELD_RESMAP2:
			gs->insertsub(add_resmap(file, "resource map2?", xex_shared, i, ofs));
			break;
		case XEX_HEADER_FIELD_STACK_SIZE:
			gs->insertsub(add_single(file, "default stack size", xex_shared, i, ofs));
			break;
		case XEX_HEADER_FIELD_CACHE_INFO:
			gs->insertsub(add_single(file, "cache info", xex_shared, i, ofs));
			break;
		case XEX_HEADER_FIELD_MEDIAINFO:
			gs->insertsub(add_fileinfo(file, "file information", xex_shared, i, ofs));
			break;
		case XEX_HEADER_FIELD_LAN_KEY:
			gs->insertsub(add_single(file, "lan key", xex_shared, i, ofs));
			break;
		case XEX_HEADER_FIELD_IMPORT_UNK:
		case XEX_HEADER_FIELD_UNK0:
		default: 
			gs->insertsub(add_resmap(file, "UNKNOWN", xex_shared, i, ofs));
		}
		ofs += 8;
	}
	cs=new ht_collapsable_sub();
	cs->init(file, gs, true, "general info table", true);
	v->insertsub(cs);
	return v;

}

format_viewer_if htxexheader_if = {
	htxexheader_init,
	0
};

/*
 *	CLASS ht_xex_header_viewer
 */

void ht_xex_header_viewer::init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *group)
{
	ht_uformat_viewer::init(b, desc, caps, file, group);
	VIEW_DEBUG_NAME("ht_xex_header_viewer");
}

static ht_format_viewer *find_hex_viewer(ht_group *group)
{
	// FIXME: God forgive us...
	ht_group *vr_group=group;
	while (strcmp(vr_group->desc, VIEWERGROUP_NAME)) vr_group=vr_group->group;
	ht_view *c=vr_group->getfirstchild();
	while (c) {
		if (c->desc && (strcmp(c->desc, DESC_HEX)==0)) {
			return (ht_format_viewer*)c;
		}
		c=c->next;
	}
	return NULL;
}

bool ht_xex_header_viewer::ref_sel(LINE_ID *id)
{
	ht_xex_shared_data *xex_shared=(ht_xex_shared_data *)format_group->get_shared_data();
	ht_format_viewer *hexv = find_hex_viewer(group);
	if (!hexv) return false;
	switch (id->id1) {
	case 0: {
		uint32 ofs = xex_shared->info_table_cooked[id->id2].start;
		uint32 size = xex_shared->info_table_cooked[id->id2].size;
		vstate_save();
		hexv->goto_offset(ofs, false);
		hexv->pselect_set(ofs, ofs+size);
		app->focus(hexv);
		return true;
	}
	case 1:
		switch (id->id2) {
		case 0: {
			vstate_save();
			uint32 ofs = xex_shared->header.file_header_offset;
			hexv->goto_offset(ofs, false);
			hexv->pselect_set(ofs, ofs+xex_shared->file_header.hdr_size);
			app->focus(hexv);
			return true;
		}
		case 1: {			
			vstate_save();
			uint32 ofs = xex_shared->header.file_header_offset + 8;
			hexv->goto_offset(ofs, false);
			hexv->pselect_set(ofs, ofs+256);
			app->focus(hexv);
			return true;
		}
		}
	}
	return false;
}
ht-2.0.22/htpeimg.h0000644000175000001440000000237710615341623010745 00000000000000/* 
 *	HT Editor
 *	htpeimg.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTPEIMG_H__
#define __HTPEIMG_H__

#include "htanaly.h"
#include "htpe.h"
#include "formats.h"

extern format_viewer_if htpeimage_if;

/*
 *	CLASS ht_pe_aviewer
 */

class ht_pe_aviewer: public ht_aviewer {
public:
	ht_pe_shared_data *pe_shared;
		   void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Analyser *Analyser, ht_pe_shared_data *pe_shared);
	virtual bool func_handler(eval_scalar *result, char *name, eval_scalarlist *params);
	virtual void setAnalyser(Analyser *a);
};

#endif /* !__HTPEIMG_H__ */
ht-2.0.22/syntax.h0000644000175000001440000001051710615341624010632 00000000000000/*
 *	HT Editor
 *	syntax.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __SYNTAX_H__
#define __SYNTAX_H__

#include "data.h"
#include "htobj.h"

#define HT_HTML_SYNTAX_LEXER

struct text_pos {
	uint line;
	uint pofs;
};

typedef uint lexer_state;
typedef uint lexer_state_set;
typedef uint lexer_token;

enum lexer_rule_string_type {
	LRST_EMPTY,
	LRST_STRING,
	LRST_STRING_EXPECT,
	LRST_REGEX,
	LRST_CHARSET,
	LRST_WHITESPACE,
	LRST_QSTRING,			/* '[^']*' */
	LRST_DQSTRING,			/* "[^"]*" */
//     LRST_DQSTRING2,		/* "([^"]|\")*" */
	LRST_ANYCHAR,
	LRST_IDENTIFIER
};

struct syntax_lexer_rule {
	lexer_state_set needstate;
	bool need_line_start;
	lexer_rule_string_type string_type;
	const char *string;
	lexer_state state;
	lexer_token token;
};

/*
 *	CLASS ht_syntax_lexer
 */

class ht_syntax_lexer: public Object {
public:
/* new */
	virtual	void config_changed();
	virtual	vcp getcolor_syntax(uint pal_index)=0;
	virtual	lexer_state getinitstate()=0;
	virtual	lexer_token geterrortoken()=0;
	virtual	const char *getname()=0;
	virtual	lexer_token gettoken(void *buf, uint buflen, text_pos p, bool start_of_line, lexer_state *ret_state, uint *ret_len)=0;
	virtual	vcp gettoken_color(lexer_token t)=0;
};

/*
 *	CLASS ht_lang_syntax_lexer
 */

class ht_lang_syntax_lexer: public ht_syntax_lexer {
protected:
	syntax_lexer_rule *lexer_rules;
	void **lexer_rules_precompiled;
	int lexer_rules_count;

/* new */
			void free_lexer_rules();
			void set_lexer_rules(syntax_lexer_rule *lr);
public:
			void init(syntax_lexer_rule *lexer_rules);
	virtual	void done();
/* overwritten */
	virtual	lexer_token gettoken(void *buf, uint buflen, text_pos p, bool start_of_line, lexer_state *ret_state, uint *ret_len);
};

/*
 *	CLASS ht_c_syntax_lexer
 */

class ht_c_syntax_lexer: public ht_lang_syntax_lexer {
protected:
	const char **c_reserved_sorted;
	uint c_reserved_count;

	palette c_pal;
	
	virtual	void config_changed();
			void reloadpalette();
public:
			void init();
	virtual	void done();
/* overwritten */
	virtual	vcp getcolor_syntax(uint pal_index);
	virtual	lexer_state getinitstate();
	virtual	lexer_token geterrortoken();
	virtual	const char *getname();
	virtual	lexer_token gettoken(void *buf, uint buflen, text_pos p, bool start_of_line, lexer_state *ret_state, uint *ret_len);
	virtual	vcp gettoken_color(lexer_token t);
};

#ifdef HT_HTML_SYNTAX_LEXER
/*
 *	CLASS ht_html_syntax_lexer
 */

class ht_html_syntax_lexer: public ht_lang_syntax_lexer {
protected:
	char **html_reserved_sorted;
	uint html_reserved_count;

	palette html_pal;
	
	virtual	void config_changed();
			void reloadpalette();
public:
			void init();
	virtual	void done();
/* overwritten */
	virtual	vcp getcolor_syntax(uint pal_index);
	virtual	lexer_state getinitstate();
	virtual	lexer_token geterrortoken();
	virtual	const char *getname();
	virtual	lexer_token gettoken(void *buf, uint buflen, text_pos p, bool start_of_line, lexer_state *ret_state, uint *ret_len);
	virtual	vcp gettoken_color(lexer_token t);
};
#endif

const char **create_sorted_stringtable(const char **table);

/*
 *	syntax palette
 */

#define palkey_syntax_default						"c/default"

#define palidx_syntax_whitespace                       0
#define palidx_syntax_comment                          1
#define palidx_syntax_identifier                       2
#define palidx_syntax_reserved                         3
#define palidx_syntax_intnum                           4
#define palidx_syntax_floatnum                         5
#define palidx_syntax_string                           6
#define palidx_syntax_char                             7
#define palidx_syntax_symbol                           8
#define palidx_syntax_preprocess					9
#define palidx_syntax_meta                             10

#endif /* __SYNTAX_H__ */
ht-2.0.22/htlepage.cc0000644000175000001440000000411710620177260011231 00000000000000/* 
 *	HT Editor
 *	htlepage.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "htnewexe.h"
#include "htle.h"
#include "htlepage.h"
#include "httag.h"
#include "strtools.h"
#include "formats.h"
#include "snprintf.h"

#include "lestruct.h"

#include 

static ht_mask_ptable lepagemap[]=
{
	{"page high",	STATICTAG_EDIT_WORD_LE("00000000")},
	{"page low",	STATICTAG_EDIT_BYTE("00000002")},
	{"flags",		STATICTAG_EDIT_BYTE("00000003")},
	{0, 0}
};

static ht_view *htlepagemaps_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_le_shared_data *le_shared=(ht_le_shared_data *)group->get_shared_data();

	FileOfs h = le_shared->hdr_ofs;
	ht_uformat_viewer *v=new ht_uformat_viewer();
	v->init(b, DESC_LE_PAGEMAP, VC_EDIT | VC_SEARCH, file, group);
	
	ht_mask_sub *m = new ht_mask_sub();
	m->init(file, 0);

	char t[64];
	ht_snprintf(t, sizeof t, "* LE page maps at offset %08qx", h+le_shared->hdr.pagemap);
	m->add_mask(t);

	v->insertsub(m);

	/* FIXME: */
	bool le_bigendian = false;

	for (uint32 i=0; ihdr.pagecnt; i++) {
		m=new ht_mask_sub();
		m->init(file, i);
		
		ht_snprintf(t, sizeof t, "--- page %d at %08x ---", i+1, le_shared->pagemap.offset[i]);
		m->add_staticmask_ptable(lepagemap, h+le_shared->hdr.pagemap+i*4, le_bigendian);
		ht_collapsable_sub *cs=new ht_collapsable_sub();
		cs->init(file, m, 1, t, 1);
		v->insertsub(cs);
	}

	le_shared->v_pagemaps=v;
	return v;
}

format_viewer_if htlepagemaps_if = {
	htlepagemaps_init,
	0
};
ht-2.0.22/htneimg.cc0000644000175000001440000000666710615341621011105 00000000000000/*
 *	HT Editor
 *	htneimg.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "log.h"
#include "htnewexe.h"
#include "htpal.h"
#include "htneimg.h"
#include "strtools.h"
#include "formats.h"
#include "tools.h"

#include "nestruct.h"

#include "htanaly.h"
#include "ne_analy.h"

static ht_view *htneimage_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_ne_shared_data *ne_shared=(ht_ne_shared_data *)group->get_shared_data();

	String fn;
	LOG("%y: NE: loading image (starting analyser)...", &file->getFilename(fn));
	NEAnalyser *p = new NEAnalyser();
	p->init(ne_shared, file);

	Bounds c=*b;
	ht_group *g=new ht_group();
	g->init(&c, VO_RESIZE, DESC_NE_IMAGE"-g");
	AnalyInfoline *head;

	c.y += 2;
	c.h -= 2;
	ht_ne_aviewer *v=new ht_ne_aviewer();
	v->init(&c, DESC_NE_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, p, ne_shared);

	c.y-=2;
	c.h=2;
	head=new AnalyInfoline();
	head->init(&c, v, ANALY_STATUS_DEFAULT);

	v->attachInfoline(head);

/* search for lowest/highest */
	NEAddress l=(NEAddress)-1, h=0;
	NE_SEGMENT *s = ne_shared->segments.segments;
	for (uint i=0; isegments.segment_count; i++) {
		NEAddress base = NE_MAKE_ADDR(i+1, 0);
		uint evsize = MAX(NE_get_seg_vsize(ne_shared, i), NE_get_seg_psize(ne_shared, i));
		if (base < l) l = base;
		if ((base + evsize > h) && (evsize)) h = base + evsize - 1;
		s++;
	}
/**/
	Address *low = p->createAddress1616(NE_ADDR_SEG(l), NE_ADDR_OFS(l));
	Address *high = p->createAddress1616(NE_ADDR_SEG(h), NE_ADDR_OFS(h));
	ht_analy_sub *analy=new ht_analy_sub();
	analy->init(file, v, p, low, high);
	v->analy_sub = analy;
	v->insertsub(analy);
	delete high;
	delete low;

	v->sendmsg(msg_complete_init, 0);

	if (!(ne_shared->hdr.flags & NE_FLAGS_SELFLOAD)) {
		Address *tmpaddr = p->createAddress1616(NE_ADDR_SEG(ne_shared->hdr.csip), NE_ADDR_OFS(ne_shared->hdr.csip));
		v->gotoAddress(tmpaddr, NULL);
		delete tmpaddr;
	} /* FIXME: else what ? */

	g->insert(head);
	g->insert(v);

	g->setpalette(palkey_generic_window_default);

	ne_shared->v_image=v;
	return g;
}

format_viewer_if htneimage_if = {
	htneimage_init,
	0
};

/*
 *	CLASS ht_ne_aviewer
 */

void ht_ne_aviewer::init(Bounds *b, const char *desc, int caps, File *File, ht_format_group *format_group, Analyser *Analy, ht_ne_shared_data *NE_shared)
{
	ht_aviewer::init(b, desc, caps, File, format_group, Analy);
	ne_shared = NE_shared;
	file = File;
}

const char *ht_ne_aviewer::func(uint i, bool execute)
{
	switch (i) {
		case 3: {
			bool e = false;
			file->cntl(FCNTL_GET_RELOC, &e);
			if (execute) {
				file->cntl(FCNTL_SET_RELOC, !e);
			}
			return e ? (char*)"unrelocate" : (char*)"relocate";
		}
	}
	return ht_aviewer::func(i, execute);
}

void ht_ne_aviewer::setAnalyser(Analyser *a)
{
	((NEAnalyser*)a)->ne_shared = ne_shared;
	((NEAnalyser*)a)->file = file;
	analy = a;
	analy_sub->setAnalyser(a);
}
ht-2.0.22/regex.c0000644000175000001440000046200510615341624010414 00000000000000/* Extended regular expression matching and search library,
   version 0.12.
   (Implements POSIX draft P10003.2/D11.2, except for
   internationalization features.)

   Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */

/* AIX requires this to be the first thing in the file. */
#if defined (_AIX) && !defined (REGEX_MALLOC)
  #pragma alloca
#endif

#define _GNU_SOURCE

#ifdef HAVE_CONFIG_H
#include 
#endif

/* We need this for `regex.h', and perhaps for the Emacs include files.  */
#include 

/* This is for other GNU distributions with internationalized messages.  */
#if HAVE_LIBINTL_H || defined (_LIBC)
# include 
#else
# define gettext(msgid) (msgid)
#endif

/* The `emacs' switch turns on certain matching commands
   that make sense only in Emacs. */
#ifdef emacs

#include "lisp.h"
#include "buffer.h"
#include "syntax.h"

#else  /* not emacs */

/* If we are not linking with Emacs proper,
   we can't use the relocating allocator
   even if config.h says that we can.  */
#undef REL_ALLOC

#include 

/* When used in Emacs's lib-src, we need to get bzero and bcopy somehow.
   If nothing else has been done, use the method below.  */
#ifdef INHIBIT_STRING_HEADER
#if !(defined (HAVE_BZERO) && defined (HAVE_BCOPY))
#if !defined (bzero) && !defined (bcopy)
#undef INHIBIT_STRING_HEADER
#endif
#endif
#endif

/* This is the normal way of making sure we have a bcopy and a bzero.
   This is used in most programs--a few other programs avoid this
   by defining INHIBIT_STRING_HEADER.  */
#ifndef INHIBIT_STRING_HEADER
/*#if defined (HAVE_STRING_H) || defined (STDC_HEADERS) || defined (_LIBC)*/
#include 
#ifndef bcmp
#define bcmp(s1, s2, n)	memcmp ((s1), (s2), (n))
#endif
#ifndef bcopy
#define bcopy(s, d, n)	memcpy ((d), (s), (n))
#endif
#ifndef bzero
#define bzero(s, n)	memset ((s), 0, (n))
#endif
/*#else
#include 
#endif*/
#endif

/* Define the syntax stuff for \<, \>, etc.  */

/* This must be nonzero for the wordchar and notwordchar pattern
   commands in re_match_2.  */
#ifndef Sword 
#define Sword 1
#endif

#ifdef SWITCH_ENUM_BUG
#define SWITCH_ENUM_CAST(x) ((int)(x))
#else
#define SWITCH_ENUM_CAST(x) (x)
#endif

#ifdef SYNTAX_TABLE

extern char *re_syntax_table;

#else /* not SYNTAX_TABLE */

/* How many characters in the character set.  */
#define CHAR_SET_SIZE 256

static char re_syntax_table[CHAR_SET_SIZE];

static void
init_syntax_once ()
{
   register int c;
   static int done = 0;

   if (done)
	return;

   bzero (re_syntax_table, sizeof re_syntax_table);

   for (c = 'a'; c <= 'z'; c++)
	re_syntax_table[c] = Sword;

   for (c = 'A'; c <= 'Z'; c++)
	re_syntax_table[c] = Sword;

   for (c = '0'; c <= '9'; c++)
	re_syntax_table[c] = Sword;

   re_syntax_table['_'] = Sword;

   done = 1;
}

#endif /* not SYNTAX_TABLE */

#define SYNTAX(c) re_syntax_table[c]

#endif /* not emacs */

/* Get the interface, including the syntax bits.  */
#include "regex.h"

/* isalpha etc. are used for the character classes.  */
#include 

/* Jim Meyering writes:

   "... Some ctype macros are valid only for character codes that
   isascii says are ASCII (SGI's IRIX-4.0.5 is one such system --when
   using /bin/cc or gcc but without giving an ansi option).  So, all
   ctype uses should be through macros like ISPRINT...  If
   STDC_HEADERS is defined, then autoconf has verified that the ctype
   macros don't need to be guarded with references to isascii. ...
   Defining isascii to 1 should let any compiler worth its salt
   eliminate the && through constant folding."  */

#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII))
#define ISASCII(c) 1
#else
#define ISASCII(c) isascii(c)
#endif

#ifdef isblank
#define ISBLANK(c) (ISASCII (c) && isblank (c))
#else
#define ISBLANK(c) ((c) == ' ' || (c) == '\t')
#endif
#ifdef isgraph
#define ISGRAPH(c) (ISASCII (c) && isgraph (c))
#else
#define ISGRAPH(c) (ISASCII (c) && isprint (c) && !isspace (c))
#endif

#define ISPRINT(c) (ISASCII (c) && isprint (c))
#define ISDIGIT(c) (ISASCII (c) && isdigit (c))
#define ISALNUM(c) (ISASCII (c) && isalnum (c))
#define ISALPHA(c) (ISASCII (c) && isalpha (c))
#define ISCNTRL(c) (ISASCII (c) && iscntrl (c))
#define ISLOWER(c) (ISASCII (c) && islower (c))
#define ISPUNCT(c) (ISASCII (c) && ispunct (c))
#define ISSPACE(c) (ISASCII (c) && isspace (c))
#define ISUPPER(c) (ISASCII (c) && isupper (c))
#define ISXDIGIT(c) (ISASCII (c) && isxdigit (c))

#ifndef NULL
#define NULL (void *)0
#endif

/* We remove any previous definition of `SIGN_EXTEND_CHAR',
   since ours (we hope) works properly with all combinations of
   machines, compilers, `char' and `unsigned char' argument types.
   (Per Bothner suggested the basic approach.)  */
#undef SIGN_EXTEND_CHAR
#if __STDC__
#define SIGN_EXTEND_CHAR(c) ((signed char) (c))
#else  /* not __STDC__ */
/* As in Harbison and Steele.  */
#define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128)
#endif

/* Should we use malloc or alloca?  If REGEX_MALLOC is not defined, we
   use `alloca' instead of `malloc'.  This is because using malloc in
   re_search* or re_match* could cause memory leaks when C-g is used in
   Emacs; also, malloc is slower and causes storage fragmentation.  On
   the other hand, malloc is more portable, and easier to debug.  
   
   Because we sometimes use alloca, some routines have to be macros,
   not functions -- `alloca'-allocated space disappears at the end of the
   function it is called in.  */

#ifdef REGEX_MALLOC

#define REGEX_ALLOCATE malloc
#define REGEX_REALLOCATE(source, osize, nsize) realloc (source, nsize)
#define REGEX_FREE free

#else /* not REGEX_MALLOC  */

/* Emacs already defines alloca, sometimes.  */
#ifndef alloca

/* Make alloca work the best possible way.  */
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not __GNUC__ */
#if HAVE_ALLOCA_H
#include 
#else /* not __GNUC__ or HAVE_ALLOCA_H */
#ifndef _AIX /* Already did AIX, up at the top.  */
char *alloca ();
#endif /* not _AIX */
#endif /* not HAVE_ALLOCA_H */ 
#endif /* not __GNUC__ */

#endif /* not alloca */

#define REGEX_ALLOCATE alloca

/* Assumes a `char *destination' variable.  */
#define REGEX_REALLOCATE(source, osize, nsize)				\
  (destination = (char *) alloca (nsize),				\
   bcopy (source, destination, osize),					\
   destination)

/* No need to do anything to free, after alloca.  */
#define REGEX_FREE(arg) ((void)0) /* Do nothing!  But inhibit gcc warning.  */

#endif /* not REGEX_MALLOC */

/* Define how to allocate the failure stack.  */

#ifdef REL_ALLOC
#define REGEX_ALLOCATE_STACK(size)				\
  r_alloc (&failure_stack_ptr, (size))
#define REGEX_REALLOCATE_STACK(source, osize, nsize)		\
  r_re_alloc (&failure_stack_ptr, (nsize))
#define REGEX_FREE_STACK(ptr)					\
  r_alloc_free (&failure_stack_ptr)

#else /* not REL_ALLOC */

#ifdef REGEX_MALLOC

#define REGEX_ALLOCATE_STACK malloc
#define REGEX_REALLOCATE_STACK(source, osize, nsize) realloc (source, nsize)
#define REGEX_FREE_STACK free

#else /* not REGEX_MALLOC */

#define REGEX_ALLOCATE_STACK alloca

#define REGEX_REALLOCATE_STACK(source, osize, nsize)			\
   REGEX_REALLOCATE (source, osize, nsize)
/* No need to explicitly free anything.  */
#define REGEX_FREE_STACK(arg)

#endif /* not REGEX_MALLOC */
#endif /* not REL_ALLOC */


/* True if `size1' is non-NULL and PTR is pointing anywhere inside
   `string1' or just past its end.  This works if PTR is NULL, which is
   a good thing.  */
#define FIRST_STRING_P(ptr) 					\
  (size1 && string1 <= (ptr) && (ptr) <= string1 + size1)

/* (Re)Allocate N items of type T using malloc, or fail.  */
#define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t)))
#define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t)))
#define RETALLOC_IF(addr, n, t) \
  if (addr) RETALLOC((addr), (n), t); else (addr) = TALLOC ((n), t)
#define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t)))

#define BYTEWIDTH 8 /* In bits.  */

#define STREQ(s1, s2) ((strcmp (s1, s2) == 0))

#undef MAX
#undef MIN
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef char boolean;
#define false 0
#define true 1

static int re_match_2_internal ();

/* These are the command codes that appear in compiled regular
   expressions.  Some opcodes are followed by argument bytes.  A
   command code can specify any interpretation whatsoever for its
   arguments.  Zero bytes may appear in the compiled regular expression.  */

typedef enum
{
  no_op = 0,

  /* Succeed right away--no more backtracking.  */
  succeed,

	   /* Followed by one byte giving n, then by n literal bytes.  */
  exactn,

	   /* Matches any (more or less) character.  */
  anychar,

	   /* Matches any one char belonging to specified set.  First
		 following byte is number of bitmap bytes.  Then come bytes
		 for a bitmap saying which chars are in.  Bits in each byte
		 are ordered low-bit-first.  A character is in the set if its
		 bit is 1.  A character too large to have a bit in the map is
		 automatically not in the set.  */
  charset,

	   /* Same parameters as charset, but match any character that is
		 not one of those specified.  */
  charset_not,

	   /* Start remembering the text that is matched, for storing in a
		 register.  Followed by one byte with the register number, in
		 the range 0 to one less than the pattern buffer's re_nsub
		 field.  Then followed by one byte with the number of groups
		 inner to this one.  (This last has to be part of the
		 start_memory only because we need it in the on_failure_jump
		 of re_match_2.)  */
  start_memory,

	   /* Stop remembering the text that is matched and store it in a
		 memory register.  Followed by one byte with the register
		 number, in the range 0 to one less than `re_nsub' in the
		 pattern buffer, and one byte with the number of inner groups,
		 just like `start_memory'.  (We need the number of inner
		 groups here because we don't have any easy way of finding the
		 corresponding start_memory when we're at a stop_memory.)  */
  stop_memory,

	   /* Match a duplicate of something remembered. Followed by one
		 byte containing the register number.  */
  duplicate,

	   /* Fail unless at beginning of line.  */
  begline,

	   /* Fail unless at end of line.  */
  endline,

	   /* Succeeds if at beginning of buffer (if emacs) or at beginning
		 of string to be matched (if not).  */
  begbuf,

	   /* Analogously, for end of buffer/string.  */
  endbuf,
 
	   /* Followed by two byte relative address to which to jump.  */
  jump, 

	/* Same as jump, but marks the end of an alternative.  */
  jump_past_alt,

	   /* Followed by two-byte relative address of place to resume at
		 in case of failure.  */
  on_failure_jump,
	
	   /* Like on_failure_jump, but pushes a placeholder instead of the
		 current string position when executed.  */
  on_failure_keep_string_jump,
  
	   /* Throw away latest failure point and then jump to following
		 two-byte relative address.  */
  pop_failure_jump,

	   /* Change to pop_failure_jump if know won't have to backtrack to
		 match; otherwise change to jump.  This is used to jump
		 back to the beginning of a repeat.  If what follows this jump
		 clearly won't match what the repeat does, such that we can be
		 sure that there is no use backtracking out of repetitions
		 already matched, then we change it to a pop_failure_jump.
		 Followed by two-byte address.  */
  maybe_pop_jump,

	   /* Jump to following two-byte address, and push a dummy failure
		 point. This failure point will be thrown away if an attempt
		 is made to use it for a failure.  A `+' construct makes this
		 before the first repeat.  Also used as an intermediary kind
		 of jump when compiling an alternative.  */
  dummy_failure_jump,

	/* Push a dummy failure point and continue.  Used at the end of
	   alternatives.  */
  push_dummy_failure,

	   /* Followed by two-byte relative address and two-byte number n.
		 After matching N times, jump to the address upon failure.  */
  succeed_n,

	   /* Followed by two-byte relative address, and two-byte number n.
		 Jump to the address N times, then fail.  */
  jump_n,

	   /* Set the following two-byte relative address to the
		 subsequent two-byte number.  The address *includes* the two
		 bytes of number.  */
  set_number_at,

  wordchar,	/* Matches any word-constituent character.  */
  notwordchar,	/* Matches any char that is not a word-constituent.  */

  wordbeg,	/* Succeeds if at word beginning.  */
  wordend,	/* Succeeds if at word end.  */

  wordbound,	/* Succeeds if at a word boundary.  */
  notwordbound	/* Succeeds if not at a word boundary.  */

#ifdef emacs
  ,before_dot,	/* Succeeds if before point.  */
  at_dot,	/* Succeeds if at point.  */
  after_dot,	/* Succeeds if after point.  */

	/* Matches any character whose syntax is specified.  Followed by
		 a byte which contains a syntax code, e.g., Sword.  */
  syntaxspec,

	/* Matches any character whose syntax is not that specified.  */
  notsyntaxspec
#endif /* emacs */
} re_opcode_t;

/* Common operations on the compiled pattern.  */

/* Store NUMBER in two contiguous bytes starting at DESTINATION.  */

#define STORE_NUMBER(destination, number)				\
  do {									\
    (destination)[0] = (number) & 0377;					\
    (destination)[1] = (number) >> 8;					\
  } while (0)

/* Same as STORE_NUMBER, except increment DESTINATION to
   the byte after where the number is stored.  Therefore, DESTINATION
   must be an lvalue.  */

#define STORE_NUMBER_AND_INCR(destination, number)			\
  do {									\
    STORE_NUMBER (destination, number);					\
    (destination) += 2;							\
  } while (0)

/* Put into DESTINATION a number stored in two contiguous bytes starting
   at SOURCE.  */

#define EXTRACT_NUMBER(destination, source)				\
  do {									\
    (destination) = *(source) & 0377;					\
    (destination) += SIGN_EXTEND_CHAR (*((source) + 1)) << 8;		\
  } while (0)

#ifdef DEBUG
static void
extract_number (dest, source)
    int *dest;
    unsigned char *source;
{
  int temp = SIGN_EXTEND_CHAR (*(source + 1)); 
  *dest = *source & 0377;
  *dest += temp << 8;
}

#ifndef EXTRACT_MACROS /* To debug the macros.  */
#undef EXTRACT_NUMBER
#define EXTRACT_NUMBER(dest, src) extract_number (&dest, src)
#endif /* not EXTRACT_MACROS */

#endif /* DEBUG */

/* Same as EXTRACT_NUMBER, except increment SOURCE to after the number.
   SOURCE must be an lvalue.  */

#define EXTRACT_NUMBER_AND_INCR(destination, source)			\
  do {									\
    EXTRACT_NUMBER (destination, source);				\
    (source) += 2; 							\
  } while (0)

#ifdef DEBUG
static void
extract_number_and_incr (destination, source)
    int *destination;
    unsigned char **source;
{ 
  extract_number (destination, *source);
  *source += 2;
}

#ifndef EXTRACT_MACROS
#undef EXTRACT_NUMBER_AND_INCR
#define EXTRACT_NUMBER_AND_INCR(dest, src) \
  extract_number_and_incr (&dest, &src)
#endif /* not EXTRACT_MACROS */

#endif /* DEBUG */

/* If DEBUG is defined, Regex prints many voluminous messages about what
   it is doing (if the variable `debug' is nonzero).  If linked with the
   main program in `iregex.c', you can enter patterns and strings
   interactively.  And if linked with the main program in `main.c' and
   the other test files, you can run the already-written tests.  */

#ifdef DEBUG

/* We use standard I/O for debugging.  */
#include 

/* It is useful to test things that ``must'' be true when debugging.  */
#include 

static int debug = 0;

#define DEBUG_STATEMENT(e) e
#define DEBUG_PRINT1(x) if (debug) printf (x)
#define DEBUG_PRINT2(x1, x2) if (debug) printf (x1, x2)
#define DEBUG_PRINT3(x1, x2, x3) if (debug) printf (x1, x2, x3)
#define DEBUG_PRINT4(x1, x2, x3, x4) if (debug) printf (x1, x2, x3, x4)
#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e) 				\
  if (debug) print_partial_compiled_pattern (s, e)
#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2)			\
  if (debug) print_double_string (w, s1, sz1, s2, sz2)


/* Print the fastmap in human-readable form.  */

void
print_fastmap (fastmap)
    char *fastmap;
{
  unsigned was_a_range = 0;
  unsigned i = 0;  
  
  while (i < (1 << BYTEWIDTH))
    {
	 if (fastmap[i++])
	{
	  was_a_range = 0;
		putchar (i - 1);
		while (i < (1 << BYTEWIDTH)  &&  fastmap[i])
		  {
		    was_a_range = 1;
		    i++;
		  }
	  if (was_a_range)
		  {
		    printf ("-");
		    putchar (i - 1);
		  }
	   }
    }
  putchar ('\n'); 
}


/* Print a compiled pattern string in human-readable form, starting at
   the START pointer into it and ending just before the pointer END.  */

void
print_partial_compiled_pattern (start, end)
    unsigned char *start;
    unsigned char *end;
{
  int mcnt, mcnt2;
  unsigned char *p = start;
  unsigned char *pend = end;

  if (start == NULL)
    {
	 printf ("(null)\n");
	 return;
    }
    
  /* Loop over pattern commands.  */
  while (p < pend)
    {
	 printf ("%d:\t", p - start);

	 switch ((re_opcode_t) *p++)
	{
	   case no_op:
		printf ("/no_op");
		break;

	case exactn:
	  mcnt = *p++;
		printf ("/exactn/%d", mcnt);
		do
	    {
		    putchar ('/');
		 putchar (*p++);
		  }
		while (--mcnt);
		break;

	case start_memory:
		mcnt = *p++;
		printf ("/start_memory/%d/%d", mcnt, *p++);
		break;

	case stop_memory:
		mcnt = *p++;
	  printf ("/stop_memory/%d/%d", mcnt, *p++);
		break;

	case duplicate:
	  printf ("/duplicate/%d", *p++);
	  break;

	case anychar:
	  printf ("/anychar");
	  break;

	case charset:
	   case charset_not:
		{
		  register int c, last = -100;
	    register int in_range = 0;

	    printf ("/charset [%s",
			  (re_opcode_t) *(p - 1) == charset_not ? "^" : "");
		  
		  assert (p + *p < pend);

		  for (c = 0; c < 256; c++)
		 if (c / 8 < *p
		  && (p[1 + (c/8)] & (1 << (c % 8))))
		{
		  /* Are we starting a range?  */
		  if (last + 1 == c && ! in_range)
		    {
			 putchar ('-');
			 in_range = 1;
		    }
		  /* Have we broken a range?  */
		  else if (last + 1 != c && in_range)
		    {
			 putchar (last);
			 in_range = 0;
		    }
			 
		  if (! in_range)
		    putchar (c);

		  last = c;
		    }

	    if (in_range)
		 putchar (last);

	    putchar (']');

	    p += 1 + *p;
	  }
	  break;

	case begline:
	  printf ("/begline");
		break;

	case endline:
		printf ("/endline");
		break;

	case on_failure_jump:
		extract_number_and_incr (&mcnt, &p);
	  printf ("/on_failure_jump to %d", p + mcnt - start);
		break;

	case on_failure_keep_string_jump:
		extract_number_and_incr (&mcnt, &p);
	  printf ("/on_failure_keep_string_jump to %d", p + mcnt - start);
		break;

	case dummy_failure_jump:
		extract_number_and_incr (&mcnt, &p);
	  printf ("/dummy_failure_jump to %d", p + mcnt - start);
		break;

	case push_dummy_failure:
		printf ("/push_dummy_failure");
		break;
		
	   case maybe_pop_jump:
		extract_number_and_incr (&mcnt, &p);
	  printf ("/maybe_pop_jump to %d", p + mcnt - start);
	  break;

	   case pop_failure_jump:
	  extract_number_and_incr (&mcnt, &p);
	  printf ("/pop_failure_jump to %d", p + mcnt - start);
	  break;          
		
	   case jump_past_alt:
	  extract_number_and_incr (&mcnt, &p);
	  printf ("/jump_past_alt to %d", p + mcnt - start);
	  break;          
		
	   case jump:
	  extract_number_and_incr (&mcnt, &p);
	  printf ("/jump to %d", p + mcnt - start);
	  break;

	   case succeed_n: 
		extract_number_and_incr (&mcnt, &p);
		extract_number_and_incr (&mcnt2, &p);
	  printf ("/succeed_n to %d, %d times", p + mcnt - start, mcnt2);
		break;
	   
	   case jump_n: 
		extract_number_and_incr (&mcnt, &p);
		extract_number_and_incr (&mcnt2, &p);
	  printf ("/jump_n to %d, %d times", p + mcnt - start, mcnt2);
		break;
	   
	   case set_number_at: 
		extract_number_and_incr (&mcnt, &p);
		extract_number_and_incr (&mcnt2, &p);
	  printf ("/set_number_at location %d to %d", p + mcnt - start, mcnt2);
		break;
	   
	   case wordbound:
	  printf ("/wordbound");
	  break;

	case notwordbound:
	  printf ("/notwordbound");
		break;

	case wordbeg:
	  printf ("/wordbeg");
	  break;
		
	case wordend:
	  printf ("/wordend");
		
#ifdef emacs
	case before_dot:
	  printf ("/before_dot");
		break;

	case at_dot:
	  printf ("/at_dot");
		break;

	case after_dot:
	  printf ("/after_dot");
		break;

	case syntaxspec:
		printf ("/syntaxspec");
	  mcnt = *p++;
	  printf ("/%d", mcnt);
		break;
	  
	case notsyntaxspec:
		printf ("/notsyntaxspec");
	  mcnt = *p++;
	  printf ("/%d", mcnt);
	  break;
#endif /* emacs */

	case wordchar:
	  printf ("/wordchar");
		break;
	  
	case notwordchar:
	  printf ("/notwordchar");
		break;

	case begbuf:
	  printf ("/begbuf");
		break;

	case endbuf:
	  printf ("/endbuf");
		break;

	   default:
		printf ("?%d", *(p-1));
	}

	 putchar ('\n');
    }

  printf ("%d:\tend of pattern.\n", p - start);
}


void
print_compiled_pattern (bufp)
    struct re_pattern_buffer *bufp;
{
  unsigned char *buffer = bufp->buffer;

  print_partial_compiled_pattern (buffer, buffer + bufp->used);
  printf ("%d bytes used/%d bytes allocated.\n", bufp->used, bufp->allocated);

  if (bufp->fastmap_accurate && bufp->fastmap)
    {
	 printf ("fastmap: ");
	 print_fastmap (bufp->fastmap);
    }

  printf ("re_nsub: %d\t", bufp->re_nsub);
  printf ("regs_alloc: %d\t", bufp->regs_allocated);
  printf ("can_be_null: %d\t", bufp->can_be_null);
  printf ("newline_anchor: %d\n", bufp->newline_anchor);
  printf ("no_sub: %d\t", bufp->no_sub);
  printf ("not_bol: %d\t", bufp->not_bol);
  printf ("not_eol: %d\t", bufp->not_eol);
  printf ("syntax: %d\n", bufp->syntax);
  /* Perhaps we should print the translate table?  */
}


void
print_double_string (where, string1, size1, string2, size2)
    const char *where;
    const char *string1;
    const char *string2;
    int size1;
    int size2;
{
  unsigned this_char;
  
  if (where == NULL)
    printf ("(null)");
  else
    {
	 if (FIRST_STRING_P (where))
	   {
		for (this_char = where - string1; this_char < size1; this_char++)
		  putchar (string1[this_char]);

		where = string2;    
	   }

	 for (this_char = where - string2; this_char < size2; this_char++)
	   putchar (string2[this_char]);
    }
}

#else /* not DEBUG */

#undef assert
#define assert(e)

#define DEBUG_STATEMENT(e)
#define DEBUG_PRINT1(x)
#define DEBUG_PRINT2(x1, x2)
#define DEBUG_PRINT3(x1, x2, x3)
#define DEBUG_PRINT4(x1, x2, x3, x4)
#define DEBUG_PRINT_COMPILED_PATTERN(p, s, e)
#define DEBUG_PRINT_DOUBLE_STRING(w, s1, sz1, s2, sz2)

#endif /* not DEBUG */

/* Set by `re_set_syntax' to the current regexp syntax to recognize.  Can
   also be assigned to arbitrarily: each pattern buffer stores its own
   syntax, so it can be changed between regex compilations.  */
/* This has no initializer because initialized variables in Emacs
   become read-only after dumping.  */
reg_syntax_t re_syntax_options;


/* Specify the precise syntax of regexps for compilation.  This provides
   for compatibility for various utilities which historically have
   different, incompatible syntaxes.

   The argument SYNTAX is a bit mask comprised of the various bits
   defined in regex.h.  We return the old syntax.  */

reg_syntax_t
re_set_syntax (syntax)
    reg_syntax_t syntax;
{
  reg_syntax_t ret = re_syntax_options;
  
  re_syntax_options = syntax;
  return ret;
}

/* This table gives an error message for each of the error codes listed
   in regex.h.  Obviously the order here has to be same as there.
   POSIX doesn't require that we do anything for REG_NOERROR,
   but why not be nice?  */

static const char *re_error_msgid[] =
  { "Success",					/* REG_NOERROR */
    "No match",					/* REG_NOMATCH */
    "Invalid regular expression",		/* REG_BADPAT */
    "Invalid collation character",		/* REG_ECOLLATE */
    "Invalid character class name",		/* REG_ECTYPE */
    "Trailing backslash",			/* REG_EESCAPE */
    "Invalid back reference",			/* REG_ESUBREG */
    "Unmatched [ or [^",			/* REG_EBRACK */
    "Unmatched ( or \\(",			/* REG_EPAREN */
    "Unmatched \\{",				/* REG_EBRACE */
    "Invalid content of \\{\\}",		/* REG_BADBR */
    "Invalid range end",			/* REG_ERANGE */
    "Memory exhausted",				/* REG_ESPACE */
    "Invalid preceding regular expression",	/* REG_BADRPT */
    "Premature end of regular expression",	/* REG_EEND */
    "Regular expression too big",		/* REG_ESIZE */
    "Unmatched ) or \\)",			/* REG_ERPAREN */
  };

/* Avoiding alloca during matching, to placate r_alloc.  */

/* Define MATCH_MAY_ALLOCATE unless we need to make sure that the
   searching and matching functions should not call alloca.  On some
   systems, alloca is implemented in terms of malloc, and if we're
   using the relocating allocator routines, then malloc could cause a
   relocation, which might (if the strings being searched are in the
   ralloc heap) shift the data out from underneath the regexp
   routines.

   Here's another reason to avoid allocation: Emacs 
   processes input from X in a signal handler; processing X input may
   call malloc; if input arrives while a matching routine is calling
   malloc, then we're scrod.  But Emacs can't just block input while
   calling matching routines; then we don't notice interrupts when
   they come in.  So, Emacs blocks input around all regexp calls
   except the matching calls, which it leaves unprotected, in the
   faith that they will not malloc.  */

/* Normally, this is fine.  */
#define MATCH_MAY_ALLOCATE

/* When using GNU C, we are not REALLY using the C alloca, no matter
   what config.h may say.  So don't take precautions for it.  */
#ifdef __GNUC__
#undef C_ALLOCA
#endif

/* The match routines may not allocate if (1) they would do it with malloc
   and (2) it's not safe for them to use malloc.
   Note that if REL_ALLOC is defined, matching would not use malloc for the
   failure stack, but we would still use it for the register vectors;
   so REL_ALLOC should not affect this.  */
#if (defined (C_ALLOCA) || defined (REGEX_MALLOC)) && defined (emacs)
#undef MATCH_MAY_ALLOCATE
#endif


/* Failure stack declarations and macros; both re_compile_fastmap and
   re_match_2 use a failure stack.  These have to be macros because of
   REGEX_ALLOCATE_STACK.  */
   

/* Number of failure points for which to initially allocate space
   when matching.  If this number is exceeded, we allocate more
   space, so it is not a hard limit.  */
#ifndef INIT_FAILURE_ALLOC
#define INIT_FAILURE_ALLOC 5
#endif

/* Roughly the maximum number of failure points on the stack.  Would be
   exactly that if always used MAX_FAILURE_SPACE each time we failed.
   This is a variable only so users of regex can assign to it; we never
   change it ourselves.  */
#if defined (MATCH_MAY_ALLOCATE)
int re_max_failures = 200000;
#else
int re_max_failures = 2000;
#endif

union fail_stack_elt
{
  unsigned char *pointer;
  int integer;
};

typedef union fail_stack_elt fail_stack_elt_t;

typedef struct
{
  fail_stack_elt_t *stack;
  unsigned size;
  unsigned avail;			/* Offset of next open position.  */
} fail_stack_type;

#define FAIL_STACK_EMPTY()     (fail_stack.avail == 0)
#define FAIL_STACK_PTR_EMPTY() (fail_stack_ptr->avail == 0)
#define FAIL_STACK_FULL()      (fail_stack.avail == fail_stack.size)


/* Define macros to initialize and free the failure stack.
   Do `return -2' if the alloc fails.  */

#ifdef MATCH_MAY_ALLOCATE
#define INIT_FAIL_STACK()						\
  do {									\
    fail_stack.stack = (fail_stack_elt_t *)				\
	 REGEX_ALLOCATE_STACK (INIT_FAILURE_ALLOC * sizeof (fail_stack_elt_t));	\
									\
    if (fail_stack.stack == NULL)					\
	 return -2;							\
									\
    fail_stack.size = INIT_FAILURE_ALLOC;				\
    fail_stack.avail = 0;						\
  } while (0)

#define RESET_FAIL_STACK()  REGEX_FREE_STACK (fail_stack.stack)
#else
#define INIT_FAIL_STACK()						\
  do {									\
    fail_stack.avail = 0;						\
  } while (0)

#define RESET_FAIL_STACK()
#endif


/* Double the size of FAIL_STACK, up to approximately `re_max_failures' items.

   Return 1 if succeeds, and 0 if either ran out of memory
   allocating space for it or it was already too large.  
   
   REGEX_REALLOCATE_STACK requires `destination' be declared.   */

#define DOUBLE_FAIL_STACK(fail_stack)					\
  ((fail_stack).size > re_max_failures * MAX_FAILURE_ITEMS		\
   ? 0									\
   : ((fail_stack).stack = (fail_stack_elt_t *)				\
	   REGEX_REALLOCATE_STACK ((fail_stack).stack, 			\
		(fail_stack).size * sizeof (fail_stack_elt_t),		\
		((fail_stack).size << 1) * sizeof (fail_stack_elt_t)),	\
									\
	 (fail_stack).stack == NULL					\
	 ? 0								\
	 : ((fail_stack).size <<= 1, 					\
	    1)))


/* Push pointer POINTER on FAIL_STACK. 
   Return 1 if was able to do so and 0 if ran out of memory allocating
   space to do so.  */
#define PUSH_PATTERN_OP(POINTER, FAIL_STACK)				\
  ((FAIL_STACK_FULL ()							\
    && !DOUBLE_FAIL_STACK (FAIL_STACK))					\
   ? 0									\
   : ((FAIL_STACK).stack[(FAIL_STACK).avail++].pointer = POINTER,	\
	 1))

/* Push a pointer value onto the failure stack.
   Assumes the variable `fail_stack'.  Probably should only
   be called from within `PUSH_FAILURE_POINT'.  */
#define PUSH_FAILURE_POINTER(item)					\
  fail_stack.stack[fail_stack.avail++].pointer = (unsigned char *) (item)

/* This pushes an integer-valued item onto the failure stack.
   Assumes the variable `fail_stack'.  Probably should only
   be called from within `PUSH_FAILURE_POINT'.  */
#define PUSH_FAILURE_INT(item)					\
  fail_stack.stack[fail_stack.avail++].integer = (item)

/* Push a fail_stack_elt_t value onto the failure stack.
   Assumes the variable `fail_stack'.  Probably should only
   be called from within `PUSH_FAILURE_POINT'.  */
#define PUSH_FAILURE_ELT(item)					\
  fail_stack.stack[fail_stack.avail++] =  (item)

/* These three POP... operations complement the three PUSH... operations.
   All assume that `fail_stack' is nonempty.  */
#define POP_FAILURE_POINTER() fail_stack.stack[--fail_stack.avail].pointer
#define POP_FAILURE_INT() fail_stack.stack[--fail_stack.avail].integer
#define POP_FAILURE_ELT() fail_stack.stack[--fail_stack.avail]

/* Used to omit pushing failure point id's when we're not debugging.  */
#ifdef DEBUG
#define DEBUG_PUSH PUSH_FAILURE_INT
#define DEBUG_POP(item_addr) *(item_addr) = POP_FAILURE_INT ()
#else
#define DEBUG_PUSH(item)
#define DEBUG_POP(item_addr)
#endif


/* Push the information about the state we will need
   if we ever fail back to it.  
   
   Requires variables fail_stack, regstart, regend, reg_info, and
   num_regs be declared.  DOUBLE_FAIL_STACK requires `destination' be
   declared.
   
   Does `return FAILURE_CODE' if runs out of memory.  */

#define PUSH_FAILURE_POINT(pattern_place, string_place, failure_code)	\
  do {									\
    char *destination;							\
    /* Must be int, so when we don't save any registers, the arithmetic	\
	  of 0 + -1 isn't done as unsigned.  */				\
    int this_reg;							\
									\
    destination = 0;	/* inhibit possible compiler warning */		\
    DEBUG_STATEMENT (failure_id++);					\
    DEBUG_STATEMENT (nfailure_points_pushed++);				\
    DEBUG_PRINT2 ("\nPUSH_FAILURE_POINT #%u:\n", failure_id);		\
    DEBUG_PRINT2 ("  Before push, next avail: %d\n", (fail_stack).avail);\
    DEBUG_PRINT2 ("                     size: %d\n", (fail_stack).size);\
									\
    DEBUG_PRINT2 ("  slots needed: %d\n", NUM_FAILURE_ITEMS);		\
    DEBUG_PRINT2 ("     available: %d\n", REMAINING_AVAIL_SLOTS);	\
									\
    /* Ensure we have enough space allocated for what we will push.  */	\
    while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS)			\
	 {									\
	   if (!DOUBLE_FAIL_STACK (fail_stack))				\
		return failure_code;						\
									\
	   DEBUG_PRINT2 ("\n  Doubled stack; size now: %d\n",		\
			  (fail_stack).size);				\
	   DEBUG_PRINT2 ("  slots available: %d\n", REMAINING_AVAIL_SLOTS);\
	 }									\
									\
    /* Push the info, starting with the registers.  */			\
    DEBUG_PRINT1 ("\n");						\
									\
    for (this_reg = lowest_active_reg; this_reg <= highest_active_reg;	\
	    this_reg++)							\
	 {									\
	DEBUG_PRINT2 ("  Pushing reg: %d\n", this_reg);			\
	   DEBUG_STATEMENT (num_regs_pushed++);				\
									\
	DEBUG_PRINT2 ("    start: 0x%x\n", regstart[this_reg]);		\
	   PUSH_FAILURE_POINTER (regstart[this_reg]);			\
														  \
	DEBUG_PRINT2 ("    end: 0x%x\n", regend[this_reg]);		\
	   PUSH_FAILURE_POINTER (regend[this_reg]);			\
									\
	DEBUG_PRINT2 ("    info: 0x%x\n      ", reg_info[this_reg]);	\
	   DEBUG_PRINT2 (" match_null=%d",					\
				  REG_MATCH_NULL_STRING_P (reg_info[this_reg]));	\
	   DEBUG_PRINT2 (" active=%d", IS_ACTIVE (reg_info[this_reg]));	\
	   DEBUG_PRINT2 (" matched_something=%d",				\
				  MATCHED_SOMETHING (reg_info[this_reg]));		\
	   DEBUG_PRINT2 (" ever_matched=%d",				\
				  EVER_MATCHED_SOMETHING (reg_info[this_reg]));	\
	DEBUG_PRINT1 ("\n");						\
	   PUSH_FAILURE_ELT (reg_info[this_reg].word);			\
	 }									\
									\
    DEBUG_PRINT2 ("  Pushing  low active reg: %d\n", lowest_active_reg);\
    PUSH_FAILURE_INT (lowest_active_reg);				\
									\
    DEBUG_PRINT2 ("  Pushing high active reg: %d\n", highest_active_reg);\
    PUSH_FAILURE_INT (highest_active_reg);				\
									\
    DEBUG_PRINT2 ("  Pushing pattern 0x%x: ", pattern_place);		\
    DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend);		\
    PUSH_FAILURE_POINTER (pattern_place);				\
									\
    DEBUG_PRINT2 ("  Pushing string 0x%x: `", string_place);		\
    DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2,   \
				 size2);				\
    DEBUG_PRINT1 ("'\n");						\
    PUSH_FAILURE_POINTER (string_place);				\
									\
    DEBUG_PRINT2 ("  Pushing failure id: %u\n", failure_id);		\
    DEBUG_PUSH (failure_id);						\
  } while (0)

/* This is the number of items that are pushed and popped on the stack
   for each register.  */
#define NUM_REG_ITEMS  3

/* Individual items aside from the registers.  */
#ifdef DEBUG
#define NUM_NONREG_ITEMS 5 /* Includes failure point id.  */
#else
#define NUM_NONREG_ITEMS 4
#endif

/* We push at most this many items on the stack.  */
#define MAX_FAILURE_ITEMS ((num_regs - 1) * NUM_REG_ITEMS + NUM_NONREG_ITEMS)

/* We actually push this many items.  */
#define NUM_FAILURE_ITEMS						\
  ((highest_active_reg - lowest_active_reg + 1) * NUM_REG_ITEMS 	\
    + NUM_NONREG_ITEMS)

/* How many items can still be added to the stack without overflowing it.  */
#define REMAINING_AVAIL_SLOTS ((fail_stack).size - (fail_stack).avail)


/* Pops what PUSH_FAIL_STACK pushes.

   We restore into the parameters, all of which should be lvalues:
	STR -- the saved data position.
	PAT -- the saved pattern position.
	LOW_REG, HIGH_REG -- the highest and lowest active registers.
	REGSTART, REGEND -- arrays of string positions.
	REG_INFO -- array of information about each subexpression.
   
   Also assumes the variables `fail_stack' and (if debugging), `bufp',
   `pend', `string1', `size1', `string2', and `size2'.  */

#define POP_FAILURE_POINT(str, pat, low_reg, high_reg, regstart, regend, reg_info)\
{									\
  DEBUG_STATEMENT (fail_stack_elt_t failure_id;)			\
  int this_reg;								\
  const unsigned char *string_temp;					\
									\
  assert (!FAIL_STACK_EMPTY ());					\
									\
  /* Remove failure points and point to how many regs pushed.  */	\
  DEBUG_PRINT1 ("POP_FAILURE_POINT:\n");				\
  DEBUG_PRINT2 ("  Before pop, next avail: %d\n", fail_stack.avail);	\
  DEBUG_PRINT2 ("                    size: %d\n", fail_stack.size);	\
									\
  assert (fail_stack.avail >= NUM_NONREG_ITEMS);			\
									\
  DEBUG_POP (&failure_id);						\
  DEBUG_PRINT2 ("  Popping failure id: %u\n", failure_id);		\
									\
  /* If the saved string location is NULL, it came from an		\
	on_failure_keep_string_jump opcode, and we want to throw away the	\
	saved NULL, thus retaining our current position in the string.  */	\
  string_temp = POP_FAILURE_POINTER ();					\
  if (string_temp != NULL)						\
    str = (const char *) string_temp;					\
									\
  DEBUG_PRINT2 ("  Popping string 0x%x: `", str);			\
  DEBUG_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2);	\
  DEBUG_PRINT1 ("'\n");							\
									\
  pat = (unsigned char *) POP_FAILURE_POINTER ();			\
  DEBUG_PRINT2 ("  Popping pattern 0x%x: ", pat);			\
  DEBUG_PRINT_COMPILED_PATTERN (bufp, pat, pend);			\
									\
  /* Restore register info.  */						\
  high_reg = (unsigned) POP_FAILURE_INT ();				\
  DEBUG_PRINT2 ("  Popping high active reg: %d\n", high_reg);		\
									\
  low_reg = (unsigned) POP_FAILURE_INT ();				\
  DEBUG_PRINT2 ("  Popping  low active reg: %d\n", low_reg);		\
									\
  for (this_reg = high_reg; this_reg >= low_reg; this_reg--)		\
    {									\
	 DEBUG_PRINT2 ("    Popping reg: %d\n", this_reg);			\
									\
	 reg_info[this_reg].word = POP_FAILURE_ELT ();			\
	 DEBUG_PRINT2 ("      info: 0x%x\n", reg_info[this_reg]);		\
									\
	 regend[this_reg] = (const char *) POP_FAILURE_POINTER ();		\
	 DEBUG_PRINT2 ("      end: 0x%x\n", regend[this_reg]);		\
									\
	 regstart[this_reg] = (const char *) POP_FAILURE_POINTER ();	\
	 DEBUG_PRINT2 ("      start: 0x%x\n", regstart[this_reg]);		\
    }									\
									\
  set_regs_matched_done = 0;						\
  DEBUG_STATEMENT (nfailure_points_popped++);				\
} /* POP_FAILURE_POINT */



/* Structure for per-register (a.k.a. per-group) information.
   Other register information, such as the
   starting and ending positions (which are addresses), and the list of
   inner groups (which is a bits list) are maintained in separate
   variables.  
   
   We are making a (strictly speaking) nonportable assumption here: that
   the compiler will pack our bit fields into something that fits into
   the type of `word', i.e., is something that fits into one item on the
   failure stack.  */

typedef union
{
  fail_stack_elt_t word;
  struct
  {
	 /* This field is one if this group can match the empty string,
	    zero if not.  If not yet determined,  `MATCH_NULL_UNSET_VALUE'.  */
#define MATCH_NULL_UNSET_VALUE 3
    unsigned match_null_string_p : 2;
    unsigned is_active : 1;
    unsigned matched_something : 1;
    unsigned ever_matched_something : 1;
  } bits;
} register_info_type;

#define REG_MATCH_NULL_STRING_P(R)  ((R).bits.match_null_string_p)
#define IS_ACTIVE(R)  ((R).bits.is_active)
#define MATCHED_SOMETHING(R)  ((R).bits.matched_something)
#define EVER_MATCHED_SOMETHING(R)  ((R).bits.ever_matched_something)


/* Call this when have matched a real character; it sets `matched' flags
   for the subexpressions which we are currently inside.  Also records
   that those subexprs have matched.  */
#define SET_REGS_MATCHED()						\
  do									\
    {									\
	 if (!set_regs_matched_done)					\
	{								\
	  unsigned r;							\
	  set_regs_matched_done = 1;					\
	  for (r = lowest_active_reg; r <= highest_active_reg; r++)	\
	    {								\
		 MATCHED_SOMETHING (reg_info[r])				\
		= EVER_MATCHED_SOMETHING (reg_info[r])			\
		= 1;							\
	    }								\
	}								\
    }									\
  while (0)

/* Registers are set to a sentinel when they haven't yet matched.  */
static char reg_unset_dummy;
#define REG_UNSET_VALUE (®_unset_dummy)
#define REG_UNSET(e) ((e) == REG_UNSET_VALUE)

/* Subroutine declarations and macros for regex_compile.  */

static void store_op1 (), store_op2 ();
static void insert_op1 (), insert_op2 ();
static boolean at_begline_loc_p (), at_endline_loc_p ();
static boolean group_in_compile_stack ();
static reg_errcode_t compile_range ();

/* Fetch the next character in the uncompiled pattern---translating it 
   if necessary.  Also cast from a signed character in the constant
   string passed to us by the user to an unsigned char that we can use
   as an array index (in, e.g., `translate').  */
#define PATFETCH(c)							\
  do {if (p == pend) return REG_EEND;					\
    c = (unsigned char) *p++;						\
    if (translate) c = translate[c]; 					\
  } while (0)

/* Fetch the next character in the uncompiled pattern, with no
   translation.  */
#define PATFETCH_RAW(c)							\
  do {if (p == pend) return REG_EEND;					\
    c = (unsigned char) *p++; 						\
  } while (0)

/* Go backwards one character in the pattern.  */
#define PATUNFETCH p--


/* If `translate' is non-null, return translate[D], else just D.  We
   cast the subscript to translate because some data is declared as
   `char *', to avoid warnings when a string constant is passed.  But
   when we use a character as a subscript we must make it unsigned.  */
#define TRANSLATE(d) (translate ? translate[(unsigned char) (d)] : (d))


/* Macros for outputting the compiled pattern into `buffer'.  */

/* If the buffer isn't allocated when it comes in, use this.  */
#define INIT_BUF_SIZE  32

/* Make sure we have at least N more bytes of space in buffer.  */
#define GET_BUFFER_SPACE(n)						\
    while (b - bufp->buffer + (n) > bufp->allocated)			\
	 EXTEND_BUFFER ()

/* Make sure we have one more byte of buffer space and then add C to it.  */
#define BUF_PUSH(c)							\
  do {									\
    GET_BUFFER_SPACE (1);						\
    *b++ = (unsigned char) (c);						\
  } while (0)


/* Ensure we have two more bytes of buffer space and then append C1 and C2.  */
#define BUF_PUSH_2(c1, c2)						\
  do {									\
    GET_BUFFER_SPACE (2);						\
    *b++ = (unsigned char) (c1);					\
    *b++ = (unsigned char) (c2);					\
  } while (0)


/* As with BUF_PUSH_2, except for three bytes.  */
#define BUF_PUSH_3(c1, c2, c3)						\
  do {									\
    GET_BUFFER_SPACE (3);						\
    *b++ = (unsigned char) (c1);					\
    *b++ = (unsigned char) (c2);					\
    *b++ = (unsigned char) (c3);					\
  } while (0)


/* Store a jump with opcode OP at LOC to location TO.  We store a
   relative address offset by the three bytes the jump itself occupies.  */
#define STORE_JUMP(op, loc, to) \
  store_op1 (op, loc, (to) - (loc) - 3)

/* Likewise, for a two-argument jump.  */
#define STORE_JUMP2(op, loc, to, arg) \
  store_op2 (op, loc, (to) - (loc) - 3, arg)

/* Like `STORE_JUMP', but for inserting.  Assume `b' is the buffer end.  */
#define INSERT_JUMP(op, loc, to) \
  insert_op1 (op, loc, (to) - (loc) - 3, b)

/* Like `STORE_JUMP2', but for inserting.  Assume `b' is the buffer end.  */
#define INSERT_JUMP2(op, loc, to, arg) \
  insert_op2 (op, loc, (to) - (loc) - 3, arg, b)


/* This is not an arbitrary limit: the arguments which represent offsets
   into the pattern are two bytes long.  So if 2^16 bytes turns out to
   be too small, many things would have to change.  */
#define MAX_BUF_SIZE (1L << 16)


/* Extend the buffer by twice its current size via realloc and
   reset the pointers that pointed into the old block to point to the
   correct places in the new one.  If extending the buffer results in it
   being larger than MAX_BUF_SIZE, then flag memory exhausted.  */
#define EXTEND_BUFFER()							\
  do { 									\
    unsigned char *old_buffer = bufp->buffer;				\
    if (bufp->allocated == MAX_BUF_SIZE) 				\
	 return REG_ESIZE;							\
    bufp->allocated <<= 1;						\
    if (bufp->allocated > MAX_BUF_SIZE)					\
	 bufp->allocated = MAX_BUF_SIZE; 					\
    bufp->buffer = (unsigned char *) realloc (bufp->buffer, bufp->allocated);\
    if (bufp->buffer == NULL)						\
	 return REG_ESPACE;						\
    /* If the buffer moved, move all the pointers into it.  */		\
    if (old_buffer != bufp->buffer)					\
	 {									\
	   b = (b - old_buffer) + bufp->buffer;				\
	   begalt = (begalt - old_buffer) + bufp->buffer;			\
	   if (fixup_alt_jump)						\
		fixup_alt_jump = (fixup_alt_jump - old_buffer) + bufp->buffer;\
	   if (laststart)							\
		laststart = (laststart - old_buffer) + bufp->buffer;		\
	   if (pending_exact)						\
		pending_exact = (pending_exact - old_buffer) + bufp->buffer;	\
	 }									\
  } while (0)


/* Since we have one byte reserved for the register number argument to
   {start,stop}_memory, the maximum number of groups we can report
   things about is what fits in that byte.  */
#define MAX_REGNUM 255

/* But patterns can have more than `MAX_REGNUM' registers.  We just
   ignore the excess.  */
typedef unsigned regnum_t;


/* Macros for the compile stack.  */

/* Since offsets can go either forwards or backwards, this type needs to
   be able to hold values from -(MAX_BUF_SIZE - 1) to MAX_BUF_SIZE - 1.  */
typedef int pattern_offset_t;

typedef struct
{
  pattern_offset_t begalt_offset;
  pattern_offset_t fixup_alt_jump;
  pattern_offset_t inner_group_offset;
  pattern_offset_t laststart_offset;  
  regnum_t regnum;
} compile_stack_elt_t;


typedef struct
{
  compile_stack_elt_t *stack;
  unsigned size;
  unsigned avail;			/* Offset of next open position.  */
} compile_stack_type;


#define INIT_COMPILE_STACK_SIZE 32

#define COMPILE_STACK_EMPTY  (compile_stack.avail == 0)
#define COMPILE_STACK_FULL  (compile_stack.avail == compile_stack.size)

/* The next available element.  */
#define COMPILE_STACK_TOP (compile_stack.stack[compile_stack.avail])


/* Set the bit for character C in a list.  */
#define SET_LIST_BIT(c)                               \
  (b[((unsigned char) (c)) / BYTEWIDTH]               \
   |= 1 << (((unsigned char) c) % BYTEWIDTH))


/* Get the next unsigned number in the uncompiled pattern.  */
#define GET_UNSIGNED_NUMBER(num) 					\
  { if (p != pend)							\
	{									\
	  PATFETCH (c); 							\
	  while (ISDIGIT (c)) 						\
	    { 								\
		 if (num < 0)							\
		    num = 0;							\
		 num = num * 10 + c - '0'; 					\
		 if (p == pend) 						\
		    break; 							\
		 PATFETCH (c);						\
	    } 								\
	  } 								\
    }		

#define CHAR_CLASS_MAX_LENGTH  6 /* Namely, `xdigit'.  */

#define IS_CHAR_CLASS(string)						\
   (STREQ (string, "alpha") || STREQ (string, "upper")			\
    || STREQ (string, "lower") || STREQ (string, "digit")		\
    || STREQ (string, "alnum") || STREQ (string, "xdigit")		\
    || STREQ (string, "space") || STREQ (string, "print")		\
    || STREQ (string, "punct") || STREQ (string, "graph")		\
    || STREQ (string, "cntrl") || STREQ (string, "blank"))

#ifndef MATCH_MAY_ALLOCATE

/* If we cannot allocate large objects within re_match_2_internal,
   we make the fail stack and register vectors global.
   The fail stack, we grow to the maximum size when a regexp
   is compiled.
   The register vectors, we adjust in size each time we
   compile a regexp, according to the number of registers it needs.  */

static fail_stack_type fail_stack;

/* Size with which the following vectors are currently allocated.
   That is so we can make them bigger as needed,
   but never make them smaller.  */
static int regs_allocated_size;

static const char **     regstart, **     regend;
static const char ** old_regstart, ** old_regend;
static const char **best_regstart, **best_regend;
static register_info_type *reg_info; 
static const char **reg_dummy;
static register_info_type *reg_info_dummy;

/* Make the register vectors big enough for NUM_REGS registers,
   but don't make them smaller.  */

static
regex_grow_registers (num_regs)
	int num_regs;
{
  if (num_regs > regs_allocated_size)
    {
	 RETALLOC_IF (regstart,	 num_regs, const char *);
	 RETALLOC_IF (regend,	 num_regs, const char *);
	 RETALLOC_IF (old_regstart, num_regs, const char *);
	 RETALLOC_IF (old_regend,	 num_regs, const char *);
	 RETALLOC_IF (best_regstart, num_regs, const char *);
	 RETALLOC_IF (best_regend,	 num_regs, const char *);
	 RETALLOC_IF (reg_info,	 num_regs, register_info_type);
	 RETALLOC_IF (reg_dummy,	 num_regs, const char *);
	 RETALLOC_IF (reg_info_dummy, num_regs, register_info_type);

	 regs_allocated_size = num_regs;
    }
}

#endif /* not MATCH_MAY_ALLOCATE */

/* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX.
   Returns one of error codes defined in `regex.h', or zero for success.

   Assumes the `allocated' (and perhaps `buffer') and `translate'
   fields are set in BUFP on entry.

   If it succeeds, results are put in BUFP (if it returns an error, the
   contents of BUFP are undefined):
	`buffer' is the compiled pattern;
	`syntax' is set to SYNTAX;
	`used' is set to the length of the compiled pattern;
	`fastmap_accurate' is zero;
	`re_nsub' is the number of subexpressions in PATTERN;
	`not_bol' and `not_eol' are zero;
   
   The `fastmap' and `newline_anchor' fields are neither
   examined nor set.  */

/* Return, freeing storage we allocated.  */
#define FREE_STACK_RETURN(value)		\
  return (free (compile_stack.stack), value)

static reg_errcode_t
regex_compile (pattern, size, syntax, bufp)
	const char *pattern;
	int size;
	reg_syntax_t syntax;
	struct re_pattern_buffer *bufp;
{
  /* We fetch characters from PATTERN here.  Even though PATTERN is
	`char *' (i.e., signed), we declare these variables as unsigned, so
	they can be reliably used as array indices.  */
  register unsigned char c, c1;
  
  /* A random temporary spot in PATTERN.  */
  const char *p1;

  /* Points to the end of the buffer, where we should append.  */
  register unsigned char *b;
  
  /* Keeps track of unclosed groups.  */
  compile_stack_type compile_stack;

  /* Points to the current (ending) position in the pattern.  */
  const char *p = pattern;
  const char *pend = pattern + size;
  
  /* How to translate the characters in the pattern.  */
  char *translate = bufp->translate;

  /* Address of the count-byte of the most recently inserted `exactn'
	command.  This makes it possible to tell if a new exact-match
	character can be added to that command or if the character requires
	a new `exactn' command.  */
  unsigned char *pending_exact = 0;

  /* Address of start of the most recently finished expression.
	This tells, e.g., postfix * where to find the start of its
	operand.  Reset at the beginning of groups and alternatives.  */
  unsigned char *laststart = 0;

  /* Address of beginning of regexp, or inside of last group.  */
  unsigned char *begalt;

  /* Place in the uncompiled pattern (i.e., the {) to
	which to go back if the interval is invalid.  */
  const char *beg_interval;
			 
  /* Address of the place where a forward jump should go to the end of
	the containing expression.  Each alternative of an `or' -- except the
	last -- ends with a forward jump of this sort.  */
  unsigned char *fixup_alt_jump = 0;

  /* Counts open-groups as they are encountered.  Remembered for the
	matching close-group on the compile stack, so the same register
	number is put in the stop_memory as the start_memory.  */
  regnum_t regnum = 0;

#ifdef DEBUG
  DEBUG_PRINT1 ("\nCompiling pattern: ");
  if (debug)
    {
	 unsigned debug_count;
	 
	 for (debug_count = 0; debug_count < size; debug_count++)
	   putchar (pattern[debug_count]);
	 putchar ('\n');
    }
#endif /* DEBUG */

  /* Initialize the compile stack.  */
  compile_stack.stack = TALLOC (INIT_COMPILE_STACK_SIZE, compile_stack_elt_t);
  if (compile_stack.stack == NULL)
    return REG_ESPACE;

  compile_stack.size = INIT_COMPILE_STACK_SIZE;
  compile_stack.avail = 0;

  /* Initialize the pattern buffer.  */
  bufp->syntax = syntax;
  bufp->fastmap_accurate = 0;
  bufp->not_bol = bufp->not_eol = 0;

  /* Set `used' to zero, so that if we return an error, the pattern
	printer (for debugging) will think there's no pattern.  We reset it
	at the end.  */
  bufp->used = 0;
  
  /* Always count groups, whether or not bufp->no_sub is set.  */
  bufp->re_nsub = 0;				

#if !defined (emacs) && !defined (SYNTAX_TABLE)
  /* Initialize the syntax table.  */
   init_syntax_once ();
#endif

  if (bufp->allocated == 0)
    {
	 if (bufp->buffer)
	{ /* If zero allocated, but buffer is non-null, try to realloc
		   enough space.  This loses if buffer's address is bogus, but
		   that is the user's responsibility.  */
		RETALLOC (bufp->buffer, INIT_BUF_SIZE, unsigned char);
	   }
	 else
	   { /* Caller did not allocate a buffer.  Do it for them.  */
		bufp->buffer = TALLOC (INIT_BUF_SIZE, unsigned char);
	   }
	 if (!bufp->buffer) FREE_STACK_RETURN (REG_ESPACE);

	 bufp->allocated = INIT_BUF_SIZE;
    }

  begalt = b = bufp->buffer;

  /* Loop through the uncompiled pattern until we're at the end.  */
  while (p != pend)
    {
	 PATFETCH (c);

	 switch (c)
	   {
	   case '^':
		{
		  if (   /* If at start of pattern, it's an operator.  */
			    p == pattern + 1
			    /* If context independent, it's an operator.  */
			 || syntax & RE_CONTEXT_INDEP_ANCHORS
			    /* Otherwise, depends on what's come before.  */
			 || at_begline_loc_p (pattern, p, syntax))
		    BUF_PUSH (begline);
		  else
		    goto normal_char;
		}
		break;


	   case '$':
		{
		  if (   /* If at end of pattern, it's an operator.  */
			    p == pend 
			    /* If context independent, it's an operator.  */
			 || syntax & RE_CONTEXT_INDEP_ANCHORS
			    /* Otherwise, depends on what's next.  */
			 || at_endline_loc_p (p, pend, syntax))
			BUF_PUSH (endline);
		   else
			goto normal_char;
		 }
		 break;


	case '+':
	   case '?':
		if ((syntax & RE_BK_PLUS_QM)
		    || (syntax & RE_LIMITED_OPS))
		  goto normal_char;
	   handle_plus:
	   case '*':
		/* If there is no previous pattern... */
		if (!laststart)
		  {
		    if (syntax & RE_CONTEXT_INVALID_OPS)
			 FREE_STACK_RETURN (REG_BADRPT);
		    else if (!(syntax & RE_CONTEXT_INDEP_OPS))
			 goto normal_char;
		  }

		{
		  /* Are we optimizing this jump?  */
		  boolean keep_string_p = false;
		  
		  /* 1 means zero (many) matches is allowed.  */
		  char zero_times_ok = 0, many_times_ok = 0;

		  /* If there is a sequence of repetition chars, collapse it
			down to just one (the right one).  We can't combine
			interval operators with these because of, e.g., `a{2}*',
			which should only match an even number of `a's.  */

		  for (;;)
		    {
			 zero_times_ok |= c != '+';
			 many_times_ok |= c != '?';

			 if (p == pend)
			   break;

			 PATFETCH (c);

			 if (c == '*'
				|| (!(syntax & RE_BK_PLUS_QM) && (c == '+' || c == '?')))
			   ;

			 else if (syntax & RE_BK_PLUS_QM  &&  c == '\\')
			   {
				if (p == pend) FREE_STACK_RETURN (REG_EESCAPE);

				PATFETCH (c1);
				if (!(c1 == '+' || c1 == '?'))
				  {
				    PATUNFETCH;
				    PATUNFETCH;
				    break;
				  }

				c = c1;
			   }
			 else
			   {
				PATUNFETCH;
				break;
			   }

			 /* If we get here, we found another repeat character.  */
			}

		  /* Star, etc. applied to an empty pattern is equivalent
			to an empty pattern.  */
		  if (!laststart)  
		    break;

		  /* Now we know whether or not zero matches is allowed
			and also whether or not two or more matches is allowed.  */
		  if (many_times_ok)
		    { /* More than one repetition is allowed, so put in at the
			    end a backward relative jump from `b' to before the next
			    jump we're going to put in below (which jumps from
			    laststart to after this jump).  

			    But if we are at the `*' in the exact sequence `.*\n',
			    insert an unconditional jump backwards to the .,
			    instead of the beginning of the loop.  This way we only
			    push a failure point once, instead of every time
			    through the loop.  */
			 assert (p - 1 > pattern);

			 /* Allocate the space for the jump.  */
			 GET_BUFFER_SPACE (3);

			 /* We know we are not at the first character of the pattern,
			    because laststart was nonzero.  And we've already
			    incremented `p', by the way, to be the character after
			    the `*'.  Do we have to do something analogous here
			    for null bytes, because of RE_DOT_NOT_NULL?  */
			 if (TRANSLATE (*(p - 2)) == TRANSLATE ('.')
		    && zero_times_ok
				&& p < pend && TRANSLATE (*p) == TRANSLATE ('\n')
				&& !(syntax & RE_DOT_NEWLINE))
			   { /* We have .*\n.  */
				STORE_JUMP (jump, b, laststart);
				keep_string_p = true;
			   }
			 else
			   /* Anything else.  */
			   STORE_JUMP (maybe_pop_jump, b, laststart - 3);

			 /* We've added more stuff to the buffer.  */
			 b += 3;
		    }

		  /* On failure, jump from laststart to b + 3, which will be the
			end of the buffer after this jump is inserted.  */
		  GET_BUFFER_SPACE (3);
		  INSERT_JUMP (keep_string_p ? on_failure_keep_string_jump
							    : on_failure_jump,
					laststart, b + 3);
		  pending_exact = 0;
		  b += 3;

		  if (!zero_times_ok)
		    {
			 /* At least one repetition is required, so insert a
			    `dummy_failure_jump' before the initial
			    `on_failure_jump' instruction of the loop. This
			    effects a skip over that instruction the first time
			    we hit that loop.  */
			 GET_BUFFER_SPACE (3);
			 INSERT_JUMP (dummy_failure_jump, laststart, laststart + 6);
			 b += 3;
		    }
		  }
	  break;


	case '.':
		laststart = b;
		BUF_PUSH (anychar);
		break;


	   case '[':
		{
		  boolean had_char_class = false;

		  if (p == pend) FREE_STACK_RETURN (REG_EBRACK);

		  /* Ensure that we have enough space to push a charset: the
			opcode, the length count, and the bitset; 34 bytes in all.  */
	    GET_BUFFER_SPACE (34);

		  laststart = b;

		  /* We test `*p == '^' twice, instead of using an if
			statement, so we only need one BUF_PUSH.  */
		  BUF_PUSH (*p == '^' ? charset_not : charset); 
		  if (*p == '^')
		    p++;

		  /* Remember the first position in the bracket expression.  */
		  p1 = p;

		  /* Push the number of bytes in the bitmap.  */
		  BUF_PUSH ((1 << BYTEWIDTH) / BYTEWIDTH);

		  /* Clear the whole map.  */
		  bzero (b, (1 << BYTEWIDTH) / BYTEWIDTH);

		  /* charset_not matches newline according to a syntax bit.  */
		  if ((re_opcode_t) b[-2] == charset_not
			 && (syntax & RE_HAT_LISTS_NOT_NEWLINE))
		    SET_LIST_BIT ('\n');

		  /* Read in characters and ranges, setting map bits.  */
		  for (;;)
		    {
			 if (p == pend) FREE_STACK_RETURN (REG_EBRACK);

			 PATFETCH (c);

			 /* \ might escape characters inside [...] and [^...].  */
			 if ((syntax & RE_BACKSLASH_ESCAPE_IN_LISTS) && c == '\\')
			   {
				if (p == pend) FREE_STACK_RETURN (REG_EESCAPE);

				PATFETCH (c1);
				SET_LIST_BIT (c1);
				continue;
			   }

			 /* Could be the end of the bracket expression.  If it's
			    not (i.e., when the bracket expression is `[]' so
			    far), the ']' character bit gets set way below.  */
			 if (c == ']' && p != p1 + 1)
			   break;

			 /* Look ahead to see if it's a range when the last thing
			    was a character class.  */
			 if (had_char_class && c == '-' && *p != ']')
			   FREE_STACK_RETURN (REG_ERANGE);

			 /* Look ahead to see if it's a range when the last thing
			    was a character: if this is a hyphen not at the
			    beginning or the end of a list, then it's the range
			    operator.  */
			 if (c == '-' 
				&& !(p - 2 >= pattern && p[-2] == '[') 
				&& !(p - 3 >= pattern && p[-3] == '[' && p[-2] == '^')
				&& *p != ']')
			   {
				reg_errcode_t ret
				  = compile_range (&p, pend, translate, syntax, b);
				if (ret != REG_NOERROR) FREE_STACK_RETURN (ret);
			   }

			 else if (p[0] == '-' && p[1] != ']')
			   { /* This handles ranges made up of characters only.  */
				reg_errcode_t ret;

		    /* Move past the `-'.  */
				PATFETCH (c1);
				
				ret = compile_range (&p, pend, translate, syntax, b);
				if (ret != REG_NOERROR) FREE_STACK_RETURN (ret);
			   }

			 /* See if we're at the beginning of a possible character
			    class.  */

			 else if (syntax & RE_CHAR_CLASSES && c == '[' && *p == ':')
			   { /* Leave room for the null.  */
				char str[CHAR_CLASS_MAX_LENGTH + 1];

				PATFETCH (c);
				c1 = 0;

				/* If pattern is `[[:'.  */
				if (p == pend) FREE_STACK_RETURN (REG_EBRACK);

				for (;;)
				  {
				    PATFETCH (c);
				    if (c == ':' || c == ']' || p == pend
					   || c1 == CHAR_CLASS_MAX_LENGTH)
					 break;
				    str[c1++] = c;
				  }
				str[c1] = '\0';

				/* If isn't a word bracketed by `[:' and:`]':
				   undo the ending character, the letters, and leave 
				   the leading `:' and `[' (but set bits for them).  */
				if (c == ':' && *p == ']')
				  {
				    int ch;
				    boolean is_alnum = STREQ (str, "alnum");
				    boolean is_alpha = STREQ (str, "alpha");
				    boolean is_blank = STREQ (str, "blank");
				    boolean is_cntrl = STREQ (str, "cntrl");
				    boolean is_digit = STREQ (str, "digit");
				    boolean is_graph = STREQ (str, "graph");
				    boolean is_lower = STREQ (str, "lower");
				    boolean is_print = STREQ (str, "print");
				    boolean is_punct = STREQ (str, "punct");
				    boolean is_space = STREQ (str, "space");
				    boolean is_upper = STREQ (str, "upper");
				    boolean is_xdigit = STREQ (str, "xdigit");
				    
				    if (!IS_CHAR_CLASS (str))
			  FREE_STACK_RETURN (REG_ECTYPE);

				    /* Throw away the ] at the end of the character
					  class.  */
				    PATFETCH (c);					

				    if (p == pend) FREE_STACK_RETURN (REG_EBRACK);

				    for (ch = 0; ch < 1 << BYTEWIDTH; ch++)
					 {
			    /* This was split into 3 if's to
				  avoid an arbitrary limit in some compiler.  */
					   if (   (is_alnum  && ISALNUM (ch))
						  || (is_alpha  && ISALPHA (ch))
						  || (is_blank  && ISBLANK (ch))
						  || (is_cntrl  && ISCNTRL (ch)))
				 SET_LIST_BIT (ch);
			    if (   (is_digit  && ISDIGIT (ch))
						  || (is_graph  && ISGRAPH (ch))
						  || (is_lower  && ISLOWER (ch))
						  || (is_print  && ISPRINT (ch)))
				 SET_LIST_BIT (ch);
			    if (   (is_punct  && ISPUNCT (ch))
						  || (is_space  && ISSPACE (ch))
						  || (is_upper  && ISUPPER (ch))
						  || (is_xdigit && ISXDIGIT (ch)))
				 SET_LIST_BIT (ch);
					 }
				    had_char_class = true;
				  }
				else
				  {
				    c1++;
				    while (c1--)    
					 PATUNFETCH;
				    SET_LIST_BIT ('[');
				    SET_LIST_BIT (':');
				    had_char_class = false;
				  }
			   }
			 else
			   {
				had_char_class = false;
				SET_LIST_BIT (c);
			   }
		    }

		  /* Discard any (non)matching list bytes that are all 0 at the
			end of the map.  Decrease the map-length byte too.  */
		  while ((int) b[-1] > 0 && b[b[-1] - 1] == 0) 
		    b[-1]--; 
		  b += b[-1];
		}
		break;


	case '(':
		if (syntax & RE_NO_BK_PARENS)
		  goto handle_open;
		else
		  goto normal_char;


	   case ')':
		if (syntax & RE_NO_BK_PARENS)
		  goto handle_close;
		else
		  goto normal_char;


	   case '\n':
		if (syntax & RE_NEWLINE_ALT)
		  goto handle_alt;
		else
		  goto normal_char;


	case '|':
		if (syntax & RE_NO_BK_VBAR)
		  goto handle_alt;
		else
		  goto normal_char;


	   case '{':
		 if (syntax & RE_INTERVALS && syntax & RE_NO_BK_BRACES)
		   goto handle_interval;
		 else
		   goto normal_char;


	   case '\\':
		if (p == pend) FREE_STACK_RETURN (REG_EESCAPE);

		/* Do not translate the character after the \, so that we can
		   distinguish, e.g., \B from \b, even if we normally would
		   translate, e.g., B to b.  */
		PATFETCH_RAW (c);

		switch (c)
		  {
		  case '(':
		    if (syntax & RE_NO_BK_PARENS)
			 goto normal_backslash;

		  handle_open:
		    bufp->re_nsub++;
		    regnum++;

		    if (COMPILE_STACK_FULL)
			 { 
			   RETALLOC (compile_stack.stack, compile_stack.size << 1,
					   compile_stack_elt_t);
			   if (compile_stack.stack == NULL) return REG_ESPACE;

			   compile_stack.size <<= 1;
			 }

		    /* These are the values to restore when we hit end of this
			  group.  They are all relative offsets, so that if the
			  whole pattern moves because of realloc, they will still
			  be valid.  */
		    COMPILE_STACK_TOP.begalt_offset = begalt - bufp->buffer;
		    COMPILE_STACK_TOP.fixup_alt_jump 
			 = fixup_alt_jump ? fixup_alt_jump - bufp->buffer + 1 : 0;
		    COMPILE_STACK_TOP.laststart_offset = b - bufp->buffer;
		    COMPILE_STACK_TOP.regnum = regnum;

		    /* We will eventually replace the 0 with the number of
			  groups inner to this one.  But do not push a
			  start_memory for groups beyond the last one we can
			  represent in the compiled pattern.  */
		    if (regnum <= MAX_REGNUM)
			 {
			   COMPILE_STACK_TOP.inner_group_offset = b - bufp->buffer + 2;
			   BUF_PUSH_3 (start_memory, regnum, 0);
			 }
			 
		    compile_stack.avail++;

		    fixup_alt_jump = 0;
		    laststart = 0;
		    begalt = b;
		 /* If we've reached MAX_REGNUM groups, then this open
		 won't actually generate any code, so we'll have to
		 clear pending_exact explicitly.  */
		 pending_exact = 0;
		    break;


		  case ')':
		    if (syntax & RE_NO_BK_PARENS) goto normal_backslash;

		    if (COMPILE_STACK_EMPTY)
			 if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
			   goto normal_backslash;
			 else
			   FREE_STACK_RETURN (REG_ERPAREN);

		  handle_close:
		    if (fixup_alt_jump)
			 { /* Push a dummy failure point at the end of the
				 alternative for a possible future
				 `pop_failure_jump' to pop.  See comments at
				 `push_dummy_failure' in `re_match_2'.  */
			   BUF_PUSH (push_dummy_failure);
			   
			   /* We allocated space for this jump when we assigned
				 to `fixup_alt_jump', in the `handle_alt' case below.  */
			   STORE_JUMP (jump_past_alt, fixup_alt_jump, b - 1);
			 }

		    /* See similar code for backslashed left paren above.  */
		    if (COMPILE_STACK_EMPTY)
			 if (syntax & RE_UNMATCHED_RIGHT_PAREN_ORD)
			   goto normal_char;
			 else
			   FREE_STACK_RETURN (REG_ERPAREN);

		    /* Since we just checked for an empty stack above, this
			  ``can't happen''.  */
		    assert (compile_stack.avail != 0);
		    {
			 /* We don't just want to restore into `regnum', because
			    later groups should continue to be numbered higher,
			    as in `(ab)c(de)' -- the second group is #2.  */
			 regnum_t this_group_regnum;

			 compile_stack.avail--;		
			 begalt = bufp->buffer + COMPILE_STACK_TOP.begalt_offset;
			 fixup_alt_jump
			   = COMPILE_STACK_TOP.fixup_alt_jump
				? bufp->buffer + COMPILE_STACK_TOP.fixup_alt_jump - 1 
				: 0;
			 laststart = bufp->buffer + COMPILE_STACK_TOP.laststart_offset;
			 this_group_regnum = COMPILE_STACK_TOP.regnum;
		/* If we've reached MAX_REGNUM groups, then this open
		   won't actually generate any code, so we'll have to
		   clear pending_exact explicitly.  */
		pending_exact = 0;

			 /* We're at the end of the group, so now we know how many
			    groups were inside this one.  */
			 if (this_group_regnum <= MAX_REGNUM)
			   {
				unsigned char *inner_group_loc
				  = bufp->buffer + COMPILE_STACK_TOP.inner_group_offset;
				
				*inner_group_loc = regnum - this_group_regnum;
				BUF_PUSH_3 (stop_memory, this_group_regnum,
						  regnum - this_group_regnum);
			   }
		    }
		    break;


		  case '|':					/* `\|'.  */
		    if (syntax & RE_LIMITED_OPS || syntax & RE_NO_BK_VBAR)
			 goto normal_backslash;
		  handle_alt:
		    if (syntax & RE_LIMITED_OPS)
			 goto normal_char;

		    /* Insert before the previous alternative a jump which
			  jumps to this alternative if the former fails.  */
		    GET_BUFFER_SPACE (3);
		    INSERT_JUMP (on_failure_jump, begalt, b + 6);
		    pending_exact = 0;
		    b += 3;

		    /* The alternative before this one has a jump after it
			  which gets executed if it gets matched.  Adjust that
			  jump so it will jump to this alternative's analogous
			  jump (put in below, which in turn will jump to the next
			  (if any) alternative's such jump, etc.).  The last such
			  jump jumps to the correct final destination.  A picture:
					 _____ _____ 
					 |   | |   |   
					 |   v |   v 
					a | b   | c   

			  If we are at `b', then fixup_alt_jump right now points to a
			  three-byte space after `a'.  We'll put in the jump, set
			  fixup_alt_jump to right after `b', and leave behind three
			  bytes which we'll fill in when we get to after `c'.  */

		    if (fixup_alt_jump)
			 STORE_JUMP (jump_past_alt, fixup_alt_jump, b);

		    /* Mark and leave space for a jump after this alternative,
			  to be filled in later either by next alternative or
			  when know we're at the end of a series of alternatives.  */
		    fixup_alt_jump = b;
		    GET_BUFFER_SPACE (3);
		    b += 3;

		    laststart = 0;
		    begalt = b;
		    break;


		  case '{': 
		    /* If \{ is a literal.  */
		    if (!(syntax & RE_INTERVALS)
				 /* If we're at `\{' and it's not the open-interval 
				    operator.  */
			   || ((syntax & RE_INTERVALS) && (syntax & RE_NO_BK_BRACES))
			   || (p - 2 == pattern  &&  p == pend))
			 goto normal_backslash;

		  handle_interval:
		    {
			 /* If got here, then the syntax allows intervals.  */

			 /* At least (most) this many matches must be made.  */
			 int lower_bound = -1, upper_bound = -1;

			 beg_interval = p - 1;

			 if (p == pend)
			   {
				if (syntax & RE_NO_BK_BRACES)
				  goto unfetch_interval;
				else
				  FREE_STACK_RETURN (REG_EBRACE);
			   }

			 GET_UNSIGNED_NUMBER (lower_bound);

			 if (c == ',')
			   {
				GET_UNSIGNED_NUMBER (upper_bound);
				if (upper_bound < 0) upper_bound = RE_DUP_MAX;
			   }
			 else
			   /* Interval such as `{1}' => match exactly once. */
			   upper_bound = lower_bound;

			 if (lower_bound < 0 || upper_bound > RE_DUP_MAX
				|| lower_bound > upper_bound)
			   {
				if (syntax & RE_NO_BK_BRACES)
				  goto unfetch_interval;
				else 
				  FREE_STACK_RETURN (REG_BADBR);
			   }

			 if (!(syntax & RE_NO_BK_BRACES)) 
			   {
				if (c != '\\') FREE_STACK_RETURN (REG_EBRACE);

				PATFETCH (c);
			   }

			 if (c != '}')
			   {
				if (syntax & RE_NO_BK_BRACES)
				  goto unfetch_interval;
				else 
				  FREE_STACK_RETURN (REG_BADBR);
			   }

			 /* We just parsed a valid interval.  */

			 /* If it's invalid to have no preceding re.  */
			 if (!laststart)
			   {
				if (syntax & RE_CONTEXT_INVALID_OPS)
				  FREE_STACK_RETURN (REG_BADRPT);
				else if (syntax & RE_CONTEXT_INDEP_OPS)
				  laststart = b;
				else
				  goto unfetch_interval;
			   }

			 /* If the upper bound is zero, don't want to succeed at
			    all; jump from `laststart' to `b + 3', which will be
			    the end of the buffer after we insert the jump.  */
			  if (upper_bound == 0)
			    {
				 GET_BUFFER_SPACE (3);
				 INSERT_JUMP (jump, laststart, b + 3);
				 b += 3;
			    }

			  /* Otherwise, we have a nontrivial interval.  When
				we're all done, the pattern will look like:
				  set_number_at  
				  set_number_at  
				  succeed_n  
				  
				  jump_n  
				(The upper bound and `jump_n' are omitted if
				`upper_bound' is 1, though.)  */
			  else 
			    { /* If the upper bound is > 1, we need to insert
				    more at the end of the loop.  */
				 unsigned nbytes = 10 + (upper_bound > 1) * 10;

				 GET_BUFFER_SPACE (nbytes);

				 /* Initialize lower bound of the `succeed_n', even
				    though it will be set during matching by its
				    attendant `set_number_at' (inserted next),
				    because `re_compile_fastmap' needs to know.
				    Jump to the `jump_n' we might insert below.  */
				 INSERT_JUMP2 (succeed_n, laststart,
							b + 5 + (upper_bound > 1) * 5,
							lower_bound);
				 b += 5;

				 /* Code to initialize the lower bound.  Insert 
				    before the `succeed_n'.  The `5' is the last two
				    bytes of this `set_number_at', plus 3 bytes of
				    the following `succeed_n'.  */
				 insert_op2 (set_number_at, laststart, 5, lower_bound, b);
				 b += 5;

				 if (upper_bound > 1)
				   { /* More than one repetition is allowed, so
					   append a backward jump to the `succeed_n'
					   that starts this interval.
					   
					   When we've reached this during matching,
					   we'll have matched the interval once, so
					   jump back only `upper_bound - 1' times.  */
					STORE_JUMP2 (jump_n, b, laststart + 5,
							   upper_bound - 1);
					b += 5;

					/* The location we want to set is the second
					   parameter of the `jump_n'; that is `b-2' as
					   an absolute address.  `laststart' will be
					   the `set_number_at' we're about to insert;
					   `laststart+3' the number to set, the source
					   for the relative address.  But we are
					   inserting into the middle of the pattern --
					   so everything is getting moved up by 5.
					   Conclusion: (b - 2) - (laststart + 3) + 5,
					   i.e., b - laststart.
					   
					   We insert this at the beginning of the loop
					   so that if we fail during matching, we'll
					   reinitialize the bounds.  */
					insert_op2 (set_number_at, laststart, b - laststart,
							  upper_bound - 1, b);
					b += 5;
				   }
			    }
			 pending_exact = 0;
			 beg_interval = NULL;
		    }
		    break;

		  unfetch_interval:
		    /* If an invalid interval, match the characters as literals.  */
			assert (beg_interval);
			p = beg_interval;
			beg_interval = NULL;

			/* normal_char and normal_backslash need `c'.  */
			PATFETCH (c);	

			if (!(syntax & RE_NO_BK_BRACES))
			  {
			    if (p > pattern  &&  p[-1] == '\\')
				 goto normal_backslash;
			  }
			goto normal_char;

#ifdef emacs
		  /* There is no way to specify the before_dot and after_dot
			operators.  rms says this is ok.  --karl  */
		  case '=':
		    BUF_PUSH (at_dot);
		    break;

		  case 's':	
		    laststart = b;
		    PATFETCH (c);
		    BUF_PUSH_2 (syntaxspec, syntax_spec_code[c]);
		    break;

		  case 'S':
		    laststart = b;
		    PATFETCH (c);
		    BUF_PUSH_2 (notsyntaxspec, syntax_spec_code[c]);
		    break;
#endif /* emacs */


		  case 'w':
		    laststart = b;
		    BUF_PUSH (wordchar);
		    break;


		  case 'W':
		    laststart = b;
		    BUF_PUSH (notwordchar);
		    break;


		  case '<':
		    BUF_PUSH (wordbeg);
		    break;

		  case '>':
		    BUF_PUSH (wordend);
		    break;

		  case 'b':
		    BUF_PUSH (wordbound);
		    break;

		  case 'B':
		    BUF_PUSH (notwordbound);
		    break;

		  case '`':
		    BUF_PUSH (begbuf);
		    break;

		  case '\'':
		    BUF_PUSH (endbuf);
		    break;

		  case '1': case '2': case '3': case '4': case '5':
		  case '6': case '7': case '8': case '9':
		    if (syntax & RE_NO_BK_REFS)
			 goto normal_char;

		    c1 = c - '0';

		    if (c1 > regnum)
			 FREE_STACK_RETURN (REG_ESUBREG);

		    /* Can't back reference to a subexpression if inside of it.  */
		    if (group_in_compile_stack (compile_stack, c1))
			 goto normal_char;

		    laststart = b;
		    BUF_PUSH_2 (duplicate, c1);
		    break;


		  case '+':
		  case '?':
		    if (syntax & RE_BK_PLUS_QM)
			 goto handle_plus;
		    else
			 goto normal_backslash;

		  default:
		  normal_backslash:
		    /* You might think it would be useful for \ to mean
			  not to translate; but if we don't translate it
			  it will never match anything.  */
		    c = TRANSLATE (c);
		    goto normal_char;
		  }
		break;


	default:
	   /* Expects the character in `c'.  */
	normal_char:
		 /* If no exactn currently being built.  */
		if (!pending_exact 

		    /* If last exactn not at current position.  */
		    || pending_exact + *pending_exact + 1 != b
		    
		    /* We have only one byte following the exactn for the count.  */
		 || *pending_exact == (1 << BYTEWIDTH) - 1

		    /* If followed by a repetition operator.  */
		    || *p == '*' || *p == '^'
		 || ((syntax & RE_BK_PLUS_QM)
		  ? *p == '\\' && (p[1] == '+' || p[1] == '?')
		  : (*p == '+' || *p == '?'))
		 || ((syntax & RE_INTERVALS)
			   && ((syntax & RE_NO_BK_BRACES)
			 ? *p == '{'
				  : (p[0] == '\\' && p[1] == '{'))))
	    {
		 /* Start building a new exactn.  */
		    
		    laststart = b;

		 BUF_PUSH_2 (exactn, 0);
		 pending_exact = b - 1;
		  }
		  
	  BUF_PUSH (c);
		(*pending_exact)++;
	  break;
	   } /* switch (c) */
    } /* while p != pend */

  
  /* Through the pattern now.  */
  
  if (fixup_alt_jump)
    STORE_JUMP (jump_past_alt, fixup_alt_jump, b);

  if (!COMPILE_STACK_EMPTY) 
    FREE_STACK_RETURN (REG_EPAREN);

  /* If we don't want backtracking, force success
	the first time we reach the end of the compiled pattern.  */
  if (syntax & RE_NO_POSIX_BACKTRACKING)
    BUF_PUSH (succeed);

  free (compile_stack.stack);

  /* We have succeeded; set the length of the buffer.  */
  bufp->used = b - bufp->buffer;

#ifdef DEBUG
  if (debug)
    {
	 DEBUG_PRINT1 ("\nCompiled pattern: \n");
	 print_compiled_pattern (bufp);
    }
#endif /* DEBUG */

#ifndef MATCH_MAY_ALLOCATE
  /* Initialize the failure stack to the largest possible stack.  This
	isn't necessary unless we're trying to avoid calling alloca in
	the search and match routines.  */
  {
    int num_regs = bufp->re_nsub + 1;

    /* Since DOUBLE_FAIL_STACK refuses to double only if the current size
	  is strictly greater than re_max_failures, the largest possible stack
	  is 2 * re_max_failures failure points.  */
    if (fail_stack.size < (2 * re_max_failures * MAX_FAILURE_ITEMS))
	 {
	fail_stack.size = (2 * re_max_failures * MAX_FAILURE_ITEMS);

#ifdef emacs
	if (! fail_stack.stack)
	  fail_stack.stack
	    = (fail_stack_elt_t *) xmalloc (fail_stack.size 
					    * sizeof (fail_stack_elt_t));
	else
	  fail_stack.stack
	    = (fail_stack_elt_t *) xrealloc (fail_stack.stack,
						(fail_stack.size
						 * sizeof (fail_stack_elt_t)));
#else /* not emacs */
	if (! fail_stack.stack)
	  fail_stack.stack
	    = (fail_stack_elt_t *) malloc (fail_stack.size 
					   * sizeof (fail_stack_elt_t));
	else
	  fail_stack.stack
	    = (fail_stack_elt_t *) realloc (fail_stack.stack,
					    (fail_stack.size
						* sizeof (fail_stack_elt_t)));
#endif /* not emacs */
	 }

    regex_grow_registers (num_regs);
  }
#endif /* not MATCH_MAY_ALLOCATE */

  return REG_NOERROR;
} /* regex_compile */

/* Subroutines for `regex_compile'.  */

/* Store OP at LOC followed by two-byte integer parameter ARG.  */

static void
store_op1 (op, loc, arg)
    re_opcode_t op;
    unsigned char *loc;
    int arg;
{
  *loc = (unsigned char) op;
  STORE_NUMBER (loc + 1, arg);
}


/* Like `store_op1', but for two two-byte parameters ARG1 and ARG2.  */

static void
store_op2 (op, loc, arg1, arg2)
    re_opcode_t op;
    unsigned char *loc;
    int arg1, arg2;
{
  *loc = (unsigned char) op;
  STORE_NUMBER (loc + 1, arg1);
  STORE_NUMBER (loc + 3, arg2);
}


/* Copy the bytes from LOC to END to open up three bytes of space at LOC
   for OP followed by two-byte integer parameter ARG.  */

static void
insert_op1 (op, loc, arg, end)
    re_opcode_t op;
    unsigned char *loc;
    int arg;
    unsigned char *end;    
{
  register unsigned char *pfrom = end;
  register unsigned char *pto = end + 3;

  while (pfrom != loc)
    *--pto = *--pfrom;
    
  store_op1 (op, loc, arg);
}


/* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2.  */

static void
insert_op2 (op, loc, arg1, arg2, end)
    re_opcode_t op;
    unsigned char *loc;
    int arg1, arg2;
    unsigned char *end;    
{
  register unsigned char *pfrom = end;
  register unsigned char *pto = end + 5;

  while (pfrom != loc)
    *--pto = *--pfrom;
    
  store_op2 (op, loc, arg1, arg2);
}


/* P points to just after a ^ in PATTERN.  Return true if that ^ comes
   after an alternative or a begin-subexpression.  We assume there is at
   least one character before the ^.  */

static boolean
at_begline_loc_p (pattern, p, syntax)
    const char *pattern, *p;
    reg_syntax_t syntax;
{
  const char *prev = p - 2;
  boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\';
  
  return
	  /* After a subexpression?  */
	  (*prev == '(' && (syntax & RE_NO_BK_PARENS || prev_prev_backslash))
	  /* After an alternative?  */
    || (*prev == '|' && (syntax & RE_NO_BK_VBAR || prev_prev_backslash));
}


/* The dual of at_begline_loc_p.  This one is for $.  We assume there is
   at least one character after the $, i.e., `P < PEND'.  */

static boolean
at_endline_loc_p (p, pend, syntax)
    const char *p, *pend;
    int syntax;
{
  const char *next = p;
  boolean next_backslash = *next == '\\';
  const char *next_next = p + 1 < pend ? p + 1 : 0;
  
  return
	  /* Before a subexpression?  */
	  (syntax & RE_NO_BK_PARENS ? *next == ')'
	   : next_backslash && next_next && *next_next == ')')
	  /* Before an alternative?  */
    || (syntax & RE_NO_BK_VBAR ? *next == '|'
	   : next_backslash && next_next && *next_next == '|');
}


/* Returns true if REGNUM is in one of COMPILE_STACK's elements and 
   false if it's not.  */

static boolean
group_in_compile_stack (compile_stack, regnum)
    compile_stack_type compile_stack;
    regnum_t regnum;
{
  int this_element;

  for (this_element = compile_stack.avail - 1;  
	  this_element >= 0; 
	  this_element--)
    if (compile_stack.stack[this_element].regnum == regnum)
	 return true;

  return false;
}


/* Read the ending character of a range (in a bracket expression) from the
   uncompiled pattern *P_PTR (which ends at PEND).  We assume the
   starting character is in `P[-2]'.  (`P[-1]' is the character `-'.)
   Then we set the translation of all bits between the starting and
   ending characters (inclusive) in the compiled pattern B.
   
   Return an error code.
   
   We use these short variable names so we can use the same macros as
   `regex_compile' itself.  */

static reg_errcode_t
compile_range (p_ptr, pend, translate, syntax, b)
    const char **p_ptr, *pend;
    char *translate;
    reg_syntax_t syntax;
    unsigned char *b;
{
  unsigned this_char;

  const char *p = *p_ptr;
  int range_start, range_end;
  
  if (p == pend)
    return REG_ERANGE;

  /* Even though the pattern is a signed `char *', we need to fetch
	with unsigned char *'s; if the high bit of the pattern character
	is set, the range endpoints will be negative if we fetch using a
	signed char *.

	We also want to fetch the endpoints without translating them; the 
	appropriate translation is done in the bit-setting loop below.  */
  /* The SVR4 compiler on the 3B2 had trouble with unsigned const char *.  */
  range_start = ((const unsigned char *) p)[-2];
  range_end   = ((const unsigned char *) p)[0];

  /* Have to increment the pointer into the pattern string, so the
	caller isn't still at the ending character.  */
  (*p_ptr)++;

  /* If the start is after the end, the range is empty.  */
  if (range_start > range_end)
    return syntax & RE_NO_EMPTY_RANGES ? REG_ERANGE : REG_NOERROR;

  /* Here we see why `this_char' has to be larger than an `unsigned
	char' -- the range is inclusive, so if `range_end' == 0xff
	(assuming 8-bit characters), we would otherwise go into an infinite
	loop, since all characters <= 0xff.  */
  for (this_char = range_start; this_char <= range_end; this_char++)
    {
	 SET_LIST_BIT (TRANSLATE (this_char));
    }
  
  return REG_NOERROR;
}

/* re_compile_fastmap computes a ``fastmap'' for the compiled pattern in
   BUFP.  A fastmap records which of the (1 << BYTEWIDTH) possible
   characters can start a string that matches the pattern.  This fastmap
   is used by re_search to skip quickly over impossible starting points.

   The caller must supply the address of a (1 << BYTEWIDTH)-byte data
   area as BUFP->fastmap.
   
   We set the `fastmap', `fastmap_accurate', and `can_be_null' fields in
   the pattern buffer.

   Returns 0 if we succeed, -2 if an internal error.   */

int
re_compile_fastmap (bufp)
	struct re_pattern_buffer *bufp;
{
  int j, k;
#ifdef MATCH_MAY_ALLOCATE
  fail_stack_type fail_stack;
#endif
#ifndef REGEX_MALLOC
  char *destination;
#endif
  /* We don't push any register information onto the failure stack.  */
  unsigned num_regs = 0;
  
  register char *fastmap = bufp->fastmap;
  unsigned char *pattern = bufp->buffer;
  unsigned long size = bufp->used;
  unsigned char *p = pattern;
  register unsigned char *pend = pattern + size;

#ifdef REL_ALLOC
  /* This holds the pointer to the failure stack, when
	it is allocated relocatably.  */
  fail_stack_elt_t *failure_stack_ptr;
#endif

  /* Assume that each path through the pattern can be null until
	proven otherwise.  We set this false at the bottom of switch
	statement, to which we get only if a particular path doesn't
	match the empty string.  */
  boolean path_can_be_null = true;

  /* We aren't doing a `succeed_n' to begin with.  */
  boolean succeed_n_p = false;

  assert (fastmap != NULL && p != NULL);
  
  INIT_FAIL_STACK ();
  bzero (fastmap, 1 << BYTEWIDTH);  /* Assume nothing's valid.  */
  bufp->fastmap_accurate = 1;	    /* It will be when we're done.  */
  bufp->can_be_null = 0;
	 
  while (1)
    {
	 if (p == pend || *p == succeed)
	{
	  /* We have reached the (effective) end of pattern.  */
	  if (!FAIL_STACK_EMPTY ())
	    {
		 bufp->can_be_null |= path_can_be_null;

		 /* Reset for next path.  */
		 path_can_be_null = true;

		 p = fail_stack.stack[--fail_stack.avail].pointer;

		 continue;
	    }
	  else
	    break;
	}

	 /* We should never be about to go beyond the end of the pattern.  */
	 assert (p < pend);
	 
	 switch (SWITCH_ENUM_CAST ((re_opcode_t) *p++))
	{

	   /* I guess the idea here is to simply not bother with a fastmap
		 if a backreference is used, since it's too hard to figure out
		 the fastmap for the corresponding group.  Setting
		 `can_be_null' stops `re_search_2' from using the fastmap, so
		 that is all we do.  */
	case duplicate:
	  bufp->can_be_null = 1;
		goto done;


	 /* Following are the cases which match a character.  These end
	    with `break'.  */

	case exactn:
		fastmap[p[1]] = 1;
	  break;


	   case charset:
		for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
	    if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))
		    fastmap[j] = 1;
	  break;


	case charset_not:
	  /* Chars beyond end of map must be allowed.  */
	  for (j = *p * BYTEWIDTH; j < (1 << BYTEWIDTH); j++)
		  fastmap[j] = 1;

	  for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
	    if (!(p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH))))
		    fastmap[j] = 1;
		break;


	case wordchar:
	  for (j = 0; j < (1 << BYTEWIDTH); j++)
	    if (SYNTAX (j) == Sword)
		 fastmap[j] = 1;
	  break;


	case notwordchar:
	  for (j = 0; j < (1 << BYTEWIDTH); j++)
	    if (SYNTAX (j) != Sword)
		 fastmap[j] = 1;
	  break;


	   case anychar:
	  {
	    int fastmap_newline = fastmap['\n'];

	    /* `.' matches anything ...  */
	    for (j = 0; j < (1 << BYTEWIDTH); j++)
		 fastmap[j] = 1;

	    /* ... except perhaps newline.  */
	    if (!(bufp->syntax & RE_DOT_NEWLINE))
		 fastmap['\n'] = fastmap_newline;

	    /* Return if we have already set `can_be_null'; if we have,
		  then the fastmap is irrelevant.  Something's wrong here.  */
	    else if (bufp->can_be_null)
		 goto done;

	    /* Otherwise, have to check alternative paths.  */
	    break;
	  }

#ifdef emacs
	   case syntaxspec:
	  k = *p++;
	  for (j = 0; j < (1 << BYTEWIDTH); j++)
	    if (SYNTAX (j) == (enum syntaxcode) k)
		 fastmap[j] = 1;
	  break;


	case notsyntaxspec:
	  k = *p++;
	  for (j = 0; j < (1 << BYTEWIDTH); j++)
	    if (SYNTAX (j) != (enum syntaxcode) k)
		 fastmap[j] = 1;
	  break;


	 /* All cases after this match the empty string.  These end with
	    `continue'.  */


	case before_dot:
	case at_dot:
	case after_dot:
		continue;
#endif /* not emacs */


	   case no_op:
	   case begline:
	   case endline:
	case begbuf:
	case endbuf:
	case wordbound:
	case notwordbound:
	case wordbeg:
	case wordend:
	   case push_dummy_failure:
		continue;


	case jump_n:
	   case pop_failure_jump:
	case maybe_pop_jump:
	case jump:
	   case jump_past_alt:
	case dummy_failure_jump:
		EXTRACT_NUMBER_AND_INCR (j, p);
	  p += j;	
	  if (j > 0)
	    continue;
		  
		/* Jump backward implies we just went through the body of a
		   loop and matched nothing.  Opcode jumped to should be
		   `on_failure_jump' or `succeed_n'.  Just treat it like an
		   ordinary jump.  For a * loop, it has pushed its failure
		   point already; if so, discard that as redundant.  */
		if ((re_opcode_t) *p != on_failure_jump
		 && (re_opcode_t) *p != succeed_n)
	    continue;

		p++;
		EXTRACT_NUMBER_AND_INCR (j, p);
		p += j;		
	  
		/* If what's on the stack is where we are now, pop it.  */
		if (!FAIL_STACK_EMPTY () 
		 && fail_stack.stack[fail_stack.avail - 1].pointer == p)
		  fail_stack.avail--;

		continue;


	   case on_failure_jump:
	   case on_failure_keep_string_jump:
	handle_on_failure_jump:
		EXTRACT_NUMBER_AND_INCR (j, p);

		/* For some patterns, e.g., `(a?)?', `p+j' here points to the
		   end of the pattern.  We don't want to push such a point,
		   since when we restore it above, entering the switch will
		   increment `p' past the end of the pattern.  We don't need
		   to push such a point since we obviously won't find any more
		   fastmap entries beyond `pend'.  Such a pattern can match
		   the null string, though.  */
		if (p + j < pend)
		  {
		    if (!PUSH_PATTERN_OP (p + j, fail_stack))
		{
		  RESET_FAIL_STACK ();
		  return -2;
		}
		  }
		else
		  bufp->can_be_null = 1;

		if (succeed_n_p)
		  {
		    EXTRACT_NUMBER_AND_INCR (k, p);	/* Skip the n.  */
		    succeed_n_p = false;
	    }

		continue;


	case succeed_n:
		/* Get to the number of times to succeed.  */
		p += 2;		

		/* Increment p past the n for when k != 0.  */
		EXTRACT_NUMBER_AND_INCR (k, p);
		if (k == 0)
	    {
		    p -= 4;
		 succeed_n_p = true;  /* Spaghetti code alert.  */
		    goto handle_on_failure_jump;
		  }
		continue;


	case set_number_at:
		p += 4;
		continue;


	case start_memory:
	   case stop_memory:
	  p += 2;
	  continue;


	default:
		abort (); /* We have listed all the cases.  */
	   } /* switch *p++ */

	 /* Getting here means we have found the possible starting
	    characters for one path of the pattern -- and that the empty
	    string does not match.  We need not follow this path further.
	    Instead, look at the next alternative (remembered on the
	    stack), or quit if no more.  The test at the top of the loop
	    does these things.  */
	 path_can_be_null = false;
	 p = pend;
    } /* while p */

  /* Set `can_be_null' for the last path (also the first path, if the
	pattern is empty).  */
  bufp->can_be_null |= path_can_be_null;

 done:
  RESET_FAIL_STACK ();
  return 0;
} /* re_compile_fastmap */

/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
   ENDS.  Subsequent matches using PATTERN_BUFFER and REGS will use
   this memory for recording register information.  STARTS and ENDS
   must be allocated using the malloc library routine, and must each
   be at least NUM_REGS * sizeof (regoff_t) bytes long.

   If NUM_REGS == 0, then subsequent matches should allocate their own
   register data.

   Unless this function is called, the first search or match using
   PATTERN_BUFFER will allocate its own register data, without
   freeing the old data.  */

void
re_set_registers (bufp, regs, num_regs, starts, ends)
    struct re_pattern_buffer *bufp;
    struct re_registers *regs;
    unsigned num_regs;
    regoff_t *starts, *ends;
{
  if (num_regs)
    {
	 bufp->regs_allocated = REGS_REALLOCATE;
	 regs->num_regs = num_regs;
	 regs->start = starts;
	 regs->end = ends;
    }
  else
    {
	 bufp->regs_allocated = REGS_UNALLOCATED;
	 regs->num_regs = 0;
	 regs->start = regs->end = (regoff_t *) 0;
    }
}

/* Searching routines.  */

/* Like re_search_2, below, but only one string is specified, and
   doesn't let you say where to stop matching. */

int
re_search (bufp, string, size, startpos, range, regs)
	struct re_pattern_buffer *bufp;
	const char *string;
	int size, startpos, range;
	struct re_registers *regs;
{
  return re_search_2 (bufp, NULL, 0, string, size, startpos, range, 
			 regs, size);
}


/* Using the compiled pattern in BUFP->buffer, first tries to match the
   virtual concatenation of STRING1 and STRING2, starting first at index
   STARTPOS, then at STARTPOS + 1, and so on.
   
   STRING1 and STRING2 have length SIZE1 and SIZE2, respectively.
   
   RANGE is how far to scan while trying to match.  RANGE = 0 means try
   only at STARTPOS; in general, the last start tried is STARTPOS +
   RANGE.
   
   In REGS, return the indices of the virtual concatenation of STRING1
   and STRING2 that matched the entire BUFP->buffer and its contained
   subexpressions.
   
   Do not consider matching one past the index STOP in the virtual
   concatenation of STRING1 and STRING2.

   We return either the position in the strings at which the match was
   found, -1 if no match, or -2 if error (such as failure
   stack overflow).  */

int
re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
	struct re_pattern_buffer *bufp;
	const char *string1, *string2;
	int size1, size2;
	int startpos;
	int range;
	struct re_registers *regs;
	int stop;
{
  int val;
  register char *fastmap = bufp->fastmap;
  register char *translate = bufp->translate;
  int total_size = size1 + size2;
  int endpos = startpos + range;

  /* Check for out-of-range STARTPOS.  */
  if (startpos < 0 || startpos > total_size)
    return -1;
    
  /* Fix up RANGE if it might eventually take us outside
	the virtual concatenation of STRING1 and STRING2.  */
  if (endpos < -1)
    range = -1 - startpos;
  else if (endpos > total_size)
    range = total_size - startpos;

  /* If the search isn't to be a backwards one, don't waste time in a
	search for a pattern that must be anchored.  */
  if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0)
    {
	 if (startpos > 0)
	return -1;
	 else
	range = 1;
    }

  /* Update the fastmap now if not correct already.  */
  if (fastmap && !bufp->fastmap_accurate)
    if (re_compile_fastmap (bufp) == -2)
	 return -2;
  
  /* Loop through the string, looking for a place to start matching.  */
  for (;;)
    { 
	 /* If a fastmap is supplied, skip quickly over characters that
	    cannot be the start of a match.  If the pattern can match the
	    null string, however, we don't need to skip characters; we want
	    the first null string.  */
	 if (fastmap && startpos < total_size && !bufp->can_be_null)
	{
	  if (range > 0)	/* Searching forwards.  */
	    {
		 register const char *d;
		 register int lim = 0;
		 int irange = range;

		    if (startpos < size1 && startpos + range >= size1)
			 lim = range - (size1 - startpos);

		 d = (startpos >= size1 ? string2 - size1 : string1) + startpos;
   
		    /* Written out as an if-else to avoid testing `translate'
			  inside the loop.  */
		 if (translate)
			 while (range > lim
				   && !fastmap[(unsigned char)
				   translate[(unsigned char) *d++]])
			   range--;
		 else
			 while (range > lim && !fastmap[(unsigned char) *d++])
			   range--;

		 startpos += irange - range;
	    }
	  else				/* Searching backwards.  */
	    {
		 register char c = (size1 == 0 || startpos >= size1
						   ? string2[startpos - size1] 
						   : string1[startpos]);

		 if (!fastmap[(unsigned char) TRANSLATE (c)])
		goto advance;
	    }
	}

	 /* If can't match the null string, and that's all we have left, fail.  */
	 if (range >= 0 && startpos == total_size && fastmap
		&& !bufp->can_be_null)
	return -1;

	 val = re_match_2_internal (bufp, string1, size1, string2, size2,
				 startpos, regs, stop);
#ifndef REGEX_MALLOC
#ifdef C_ALLOCA
	 alloca (0);
#endif
#endif

	 if (val >= 0)
	return startpos;
	   
	 if (val == -2)
	return -2;

    advance:
	 if (!range) 
	   break;
	 else if (range > 0) 
	   {
		range--; 
		startpos++;
	   }
	 else
	   {
		range++; 
		startpos--;
	   }
    }
  return -1;
} /* re_search_2 */

/* Declarations and macros for re_match_2.  */

static int bcmp_translate ();
static boolean alt_match_null_string_p (),
			common_op_match_null_string_p (),
			group_match_null_string_p ();

/* This converts PTR, a pointer into one of the search strings `string1'
   and `string2' into an offset from the beginning of that string.  */
#define POINTER_TO_OFFSET(ptr)			\
  (FIRST_STRING_P (ptr)				\
   ? ((regoff_t) ((ptr) - string1))		\
   : ((regoff_t) ((ptr) - string2 + size1)))

/* Macros for dealing with the split strings in re_match_2.  */

#define MATCHING_IN_FIRST_STRING  (dend == end_match_1)

/* Call before fetching a character with *d.  This switches over to
   string2 if necessary.  */
#define PREFETCH()							\
  while (d == dend)						    	\
    {									\
	 /* End of string2 => fail.  */					\
	 if (dend == end_match_2) 						\
	   goto fail;							\
	 /* End of string1 => advance to string2.  */ 			\
	 d = string2;						        \
	 dend = end_match_2;						\
    }


/* Test if at very beginning or at very end of the virtual concatenation
   of `string1' and `string2'.  If only one string, it's `string2'.  */
#define AT_STRINGS_BEG(d) ((d) == (size1 ? string1 : string2) || !size2)
#define AT_STRINGS_END(d) ((d) == end2)	


/* Test if D points to a character which is word-constituent.  We have
   two special cases to check for: if past the end of string1, look at
   the first character in string2; and if before the beginning of
   string2, look at the last character in string1.  */
#define WORDCHAR_P(d)							\
  (SYNTAX ((d) == end1 ? *string2					\
		 : (d) == string2 - 1 ? *(end1 - 1) : *(d))			\
   == Sword)

/* Test if the character before D and the one at D differ with respect
   to being word-constituent.  */
#define AT_WORD_BOUNDARY(d)						\
  (AT_STRINGS_BEG (d) || AT_STRINGS_END (d)				\
   || WORDCHAR_P (d - 1) != WORDCHAR_P (d))


/* Free everything we malloc.  */
#ifdef MATCH_MAY_ALLOCATE
#define FREE_VAR(var) if (var) REGEX_FREE (var); var = NULL
#define FREE_VARIABLES()						\
  do {									\
    REGEX_FREE_STACK (fail_stack.stack);				\
    FREE_VAR (regstart);						\
    FREE_VAR (regend);							\
    FREE_VAR (old_regstart);						\
    FREE_VAR (old_regend);						\
    FREE_VAR (best_regstart);						\
    FREE_VAR (best_regend);						\
    FREE_VAR (reg_info);						\
    FREE_VAR (reg_dummy);						\
    FREE_VAR (reg_info_dummy);						\
  } while (0)
#else
#define FREE_VARIABLES() ((void)0) /* Do nothing!  But inhibit gcc warning.  */
#endif /* not MATCH_MAY_ALLOCATE */

/* These values must meet several constraints.  They must not be valid
   register values; since we have a limit of 255 registers (because
   we use only one byte in the pattern for the register number), we can
   use numbers larger than 255.  They must differ by 1, because of
   NUM_FAILURE_ITEMS above.  And the value for the lowest register must
   be larger than the value for the highest register, so we do not try
   to actually save any registers when none are active.  */
#define NO_HIGHEST_ACTIVE_REG (1 << BYTEWIDTH)
#define NO_LOWEST_ACTIVE_REG (NO_HIGHEST_ACTIVE_REG + 1)

/* Matching routines.  */

#ifndef emacs   /* Emacs never uses this.  */
/* re_match is like re_match_2 except it takes only a single string.  */

int
re_match (bufp, string, size, pos, regs)
	struct re_pattern_buffer *bufp;
	const char *string;
	int size, pos;
	struct re_registers *regs;
{
  int result = re_match_2_internal (bufp, NULL, 0, string, size,
				    pos, regs, size);
#ifndef REGEX_MALLOC
  alloca (0);
#endif
  return result;
}
#endif /* not emacs */


/* re_match_2 matches the compiled pattern in BUFP against the
   the (virtual) concatenation of STRING1 and STRING2 (of length SIZE1
   and SIZE2, respectively).  We start matching at POS, and stop
   matching at STOP.
   
   If REGS is non-null and the `no_sub' field of BUFP is nonzero, we
   store offsets for the substring each group matched in REGS.  See the
   documentation for exactly how many groups we fill.

   We return -1 if no match, -2 if an internal error (such as the
   failure stack overflowing).  Otherwise, we return the length of the
   matched substring.  */

int
re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop)
	struct re_pattern_buffer *bufp;
	const char *string1, *string2;
	int size1, size2;
	int pos;
	struct re_registers *regs;
	int stop;
{
  int result = re_match_2_internal (bufp, string1, size1, string2, size2,
				    pos, regs, stop);
#ifndef REGEX_MALLOC
  alloca (0);
#endif
  return result;
}

/* This is a separate function so that we can force an alloca cleanup
   afterwards.  */
static int
re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
	struct re_pattern_buffer *bufp;
	const char *string1, *string2;
	int size1, size2;
	int pos;
	struct re_registers *regs;
	int stop;
{
  /* General temporaries.  */
  int mcnt;
  unsigned char *p1;

  /* Just past the end of the corresponding string.  */
  const char *end1, *end2;

  /* Pointers into string1 and string2, just past the last characters in
	each to consider matching.  */
  const char *end_match_1, *end_match_2;

  /* Where we are in the data, and the end of the current string.  */
  const char *d, *dend;
  
  /* Where we are in the pattern, and the end of the pattern.  */
  unsigned char *p = bufp->buffer;
  register unsigned char *pend = p + bufp->used;

  /* Mark the opcode just after a start_memory, so we can test for an
	empty subpattern when we get to the stop_memory.  */
  unsigned char *just_past_start_mem = 0;

  /* We use this to map every character in the string.  */
  char *translate = bufp->translate;

  /* Failure point stack.  Each place that can handle a failure further
	down the line pushes a failure point on this stack.  It consists of
	restart, regend, and reg_info for all registers corresponding to
	the subexpressions we're currently inside, plus the number of such
	registers, and, finally, two char *'s.  The first char * is where
	to resume scanning the pattern; the second one is where to resume
	scanning the strings.  If the latter is zero, the failure point is
	a ``dummy''; if a failure happens and the failure point is a dummy,
	it gets discarded and the next next one is tried.  */
#ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global.  */
  fail_stack_type fail_stack;
#endif
#ifdef DEBUG
  static unsigned failure_id = 0;
  unsigned nfailure_points_pushed = 0, nfailure_points_popped = 0;
#endif

#ifdef REL_ALLOC
  /* This holds the pointer to the failure stack, when
	it is allocated relocatably.  */
  fail_stack_elt_t *failure_stack_ptr;
#endif

  /* We fill all the registers internally, independent of what we
	return, for use in backreferences.  The number here includes
	an element for register zero.  */
  unsigned num_regs = bufp->re_nsub + 1;
  
  /* The currently active registers.  */
  unsigned lowest_active_reg = NO_LOWEST_ACTIVE_REG;
  unsigned highest_active_reg = NO_HIGHEST_ACTIVE_REG;

  /* Information on the contents of registers. These are pointers into
	the input strings; they record just what was matched (on this
	attempt) by a subexpression part of the pattern, that is, the
	regnum-th regstart pointer points to where in the pattern we began
	matching and the regnum-th regend points to right after where we
	stopped matching the regnum-th subexpression.  (The zeroth register
	keeps track of what the whole pattern matches.)  */
#ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global.  */
  const char **regstart, **regend;
#endif

  /* If a group that's operated upon by a repetition operator fails to
	match anything, then the register for its start will need to be
	restored because it will have been set to wherever in the string we
	are when we last see its open-group operator.  Similarly for a
	register's end.  */
#ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global.  */
  const char **old_regstart, **old_regend;
#endif

  /* The is_active field of reg_info helps us keep track of which (possibly
	nested) subexpressions we are currently in. The matched_something
	field of reg_info[reg_num] helps us tell whether or not we have
	matched any of the pattern so far this time through the reg_num-th
	subexpression.  These two fields get reset each time through any
	loop their register is in.  */
#ifdef MATCH_MAY_ALLOCATE /* otherwise, this is global.  */
  register_info_type *reg_info; 
#endif

  /* The following record the register info as found in the above
	variables when we find a match better than any we've seen before. 
	This happens as we backtrack through the failure points, which in
	turn happens only if we have not yet matched the entire string. */
  unsigned best_regs_set = false;
#ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global.  */
  const char **best_regstart, **best_regend;
#endif
  
  /* Logically, this is `best_regend[0]'.  But we don't want to have to
	allocate space for that if we're not allocating space for anything
	else (see below).  Also, we never need info about register 0 for
	any of the other register vectors, and it seems rather a kludge to
	treat `best_regend' differently than the rest.  So we keep track of
	the end of the best match so far in a separate variable.  We
	initialize this to NULL so that when we backtrack the first time
	and need to test it, it's not garbage.  */
  const char *match_end = NULL;

  /* This helps SET_REGS_MATCHED avoid doing redundant work.  */
  int set_regs_matched_done = 0;

  /* Used when we pop values we don't care about.  */
#ifdef MATCH_MAY_ALLOCATE /* otherwise, these are global.  */
  const char **reg_dummy;
  register_info_type *reg_info_dummy;
#endif

#ifdef DEBUG
  /* Counts the total number of registers pushed.  */
  unsigned num_regs_pushed = 0; 	
#endif

  DEBUG_PRINT1 ("\n\nEntering re_match_2.\n");
  
  INIT_FAIL_STACK ();
  
#ifdef MATCH_MAY_ALLOCATE
  /* Do not bother to initialize all the register variables if there are
	no groups in the pattern, as it takes a fair amount of time.  If
	there are groups, we include space for register 0 (the whole
	pattern), even though we never use it, since it simplifies the
	array indexing.  We should fix this.  */
  if (bufp->re_nsub)
    {
	 regstart = REGEX_TALLOC (num_regs, const char *);
	 regend = REGEX_TALLOC (num_regs, const char *);
	 old_regstart = REGEX_TALLOC (num_regs, const char *);
	 old_regend = REGEX_TALLOC (num_regs, const char *);
	 best_regstart = REGEX_TALLOC (num_regs, const char *);
	 best_regend = REGEX_TALLOC (num_regs, const char *);
	 reg_info = REGEX_TALLOC (num_regs, register_info_type);
	 reg_dummy = REGEX_TALLOC (num_regs, const char *);
	 reg_info_dummy = REGEX_TALLOC (num_regs, register_info_type);

	 if (!(regstart && regend && old_regstart && old_regend && reg_info 
		  && best_regstart && best_regend && reg_dummy && reg_info_dummy)) 
	   {
		FREE_VARIABLES ();
		return -2;
	   }
    }
  else
    {
	 /* We must initialize all our variables to NULL, so that
	    `FREE_VARIABLES' doesn't try to free them.  */
	 regstart = regend = old_regstart = old_regend = best_regstart
	   = best_regend = reg_dummy = NULL;
	 reg_info = reg_info_dummy = (register_info_type *) NULL;
    }
#endif /* MATCH_MAY_ALLOCATE */

  /* The starting position is bogus.  */
  if (pos < 0 || pos > size1 + size2)
    {
	 FREE_VARIABLES ();
	 return -1;
    }
    
  /* Initialize subexpression text positions to -1 to mark ones that no
	start_memory/stop_memory has been seen for. Also initialize the
	register information struct.  */
  for (mcnt = 1; mcnt < num_regs; mcnt++)
    {
	 regstart[mcnt] = regend[mcnt] 
	   = old_regstart[mcnt] = old_regend[mcnt] = REG_UNSET_VALUE;
	   
	 REG_MATCH_NULL_STRING_P (reg_info[mcnt]) = MATCH_NULL_UNSET_VALUE;
	 IS_ACTIVE (reg_info[mcnt]) = 0;
	 MATCHED_SOMETHING (reg_info[mcnt]) = 0;
	 EVER_MATCHED_SOMETHING (reg_info[mcnt]) = 0;
    }
  
  /* We move `string1' into `string2' if the latter's empty -- but not if
	`string1' is null.  */
  if (size2 == 0 && string1 != NULL)
    {
	 string2 = string1;
	 size2 = size1;
	 string1 = 0;
	 size1 = 0;
    }
  end1 = string1 + size1;
  end2 = string2 + size2;

  /* Compute where to stop matching, within the two strings.  */
  if (stop <= size1)
    {
	 end_match_1 = string1 + stop;
	 end_match_2 = string2;
    }
  else
    {
	 end_match_1 = end1;
	 end_match_2 = string2 + stop - size1;
    }

  /* `p' scans through the pattern as `d' scans through the data. 
	`dend' is the end of the input string that `d' points within.  `d'
	is advanced into the following input string whenever necessary, but
	this happens before fetching; therefore, at the beginning of the
	loop, `d' can be pointing at the end of a string, but it cannot
	equal `string2'.  */
  if (size1 > 0 && pos <= size1)
    {
	 d = string1 + pos;
	 dend = end_match_1;
    }
  else
    {
	 d = string2 + pos - size1;
	 dend = end_match_2;
    }

  DEBUG_PRINT1 ("The compiled pattern is: ");
  DEBUG_PRINT_COMPILED_PATTERN (bufp, p, pend);
  DEBUG_PRINT1 ("The string to match is: `");
  DEBUG_PRINT_DOUBLE_STRING (d, string1, size1, string2, size2);
  DEBUG_PRINT1 ("'\n");
  
  /* This loops over pattern commands.  It exits by returning from the
	function if the match is complete, or it drops through if the match
	fails at this starting point in the input data.  */
  for (;;)
    {
	 DEBUG_PRINT2 ("\n0x%x: ", p);

	 if (p == pend)
	{ /* End of pattern means we might have succeeded.  */
		DEBUG_PRINT1 ("end of pattern ... ");
		
	  /* If we haven't matched the entire string, and we want the
		   longest match, try backtracking.  */
		if (d != end_match_2)
	    {
		 /* 1 if this match ends in the same string (string1 or string2)
		 as the best previous match.  */
		 boolean same_str_p = (FIRST_STRING_P (match_end) 
				    == MATCHING_IN_FIRST_STRING);
		 /* 1 if this match is the best seen so far.  */
		 boolean best_match_p;

		 /* AIX compiler got confused when this was combined
		 with the previous declaration.  */
		 if (same_str_p)
		best_match_p = d > match_end;
		 else
		best_match_p = !MATCHING_IN_FIRST_STRING;

		    DEBUG_PRINT1 ("backtracking.\n");
		    
		    if (!FAIL_STACK_EMPTY ())
			 { /* More failure points to try.  */

			   /* If exceeds best match so far, save it.  */
			   if (!best_regs_set || best_match_p)
				{
				  best_regs_set = true;
				  match_end = d;
				  
				  DEBUG_PRINT1 ("\nSAVING match as best so far.\n");
				  
				  for (mcnt = 1; mcnt < num_regs; mcnt++)
				    {
					 best_regstart[mcnt] = regstart[mcnt];
					 best_regend[mcnt] = regend[mcnt];
				    }
				}
			   goto fail;	       
			 }

		    /* If no failure points, don't restore garbage.  And if
			  last match is real best match, don't restore second
			  best one. */
		    else if (best_regs_set && !best_match_p)
			 {
		   restore_best_regs:
			   /* Restore best match.  It may happen that `dend ==
				 end_match_1' while the restored d is in string2.
				 For example, the pattern `x.*y.*z' against the
				 strings `x-' and `y-z-', if the two strings are
				 not consecutive in memory.  */
			   DEBUG_PRINT1 ("Restoring best registers.\n");
			   
			   d = match_end;
			   dend = ((d >= string1 && d <= end1)
				 ? end_match_1 : end_match_2);

		  for (mcnt = 1; mcnt < num_regs; mcnt++)
		    {
			 regstart[mcnt] = best_regstart[mcnt];
			 regend[mcnt] = best_regend[mcnt];
		    }
			 }
		  } /* d != end_match_2 */

	succeed_label:
		DEBUG_PRINT1 ("Accepting match.\n");

		/* If caller wants register contents data back, do it.  */
		if (regs && !bufp->no_sub)
	    {
		    /* Have the register data arrays been allocated?  */
		    if (bufp->regs_allocated == REGS_UNALLOCATED)
			 { /* No.  So allocate them with malloc.  We need one
				 extra element beyond `num_regs' for the `-1' marker
				 GNU code uses.  */
			   regs->num_regs = MAX (RE_NREGS, num_regs + 1);
			   regs->start = TALLOC (regs->num_regs, regoff_t);
			   regs->end = TALLOC (regs->num_regs, regoff_t);
			   if (regs->start == NULL || regs->end == NULL)
		    {
			 FREE_VARIABLES ();
			 return -2;
		    }
			   bufp->regs_allocated = REGS_REALLOCATE;
			 }
		    else if (bufp->regs_allocated == REGS_REALLOCATE)
			 { /* Yes.  If we need more elements than were already
				 allocated, reallocate them.  If we need fewer, just
				 leave it alone.  */
			   if (regs->num_regs < num_regs + 1)
				{
				  regs->num_regs = num_regs + 1;
				  RETALLOC (regs->start, regs->num_regs, regoff_t);
				  RETALLOC (regs->end, regs->num_regs, regoff_t);
				  if (regs->start == NULL || regs->end == NULL)
			{
			  FREE_VARIABLES ();
			  return -2;
			}
				}
			 }
		    else
		{
		  /* These braces fend off a "empty body in an else-statement"
			warning under GCC when assert expands to nothing.  */
		  assert (bufp->regs_allocated == REGS_FIXED);
		}

		    /* Convert the pointer data in `regstart' and `regend' to
			  indices.  Register zero has to be set differently,
			  since we haven't kept track of any info for it.  */
		    if (regs->num_regs > 0)
			 {
			   regs->start[0] = pos;
			   regs->end[0] = (MATCHING_IN_FIRST_STRING
				  ? ((regoff_t) (d - string1))
					: ((regoff_t) (d - string2 + size1)));
			 }
		    
		    /* Go through the first `min (num_regs, regs->num_regs)'
			  registers, since that is all we initialized.  */
		 for (mcnt = 1; mcnt < MIN (num_regs, regs->num_regs); mcnt++)
		{
			   if (REG_UNSET (regstart[mcnt]) || REG_UNSET (regend[mcnt]))
				regs->start[mcnt] = regs->end[mcnt] = -1;
			   else
				{
			 regs->start[mcnt]
			= (regoff_t) POINTER_TO_OFFSET (regstart[mcnt]);
				  regs->end[mcnt]
			= (regoff_t) POINTER_TO_OFFSET (regend[mcnt]);
				}
		}
		    
		    /* If the regs structure we return has more elements than
			  were in the pattern, set the extra elements to -1.  If
			  we (re)allocated the registers, this is the case,
			  because we always allocate enough to have at least one
			  -1 at the end.  */
		    for (mcnt = num_regs; mcnt < regs->num_regs; mcnt++)
			 regs->start[mcnt] = regs->end[mcnt] = -1;
	    } /* regs && !bufp->no_sub */

		DEBUG_PRINT4 ("%u failure points pushed, %u popped (%u remain).\n",
				    nfailure_points_pushed, nfailure_points_popped,
				    nfailure_points_pushed - nfailure_points_popped);
		DEBUG_PRINT2 ("%u registers pushed.\n", num_regs_pushed);

		mcnt = d - pos - (MATCHING_IN_FIRST_STRING 
			    ? string1 
			    : string2 - size1);

		DEBUG_PRINT2 ("Returning %d from re_match_2.\n", mcnt);

		FREE_VARIABLES ();
		return mcnt;
	   }

	 /* Otherwise match next pattern command.  */
	 switch (SWITCH_ENUM_CAST ((re_opcode_t) *p++))
	{
	   /* Ignore these.  Used to ignore the n of succeed_n's which
		 currently have n == 0.  */
	   case no_op:
		DEBUG_PRINT1 ("EXECUTING no_op.\n");
		break;

	case succeed:
		DEBUG_PRINT1 ("EXECUTING succeed.\n");
	  goto succeed_label;

	   /* Match the next n pattern characters exactly.  The following
		 byte in the pattern defines n, and the n bytes after that
		 are the characters to match.  */
	case exactn:
	  mcnt = *p++;
		DEBUG_PRINT2 ("EXECUTING exactn %d.\n", mcnt);

		/* This is written out as an if-else so we don't waste time
		   testing `translate' inside the loop.  */
		if (translate)
	    {
		 do
		{
		  PREFETCH ();
		  if (translate[(unsigned char) *d++] != (char) *p++)
				goto fail;
		}
		 while (--mcnt);
	    }
	  else
	    {
		 do
		{
		  PREFETCH ();
		  if (*d++ != (char) *p++) goto fail;
		}
		 while (--mcnt);
	    }
	  SET_REGS_MATCHED ();
		break;


	   /* Match any character except possibly a newline or a null.  */
	case anychar:
		DEBUG_PRINT1 ("EXECUTING anychar.\n");

		PREFETCH ();

		if ((!(bufp->syntax & RE_DOT_NEWLINE) && TRANSLATE (*d) == '\n')
		    || (bufp->syntax & RE_DOT_NOT_NULL && TRANSLATE (*d) == '\000'))
	    goto fail;

		SET_REGS_MATCHED ();
		DEBUG_PRINT2 ("  Matched `%d'.\n", *d);
		d++;
	  break;


	case charset:
	case charset_not:
	  {
	    register unsigned char c;
	    boolean not = (re_opcode_t) *(p - 1) == charset_not;

		  DEBUG_PRINT2 ("EXECUTING charset%s.\n", not ? "_not" : "");

	    PREFETCH ();
	    c = TRANSLATE (*d); /* The character to match.  */

		  /* Cast to `unsigned' instead of `unsigned char' in case the
			bit list is a full 32 bytes long.  */
	    if (c < (unsigned) (*p * BYTEWIDTH)
		&& p[1 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
		 not = !not;

	    p += 1 + *p;

	    if (!not) goto fail;
		  
	    SET_REGS_MATCHED ();
		  d++;
	    break;
	  }


	   /* The beginning of a group is represented by start_memory.
		 The arguments are the register number in the next byte, and the
		 number of groups inner to this one in the next.  The text
		 matched within the group is recorded (in the internal
		 registers data structure) under the register number.  */
	   case start_memory:
	  DEBUG_PRINT3 ("EXECUTING start_memory %d (%d):\n", *p, p[1]);

		/* Find out if this group can match the empty string.  */
	  p1 = p;		/* To send to group_match_null_string_p.  */
		
		if (REG_MATCH_NULL_STRING_P (reg_info[*p]) == MATCH_NULL_UNSET_VALUE)
		  REG_MATCH_NULL_STRING_P (reg_info[*p]) 
		    = group_match_null_string_p (&p1, pend, reg_info);

		/* Save the position in the string where we were the last time
		   we were at this open-group operator in case the group is
		   operated upon by a repetition operator, e.g., with `(a*)*b'
		   against `ab'; then we want to ignore where we are now in
		   the string in case this attempt to match fails.  */
		old_regstart[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
					    ? REG_UNSET (regstart[*p]) ? d : regstart[*p]
					    : regstart[*p];
	  DEBUG_PRINT2 ("  old_regstart: %d\n", 
			 POINTER_TO_OFFSET (old_regstart[*p]));

		regstart[*p] = d;
	  DEBUG_PRINT2 ("  regstart: %d\n", POINTER_TO_OFFSET (regstart[*p]));

		IS_ACTIVE (reg_info[*p]) = 1;
		MATCHED_SOMETHING (reg_info[*p]) = 0;

	  /* Clear this whenever we change the register activity status.  */
	  set_regs_matched_done = 0;
		
		/* This is the new highest active register.  */
		highest_active_reg = *p;
		
		/* If nothing was active before, this is the new lowest active
		   register.  */
		if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
		  lowest_active_reg = *p;

		/* Move past the register number and inner group count.  */
		p += 2;
	  just_past_start_mem = p;

		break;


	   /* The stop_memory opcode represents the end of a group.  Its
		 arguments are the same as start_memory's: the register
		 number, and the number of inner groups.  */
	case stop_memory:
	  DEBUG_PRINT3 ("EXECUTING stop_memory %d (%d):\n", *p, p[1]);
		   
		/* We need to save the string position the last time we were at
		   this close-group operator in case the group is operated
		   upon by a repetition operator, e.g., with `((a*)*(b*)*)*'
		   against `aba'; then we want to ignore where we are now in
		   the string in case this attempt to match fails.  */
		old_regend[*p] = REG_MATCH_NULL_STRING_P (reg_info[*p])
					  ? REG_UNSET (regend[*p]) ? d : regend[*p]
			   : regend[*p];
	  DEBUG_PRINT2 ("      old_regend: %d\n", 
			 POINTER_TO_OFFSET (old_regend[*p]));

		regend[*p] = d;
	  DEBUG_PRINT2 ("      regend: %d\n", POINTER_TO_OFFSET (regend[*p]));

		/* This register isn't active anymore.  */
		IS_ACTIVE (reg_info[*p]) = 0;

	  /* Clear this whenever we change the register activity status.  */
	  set_regs_matched_done = 0;

		/* If this was the only register active, nothing is active
		   anymore.  */
		if (lowest_active_reg == highest_active_reg)
		  {
		    lowest_active_reg = NO_LOWEST_ACTIVE_REG;
		    highest_active_reg = NO_HIGHEST_ACTIVE_REG;
		  }
		else
		  { /* We must scan for the new highest active register, since
			  it isn't necessarily one less than now: consider
			  (a(b)c(d(e)f)g).  When group 3 ends, after the f), the
			  new highest active register is 1.  */
		    unsigned char r = *p - 1;
		    while (r > 0 && !IS_ACTIVE (reg_info[r]))
			 r--;
		    
		    /* If we end up at register zero, that means that we saved
			  the registers as the result of an `on_failure_jump', not
			  a `start_memory', and we jumped to past the innermost
			  `stop_memory'.  For example, in ((.)*) we save
			  registers 1 and 2 as a result of the *, but when we pop
			  back to the second ), we are at the stop_memory 1.
			  Thus, nothing is active.  */
		 if (r == 0)
			 {
			   lowest_active_reg = NO_LOWEST_ACTIVE_REG;
			   highest_active_reg = NO_HIGHEST_ACTIVE_REG;
			 }
		    else
			 highest_active_reg = r;
		  }
		
		/* If just failed to match something this time around with a
		   group that's operated on by a repetition operator, try to
		   force exit from the ``loop'', and restore the register
		   information for this group that we had before trying this
		   last match.  */
		if ((!MATCHED_SOMETHING (reg_info[*p])
			|| just_past_start_mem == p - 1)
		 && (p + 2) < pend)              
		  {
		    boolean is_a_jump_n = false;
		    
		    p1 = p + 2;
		    mcnt = 0;
		    switch ((re_opcode_t) *p1++)
			 {
			   case jump_n:
		    is_a_jump_n = true;
			   case pop_failure_jump:
		  case maybe_pop_jump:
		  case jump:
		  case dummy_failure_jump:
				EXTRACT_NUMBER_AND_INCR (mcnt, p1);
		    if (is_a_jump_n)
			 p1 += 2;
				break;
			   
			   default:
				/* do nothing */ ;
			 }
		 p1 += mcnt;
	   
		    /* If the next operation is a jump backwards in the pattern
		    to an on_failure_jump right before the start_memory
			  corresponding to this stop_memory, exit from the loop
			  by forcing a failure after pushing on the stack the
			  on_failure_jump's jump in the pattern, and d.  */
		    if (mcnt < 0 && (re_opcode_t) *p1 == on_failure_jump
			   && (re_opcode_t) p1[3] == start_memory && p1[4] == *p)
		{
			   /* If this group ever matched anything, then restore
				 what its registers were before trying this last
				 failed match, e.g., with `(a*)*b' against `ab' for
				 regstart[1], and, e.g., with `((a*)*(b*)*)*'
				 against `aba' for regend[3].
				 
				 Also restore the registers for inner groups for,
				 e.g., `((a*)(b*))*' against `aba' (register 3 would
				 otherwise get trashed).  */
				 
			   if (EVER_MATCHED_SOMETHING (reg_info[*p]))
		    {
			 unsigned r; 
	   
				  EVER_MATCHED_SOMETHING (reg_info[*p]) = 0;
				  
			 /* Restore this and inner groups' (if any) registers.  */
				  for (r = *p; r < *p + *(p + 1); r++)
				    {
					 regstart[r] = old_regstart[r];

					 /* xx why this test?  */
					 if (old_regend[r] >= regstart[r])
					   regend[r] = old_regend[r];
				    }     
				}
		  p1++;
			   EXTRACT_NUMBER_AND_INCR (mcnt, p1);
			   PUSH_FAILURE_POINT (p1 + mcnt, d, -2);

			   goto fail;
			 }
		  }
		
		/* Move past the register number and the inner group count.  */
		p += 2;
		break;


	/* \ has been turned into a `duplicate' command which is
		 followed by the numeric value of  as the register number.  */
	   case duplicate:
	  {
	    register const char *d2, *dend2;
	    int regno = *p++;   /* Get which register to match against.  */
	    DEBUG_PRINT2 ("EXECUTING duplicate %d.\n", regno);

	    /* Can't back reference a group which we've never matched.  */
		  if (REG_UNSET (regstart[regno]) || REG_UNSET (regend[regno]))
		    goto fail;
		    
		  /* Where in input to try to start matching.  */
		  d2 = regstart[regno];
		  
		  /* Where to stop matching; if both the place to start and
			the place to stop matching are in the same string, then
			set to the place to stop, otherwise, for now have to use
			the end of the first string.  */

		  dend2 = ((FIRST_STRING_P (regstart[regno]) 
			 == FIRST_STRING_P (regend[regno]))
			? regend[regno] : end_match_1);
	    for (;;)
		 {
		/* If necessary, advance to next segment in register
			    contents.  */
		while (d2 == dend2)
		  {
		    if (dend2 == end_match_2) break;
		    if (dend2 == regend[regno]) break;

				/* End of string1 => advance to string2. */
				d2 = string2;
				dend2 = regend[regno];
		  }
		/* At end of register contents => success */
		if (d2 == dend2) break;

		/* If necessary, advance to next segment in data.  */
		PREFETCH ();

		/* How many characters left in this segment to match.  */
		mcnt = dend - d;
			 
		/* Want how many consecutive characters we can match in
			    one shot, so, if necessary, adjust the count.  */
			 if (mcnt > dend2 - d2)
		  mcnt = dend2 - d2;
			   
		/* Compare that many; failure if mismatch, else move
			    past them.  */
		if (translate 
				? bcmp_translate (d, d2, mcnt, translate) 
				: bcmp (d, d2, mcnt))
		  goto fail;
		d += mcnt, d2 += mcnt;

		/* Do this because we've match some characters.  */
		SET_REGS_MATCHED ();
		 }
	  }
	  break;


	   /* begline matches the empty string at the beginning of the string
		 (unless `not_bol' is set in `bufp'), and, if
		 `newline_anchor' is set, after newlines.  */
	case begline:
		DEBUG_PRINT1 ("EXECUTING begline.\n");
		
		if (AT_STRINGS_BEG (d))
		  {
		    if (!bufp->not_bol) break;
		  }
		else if (d[-1] == '\n' && bufp->newline_anchor)
		  {
		    break;
		  }
		/* In all other cases, we fail.  */
		goto fail;


	   /* endline is the dual of begline.  */
	case endline:
		DEBUG_PRINT1 ("EXECUTING endline.\n");

		if (AT_STRINGS_END (d))
		  {
		    if (!bufp->not_eol) break;
		  }
		
		/* We have to ``prefetch'' the next character.  */
		else if ((d == end1 ? *string2 : *d) == '\n'
			    && bufp->newline_anchor)
		  {
		    break;
		  }
		goto fail;


	/* Match at the very beginning of the data.  */
	   case begbuf:
		DEBUG_PRINT1 ("EXECUTING begbuf.\n");
		if (AT_STRINGS_BEG (d))
		  break;
		goto fail;


	/* Match at the very end of the data.  */
	   case endbuf:
		DEBUG_PRINT1 ("EXECUTING endbuf.\n");
	  if (AT_STRINGS_END (d))
	    break;
		goto fail;


	   /* on_failure_keep_string_jump is used to optimize `.*\n'.  It
		 pushes NULL as the value for the string on the stack.  Then
		 `pop_failure_point' will keep the current value for the
		 string, instead of restoring it.  To see why, consider
		 matching `foo\nbar' against `.*\n'.  The .* matches the foo;
		 then the . fails against the \n.  But the next thing we want
		 to do is match the \n against the \n; if we restored the
		 string value, we would be back at the foo.
		 
		 Because this is used only in specific cases, we don't need to
		 check all the things that `on_failure_jump' does, to make
		 sure the right things get saved on the stack.  Hence we don't
		 share its code.  The only reason to push anything on the
		 stack at all is that otherwise we would have to change
		 `anychar's code to do something besides goto fail in this
		 case; that seems worse than this.  */
	   case on_failure_keep_string_jump:
		DEBUG_PRINT1 ("EXECUTING on_failure_keep_string_jump");
		
		EXTRACT_NUMBER_AND_INCR (mcnt, p);
		DEBUG_PRINT3 (" %d (to 0x%x):\n", mcnt, p + mcnt);

		PUSH_FAILURE_POINT (p + mcnt, NULL, -2);
		break;


	/* Uses of on_failure_jump:
	   
		 Each alternative starts with an on_failure_jump that points
		 to the beginning of the next alternative.  Each alternative
		 except the last ends with a jump that in effect jumps past
		 the rest of the alternatives.  (They really jump to the
		 ending jump of the following alternative, because tensioning
		 these jumps is a hassle.)

		 Repeats start with an on_failure_jump that points past both
		 the repetition text and either the following jump or
		 pop_failure_jump back to this on_failure_jump.  */
	case on_failure_jump:
	   on_failure:
		DEBUG_PRINT1 ("EXECUTING on_failure_jump");

		EXTRACT_NUMBER_AND_INCR (mcnt, p);
		DEBUG_PRINT3 (" %d (to 0x%x)", mcnt, p + mcnt);

		/* If this on_failure_jump comes right before a group (i.e.,
		   the original * applied to a group), save the information
		   for that group and all inner ones, so that if we fail back
		   to this point, the group's information will be correct.
		   For example, in \(a*\)*\1, we need the preceding group,
		   and in \(\(a*\)b*\)\2, we need the inner group.  */

		/* We can't use `p' to check ahead because we push
		   a failure point to `p + mcnt' after we do this.  */
		p1 = p;

		/* We need to skip no_op's before we look for the
		   start_memory in case this on_failure_jump is happening as
		   the result of a completed succeed_n, as in \(a\)\{1,3\}b\1
		   against aba.  */
		while (p1 < pend && (re_opcode_t) *p1 == no_op)
		  p1++;

		if (p1 < pend && (re_opcode_t) *p1 == start_memory)
		  {
		    /* We have a new highest active register now.  This will
			  get reset at the start_memory we are about to get to,
			  but we will have saved all the registers relevant to
			  this repetition op, as described above.  */
		    highest_active_reg = *(p1 + 1) + *(p1 + 2);
		    if (lowest_active_reg == NO_LOWEST_ACTIVE_REG)
			 lowest_active_reg = *(p1 + 1);
		  }

		DEBUG_PRINT1 (":\n");
		PUSH_FAILURE_POINT (p + mcnt, d, -2);
		break;


	   /* A smart repeat ends with `maybe_pop_jump'.
	   We change it to either `pop_failure_jump' or `jump'.  */
	   case maybe_pop_jump:
		EXTRACT_NUMBER_AND_INCR (mcnt, p);
		DEBUG_PRINT2 ("EXECUTING maybe_pop_jump %d.\n", mcnt);
		{
	    register unsigned char *p2 = p;

		  /* Compare the beginning of the repeat with what in the
			pattern follows its end. If we can establish that there
			is nothing that they would both match, i.e., that we
			would have to backtrack because of (as in, e.g., `a*a')
			then we can change to pop_failure_jump, because we'll
			never have to backtrack.
			
			This is not true in the case of alternatives: in
			`(a|ab)*' we do need to backtrack to the `ab' alternative
			(e.g., if the string was `ab').  But instead of trying to
			detect that here, the alternative has put on a dummy
			failure point which is what we will end up popping.  */

	    /* Skip over open/close-group commands.
		  If what follows this loop is a ...+ construct,
		  look at what begins its body, since we will have to
		  match at least one of that.  */
	    while (1)
		 {
		if (p2 + 2 < pend
		    && ((re_opcode_t) *p2 == stop_memory
			|| (re_opcode_t) *p2 == start_memory))
		  p2 += 3;
		else if (p2 + 6 < pend
			 && (re_opcode_t) *p2 == dummy_failure_jump)
		  p2 += 6;
		else
		  break;
		 }

	    p1 = p + mcnt;
	    /* p1[0] ... p1[2] are the `on_failure_jump' corresponding
		  to the `maybe_finalize_jump' of this case.  Examine what 
		  follows.  */

		  /* If we're at the end of the pattern, we can change.  */
		  if (p2 == pend)
		 {
		/* Consider what happens when matching ":\(.*\)"
		   against ":/".  I don't really understand this code
		   yet.  */
		   p[-3] = (unsigned char) pop_failure_jump;
			 DEBUG_PRINT1
			   ("  End of pattern: change to `pop_failure_jump'.\n");
		    }

		  else if ((re_opcode_t) *p2 == exactn
			|| (bufp->newline_anchor && (re_opcode_t) *p2 == endline))
		 {
		register unsigned char c
			   = *p2 == (unsigned char) endline ? '\n' : p2[2];

			 if ((re_opcode_t) p1[3] == exactn && p1[5] != c)
			   {
		    p[-3] = (unsigned char) pop_failure_jump;
				DEBUG_PRINT3 ("  %c != %c => pop_failure_jump.\n",
						    c, p1[5]);
			   }
			   
		else if ((re_opcode_t) p1[3] == charset
			 || (re_opcode_t) p1[3] == charset_not)
		  {
		    int not = (re_opcode_t) p1[3] == charset_not;
				
		    if (c < (unsigned char) (p1[4] * BYTEWIDTH)
			&& p1[5 + c / BYTEWIDTH] & (1 << (c % BYTEWIDTH)))
			 not = !not;

				/* `not' is equal to 1 if c would match, which means
				    that we can't change to pop_failure_jump.  */
		    if (!not)
				  {
			   p[-3] = (unsigned char) pop_failure_jump;
				    DEBUG_PRINT1 ("  No match => pop_failure_jump.\n");
				  }
		  }
		 }
		  else if ((re_opcode_t) *p2 == charset)
		 {
#ifdef DEBUG
		register unsigned char c
			   = *p2 == (unsigned char) endline ? '\n' : p2[2];
#endif

			 if ((re_opcode_t) p1[3] == exactn
		    && ! ((int) p2[1] * BYTEWIDTH > (int) p1[4]
			  && (p2[1 + p1[4] / BYTEWIDTH]
				 & (1 << (p1[4] % BYTEWIDTH)))))
			   {
		    p[-3] = (unsigned char) pop_failure_jump;
				DEBUG_PRINT3 ("  %c != %c => pop_failure_jump.\n",
						    c, p1[5]);
			   }
			   
		else if ((re_opcode_t) p1[3] == charset_not)
		  {
		    int idx;
		    /* We win if the charset_not inside the loop
			  lists every character listed in the charset after.  */
		    for (idx = 0; idx < (int) p2[1]; idx++)
			 if (! (p2[2 + idx] == 0
				|| (idx < (int) p1[4]
				 && ((p2[2 + idx] & ~ p1[5 + idx]) == 0))))
			break;

		    if (idx == p2[1])
				  {
			   p[-3] = (unsigned char) pop_failure_jump;
				    DEBUG_PRINT1 ("  No match => pop_failure_jump.\n");
				  }
		  }
		else if ((re_opcode_t) p1[3] == charset)
		  {
		    int idx;
		    /* We win if the charset inside the loop
			  has no overlap with the one after the loop.  */
		    for (idx = 0;
			 idx < (int) p2[1] && idx < (int) p1[4];
			 idx++)
			 if ((p2[2 + idx] & p1[5 + idx]) != 0)
			break;

		    if (idx == p2[1] || idx == p1[4])
				  {
			   p[-3] = (unsigned char) pop_failure_jump;
				    DEBUG_PRINT1 ("  No match => pop_failure_jump.\n");
				  }
		  }
		 }
	  }
	  p -= 2;		/* Point at relative address again.  */
	  if ((re_opcode_t) p[-1] != pop_failure_jump)
	    {
		 p[-1] = (unsigned char) jump;
		    DEBUG_PRINT1 ("  Match => jump.\n");
		 goto unconditional_jump;
	    }
	   /* Note fall through.  */


	/* The end of a simple repeat has a pop_failure_jump back to
		 its matching on_failure_jump, where the latter will push a
		 failure point.  The pop_failure_jump takes off failure
		 points put on by this pop_failure_jump's matching
		 on_failure_jump; we got through the pattern to here from the
		 matching on_failure_jump, so didn't fail.  */
	   case pop_failure_jump:
		{
		  /* We need to pass separate storage for the lowest and
			highest registers, even though we don't care about the
			actual values.  Otherwise, we will restore only one
			register from the stack, since lowest will == highest in
			`pop_failure_point'.  */
		  unsigned dummy_low_reg, dummy_high_reg;
		  unsigned char *pdummy;
		  const char *sdummy;

		  DEBUG_PRINT1 ("EXECUTING pop_failure_jump.\n");
		  POP_FAILURE_POINT (sdummy, pdummy,
						 dummy_low_reg, dummy_high_reg,
						 reg_dummy, reg_dummy, reg_info_dummy);
		}
		/* Note fall through.  */

		
	   /* Unconditionally jump (without popping any failure points).  */
	   case jump:
	unconditional_jump:
	  EXTRACT_NUMBER_AND_INCR (mcnt, p);	/* Get the amount to jump.  */
		DEBUG_PRINT2 ("EXECUTING jump %d ", mcnt);
	  p += mcnt;				/* Do the jump.  */
		DEBUG_PRINT2 ("(to 0x%x).\n", p);
	  break;

	
	   /* We need this opcode so we can detect where alternatives end
		 in `group_match_null_string_p' et al.  */
	   case jump_past_alt:
		DEBUG_PRINT1 ("EXECUTING jump_past_alt.\n");
		goto unconditional_jump;


	   /* Normally, the on_failure_jump pushes a failure point, which
		 then gets popped at pop_failure_jump.  We will end up at
		 pop_failure_jump, also, and with a pattern of, say, `a+', we
		 are skipping over the on_failure_jump, so we have to push
		 something meaningless for pop_failure_jump to pop.  */
	   case dummy_failure_jump:
		DEBUG_PRINT1 ("EXECUTING dummy_failure_jump.\n");
		/* It doesn't matter what we push for the string here.  What
		   the code at `fail' tests is the value for the pattern.  */
		PUSH_FAILURE_POINT (0, 0, -2);
		goto unconditional_jump;


	   /* At the end of an alternative, we need to push a dummy failure
		 point in case we are followed by a `pop_failure_jump', because
		 we don't want the failure point for the alternative to be
		 popped.  For example, matching `(a|ab)*' against `aab'
		 requires that we match the `ab' alternative.  */
	   case push_dummy_failure:
		DEBUG_PRINT1 ("EXECUTING push_dummy_failure.\n");
		/* See comments just above at `dummy_failure_jump' about the
		   two zeroes.  */
		PUSH_FAILURE_POINT (0, 0, -2);
		break;

	   /* Have to succeed matching what follows at least n times.
		 After that, handle like `on_failure_jump'.  */
	   case succeed_n: 
		EXTRACT_NUMBER (mcnt, p + 2);
		DEBUG_PRINT2 ("EXECUTING succeed_n %d.\n", mcnt);

		assert (mcnt >= 0);
		/* Originally, this is how many times we HAVE to succeed.  */
		if (mcnt > 0)
		  {
			mcnt--;
		  p += 2;
			STORE_NUMBER_AND_INCR (p, mcnt);
			DEBUG_PRINT3 ("  Setting 0x%x to %d.\n", p, mcnt);
		  }
	  else if (mcnt == 0)
		  {
		    DEBUG_PRINT2 ("  Setting two bytes from 0x%x to no_op.\n", p+2);
		 p[2] = (unsigned char) no_op;
		    p[3] = (unsigned char) no_op;
		    goto on_failure;
		  }
		break;
	   
	   case jump_n: 
		EXTRACT_NUMBER (mcnt, p + 2);
		DEBUG_PRINT2 ("EXECUTING jump_n %d.\n", mcnt);

		/* Originally, this is how many times we CAN jump.  */
		if (mcnt)
		  {
			mcnt--;
			STORE_NUMBER (p + 2, mcnt);
		  goto unconditional_jump;	     
		  }
		/* If don't have to jump any more, skip over the rest of command.  */
	  else      
	    p += 4;		     
		break;
	   
	case set_number_at:
	  {
		  DEBUG_PRINT1 ("EXECUTING set_number_at.\n");

		  EXTRACT_NUMBER_AND_INCR (mcnt, p);
		  p1 = p + mcnt;
		  EXTRACT_NUMBER_AND_INCR (mcnt, p);
		  DEBUG_PRINT3 ("  Setting 0x%x to %d.\n", p1, mcnt);
	    STORE_NUMBER (p1, mcnt);
		  break;
		}

	   case wordbound:
		DEBUG_PRINT1 ("EXECUTING wordbound.\n");
		if (AT_WORD_BOUNDARY (d))
	    break;
		goto fail;

	case notwordbound:
		DEBUG_PRINT1 ("EXECUTING notwordbound.\n");
	  if (AT_WORD_BOUNDARY (d))
	    goto fail;
		break;

	case wordbeg:
		DEBUG_PRINT1 ("EXECUTING wordbeg.\n");
	  if (WORDCHAR_P (d) && (AT_STRINGS_BEG (d) || !WORDCHAR_P (d - 1)))
	    break;
		goto fail;

	case wordend:
		DEBUG_PRINT1 ("EXECUTING wordend.\n");
	  if (!AT_STRINGS_BEG (d) && WORDCHAR_P (d - 1)
		    && (!WORDCHAR_P (d) || AT_STRINGS_END (d)))
	    break;
		goto fail;

#ifdef emacs
	case before_dot:
		DEBUG_PRINT1 ("EXECUTING before_dot.\n");
	  if (PTR_CHAR_POS ((unsigned char *) d) >= point)
	    goto fail;
	  break;
  
	case at_dot:
		DEBUG_PRINT1 ("EXECUTING at_dot.\n");
	  if (PTR_CHAR_POS ((unsigned char *) d) != point)
	    goto fail;
	  break;
  
	case after_dot:
		DEBUG_PRINT1 ("EXECUTING after_dot.\n");
		if (PTR_CHAR_POS ((unsigned char *) d) <= point)
	    goto fail;
	  break;
#if 0 /* not emacs19 */
	case at_dot:
		DEBUG_PRINT1 ("EXECUTING at_dot.\n");
	  if (PTR_CHAR_POS ((unsigned char *) d) + 1 != point)
	    goto fail;
	  break;
#endif /* not emacs19 */

	case syntaxspec:
		DEBUG_PRINT2 ("EXECUTING syntaxspec %d.\n", mcnt);
	  mcnt = *p++;
	  goto matchsyntax;

	   case wordchar:
		DEBUG_PRINT1 ("EXECUTING Emacs wordchar.\n");
	  mcnt = (int) Sword;
	   matchsyntax:
	  PREFETCH ();
	  /* Can't use *d++ here; SYNTAX may be an unsafe macro.  */
	  d++;
	  if (SYNTAX (d[-1]) != (enum syntaxcode) mcnt)
	    goto fail;
		SET_REGS_MATCHED ();
	  break;

	case notsyntaxspec:
		DEBUG_PRINT2 ("EXECUTING notsyntaxspec %d.\n", mcnt);
	  mcnt = *p++;
	  goto matchnotsyntax;

	   case notwordchar:
		DEBUG_PRINT1 ("EXECUTING Emacs notwordchar.\n");
	  mcnt = (int) Sword;
	   matchnotsyntax:
	  PREFETCH ();
	  /* Can't use *d++ here; SYNTAX may be an unsafe macro.  */
	  d++;
	  if (SYNTAX (d[-1]) == (enum syntaxcode) mcnt)
	    goto fail;
	  SET_REGS_MATCHED ();
		break;

#else /* not emacs */
	case wordchar:
		DEBUG_PRINT1 ("EXECUTING non-Emacs wordchar.\n");
	  PREFETCH ();
		if (!WORDCHAR_P (d))
		  goto fail;
	  SET_REGS_MATCHED ();
		d++;
	  break;
	  
	case notwordchar:
		DEBUG_PRINT1 ("EXECUTING non-Emacs notwordchar.\n");
	  PREFETCH ();
	  if (WORDCHAR_P (d))
		  goto fail;
		SET_REGS_MATCHED ();
		d++;
	  break;
#endif /* not emacs */
		
	   default:
		abort ();
	}
	 continue;  /* Successfully executed one pattern command; keep going.  */


    /* We goto here if a matching operation fails. */
    fail:
	 if (!FAIL_STACK_EMPTY ())
	{ /* A restart point is known.  Restore to that state.  */
		DEBUG_PRINT1 ("\nFAIL:\n");
		POP_FAILURE_POINT (d, p,
					    lowest_active_reg, highest_active_reg,
					    regstart, regend, reg_info);

		/* If this failure point is a dummy, try the next one.  */
		if (!p)
	    goto fail;

		/* If we failed to the end of the pattern, don't examine *p.  */
	  assert (p <= pend);
		if (p < pend)
		  {
		    boolean is_a_jump_n = false;
		    
		    /* If failed to a backwards jump that's part of a repetition
			  loop, need to pop this failure point and use the next one.  */
		    switch ((re_opcode_t) *p)
			 {
			 case jump_n:
			   is_a_jump_n = true;
			 case maybe_pop_jump:
			 case pop_failure_jump:
			 case jump:
			   p1 = p + 1;
			   EXTRACT_NUMBER_AND_INCR (mcnt, p1);
			   p1 += mcnt;	

			   if ((is_a_jump_n && (re_opcode_t) *p1 == succeed_n)
				  || (!is_a_jump_n
					 && (re_opcode_t) *p1 == on_failure_jump))
				goto fail;
			   break;
			 default:
			   /* do nothing */ ;
			 }
		  }

		if (d >= string1 && d <= end1)
	    dend = end_match_1;
	   }
	 else
	   break;   /* Matching at this starting point really fails.  */
    } /* for (;;) */

  if (best_regs_set)
    goto restore_best_regs;

  FREE_VARIABLES ();

  return -1;         			/* Failure to match.  */
} /* re_match_2 */

/* Subroutine definitions for re_match_2.  */


/* We are passed P pointing to a register number after a start_memory.
   
   Return true if the pattern up to the corresponding stop_memory can
   match the empty string, and false otherwise.
   
   If we find the matching stop_memory, sets P to point to one past its number.
   Otherwise, sets P to an undefined byte less than or equal to END.

   We don't handle duplicates properly (yet).  */

static boolean
group_match_null_string_p (p, end, reg_info)
    unsigned char **p, *end;
    register_info_type *reg_info;
{
  int mcnt;
  /* Point to after the args to the start_memory.  */
  unsigned char *p1 = *p + 2;
  
  while (p1 < end)
    {
	 /* Skip over opcodes that can match nothing, and return true or
	 false, as appropriate, when we get to one that can't, or to the
	    matching stop_memory.  */
	 
	 switch ((re_opcode_t) *p1)
	   {
	   /* Could be either a loop or a series of alternatives.  */
	   case on_failure_jump:
		p1++;
		EXTRACT_NUMBER_AND_INCR (mcnt, p1);
		
		/* If the next operation is not a jump backwards in the
		pattern.  */

	  if (mcnt >= 0)
	    {
		    /* Go through the on_failure_jumps of the alternatives,
			  seeing if any of the alternatives cannot match nothing.
			  The last alternative starts with only a jump,
			  whereas the rest start with on_failure_jump and end
			  with a jump, e.g., here is the pattern for `a|b|c':

			  /on_failure_jump/0/6/exactn/1/a/jump_past_alt/0/6
			  /on_failure_jump/0/6/exactn/1/b/jump_past_alt/0/3
			  /exactn/1/c						

			  So, we have to first go through the first (n-1)
			  alternatives and then deal with the last one separately.  */


		    /* Deal with the first (n-1) alternatives, which start
			  with an on_failure_jump (see above) that jumps to right
			  past a jump_past_alt.  */

		    while ((re_opcode_t) p1[mcnt-3] == jump_past_alt)
			 {
			   /* `mcnt' holds how many bytes long the alternative
				 is, including the ending `jump_past_alt' and
				 its number.  */

			   if (!alt_match_null_string_p (p1, p1 + mcnt - 3, 
								  reg_info))
				return false;

			   /* Move to right after this alternative, including the
			jump_past_alt.  */
			   p1 += mcnt;	

			   /* Break if it's the beginning of an n-th alternative
				 that doesn't begin with an on_failure_jump.  */
			   if ((re_opcode_t) *p1 != on_failure_jump)
				break;
		
		  /* Still have to check that it's not an n-th
			alternative that starts with an on_failure_jump.  */
		  p1++;
			   EXTRACT_NUMBER_AND_INCR (mcnt, p1);
			   if ((re_opcode_t) p1[mcnt-3] != jump_past_alt)
				{
			 /* Get to the beginning of the n-th alternative.  */
				  p1 -= 3;
				  break;
				}
			 }

		    /* Deal with the last alternative: go back and get number
			  of the `jump_past_alt' just before it.  `mcnt' contains
			  the length of the alternative.  */
		    EXTRACT_NUMBER (mcnt, p1 - 2);

		    if (!alt_match_null_string_p (p1, p1 + mcnt, reg_info))
			 return false;

		    p1 += mcnt;	/* Get past the n-th alternative.  */
		  } /* if mcnt > 0 */
		break;

		
	   case stop_memory:
	  assert (p1[1] == **p);
		*p = p1 + 2;
		return true;

	   
	   default: 
		if (!common_op_match_null_string_p (&p1, end, reg_info))
		  return false;
	   }
    } /* while p1 < end */

  return false;
} /* group_match_null_string_p */


/* Similar to group_match_null_string_p, but doesn't deal with alternatives:
   It expects P to be the first byte of a single alternative and END one
   byte past the last. The alternative can contain groups.  */
   
static boolean
alt_match_null_string_p (p, end, reg_info)
    unsigned char *p, *end;
    register_info_type *reg_info;
{
  int mcnt;
  unsigned char *p1 = p;
  
  while (p1 < end)
    {
	 /* Skip over opcodes that can match nothing, and break when we get 
	    to one that can't.  */
	 
	 switch ((re_opcode_t) *p1)
	   {
	/* It's a loop.  */
	   case on_failure_jump:
		p1++;
		EXTRACT_NUMBER_AND_INCR (mcnt, p1);
		p1 += mcnt;
		break;
		
	default: 
		if (!common_op_match_null_string_p (&p1, end, reg_info))
		  return false;
	   }
    }  /* while p1 < end */

  return true;
} /* alt_match_null_string_p */


/* Deals with the ops common to group_match_null_string_p and
   alt_match_null_string_p.  
   
   Sets P to one after the op and its arguments, if any.  */

static boolean
common_op_match_null_string_p (p, end, reg_info)
    unsigned char **p, *end;
    register_info_type *reg_info;
{
  int mcnt;
  boolean ret;
  int reg_no;
  unsigned char *p1 = *p;

  switch ((re_opcode_t) *p1++)
    {
    case no_op:
    case begline:
    case endline:
    case begbuf:
    case endbuf:
    case wordbeg:
    case wordend:
    case wordbound:
    case notwordbound:
#ifdef emacs
    case before_dot:
    case at_dot:
    case after_dot:
#endif
	 break;

    case start_memory:
	 reg_no = *p1;
	 assert (reg_no > 0 && reg_no <= MAX_REGNUM);
	 ret = group_match_null_string_p (&p1, end, reg_info);
	 
	 /* Have to set this here in case we're checking a group which
	    contains a group and a back reference to it.  */

	 if (REG_MATCH_NULL_STRING_P (reg_info[reg_no]) == MATCH_NULL_UNSET_VALUE)
	   REG_MATCH_NULL_STRING_P (reg_info[reg_no]) = ret;

	 if (!ret)
	   return false;
	 break;
		
    /* If this is an optimized succeed_n for zero times, make the jump.  */
    case jump:
	 EXTRACT_NUMBER_AND_INCR (mcnt, p1);
	 if (mcnt >= 0)
	   p1 += mcnt;
	 else
	   return false;
	 break;

    case succeed_n:
	 /* Get to the number of times to succeed.  */
	 p1 += 2;		
	 EXTRACT_NUMBER_AND_INCR (mcnt, p1);

	 if (mcnt == 0)
	   {
		p1 -= 4;
		EXTRACT_NUMBER_AND_INCR (mcnt, p1);
		p1 += mcnt;
	   }
	 else
	   return false;
	 break;

    case duplicate: 
	 if (!REG_MATCH_NULL_STRING_P (reg_info[*p1]))
	   return false;
	 break;

    case set_number_at:
	 p1 += 4;

    default:
	 /* All other opcodes mean we cannot match the empty string.  */
	 return false;
  }

  *p = p1;
  return true;
} /* common_op_match_null_string_p */


/* Return zero if TRANSLATE[S1] and TRANSLATE[S2] are identical for LEN
   bytes; nonzero otherwise.  */
   
static int
bcmp_translate (s1, s2, len, translate)
	unsigned char *s1, *s2;
	register int len;
	char *translate;
{
  register unsigned char *p1 = s1, *p2 = s2;
  while (len)
    {
	 if (translate[*p1++] != translate[*p2++]) return 1;
	 len--;
    }
  return 0;
}

/* Entry points for GNU code.  */

/* re_compile_pattern is the GNU regular expression compiler: it
   compiles PATTERN (of length SIZE) and puts the result in BUFP.
   Returns 0 if the pattern was valid, otherwise an error string.
   
   Assumes the `allocated' (and perhaps `buffer') and `translate' fields
   are set in BUFP on entry.
   
   We call regex_compile to do the actual compilation.  */

const char *
re_compile_pattern (pattern, length, bufp)
	const char *pattern;
	int length;
	struct re_pattern_buffer *bufp;
{
  reg_errcode_t ret;
  
  /* GNU code is written to assume at least RE_NREGS registers will be set
	(and at least one extra will be -1).  */
  bufp->regs_allocated = REGS_UNALLOCATED;
  
  /* And GNU code determines whether or not to get register information
	by passing null for the REGS argument to re_match, etc., not by
	setting no_sub.  */
  bufp->no_sub = 0;
  
  /* Match anchors at newline.  */
  bufp->newline_anchor = 1;
  
  ret = regex_compile (pattern, length, re_syntax_options, bufp);

  if (!ret)
    return NULL;
  return gettext (re_error_msgid[(int) ret]);
}     

/* Entry points compatible with 4.2 BSD regex library.  We don't define
   them unless specifically requested.  */

#ifdef _REGEX_RE_COMP

/* BSD has one and only one pattern buffer.  */
static struct re_pattern_buffer re_comp_buf;

char *
re_comp (s)
    const char *s;
{
  reg_errcode_t ret;
  
  if (!s)
    {
	 if (!re_comp_buf.buffer)
	return gettext ("No previous regular expression");
	 return 0;
    }

  if (!re_comp_buf.buffer)
    {
	 re_comp_buf.buffer = (unsigned char *) malloc (200);
	 if (re_comp_buf.buffer == NULL)
	   return gettext (re_error_msgid[(int) REG_ESPACE]);
	 re_comp_buf.allocated = 200;

	 re_comp_buf.fastmap = (char *) malloc (1 << BYTEWIDTH);
	 if (re_comp_buf.fastmap == NULL)
	return gettext (re_error_msgid[(int) REG_ESPACE]);
    }

  /* Since `re_exec' always passes NULL for the `regs' argument, we
	don't need to initialize the pattern buffer fields which affect it.  */

  /* Match anchors at newlines.  */
  re_comp_buf.newline_anchor = 1;

  ret = regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf);
  
  if (!ret)
    return NULL;

  /* Yes, we're discarding `const' here if !HAVE_LIBINTL.  */
  return (char *) gettext (re_error_msgid[(int) ret]);
}


int
re_exec (s)
    const char *s;
{
  const int len = strlen (s);
  return
    0 <= re_search (&re_comp_buf, s, len, 0, len, (struct re_registers *) 0);
}
#endif /* _REGEX_RE_COMP */

/* POSIX.2 functions.  Don't define these for Emacs.  */

#ifndef emacs

/* regcomp takes a regular expression as a string and compiles it.

   PREG is a regex_t *.  We do not expect any fields to be initialized,
   since POSIX says we shouldn't.  Thus, we set

	`buffer' to the compiled pattern;
	`used' to the length of the compiled pattern;
	`syntax' to RE_SYNTAX_POSIX_EXTENDED if the
	  REG_EXTENDED bit in CFLAGS is set; otherwise, to
	  RE_SYNTAX_POSIX_BASIC;
	`newline_anchor' to REG_NEWLINE being set in CFLAGS;
	`fastmap' and `fastmap_accurate' to zero;
	`re_nsub' to the number of subexpressions in PATTERN.

   PATTERN is the address of the pattern string.

   CFLAGS is a series of bits which affect compilation.

	If REG_EXTENDED is set, we use POSIX extended syntax; otherwise, we
	use POSIX basic syntax.

	If REG_NEWLINE is set, then . and [^...] don't match newline.
	Also, regexec will try a match beginning after every newline.

	If REG_ICASE is set, then we considers upper- and lowercase
	versions of letters to be equivalent when matching.

	If REG_NOSUB is set, then when PREG is passed to regexec, that
	routine will report only success or failure, and nothing about the
	registers.

   It returns 0 if it succeeds, nonzero if it doesn't.  (See regex.h for
   the return codes and their meanings.)  */

int
regcomp (preg, pattern, cflags)
    regex_t *preg;
    const char *pattern; 
    int cflags;
{
  reg_errcode_t ret;
  unsigned syntax
    = (cflags & REG_EXTENDED) ?
	 RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC;

  /* regex_compile will allocate the space for the compiled pattern.  */
  preg->buffer = 0;
  preg->allocated = 0;
  preg->used = 0;
  
  /* Don't bother to use a fastmap when searching.  This simplifies the
	REG_NEWLINE case: if we used a fastmap, we'd have to put all the
	characters after newlines into the fastmap.  This way, we just try
	every character.  */
  preg->fastmap = 0;
  
  if (cflags & REG_ICASE)
    {
	 unsigned i;
	 
	 preg->translate = (char *) malloc (CHAR_SET_SIZE);
	 if (preg->translate == NULL)
	   return (int) REG_ESPACE;

	 /* Map uppercase characters to corresponding lowercase ones.  */
	 for (i = 0; i < CHAR_SET_SIZE; i++)
	   preg->translate[i] = ISUPPER (i) ? tolower (i) : i;
    }
  else
    preg->translate = NULL;

  /* If REG_NEWLINE is set, newlines are treated differently.  */
  if (cflags & REG_NEWLINE)
    { /* REG_NEWLINE implies neither . nor [^...] match newline.  */
	 syntax &= ~RE_DOT_NEWLINE;
	 syntax |= RE_HAT_LISTS_NOT_NEWLINE;
	 /* It also changes the matching behavior.  */
	 preg->newline_anchor = 1;
    }
  else
    preg->newline_anchor = 0;

  preg->no_sub = !!(cflags & REG_NOSUB);

  /* POSIX says a null character in the pattern terminates it, so we 
	can use strlen here in compiling the pattern.  */
  ret = regex_compile (pattern, strlen (pattern), syntax, preg);
  
  /* POSIX doesn't distinguish between an unmatched open-group and an
	unmatched close-group: both are REG_EPAREN.  */
  if (ret == REG_ERPAREN) ret = REG_EPAREN;
  
  return (int) ret;
}


/* regexec searches for a given pattern, specified by PREG, in the
   string STRING.
   
   If NMATCH is zero or REG_NOSUB was set in the cflags argument to
   `regcomp', we ignore PMATCH.  Otherwise, we assume PMATCH has at
   least NMATCH elements, and we set them to the offsets of the
   corresponding matched substrings.
   
   EFLAGS specifies `execution flags' which affect matching: if
   REG_NOTBOL is set, then ^ does not match at the beginning of the
   string; if REG_NOTEOL is set, then $ does not match at the end.
   
   We return 0 if we find a match and REG_NOMATCH if not.  */

int
regexec (preg, string, nmatch, pmatch, eflags)
    const regex_t *preg;
    const char *string; 
    size_t nmatch; 
    regmatch_t pmatch[]; 
    int eflags;
{
  int ret;
  struct re_registers regs;
  regex_t private_preg;
  int len = strlen (string);
  boolean want_reg_info = !preg->no_sub && nmatch > 0;

  private_preg = *preg;
  
  private_preg.not_bol = !!(eflags & REG_NOTBOL);
  private_preg.not_eol = !!(eflags & REG_NOTEOL);
  
  /* The user has told us exactly how many registers to return
	information about, via `nmatch'.  We have to pass that on to the
	matching routines.  */
  private_preg.regs_allocated = REGS_FIXED;
  
  if (want_reg_info)
    {
	 regs.num_regs = nmatch;
	 regs.start = TALLOC (nmatch, regoff_t);
	 regs.end = TALLOC (nmatch, regoff_t);
	 if (regs.start == NULL || regs.end == NULL)
	   return (int) REG_NOMATCH;
    }

  /* Perform the searching operation.  */
  ret = re_search (&private_preg, string, len,
			    /* start: */ 0, /* range: */ len,
			    want_reg_info ? ®s : (struct re_registers *) 0);
  
  /* Copy the register information to the POSIX structure.  */
  if (want_reg_info)
    {
	 if (ret >= 0)
	   {
		unsigned r;

		for (r = 0; r < nmatch; r++)
		  {
		    pmatch[r].rm_so = regs.start[r];
		    pmatch[r].rm_eo = regs.end[r];
		  }
	   }

	 /* If we needed the temporary register info, free the space now.  */
	 free (regs.start);
	 free (regs.end);
    }

  /* We want zero return to mean success, unlike `re_search'.  */
  return ret >= 0 ? (int) REG_NOERROR : (int) REG_NOMATCH;
}


/* Returns a message corresponding to an error code, ERRCODE, returned
   from either regcomp or regexec.   We don't use PREG here.  */

size_t
regerror (errcode, preg, errbuf, errbuf_size)
    int errcode;
    const regex_t *preg;
    char *errbuf;
    size_t errbuf_size;
{
  const char *msg;
  size_t msg_size;

  if (errcode < 0
	 || errcode >= (sizeof (re_error_msgid) / sizeof (re_error_msgid[0])))
    /* Only error codes returned by the rest of the code should be passed 
	  to this routine.  If we are given anything else, or if other regex
	  code generates an invalid error code, then the program has a bug.
	  Dump core so we can fix it.  */
    abort ();

  msg = gettext (re_error_msgid[errcode]);

  msg_size = strlen (msg) + 1; /* Includes the null.  */
  
  if (errbuf_size != 0)
    {
	 if (msg_size > errbuf_size)
	   {
		strncpy (errbuf, msg, errbuf_size - 1);
		errbuf[errbuf_size - 1] = 0;
	   }
	 else
	   strcpy (errbuf, msg);
    }

  return msg_size;
}


/* Free dynamically allocated space used by PREG.  */

void
regfree (preg)
    regex_t *preg;
{
  if (preg->buffer != NULL)
    free (preg->buffer);
  preg->buffer = NULL;
  
  preg->allocated = 0;
  preg->used = 0;

  if (preg->fastmap != NULL)
    free (preg->fastmap);
  preg->fastmap = NULL;
  preg->fastmap_accurate = 0;

  if (preg->translate != NULL)
    free (preg->translate);
  preg->translate = NULL;
}

#endif /* not emacs  */

/*
Local variables:
make-backup-files: t
version-control: t
trim-versions-without-asking: nil
End:
*/
ht-2.0.22/stream.cc0000644000175000001440000007430610636476574010763 00000000000000/*
 *	HT Editor
 *	stream.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 	/* for mode definitions */
#include 	/* for mode definitions */
#include 

#include "htdebug.h"
#include "except.h"
#include "snprintf.h"
#include "stream.h"
#include "strtools.h"
#include "tools.h"

/*
 *	Listener
 */
#if 0
class Listener: public Object {
public:
	StreamEventListener *listener;
	StreamEvent notify_mask;

	Listener(StreamEventListener *l, StreamEvent nmask)
	{
		listener = l;
		notify_mask = nmask;
	}

/* extends Object */
	virtual int compareTo(const Object *obj) const
	{
		return ((Listener*)obj)->listener == listener ? 0 : 1;
	}
};
#endif
/*
 *	Stream
 */

#define STREAM_COPYBUF_SIZE	(64*1024)

Stream::Stream()
{
	mAccessMode = IOAM_NULL;
//	mListeners = NULL;
}

/*
Stream::~Stream()
{
//	delete mListeners;
}
*/

/*
void Stream::addEventListener(StreamEventListener *l, StreamEvent mask)
{
	if (!mListeners) mListeners = new Array(true);
	*mListeners += new Listener(l, mask);
}
*/
void Stream::checkAccess(IOAccessMode mask)
{
	if ((mAccessMode & mask) != mask) throw IOException(EACCES);
}

/**
 *	Copy (whole) stream to another (i.e. copy until EOF)
 *	@param stream Stream to copy this Stream to
 *	@returns number of bytes copied
 */
FileOfs Stream::copyAllTo(Stream *stream)
{
	byte *buf = new byte[STREAM_COPYBUF_SIZE];
	FileOfs result = 0;
	uint r, t;
	do {
		uint k = STREAM_COPYBUF_SIZE;
		r = read(buf, k);
		assert(r <= k);
		t = stream->write(buf, r);
		assert(t <= r);
		result += t;
		if (t != k) break;
	} while (t);
	delete[] buf;
	return result;
}

/**
 *	Copy (partial) stream to another
 *	@param stream Stream to copy this Stream to
 *	@param count maximum number of bytes to copy
 *	@returns number of bytes copied
 */
FileOfs Stream::copyTo(Stream *stream, FileOfs count)
{
	byte *buf = new byte[STREAM_COPYBUF_SIZE];
	FileOfs result = 0;
	while (count) {
		uint k = STREAM_COPYBUF_SIZE;
		if (k > count) k = count;
		uint r = read(buf, k);
		assert(r <= k);
		uint t = stream->write(buf, r);
		assert(t <= r);
		count -= t;
		result += t;
		if (t != k) break;
	}
	delete[] buf;
	return result;
}

/**
 *	Get access-mode
 */
IOAccessMode Stream::getAccessMode() const
{
	return mAccessMode;
}

/**
 *	Get descriptive name
 */
String &Stream::getDesc(String &result) const
{
	result = "";
	return result;
}
/*
void Stream::notifyListeners(StreamEvent event,...)
{
	if (!mListeners) return;
	foreach(Listener, l, *mListeners,
		if (l->notify_mask & event) {
			va_list ap;
			va_start(ap, event);
			l->listener->handleEvent(event, ap);
			va_end(ap);
		}
	);
}
*/
/**
 *	Set access-mode
 */
int	Stream::setAccessMode(IOAccessMode mode)
{
	mAccessMode = mode;
	return 0;
}

/**
 *	Set access-mode, throw IOException if unsuccessful
 */
void	Stream::setAccessModex(IOAccessMode mode)
{
	int e = setAccessMode(mode);
	if (e) throw IOException(e);
}

/**
 *	Read from stream.
 *	Read up to size bytes from stream into buf.
 *	If less than size bytes are read, the exact number is
 *	returned and a (temporary) end-of-file (EOF) is encountered.
 *
 *	@param buf pointer to bytes to read
 *	@param size number of bytes to read
 *	@returns number of bytes read
 *	@throws IOException
 */
uint	Stream::read(void *buf, uint size)
{
	return 0;
}

/**
 *	Exact read from stream.
 *	Read exactly size bytes from stream into buf.
 *	If less than size bytes are read, IOException is thrown.
 *
 *	@param buf pointer to bytes to read
 *	@param size number of bytes to read
 *	@throws IOException
 */
//#include "snprintf.h" 
void	Stream::readx(void *buf, uint size)
{
//	File *f = dynamic_cast(this);
//	FileOfs t = f ? f->tell() : 0;
	if (read(buf, size) != size) {
//		FileOfs sz = f ? f->getSize() : mkfofs(0);
//		ht_printf("readx failed, ofs = 0x%qx, size = %d (file size 0x%qx)\n", &t, size, &sz);
		throw EOFException();
	}	    
}
/*
void Stream::removeEventListener(StreamEventListener *l)
{
	Listener t(l, SEV_NULL);
	bool b = (*mListeners -= &t);
	assert(b);
}
*/
/**
 *	Write to stream.
 *	Write up to size bytes from buf into stream.
 *	If less than size bytes are written, the exact number is
 *	returned and a (temporary) end-of-file (EOF) is encountered.
 *
 *	@param buf pointer to bytes to write
 *	@param size number of bytes to write
 *	@returns number of bytes written
 *	@throws IOException
 */
uint	Stream::write(const void *buf, uint size)
{
	return 0;
}

/**
 *	Exact write to stream.
 *	Write exactly size bytes from buf into stream.
 *	If less than size bytes are written, IOException is thrown.
 *
 *	@param buf pointer to bytes to write
 *	@param size number of bytes to write
 *	@throws IOException
 */
void	Stream::writex(const void *buf, uint size)
{
	if (write(buf, size) != size) throw EOFException();
}


// FIXME: more dynamical solution appreciated
#define REASONABLE_STRING_LIMIT	1024
 
char *Stream::readstrz()
{
	/* get string size */
	char buf[REASONABLE_STRING_LIMIT];
	int z = 0;
	while (1) {
		readx(buf+z, 1);
		z++;
		if (z >= REASONABLE_STRING_LIMIT) {
			z = REASONABLE_STRING_LIMIT;
			break;
		}
		if (buf[z-1] == 0) break;
	}
	if (!z) return NULL;
	char *str = ht_malloc(z);
	if (!str) throw std::bad_alloc();
	memcpy(str, buf, z-1);
	str[z-1] = 0;
	return str;
}

bool Stream::readStringz(String &s)
{
	String r;
	try {
		while (1) {
			char c;
			readx(&c, 1);
			if (!c) break;
			r.appendChar(c);
		}
		s.grab(r);
		return true;
	} catch (const EOFException &) {
		return false;
	}
}

void Stream::writestrz(const char *str)
{
	if (str) {
		writex(str, strlen(str)+1);
	} else {
		byte n = 0;
		writex(&n, 1);
	}
}

char *Stream::readstrp()
{
	uint8 l;
	readx(&l, 1);
	char *str = ht_malloc(l+1);
	if (!str) throw std::bad_alloc();
	try {
		readx(str, l);
	} catch (...) {
		free(str);
		throw;
	}
	str[l] = 0;
	return str;
}

char *Stream::readstrl()
{
	uint32 l = 0;
	for (int i=0; i<4; i++) {
		uint8 b;
		readx(&b, 1);
		l <<= 7;
		l |= b & 0x7f;
		if (!(b & 0x80)) break;
	}
	char *str = ht_malloc(l+1);
	if (!str) throw std::bad_alloc();	
	try {
		readx(str, l);
	} catch (...) {
		free(str);
		throw;
	}
	str[l] = 0;
	return str;
}

void Stream::writestrl(const char *str)
{
	uint8 b;
	uint32 len = strlen(str);
	if (!len) {
		b = 0;
		writex(&b, 1);
		return;
	}
	int i = 4;
	uint32 a = 0xfe000000;
	while (!(len & a)) {
		a >>= 7;
		i--;
	}
	len <<= (4-i)*7;
	while (i--) {
		a = i ? 0x80 : 0;
		b = ((len & 0xfe000000) >> (3 * 7)) | a;
		len <<= 7;
		writex(&b, 1);
		return;
	}
}

void Stream::writestrp(const char *str)
{
	unsigned char l = str ? strlen(str) : 0;
	writex(&l, 1);
	writex(str, l);
}

char *Stream::readstrw()
{
	short t;
	byte lbuf[2];
	readx(lbuf, 2);
	int l = lbuf[0] | lbuf[1] << 8;
	char *a = ht_malloc(l+1);
	if (!a) throw std::bad_alloc();
	for (int i=0; i < l; i++) {
		// FIXME: this looks wrong
		readx(&t, 2);
		a[i] = (char)t;
	}
	a[l] = 0;
	return a;
}

void Stream::writestrw(const char *str)
{
	/* FIXME: someone implement me ? */
	throw NotImplementedException(HERE);
}
/*
 *   StreamLayer
 */

StreamLayer::StreamLayer(Stream *s, bool own) : Stream()
{
	mStream = s;
	mOwnStream = own;
}

StreamLayer::~StreamLayer()
{
	if (mOwnStream) delete mStream;
}

IOAccessMode StreamLayer::getAccessMode() const
{
	return mStream->getAccessMode();
}

String &StreamLayer::getDesc(String &result) const
{
	return mStream->getDesc(result);
}

int StreamLayer::setAccessMode(IOAccessMode mode)
{
	return mStream->setAccessMode(mode);
}

uint StreamLayer::read(void *buf, uint size)
{
	return mStream->read(buf, size);
}

uint StreamLayer::write(const void *buf, uint size)
{
	return mStream->write(buf, size);
}

Stream *StreamLayer::getLayered() const
{
	return mStream;
}

void StreamLayer::setLayered(Stream *newLayered, bool ownNewLayered)
{
	mStream = newLayered;
	mOwnStream = ownNewLayered;
}

/*
 *	ObjectStream
 */
ObjectStream::ObjectStream(Stream *s, bool own_s) : StreamLayer(s, own_s)
{
}

void ObjectStream::putCommentf(const char *comment_format, ...)
{
	char buf[1024];
	va_list arg;
	va_start(arg, comment_format);
	ht_vsnprintf(buf, sizeof buf, comment_format, arg);
	va_end(arg);
	putComment(buf);
}

/**
 *	A object-stream-layer.
 */
ObjectStreamLayer::ObjectStreamLayer(ObjectStream *aObjStream, bool own_ostream)
: ObjectStream(aObjStream, own_ostream)
{
	mObjStream = aObjStream;
}

void ObjectStreamLayer::getBinary(void *buf, uint size, const char *desc)
{
	return mObjStream->getBinary(buf, size, desc);
}

bool ObjectStreamLayer::getBool(const char *desc)
{
	return mObjStream->getBool(desc);
}

uint64 ObjectStreamLayer::getInt(uint size, const char *desc)
{
	return mObjStream->getInt(size, desc);
}

Object *ObjectStreamLayer::getObjectInternal(const char *name, ObjectID id)
{
	return mObjStream->getObjectInternal(name, id);
}

char *ObjectStreamLayer::getString(const char *desc)
{
	return mObjStream->getString(desc);
}

byte *ObjectStreamLayer::getLenString(int &len, const char *desc)
{
	return mObjStream->getLenString(len, desc);
}

void ObjectStreamLayer::putBinary(const void *mem, uint size, const char *desc)
{
	return mObjStream->putBinary(mem, size, desc);
}

void ObjectStreamLayer::putBool(bool b, const char *desc)
{
	return mObjStream->putBool(b, desc);
}

void ObjectStreamLayer::putComment(const char *comment)
{
	return mObjStream->putComment(comment);
}

void ObjectStreamLayer::putInt(uint64 i, uint size, const char *desc, uint int_fmt_hint)
{
	return mObjStream->putInt(i, size, desc, int_fmt_hint);
}

void ObjectStreamLayer::putObject(const Object *object, const char *name, ObjectID id)
{
	return mObjStream->putObject(object, name, id);
}

void ObjectStreamLayer::putSeparator()
{
	return mObjStream->putSeparator();
}

void ObjectStreamLayer::putString(const char *string, const char *desc)
{
	return mObjStream->putString(string, desc);
}

void ObjectStreamLayer::putLenString(const byte *string, int len, const char *desc)
{
	return mObjStream->putLenString(string, len, desc);
}

/*
 *	A File
 */
File::File()
{
	mcount = 0;
}

#define FILE_TRANSFER_BUFSIZE 4*1024
/**
 *	Low-level control function.
 *	@param cmd file control command number
 *	@returns 0 on success, POSIX.1 I/O error code on error
 */
int File::cntl(uint cmd, ...)
{
	va_list vargs;
	va_start(vargs, cmd);
	int ret = vcntl(cmd, vargs);
	va_end(vargs);
	return ret;
}

void File::move(FileOfs src, FileOfs dest, FileOfs size)
{
	if (dest < src) {
		char tbuf[FILE_TRANSFER_BUFSIZE];
		while (size != 0) {
			FileOfs k = size;
			if (k > sizeof tbuf) k = sizeof tbuf;
			seek(src);
			readx(tbuf, k);
			seek(dest);
			writex(tbuf, k);
			src += k;
			dest += k;
			size -= k;
		}
	} else if (dest > src) {
		src += size;
		dest += size;
		char tbuf[FILE_TRANSFER_BUFSIZE];
		while (size != 0) {
			FileOfs k = size;
			if (k > sizeof tbuf) k = sizeof tbuf;
			src -= k;
			dest -= k;
			seek(src);
			readx(tbuf, k);
			seek(dest);
			writex(tbuf, k);
			size -= k;
		}
	}
}

/**
 *	Cut out bytes from file.
 *	Cut out size bytes starting at current file pointer, ending at
 *	current file pointer + size. Does not modify the current file pointer.
 *
 *	@param size number of bytes to delete
 *	@throws IOException
 */
void File::cut(FileOfs size)
{
	FileOfs t = tell();
	FileOfs o = t+size;
	if (o > getSize()) throw IOException(EINVAL);
	FileOfs s = getSize()-o;
	move(o, t, s);
	truncate(getSize()-size);
	seek(t);
}

/**
 *	Extend file.
 *	Extend file to new size newsize.
 *	The current file pointer is undefined (but valid) after this operation.
 *
 *	@param newsize new extended file size
 *	@throws IOException
 */
void File::extend(FileOfs newsize)
{
	if (getSize() > newsize) throw IOException(EINVAL);
	if (getSize() == newsize) return;

	FileOfs save_ofs = tell();
	int e = 0;

	IOAccessMode oldmode = getAccessMode();
	if (!(oldmode & IOAM_WRITE)) {
		int f = setAccessMode(oldmode | IOAM_WRITE);
		if (f) throw IOException(f);
	}

	FileOfs s = getSize();
	char buf[FILE_TRANSFER_BUFSIZE];
	memset(buf, 0, sizeof buf);
	newsize -= s;
	seek(s);
	while (newsize != 0) {
		uint k = MIN(sizeof buf, newsize);
		uint l = write(buf, k);
		if (l != k) {
			e = EIO;
			break;
		}
		newsize -= l;
	}

	if (!(oldmode & IOAM_WRITE)) {
		int f = setAccessMode(oldmode);
		if (f) e = f;
	}
	if (e) throw IOException(e);
	seek(save_ofs);
}

/**
 *	Get filename.
 *
 *	@param result String that receives the filename
 *	@returns its argument
 */
String &File::getFilename(String &result) const
{
	result = "";
	return result;
}

/**
 *	Get file size.
 *
 *	@returns file size
 */
FileOfs File::getSize() const
{
	return 0;
}

#define FILE_INSERT_BUFSIZE 4*1024
/**
 *	Insert bytes into file.
 *	Insert size bytes from buf at the current file pointer
 *	into the file and extend file accordingly.
 *
 *	@param buf pointer to buffer that holds at least size bytes
 *	@param size number of bytes to insert
 *	@throws IOException
 */
void File::insert(const void *buf, FileOfs size)
{
	FileOfs t = tell();
	FileOfs s = getSize()-t;
	extend(getSize()+size);
	move(t, t+size, s);
	seek(t);
	writex(buf, size);
}

/**
 *	Get file status in a portable way.
 *	@param s structure that receives the file status
 */
void File::pstat(pstat_t &s) const
{
	s.caps = 0;
}

/**
 *	Set current file pointer.
 *	@param offset new value for current file pointer
 */
void File::seek(FileOfs offset)
{
	throw NotImplementedException(HERE);
}

/**
 *	Get current file pointer.
 *	@returns current file pointer
 */
FileOfs File::tell() const
{
	return 0;
}

/**
 *	Truncate file.
 *	Truncate file to new size newsize.
 *	The current file pointer is undefined (but valid) after this operation.
 *
 *	@param newsize new truncated file size
 *	@throws IOException
 */
void File::truncate(FileOfs newsize)
{
	if (getSize() < newsize) throw IOException(EINVAL);
	if (getSize() == newsize) return;

	throw NotImplementedException(HERE);
}

/**
 *	Vararg wrapper for cntl()
 */
int File::vcntl(uint cmd, va_list vargs)
{
	switch (cmd) {
		case FCNTL_GET_MOD_COUNT: {	// int &mcount
			int *mc = va_arg(vargs, int *);
			*mc = mcount;
			return 0;
		}
	}
	return ENOSYS;
}

char *File::fgetstrz()
{
	FileOfs o = tell();
	/* get string size */
	char buf[64];
	int s, z = 0;
	bool found = false;
	while (!found) {
		s = read(buf, 64);
		for (int i=0; i < s; i++) {
			z++;
			if (buf[i] == 0) {
				found = true;
				break;
			}
		}
		if (s < 64) {
			break;
		}
	}
	if (s == 0) return ht_strdup("");
	/* read string */
	char *str = ht_malloc(z);
	if (!str) throw std::bad_alloc();
	seek(o);
	readx(str, z);
	str[z-1] = 0;
	return str;
}

/*
 *	FileLayer
 */
FileLayer::FileLayer(File *f, bool own_f) : File()
{
	mFile = f;
	mOwnFile = own_f;
}

FileLayer::~FileLayer()
{
	if (mOwnFile) delete mFile;
}

void FileLayer::cut(FileOfs size)
{
	return mFile->cut(size);
}

void FileLayer::extend(FileOfs newsize)
{
	return mFile->extend(newsize);
}

IOAccessMode FileLayer::getAccessMode() const
{
	return mFile->getAccessMode();
}

String &FileLayer::getDesc(String &result) const
{
	return mFile->getDesc(result);
}

String &FileLayer::getFilename(String &result) const
{
	return mFile->getFilename(result);
}

FileOfs FileLayer::getSize() const
{
	return mFile->getSize();
}

void FileLayer::insert(const void *buf, FileOfs size)
{
	return mFile->insert(buf, size);
}

void FileLayer::pstat(pstat_t &s) const
{
	return mFile->pstat(s);
}

uint FileLayer::read(void *buf, uint size)
{
	return mFile->read(buf, size);
}

void FileLayer::seek(FileOfs offset)
{
	return mFile->seek(offset);
}

int FileLayer::setAccessMode(IOAccessMode mode)
{
	return mFile->setAccessMode(mode);
}

File *FileLayer::getLayered() const
{
	return mFile;
}

void FileLayer::setLayered(File *newLayered, bool ownNewLayered)
{
	mFile = newLayered;
	mOwnFile = ownNewLayered;
}

FileOfs FileLayer::tell() const
{
	return mFile->tell();
}

void FileLayer::truncate(FileOfs newsize)
{
	return mFile->truncate(newsize);
}

int FileLayer::vcntl(uint cmd, va_list vargs)
{
	return mFile->vcntl(cmd, vargs);
}

uint FileLayer::write(const void *buf, uint size)
{
	return mFile->write(buf, size);
}

/*
 *	LocalFileFD
 */

/**
 *	create open file
 */
LocalFileFD::LocalFileFD(const String &aFilename, IOAccessMode am, FileOpenMode om)
 : File(), mFilename(aFilename)
{
	mOpenMode = om;
	fd = -1;
	own_fd = false;
	int e = setAccessMode(am);
	if (e) throw IOException(e);
	mOpenMode = FOM_EXISTS;
}

/**
 *	map a file descriptor [fd]
 */
LocalFileFD::LocalFileFD(int f, bool own_f, IOAccessMode am)
 : File()
{
	mFilename = NULL;
	fd = f;
	own_fd = own_f;
	offset = 0;
	int e = File::setAccessMode(am);
	if (e) throw IOException(e);
}

LocalFileFD::~LocalFileFD()
{
	if (own_fd && (fd>=0)) ::close(fd);
}

String &LocalFileFD::getDesc(String &result) const
{
	result = mFilename;
	return result;
}

String &LocalFileFD::getFilename(String &result) const
{
	result = mFilename;
	return result;
}

FileOfs LocalFileFD::getSize() const
{
	FileOfs t = tell();
	off_t r = ::lseek(fd, 0, SEEK_END);
	if (r == (off_t)-1) return 0;	// hm...
	::lseek(fd, t, SEEK_SET);
	return r;
}

uint LocalFileFD::read(void *buf, uint size)
{
	if (!(getAccessMode() & IOAM_READ)) throw IOException(EACCES);
	errno = 0;
	uint r = ::read(fd, buf, size);
	int e = errno;
	if (e) {
		::lseek(fd, 0, SEEK_SET);
		offset = 0;
		if (e != EAGAIN) throw IOException(e);
		return 0;
	} else {
		offset += r;
		return r;
	}		
}

void LocalFileFD::seek(FileOfs o)
{
	off_t r = ::lseek(fd, o, SEEK_SET);
	if (r == (off_t)-1) throw IOException(errno);
	offset = r;
	if (offset != o) throw IOException(EIO);
}

int LocalFileFD::setAccessMode(IOAccessMode am)
{
	IOAccessMode orig_access_mode = getAccessMode();
	int e = setAccessModeInternal(am);
	if (e && setAccessModeInternal(orig_access_mode))
		throw IOException(e);
	return e;
}

int LocalFileFD::setAccessModeInternal(IOAccessMode am)
{
//RETRY:
	if (getAccessMode() == am) return 0;
	if (fd >= 0) {
		// must own fd to change its access mode cause we can't
		// reopen a fd. right?
		if (!own_fd) throw NotImplementedException(HERE);
		// FIXME: race condition here, how to reopen a fd atomically?
		close(fd);
		fd = -1;
	}
	File::setAccessMode(IOAM_NULL);

	int mode = 0;

	if ((am & IOAM_READ) && (am & IOAM_WRITE)) mode = O_RDWR;
	else if (am & IOAM_READ) mode = O_RDONLY;
	else if (am & IOAM_WRITE) mode = O_WRONLY;

//	mode |= O_BINARY;

	switch (mOpenMode) {
	case FOM_APPEND:
		mode |= O_APPEND;
		break;
	case FOM_CREATE:
		mode |= O_CREAT | O_TRUNC;
		break;
	case FOM_EXISTS:
		;
	}

	int e = 0;
	if (am != IOAM_NULL) {
		pstat_t s;
		fd = ::open(mFilename.contentChar(), mode);
		if (fd < 0) e = errno;
		if (!e) {
			own_fd = true;
			e = sys_pstat_fd(s, fd);
			if (!e) {
				if (HT_S_ISDIR(s.mode)) {
					e = EISDIR;
				} else if (!HT_S_ISREG(s.mode) && !HT_S_ISBLK(s.mode)) {
					e = EINVAL;
				}
			}
		}
	}
	return e ? e : File::setAccessMode(am);
}

FileOfs LocalFileFD::tell() const
{
	return offset;
}

void LocalFileFD::truncate(FileOfs newsize)
{
	errno = 0;
	int e = sys_truncate_fd(fd, newsize);
	if (errno) e = errno;
	if (e) throw IOException(e);
}

int LocalFileFD::vcntl(uint cmd, va_list vargs)
{
	switch (cmd) {
		case FCNTL_FLUSH_STAT: {
			IOAccessMode m = getAccessMode();
			int e, f;
			e = setAccessMode(IOAM_NULL);
			f = setAccessMode(m);
			return e ? e : f;
		}
		case FCNTL_GET_FD: {	// (int &fd)
			int *pfd = va_arg(vargs, int*);
			*pfd = fd;
			return 0;
		}
	}
	return File::vcntl(cmd, vargs);
}

uint LocalFileFD::write(const void *buf, uint size)
{
	if (!(getAccessMode() & IOAM_WRITE)) throw IOException(EACCES);
	errno = 0;
	uint r = ::write(fd, buf, size);
	int e = errno;
	if (e) {
		::lseek(fd, 0, SEEK_SET);
		offset = 0;
		if (e != EAGAIN) throw IOException(e);
		return 0;
	} else {
		offset += r;
		return r;
	}		
}

/*
 *	StdIoFile
 */

/**
 *	create open file
 */
LocalFile::LocalFile(const String &aFilename, IOAccessMode am, FileOpenMode om)
 : File(), mFilename(aFilename)
{
	mOpenMode = om;
	file = NULL;
	own_file = false;
	offset = 0;
	int e = LocalFile::setAccessMode(am);
	if (e) throw IOException(e);
	mOpenMode = FOM_EXISTS;
}

/**
 *	map a file stream [FILE*]
 */
LocalFile::LocalFile(SYS_FILE *f, bool own_f, IOAccessMode am)
 : File()
{
	file = f;
	own_file = own_f;
	File::setAccessMode(am);
}

LocalFile::~LocalFile()
{
	if (own_file && file) sys_fclose(file);
}

String &LocalFile::getDesc(String &result) const
{
	result = mFilename;
	return result;
}

String &LocalFile::getFilename(String &result) const
{
	result = mFilename;
	return result;
}

FileOfs LocalFile::getSize() const
{
	FileOfs t = tell();
	sys_fseek(file, 0, SYS_SEEK_END);
	FileOfs r = sys_ftell(file);
	sys_fseek(file, t, SYS_SEEK_SET);
	return r;
}

void LocalFile::pstat(pstat_t &s) const
{
	sys_pstat_file(s, file);
}

uint LocalFile::read(void *buf, uint size)
{
	if (!(getAccessMode() & IOAM_READ)) throw IOException(EACCES);
	errno = 0;
	uint r = sys_fread(file, (byte*)buf, size);
	if (errno) throw IOException(errno);
	offset += r;
	return r;
}

void LocalFile::seek(FileOfs o)
{
	int e = sys_fseek(file, o, SYS_SEEK_SET);
	if (e) throw IOException(e);
	offset = o;
}

int LocalFile::setAccessMode(IOAccessMode am)
{
	IOAccessMode orig_access_mode = getAccessMode();
	int e = setAccessModeInternal(am);
	if (e && setAccessModeInternal(orig_access_mode))
		throw IOException(e);
	return e;
}

int LocalFile::setAccessModeInternal(IOAccessMode am)
{
//RETRY:
	if (getAccessMode() == am) return 0;

	int e = 0;
	if (am != IOAM_NULL) {
		pstat_t s;
		if (file) {
			file = sys_freopen(mFilename.contentChar(), mOpenMode, am, file);
			if (!file) setAccessMode(IOAM_NULL);
		} else {
			file = sys_fopen(mFilename.contentChar(), mOpenMode, am);
		}
		if (!file) e = errno;
		if (!e) {
			own_file = true;
			e = sys_pstat_file(s, file);
			if (!e) {
				if (HT_S_ISDIR(s.mode)) {
					e = EISDIR;
				} else if (!HT_S_ISREG(s.mode) && !HT_S_ISBLK(s.mode)) {
					e = EINVAL;
				}
			}
		}
	} else {
		if (file) {
			sys_fclose(file);
			file = NULL;
		}
	}
	return e ? e : File::setAccessMode(am);
}

FileOfs LocalFile::tell() const
{
	return offset;
}

void LocalFile::truncate(FileOfs newsize)
{
	errno = 0;

	IOAccessMode old_am = getAccessMode();
	int e;
	e = setAccessMode(IOAM_NULL);
	if (!e) {
		e = sys_truncate(mFilename.contentChar(), newsize);
		if (errno) e = errno;
	}
	if (!e) e = setAccessMode(old_am);
	if (e) throw IOException(e);
}

int LocalFile::vcntl(uint cmd, va_list vargs)
{
	switch (cmd) {
	case FCNTL_FLUSH_STAT: {
		IOAccessMode m = getAccessMode();
		int e, f;
		e = setAccessMode(IOAM_NULL);
		f = setAccessMode(m);
		return e ? e : f;
	}
	case FCNTL_GET_FD: 	// (int &fd)
/*		if (file) {
			int *pfd = va_arg(vargs, int*);
			*pfd = fileno(file);
			return 0;
		}*/
		// FIXME:
		assert(0);
		break;
	}
	return File::vcntl(cmd, vargs);
}

uint LocalFile::write(const void *buf, uint size)
{
	if (!(getAccessMode() & IOAM_WRITE)) throw IOException(EACCES);
	errno = 0;
	uint r = sys_fwrite(file, (byte*)buf, size);
	if (errno) throw IOException(errno);
	offset += r;
	return r;
}

/*
 *	TempFile
 */
TempFile::TempFile(uint am) : LocalFile(tmpfile(), true, am)
{
}

String &TempFile::getDesc(String &result) const
{
	result = "temporary file";
	return result;
}

void TempFile::pstat(pstat_t &s) const
{
	s.caps = pstat_size;
	s.size = getSize();
}

/*
 *	MemMapFile
 */
MemMapFile::MemMapFile(void *b, uint s, FileOfs ofs) : ConstMemMapFile(b, s, ofs)
{
}

uint MemMapFile::write(const void *b, uint size)
{
	if (pos > this->size) return 0;	// or throw exception?
	if (pos+size > this->size) size = this->size - pos;
	memcpy(((byte*)buf) + pos, b, size);
	pos += size;
	return size;
}

/*
 *	ConstMemMapFile
 */
ConstMemMapFile::ConstMemMapFile(const void *b, uint s, FileOfs o)
: File()
{
	buf = b;
	pos = 0;
	size = s;
	ofs = o;
}

String &ConstMemMapFile::getDesc(String &result) const
{
	result = "ConstMemMapFile";
	return result;
}

FileOfs ConstMemMapFile::getSize() const
{
	return size;
}

uint ConstMemMapFile::read(void *b, uint size)
{
	if (pos > this->size) return 0;
	if (pos+size > this->size) size = this->size - pos;
	memcpy(b, (const byte*)buf+pos, size);
	pos += size;
	return size;
}

void ConstMemMapFile::seek(FileOfs offset)
{
	pos = offset - ofs;
}

FileOfs ConstMemMapFile::tell() const
{
	return pos + ofs;
}

/*
 *	NullFile
 */
NullFile::NullFile() : File()
{
}

void NullFile::extend(FileOfs newsize)
{
	if (newsize != 0) throw IOException(EINVAL);
}

String &NullFile::getDesc(String &result) const
{
	result = "null device";
	return result;
}

FileOfs NullFile::getSize() const
{
	return 0;
}

void NullFile::pstat(pstat_t &s) const
{
	s.caps = pstat_size;
	s.size = getSize();
}

uint NullFile::read(void *buf, uint size)
{
	return 0;
}

void NullFile::seek(FileOfs offset)
{
	if (offset != 0) throw IOException(EINVAL);
}

int NullFile::setAccessMode(IOAccessMode am)
{
	return (am == getAccessMode()) ? 0 : EACCES;
}

FileOfs NullFile::tell() const
{
	return 0;
}

void NullFile::truncate(FileOfs newsize)
{
	if (newsize != 0) throw IOException(EINVAL);
}

uint NullFile::write(const void *buf, uint size)
{
	return 0;
}

/*
 *	MemoryFile
 */
#define MEMORYFILE_GROW_FACTOR_NUM		4
#define MEMORYFILE_GROW_FACTOR_DENOM		3
#define MEMORYFILE_MIN_BUFSIZE			32

MemoryFile::MemoryFile(FileOfs o, uint size, IOAccessMode mode) : File()
{
	ofs = o;
	dsize = size;
	buf = NULL;
	ibufsize = size;
	if (ibufsize < MEMORYFILE_MIN_BUFSIZE) ibufsize = MEMORYFILE_MIN_BUFSIZE;
	resizeBuf(ibufsize);
	memset(buf, 0, dsize);
	mcount = 0;

	pos = 0;
	int e = setAccessMode(mode);
	if (e) throw IOException(e);
}

MemoryFile::~MemoryFile()
{
	free(buf);
}

byte *MemoryFile::getBufPtr() const
{
	return buf;
}

void MemoryFile::extend(FileOfs newsize)
{
	// MemoryFiles may not be > 2G
	if (newsize > 0x7fffffff) throw IOException(EINVAL);
	if (newsize < getSize()) throw IOException(EINVAL);
	if (newsize == getSize()) return;
	while (bufsize dsize) {
		if (pos >= dsize) return 0;
		size = dsize-pos;
	}
	memcpy(b, buf+pos, size);
	pos += size;
	return size;
}

void MemoryFile::resizeBuf(uint newsize)
{
	bufsize = newsize;

	assert(dsize <= bufsize);

	buf = (byte*)realloc(buf, bufsize ? bufsize : 1);
	if (!buf) throw std::bad_alloc();
}

void MemoryFile::seek(FileOfs o)
{
	if (o= bufsize) extendBuf();
	memcpy(((byte*)buf) + pos, b, size);
	pos += size;
	if (pos > dsize) dsize = pos;
	mcount++;
	return size;
}

/*
 *	A file layer, representing a cropped version of a file
 */
CroppedFile::CroppedFile(File *file, bool own_file, FileOfs aCropStart, FileOfs aCropSize)
: FileLayer(file, own_file)
{
	mCropStart = aCropStart;
	mHasCropSize = true;
	mCropSize = aCropSize;
	seek(0);
}

CroppedFile::CroppedFile(File *file, bool own_file, FileOfs aCropStart)
: FileLayer(file, own_file)
{
	mCropStart = aCropStart;
	mHasCropSize = false;
	seek(0);
}

void CroppedFile::extend(FileOfs newsize)
{
	throw IOException(ENOSYS);
}

String &CroppedFile::getDesc(String &result) const
{
	String s;
	if (mHasCropSize) {
		result.assignFormat("[->%qx,%qx] of %y", mCropStart, mCropSize, &FileLayer::getDesc(s));
	} else {
		result.assignFormat("[->%qx,...] of %y", mCropStart, &FileLayer::getDesc(s));
	}
	return result;
}

FileOfs	CroppedFile::getSize() const
{
	FileOfs lsize = FileLayer::getSize();
	if (lsize < mCropStart) return 0;
	lsize -= mCropStart;
	if (mHasCropSize) {
		if (lsize > mCropSize) lsize = mCropSize;
	}
	return lsize;
}

void CroppedFile::pstat(pstat_t &s) const
{
	FileLayer::pstat(s);
	if (s.caps & pstat_size) {
		s.size = getSize();
	}
}

uint CroppedFile::read(void *buf, uint size)
{
	FileOfs offset = FileLayer::tell();
	if (offset= mCropStart+mCropSize) return 0;
		if (offset+size >= mCropStart+mCropSize) size = mCropStart+mCropSize-offset;
	}
	return FileLayer::read(buf, size);
}

void CroppedFile::seek(FileOfs offset)
{
/*	if (mHasCropSize) {
...
		if (offset>mCropStart) throw IOException(EIO);
	}*/
	FileLayer::seek(offset+mCropStart);
}

FileOfs CroppedFile::tell() const
{
	FileOfs offset = FileLayer::tell();
	if (offset < mCropStart) throw IOException(EIO);
	return offset - mCropStart;
}

void CroppedFile::truncate(FileOfs newsize)
{
	// not implemented because not considered safe
	throw IOException(ENOSYS);
}

uint CroppedFile::write(const void *buf, uint size)
{
	FileOfs offset = FileLayer::tell();
	if (offset= mCropStart+mCropSize) return 0;
		if (offset+size >= mCropStart+mCropSize) size = mCropStart+mCropSize-offset;
	}
	return FileLayer::write(buf, size);
}


ht-2.0.22/class.h0000644000175000001440000001237310615341616010414 00000000000000/*
 *	HT Editor
 *	class.h
 *
 *	Copyright (C) 2001 Stanley Gambarin 
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef _CLASS_H
#define _CLASS_H

#include "htformat.h"
#include "stddata.h"

typedef unsigned char  u1;
typedef unsigned int   u2;
typedef unsigned long  u4;

/* flags */
static const u2 jACC_PUBLIC                 = 0x0001;
static const u2 jACC_PRIVATE                = 0x0002;
static const u2 jACC_PROTECTED              = 0x0004;
static const u2 jACC_STATIC                 = 0x0008;
static const u2 jACC_FINAL                  = 0x0010;
static const u2 jACC_SUPER                  = 0x0020;
static const u2 jACC_SYNCHRONIZED           = 0x0020;
static const u2 jACC_VOLATILE               = 0x0040;
static const u2 jACC_TRANSIENT              = 0x0080;
static const u2 jACC_NATIVE                 = 0x0100;
static const u2 jACC_INTERFACE              = 0x0200;
static const u2 jACC_ABSTRACT               = 0x0400;
static const u2 jACC_STRICT                 = 0x0800;
static const u2 jACC_JNM                    = 0x4000;

/* constant pool tags */
static const u1 CONSTANT_Utf8               =  1;
static const u1 CONSTANT_Integer            =  3;
static const u1 CONSTANT_Float              =  4;
static const u1 CONSTANT_Long               =  5;
static const u1 CONSTANT_Double             =  6;
static const u1 CONSTANT_Class              =  7;
static const u1 CONSTANT_String             =  8;
static const u1 CONSTANT_Fieldref           =  9;
static const u1 CONSTANT_Methodref          = 10;
static const u1 CONSTANT_InterfaceMethodref = 11;
static const u1 CONSTANT_NameAndType        = 12;

struct cp_info {
	u4 offset;
	u1 tag;
	union {
		char   *string;
		double dval;
		float  fval;
		sint32 ival;
		uint32 llval[2];
	} value;
};

static const u2 ATTRIB_ConstantValue      =  1;
static const u2 ATTRIB_Code               =  2;
static const u2 ATTRIB_Exceptions         =  3;
static const u2 ATTRIB_InnerClasses       =  4;
static const u2 ATTRIB_Synthetic          =  5;
static const u2 ATTRIB_SourceFile         =  6;
static const u2 ATTRIB_LineNumberTable    =  7;
static const u2 ATTRIB_LocalVariableTable =  8;
static const u2 ATTRIB_Deprecated         =  9;
static const u2 ATTRIB_Signature          =  10;

struct exception_info {
	u2 start_pc;
	u2 end_pc;
	u2 handler_pc;
	u2 catch_type;
};

struct attrib_info {
	u4 offset;
	u2 tag;
	u2 name;
	u4 len;
	union {
		struct {
			u2 max_stack;
			u2 max_locals;
			u4 len;
			u4 start;
			u2 exctbl_len;
			exception_info *exctbl;
		} code;
		u2 signature;
	};
};

/* mf_info */
struct mf_info {
	u4 offset;
	u2 flags;
	char *name;
	char *desc;
	u2 attribs_count;
	attrib_info **attribs;
};

/* classfile */
struct classfile {
	u4 offset;
	u4 magic;
	u2 minor_version;
	u2 major_version;
	u2 cpool_count;
	cp_info **cpool;
	u4 coffset;
	u2 access_flags;
	u2 this_class;
	u2 super_class;
	u2 interfaces_count;
	u2 *interfaces;
	u4 foffset;
	u2 fields_count;
	mf_info **fields;
	u4 moffset;
	u2 methods_count;
	mf_info **methods;
	u4 aoffset;
	u2 attribs_count;
	attrib_info **attribs;
};

struct ht_class_shared_data {
	Container	*methods;
	Container	*fields;
	classfile	*file;
	Area		*valid;
	Area		*initialized;
	int		flags;
	struct {
		char *thisclass;
		char *superclass;
		Container *interfaces;
	} classinfo;
};

extern ht_class_shared_data *class_read(File *);
extern void class_unread(ht_class_shared_data *);
extern attrib_info *attribute_read(Stream *, classfile *);

int token_translate(char *buf, int maxlen, uint32 token, ht_class_shared_data *shared);
void java_demangle(char *result, const char *classname, const char *name, const char *type, int flags);
void java_demangle_field(char *result, const char *name, const char *type, int flags);
char *java_demangle_flags(char *result, int flags);

class cview: public ht_format_group {
public:
	void init(Bounds *, File *, format_viewer_if **, ht_format_group *, FileOfs, void *shared);
	virtual void done();
};

#define ClassAddress uint32

class ClassMethod: public Object {
public:
	const char *name;
	const char *type;
	ClassAddress start;
	uint length;
	int flags;
	int exctbl_len;
	exception_info *exctbl;

			ClassMethod(char *name, char *type, ClassAddress start, uint length, int flags,
				int exctbl_len, exception_info *exctbl);
	virtual int	compareTo(const Object *obj) const;
		void	addsig(const char *s) { type = s; } 
};

class ClassField: public Object {
public:
	const char *name;
	const char *type;
	int flags;

			ClassField(char *name, char *type, int flags);
		void	addsig(const char *s) { type = s; } 
};


#define DESC_JAVA		"java - class file"
#define DESC_JAVA_HEADERS	"java/headers"
#define DESC_JAVA_IMAGE		"java/image"

extern format_viewer_if htcls_if;

#endif /* _CLASS_H */

ht-2.0.22/htlevxd.h0000644000175000001440000000152110206756710010757 00000000000000/* 
 *	HT Editor
 *	htlevxd.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTLEVXD_H__
#define __HTLEVXD_H__

#include "formats.h"

extern format_viewer_if htlevxd_if;

#endif /* !__HTLEVXD_H__ */
ht-2.0.22/htpe.h0000644000175000001440000000663410615341623010250 00000000000000/* 
 *	HT Editor
 *	htpe.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTPE_H__
#define __HTPE_H__

#include "formats.h"
#include "pestruct.h"
#include "htpeexp.h"
#include "htpeil.h"
#include "htpeimp.h"
#include "htpedimp.h"

#define DESC_PE "pe - win32 portable exe"
#define DESC_PE_HEADER "pe/header"
#define DESC_PE_IMPORTS "pe/imports"
#define DESC_PE_DIMPORTS "pe/delay-imports"
#define DESC_PE_EXPORTS "pe/exports"
#define DESC_PE_RESOURCES "pe/resources"
#define DESC_PE_IMAGE "pe/image"
#define DESC_PE_IL "pe/il"

#define ATOM_PE_MACHINES 			0x50450000
#define ATOM_PE_MACHINES_STR			 "50450000"

#define ATOM_PE_OPTIONAL_MAGICS 		0x50450001
#define ATOM_PE_OPTIONAL_MAGICS_STR 		 "50450001"

#define ATOM_PE_SUBSYSTEMS 			0x50450002
#define ATOM_PE_SUBSYSTEMS_STR 			 "50450002"

#define ATOM_PE_CHARACTERISTICS			0x50450003
#define ATOM_PE_CHARACTERISTICS_STR		 "50450003"

#define ATOM_PE_DLL_CHARACTERISTICS		0x50450004
#define ATOM_PE_DLL_CHARACTERISTICS_STR		 "50450004"

#define ATOM_PE_SECTION_CHARACTERISTICS		0x50450005
#define ATOM_PE_SECTION_CHARACTERISTICS_STR	 "50450005"

extern format_viewer_if htpe_if;

struct pe_section_headers {
	uint section_count;
	COFF_SECTION_HEADER *sections;
};

struct ht_pe_shared_data {
	FileOfs header_ofs;
	COFF_HEADER coffheader;
	uint16 opt_magic;
	union {
		struct {
			COFF_OPTIONAL_HEADER32 header;
			PE_OPTIONAL_HEADER32_NT header_nt;
		} pe32;
		struct {
			COFF_OPTIONAL_HEADER64 header;
			PE_OPTIONAL_HEADER64_NT header_nt;
		} pe64;
	};
	pe_section_headers sections;
	ht_pe_il *il;
	ht_pe_export exports;
	ht_pe_import imports;
	ht_pe_import dimports;
	ht_format_viewer *v_header;
	ht_view *v_exports;
	ht_view *v_imports;
	ht_view *v_dimports;
	ht_view *v_resources;
	ht_view *v_il;
	ht_format_viewer *v_image;	
};

/*
 *	CLASS ht_pe
 */

class ht_pe: public ht_format_group {
protected:
	bool loc_enum;
public:
		void init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs);
	virtual	void done();
/* overwritten */
	virtual   void loc_enum_start();
	virtual   bool loc_enum_next(ht_format_loc *loc);
};

bool pe_rva_to_section(pe_section_headers *section_headers, RVA rva, int *section);
bool pe_rva_to_ofs(pe_section_headers *section_headers, RVA rva, FileOfs *ofs);
bool pe_rva_is_valid(pe_section_headers *section_headers, RVA rva);
bool pe_rva_is_physical(pe_section_headers *section_headers, RVA rva);

bool pe_ofs_to_rva(pe_section_headers *section_headers, FileOfs ofs, RVA *rva);
bool pe_ofs_to_section(pe_section_headers *section_headers, FileOfs ofs, int *section);
bool pe_ofs_to_rva_and_section(pe_section_headers *section_headers, FileOfs ofs, RVA *rva, int *section);

bool pe_section_name_to_section(pe_section_headers *section_headers, const char *name, int *section);

#endif /* !__HTPE_H__ */
ht-2.0.22/htpal.h0000644000175000001440000000672010615341623010414 00000000000000/* 
 *	HT Editor
 *	htpal.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTPAL_H__
#define __HTPAL_H__

#include "data.h"
#include "htobj.h"
#include "htreg.h"

#define rnt_palette_name		"palette"

struct defpal {
	int idx;
	const char *name;
	int color;
};

/*
 *	CLASS palette_entry
 */

class palette_entry: public ht_registry_data {
public:
	uint idx;
	vcp color;

		palette_entry(uint idx=0, vcp color=0);
		palette_entry(BuildCtorArg&a): ht_registry_data(a) {};
/* overwritten */
	virtual	bool editdialog(const char *keyname);
	virtual void strvalue(char *buf32bytes);
	virtual	void load(ObjectStream &f);
	virtual	ObjectID getObjectID() const;
	virtual	void store(ObjectStream &f) const;
};

/*
 *	palette_key
 */

#define palettekey "palette"

/*
 *   palette class keys
 */

#define palclasskey_generic					"generic"
#define palclasskey_tags	     				"tags"
#define palclasskey_syntax	     				"syntax"

/*
 *	generic palette
 */

#define palkey_generic_window_default				"window"
#define palkey_generic_dialog_default				"dialog"
#define palkey_generic_menu_default				"menu"
#define palkey_generic_keys_default				"keyline"
#define palkey_generic_desktop_default				"desktop"
#define palkey_generic_help_default				"help"

#define palkey_generic_cyan					"cyan"
#define palkey_generic_black					"black"
#define palkey_generic_blue					"blue"
#define palkey_generic_gray					"gray"
#define palkey_generic_special					"special"

#define palidx_generic_body					0
#define palidx_generic_text_focused				1
#define palidx_generic_text_unfocused				2
#define palidx_generic_text_shortcut				3
#define palidx_generic_text_shortcut_selected			4
#define palidx_generic_text_selected				5
#define palidx_generic_text_disabled				6
#define palidx_generic_frame_focused				7
#define palidx_generic_frame_unfocused				8
#define palidx_generic_frame_move_resize			9
#define palidx_generic_frame_killer				10
#define palidx_generic_scrollbar				11
#define palidx_generic_input_focused				12
#define palidx_generic_input_unfocused				13
#define palidx_generic_input_selected				14
#define palidx_generic_input_clip 				15
#define palidx_generic_button_focused				16
#define palidx_generic_button_unfocused				17
#define palidx_generic_button_shadow 				18
#define palidx_generic_button_shortcut				19
#define palidx_generic_list_focused_selected			20
#define palidx_generic_list_focused_unselected			21
#define palidx_generic_list_unfocused_selected			22
#define palidx_generic_list_unfocused_unselected		23
#define palidx_generic_cluster_focused				24
#define palidx_generic_cluster_unfocused			25
#define palidx_generic_cluster_shortcut				26

/*
 *   reg/pal management
 */

vcp getcolorv(palette *pal, uint index);
bool load_pal(const char *pal_class, const char *pal_flavour, palette *p);

/*
 *	INIT
 */

bool init_pal();

/*
 *	DONE
 */

void done_pal();

#endif /* !__HTPAL_H__ */
ht-2.0.22/htelfsym.h0000644000175000001440000000156210206756707011147 00000000000000/* 
 *	HT Editor
 *	htelfsym.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __HTELFSYM_H__
#define __HTELFSYM_H__

#include "htobj.h"
#include "formats.h"

extern format_viewer_if htelfsymboltable_if;

#endif /* !__HTELFSYM_H__ */

ht-2.0.22/fltstruc.h0000644000175000001440000000346710615341616011161 00000000000000/* 
 *	HT Editor
 *	fltstruc.h
 *
 *	Copyright (C) 2003 Sebastian Biallas (sb@biallas.net)
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __FLTSTRUC_H__
#define __FLTSTRUC_H__

#include "io/types.h"

#define FLTMAG0 'b'
#define FLTMAG1 'F'
#define FLTMAG2 'L'
#define FLTMAG3 'T'

struct flat_hdr {
	byte magic[4];			/* bFLT magic */
	uint32 version;			/* binfmt_flat version */
	uint32 entry;			/* Offset of first executable instruction with text segment from beginning of file*/
	uint32 data_start;		/* Offset of data segment from beginning of file*/
	uint32 data_end;			/* Offset of end of data segment from beginning of file*/
	uint32 bss_end;			/* Offset of end of bss segment from beginning of file*/
					/* (It is assumed that data_end through bss_end for bss segment.) */
	uint32 stack_size;		/* Size of stack, in bytes */
	uint32 reloc_start;		/* Offset of relocation records from beginning of file */
	uint32 reloc_count;		/* Number of relocation records */
	uint32 filler[7];		/* Reservered, set to zero */
};

#define FLAT_RELOC_TYPE_TEXT 0
#define FLAT_RELOC_TYPE_DATA 1
#define FLAT_RELOC_TYPE_BSS 2

struct flat_reloc {
	uint32 value; /* 2: type, 30: offset */
};

extern byte FLAT_HEADER_struct[20];

#endif /* __FLTSTRUC_H__ */
ht-2.0.22/htlevxd.cc0000644000175000001440000000717410615341620011121 00000000000000/* 
 *	HT Editor
 *	htlevxd.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "atom.h"
#include "htnewexe.h"
#include "htle.h"
#include "htlevxd.h"
#include "httag.h"
#include "formats.h"
#include "snprintf.h"

#include "lestruct.h"

static ht_mask_ptable le_vxd_header[]=
{
	{"next",							STATICTAG_EDIT_DWORD_LE("00000000")},
	{"SDK version",					STATICTAG_EDIT_WORD_LE("00000004")},
	{"device number",					STATICTAG_EDIT_WORD_LE("00000006")},
	{"version major",					STATICTAG_EDIT_BYTE("00000008")},
	{"version minor",					STATICTAG_EDIT_BYTE("00000009")},
	{"flags",							STATICTAG_EDIT_WORD_LE("0000000a")},
	{"name",							STATICTAG_EDIT_CHAR("0000000c")STATICTAG_EDIT_CHAR("0000000d")STATICTAG_EDIT_CHAR("0000000e")STATICTAG_EDIT_CHAR("0000000f")STATICTAG_EDIT_CHAR("00000010")STATICTAG_EDIT_CHAR("00000011")STATICTAG_EDIT_CHAR("00000012")STATICTAG_EDIT_CHAR("00000013")},
	{"init order",						STATICTAG_EDIT_DWORD_LE("00000014")},
	{"offset of control function",		STATICTAG_EDIT_DWORD_LE("00000018")},
	{"offset of V86-control function",		STATICTAG_EDIT_DWORD_LE("0000001c")},
	{"offset of PM-control function",		STATICTAG_EDIT_DWORD_LE("00000020")},
	{"CS:IP of V86-control function",		STATICTAG_EDIT_DWORD_LE("00000024")},
	{"CS:IP of PM-control function",		STATICTAG_EDIT_DWORD_LE("00000028")},
	{"reference data from real mode",		STATICTAG_EDIT_DWORD_LE("0000002c")},
	{"offset of service table",			STATICTAG_EDIT_DWORD_LE("00000030")},
	{"size of service table",			STATICTAG_EDIT_DWORD_LE("00000034")},
	{"offset of win32 service table",		STATICTAG_EDIT_DWORD_LE("00000038")},
	{"prev",							STATICTAG_EDIT_CHAR("0000003c")STATICTAG_EDIT_CHAR("0000003d")STATICTAG_EDIT_CHAR("0000003e")STATICTAG_EDIT_CHAR("0000003f")},
	{"size of this structure",			STATICTAG_EDIT_DWORD_LE("00000040")},
	{"reserved",						STATICTAG_EDIT_CHAR("00000044")STATICTAG_EDIT_CHAR("00000045")STATICTAG_EDIT_CHAR("00000046")STATICTAG_EDIT_CHAR("00000047")},
	{"reserved",						STATICTAG_EDIT_CHAR("00000048")STATICTAG_EDIT_CHAR("00000049")STATICTAG_EDIT_CHAR("0000004a")STATICTAG_EDIT_CHAR("0000004b")},
	{"reserved",						STATICTAG_EDIT_CHAR("0000004c")STATICTAG_EDIT_CHAR("0000004d")STATICTAG_EDIT_CHAR("0000004e")STATICTAG_EDIT_CHAR("0000004f")},
	{ NULL, NULL }
};

static ht_view *htlevxd_init(Bounds *b, File *file, ht_format_group *group)
{
	ht_le_shared_data *le_shared=(ht_le_shared_data *)group->get_shared_data();
	if (!le_shared->is_vxd) return NULL;
	File *myfile = le_shared->reloc_file;

	/* FIXME: */
	bool le_bigendian = false;

	ht_uformat_viewer *v = new ht_uformat_viewer();
	v->init(b, DESC_LE_VXD, VC_EDIT | VC_SEARCH, myfile, group);
	ht_mask_sub *m = new ht_mask_sub();
	m->init(myfile, 0);

	char info[128];
	ht_snprintf(info, sizeof info, "* LE VXD descriptor in section 1, offset %08qx", le_shared->vxd_desc_linear_ofs);
	m->add_mask(info);
	m->add_staticmask_ptable(le_vxd_header, le_shared->vxd_desc_linear_ofs, le_bigendian);
	v->insertsub(m);

	le_shared->v_le_vxd = v;
	return v;
}

format_viewer_if htlevxd_if = {
	htlevxd_init,
	0
};
ht-2.0.22/Makefile.am0000644000175000017500000000737212127651416011203 00000000000000AM_CPPFLAGS = ${my_CPPFLAGS} -I$(srcdir)/$(ANALYSER_DIR) \
              -I$(srcdir)/$(ASM_DIR) -I$(srcdir)/$(INFO_DIR) \
              -I$(srcdir)/$(IO_DIR) -I$(srcdir)/$(COMIO_DIR) \
              -I$(srcdir)/$(OUTPUT_DIR) -I$(srcdir)/$(EVAL_DIR) -I$(srcdir)
AM_CFLAGS   = ${my_CFLAGS}
AM_CXXFLAGS = ${my_CXXFLAGS}

bin_PROGRAMS	= ht

ANALYSER_DIR	= analyser
ASM_DIR		= asm
INFO_DIR	= info
COMIO_DIR	= io
IO_DIR		= io/@IO_DIR@
OUTPUT_DIR	= output
EVAL_DIR	= eval
#SRT_DIR		= srt
EXTRA_DIST	= TODO ChangeLog README KNOWNBUGS INSTALL COPYING AUTHORS
SUBDIRS		= tools analyser asm doc info io output eval

ht_LDADD	= $(ANALYSER_DIR)/libanalyser.a $(ASM_DIR)/libasm.a $(INFO_DIR)/libinfo.a $(IO_DIR)/libhtio.a $(OUTPUT_DIR)/liboutput.a $(COMIO_DIR)/libcomio.a $(EVAL_DIR)/libhteval.a ${HT_LIBS} ${LZO_LIBS} ${curses_LIBS}
ht_LDFLAGS	= ${HT_LDFLAGS}

if ENABLE_INCLUDED_LZO
SUBDIRS += minilzo
ht_LDADD += minilzo/liblzo.a
endif

ht_SOURCES	= atom.cc atom.h except.cc except.h data.cc data.h \
str.cc str.h strtools.cc strtools.h endianess.h endianess.cc \
htdoc.c htdoc.h blockop.cc blockop.h coff_s.h \
config.h cstream.cc cstream.h demangle.h elfstruc.h \
formats.cc formats.h htanaly.cc htanaly.h htapp.cc \
htapp.h htcfg.cc htcfg.h htclipboard.cc htclipboard.h \
htcoff.cc htcoff.h htcoffhd.cc htcoffhd.h htctrl.cc htctrl.h \
htdebug.cc htdebug.h htdialog.cc htdialog.h htelf.cc htelf.h htelfhd.cc \
htelfhd.h htelfimg.cc htelfimg.h htelfphs.cc htelfphs.h htelfshs.cc htelfshs.h \
htelfsym.cc htelfsym.h htelfrel.cc htelfrel.h htfinfo.cc htfinfo.h htformat.cc \
htformat.h hthex.cc hthex.h hthist.cc hthist.h htidle.cc \
htidle.h htinfo.h htiobox.cc htiobox.h htle.cc htle.h htleent.cc \
htleent.h htlehead.cc htlehead.h htleimg.cc htleimg.h htleobj.cc htleobj.h \
htlepage.cc htlepage.h htmenu.cc htmenu.h htmz.cc htmz.h \
htmzhead.cc htmzhead.h htmzimg.cc htmzimg.h htmzrel.cc htmzrel.h htne.cc \
htne.h htneent.cc htneent.h htnehead.cc htnehead.h htnenms.cc htnenms.h \
htneobj.cc htneobj.h htnewexe.cc htnewexe.h htobj.cc htobj.h htpal.cc \
htpal.h htpe.cc htpe.h htpedimp.cc htpedimp.h htpeexp.cc htpeexp.h \
htpehead.cc htpehead.h htpeimg.cc htpeimg.h htpeimp.cc htpeimp.h htperes.cc \
htperes.h htreg.cc htreg.h htsearch.cc htsearch.h \
httag.cc httag.h httree.cc \
httree.h lestruct.h main.cc mzstruct.h nestruct.h pestruct.h \
store.cc store.h stream.cc stream.h tools.cc tools.h vxd.cc vxd.h \
vxdserv.cc vxdserv.h cplus-dem.c demangle.h regex.c regex.h \
syntax.cc syntax.h textfile.cc textfile.h textedit.cc textedit.h \
classread.cc classview.cc class.h httext.cc httext.h hteval.cc hteval.h \
relfile.cc relfile.h htprocess.cc htprocess.h mfile.cc mfile.h elfstruc.cc \
pestruct.cc coff_s.cc mzstruct.cc defreg.h defreg.c htdisasm.cc htdisasm.h \
htcoffimg.cc htcoffimg.h nestruct.cc htneimg.cc htneimg.h htneimp.cc htneimp.h \
cmds.cc cmds.h snprintf.cc snprintf.h htpeil.cc htpeil.h \
ilstruct.cc ilstruct.h log.cc log.h classimg.cc classimg.h \
vfs.cc vfs.h vfsview.cc vfsview.h htlevxd.cc htlevxd.h lestruct.cc \
htmacho.cc htmacho.h htmachohd.cc htmachohd.h machostruc.cc machostruc.h \
htmachoimg.cc htmachoimg.h fltstruc.h fltstruc.cc htflt.cc htflt.h htflthd.cc \
htflthd.h htfltimg.cc htfltimg.h xbestruct.cc xbestruct.h htxbehead.cc \
htxbehead.h htxbe.cc htxbe.h htxbeimg.cc htxbeimg.h htxbeimp.cc htxbeimp.h \
pefstruc.cc pefstruc.h htpef.cc htpef.h htpefhd.cc htpefhd.h htpefimg.cc htpefimg.h \
htpefimp.cc htpefimp.h htxex.cc htxex.h htxexhead.cc htxexhead.h xexstruct.cc \
cp-demangle.c cp-demangle.h xexstruct.h htxeximg.cc htxeximg.h safe-ctype.h

dist2: distdir
	$(AMTAR) chof - $(distdir) | BZIP2=$(BZIP2_ENV) bzip2 -c >$(distdir).tar.bz2
	$(am__remove_distdir)

dist-all2: dist2

htdoc.c htdoc.h: $(srcdir)/doc/hthelp.info tools/bin2c
	tools/bin2c -Nhtinfo $(srcdir)/doc/hthelp.info htdoc.c htdoc.h
ht-2.0.22/pefstruc.cc0000644000175000001440000000570210615341624011275 00000000000000/* 
 *	HT Editor
 *	peffstruc.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "pefstruc.h"
#include "endianess.h"

byte PEF_CONTAINER_HEADER_struct[]= {
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,

	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,

	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,

	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	0
};

byte PEF_SECTION_HEADER_struct[]= {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,

	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	0
};

byte PEF_LOADER_INFO_HEADER_struct[]= {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,

	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,

	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	0
};

byte PEF_ImportedLibrary_struct[]= {
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST,	
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST,
	STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST,
};
ht-2.0.22/vfs.h0000644000175000017500000001123512127651420010102 00000000000000/*
 *	HT Editor
 *	vfs.h
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#ifndef __VFS_H__
#define __VFS_H__

#include "htobj.h"
#include "htreg.h"
#include "stream.h"

#define VFS_DIR_MAX      256
#define VFS_PROTO_MAX	16
#define VFS_URL_MAX		(VFS_DIR_MAX+VFS_PROTO_MAX+1)

/*
 *	class RegNodeFile
 */

class RegNodeFile: public MemoryFile {
protected:
	char *nodename;
	uint access_mode0;
	uint open_mode;

/* overwritten */
		   int		load_node(ObjectStream &s, ht_registry_node **node);
		   void		store_node(ObjectStream &s, ht_registry_node *node);
public:
		RegNodeFile(const char *nodename, uint am, uint om);
	virtual ~RegNodeFile();
};

/*
 *   class Vfs
 */

#define VFSCAP_WRITABLE		1

class Vfs: public Object {
public:
/* new */
	virtual	int		canonicalize(String &result, const char *filename, const char *cwd) = 0;
	virtual	int		createFile(const char *filename, uint createtype) = 0;
	virtual	int		deleteFile(const char *filename) = 0;
	virtual	void *		enumFiletype(uint *type, char **name, void *handle) = 0;
	virtual	int		compareFilenames(const char *a, const char *b) = 0;
	virtual	bool		findFirst(const char *dirname, pfind_t *f) = 0;
	virtual	bool		findNext(pfind_t *f) = 0;
	virtual	bool		findClose(pfind_t *f) = 0;
	virtual	int		getCaps() = 0;
	virtual	const char *	getProtoName() = 0;
	virtual	is_path_delim	isPathDelim() = 0;
	virtual	int		makeDir(const char *dirname) = 0;
	virtual	int		open(const char *filename, bool edit) = 0;
	virtual	int		pstat(pstat_t *s, const char *filename) = 0;
	virtual	int		renameFile(const char *filename, const char *newname) = 0;
	virtual	int		fileClose(File *f) = 0;
	virtual	int		fileOpen(const char *filename, IOAccessMode access_mode, FileOpenMode open_mode, File **f) = 0;
};

/*
 *	class LocalFs
 */

class LocalFs: public Vfs {
public:
		void		init();
	virtual	void		done();
/* overwritten */
	virtual	int		canonicalize(String &result, const char *filename, const char *cwd);
	virtual	int		compareFilenames(const char *a, const char *b);
	virtual	int		createFile(const char *filename, uint createtype);
	virtual	int		deleteFile(const char *filename);
	virtual	void *		enumFiletype(uint *type, char **name, void *handle);
	virtual	bool		findFirst(const char *dirname, pfind_t *f);
	virtual	bool		findNext(pfind_t *f);
	virtual	bool		findClose(pfind_t *f);
	virtual	int		getCaps();
	virtual	const char *	getProtoName();
	virtual	is_path_delim	isPathDelim();
	virtual	int		makeDir(const char *dirname);
	virtual	int		open(const char *filename, bool edit);
	virtual	int		pstat(pstat_t *s, const char *filename);
	virtual	int		renameFile(const char *filename, const char *newname);
	virtual	int		fileClose(File *f);
	virtual	int		fileOpen(const char *filename, IOAccessMode access_mode, FileOpenMode open_mode, File **f);
};                      

/*
 *	class RegistryFs
 */

class RegistryFs: public Vfs {
protected:
	ht_registry_node *enum_last;
	char *enum_dir;

/* new */
		void		create_pfind_t(pfind_t *f, const ht_registry_node *node);
		void		create_pstat_t(pstat_t *s, ht_registry_data *data, ht_registry_node_type type);
public:
		void		init();
	virtual	void		done();
/* overwritten */
	virtual	int		canonicalize(String &result, const char *filename, const char *cwd);
	virtual	int		createFile(const char *filename, uint createtype);
	virtual	int		deleteFile(const char *filename);
	virtual	void *		enumFiletype(uint *type, char **name, void *handle);
	virtual	int		compareFilenames(const char *a, const char *b);
	virtual	bool		findFirst(const char *dirname, pfind_t *f);
	virtual	bool		findNext(pfind_t *f);
	virtual	bool		findClose(pfind_t *f);
	virtual	int		getCaps();
	virtual	const char *	getProtoName();
	virtual	is_path_delim	isPathDelim();
	virtual	int		makeDir(const char *dirname);
	virtual	int		open(const char *filename, bool edit);
	virtual	int		pstat(pstat_t *s, const char *filename);
	virtual	int		renameFile(const char *filename, const char *newname);
	virtual	int		fileClose(File *f);
	virtual	int		fileOpen(const char *filename, IOAccessMode access_mode, FileOpenMode open_mode, File **f);
};                      
#endif /* __VFS_H__ */

ht-2.0.22/htiobox.cc0000644000175000001440000001425210615341620011112 00000000000000/*
 *	HT Editor
 *	htiobox.cc
 *
 *	Copyright (C) 1999-2002 Stefan Weyergraf
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License version 2 as
 *	published by the Free Software Foundation.
 *
 *	This program is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program; if not, write to the Free Software
 *	Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include "atom.h"
#include "htctrl.h"
#include "htdialog.h"
#include "hthist.h"
#include "htiobox.h"
#include "snprintf.h"
#include "tools.h"

#include 
#include 
#include 

int imsgbox(Bounds *b, int buttonmask, const char *title, bool modal, statictext_align align, char *buf)
{
	ht_dialog *dialog=new ht_dialog();
	dialog->init(b, title, FS_KILLER | FS_TITLE | (modal ? 0 : FS_MOVE | FS_RESIZE));

	Bounds c;

	c.x=1;
	c.y=0;
	c.w=b->w-4;
	c.h=b->h-4;
	ht_statictext *text=new ht_statictext();
	text->init(&c, buf, align);
	text->growmode = MK_GM(GMH_FIT, GMV_FIT);

	dialog->insert(text);

	int buttons=0;
	if (buttonmask & btmask_ok) buttons++; else
	if (buttonmask & btmask_yes) buttons++;
	if (buttonmask & btmask_no) buttons++; else
	if (buttonmask & btmask_skip) buttons++;
	if (buttonmask & btmask_cancel) buttons++;
	if (buttonmask & btmask_all) buttons++;
	if (buttonmask & btmask_none) buttons++;

	int pos=0;
	if (buttonmask & btmask_ok) {
		c.x=b->w/2-5*(buttons-2*pos);
		c.y=b->h-4;
		c.w=9;
		c.h=2;
		ht_button *button=new ht_button();
		button->init(&c, "O~K", button_ok);
		button->growmode = MK_GM(GMH_LEFT, GMV_BOTTOM);
		dialog->insert(button);
		pos++;
	} else if (buttonmask & btmask_yes) {
		c.x=b->w/2-5*(buttons-2*pos);
		c.y=b->h-4;
		c.w=9;
		c.h=2;
		ht_button *button=new ht_button();
		button->init(&c, "~Yes", button_yes);
		button->growmode = MK_GM(GMH_LEFT, GMV_BOTTOM);
		dialog->insert(button);
		pos++;
	}
	if (buttonmask & btmask_no) {
		c.x=b->w/2-5*(buttons-2*pos);
		c.y=b->h-4;
		c.w=9;
		c.h=2;
		ht_button *button=new ht_button();
		button->init(&c, "~No", button_no);
		button->growmode = MK_GM(GMH_LEFT, GMV_BOTTOM);
		dialog->insert(button);
		pos++;
	} else if (buttonmask & btmask_skip) {
		c.x=b->w/2-5*(buttons-2*pos);
		c.y=b->h-4;
		c.w=9;
		c.h=2;
		ht_button *button=new ht_button();
		button->init(&c, "~Skip", button_skip);
		button->growmode = MK_GM(GMH_LEFT, GMV_BOTTOM);
		dialog->insert(button);
		pos++;
	}
	if (buttonmask & btmask_all) {
		c.x=b->w/2-5*(buttons-2*pos);
		c.y=b->h-4;
		c.w=9;
		c.h=2;
		ht_button *button=new ht_button();
		button->init(&c, "~All", button_all);
		button->growmode = MK_GM(GMH_LEFT, GMV_BOTTOM);
		dialog->insert(button);
		pos++;
	}
	if (buttonmask & btmask_none) {
		c.x=b->w/2-5*(buttons-2*pos);
		c.y=b->h-4;
		c.w=9;
		c.h=2;
		ht_button *button=new ht_button();
		button->init(&c, "~None", button_none);
		button->growmode = MK_GM(GMH_LEFT, GMV_BOTTOM);
		dialog->insert(button);
		pos++;
	}
	if (buttonmask & btmask_cancel) {
		c.x=b->w/2-5*(buttons-2*pos);
		c.y=b->h-4;
		c.w=9;
		c.h=2;
		ht_button *button=new ht_button();
		button->init(&c, "~Cancel", button_cancel);
		button->growmode = MK_GM(GMH_LEFT, GMV_BOTTOM);
		dialog->insert(button);
		pos++;
	}
	if (!buttons) {
		Bounds x;
		text->getbounds(&x);
		x.h+=2;
		text->setbounds(&x);
	}

	int r=dialog->run(modal);
	dialog->done();
	delete dialog;
	return r;
}

int msgbox(int buttonmask, const char *title, bool modal, statictext_align align, const char *format, ...)
{
	char buf[1024];
	va_list arg;
	va_start(arg, format);
	ht_vsnprintf(buf, 1024, format, arg);
	va_end(arg);

	char *s=buf;
	int ns=1;
	while ((s=strchr(s, '\n'))) {
		s++;
		ns++;
	}
	int strl=strlen(buf);

	Bounds b;
	app->getbounds(&b);
	b.w=55;
	b.h=MAX(strl/(b.w-4), ns)+6;
	b.x=(screen->w - b.w)/2;
	b.y=(screen->h - b.h)/2;
	return imsgbox(&b, buttonmask, title, modal, align, buf);
}

int msgboxrect(Bounds *b, int buttonmask, const char *title, bool modal, statictext_align align, const char *format, ...)
{
	char buf[1024];
	va_list arg;
	va_start(arg, format);
	ht_vsnprintf(buf, 1024, format, arg);
	va_end(arg);

	return imsgbox(b, buttonmask, title, modal, align, buf);
}

bool inputbox(const char *title, const char *label, char *result, int limit, uint32 histid)
{
	Bounds b;
	app->getbounds(&b);
	b.x = (b.w - 60) / 2,
	b.y = (b.h - 8) / 2;
	b.w = 60;
	b.h = 8;
	return inputboxrect(&b, title, label, result, limit, histid);
}

bool inputboxrect(Bounds *b, const char *title, const char *label, char *result, int limit, uint32 histid)
{
	ht_dialog *dialog=new ht_dialog();
	dialog->init(b, title, FS_KILLER | FS_TITLE | FS_MOVE | FS_RESIZE);

	ht_strinputfield *input;

	Bounds  b2;
	b2.x = 3 + strlen(label);
	b2.y = 1;
	b2.w = b->w - 3 - b2.x;
	b2.h = 1;

	List *hist = NULL;
	if (histid) hist = (List*)getAtomValue(histid);
	input = new ht_strinputfield();
	input->init(&b2, limit, hist);
	ht_inputfield_data d;
	d.text = (byte *)result;
	d.textlen = strlen((char*)d.text);
	input->databuf_set(&d, sizeof d);
	dialog->insert(input);

	if (label) {
		b2.x = 1;
		b2.y = 1;
		b2.w = 3 + strlen(label) - b2.x;
		b2.h = 1;

		ht_label *lab = new ht_label();
		lab->init(&b2, label, input);
		dialog->insert(lab);
	}

	b2.x = b->w - 25;
	b2.y = b->h - 5;
	b2.w = 10;
	b2.h = 2;

	ht_button *bok = new ht_button();
	bok->init(&b2, "O~k", button_ok);
	dialog->insert(bok);

	b2.x += 12;

	ht_button *bcancel = new ht_button();
	bcancel->init(&b2, "~Cancel", button_cancel);
	dialog->insert(bcancel);

	if (dialog->run(0)) {
		int dsize = input->datasize();
		ht_inputfield_data *data = ht_malloc(dsize);
		ViewDataBuf vdb(input, data, dsize);
		bin2str(result, data->text, data->textlen);
		free(data);
		if (hist) insert_history_entry(hist, result, 0);

		dialog->done();
		delete dialog;
		return true;
	}
	dialog->done();
	delete dialog;
	return false;
}

void get_std_progress_indicator_metrics(Bounds *b)
{
	app->getbounds(b);
	b->w=b->w*2/3;
	b->h=6;
	b->x=(screen->w - b->w)/2;
	b->y=(screen->h - b->h)/2;
}

ht-2.0.22/doc/0000755000175000017500000000000012156433676007773 500000000000000ht-2.0.22/doc/ht.info0000644000175000001440000003572312156423373011202 00000000000000This is ht.info, produced by makeinfo version 5.1 from ht.texi.

START-INFO-DIR-ENTRY
* ht: (ht.info).             HT Editor.
END-INFO-DIR-ENTRY

   This file documents the HT Editor.

   Copyright (C) 1999-2013 The HT authors.
*Note The HT Authors: Authors, for a list of the copyright holders.

   Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.





   Trademarks are the property of their respective owners, which may be
registered in certain jurisdictions.


File: ht.info,  Node: Top,  Prev: (dir),  Up: (dir)

HT Editor
=========

This is HT 2.0.22; Have fun...

* Menu:

* About::
* Key bindings::
* Features::
* Authors::
* Where to download?::


File: ht.info,  Node: About,  Prev: Top,  Up: Top

About
=====

This program is a file viewer, editor and analyzer for text, binary, and
(especially) executable files.

     This program is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License version
     2 as published by the Free Software Foundation.

     This program is distributed in the hope that it will be useful, but
     WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
     General Public License for more details.

     You should have received a copy of the GNU General Public License
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
     02110-1301 USA.


File: ht.info,  Node: Key bindings,  Prev: Top,  Up: Top

Key bindings
============

   * General key bindings

     Return             follow link (if applicable)
     Backspace          undo "follow link"
     Space/F6           choose view mode
     Alt+[1-9]          select window
     Alt+0              select window list
     Ctrl+Left/Right    scroll left/right
     Cursor keys        move around
     Page Up/Down       next/prev page
     Alt+S              toggle select
     Ctrl+Ins/Alt+C     copy
     Shift+Ins/Alt+V    insert
     Ctrl+Del/Alt+D     delete
     Shift+Del/Alt+X    cut

   * Window key bindings

     Alt+F3/Ctrl+W      close window
     Ctrl+F5            resize/move mode
                        (in resize/move mode only:)
     Space              toggle resize/move mode
     Cursor keys        resize/move window
     Escape/Return/Ctrl+F5leave resize/move mode

   * Analyser key bindings

     c                  continue code analysis at cursor
     f                  follow dword ptr at address
     n                  name current address (empty string to delete)
     x                  show xrefs (search for xrefs)
     #                  edit comments
     s                  define a string
     i                  define an integer (32bit)
     h                  define a halfword (16bit)
     b                  define a byte (8bit)
     Ctrl+A             call assembler
     Ctrl+F             goto start of current function
                        (indicated in the 2nd line)
     Ctrl+L             goto previous label
     Ctrl+T             show recursive function references
                        


Note: Some keys don't work in HT-posix.  Try using Escape instead of
Control or something...


File: ht.info,  Node: Authors,  Prev: Top,  Up: Top

Authors
=======

   * Stefan Weyergraf

   * Sebastian Biallas 


File: ht.info,  Node: Features,  Prev: Top,  Up: Top

Features
========

HT contains some very advanced and useful features, which you should
carefully inspect:

* Menu:

* General features::
* Configuration files::
* Clipboard::
* Global history::
* Expression evaluation::
* Block operations::
* Search and its different modes::
* Command line options::


File: ht.info,  Node: General features,  Prev: Features,  Up: Features

General features
================

  1. Supported file formats
        * common object file format (COFF/XCOFF32)
               - header
               - image with code/data analyser (x86)
        * executable and linkable format (ELF)
               - header
               - section headers
               - program headers
               - symbol tables
               - image with code/data analyser (x86, AMD64, IA-64,
               Alpha, PowerPC, ARM) and relocations
        * linear executables (LE)
               - header
               - VxD descriptor
               - object table
               - page table
               - image with code/data analyser (x86)
               - auto-relocation layer (only internal refs for now)
        * standard dos executables (MZ)
               - header
               - relocations
               - image (disassembly only)
        * new executables (NE)
               - header
               - segments
               - names
               - entrypoints
               - image with code/data analyser (x86)
               - auto-relocation layer (pretty complete)
        * portable executables (PE32, PE64)
               - header
               - import section
               - delay-import section
               - export section
               - resources
               - image with code/data analyser (x86, AMD64, PowerPC,
               IA-64, Alpha, ARM)
               - preliminary support for .net executables
        * java class files (CLASS)
               - header
               - image with code/data analyser (java bytecode
               disassembler)
        * Mach exe/link format (MachO)
               - header
               - image with code/data analyser (x86, AMD64, PowerPC,
               ARM)
        * X-Box executable (XBE)
               - header
               - imports
               - image with code/data analyser (x86)
        * Flat (FLT)
               - header
               - image with data analyser (no disassembler yet)
        * PowerPC executable format (PEF)
               - header
               - imports - image with code/data analyser (PowerPC)
        * Still some to be implemented (M$-OBJ, ARCH, LX)
  2. Code & Data Analyser
          - finds branch sources and destinations recursively
          - finds procedure entries
          - creates labels based on this information
          - creates xref information
          - allows to interactively analyse unexplored code (press 'c')
          - allows to create/rename/delete labels (press 'n')
          - allows to create/edit comments (press '#')
  3. Target systems
          - DJGPP
          - GNU/Linux
          - FreeBSD
          - Win32


File: ht.info,  Node: Configuration files,  Prev: Features,  Up: Features

Configuration files
===================

Global configuration
--------------------

HT automatically creates a file to store its configuration.  It is
called '~/.htcfg2' on Unices and 'ht.cfg2' (where ht.exe resides) on
Windows.  More specifically it contains HT's registry and the *Note
Global history::.

Per file configuration
----------------------

The analyser (for analysable files) will be stored in an extra file
called 'FILENAME.htcfg', where FILENAME is the analysed file.  This file
contains all information to restore the complete state of the analyser.


File: ht.info,  Node: Clipboard,  Prev: Features,  Up: Features

Clipboard
=========

All open files and dialogs use the common clipboard, where all copied
and cut text or binary data is stored.  Clipboard operations are
normally binary safe, that means you can copy some binary data out of a
file and paste it into an input line.  Exceptions are only the \0
character (binary null), it will be converted to a space in places where
it would not make sense (e.g.  file open).

   Although the clipboard won't be saved between different HT sessions
(ie.  you will loose it when exiting HT), you can either save and load
it or part of it manually (via Edit->paste into/copy from file) or rely
on the input lines' *Note history: Global history, which is stored and
retrieved from the config file automatically.


File: ht.info,  Node: Global history,  Prev: Features,  Up: Features

Global history
==============

HTs history system is global, which means that you can use it for all
open files.  Histories are also grouped by their context.  I.e.
file-related and regex-search-related dialogs have their own history
(who would want to open "[0-9][0-9a-z]+" anyway?).

   History entries are stored within the *Note Configuration files::, so
they can be reused when you relaunch.

   You can delete a history entry by pressing DEL inside the history
popup.


File: ht.info,  Node: Expression evaluation,  Prev: Features,  Up: Features

Expression evaluation
=====================

HT contains a very powerful expression evaluator which is used in all
dialogs where expressions are expected.  These are mainly
blockoperation, goto, search and of course evaluate itself
(Edit->Evaluate).

   You can use all standard math operators (+ - / * % **), logical
operators (!  && || ^^), relational operators (== != < > <= >=), bit
operators (~ & | ^), string operators (.  for concatenation),
parenthesis, the ternary operator (a?b:c), functions and symbols (both
depending on context).

   The evaluator uses integer, string and float types depending on
context.  You can always convert a result via the 'int()', 'string()'
and 'float()' functions to appropriate type.  Try Edit->Evaluate to see
how it works...

Functions and symbols
---------------------

You can always use the standard built-in math ('round', 'sin', 'random',
etc.)  and string ('strcmp', 'strchr', 'sprintf', etc.)  functions, they
work more or less like the corresponding C functions (actually they ARE
more or less wrappers for them); see 'eval/eval.y' for details (sorry
but a detailed help would get outdated rather soon).

   The symbol _ always refers to the last result.  If you are in a hex
buffer, the variable 'first' contains the offset of the first byte and
the variable 'last' contains the offset of the last byte.  This is
useful, for instace, if you want to jump to the last byte of a file.

   If you are in a hex buffer, the variable 'first' contains the offset
of the first byte and the variable 'last' contains the offset of the
last byte.  This is useful, for instance, if you want to jump to the
last byte of a file.

   When using *Note Block operations::, or searching you have some
context depending functions and symbols; see these sections for
explanation.


File: ht.info,  Node: Block operations,  Prev: Features,  Up: Features

Block operations
================

Block operation (Blockop) is a very powerful tool to perform
modifications on binary files.  It is available in hex viewer only.

   Blockop takes four parameters: START, END, MODE and EXPRESSION.
Blockop works as follows:

   * START: Start at the offset specified by START
   * REPEAT: Evaluate EXPRESSION and store n bytes (1 - byte, 2 - word,
     4 - dword, variable - string) at the current offset.  Increment
     current offset by n.  Stop if END has been reached.

Special variables/functions that can be used in EXPRESSION:

'readbyte(ofs)'
     read a byte from offset OFS, returns a number
'readstring(ofs, size)'
     read SIZE bytes from offset OFS, returns a string
'i'
     contains the iteration count/index starting with 0


File: ht.info,  Node: Search and its different modes,  Prev: Features,  Up: Features

Search and its different modes
==============================

The search function is one of the most advanced functions of HT. It is
invoked through F7, Shift-F7 continues a search from cursor.  Depending
on context (ie.  file type and mode) the following modes are enabled:

bin: ASCII / Hex
----------------

Enter an exact search string either via ascii characters or via
hexadecimal interpretation.  This is the fastest search mode.  You may
specify a case-insensitive search.

bin: eval str
-------------

Enter an expression, it will be evaluated ONCE (difference to the 4th
mode), and HT will then search for the result-string.  This is pretty
useful when searching for intermixed text and control-chars/binary, e.g.
'"hello world\n\0"'

display: regex
--------------

As the prefix indicates, this search doesn't search in the binary file
but in the display on screen.  HT searches for a regular expression so
this can be very powerful, e.g.  in PE/Image you can search for
'(add|sub).+?,\ [78]$'.  This will find all add or sub instructions with
second parameter 7 or 8.

expr nonzero
------------

This is the slowest but also most advanced search mode.  Enter an
expression and the search stops if this expression evaluates to non-zero
(it will be evaluated on every byte).  In this mode there are two
predefined symbols and some functions: I is always the number of current
iteration and O stands for the current offset in file.  With the
functions 'readbyte(ofs)' and 'readstring(ofs, size)' you access the
file's content.

   It's easier to understand this with examples:

  1. Searching for patterns:

       a. Enter 'readbyte(o) == readbyte(o+1)'
          This will search for two equal bytes ("AA", "55", "!!", etc.).
       b. Enter '(readbyte(o) == readbyte(o+1)-1) &&
          (readbyte(o)==readbyte(o+2)-2)'
          This will search for three ascending bytes ("ABC", "123",
          etc).

  2. Search with special functions:

     With HT you can easily detect the RSA key in the 'ADVAPI32.DLL':
     Search for 'entropy(readstring(o, 64)) > 82' in expr!=0 mode, and
     you will find it very quickly.  How does it work?  'readstring(o,
     64)' reads a 64 byte string from current offset and entropy
     calculates the entropy ("randomness") of a string (result is
     0..100).  So the search stops if a entropy greater than 82%
     (guessed value) is encountered, which normally indicates packed or
     encryted data.

     Note: the 'entropy()' function is not the best of its kind, if you
     know of a better one please let us know!


File: ht.info,  Node: Command line options,  Prev: Features,  Up: Features

Command line options
====================

'--'                   treat all additional parameters as file names
                       
'-v'    '--version'    show version and copyright on console
                       
'-h'    '--help'       show help
                       
'-t'    '--text'       load file(s) in text editor mode
                       
'-b'    '--bin'        load file(s) in hex editor mode
                       
'-a'    '--auto'       try to guess file type


File: ht.info,  Node: Where to download?,  Prev: Top,  Up: Top

Where to download?
==================

The HT homepage is located at 

Downloads are available from the 'download' section.  Please also take a
look at 



Tag Table:
Node: Top577
Node: About770
Node: Key bindings1614
Node: Authors3371
Node: Features3507
Node: General features3866
Node: Configuration files6662
Node: Clipboard7307
Node: Global history8117
Node: Expression evaluation8664
Node: Block operations10556
Node: Search and its different modes11407
Node: Command line options14070
Node: Where to download?14632

End Tag Table
ht-2.0.22/doc/ht.html0000644000175000001440000005667412156423374011224 00000000000000



HT Editor Documentation















HT Editor Documentation

Previous: (dir), Up: (dir)  

HT Editor

This is HT 2.0.22; Have fun…


Previous: Top, Up: Top  

About

This program is a file viewer, editor and analyzer for text, binary, and (especially) executable files.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.


Previous: Top, Up: Top  

Key bindings

  • General key bindings
    Returnfollow link (if applicable)
    Backspaceundo “follow link”
    Space/F6choose view mode
    Alt+[1-9]select window
    Alt+0select window list
    Ctrl+Left/Rightscroll left/right
    Cursor keysmove around
    Page Up/Downnext/prev page
    Alt+Stoggle select
    Ctrl+Ins/Alt+Ccopy
    Shift+Ins/Alt+Vinsert
    Ctrl+Del/Alt+Ddelete
    Shift+Del/Alt+Xcut
  • Window key bindings
    Alt+F3/Ctrl+Wclose window
    Ctrl+F5resize/move mode
    (in resize/move mode only:)
    Spacetoggle resize/move mode
    Cursor keysresize/move window
    Escape/Return/Ctrl+F5leave resize/move mode
  • Analyser key bindings
    ccontinue code analysis at cursor
    ffollow dword ptr at address
    nname current address (empty string to delete)
    xshow xrefs (search for xrefs)
    #edit comments
    sdefine a string
    idefine an integer (32bit)
    hdefine a halfword (16bit)
    bdefine a byte (8bit)
    Ctrl+Acall assembler
    Ctrl+Fgoto start of current function
    (indicated in the 2nd line)
    Ctrl+Lgoto previous label
    Ctrl+Tshow recursive function references

Note: Some keys don’t work in HT-posix. Try using Escape instead of Control or something...


Previous: Top, Up: Top  

Authors


Previous: Top, Up: Top  

Features

HT contains some very advanced and useful features, which you should carefully inspect:


Previous: Features, Up: Features  

General features

  1. Supported file formats
    • common object file format (COFF/XCOFF32)
      • - header
        - image with code/data analyser (x86)
    • executable and linkable format (ELF)
      • - header
        - section headers
        - program headers
        - symbol tables
        - image with code/data analyser (x86, AMD64, IA-64, Alpha, PowerPC, ARM) and relocations
    • linear executables (LE)
      • - header
        - VxD descriptor
        - object table
        - page table
        - image with code/data analyser (x86)
        - auto-relocation layer (only internal refs for now)
    • standard dos executables (MZ)
      • - header
        - relocations
        - image (disassembly only)
    • new executables (NE)
      • - header
        - segments
        - names
        - entrypoints
        - image with code/data analyser (x86)
        - auto-relocation layer (pretty complete)
    • portable executables (PE32, PE64)
      • - header
        - import section
        - delay-import section
        - export section
        - resources
        - image with code/data analyser (x86, AMD64, PowerPC, IA-64, Alpha, ARM)
        - preliminary support for .net executables
    • java class files (CLASS)
      • - header
        - image with code/data analyser (java bytecode disassembler)
    • Mach exe/link format (MachO)
      • - header
        - image with code/data analyser (x86, AMD64, PowerPC, ARM)
    • X-Box executable (XBE)
      • - header
        - imports
        - image with code/data analyser (x86)
    • Flat (FLT)
      • - header
        - image with data analyser (no disassembler yet)
    • PowerPC executable format (PEF)
      • - header
        - imports - image with code/data analyser (PowerPC)
    • Still some to be implemented (M$-OBJ, ARCH, LX)
  2. Code & Data Analyser
    • - finds branch sources and destinations recursively
      - finds procedure entries
      - creates labels based on this information
      - creates xref information
      - allows to interactively analyse unexplored code (press ’c’)
      - allows to create/rename/delete labels (press ’n’)
      - allows to create/edit comments (press ’#’)
  3. Target systems
    • - DJGPP
      - GNU/Linux
      - FreeBSD
      - Win32

Previous: Features, Up: Features  

Configuration files

Global configuration

HT automatically creates a file to store its configuration. It is called ~/.htcfg2 on Unices and ht.cfg2 (where ht.exe resides) on Windows. More specifically it contains HT’s registry and the See Global history.

Per file configuration

The analyser (for analysable files) will be stored in an extra file called FILENAME.htcfg, where FILENAME is the analysed file. This file contains all information to restore the complete state of the analyser.


Previous: Features, Up: Features  

Clipboard

All open files and dialogs use the common clipboard, where all copied and cut text or binary data is stored. Clipboard operations are normally binary safe, that means you can copy some binary data out of a file and paste it into an input line. Exceptions are only the \0 character (binary null), it will be converted to a space in places where it would not make sense (e.g. file open).

Although the clipboard won’t be saved between different HT sessions (ie. you will loose it when exiting HT), you can either save and load it or part of it manually (via Edit->paste into/copy from file) or rely on the input lines’ See history, which is stored and retrieved from the config file automatically.


Previous: Features, Up: Features  

Global history

HTs history system is global, which means that you can use it for all open files. Histories are also grouped by their context. I.e. file-related and regex-search-related dialogs have their own history (who would want to open "[0-9][0-9a-z]+" anyway?).

History entries are stored within the See Configuration files, so they can be reused when you relaunch.

You can delete a history entry by pressing DEL inside the history popup.


Previous: Features, Up: Features  

Expression evaluation

HT contains a very powerful expression evaluator which is used in all dialogs where expressions are expected. These are mainly blockoperation, goto, search and of course evaluate itself (Edit->Evaluate).

You can use all standard math operators (+ - / * % **), logical operators (! && || ^^), relational operators (== != < > <= >=), bit operators (~ & | ^), string operators (. for concatenation), parenthesis, the ternary operator (a?b:c), functions and symbols (both depending on context).

The evaluator uses integer, string and float types depending on context. You can always convert a result via the int(), string() and float() functions to appropriate type. Try Edit->Evaluate to see how it works…

Functions and symbols

You can always use the standard built-in math (round, sin, random, etc.) and string (strcmp, strchr, sprintf, etc.) functions, they work more or less like the corresponding C functions (actually they ARE more or less wrappers for them); see eval/eval.y for details (sorry but a detailed help would get outdated rather soon).

The symbol _ always refers to the last result. If you are in a hex buffer, the variable first contains the offset of the first byte and the variable last contains the offset of the last byte. This is useful, for instace, if you want to jump to the last byte of a file.

If you are in a hex buffer, the variable first contains the offset of the first byte and the variable last contains the offset of the last byte. This is useful, for instance, if you want to jump to the last byte of a file.

When using See Block operations, or searching you have some context depending functions and symbols; see these sections for explanation.


Previous: Features, Up: Features  

Block operations

Block operation (Blockop) is a very powerful tool to perform modifications on binary files. It is available in hex viewer only.

Blockop takes four parameters: start, end, mode and expression. Blockop works as follows:

  • START: Start at the offset specified by start
  • REPEAT: Evaluate expression and store n bytes (1 - byte, 2 - word, 4 - dword, variable - string) at the current offset. Increment current offset by n. Stop if end has been reached.

Special variables/functions that can be used in expression:

readbyte(ofs)

read a byte from offset ofs, returns a number

readstring(ofs, size)

read size bytes from offset ofs, returns a string

i

contains the iteration count/index starting with 0


Previous: Features, Up: Features  

Search and its different modes

The search function is one of the most advanced functions of HT. It is invoked through F7, Shift-F7 continues a search from cursor. Depending on context (ie. file type and mode) the following modes are enabled:

bin: ASCII / Hex

Enter an exact search string either via ascii characters or via hexadecimal interpretation. This is the fastest search mode. You may specify a case-insensitive search.

bin: eval str

Enter an expression, it will be evaluated ONCE (difference to the 4th mode), and HT will then search for the result-string. This is pretty useful when searching for intermixed text and control-chars/binary, e.g. "hello world\n\0"

display: regex

As the prefix indicates, this search doesn’t search in the binary file but in the display on screen. HT searches for a regular expression so this can be very powerful, e.g. in PE/Image you can search for (add|sub).+?,\ [78]$. This will find all add or sub instructions with second parameter 7 or 8.

expr nonzero

This is the slowest but also most advanced search mode. Enter an expression and the search stops if this expression evaluates to non-zero (it will be evaluated on every byte). In this mode there are two predefined symbols and some functions: i is always the number of current iteration and o stands for the current offset in file. With the functions readbyte(ofs) and readstring(ofs, size) you access the file’s content.

It’s easier to understand this with examples:

  1. Searching for patterns:
    1. Enter readbyte(o) == readbyte(o+1)
      This will search for two equal bytes ("AA", "55", "!!", etc.).
    2. Enter (readbyte(o) == readbyte(o+1)-1) && (readbyte(o)==readbyte(o+2)-2)
      This will search for three ascending bytes ("ABC", "123", etc).
  2. Search with special functions:

    With HT you can easily detect the RSA key in the ADVAPI32.DLL: Search for entropy(readstring(o, 64)) > 82 in expr!=0 mode, and you will find it very quickly. How does it work? readstring(o, 64) reads a 64 byte string from current offset and entropy calculates the entropy ("randomness") of a string (result is 0..100). So the search stops if a entropy greater than 82% (guessed value) is encountered, which normally indicates packed or encryted data.

    Note: the entropy() function is not the best of its kind, if you know of a better one please let us know!


Previous: Features, Up: Features  

Command line options

--treat all additional parameters as file names
-v--versionshow version and copyright on console
-h--helpshow help
-t--textload file(s) in text editor mode
-b--binload file(s) in hex editor mode
-a--autotry to guess file type

Previous: Top, Up: Top  

Where to download?

The HT homepage is located at http://hte.sourceforge.net

Downloads are available from the ’download’ section. Please also take a look at http://sourceforge.net/projects/hte


ht-2.0.22/doc/hthelp.info0000644000175000017500000003601712156423373012054 00000000000000This is hthelp.info, produced by makeinfo version 5.1 from ht.texi. START-INFO-DIR-ENTRY * ht: (ht.info). HT Editor. END-INFO-DIR-ENTRY This file documents the HT Editor. Copyright (C) 1999-2013 The HT authors. *Note The HT Authors: Authors, for a list of the copyright holders. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Trademarks are the property of their respective owners, which may be registered in certain jurisdictions.  File: hthelp.info, Node: Top, Prev: (dir), Up: (dir) HT Editor ========= This is HT 2.0.22; Have fun... * Menu: * About:: * Key bindings:: * Features:: * Authors:: * Where to download?::  File: hthelp.info, Node: About, Prev: Top, Up: Top About ===== This program is a file viewer, editor and analyzer for text, binary, and (especially) executable files. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.  File: hthelp.info, Node: Key bindings, Prev: Top, Up: Top Key bindings ============ * General key bindings Return follow link (if applicable) Backspace undo "follow link" Space/F6 choose view mode Alt+[1-9] select window Alt+0 select window list Ctrl+Left/Right scroll left/right Cursor keys move around Page Up/Down next/prev page Alt+S toggle select Ctrl+Ins/Alt+C copy Shift+Ins/Alt+V insert Ctrl+Del/Alt+D delete Shift+Del/Alt+X cut * Window key bindings Alt+F3/Ctrl+W close window Ctrl+F5 resize/move mode (in resize/move mode only:) Space toggle resize/move mode Cursor keys resize/move window Escape/Return/Ctrl+F5leave resize/move mode * Analyser key bindings c continue code analysis at cursor f follow dword ptr at address n name current address (empty string to delete) x show xrefs (search for xrefs) # edit comments s define a string i define an integer (32bit) h define a halfword (16bit) b define a byte (8bit) Ctrl+A call assembler Ctrl+F goto start of current function (indicated in the 2nd line) Ctrl+L goto previous label Ctrl+T show recursive function references Note: Some keys don't work in HT-posix. Try using Escape instead of Control or something...  File: hthelp.info, Node: Authors, Prev: Top, Up: Top Authors ======= * Stefan Weyergraf * Sebastian Biallas  File: hthelp.info, Node: Features, Prev: Top, Up: Top Features ======== HT contains some very advanced and useful features, which you should carefully inspect: * Menu: * General features:: * Configuration files:: * Clipboard:: * Global history:: * Expression evaluation:: * Block operations:: * Search and its different modes:: * Command line options::  File: hthelp.info, Node: General features, Prev: Features, Up: Features General features ================ 1. Supported file formats * common object file format (COFF/XCOFF32) - header - image with code/data analyser (x86) * executable and linkable format (ELF) - header - section headers - program headers - symbol tables - image with code/data analyser (x86, AMD64, IA-64, Alpha, PowerPC, ARM) and relocations * linear executables (LE) - header - VxD descriptor - object table - page table - image with code/data analyser (x86) - auto-relocation layer (only internal refs for now) * standard dos executables (MZ) - header - relocations - image (disassembly only) * new executables (NE) - header - segments - names - entrypoints - image with code/data analyser (x86) - auto-relocation layer (pretty complete) * portable executables (PE32, PE64) - header - import section - delay-import section - export section - resources - image with code/data analyser (x86, AMD64, PowerPC, IA-64, Alpha, ARM) - preliminary support for .net executables * java class files (CLASS) - header - image with code/data analyser (java bytecode disassembler) * Mach exe/link format (MachO) - header - image with code/data analyser (x86, AMD64, PowerPC, ARM) * X-Box executable (XBE) - header - imports - image with code/data analyser (x86) * Flat (FLT) - header - image with data analyser (no disassembler yet) * PowerPC executable format (PEF) - header - imports - image with code/data analyser (PowerPC) * Still some to be implemented (M$-OBJ, ARCH, LX) 2. Code & Data Analyser - finds branch sources and destinations recursively - finds procedure entries - creates labels based on this information - creates xref information - allows to interactively analyse unexplored code (press 'c') - allows to create/rename/delete labels (press 'n') - allows to create/edit comments (press '#') 3. Target systems - DJGPP - GNU/Linux - FreeBSD - Win32  File: hthelp.info, Node: Configuration files, Prev: Features, Up: Features Configuration files =================== Global configuration -------------------- HT automatically creates a file to store its configuration. It is called '~/.htcfg2' on Unices and 'ht.cfg2' (where ht.exe resides) on Windows. More specifically it contains HT's registry and the *Note Global history::. Per file configuration ---------------------- The analyser (for analysable files) will be stored in an extra file called 'FILENAME.htcfg', where FILENAME is the analysed file. This file contains all information to restore the complete state of the analyser.  File: hthelp.info, Node: Clipboard, Prev: Features, Up: Features Clipboard ========= All open files and dialogs use the common clipboard, where all copied and cut text or binary data is stored. Clipboard operations are normally binary safe, that means you can copy some binary data out of a file and paste it into an input line. Exceptions are only the \0 character (binary null), it will be converted to a space in places where it would not make sense (e.g. file open). Although the clipboard won't be saved between different HT sessions (ie. you will loose it when exiting HT), you can either save and load it or part of it manually (via Edit->paste into/copy from file) or rely on the input lines' *Note history: Global history, which is stored and retrieved from the config file automatically.  File: hthelp.info, Node: Global history, Prev: Features, Up: Features Global history ============== HTs history system is global, which means that you can use it for all open files. Histories are also grouped by their context. I.e. file-related and regex-search-related dialogs have their own history (who would want to open "[0-9][0-9a-z]+" anyway?). History entries are stored within the *Note Configuration files::, so they can be reused when you relaunch. You can delete a history entry by pressing DEL inside the history popup.  File: hthelp.info, Node: Expression evaluation, Prev: Features, Up: Features Expression evaluation ===================== HT contains a very powerful expression evaluator which is used in all dialogs where expressions are expected. These are mainly blockoperation, goto, search and of course evaluate itself (Edit->Evaluate). You can use all standard math operators (+ - / * % **), logical operators (! && || ^^), relational operators (== != < > <= >=), bit operators (~ & | ^), string operators (. for concatenation), parenthesis, the ternary operator (a?b:c), functions and symbols (both depending on context). The evaluator uses integer, string and float types depending on context. You can always convert a result via the 'int()', 'string()' and 'float()' functions to appropriate type. Try Edit->Evaluate to see how it works... Functions and symbols --------------------- You can always use the standard built-in math ('round', 'sin', 'random', etc.) and string ('strcmp', 'strchr', 'sprintf', etc.) functions, they work more or less like the corresponding C functions (actually they ARE more or less wrappers for them); see 'eval/eval.y' for details (sorry but a detailed help would get outdated rather soon). The symbol _ always refers to the last result. If you are in a hex buffer, the variable 'first' contains the offset of the first byte and the variable 'last' contains the offset of the last byte. This is useful, for instace, if you want to jump to the last byte of a file. If you are in a hex buffer, the variable 'first' contains the offset of the first byte and the variable 'last' contains the offset of the last byte. This is useful, for instance, if you want to jump to the last byte of a file. When using *Note Block operations::, or searching you have some context depending functions and symbols; see these sections for explanation.  File: hthelp.info, Node: Block operations, Prev: Features, Up: Features Block operations ================ Block operation (Blockop) is a very powerful tool to perform modifications on binary files. It is available in hex viewer only. Blockop takes four parameters: START, END, MODE and EXPRESSION. Blockop works as follows: * START: Start at the offset specified by START * REPEAT: Evaluate EXPRESSION and store n bytes (1 - byte, 2 - word, 4 - dword, variable - string) at the current offset. Increment current offset by n. Stop if END has been reached. Special variables/functions that can be used in EXPRESSION: 'readbyte(ofs)' read a byte from offset OFS, returns a number 'readstring(ofs, size)' read SIZE bytes from offset OFS, returns a string 'i' contains the iteration count/index starting with 0  File: hthelp.info, Node: Search and its different modes, Prev: Features, Up: Features Search and its different modes ============================== The search function is one of the most advanced functions of HT. It is invoked through F7, Shift-F7 continues a search from cursor. Depending on context (ie. file type and mode) the following modes are enabled: bin: ASCII / Hex ---------------- Enter an exact search string either via ascii characters or via hexadecimal interpretation. This is the fastest search mode. You may specify a case-insensitive search. bin: eval str ------------- Enter an expression, it will be evaluated ONCE (difference to the 4th mode), and HT will then search for the result-string. This is pretty useful when searching for intermixed text and control-chars/binary, e.g. '"hello world\n\0"' display: regex -------------- As the prefix indicates, this search doesn't search in the binary file but in the display on screen. HT searches for a regular expression so this can be very powerful, e.g. in PE/Image you can search for '(add|sub).+?,\ [78]$'. This will find all add or sub instructions with second parameter 7 or 8. expr nonzero ------------ This is the slowest but also most advanced search mode. Enter an expression and the search stops if this expression evaluates to non-zero (it will be evaluated on every byte). In this mode there are two predefined symbols and some functions: I is always the number of current iteration and O stands for the current offset in file. With the functions 'readbyte(ofs)' and 'readstring(ofs, size)' you access the file's content. It's easier to understand this with examples: 1. Searching for patterns: a. Enter 'readbyte(o) == readbyte(o+1)' This will search for two equal bytes ("AA", "55", "!!", etc.). b. Enter '(readbyte(o) == readbyte(o+1)-1) && (readbyte(o)==readbyte(o+2)-2)' This will search for three ascending bytes ("ABC", "123", etc). 2. Search with special functions: With HT you can easily detect the RSA key in the 'ADVAPI32.DLL': Search for 'entropy(readstring(o, 64)) > 82' in expr!=0 mode, and you will find it very quickly. How does it work? 'readstring(o, 64)' reads a 64 byte string from current offset and entropy calculates the entropy ("randomness") of a string (result is 0..100). So the search stops if a entropy greater than 82% (guessed value) is encountered, which normally indicates packed or encryted data. Note: the 'entropy()' function is not the best of its kind, if you know of a better one please let us know!  File: hthelp.info, Node: Command line options, Prev: Features, Up: Features Command line options ==================== '--' treat all additional parameters as file names '-v' '--version' show version and copyright on console '-h' '--help' show help '-t' '--text' load file(s) in text editor mode '-b' '--bin' load file(s) in hex editor mode '-a' '--auto' try to guess file type  File: hthelp.info, Node: Where to download?, Prev: Top, Up: Top Where to download? ================== The HT homepage is located at Downloads are available from the 'download' section. Please also take a look at  Tag Table: Node: Top581 Node: About778 Node: Key bindings1626 Node: Authors3387 Node: Features3527 Node: General features3890 Node: Configuration files6690 Node: Clipboard7339 Node: Global history8153 Node: Expression evaluation8704 Node: Block operations10600 Node: Search and its different modes11455 Node: Command line options14122 Node: Where to download?14688  End Tag Table ht-2.0.22/doc/Makefile.am0000644000175000001440000000076310267265571011747 00000000000000AUTOMAKE_OPTIONS = foreign MIFLAGS = --no-split EXTRA_DIST = hthelp.info ht.info ht.html ht.texi all: hthelp.info ht.info ht.html README hthelp.info: ht.texi ${MAKEINFO} ${MIFLAGS} --fill-column=64 --output $@ ht.texi ht.info: ht.texi ${MAKEINFO} ${MIFLAGS} --output $@ ht.texi ht.html: ht.texi ${MAKEINFO} ${MIFLAGS} --html --output $@ ht.texi README: ht.texi ${MAKEINFO} ${MIFLAGS} --no-headers --no-ifinfo --no-iftex --output $@ ht.texi cp README .. clean: rm -f README hthelp.info ht-2.0.22/doc/Makefile.in0000644000175000017500000002227612127657374011772 00000000000000# Makefile.in generated by automake 1.10.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = doc DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = SOURCES = DIST_SOURCES = DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ HT_LDFLAGS = @HT_LDFLAGS@ HT_LIBS = @HT_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IO_DIR = @IO_DIR@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ LZO_LIBS = @LZO_LIBS@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ curses_CPPFLAGS = @curses_CPPFLAGS@ curses_LIBS = @curses_LIBS@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ ncurses_config = @ncurses_config@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign MIFLAGS = --no-split EXTRA_DIST = hthelp.info ht.info ht.html ht.texi all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign doc/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign doc/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic distclean \ distclean-generic distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am all: hthelp.info ht.info ht.html README hthelp.info: ht.texi ${MAKEINFO} ${MIFLAGS} --fill-column=64 --output $@ ht.texi ht.info: ht.texi ${MAKEINFO} ${MIFLAGS} --output $@ ht.texi ht.html: ht.texi ${MAKEINFO} ${MIFLAGS} --html --output $@ ht.texi README: ht.texi ${MAKEINFO} ${MIFLAGS} --no-headers --no-ifinfo --no-iftex --output $@ ht.texi cp README .. clean: rm -f README hthelp.info # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ht-2.0.22/doc/ht.texi0000644000175000017500000003751112156423355011221 00000000000000\input texinfo @c -*-texinfo-*- @c %**start of header @setfilename ht.info @settitle HT Editor Documentation @iftex @afourpaper @end iftex @c %**end of header @ifinfo @format START-INFO-DIR-ENTRY * ht: (ht.info). HT Editor. END-INFO-DIR-ENTRY @end format @end ifinfo @iftex @c @finalout @end iftex @ifinfo This file documents the HT Editor. @c Copyright @copyright{} 1999-2013 The HT authors. @* @xref{Authors, The HT Authors, The HT Authors}, for a list of the copyright holders. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. @ignore Permission is granted to process this file through TeX and print the results, provided the printed document carries a copying permission notice identical to this one except for the removal of this paragraph (this paragraph not being relevant to the printed manual). @end ignore @sp 4 Trademarks are the property of their respective owners, which may be registered in certain jurisdictions. @end ifinfo @c begin chapters on right pages @setchapternewpage odd @titlepage @title HT Manual @subtitle Edition 2.0.22, January 2013 @author Stefan Weyergraf, Sebastian Biallas @c The following two commands start the copyright page. @page @vskip 0pt plus 1filll Copyright @copyright{} 1999-2013 The HT authors. @* @xref{Authors, The HT Authors, The HT Authors}, for a list of the copyright holders. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. @sp 4 Trademarks are the property of their respective owners, which may be registered in certain jurisdictions. @end titlepage @c @c SETTINGS, DEFINES, MACROS @c @macro htversion 2.0.22 @end macro @macro hturl @uref{http://hte.sourceforge.net} @end macro @macro htsfurl @uref{http://sourceforge.net/projects/hte} @end macro @macro none @end macro @c @c TOP NODE @c @node Top, , (dir), (dir) @unnumberedsec HT Editor @noindent This is HT @htversion{}; Have fun@dots{} @menu * About:: * Key bindings:: * Features:: * Authors:: * Where to download?:: @end menu @node About, , Top, Top @unnumberedsec About @noindent This program is a file viewer, editor and analyzer for text, binary, and (especially) executable files. @quotation @noindent This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. @end quotation @node Key bindings, , Top, Top @unnumberedsec Key bindings @macro keytablecolumns .25 .75 @end macro @itemize @bullet @item General key bindings @multitable @columnfractions .25 .75 @item Return @tab follow link (if applicable) @item Backspace @tab undo ``follow link'' @item Space/F6 @tab choose view mode @item Alt+[1-9] @tab select window @item Alt+0 @tab select window list @item Ctrl+Left/Right @tab scroll left/right @item Cursor keys @tab move around @item Page Up/Down @tab next/prev page @item Alt+S @tab toggle select @item Ctrl+Ins/Alt+C @tab copy @item Shift+Ins/Alt+V @tab insert @item Ctrl+Del/Alt+D @tab delete @item Shift+Del/Alt+X @tab cut @end multitable @item Window key bindings @multitable @columnfractions .25 .75 @item Alt+F3/Ctrl+W @tab close window @item Ctrl+F5 @tab resize/move mode @item @tab (in resize/move mode only:) @item Space @tab toggle resize/move mode @item Cursor keys @tab resize/move window @item Escape/Return/Ctrl+F5 @tab leave resize/move mode @end multitable @item Analyser key bindings @multitable @columnfractions .25 .75 @item c @tab continue code analysis at cursor @item f @tab follow dword ptr at address @item n @tab name current address (empty string to delete) @item x @tab show xrefs (search for xrefs) @item # @tab edit comments @item s @tab define a string @item i @tab define an integer (32bit) @item h @tab define a halfword (16bit) @item b @tab define a byte (8bit) @item Ctrl+A @tab call assembler @item Ctrl+F @tab goto start of current function@* (indicated in the 2nd line) @item Ctrl+L @tab goto previous label @item Ctrl+T @tab show recursive function references @end multitable @end itemize @sp 1 @noindent Note: Some keys don't work in HT-posix. Try using Escape instead of Control or something... @node Authors, , Top, Top @unnumberedsec Authors @itemize @bullet @item Stefan Weyergraf @item Sebastian Biallas @email{sb@@biallas.net} @end itemize @node Features, , Top, Top @unnumberedsec Features HT contains some very advanced and useful features, which you should carefully inspect: @menu * General features:: * Configuration files:: * Clipboard:: * Global history:: * Expression evaluation:: * Block operations:: * Search and its different modes:: * Command line options:: @end menu @node General features, , Features, Features @unnumberedsec General features @enumerate 1 @item Supported file formats @itemize @bullet @item common object file format (COFF/XCOFF32) @itemize @w @item - header @* - image with code/data analyser (x86) @end itemize @item executable and linkable format (ELF) @itemize @w @item - header @* - section headers @* - program headers @* - symbol tables @* - image with code/data analyser (x86, AMD64, IA-64, Alpha, PowerPC, ARM) and relocations @end itemize @item linear executables (LE) @itemize @w @item - header @* - VxD descriptor @* - object table @* - page table @* - image with code/data analyser (x86) @* - auto-relocation layer (only internal refs for now) @end itemize @item standard dos executables (MZ) @itemize @w @item - header @* - relocations @* - image (disassembly only) @end itemize @item new executables (NE) @itemize @w @item - header @* - segments @* - names @* - entrypoints @* - image with code/data analyser (x86) @* - auto-relocation layer (pretty complete) @end itemize @item portable executables (PE32, PE64) @itemize @w @item - header @* - import section @* - delay-import section @* - export section @* - resources @* - image with code/data analyser (x86, AMD64, PowerPC, IA-64, Alpha, ARM) @* - preliminary support for .net executables @end itemize @item java class files (CLASS) @itemize @w @item - header @* - image with code/data analyser (java bytecode disassembler) @end itemize @item Mach exe/link format (MachO) @itemize @w @item - header @* - image with code/data analyser (x86, AMD64, PowerPC, ARM) @* @end itemize @item X-Box executable (XBE) @itemize @w @item - header @* - imports @* - image with code/data analyser (x86) @* @end itemize @item Flat (FLT) @itemize @w @item - header @* - image with data analyser (no disassembler yet) @* @end itemize @item PowerPC executable format (PEF) @itemize @w @item - header @* - imports - image with code/data analyser (PowerPC) @* @end itemize @item Still some to be implemented (M$-OBJ, ARCH, LX) @end itemize @item Code & Data Analyser @itemize @w - finds branch sources and destinations recursively @* - finds procedure entries @* - creates labels based on this information @* - creates xref information @* - allows to interactively analyse unexplored code (press 'c') @* - allows to create/rename/delete labels (press 'n') @* - allows to create/edit comments (press '#') @end itemize @item Target systems @itemize @w - DJGPP @* - GNU/Linux @* - FreeBSD @* - Win32 @end itemize @end enumerate @node Configuration files, , Features, Features @unnumberedsec Configuration files @unnumberedsubsec Global configuration HT automatically creates a file to store its configuration. It is called @file{~/.htcfg2} on Unices and @file{ht.cfg2} (where ht.exe resides) on Windows. More specifically it contains HT's registry and the @xref{Global history}. @unnumberedsubsec Per file configuration The analyser (for analysable files) will be stored in an extra file called @file{FILENAME.htcfg}, where FILENAME is the analysed file. This file contains all information to restore the complete state of the analyser. @node Clipboard, , Features, Features @unnumberedsec Clipboard All open files and dialogs use the common clipboard, where all copied and cut text or binary data is stored. Clipboard operations are normally binary safe, that means you can copy some binary data out of a file and paste it into an input line. Exceptions are only the \0 character (binary null), it will be converted to a space in places where it would not make sense (e.g. file open). Although the clipboard won't be saved between different HT sessions (ie. you will loose it when exiting HT), you can either save and load it or part of it manually (via Edit->paste into/copy from file) or rely on the input lines' @xref{Global history, history}, which is stored and retrieved from the config file automatically. @node Global history, , Features, Features @unnumberedsec Global history HTs history system is global, which means that you can use it for all open files. Histories are also grouped by their context. I.e. file-related and regex-search-related dialogs have their own history (who would want to open "[0-9][0-9a-z]+" anyway?). History entries are stored within the @xref{Configuration files}, so they can be reused when you relaunch. You can delete a history entry by pressing DEL inside the history popup. @node Expression evaluation, , Features, Features @unnumberedsec Expression evaluation HT contains a very powerful expression evaluator which is used in all dialogs where expressions are expected. These are mainly blockoperation, goto, search and of course evaluate itself (Edit->Evaluate). You can use all standard math operators (+ - / * % **), logical operators (! && || ^^), relational operators (== != < > <= >=), bit operators (~ & | ^), string operators (. for concatenation), parenthesis, the ternary operator (a?b:c), functions and symbols (both depending on context). The evaluator uses integer, string and float types depending on context. You can always convert a result via the @code{int()}, @code{string()} and @code{float()} functions to appropriate type. Try Edit->Evaluate to see how it works@dots{} @unnumberedsubsec Functions and symbols You can always use the standard built-in math (@code{round}, @code{sin}, @code{random}, etc.) and string (@code{strcmp}, @code{strchr}, @code{sprintf}, etc.) functions, they work more or less like the corresponding C functions (actually they ARE more or less wrappers for them); see @file{eval/eval.y} for details (sorry but a detailed help would get outdated rather soon). The symbol _ always refers to the last result. If you are in a hex buffer, the variable @code{first} contains the offset of the first byte and the variable @code{last} contains the offset of the last byte. This is useful, for instace, if you want to jump to the last byte of a file. If you are in a hex buffer, the variable @code{first} contains the offset of the first byte and the variable @code{last} contains the offset of the last byte. This is useful, for instance, if you want to jump to the last byte of a file. When using @xref{Block operations}, or searching you have some context depending functions and symbols; see these sections for explanation. @node Block operations, , Features, Features @unnumberedsec Block operations Block operation (Blockop) is a very powerful tool to perform modifications on binary files. It is available in hex viewer only. Blockop takes four parameters: @var{start}, @var{end}, @var{mode} and @var{expression}. Blockop works as follows: @itemize @bullet @item START: Start at the offset specified by @var{start} @item REPEAT: Evaluate @var{expression} and store n bytes (1 - byte, 2 - word, 4 - dword, variable - string) at the current offset. Increment current offset by n. Stop if @var{end} has been reached. @end itemize @noindent Special variables/functions that can be used in @var{expression}: @table @code @item readbyte(ofs) read a byte from offset @var{ofs}, returns a number @item readstring(ofs, size) read @var{size} bytes from offset @var{ofs}, returns a string @item i contains the iteration count/index starting with 0 @end table @node Search and its different modes, , Features, Features @unnumberedsec Search and its different modes The search function is one of the most advanced functions of HT. It is invoked through F7, Shift-F7 continues a search from cursor. Depending on context (ie. file type and mode) the following modes are enabled: @unnumberedsubsec bin: ASCII / Hex Enter an exact search string either via ascii characters or via hexadecimal interpretation. This is the fastest search mode. You may specify a case-insensitive search. @unnumberedsubsec bin: eval str Enter an expression, it will be evaluated ONCE (difference to the 4th mode), and HT will then search for the result-string. This is pretty useful when searching for intermixed text and control-chars/binary, e.g. @code{"hello world\n\0"} @unnumberedsubsec display: regex As the prefix indicates, this search doesn't search in the binary file but in the display on screen. HT searches for a regular expression so this can be very powerful, e.g. in PE/Image you can search for @code{(add|sub).+?,\ [78]$}. This will find all add or sub instructions with second parameter 7 or 8. @unnumberedsubsec expr nonzero This is the slowest but also most advanced search mode. Enter an expression and the search stops if this expression evaluates to non-zero (it will be evaluated on every byte). In this mode there are two predefined symbols and some functions: @var{i} is always the number of current iteration and @var{o} stands for the current offset in file. With the functions @code{readbyte(ofs)} and @code{readstring(ofs, size)} you access the file's content. It's easier to understand this with examples: @enumerate 1 @item Searching for patterns: @enumerate a @item Enter @code{readbyte(o) == readbyte(o+1)}@* This will search for two equal bytes ("AA", "55", "!!", etc.). @item Enter @code{(readbyte(o) == readbyte(o+1)-1) && (readbyte(o)==readbyte(o+2)-2)}@* This will search for three ascending bytes ("ABC", "123", etc). @end enumerate @item Search with special functions: With HT you can easily detect the RSA key in the @file{ADVAPI32.DLL}: Search for @code{entropy(readstring(o, 64)) > 82} in expr!=0 mode, and you will find it very quickly. How does it work? @code{readstring(o, 64)} reads a 64 byte string from current offset and entropy calculates the entropy ("randomness") of a string (result is 0..100). So the search stops if a entropy greater than 82% (guessed value) is encountered, which normally indicates packed or encryted data. Note: the @code{entropy()} function is not the best of its kind, if you know of a better one please let us know! @end enumerate @node Command line options, , Features, Features @unnumberedsec Command line options @multitable @columnfractions .10 .20 .70 @item @code{--} @tab @tab treat all additional parameters as file names @item @code{-v} @tab @code{--version} @tab show version and copyright on console @item @code{-h} @tab @code{--help} @tab show help @item @code{-t} @tab @code{--text} @tab load file(s) in text editor mode @item @code{-b} @tab @code{--bin} @tab load file(s) in hex editor mode @item @code{-a} @tab @code{--auto} @tab try to guess file type @end multitable @node Where to download?, , Top, Top @unnumberedsec Where to download? @noindent The HT homepage is located at @hturl{} @noindent Downloads are available from the 'download' section. Please also take a look at @htsfurl{} @ifinfo @contents @end ifinfo @bye ht-2.0.22/doc/README0000644000175000017500000003146212156423374010573 00000000000000HT Editor ========= This is HT 2.0.22; Have fun... About ===== This program is a file viewer, editor and analyzer for text, binary, and (especially) executable files. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Key bindings ============ * General key bindings Return follow link (if applicable) Backspace undo "follow link" Space/F6 choose view mode Alt+[1-9] select window Alt+0 select window list Ctrl+Left/Right scroll left/right Cursor keys move around Page Up/Down next/prev page Alt+S toggle select Ctrl+Ins/Alt+C copy Shift+Ins/Alt+V insert Ctrl+Del/Alt+D delete Shift+Del/Alt+X cut * Window key bindings Alt+F3/Ctrl+W close window Ctrl+F5 resize/move mode (in resize/move mode only:) Space toggle resize/move mode Cursor keys resize/move window Escape/Return/Ctrl+F5leave resize/move mode * Analyser key bindings c continue code analysis at cursor f follow dword ptr at address n name current address (empty string to delete) x show xrefs (search for xrefs) # edit comments s define a string i define an integer (32bit) h define a halfword (16bit) b define a byte (8bit) Ctrl+A call assembler Ctrl+F goto start of current function (indicated in the 2nd line) Ctrl+L goto previous label Ctrl+T show recursive function references Note: Some keys don't work in HT-posix. Try using Escape instead of Control or something... Authors ======= * Stefan Weyergraf * Sebastian Biallas Features ======== HT contains some very advanced and useful features, which you should carefully inspect: General features ================ 1. Supported file formats * common object file format (COFF/XCOFF32) - header - image with code/data analyser (x86) * executable and linkable format (ELF) - header - section headers - program headers - symbol tables - image with code/data analyser (x86, AMD64, IA-64, Alpha, PowerPC, ARM) and relocations * linear executables (LE) - header - VxD descriptor - object table - page table - image with code/data analyser (x86) - auto-relocation layer (only internal refs for now) * standard dos executables (MZ) - header - relocations - image (disassembly only) * new executables (NE) - header - segments - names - entrypoints - image with code/data analyser (x86) - auto-relocation layer (pretty complete) * portable executables (PE32, PE64) - header - import section - delay-import section - export section - resources - image with code/data analyser (x86, AMD64, PowerPC, IA-64, Alpha, ARM) - preliminary support for .net executables * java class files (CLASS) - header - image with code/data analyser (java bytecode disassembler) * Mach exe/link format (MachO) - header - image with code/data analyser (x86, AMD64, PowerPC, ARM) * X-Box executable (XBE) - header - imports - image with code/data analyser (x86) * Flat (FLT) - header - image with data analyser (no disassembler yet) * PowerPC executable format (PEF) - header - imports - image with code/data analyser (PowerPC) * Still some to be implemented (M$-OBJ, ARCH, LX) 2. Code & Data Analyser - finds branch sources and destinations recursively - finds procedure entries - creates labels based on this information - creates xref information - allows to interactively analyse unexplored code (press 'c') - allows to create/rename/delete labels (press 'n') - allows to create/edit comments (press '#') 3. Target systems - DJGPP - GNU/Linux - FreeBSD - Win32 Configuration files =================== Global configuration -------------------- HT automatically creates a file to store its configuration. It is called '~/.htcfg2' on Unices and 'ht.cfg2' (where ht.exe resides) on Windows. More specifically it contains HT's registry and the *Note Global history::. Per file configuration ---------------------- The analyser (for analysable files) will be stored in an extra file called 'FILENAME.htcfg', where FILENAME is the analysed file. This file contains all information to restore the complete state of the analyser. Clipboard ========= All open files and dialogs use the common clipboard, where all copied and cut text or binary data is stored. Clipboard operations are normally binary safe, that means you can copy some binary data out of a file and paste it into an input line. Exceptions are only the \0 character (binary null), it will be converted to a space in places where it would not make sense (e.g. file open). Although the clipboard won't be saved between different HT sessions (ie. you will loose it when exiting HT), you can either save and load it or part of it manually (via Edit->paste into/copy from file) or rely on the input lines' *Note history: Global history, which is stored and retrieved from the config file automatically. Global history ============== HTs history system is global, which means that you can use it for all open files. Histories are also grouped by their context. I.e. file-related and regex-search-related dialogs have their own history (who would want to open "[0-9][0-9a-z]+" anyway?). History entries are stored within the *Note Configuration files::, so they can be reused when you relaunch. You can delete a history entry by pressing DEL inside the history popup. Expression evaluation ===================== HT contains a very powerful expression evaluator which is used in all dialogs where expressions are expected. These are mainly blockoperation, goto, search and of course evaluate itself (Edit->Evaluate). You can use all standard math operators (+ - / * % **), logical operators (! && || ^^), relational operators (== != < > <= >=), bit operators (~ & | ^), string operators (. for concatenation), parenthesis, the ternary operator (a?b:c), functions and symbols (both depending on context). The evaluator uses integer, string and float types depending on context. You can always convert a result via the 'int()', 'string()' and 'float()' functions to appropriate type. Try Edit->Evaluate to see how it works... Functions and symbols --------------------- You can always use the standard built-in math ('round', 'sin', 'random', etc.) and string ('strcmp', 'strchr', 'sprintf', etc.) functions, they work more or less like the corresponding C functions (actually they ARE more or less wrappers for them); see 'eval/eval.y' for details (sorry but a detailed help would get outdated rather soon). The symbol _ always refers to the last result. If you are in a hex buffer, the variable 'first' contains the offset of the first byte and the variable 'last' contains the offset of the last byte. This is useful, for instace, if you want to jump to the last byte of a file. If you are in a hex buffer, the variable 'first' contains the offset of the first byte and the variable 'last' contains the offset of the last byte. This is useful, for instance, if you want to jump to the last byte of a file. When using *Note Block operations::, or searching you have some context depending functions and symbols; see these sections for explanation. Block operations ================ Block operation (Blockop) is a very powerful tool to perform modifications on binary files. It is available in hex viewer only. Blockop takes four parameters: START, END, MODE and EXPRESSION. Blockop works as follows: * START: Start at the offset specified by START * REPEAT: Evaluate EXPRESSION and store n bytes (1 - byte, 2 - word, 4 - dword, variable - string) at the current offset. Increment current offset by n. Stop if END has been reached. Special variables/functions that can be used in EXPRESSION: 'readbyte(ofs)' read a byte from offset OFS, returns a number 'readstring(ofs, size)' read SIZE bytes from offset OFS, returns a string 'i' contains the iteration count/index starting with 0 Search and its different modes ============================== The search function is one of the most advanced functions of HT. It is invoked through F7, Shift-F7 continues a search from cursor. Depending on context (ie. file type and mode) the following modes are enabled: bin: ASCII / Hex ---------------- Enter an exact search string either via ascii characters or via hexadecimal interpretation. This is the fastest search mode. You may specify a case-insensitive search. bin: eval str ------------- Enter an expression, it will be evaluated ONCE (difference to the 4th mode), and HT will then search for the result-string. This is pretty useful when searching for intermixed text and control-chars/binary, e.g. '"hello world\n\0"' display: regex -------------- As the prefix indicates, this search doesn't search in the binary file but in the display on screen. HT searches for a regular expression so this can be very powerful, e.g. in PE/Image you can search for '(add|sub).+?,\ [78]$'. This will find all add or sub instructions with second parameter 7 or 8. expr nonzero ------------ This is the slowest but also most advanced search mode. Enter an expression and the search stops if this expression evaluates to non-zero (it will be evaluated on every byte). In this mode there are two predefined symbols and some functions: I is always the number of current iteration and O stands for the current offset in file. With the functions 'readbyte(ofs)' and 'readstring(ofs, size)' you access the file's content. It's easier to understand this with examples: 1. Searching for patterns: a. Enter 'readbyte(o) == readbyte(o+1)' This will search for two equal bytes ("AA", "55", "!!", etc.). b. Enter '(readbyte(o) == readbyte(o+1)-1) && (readbyte(o)==readbyte(o+2)-2)' This will search for three ascending bytes ("ABC", "123", etc). 2. Search with special functions: With HT you can easily detect the RSA key in the 'ADVAPI32.DLL': Search for 'entropy(readstring(o, 64)) > 82' in expr!=0 mode, and you will find it very quickly. How does it work? 'readstring(o, 64)' reads a 64 byte string from current offset and entropy calculates the entropy ("randomness") of a string (result is 0..100). So the search stops if a entropy greater than 82% (guessed value) is encountered, which normally indicates packed or encryted data. Note: the 'entropy()' function is not the best of its kind, if you know of a better one please let us know! Command line options ==================== '--' treat all additional parameters as file names '-v' '--version' show version and copyright on console '-h' '--help' show help '-t' '--text' load file(s) in text editor mode '-b' '--bin' load file(s) in hex editor mode '-a' '--auto' try to guess file type Where to download? ================== The HT homepage is located at Downloads are available from the 'download' section. Please also take a look at ht-2.0.22/htfltimg.cc0000644000175000001440000000555510615341616011267 00000000000000/* * HT Editor * htfltimg.cc * * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "log.h" #include "htfltimg.h" #include "htpal.h" #include "strtools.h" #include "formats.h" #include "snprintf.h" #include "tools.h" #include "fltstruc.h" #include "flt_analy.h" static ht_view *htfltimage_init(Bounds *b, File *file, ht_format_group *group) { ht_flt_shared_data *flt_shared=(ht_flt_shared_data *)group->get_shared_data(); String fn; LOG("%y: FLAT: loading image (starting analyser)...", &file->getFilename(fn)); FLTAnalyser *p = new FLTAnalyser(); p->init(flt_shared, file); Bounds c=*b; ht_group *g=new ht_group(); g->init(&c, VO_RESIZE, DESC_FLT_IMAGE"-g"); AnalyInfoline *head; c.y+=2; c.h-=2; ht_flt_aviewer *v=new ht_flt_aviewer(); v->init(&c, DESC_FLT_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, p, flt_shared); c.y-=2; c.h=2; head=new AnalyInfoline(); head->init(&c, v, ANALY_STATUS_DEFAULT); v->attachInfoline(head); /* find lowest/highest address */ Address *low; Address *high; low = p->createAddress32(flt_shared->code_start); high = p->createAddress32(flt_shared->bss_end-1); ht_analy_sub *analy=new ht_analy_sub(); if (low->compareTo(high) < 0) { analy->init(file, v, p, low, high); v->analy_sub = analy; v->insertsub(analy); } else { delete analy; v->done(); delete v; head->done(); delete head; g->done(); delete g; delete high; delete low; return NULL; } delete high; delete low; v->sendmsg(msg_complete_init, 0); Address *tmpaddr = p->createAddress32(flt_shared->header.entry); v->gotoAddress(tmpaddr, NULL); delete tmpaddr; g->insert(head); g->insert(v); g->setpalette(palkey_generic_window_default); // macho_shared->v_image=v; return g; } format_viewer_if htfltimage_if = { htfltimage_init, 0 }; /* * CLASS ht_flt_aviewer */ void ht_flt_aviewer::init(Bounds *b, const char *desc, int caps, File *File, ht_format_group *format_group, Analyser *Analy, ht_flt_shared_data *FLT_shared) { ht_aviewer::init(b, desc, caps, File, format_group, Analy); flt_shared = FLT_shared; } void ht_flt_aviewer::setAnalyser(Analyser *a) { ((FLTAnalyser *)a)->flt_shared = flt_shared; ((FLTAnalyser *)a)->file = file; analy = a; analy_sub->setAnalyser(a); } ht-2.0.22/store.h0000644000175000001440000001205210615341624010434 00000000000000/* * HT Editor * store.h * * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef STORE_H #define STORE_H #include "data.h" #include "sys/types.h" typedef Object *(*object_builder)(); #include "stream.h" #include "except.h" class ObjectNotRegisteredException: public MsgfException { ObjectID mID; public: ObjectNotRegisteredException(ObjectID aID); }; class ObjectStreamInter: public ObjectStream { public: ObjectStreamInter(Stream *s, bool own_stream); /* extends ObjectStream */ virtual Object *getObjectInternal(const char *name, ObjectID id = OBJID_INVALID); virtual void putObject(const Object *object, const char *name, ObjectID id = OBJID_INVALID); }; class ObjectStreamBin: public ObjectStreamInter { public: ObjectStreamBin(Stream *s, bool own_s); /* extends ObjectStream */ virtual void getBinary(void *buf, uint size, const char *desc); virtual bool getBool(const char *desc); virtual uint64 getInt(uint size, const char *desc); virtual char * getString(const char *desc); virtual byte * getLenString(int &length, const char *desc); virtual void putBinary(const void *mem, uint size, const char *desc); virtual void putBool(bool b, const char *desc); virtual void putComment(const char *comment); virtual void putCommentf(const char *comment_format, ...); virtual void putInt(uint64 i, uint size, const char *desc, uint int_fmt_hint = OS_FMT_DEC); virtual void putSeparator(); virtual void putString(const char *string, const char *desc); virtual void putLenString(const byte *string, int length, const char *desc); virtual void corrupt(); }; class ObjectStreamText: public ObjectStreamInter { protected: char cur; int line; int errorline; int indent; public: ObjectStreamText(Stream *s, bool own_stream); /* extends ObjectStreamInter */ virtual Object * getObjectInternal(const char *name, ObjectID id = OBJID_INVALID); virtual void putObject(const Object *object, const char *name, ObjectID id = OBJID_INVALID); /* extends ObjectStream */ virtual void getBinary(void *buf, uint size, const char *desc); virtual bool getBool(const char *desc); virtual uint64 getInt(uint size, const char *desc); virtual char * getString(const char *desc); virtual byte * getLenString(int &length, const char *desc); virtual void putBinary(const void *mem, uint size, const char *desc); virtual void putBool(bool b, const char *desc); virtual void putComment(const char *comment); virtual void putInt(uint64 i, uint size, const char *desc, uint int_fmt_hint = OS_FMT_DEC); virtual void putSeparator(); virtual void putString(const char *string, const char *desc); virtual void putLenString(const byte *string, int length, const char *desc); virtual void corrupt(); void setSyntaxError(); int getErrorLine(); private: /* io */ void expect(char c); void skipWhite(); char readChar(); void readDesc(const char *desc); void putDesc(const char *desc); void putIndent(); void putChar(char c); void putS(const char *s); }; /* * ObjectStreamNative View:set/getData() methods * (endian-dependend) */ #define DATABUF_BOOL(name) bool name PACKED #define DATABUF_UINT(name) uint name PACKED #define DATABUF_PTR(type, name) type* name PACKED class ObjectStreamNative: public ObjectStream { protected: bool duplicate; Array allocd; void *duppa(const void *p, int size); public: ObjectStreamNative(Stream *s, bool own_s, bool duplicate); /* extends ObjectStream */ virtual void getBinary(void *buf, uint size, const char *desc); virtual bool getBool(const char *desc); virtual uint64 getInt(uint size, const char *desc); virtual Object * getObjectInternal(const char *name, ObjectID id = OBJID_INVALID); virtual char * getString(const char *desc); virtual byte * getLenString(int &length, const char *desc); virtual void putBinary(const void *mem, uint size, const char *desc); virtual void putBool(bool b, const char *desc); virtual void putComment(const char *comment); virtual void putInt(uint64 i, uint size, const char *desc, uint int_fmt_hint = OS_FMT_DEC); virtual void putObject(const Object *object, const char *name, ObjectID id = OBJID_INVALID); virtual void putSeparator(); virtual void putString(const char *string, const char *desc); virtual void putLenString(const byte *string, int length, const char *desc); virtual void corrupt(); }; void putIDComment(ObjectStream &o, uint32 id); #endif ht-2.0.22/htmzhead.cc0000644000175000001440000000675610615341620011254 00000000000000/* * HT Editor * htmzhead.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "htmz.h" #include "htmzhead.h" #include "httag.h" #include "formats.h" #include "snprintf.h" static ht_mask_ptable mzheader[]= { {"magic", STATICTAG_EDIT_WORD_LE("00000000")}, {"bytes on last page of file", STATICTAG_EDIT_WORD_LE("00000002")}, {"pages in file", STATICTAG_EDIT_WORD_LE("00000004")}, {"number of relocations", STATICTAG_EDIT_WORD_LE("00000006")}, {"size of header in paragraphs", STATICTAG_EDIT_WORD_LE("00000008")}, {"minimum extra paragraphs needed", STATICTAG_EDIT_WORD_LE("0000000a")}, {"maximum extra paragraphs needed", STATICTAG_EDIT_WORD_LE("0000000c")}, {"initial SS value", STATICTAG_EDIT_WORD_LE("0000000e")}, {"initial SP value", STATICTAG_EDIT_WORD_LE("00000010")}, {"checksum", STATICTAG_EDIT_WORD_LE("00000012")}, {"initial IP value", STATICTAG_EDIT_WORD_LE("00000014")}, {"initial CS value", STATICTAG_EDIT_WORD_LE("00000016")}, {"offset of relocation table", STATICTAG_EDIT_WORD_LE("00000018")}, {"overlay number", STATICTAG_EDIT_WORD_LE("0000001a")}, {"reserved", STATICTAG_EDIT_BYTE("0000001c")" "STATICTAG_EDIT_BYTE("0000001d")" "STATICTAG_EDIT_BYTE("0000001e")" "STATICTAG_EDIT_BYTE("0000001f")" "STATICTAG_EDIT_BYTE("00000020")" "STATICTAG_EDIT_BYTE("00000021")" "STATICTAG_EDIT_BYTE("00000022")" "STATICTAG_EDIT_BYTE("00000023")}, {"reserved", STATICTAG_EDIT_BYTE("00000024")" "STATICTAG_EDIT_BYTE("00000025")" "STATICTAG_EDIT_BYTE("00000026")" "STATICTAG_EDIT_BYTE("00000027")" "STATICTAG_EDIT_BYTE("00000028")" "STATICTAG_EDIT_BYTE("00000029")" "STATICTAG_EDIT_BYTE("0000002a")" "STATICTAG_EDIT_BYTE("0000002b")}, {"reserved", STATICTAG_EDIT_BYTE("0000002c")" "STATICTAG_EDIT_BYTE("0000002d")" "STATICTAG_EDIT_BYTE("0000002e")" "STATICTAG_EDIT_BYTE("0000002f")" "STATICTAG_EDIT_BYTE("00000030")" "STATICTAG_EDIT_BYTE("00000031")" "STATICTAG_EDIT_BYTE("00000032")" "STATICTAG_EDIT_BYTE("00000033")}, {"reserved", STATICTAG_EDIT_BYTE("00000034")" "STATICTAG_EDIT_BYTE("00000035")" "STATICTAG_EDIT_BYTE("00000036")" "STATICTAG_EDIT_BYTE("00000037")" "STATICTAG_EDIT_BYTE("00000038")" "STATICTAG_EDIT_BYTE("00000039")" "STATICTAG_EDIT_BYTE("0000003a")" "STATICTAG_EDIT_BYTE("0000003b")}, {"file offset of new executable header",STATICTAG_EDIT_DWORD_LE("0000003c")}, {0, 0} }; static ht_view *htmzheader_init(Bounds *b, File *file, ht_format_group *group) { ht_uformat_viewer *v = new ht_uformat_viewer(); v->init(b, DESC_MZ_HEADER, VC_EDIT | VC_SEARCH, file, group); ht_mask_sub *m = new ht_mask_sub(); m->init(file, 0); char info[128]; ht_snprintf(info, sizeof info, "* MZ header at offset 0x%08x (paragraph=16 bytes, page=512 bytes)", 0); /* FIXME: hmm, seems to be always 0 ?! */ m->add_mask(info); m->add_staticmask_ptable(mzheader, 0, false); v->insertsub(m); return v; } format_viewer_if htmzheader_if = { htmzheader_init, 0 }; ht-2.0.22/except.cc0000644000175000001440000000676010615344716010744 00000000000000/* * HT Editor * except.cc * * Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "except.h" #include "snprintf.h" #include "strtools.h" /* * Exception */ String &Exception::reason(String &result) const { result = "Unknown Exception"; return result; } int Exception::toString(char *buf, int buflen) const { String s; return reason(s).toString(buf, buflen); } /* * MsgException */ MsgException::MsgException(const char *e) { ht_strlcpy(estr, e, sizeof estr); } String &MsgException::reason(String &result) const { result = estr; return result; } /* * MsgfException */ MsgfException::MsgfException(const char *e,...) : MsgException() { va_list va; va_start(va, e); ht_vsnprintf(estr, sizeof estr, e, va); va_end(va); } /* * IOException */ //#include IOException::IOException(int aPosixErrno) { mPosixErrno = aPosixErrno; errstr = strerror(mPosixErrno); // raise(SIGTRAP); } String &IOException::reason(String &result) const { result = "I/O error: " + errstr; return result; } /* * EOFException */ EOFException::EOFException() : IOException(0) { } String &EOFException::reason(String &result) const { return result="unexpected end of file"; } /* * NotImplementedException */ NotImplementedException::NotImplementedException(const String &filename, int line_number) { if (line_number) { location.assignFormat("%y:%d", &filename, line_number); } else { location = filename; } } String &NotImplementedException::reason(String &result) const { result = "Function not implemented"; if (!location.isEmpty()) { result += ": "; result += location; } return result; } /* * IllegalArgumentException */ IllegalArgumentException::IllegalArgumentException(const String &filename, int line_number) { if (line_number) { location.assignFormat("%y:%d", &filename, line_number); } else { location = filename; } } String &IllegalArgumentException::reason(String &result) const { result = "Illegal argument"; if (!location.isEmpty()) { result += ": "; result += location; } return result; } /* * IndexOutOfBoundsException */ IndexOutOfBoundsException::IndexOutOfBoundsException(const String &filename, int line_number) { if (line_number) { location.assignFormat("%y:%d", &filename, line_number); } else { location = filename; } } String &IndexOutOfBoundsException::reason(String &result) const { result = "Index out of bounds"; if (!location.isEmpty()) { result += ": "; result += location; } return result; } /* * TypeCastException */ TypeCastException::TypeCastException(const String &cast_type, const String &obj_type) { aresult.assignFormat("(%y) %y", &cast_type, &obj_type); } String &TypeCastException::reason(String &result) const { result = "Bad type cast"; if (!aresult.isEmpty()) { result += ": "; result += aresult; } return result; } ht-2.0.22/htfltimg.h0000644000175000001440000000230010615341616011112 00000000000000/* * HT Editor * htfltimg.h * * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTFLTIMG_H__ #define __HTFLTIMG_H__ #include "htanaly.h" #include "htflt.h" #include "formats.h" extern format_viewer_if htfltimage_if; /* * CLASS ht_flt_aviewer */ class ht_flt_aviewer: public ht_aviewer { public: ht_flt_shared_data *flt_shared; void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Analyser *Analyser, ht_flt_shared_data *flt_shared); virtual void setAnalyser(Analyser *a); }; #endif /* !__HTFLTIMG_H__ */ ht-2.0.22/classread.cc0000644000175000001440000004575210615341616011415 00000000000000/* * HT Editor * classread.cc * * Copyright (C) 2001 Stanley Gambarin * Copyright (C) 2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "analy.h" #include "class.h" #include "strtools.h" #include "snprintf.h" #include "stream.h" static u1 inp[4]; static u4 offset; #define cls_read(a, b, c, d) (((b) != ((d)->read((a), (b)*(c)))) \ ? (0) : (offset+=(b), (b))) #define READ1() \ (((inp[0]=inp[1]=inp[2]=inp[3]=0), \ (1 == cls_read (inp, 1, 1, htio))) \ ? (u1)(inp[0]) : 0) #define READ2() \ (((inp[0]=inp[1]=inp[2]=inp[3]=0), \ (2 == cls_read (inp, 2, 1, htio))) \ ? ((((u2)inp[0])<<8)|inp[1]) : 0) #define READ4() \ (((inp[0]=inp[1]=inp[2]=inp[3]=0), \ (4 == cls_read (inp, 4, 1, htio))) \ ? (((((((u4)inp[0]<<8)|inp[1])<<8)|inp[2])<<8)|inp[3]) : 0) #define READN(inb, n) cls_read (inb, n, 1, htio) #define SKIPN(n) {u1 b; for (u4 i=0; istart) return -1; if (start > (cm->start + cm->length - 1)) return 1; return 0; } ClassField::ClassField(char *n, char *d, int f) { name = n; type = d; flags = f; } /* extract name from a utf8 constant pool entry */ static char *get_string(Stream *htio, classfile *clazz, uint index) { return (index < clazz->cpool_count) ? clazz->cpool[index]->value.string : (char*)"?"; } /* extract name from a utf8 constant pool class entry */ static char *get_class_name(Stream *htio, classfile *clazz, uint index) { return (index < clazz->cpool_count) ? get_string(htio, clazz, clazz->cpool[index]->value.llval[0]): (char*)"?"; } /* extract name from a utf8 constant pool class entry */ static void get_name_and_type(Stream *htio, classfile *clazz, uint index, char *name, char *type) { strcpy(name, (index < clazz->cpool_count) ? get_string(htio, clazz, clazz->cpool[index]->value.llval[0]) : "?"); strcpy(type, (index < clazz->cpool_count) ? get_string(htio, clazz, clazz->cpool[index]->value.llval[1]) : "?"); } /* read and return constant pool entry */ static cp_info *read_cpool_entry(Stream *htio, classfile *clazz) { cp_info *cp; u2 idx; cp = ht_malloc(sizeof (*cp)); cp->offset = offset; cp->tag = READ1(); switch (cp->tag) { case CONSTANT_Utf8: idx = READ2(); cp->value.string = ht_malloc(idx+1); cls_read(cp->value.string, idx, 1, htio); cp->value.string[idx] = 0; break; case CONSTANT_Integer: case CONSTANT_Float: cp->value.ival = READ4(); break; case CONSTANT_Long: case CONSTANT_Double: cp->value.llval[0] = READ4(); cp->value.llval[1] = READ4(); break; case CONSTANT_Class: case CONSTANT_String: cp->value.llval[0] = READ2(); break; case CONSTANT_Fieldref: case CONSTANT_Methodref: case CONSTANT_InterfaceMethodref: case CONSTANT_NameAndType: cp->value.llval[0] = READ2(); cp->value.llval[1] = READ2(); break; default: return NULL; } return (cp); } /* read and return an attribute read */ attrib_info *attribute_read(Stream *htio, classfile *clazz) { attrib_info *a; u4 len; char *aname; a = ht_malloc(sizeof (*a)); if (!a) { return NULL; } a->offset = offset; a->name = READ2(); a->len = len = READ4(); aname = get_string(htio, clazz, a->name); if (!strcmp (aname, "ConstantValue")) { a->tag = ATTRIB_ConstantValue; } else if (!strcmp(aname, "Code")) { a->tag = ATTRIB_Code; a->code.max_stack = READ2(); a->code.max_locals = READ2(); a->code.len = READ4(); a->code.start = offset; len -= 2+2+4+a->code.len; SKIPN(a->code.len); a->code.exctbl_len = READ2(); if (a->code.exctbl_len) { a->code.exctbl = ht_malloc(a->code.exctbl_len * sizeof(exception_info)); for (uint i=0; i < a->code.exctbl_len; i++) { a->code.exctbl[i].start_pc = READ2(); a->code.exctbl[i].end_pc = READ2(); a->code.exctbl[i].handler_pc = READ2(); a->code.exctbl[i].catch_type = READ2(); } } len -= 2 + 8*a->code.exctbl_len; } else if (!strcmp(aname, "Signature")) { a->tag = ATTRIB_Signature; a->signature = READ2(); len -= 2; } else if (!strcmp(aname, "Exceptions")) { a->tag = ATTRIB_Exceptions; } else if (!strcmp(aname, "InnerClasses")) { a->tag = ATTRIB_InnerClasses; } else if (!strcmp(aname, "Synthetic")) { a->tag = ATTRIB_Synthetic; } else if (!strcmp(aname, "SourceFile")) { a->tag = ATTRIB_SourceFile; } else if (!strcmp(aname, "LineNumberTable")) { a->tag = ATTRIB_LineNumberTable; } else if (!strcmp(aname, "LocalVariableTable")) { a->tag = ATTRIB_LocalVariableTable; } else if (!strcmp(aname, "Deprecated")) { a->tag = ATTRIB_Deprecated; } SKIPN(len); return (a); } /* read and return method info */ static mf_info *read_fieldmethod(Stream *htio, ht_class_shared_data *shared) { mf_info *m; u2 idx; classfile *clazz = shared->file; m = (mf_info *)calloc(1, sizeof (*m)); if (!m) { return NULL; } m->offset = offset; m->flags = READ2(); m->name = get_string(htio, clazz, READ2()); m->desc = get_string(htio, clazz, READ2()); m->attribs_count = idx = READ2(); if (idx) { m->attribs = ht_malloc(idx * sizeof (*(m->attribs))); if (!m->attribs) { return NULL; } for (int i=0; i < (int)idx; i++) { m->attribs[i] = attribute_read(htio, clazz); } } return m; } /* read and return classfile */ ht_class_shared_data *class_read(File *htio) { ht_class_shared_data *shared; classfile *clazz; u2 count; u2 cpcount, index; clazz = ht_malloc(sizeof (*clazz)); if (!clazz) { return NULL; } shared = ht_malloc(sizeof (ht_class_shared_data)); shared->file = clazz; shared->methods = new AVLTree(true); shared->fields = new Array(true); shared->valid = new Area(); shared->valid->init(); shared->initialized = new Area(); shared->initialized->init(); clazz->offset = offset = 0; clazz->magic = READ4(); if (clazz->magic != 0xCAFEBABE) { return NULL; } clazz->minor_version = READ2(); clazz->major_version = READ2(); count = clazz->cpool_count = READ2(); clazz->cpool = ht_malloc((count+1) * sizeof (*(clazz->cpool))); if (!clazz->cpool) { return NULL; } cpcount = clazz->cpool_count; for (int i=1; i<(int)count; i++) { clazz->cpool[i] = read_cpool_entry(htio, clazz); if ((clazz->cpool[i]->tag == CONSTANT_Long) || (clazz->cpool[i]->tag == CONSTANT_Double)) { i++; } } clazz->coffset = offset; clazz->access_flags = READ2(); shared->flags = clazz->access_flags; index = READ2(); clazz->this_class = index; index = READ2(); clazz->super_class = index; count = clazz->interfaces_count = READ2(); shared->classinfo.interfaces = NULL; shared->classinfo.thisclass = get_class_name(htio, clazz, clazz->this_class); if (strcmp(shared->classinfo.thisclass, "?") == 0) return NULL; shared->classinfo.superclass = get_class_name(htio, clazz, clazz->super_class); if (strcmp(shared->classinfo.superclass, "?") == 0) return NULL; if (count) { clazz->interfaces = ht_malloc(count * sizeof (*(clazz->interfaces))); if (!clazz->interfaces) return NULL; shared->classinfo.interfaces = new Array(true); for (int i=0; i < (int)count; i++) { index = READ2(); clazz->interfaces[i] = index; shared->classinfo.interfaces->insert(new String(get_class_name(htio, clazz, index))); } } else { clazz->interfaces = 0; } clazz->foffset = offset; count = clazz->fields_count = READ2(); if (count) { clazz->fields = ht_malloc(count * sizeof (*(clazz->fields))); if (!clazz->fields) { return NULL; } for (int i=0; i < (int)count; i++) { mf_info *m = read_fieldmethod(htio, shared); clazz->fields[i] = m; ClassField *cf = new ClassField(m->name, m->desc, m->flags); int acount = m->attribs_count; for (int j=0; j < acount; j++) { attrib_info *ai = m->attribs[j]; if (ai->tag == ATTRIB_Signature) { cf->addsig(get_string(htio, shared->file, ai->signature)); } } shared->fields->insert(cf); } } else { clazz->fields = 0; } clazz->moffset = offset; count = clazz->methods_count = READ2(); if (count) { clazz->methods = ht_malloc(count * sizeof (*(clazz->methods))); if (!clazz->methods) { return NULL; } for (int i=0; i < (int)count; i++) { mf_info *m = read_fieldmethod(htio, shared); clazz->methods[i] = m; int acount = m->attribs_count; bool ok = false; ClassMethod *cm = NULL; for (int j=0; j < acount; j++) { attrib_info *ai = m->attribs[j]; if (ai->tag == ATTRIB_Code) { cm = new ClassMethod(m->name, m->desc, ai->code.start, ai->code.len, m->flags, ai->code.exctbl_len, ai->code.exctbl); shared->methods->insert(cm); AddressFlat32 a1(ai->code.start); AddressFlat32 a2(ai->code.start+ai->code.len); shared->initialized->add(&a1, &a2); shared->valid->add(&a1, &a2); ok = true; } else if (ai->tag == ATTRIB_Signature && cm) { cm->addsig(get_string(htio, shared->file, ai->signature)); } } if (!ok) { // fake abstract method ClassMethod *cm = new ClassMethod(m->name, m->desc, offset, 1, m->flags, 0, NULL); shared->methods->insert(cm); Address *a1 = new AddressFlat32(offset); Address *a2 = new AddressFlat32(offset+1); shared->valid->add(a1, a2); delete a1; delete a2; } } } else { clazz->methods = 0; } clazz->aoffset = offset; count = clazz->attribs_count = READ2(); if (count) { clazz->attribs = ht_malloc(count*sizeof (*(clazz->attribs))); if (!clazz->attribs) { return NULL; } for (int i=0; i<(int)count; i++) { clazz->attribs[i] = attribute_read (htio, clazz); if (!clazz->attribs[i]) { return NULL; } } } else { clazz->attribs = 0; } return shared; } void class_unread(ht_class_shared_data *shared) { u1 tag; classfile *clazz = shared->file; if (!clazz) return; for (uint i = 1; i < clazz->cpool_count; i++) { tag = clazz->cpool[i]->tag; if (tag == CONSTANT_Utf8) { free(clazz->cpool[i]->value.string); } free(clazz->cpool[i]); if (tag == CONSTANT_Long || tag == CONSTANT_Double) { i++; } } if (clazz->cpool_count) free(clazz->cpool); free(clazz->interfaces); for (uint i=0; i < clazz->fields_count; i++) { for (uint j=0; j < clazz->fields[i]->attribs_count; j++) { free(clazz->fields[i]->attribs[j]); } if (clazz->fields[i]->attribs_count) free(clazz->fields[i]->attribs); free(clazz->fields[i]); } if (clazz->fields_count) free(clazz->fields); for (uint i=0; i < clazz->methods_count; i++) { for (uint j=0; jmethods[i]->attribs_count; j++) { free (clazz->methods[i]->attribs[j]); } if (clazz->methods[i]->attribs_count) free(clazz->methods[i]->attribs); free(clazz->methods[i]); } if (clazz->methods_count) free(clazz->methods); for (uint i=0; i < clazz->attribs_count; i++) { free(clazz->attribs[i]); } if (clazz->attribs_count) { free(clazz->attribs); } if (shared->valid) { shared->valid->done(); delete shared->valid; } /* if (shared->initialized) { shared->initialized->done(); delete shared->initialized; }*/ delete shared->methods; free(shared->file); free(shared); } int java_demangle_type(char *result, const char **type); int java_demangle_generic(char *result, const char **type) { #if 0 (Ljava/util/List<+Ljava/lang/Float;>;)V (Ljava/util/List<*>;)V (Ljava/util/Map;)V (Ljava/util/Map;)V (Ljava/util/Map;)V (Ljava/util/Map;)V (Ljava/util/List;)V #endif char *old = result; *result++ = '<'; (*type)++; goto first; do { *result++ = ','; *result++ = ' '; first: switch (**type) { case 0: *result = 0; return result-old; case '*': (*type)++; *result++ = '?'; break; case '+': case '-': result += sprintf(result, "? %s ", **type=='+' ? "extends": "super"); (*type)++; // fall through default: result += java_demangle_type(result, type); } } while (**type != '>'); (*type)++; *result++ = '>'; *result = 0; return result - old; } #define STRIP_PATH int java_demangle_template(char *result, const char **type) { char *old = result; *result++ = '<'; (*type)++; goto first; do { *result++ = ','; *result++ = ' '; first: if (*type == 0) { *result = 0; return result - old; } do { *result++ = **type; (*type)++; } while (**type != ':' && **type != 0); result += sprintf(result, " extends "); goto first2; do { *result++ = ' '; *result++ = '&'; *result++ = ' '; first2: if (*type == 0) { *result = 0; return result - old; } (*type)++; result += java_demangle_type(result, type); } while (**type == ':'); } while (**type != '>'); *result++ = '>'; (*type)++; return result - old; } int java_demangle_type(char *result, const char **type) { switch (*(*type)++) { case 0: *result = 0; (*type)--; return 0; case '[': { char temp[300]; java_demangle_type(temp, type); return sprintf(result, "%s[]", temp); } case 'B': return sprintf(result, "byte"); case 'C': return sprintf(result, "char"); case 'D': return sprintf(result, "double"); case 'F': return sprintf(result, "float"); case 'I': return sprintf(result, "int"); case 'J': return sprintf(result, "long"); case 'T': case 'L': { char *oldresult = result; while (**type != ';' && **type != '<' && **type != 0) { *result = **type; #ifdef STRIP_PATH if (*result == '/') result = oldresult; else #endif result++; (*type)++; } if (**type == '<') { result += java_demangle_generic(result, type); } (*type)++; *result = 0; return result-oldresult; } case 'S': return sprintf(result, "short"); case 'V': return sprintf(result, "void"); case 'Z': return sprintf(result, "boolean"); default: return sprintf(result, "%c", *(*type-1)); } } char *java_demangle_flags(char *result, int flags) { if (flags & jACC_PUBLIC) result += sprintf(result, "public "); if (flags & jACC_PRIVATE) result += sprintf(result, "private "); if (flags & jACC_PROTECTED) result += sprintf(result, "protected "); if (flags & jACC_STATIC) result += sprintf(result, "static "); if (flags & jACC_FINAL) result += sprintf(result, "final "); if (flags & jACC_SUPER) result += sprintf(result, "super "); if (flags & jACC_SYNCHRONIZED) result += sprintf(result, "synchronized "); if (flags & jACC_VOLATILE) result += sprintf(result, "volatile "); if (flags & jACC_TRANSIENT) result += sprintf(result, "transient "); if (flags & jACC_NATIVE) result += sprintf(result, "native "); if (flags & jACC_INTERFACE) result += sprintf(result, "interface "); if (flags & jACC_ABSTRACT) result += sprintf(result, "abstract "); if (flags & jACC_STRICT) result += sprintf(result, "strict "); return result; } static const char *java_strip_path(const char *name) { #ifdef STRIP_PATH const char *nname = strrchr(name, '/'); return nname?(nname+1):name; #else return name; #endif } void java_demangle(char *result, const char *classname, const char *name, const char *type, int flags) { result = java_demangle_flags(result, flags); name = java_strip_path(name); classname = java_strip_path(classname); strcpy(result, name); const char *ret = strchr(type, ')'); if (!ret) return; if (*type == '<') { result += java_demangle_template(result, &type); *result++ = ' '; *result = 0; } if (*type != '(') return; ret++; result += java_demangle_type(result, &ret); if (strcmp(name, "")==0) { name = classname; } result += sprintf(result, " %s::%s(", classname, name); type++; while (*type != ')') { result += java_demangle_type(result, &type); if (*type != ')') { result += sprintf(result, ", "); } } result += sprintf(result, ")"); } void java_demangle_field(char *result, const char *name, const char *type, int flags) { result = java_demangle_flags(result, flags); result += java_demangle_type(result, &type); *result++ = ' '; strcpy(result, name); } int token_translate(char *buf, int maxlen, uint32 token, ht_class_shared_data *shared) { classfile *clazz = shared->file; char tag[20]; char data[1024]; char classname[1024]; char name[1024]; char type[1024]; strcpy(tag, "?"); strcpy(data, "?"); strcpy(classname, "?"); strcpy(name, "?"); strcpy(type, "?"); if (token < clazz->cpool_count) switch (clazz->cpool[token]->tag) { case CONSTANT_Class: { strcpy(tag, "Class"); const char *cl = get_class_name(NULL, clazz, token); if (cl[0] == '[') { java_demangle_type(data, &cl); } else { strcpy(data, java_strip_path(cl)); } break; } case CONSTANT_Double: strcpy(tag, "Double"); sprintf(data, "double (%f)", clazz->cpool[token]->value.dval); break; case CONSTANT_Float: strcpy(tag, "Float"); sprintf(data, "float (%f)", clazz->cpool[token]->value.fval); break; case CONSTANT_Integer: strcpy(tag, "Int"); ht_snprintf(data, sizeof data, "int (%d)", clazz->cpool[token]->value.ival); break; case CONSTANT_Long: { strcpy(tag, "Long"); uint64 v = (uint64(clazz->cpool[token]->value.llval[0]) << 32) | clazz->cpool[token]->value.llval[1]; ht_snprintf(data, sizeof data, "long (%qd)", v); break; } case CONSTANT_String: { strcpy(tag, "String"); char *d = data; *d++ = '\"'; // FIXME: add "..." on too long strings d += escape_special_str(d, 256, get_string(NULL, clazz, clazz->cpool[token]->value.llval[0]), "\"", false); *d++ = '\"'; *d = 0; break; } case CONSTANT_Fieldref: { strcpy(tag, "Field"); get_name_and_type(NULL, clazz, clazz->cpool[token]->value.llval[1], name, type); char dtype[1024]; const char *ttype=type; java_demangle_type(dtype, &ttype); ht_snprintf(data, sizeof data, "%s %s", dtype, name); break; } case CONSTANT_Methodref: strcpy(tag, "Method"); strcpy(classname, get_class_name(NULL, clazz, clazz->cpool[token]->value.llval[0])); get_name_and_type(NULL, clazz, clazz->cpool[token]->value.llval[1], name, type); java_demangle(data, classname, name, type, 0); break; case CONSTANT_InterfaceMethodref: strcpy(tag, "InterfaceMethod"); strcpy(classname, get_class_name(NULL, clazz, clazz->cpool[token]->value.llval[0])); get_name_and_type(NULL, clazz, clazz->cpool[token]->value.llval[1], name, type); java_demangle(data, classname, name, type, 0); break; } // return ht_snprintf(buf, maxlen, "<%s %s>", tag, data); return ht_snprintf(buf, maxlen, "<%s>", data); } ht-2.0.22/htmacho.h0000644000175000001440000000466010655731110010726 00000000000000/* * HT Editor * htmach-o.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTMACHO_H__ #define __HTMACHO_H__ #include "machostruc.h" #include "formats.h" #include "endianess.h" #include "htformat.h" #define DESC_MACHO "Mach-O - Mach exe/link format" #define DESC_MACHO_HEADER "Mach-O/header" /*#define DESC_MACHO_SECTION_HEADERS "elf/section headers" #define DESC_MACHO_PROGRAM_HEADERS "elf/program headers" #define DESC_MACHO_SYMTAB "elf/symbol table %s (%d)" #define DESC_MACHO_RELOCTAB "elf/relocation table %s (%d)"*/ #define DESC_MACHO_IMAGE "Mach-O/image" extern format_viewer_if htmacho_if; struct macho_commands { uint count; MACHO_COMMAND_U **cmds; }; struct ht_macho_shared_data { FileOfs header_ofs; union { MACHO_HEADER header; MACHO_HEADER64 header64; }; macho_commands cmds; uint section_count; MACHO_SECTION_U *sections; Endianess image_endianess; bool _64; }; /* * CLASS ht_macho */ class ht_macho: public ht_format_group { public: void init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs, Endianess image_endianess, bool _64); }; typedef uint64 MACHOAddress; bool macho_phys_and_mem_section(MACHO_SECTION_U *s); bool macho_valid_section(MACHO_SECTION_U *s); bool macho_addr_to_section(MACHO_SECTION_U *section_headers, uint section_count, MACHOAddress addr, int *section); bool macho_addr_to_ofs(MACHO_SECTION_U *section_headers, uint section_count, MACHOAddress addr, FileOfs *ofs); bool macho_addr_is_valid(MACHO_SECTION_U *section_headers, uint section_count, MACHOAddress addr); bool macho_ofs_to_addr(MACHO_SECTION_U *section_headers, uint section_count, FileOfs ofs, MACHOAddress *addr); bool macho_ofs_to_section(MACHO_SECTION_U *section_headers, uint section_count, FileOfs ofs, int *section); #endif /* !__HTMACHO_H__ */ ht-2.0.22/htmzimg.h0000644000175000001440000000152110206756710010760 00000000000000/* * HT Editor * htmzimg.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTMZIMG_H__ #define __HTMZIMG_H__ #include "htobj.h" extern format_viewer_if htmzimage_if; #endif /* !__HTMZIMG_H__ */ ht-2.0.22/htflthd.cc0000644000175000001440000000373410615341616011103 00000000000000/* * HT Editor * htflthd.cc * * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "fltstruc.h" #include "atom.h" #include "htflt.h" #include "htflthd.h" #include "httag.h" #include "formats.h" #include "snprintf.h" static ht_mask_ptable fltheader[]= { {"magic", STATICTAG_EDIT_DWORD_BE("00000000")}, {"version", STATICTAG_EDIT_DWORD_BE("00000004")}, {"entry", STATICTAG_EDIT_DWORD_BE("00000008")}, {"data_start", STATICTAG_EDIT_DWORD_BE("0000000c")}, {"data_end", STATICTAG_EDIT_DWORD_BE("00000010")}, {"bss_end", STATICTAG_EDIT_DWORD_BE("00000014")}, {"stack_size", STATICTAG_EDIT_DWORD_BE("00000018")}, {"reloc_start", STATICTAG_EDIT_DWORD_BE("0000001c")}, {"reloc_count", STATICTAG_EDIT_DWORD_BE("00000020")}, {0, 0} }; static ht_view *htfltheader_init(Bounds *b, File *file, ht_format_group *group) { ht_flt_shared_data *flt_shared=(ht_flt_shared_data *)group->get_shared_data(); ht_uformat_viewer *v=new ht_uformat_viewer(); v->init(b, DESC_FLT_HEADER, VC_EDIT, file, group); ht_mask_sub *m = new ht_mask_sub(); m->init(file, 0); char info[128]; ht_snprintf(info, sizeof info, "* FLAT header at offset %08qx", flt_shared->header_ofs); m->add_mask(info); m->add_staticmask_ptable(fltheader, flt_shared->header_ofs, true); v->insertsub(m); return v; } format_viewer_if htfltheader_if = { htfltheader_init, 0 }; ht-2.0.22/stream.h0000644000175000001440000004203510615341624010577 00000000000000/* * HT Editor * stream.h * * Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __STREAM_H__ #define __STREAM_H__ #include #include #include "data.h" #include "str.h" #include "io/file.h" class String; /** * A stream. */ class Stream { private: IOAccessMode mAccessMode; protected: void checkAccess(IOAccessMode mask); public: Stream(); virtual ~Stream() {}; /* new */ virtual FileOfs copyAllTo(Stream *stream); virtual FileOfs copyTo(Stream *stream, FileOfs count); virtual IOAccessMode getAccessMode() const; virtual String & getDesc(String &result) const; virtual uint read(void *buf, uint size); void readx(void *buf, uint size); virtual int setAccessMode(IOAccessMode mode); void setAccessModex(IOAccessMode mode); virtual uint write(const void *buf, uint size); void writex(const void *buf, uint size); char * readstrz(); bool readStringz(String &s); void writestrz(const char *str); char * readstrp(); void writestrp(const char *str); char * readstrw(); void writestrw( const char *str); char * readstrl(); void writestrl(const char *str); void * readmeml(uint32 &len); void writememl(void *mem, uint32 len); }; /** * A stream, layering a stream. */ class StreamLayer: public Stream { protected: Stream *mStream; bool mOwnStream; public: StreamLayer(Stream *stream, bool own_stream); virtual ~StreamLayer(); /* extends Stream */ virtual IOAccessMode getAccessMode() const; virtual String & getDesc(String &result) const; virtual uint read(void *buf, uint size); virtual int setAccessMode(IOAccessMode mode); virtual uint write(const void *buf, uint size); /* new */ Stream * getLayered() const; virtual void setLayered(Stream *newLayered, bool ownNewLayered); }; #define OS_FMT_DEC 0 #define OS_FMT_HEX 1 class GetObject; /** * A stream-layer, storing/loading |Object|s. */ class ObjectStream: public StreamLayer { public: ObjectStream(Stream *stream, bool own_stream); /* new */ virtual void getBinary(void *buf, uint size, const char *desc) = 0; virtual bool getBool(const char *desc) = 0; virtual uint64 getInt(uint size, const char *desc) = 0; virtual Object * getObjectInternal(const char *name, ObjectID id = OBJID_INVALID) = 0; GetObject getObject(const char *name, ObjectID id = OBJID_INVALID); virtual char * getString(const char *desc) = 0; virtual byte * getLenString(int &length, const char *desc) = 0; virtual void putBinary(const void *mem, uint size, const char *desc) = 0; virtual void putBool(bool b, const char *desc) = 0; virtual void putComment(const char *comment) = 0; virtual void putCommentf(const char *comment_format, ...); virtual void putInt(uint64 i, uint size, const char *desc, uint int_fmt_hint = OS_FMT_DEC) = 0; virtual void putObject(const Object *object, const char *name, ObjectID id = OBJID_INVALID) = 0; virtual void putSeparator() = 0; virtual void putString(const char *string, const char *desc) = 0; virtual void putLenString(const byte *string, int length, const char *desc) = 0; virtual void corrupt() = 0; }; class GetObject { private: friend GetObject ObjectStream::getObject(const char *name, ObjectID id); ObjectStream &mO; const char *mName; ObjectID mId; GetObject(ObjectStream &o, const char *name, ObjectID id = OBJID_INVALID) : mO(o), mName(name), mId(id) { } GetObject operator=(const GetObject &); // not implemented public: template operator T* () const { return static_cast(mO.getObjectInternal(mName, mId)); } }; inline GetObject ObjectStream::getObject(const char *name, ObjectID id) { return GetObject(*this, name, id); } #define PUTX_BINARY(st, d, size, dstr) (st).putBinary(d, size, dstr) #define PUTX_BOOL(st, d, dstr) (st).putBool(d, dstr) #define PUTX_INT(st, d, size, dstr) (st).putInt(d, size, dstr) #define PUTX_INTD(st, d, size, dstr) (st).putInt(d, size, dstr, OS_FMT_DEC) #define PUTX_INTX(st, d, size, dstr) (st).putInt(d, size, dstr, OS_FMT_HEX) #define PUTX_INT8(st, d, dstr) (st).putInt(d, 1, dstr) #define PUTX_INT8D(st, d, dstr) (st).putInt(d, 1, dstr, OS_FMT_DEC) #define PUTX_INT8X(st, d, dstr) (st).putInt(d, 1, dstr, OS_FMT_HEX) #define PUTX_INT16(st, d, dstr) (st).putInt(d, 2, dstr) #define PUTX_INT16D(st, d, dstr) (st).putInt(d, 2, dstr, OS_FMT_DEC) #define PUTX_INT16X(st, d, dstr) (st).putInt(d, 2, dstr, OS_FMT_HEX) #define PUTX_INT32(st, d, dstr) (st).putInt(d, 4, dstr) #define PUTX_INT32D(st, d, dstr) (st).putInt(d, 4, dstr, OS_FMT_DEC) #define PUTX_INT32X(st, d, dstr) (st).putInt(d, 4, dstr, OS_FMT_HEX) #define PUTX_INT64(st, d, dstr) (st).putInt(d, 8, dstr) #define PUTX_INT64D(st, d, dstr) (st).putInt(d, 8, dstr, OS_FMT_DEC) #define PUTX_INT64X(st, d, dstr) (st).putInt(d, 8, dstr, OS_FMT_HEX) #define PUTX_OBJECT(st, d, dstr) (st).putObject(d, dstr) #define PUTX_STRING(st, d, dstr) (st).putString(d, dstr) #define PUTX_LSTRING(st, d, len, dstr) (st).putLenString(d, len, dstr) #define PUT_BINARY(st, d, size) PUTX_BINARY(st, d, size, #d) #define PUT_BOOL(st, d) PUTX_BOOL(st, d, #d) #define PUT_INT(st, d, size) PUTX_INT(st, d, size, #d) #define PUT_INTD(st, d, size) PUTX_INTD(st, d, size, #d) #define PUT_INTX(st, d, size) PUTX_INTX(st, d, size, #d) #define PUT_INT8(st, d) PUTX_INT8(st, d, #d) #define PUT_INT8D(st, d) PUTX_INT8D(st, d, #d) #define PUT_INT8X(st, d) PUTX_INT8X(st, d, #d) #define PUT_INT16(st, d) PUTX_INT16(st, d, #d) #define PUT_INT16D(st, d) PUTX_INT16D(st, d, #d) #define PUT_INT16X(st, d) PUTX_INT16X(st, d, #d) #define PUT_INT32(st, d) PUTX_INT32(st, d, #d) #define PUT_INT32D(st, d) PUTX_INT32D(st, d, #d) #define PUT_INT32X(st, d) PUTX_INT32X(st, d, #d) #define PUT_INT64(st, d) PUTX_INT64(st, d, #d) #define PUT_INT64D(st, d) PUTX_INT64D(st, d, #d) #define PUT_INT64X(st, d) PUTX_INT64X(st, d, #d) #define PUT_OBJECT(st, d) PUTX_OBJECT(st, d, #d) #define PUT_STRING(st, d) PUTX_STRING(st, d, #d) #define PUT_LSTRING(st, d, len) PUTX_LSTRING(st, d, len, #d) #define GETX_BINARY(st, d, size, dstr) (st).getBinary(d, size, dstr) #define GETX_BOOL(st, dstr) (st).getBool(dstr) #define GETX_INT(st, size, dstr) (st).getInt(size, dstr) #define GETX_INTD(st, size, dstr) GETX_INT(st, size, dstr) #define GETX_INTX(st, size, dstr) GETX_INT(st, size, dstr) #define GETX_INT8(st, dstr) (st).getInt(1, dstr) #define GETX_INT8D(st, dstr) GETX_INT8(st, dstr) #define GETX_INT8X(st, dstr) GETX_INT8(st, dstr) #define GETX_INT16(st, dstr) (st).getInt(2, dstr) #define GETX_INT16D(st, dstr) GETX_INT16(st, dstr) #define GETX_INT16X(st, dstr) GETX_INT16(st, dstr) #define GETX_INT32(st, dstr) (st).getInt(4, dstr) #define GETX_INT32D(st, dstr) GETX_INT32(st, dstr) #define GETX_INT32X(st, dstr) GETX_INT32(st, dstr) #define GETX_INT64(st, dstr) (st).getInt(8, dstr) #define GETX_INT64D(st, dstr) GETX_INT64(st, dstr) #define GETX_INT64X(st, dstr) GETX_INT64(st, dstr) #define GETX_STRING(st, dstr) (st).getString(dstr) #define GETX_LSTRING(st, size, dstr) (st).getLenString(size, dstr) #define GETX_OBJECT(st, dstr) (st).getObject(dstr) #define GET_BINARY(st, d, size) GETX_BINARY(st, d, size, #d) #define GET_BOOL(st, d) d=GETX_BOOL(st, #d) #define GET_INT(st, d, size) d=GETX_INT(st, size, #d) #define GET_INTD(st, d, size) d=GET_INT(st, d, size) #define GET_INTX(st, d, size) d=GET_INT(st, d, size) #define GET_INT8(st, d) d=GETX_INT8(st, #d) #define GET_INT8D(st, d) d=GETX_INT8D(st, #d) #define GET_INT8X(st, d) d=GETX_INT8X(st, #d) #define GET_INT16(st, d) d=GETX_INT16(st, #d) #define GET_INT16D(st, d) d=GETX_INT16D(st, #d) #define GET_INT16X(st, d) d=GETX_INT16X(st, #d) #define GET_INT32(st, d) d=GETX_INT32(st, #d) #define GET_INT32D(st, d) d=GETX_INT32D(st, #d) #define GET_INT32X(st, d) d=GETX_INT32X(st, #d) #define GET_INT64(st, d) d=GETX_INT64(st, #d) #define GET_INT64D(st, d) d=GETX_INT64D(st, #d) #define GET_INT64X(st, d) d=GETX_INT64X(st, #d) #define GET_STRING(st, d) d=GETX_STRING(st, #d) #define GET_LSTRING(st, d, size) d=GETX_LSTRING(st, size, #d) #define GET_OBJECT(st, d) d=GETX_OBJECT(st, #d) /** * A object-stream-layer. */ class ObjectStreamLayer: public ObjectStream { protected: ObjectStream *mObjStream; public: ObjectStreamLayer(ObjectStream *aObjStream, bool own_ostream); /* extends ObjectStream */ virtual void getBinary(void *buf, uint size, const char *desc); virtual bool getBool(const char *desc); virtual uint64 getInt(uint size, const char *desc); virtual Object * getObjectInternal(const char *name, ObjectID id = OBJID_INVALID); virtual char * getString(const char *desc); virtual byte * getLenString(int &length, const char *desc); virtual void putBinary(const void *mem, uint size, const char *desc); virtual void putBool(bool b, const char *desc); virtual void putComment(const char *comment); virtual void putInt(uint64 i, uint size, const char *desc, uint int_fmt_hint = OS_FMT_DEC); virtual void putObject(const Object *object, const char *name, ObjectID id = OBJID_INVALID); virtual void putSeparator(); virtual void putString(const char *string, const char *desc); virtual void putLenString(const byte *string, int length, const char *desc); }; /* cntl cmd */ #define FCNTL_MODS_INVD 0x00000001 #define FCNTL_MODS_FLUSH 0x00000002 #define FCNTL_MODS_CLEAR_DIRTY_RANGE 0x00000003 // const FileOfs offset, const FileOfs range #define FCNTL_MODS_IS_DIRTY 0x00000004 // const FileOfs offset, const FileOfs range, bool &isdirty #define FCNTL_CACHE_INVD 0x00000005 #define FCNTL_FLUSH_STAT 0x00000006 #define FCNTL_GET_RELOC 0x00000007 // bool &enabled #define FCNTL_SET_RELOC 0x00000008 // bool enable #define FCNTL_GET_FD 0x00000009 // int &fd // Return a "modification count" that changes, every time the file state // ( content, size, pstat ) changes. // While identical mod-counts imply identical file states, // different mod-counts do not necessarily imply different file states ! #define FCNTL_GET_MOD_COUNT 0x00000009 // int &mcount #define IS_DIRTY_SINGLEBIT 0x80000000 /** * A file. */ class File: public Stream { protected: int mcount; public: File(); /* new */ int cntl(uint cmd, ...); virtual void cut(FileOfs size); virtual void extend(FileOfs newsize); virtual String & getFilename(String &result) const; virtual FileOfs getSize() const; virtual void insert(const void *buf, FileOfs size); virtual void pstat(pstat_t &s) const; virtual void seek(FileOfs offset); virtual FileOfs tell() const; virtual void truncate(FileOfs newsize); virtual int vcntl(uint cmd, va_list vargs); void move(FileOfs src, FileOfs dest, FileOfs size); char * fgetstrz(); }; /** * A file, layering a file. */ class FileLayer: public File { protected: File *mFile; bool mOwnFile; public: FileLayer(File *file, bool own_file); virtual ~FileLayer(); /* extends File */ virtual void cut(FileOfs size); virtual void extend(FileOfs newsize); virtual IOAccessMode getAccessMode() const; virtual String & getDesc(String &result) const; virtual String & getFilename(String &result) const; virtual FileOfs getSize() const; virtual void insert(const void *buf, FileOfs size); virtual void pstat(pstat_t &s) const; virtual uint read(void *buf, uint size); virtual void seek(FileOfs offset); virtual int setAccessMode(IOAccessMode mode); virtual FileOfs tell() const; virtual void truncate(FileOfs newsize); virtual int vcntl(uint cmd, va_list vargs); virtual uint write(const void *buf, uint size); /* new */ File * getLayered() const; virtual void setLayered(File *newLayered, bool ownNewLayered); }; /** * A local file (file descriptor [fd]). */ class LocalFileFD: public File { protected: String mFilename; FileOpenMode mOpenMode; int fd; bool own_fd; FileOfs offset; int setAccessModeInternal(IOAccessMode mode); public: LocalFileFD(const String &aFilename, IOAccessMode mode, FileOpenMode aOpenMode); LocalFileFD(int fd, bool own_fd, IOAccessMode mode); virtual ~LocalFileFD(); /* extends File */ virtual String & getDesc(String &result) const; virtual String & getFilename(String &result) const; virtual FileOfs getSize() const; virtual uint read(void *buf, uint size); virtual void seek(FileOfs offset); virtual int setAccessMode(IOAccessMode mode); virtual FileOfs tell() const; virtual void truncate(FileOfs newsize); virtual int vcntl(uint cmd, va_list vargs); virtual uint write(const void *buf, uint size); }; /** * A local file (file stream [FILE*]). */ class LocalFile: public File { protected: String mFilename; FileOpenMode mOpenMode; SYS_FILE * file; bool own_file; FileOfs offset; int setAccessModeInternal(IOAccessMode mode); public: LocalFile(const String &aFilename, IOAccessMode mode, FileOpenMode aOpenMode); LocalFile(SYS_FILE *file, bool own_file, IOAccessMode mode); virtual ~LocalFile(); /* extends File */ virtual String & getDesc(String &result) const; virtual String & getFilename(String &result) const; virtual FileOfs getSize() const; virtual void pstat(pstat_t &s) const; virtual uint read(void *buf, uint size); virtual void seek(FileOfs offset); virtual int setAccessMode(IOAccessMode mode); virtual FileOfs tell() const; virtual void truncate(FileOfs newsize); virtual int vcntl(uint cmd, va_list vargs); virtual uint write(const void *buf, uint size); }; /** * A temporary file. */ class TempFile: public LocalFile { public: TempFile(IOAccessMode mode); /* extends File */ virtual String & getDesc(String &result) const; virtual void pstat(pstat_t &s) const; }; /** * A fixed-size, read-only file, mapping a area of memory. */ class ConstMemMapFile: public File { protected: FileOfs ofs, pos; uint size; const void *buf; public: ConstMemMapFile(const void *buf, uint size, FileOfs ofs=0); /* extends File */ virtual String & getDesc(String &result) const; virtual FileOfs getSize() const; virtual uint read(void *buf, uint size); virtual void seek(FileOfs offset); virtual FileOfs tell() const; }; /** * A fixed-size file, mapping a area of memory. */ class MemMapFile: public ConstMemMapFile { public: MemMapFile(void *buf, uint size, FileOfs ofs=0); /* extends Stream */ virtual uint write(const void *buf, uint size); }; /** * A (read-only) file with zero-content. */ class NullFile: public File { public: NullFile(); /* extends File */ virtual void extend(FileOfs newsize); virtual String & getDesc(String &result) const; virtual FileOfs getSize() const; virtual void pstat(pstat_t &s) const; virtual uint read(void *buf, uint size); virtual void seek(FileOfs offset); virtual int setAccessMode(IOAccessMode mode); virtual FileOfs tell() const; virtual void truncate(FileOfs newsize); virtual uint write(const void *buf, uint size); }; /** * A file, existing only in memory. */ class MemoryFile: public File { protected: FileOfs ofs; FileOfs pos; uint bufsize, dsize, ibufsize; byte *buf; virtual uint extendBufSize(uint bufsize); virtual uint shrinkBufSize(uint bufsize); void extendBuf(); void shrinkBuf(); void resizeBuf(uint newsize); public: MemoryFile(FileOfs ofs = 0, uint size = 0, IOAccessMode mode = IOAM_READ | IOAM_WRITE); virtual ~MemoryFile(); /* extends File */ virtual void extend(FileOfs newsize); virtual IOAccessMode getAccessMode() const; virtual String & getDesc(String &result) const; virtual FileOfs getSize() const; virtual void pstat(pstat_t &s) const; virtual uint read(void *buf, uint size); virtual void seek(FileOfs offset); virtual int setAccessMode(IOAccessMode mode); virtual FileOfs tell() const; virtual void truncate(FileOfs newsize); virtual uint write(const void *buf, uint size); /* new */ byte * getBufPtr() const; }; /** * A file layer, representing a cropped version of a file */ class CroppedFile: public FileLayer { protected: FileOfs mCropStart; bool mHasCropSize; FileOfs mCropSize; public: // crop [start; start+size-1] CroppedFile(File *file, bool own_file, FileOfs aCropStart, FileOfs aCropSize); // no size, just start CroppedFile(File *file, bool own_file, FileOfs aCropStart); /* extends FileLayer */ virtual void extend(FileOfs newsize); virtual String & getDesc(String &result) const; virtual FileOfs getSize() const; virtual void pstat(pstat_t &s) const; virtual uint read(void *buf, uint size); virtual void seek(FileOfs offset); virtual FileOfs tell() const; virtual void truncate(FileOfs newsize); virtual uint write(const void *buf, uint size); }; #endif /* __STREAM_H__ */ ht-2.0.22/vfs.cc0000644000175000017500000002230012127651420010233 00000000000000/* * HT Editor * vfs.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include "htctrl.h" #include "htiobox.h" #include "keyb.h" #include "htreg.h" #include "sys.h" #include "httag.h" #include "strtools.h" #include "snprintf.h" #include "store.h" #include "tools.h" #include "vfs.h" static bool unix_is_path_delim(char c) { return c == '/'; } /* * class LocalFs */ void LocalFs::init() { Vfs::init(); } void LocalFs::done() { Vfs::done(); } int LocalFs::canonicalize(String &result, const char *filename, const char *cwd) { char res[HT_NAME_MAX]; sys_common_canonicalize(res, sizeof res, filename, cwd, sys_is_path_delim); result.assign(res); return 0; } int LocalFs::compareFilenames(const char *a, const char *b) { /* FIXME: backslash & slash */ if (strcmp(a, "..")==0) return -1; if (strcmp(b, "..")==0) return 1; return ht_stricmp(a, b); } int LocalFs::createFile(const char *filename, uint createtype) { // FIXME return ENOSYS; } int LocalFs::deleteFile(const char *filename) { /* filename must be absolute */ if ((filename[0] != '/') && (filename[0] != '\\') && ((filename[1]!=':') && (filename[2]!='/') && (filename[2]!='\\'))) return ENOENT; return remove(filename); } void *LocalFs::enumFiletype(uint *type, char **name, void *handle) { *type = 0; *name = (char*)"file"; return NULL; } bool LocalFs::findFirst(const char *dirname, pfind_t *f) { return (sys_findfirst(*f, dirname) == 0); } bool LocalFs::findNext(pfind_t *f) { return (sys_findnext(*f) == 0); } bool LocalFs::findClose(pfind_t *f) { return (sys_findclose(*f) == 0); } int LocalFs::getCaps() { return VFSCAP_WRITABLE; } const char *LocalFs::getProtoName() { return "local"; } is_path_delim LocalFs::isPathDelim() { return sys_is_path_delim; } int LocalFs::makeDir(const char *dirname) { return ENOSYS; // return mkdir(dirname, S_IWUSR); } int LocalFs::open(const char *filename, bool edit) { return ENOSYS; } int LocalFs::pstat(pstat_t *s, const char *filename) { return sys_pstat(*s, filename); } int LocalFs::renameFile(const char *filename, const char *newname) { return rename(filename, newname); } int LocalFs::fileClose(File *f) { delete f; return 0; } int LocalFs::fileOpen(const char *filename, IOAccessMode access_mode, FileOpenMode open_mode, File **f) { try { LocalFile *file=new LocalFile(filename, access_mode, open_mode); *f=file; return 0; } catch (const IOException &e) { return EIO; } } /* * class RegNodeFile */ #define REGNODE_FILE_MAGIC "HTRG" RegNodeFile::RegNodeFile(const char *nn, uint am, uint om) : MemoryFile(0, 1024, am) { access_mode0 = am; open_mode = om; nodename = ht_strdup(nn); if ((am & IOAM_READ) && (am & IOAM_WRITE)) { throw IOException(EINVAL); } ht_registry_node *node; if (!(om & FOM_CREATE)) { if (!registry->find_data_entry(nodename, &node, false)) { throw IOException(ENOENT); } } if (am & IOAM_READ) { if (om & FOM_CREATE) { throw IOException(EINVAL); } ObjectStreamBin o(this, false); store_node(o, node); seek(0); } } RegNodeFile::~RegNodeFile() { if (getAccessMode() & IOAM_WRITE) { ht_registry_node *node; seek(0); ObjectStreamBin o(this, false); int e = load_node(o, &node); if (e==0) { if (open_mode & FOM_CREATE) { if ((e = registry->create_node(nodename, node->type))) { // set_error(e); } } registry->set_node(nodename, node->type, node->data); htmsg m; m.msg = msg_config_changed; m.type = mt_broadcast; app->sendmsg(&m); } } free(nodename); } int RegNodeFile::load_node(ObjectStream &s, ht_registry_node **node) { byte magic[4]; ht_registry_node_type type; ht_registry_data *data; int n = s.read(magic, sizeof magic); if (n != sizeof magic || memcmp(magic, REGNODE_FILE_MAGIC, 4)==0) { type = s.getInt(4, NULL); data = s.getObject(NULL); } else { MemoryFile g; g.write(magic, n); s.copyAllTo(&g); ht_registry_data_raw *d = new ht_registry_data_raw(g.getBufPtr(), g.getSize()); type = RNT_RAW; data = d; } *node = new ht_registry_node(type, NULL, data); return 0; } void RegNodeFile::store_node(ObjectStream &s, ht_registry_node *node) { if (node->type == RNT_RAW) { ht_registry_data_raw *d = (ht_registry_data_raw*)node->data; s.write(d->value, d->size); } else { s.write((void*)REGNODE_FILE_MAGIC, 4); s.putInt(node->type, 4, NULL); s.putObject(node->data, NULL); } } /* * class RegistryFs */ void RegistryFs::init() { Vfs::init(); enum_last = NULL; enum_dir = NULL; } void RegistryFs::done() { Vfs::done(); } int RegistryFs::canonicalize(String &result, const char *filename, const char *cwd) { char res[HT_NAME_MAX]; sys_common_canonicalize(res, sizeof res, filename, cwd, unix_is_path_delim); result.assign(res); ht_registry_node *node; return registry->find_data_entry(result.contentChar(), &node, 0); } void RegistryFs::create_pfind_t(pfind_t *f, const ht_registry_node *node) { f->name = node->name; f->stat.caps = pstat_mode_type | pstat_desc; create_pstat_t(&f->stat, node->data, node->type); node->data->strvalue(f->stat.desc); /* FIXME: possible buffer overflow !!! only 32 bytes... */ } void RegistryFs::create_pstat_t(pstat_t *s, ht_registry_data *data, ht_registry_node_type type) { s->caps = pstat_mode_type | pstat_desc; s->mode = 0; switch (type) { case RNT_SUBDIR: s->mode |= HT_S_IFDIR; break; case RNT_SYMLINK: s->mode |= HT_S_IFLNK; break; case RNT_RAW: s->caps |= pstat_size; s->size = ((ht_registry_data_raw *)data)->size; default: s->mode |= HT_S_IFREG; } } int RegistryFs::createFile(const char *filename, uint createtype) { int e = registry->create_node(filename, createtype); htmsg m; m.msg = msg_config_changed; m.type = mt_broadcast; app->sendmsg(&m); return e; } int RegistryFs::deleteFile(const char *filename) { int e = registry->delete_node(filename); htmsg m; m.msg = msg_config_changed; m.type = mt_broadcast; app->sendmsg(&m); return e; } void *RegistryFs::enumFiletype(uint *type, char **name, void *handle) { ObjHandle oh = registry->node_types->find((Object*)handle); ht_registry_node_type_desc *n; while ((n = (ht_registry_node_type_desc *)registry->node_types->get(oh)) && n->type == RNT_SUBDIR) { oh = registry->node_types->findNext(oh); } if (n) { *type = n->type; *name = n->name; return n; } return NULL; } int RegistryFs::compareFilenames(const char *a, const char *b) { if (strcmp(a, "..") == 0) return -1; if (strcmp(b, "..") == 0) return 1; return strcmp(a, b); } bool RegistryFs::findFirst(const char *dirname, pfind_t *f) { ht_registry_node *node; free(enum_dir); enum_last = NULL; enum_dir = NULL; if (strcmp(dirname, "/")==0 || strcmp(dirname, "")==0) { if ((node = registry->enum_next(dirname, NULL))) { enum_last = node; enum_dir = ht_strdup(dirname); create_pfind_t(f, node); return true; } } else { enum_dir = ht_strdup(dirname); f->name = ".."; f->stat.caps = pstat_mode_type; f->stat.mode = HT_S_IFDIR; return true; } return false; } bool RegistryFs::findNext(pfind_t *f) { ht_registry_node *node; if ((node = registry->enum_next(enum_dir, enum_last))) { enum_last = node; create_pfind_t(f, node); return true; } return false; } bool RegistryFs::findClose(pfind_t *f) { return true; } int RegistryFs::getCaps() { return VFSCAP_WRITABLE; } const char *RegistryFs::getProtoName() { return "reg"; } is_path_delim RegistryFs::isPathDelim() { return unix_is_path_delim; } int RegistryFs::makeDir(const char *dirname) { return registry->create_subdir(dirname); } int RegistryFs::open(const char *filename, bool edit) { ht_registry_node *node; if (registry->find_data_entry(filename, &node, false)) { if (node->data->editdialog(filename)) { htmsg m; m.msg = msg_config_changed; m.type = mt_broadcast; app->sendmsg(&m); } return 0; } return ENOSYS; } int RegistryFs::pstat(pstat_t *s, const char *filename) { ht_registry_node *node; char key[VFS_DIR_MAX]; ht_snprintf(key, sizeof key, "%s", filename); int l = strlen(key)-1; if (l >= 0 && key[l] == '/') key[l] = 0; if (registry->find_any_entry(key, &node)) { create_pstat_t(s, node->data, node->type); return 0; } return EINVAL; } int RegistryFs::renameFile(const char *filename, const char *newname) { return EXDEV; } int RegistryFs::fileClose(File *f) { delete f; return 0; } int RegistryFs::fileOpen(const char *filename, IOAccessMode access_mode, FileOpenMode open_mode, File **f) { try { *f = new RegNodeFile(filename, access_mode, open_mode); return 0; } catch (const IOException &e) { return e.mPosixErrno; } } ht-2.0.22/htelfhd.h0000644000175000001440000000155110206756707010730 00000000000000/* * HT Editor * htelfhd.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTELFHD_H__ #define __HTELFHD_H__ #include "htobj.h" #include "formats.h" extern format_viewer_if htelfheader_if; #endif /* !__HTELFHD_H__ */ ht-2.0.22/htprocess.h0000644000175000001440000000170310615345251011313 00000000000000/* * HT Editor * htprocess.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __PROCESS_H__ #define __PROCESS_H__ #include "data.h" #include "htobj.h" typedef bool (*process_func)(Object *context, ht_text *progress_indicator); bool execute_process(process_func pp, Object *context); #endif /* __PROCESS_H__ */ ht-2.0.22/htformat.cc0000644000175000017500000033507412127651417011306 00000000000000/* * HT Editor * htformat.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "htformat.h" #include "htsearch.h" #include #include #include #include #include "blockop.h" #include "cmds.h" #include "htapp.h" // for popup_view_list(..) #include "atom.h" #include "htclipboard.h" #include "htctrl.h" #include "endianess.h" #include "hteval.h" #include "hthist.h" #include "htiobox.h" #include "keyb.h" #include "htpal.h" #include "httag.h" #include "textedit.h" #include "textfile.h" #include "htprocess.h" #include "snprintf.h" #include "tools.h" extern "C" { #include "evalx.h" #include "regex.h" } /*cmd_rec ht_format_viewer_cmds[] = { {cmd_file_truncate, true, true, NULL} };*/ void clear_line_id(LINE_ID *l) { l->id1 = 0; l->id2 = 0; l->id3 = 0; l->id4 = 0; l->id5 = 0; } bool compeq_line_id(const LINE_ID &a, const LINE_ID &b) { return (a.id1 == b.id1 && a.id2 == b.id2 && a.id3 == b.id3 && a.id4 == b.id4 && a.id5 == b.id5); } /* * CLASS ht_data_tagstring */ class ht_data_tagstring: public Object { public: char *value; ht_data_tagstring(const char *tagstr = NULL) : value(tag_strdup(tagstr)) { } ~ht_data_tagstring() { free(value); } }; /* * CLASS ht_search_request */ ht_search_request::ht_search_request(uint _search_class, uint _type, uint _flags) { search_class = _search_class; type = _type; flags = _flags; } /* * CLASS ht_format_group */ void ht_format_group::init(Bounds *b, int options, const char *desc, File *f, bool own_f, bool editable_f, format_viewer_if **i, ht_format_group *format_group) { ht_format_viewer::init(b, desc, 0, f, format_group); VIEW_DEBUG_NAME("ht_format_group"); xgroup = new ht_xgroup(); xgroup->init(b, options, desc); xgroup->group = group; format_views = new Array(true); // a list of ht_format_viewer_entrys own_file = own_f; editable_file = editable_f; if (i) init_ifs(i); } void ht_format_group::done() { done_ifs(); delete format_views; xgroup->done(); delete xgroup; ht_format_viewer::done(); if (own_file) delete file; } int ht_format_group::childcount() const { return xgroup->childcount(); } bool ht_format_group::done_if(format_viewer_if *i, ht_view *v) { remove(v); if (i->done) { i->done(v); } else { v->done(); delete v; } return true; } void ht_format_group::done_ifs() { int j = 0; while (1) { ht_format_viewer_entry *e=(ht_format_viewer_entry*)(*format_views)[j]; if (!(e && e->instance)) break; done_if(e->interface, e->instance); j++; } } bool ht_format_group::edit() { return (file->getAccessMode() & IOAM_WRITE); } bool ht_format_group::focus(ht_view *view) { bool r = ht_format_viewer::focus(view); if (!r) r = xgroup->focus(view); return r; } const char *ht_format_group::func(uint i, bool execute) { return ht_format_viewer::func(i, execute); } void ht_format_group::getbounds(Bounds *b) { xgroup->getbounds(b); } void *ht_format_group::get_shared_data() { return shared_data; } ht_view *ht_format_group::getfirstchild() { return xgroup->getfirstchild(); } ht_view *ht_format_group::getselected() { return xgroup->getselected(); } int ht_format_group::get_pindicator_str(char *buf, int max_len) { ht_view *c = xgroup->current; if (c && (c->options & VO_FORMAT_VIEW)) { return ((ht_format_viewer*)c)->get_pindicator_str(buf, max_len); } else { if (max_len > 0) *buf = 0; return 0; } } bool ht_format_group::get_hscrollbar_pos(int *pstart, int *psize) { ht_view *c = xgroup->current; if (c && (c->options & VO_FORMAT_VIEW)) { return ((ht_format_viewer*)c)->get_hscrollbar_pos(pstart, psize); } return false; } bool ht_format_group::get_vscrollbar_pos(int *pstart, int *psize) { ht_view *c = xgroup->current; if (c && (c->options & VO_FORMAT_VIEW)) { return ((ht_format_viewer*)c)->get_vscrollbar_pos(pstart, psize); } return false; } void ht_format_group::handlemsg(htmsg *msg) { switch (msg->msg) { case msg_keypressed: { int i = 0; switch (msg->data1.integer) { case K_F12: i++; case K_F11: i++; case K_F10: i++; case K_F9: i++; case K_F8: i++; case K_F7: i++; case K_F6: i++; case K_F5: i++; case K_F4: i++; case K_F3: i++; case K_F2: i++; case K_F1: { i++; htmsg m; m.msg = msg_funcquery; m.type = mt_empty; m.data1.integer = i; sendmsg(&m); if (m.msg == msg_retval) { sendmsg(msg_funcexec, i); clearmsg(msg); return; } break; } } break; } } ht_format_viewer::handlemsg(msg); xgroup->handlemsg(msg); switch (msg->msg) { case msg_funcexec: if (func(msg->data1.integer, 1)) { clearmsg(msg); return; } break; case msg_funcquery: { const char *s=func(msg->data1.integer, 0); if (s) { msg->msg=msg_retval; msg->data1.cstr=s; } break; } } } bool ht_format_group::init_if(format_viewer_if *i) { Bounds b; getbounds(&b); b.x=0; b.y=0; bool r=0; ht_view *v=0; if (i->init) { try { v=i->init(&b, file, this); if (v) { v->sendmsg(msg_complete_init, 0); insert(v); r=1; } } catch (const Exception &x) { errorbox("unhandled exception: %y", &x); } catch (const std::exception &x) { errorbox("unhandled exception: %s", x.what()); } catch (...) { errorbox("unhandled exception: unknown"); } } ht_format_viewer_entry *e = new ht_format_viewer_entry(); e->interface = i; e->instance = v; format_views->insert(e); return r; } void ht_format_group::init_ifs(format_viewer_if **ifs) { format_viewer_if **i=ifs; while (*i) { init_if(*i); i++; } ifs=i; } void ht_format_group::insert(ht_view *view) { xgroup->insert(view); } void ht_format_group::move(int rx, int ry) { ht_format_viewer::move(rx, ry); xgroup->move(rx, ry); } void ht_format_group::receivefocus() { xgroup->receivefocus(); } void ht_format_group::redraw() { xgroup->redraw(); } void ht_format_group::releasefocus() { xgroup->releasefocus(); } void ht_format_group::remove(ht_view *view) { xgroup->remove(view); } void ht_format_group::resize(int rw, int rh) { ht_format_viewer::resize(rw, rh); xgroup->resize(rw, rh); } void ht_format_group::setgroup(ht_group *_group) { xgroup->setgroup(_group); } bool ht_format_group::func_handler(eval_scalar *result, char *name, eval_scalarlist *params) { ht_format_viewer *v = dynamic_cast(xgroup->current); if (v) { return v->func_handler(result, name, params); } else { return false; } } bool ht_format_group::symbol_handler(eval_scalar *result, char *name) { ht_format_viewer *v = dynamic_cast(xgroup->current); if (v) { return v->symbol_handler(result, name); } else { return false; } } /* * CLASS ht_viewer */ void ht_viewer::init(Bounds *b, const char *desc, uint c) { ht_view::init(b, VO_OWNBUFFER | VO_BROWSABLE | VO_SELECTABLE | VO_MOVE | VO_RESIZE, desc); caps = c; growmode = MK_GM(GMH_FIT, GMV_FIT); } const char *ht_viewer::func(uint i, bool execute) { return NULL; } void ht_viewer::handlemsg(htmsg *msg) { int i=0; switch (msg->msg) { case msg_keypressed: { switch (msg->data1.integer) { case K_F12: i++; case K_F11: i++; case K_F10: i++; case K_F9: i++; case K_F8: i++; case K_F7: i++; case K_F6: i++; case K_F5: i++; case K_F4: i++; case K_F3: i++; case K_F2: i++; case K_F1: { i++; htmsg m; m.msg = msg_funcquery; m.type = mt_empty; m.data1.integer = i; sendmsg(&m); if (m.msg == msg_retval) { sendmsg(msg_funcexec, i); clearmsg(msg); return; } break; } } break; } case msg_funcexec: if (func(msg->data1.integer, 1)) { clearmsg(msg); return; } break; case msg_funcquery: { const char *s = func(msg->data1.integer, 0); if (s) { msg->msg = msg_retval; msg->data1.cstr = s; } break; } } ht_view::handlemsg(msg); } /* * CLASS ht_format_viewer */ void ht_format_viewer::init(Bounds *b, const char *desc, uint caps, File *f, ht_format_group *fg) { ht_viewer::init(b, desc, caps); options |= VO_FORMAT_VIEW; VIEW_DEBUG_NAME("ht_format_viewer"); file = f; format_group = fg; last_search_request = NULL; /* vs_history = new ht_stack(); vs_history->init();*/ } void ht_format_viewer::done() { delete last_search_request; ht_viewer::done(); } bool ht_format_viewer::pos_to_offset(viewer_pos pos, FileOfs *ofs) { return false; } void ht_format_viewer::clear_viewer_pos(viewer_pos *p) { } bool ht_format_viewer::compeq_viewer_pos(viewer_pos *a, viewer_pos *b) { return false; } bool ht_format_viewer::continue_search() { if (last_search_request) { ht_search_result *r = NULL; if (last_search_physical) { FileOfs o, no; if (get_current_offset(&o)) { try { if (last_search_request->search_class==SC_PHYSICAL) { if (next_logical_offset(o, &no)) { r=psearch(last_search_request, no, last_search_end_ofs); } } } catch (const Exception &e) { errorbox("error: %y", &e); } } } else { viewer_pos a, na; if (get_current_pos(&a)) { try { if (last_search_request->search_class==SC_VISUAL) { if (next_logical_pos(a, &na)) { r=vsearch(last_search_request, na, last_search_end_pos); } } } catch (const Exception &e) { errorbox("error: %y", &e); } } } if (r) return show_search_result(r); } return false; } bool ht_format_viewer::func_handler(eval_scalar *result, char *name, eval_scalarlist *params) { return false; } bool ht_format_viewer::symbol_handler(eval_scalar *result, char *name) { return false; } bool ht_format_viewer::get_current_offset(FileOfs *ofs) { return false; } bool ht_format_viewer::get_current_pos(viewer_pos *pos) { return false; } bool ht_format_viewer::get_current_real_offset(FileOfs *ofs) { return get_current_offset(ofs); } File *ht_format_viewer::get_file() { return file; } int ht_format_viewer::get_pindicator_str(char *buf, int max_len) { if (max_len > 0) *buf = 0; return 0; } bool ht_format_viewer::get_hscrollbar_pos(int *pstart, int *psize) { return false; } bool ht_format_viewer::get_vscrollbar_pos(int *pstart, int *psize) { return false; } bool ht_format_viewer::goto_offset(FileOfs ofs, bool save_vstate) { return false; } bool ht_format_viewer::goto_pos(viewer_pos pos, bool save_vstate) { return false; } static bool format_viewer_func_handler(eval_scalar *result, char *name, eval_scalarlist *params) { ht_format_viewer *viewer = (ht_format_viewer*)eval_get_context(); return viewer->func_handler(result, name, params); } static bool format_viewer_symbol_handler(eval_scalar *result, char *name) { ht_format_viewer *viewer = (ht_format_viewer*)eval_get_context(); return viewer->symbol_handler(result, name); } void ht_format_viewer::handlemsg(htmsg *msg) { switch (msg->msg) { case cmd_popup_dialog_eval: eval_dialog(format_viewer_func_handler, format_viewer_symbol_handler, this); clearmsg(msg); return; case msg_goto_offset: { FileOfs o = (FileOfs)msg->data1.q; if (goto_offset(o, false)) { clearmsg(msg); return; } break; } case msg_vstate_restore: vstate_restore((Object*)msg->data1.ptr); clearmsg(msg); return; case cmd_file_truncate: { File *f = (File*)msg->data1.ptr; FileOfs o = (FileOfs)msg->data2.q; if (file == f) { ht_format_loc loc; loc_enum_start(); while (loc_enum_next(&loc)) { if (o < loc.start+loc.length) { if (confirmbox("truncating at %08qx will destroy format '%s', continue ? \n(format ranges from %08qx to %08qx)", o, loc.name, loc.start, loc.start+loc.length) != button_yes) { clearmsg(msg); return; } break; } } } break; } case cmd_edit_mode_i: { if (file/* && (file==msg->data1.ptr)*/) { try { file->setAccessModex(IOAM_READ | IOAM_WRITE); htmsg m; m.msg = cmd_edit_mode; m.type = mt_broadcast; sendmsg(&m); } catch (const IOException &e) { String fn; errorbox("can't open file %y in write mode! (%y)", &file->getFilename(fn), &e); } } clearmsg(msg); return; } case cmd_view_mode_i: if (file /*&& (file==msg->data1.ptr)*/) { FileOfs size = file->getSize(); file->cntl(FCNTL_MODS_INVD); try { file->setAccessModex(IOAM_READ); htmsg m; m.msg = cmd_view_mode; m.type = mt_broadcast; sendmsg(&m); } catch (const IOException &e) { String fn; errorbox("can't (re)open file %y in read mode! (%y)", &file->getFilename(fn), &e); } if (size != file->getSize()) { htmsg m; m.msg = msg_filesize_changed; m.type = mt_broadcast; sendmsg(&m); } } clearmsg(msg); return; } ht_viewer::handlemsg(msg); } void ht_format_viewer::loc_enum_start() { } bool ht_format_viewer::loc_enum_next(ht_format_loc *loc) { return false; } bool ht_format_viewer::next_logical_pos(viewer_pos pos, viewer_pos *npos) { return false; } bool ht_format_viewer::next_logical_offset(FileOfs ofs, FileOfs *nofs) { return false; } bool ht_format_viewer::offset_to_pos(FileOfs ofs, viewer_pos *pos) { return false; } bool ht_format_viewer::vstate_save() { Object *vs = vstate_create(); if (vs) { htmsg m; m.msg = msg_vstate_save; m.type = mt_empty; m.data1.ptr = vs; m.data2.ptr = this; app->sendmsg(&m); return true; } return false; } uint ht_format_viewer::pread(FileOfs ofs, void *buf, uint size) { try { file->seek(ofs); return file->read(buf, size); } catch (const IOException &e) { return 0; } } ht_search_result *ht_format_viewer::psearch(ht_search_request *search, FileOfs start, FileOfs end) { return 0; } void ht_format_viewer::pselect_add(FileOfs start, FileOfs end) { } void ht_format_viewer::pselect_get(FileOfs *start, FileOfs *end) { } void ht_format_viewer::pselect_set(FileOfs start, FileOfs end) { } uint ht_format_viewer::pwrite(FileOfs ofs, void *buf, uint size) { sendmsg(msg_file_changed); file->seek(ofs); return file->write(buf, size); } bool ht_format_viewer::qword_to_offset(uint64 q, FileOfs *ofs) { return false; } bool ht_format_viewer::qword_to_pos(uint64 q, viewer_pos *pos) { return false; } bool ht_format_viewer::show_search_result(ht_search_result *r) { switch (r->search_class) { case SC_PHYSICAL: { ht_physical_search_result *s = (ht_physical_search_result*)r; if (!goto_offset(s->offset, this)) return false; pselect_set(s->offset, s->offset + s->size); return true; } case SC_VISUAL: { ht_visual_search_result *s = (ht_visual_search_result*)r; return goto_pos(s->pos, this); } } return false; } bool ht_format_viewer::string_to_qword(const char *string, uint64 *q) { eval_scalar r; if (eval(&r, string, format_viewer_func_handler, format_viewer_symbol_handler, this)) { eval_int i; scalar_context_int(&r, &i); scalar_destroy(&r); *q = i.value; return true; } else { const char *s; int p; get_eval_error(&s, &p); ht_snprintf(globalerror, GLOBAL_ERROR_SIZE, "%s at pos %d", s, p); } return false; } bool ht_format_viewer::string_to_pos(const char *string, viewer_pos *pos) { uint64 q; if (!string_to_qword(string, &q)) return false; return qword_to_pos(q, pos); } bool ht_format_viewer::string_to_offset(char *string, FileOfs *ofs) { uint64 q; if (!string_to_qword(string, &q)) return false; return qword_to_offset(q, ofs); } Object *ht_format_viewer::vstate_create() { return NULL; } void ht_format_viewer::vstate_restore(Object *view_state) { } uint ht_format_viewer::vread(viewer_pos pos, void *buf, uint size) { FileOfs o; if (pos_to_offset(pos, &o)) { return pread(o, buf, size); } return 0; } ht_search_result *ht_format_viewer::vsearch(ht_search_request *search, viewer_pos start, viewer_pos end) { return NULL; } void ht_format_viewer::vselect_add(viewer_pos start, viewer_pos end) { FileOfs so, eo; if (pos_to_offset(start, &so) && pos_to_offset(end, &eo)) { return pselect_add(so, eo); } } void ht_format_viewer::vselect_get(viewer_pos *start, viewer_pos *end) { HT_ERROR("NYI!"); } void ht_format_viewer::vselect_set(viewer_pos start, viewer_pos end) { FileOfs so, eo; if (pos_to_offset(start, &so) && pos_to_offset(end, &eo)) { return pselect_set(so, eo); } } uint ht_format_viewer::vwrite(viewer_pos pos, void *buf, uint size) { FileOfs o; if (pos_to_offset(pos, &o)) { return pwrite(o, buf, size); } return 0; } /* * CLASS ht_uformat_view */ class ht_uformat_viewer_vstate: public Object { public: int edit; ht_sub *first_sub, *last_sub; /* top line position */ uformat_viewer_pos top; /* cursor line and tag position */ uformat_viewer_pos cursor; int cursor_state; int cursor_ypos; /* selection*/ FileOfs sel_start; FileOfs sel_end; }; void ht_uformat_viewer::init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group) { tagpal.data = NULL; tagpal.size = 0; ht_format_viewer::init(b, desc, caps, file, format_group); VIEW_DEBUG_NAME("ht_uformat_view"); first_sub = 0; last_sub = 0; clear_viewer_pos(&top); clear_viewer_pos(&cursor); xscroll = 0; cursor_ypos = 0; cursor_visual_length = 0; cursor_visual_xpos = 0; cursor_select = 0; cursor_select_start = -1ULL; sel_start = 0; sel_end = 0; isdirty_cursor_line = 0; search_caps = SEARCHMODE_VREGEX; uf_initialized = false; config_changed(); } void ht_uformat_viewer::done() { edit_end(); clear_subs(); free(tagpal.data); ht_format_viewer::done(); } int ht_uformat_viewer::address_input(const char *title, char *result, int limit, uint32 histid) { Bounds b; app->getbounds(&b); b.x = (b.w - 60) / 2, b.y = (b.h - 8) / 2; b.w = 60; b.h = 8; ht_dialog *dialog = new ht_dialog(); dialog->init(&b, title, FS_KILLER | FS_TITLE | FS_MOVE | FS_RESIZE); ht_strinputfield *input; const char *label = "~Address"; Bounds b2; b2.x = 3 + strlen(label); b2.y = 1; b2.w = b.w - 3 - b2.x; b2.h = 1; List *hist = NULL; if (histid) hist = (List*)getAtomValue(histid); input = new ht_strinputfield(); input->init(&b2, limit, hist); ht_inputfield_data d; d.text = (byte*)result; d.textlen = strlen((char*)d.text); input->databuf_set(&d, sizeof d); dialog->insert(input); if (label) { b2.x = 1; b2.y = 1; b2.w = 3 + strlen(label) - b2.x; b2.h = 1; ht_label *lab = new ht_label(); lab->init(&b2, label, input); dialog->insert(lab); } b2.x = b.w - 45; b2.y = b.h - 5; b2.w = 10; b2.h = 2; ht_button *bok = new ht_button(); bok->init(&b2, "O~k", button_ok); dialog->insert(bok); b2.x += 12; ht_button *bcancel = new ht_button(); bcancel->init(&b2, "~Cancel", button_cancel); dialog->insert(bcancel); b2.x += 12; b2.w = 14; ht_button *bhelp = new ht_button(); bhelp->init(&b2, "~Functions", 100); dialog->insert(bhelp); int r; bool run = true; int retval = button_cancel; while (run && (r = dialog->run(0)) != button_cancel) { switch (r) { case 100: { dialog_eval_help(format_viewer_func_handler, format_viewer_symbol_handler, this); break; } case button_ok: { int dsize = input->datasize(); ht_inputfield_data *data = ht_malloc(dsize); ViewDataBuf vdb(input, data, dsize); bin2str(result, data->text, data->textlen); free(data); if (hist) insert_history_entry(hist, result, 0); run = false; retval = button_ok; break; } } } dialog->done(); delete dialog; return retval; } void ht_uformat_viewer::adjust_cursor_group() { cursorline_get(); int g=tag_count_groups(cursor_line); if (cursor.tag_group>=g) cursor.tag_group=0; } void ht_uformat_viewer::adjust_cursor_idx() { cursorline_get(); int c = tag_count_selectable_tags_in_group(cursor_line, cursor.tag_group); if (cursor.tag_idx > c-1) cursor.tag_idx = c-1; } int ht_uformat_viewer::center_view(viewer_pos p) { top = p.u; int r = prev_line(&top, size.h/2); cursorline_dirty(); return r; } void ht_uformat_viewer::check_cursor_visibility() { if (cursor_state != cursor_state_disabled) { if ((cursor_ypos < 0) || (cursor_ypos >= size.h)) { cursor_state=cursor_state_invisible; } else { cursor_state=cursor_state_visible; } } } void ht_uformat_viewer::complete_init() { if (uf_initialized) return; cursor_state=cursor_state_disabled; if (!first_sub) { uf_initialized = true; return; } /* initialize top_* */ clear_viewer_pos(&top); top.sub = first_sub; top.sub->first_line_id(&top.line_id); cursor_tag_micropos = 0; uformat_viewer_pos p; clear_viewer_pos(&p); p.sub = first_sub; p.sub->first_line_id(&p.line_id); char line[1024]; cursor_ypos--; do { cursor_ypos++; if (!p.sub->getline(line, sizeof line, p.line_id)) break; if (tag_count_selectable_tags(line)) { if (cursor_ypos < size.h) { cursor_state = cursor_state_visible; } else { cursor_state = cursor_state_invisible; cursor_ypos = -1; } break; } } while (next_line(&p, 1) && cursor_ypos < size.h); p.tag_idx = 0; p.tag_group = 0; if (cursor_state == cursor_state_disabled) { p.sub = first_sub; p.sub->first_line_id(&p.line_id); if (p.sub->getline(line, sizeof line, p.line_id)) { cursor_ypos = -1; cursor_state = cursor_state_invisible; } } cursor = p; /* get cursorline */ cursorline_dirty(); cursorline_get(); /* initialize visual */ update_visual_info(); /* initialize misc */ update_misc_info(); uf_initialized = true; } void ht_uformat_viewer::config_changed() { scroll_offset = get_config_dword("editor/scroll offset", 3); ht_view::config_changed(); } int ht_uformat_viewer::cursor_left() { if (cursor.tag_idx) { cursor.tag_idx--; update_visual_info(); update_misc_info(); return 1; } else { if (cursor_up(1)) { cursor_end(); return 1; } } return 0; } int ht_uformat_viewer::cursor_right() { cursorline_get(); if (cursor.tag_idx < tag_count_selectable_tags_in_group(cursor_line, cursor.tag_group)-1) { cursor.tag_idx++; update_visual_info(); update_misc_info(); return 1; } else { if (cursor_down(1)) { cursor_home(); return 1; } } return 0; } int ht_uformat_viewer::cursor_up(int n) { int scrolloff = MIN(scroll_offset, size.h/2); switch (cursor_state) { case cursor_state_invisible: case cursor_state_visible: { if (n == 1 && cursor_state == cursor_state_visible) { int r = 0; uformat_viewer_pos c; clear_viewer_pos(&c); c = cursor; char c_line[1024]; int c_ypos = cursor_ypos; int c_tag_idx = cursor.tag_idx; int c_tag_group = cursor.tag_group; int d_tag_group = cursor.tag_group; while (prev_line(&c, 1) && c_ypos >= 0) { c_ypos--; c.sub->getline(c_line, sizeof c_line, c.line_id); int g = tag_count_groups(c_line); if (d_tag_group < g) c_tag_group = d_tag_group; int s; if (c_tag_group >= g) { c_tag_group = g-1; s = tag_count_selectable_tags_in_group(c_line, c_tag_group); if (s) { c_tag_idx = s-1; r = 1; break; } } else { s = tag_count_selectable_tags_in_group(c_line, c_tag_group); if (s) { if (c_tag_idx >= s) c_tag_idx = s-1; r = 1; break; } } } if (r) { cursor = c; memcpy(cursor_line, c_line, sizeof cursor_line); cursorline_dirty(); cursor_ypos = c_ypos; cursor.tag_idx = c_tag_idx; cursor.tag_group = c_tag_group; if (cursor_ypos <= scrolloff-1) scroll_up(-cursor_ypos+scrolloff); update_misc_info(); update_visual_info(); if (edit()) update_micropos(); } else { scroll_up(n); } return r; } else { int r=0; char c_line[1024]; int c_tag_idx = cursor.tag_idx; int c_tag_group = cursor.tag_group; int d_tag_group = cursor.tag_group; uformat_viewer_pos c; int c_ypos; if (cursor_state == cursor_state_invisible) { c = top; c_ypos = 0; } else { c = cursor; c_ypos = cursor_ypos; } int nc = prev_line(&c, n); c_ypos -= nc; while (nc--) { c.sub->getline(c_line, sizeof c_line, c.line_id); int g = tag_count_groups(c_line); if (d_tag_group < g) c_tag_group=d_tag_group; int s; if (c_tag_group >= g) { c_tag_group = g-1; s = tag_count_selectable_tags_in_group(c_line, c_tag_group); if (s) { c_tag_idx = s-1; r = 1; break; } } s = tag_count_selectable_tags_in_group(c_line, c_tag_group); if (s) { if (c_tag_idx >= s) c_tag_idx = s-1; r=1; break; } if (!next_line(&c, 1)) break; c_ypos++; } if (r) { cursor = c; memcpy(cursor_line, c_line, sizeof cursor_line); cursorline_dirty(); cursor_ypos = c_ypos; cursor.tag_idx = c_tag_idx; cursor.tag_group = c_tag_group; if (-cursor_ypos+n-nc-1+scrolloff > 0) scroll_up(-cursor_ypos+n-nc-1+scrolloff); update_misc_info(); update_visual_info(); if (edit()) update_micropos(); } else { if (cursor_state == cursor_state_invisible) cursor_ypos=-0x80000000; scroll_up(n); } // FIXME: wrong value return 1; } } case cursor_state_disabled: // scroll_up(n); // return n; break; } return 0; } int ht_uformat_viewer::cursor_down(int n) { int scrolloff = MIN(scroll_offset, size.h/2); switch (cursor_state) { case cursor_state_invisible: case cursor_state_visible: { if (n == 1 && cursor_state == cursor_state_visible) { int r=0; uformat_viewer_pos c; c = cursor; char c_line[1024]; int c_ypos=cursor_ypos; int c_tag_idx=cursor.tag_idx; int c_tag_group=cursor.tag_group; int d_tag_group=cursor.tag_group; int nls; /* controls scrolling beyond end */ while ((nls = next_line(&c, 1)) && c_ypos <= size.h-1) { c_ypos++; c.sub->getline(c_line, sizeof c_line, c.line_id); int g = tag_count_groups(c_line); if (d_tag_group < g) c_tag_group = d_tag_group; int s; if (c_tag_group >= g) { c_tag_group = g-1; s=tag_count_selectable_tags_in_group(c_line, c_tag_group); if (s) { c_tag_idx = s-1; r = 1; break; } } s = tag_count_selectable_tags_in_group(c_line, c_tag_group); if (s) { if (c_tag_idx >= s) c_tag_idx = s-1; r = 1; break; } } if (r) { cursor = c; memcpy(cursor_line, c_line, sizeof cursor_line); cursorline_dirty(); cursor_ypos = c_ypos; cursor.tag_idx = c_tag_idx; cursor.tag_group = c_tag_group; if (cursor_ypos >= size.h-(scrolloff+1)) scroll_down(cursor_ypos-size.h+scrolloff+1); update_misc_info(); update_visual_info(); if (edit()) update_micropos(); } else if (nls) scroll_down(1); return r; } else { int r=0; char c_line[1024]; int c_tag_idx=cursor.tag_idx; int c_tag_group=cursor.tag_group; int d_tag_group=cursor.tag_group; uformat_viewer_pos c; int c_ypos; if (cursor_state==cursor_state_invisible) { c = top; c_ypos = next_line(&c, size.h-1); } else { c = cursor; c_ypos = cursor_ypos; } int nc=next_line(&c, n); int onc=c_ypos+nc-size.h+1; c_ypos+=nc; while (nc--) { c.sub->getline(c_line, sizeof c_line, c.line_id); int g=tag_count_groups(c_line); if (d_tag_group=g) { c_tag_group=g-1; s=tag_count_selectable_tags_in_group(c_line, c_tag_group); if (s) { c_tag_idx=s-1; r=1; break; } } else { s=tag_count_selectable_tags_in_group(c_line, c_tag_group); if (s) { if (c_tag_idx>=s) c_tag_idx=s-1; r=1; break; } } if (nc) if (!prev_line(&c, 1)) break; c_ypos--; } if (r) { cursor = c; memcpy(cursor_line, c_line, sizeof cursor_line); cursorline_dirty(); cursor_ypos=c_ypos; cursor.tag_idx=c_tag_idx; cursor.tag_group=c_tag_group; if (cursor_ypos-size.h+1+scrolloff>0) scroll_down(cursor_ypos-size.h+1+scrolloff); update_misc_info(); update_visual_info(); if (edit()) update_micropos(); } else if (onc>0) { if (cursor_state==cursor_state_invisible) cursor_ypos=-0x80000000; scroll_down(onc); } // FIXME: wrong value return 1; } } case cursor_state_disabled: // scroll_down(n); // return n; break; } return 0; } int ht_uformat_viewer::cursor_home() { cursor.tag_idx=0; if (edit()) cursor_tag_micropos=0; update_visual_info(); update_misc_info(); return 1; } int ht_uformat_viewer::cursor_end() { cursorline_get(); int c = tag_count_selectable_tags_in_group(cursor_line, cursor.tag_group); cursor.tag_idx = c-1; if (edit()) { char *e = tag_get_selectable_tag(cursor_line, cursor.tag_idx, cursor.tag_group); if (e) cursor_tag_micropos = tag_get_microsize(e) - 1; } update_visual_info(); update_misc_info(); return 1; } void ht_uformat_viewer::cursor_tab() { cursor.tag_group++; adjust_cursor_group(); } void ht_uformat_viewer::cursorline_dirty() { isdirty_cursor_line = true; } void ht_uformat_viewer::cursorline_get() { if (isdirty_cursor_line) { if (cursor.sub) cursor.sub->getline(cursor_line, sizeof cursor_line, cursor.line_id); isdirty_cursor_line = false; } } int ht_uformat_viewer::cursormicroedit_forward() { cursorline_get(); uformat_viewer_pos p; p = top; p.tag_group = cursor.tag_group; uint cursor_tag_bitidx = 0; cursorline_get(); char *e=tag_get_selectable_tag(cursor_line, cursor.tag_idx, cursor.tag_group); if (e) { if (((byte*)e)[1] == HT_TAG_EDIT_BIT) { cursor_tag_bitidx = ((ht_tag_edit_bit*)e)->bitidx; } } bool cursor_found = false; char c_line[1024]; for (int y=0; y < size.h+16; y++) { if (!p.sub->getline(c_line, sizeof c_line, p.line_id)) break; int c=tag_count_selectable_tags_in_group(c_line, p.tag_group); while (p.tag_idxbitidx == cursor_tag_bitidx ) || tb[1] != HT_TAG_EDIT_BIT) { cursor_found = true; char *t = tag_get_selectable_tag(c_line, p.tag_idx, p.tag_group); int s = tag_get_microsize(t); if (cursor_tag_micropos+1 < s) { cursor_tag_micropos++; set_cursor(p); cursorline_dirty(); update_misc_info(); update_visual_info(); return 1; } } } } p.tag_idx++; } p.tag_idx = 0; if (!next_line(&p, 1)) break; } if (cursor_right()) cursor_tag_micropos = 0; return 0; } int ht_uformat_viewer::cursormicro_forward() { cursorline_get(); char *t = tag_get_selectable_tag(cursor_line, cursor.tag_idx, cursor.tag_group); int s = tag_get_microsize(t); if (cursor_tag_micropos+1 >= s) { if (cursor_right()) cursor_tag_micropos=0; else return 0; } else { cursor_tag_micropos++; } return 1; } int ht_uformat_viewer::cursormicro_backward() { if (cursor_tag_micropos>0) { cursor_tag_micropos--; } else { if (cursor_left()) { cursorline_get(); char *t=tag_get_selectable_tag(cursor_line, cursor.tag_idx, cursor.tag_group); cursor_tag_micropos=tag_get_microsize(t)-1; } else { return 0; } } return 1; } void ht_uformat_viewer::draw() { int sdown_count=0; if (!uf_initialized) HT_ERROR("complete_init() not called!"); restart: clear(getcolor(palidx_generic_body)); if (!first_sub) return; uformat_viewer_pos p = top; uformat_viewer_pos sp; clear_viewer_pos(&sp); char line[1024]; bool cursor_in_line; int cursor_found=-1; if (focused) hidecursor(); if (!p.sub->getline(line, sizeof line, p.line_id)) { if (p.sub->closest_line_id(&p.line_id)) { top = p; } else return; if (!p.sub->getline(line, sizeof line, p.line_id)) return; } for (int y=0; y < size.h; y++) { if (y == cursor_ypos) sp = p; if (!p.sub->getline(line, sizeof line, p.line_id)) break; /**/ /* char test[128]; tag_striptags(test+sprintf(test, "%08x,%08x: ", id1, id2), line); fprintf(stdout, "%s\n", test); fflush(stdout);*/ /**/ // FIXME: revision if (cursor_state == cursor_state_visible && p.sub == cursor.sub && compeq_line_id(p.line_id, cursor.line_id)) { cursor_found = y; cursorline_dirty(); update_misc_info(); int c = tag_count_selectable_tags_in_group(line, cursor.tag_group); if (cursor.tag_idx >= c) cursor.tag_idx = c-1; if (cursor_tag_class == tag_class_edit && edit()) { char *t = tag_get_selectable_tag(line, cursor.tag_idx, cursor.tag_group); if (t) { int x = cursor_visual_xpos + tag_get_micropos(t, cursor_tag_micropos) - xscroll; if (focused && x >= 0) setcursor(x, y); } } cursor_in_line = true; } else cursor_in_line = false; print_tagstring(0, y, size.w, xscroll, line, cursor_in_line); if (xscroll > 0) buf->printChar(0, y, VCP(VC_GREEN, VC_TRANSPARENT), '<'); if (!next_line(&p, 1)) break; } if (cursor_state == cursor_state_visible && cursor_found == -1) { #if 1 if (!sp.sub) sp = top; cursor = sp; #else top = cursor; #endif cursorline_dirty(); update_misc_info(); int c = tag_count_selectable_tags_in_group(line, cursor.tag_group); if (cursor.tag_idx > c-1) cursor.tag_idx=c-1; if (sdown_count++ > 0) goto restart; } if (cursor_found != -1) cursor_ypos = cursor_found; // buf_printf(1, 1, VCP(VC_GREEN, VC_BLACK), "%s", focused ? "focused" : "unfocused"); // if (cursor_select) printf(20, 1, VCP(VC_GREEN, VC_BLACK), "start=%08x, l=%08x", cursor_select_start, cursor_select_cursor_length); // buf_printf(20, 6, 7, "csize.x=%2d, csize.y=%2d, csize.w=%2d, csize.h=%2d", csize.x, csize.y, csize.w, csize.h); // buf_printf(2, 3, 7, "size.x=%2d, size.y=%2d, size.w=%2d, size.h=%2d", size.x, size.y, size.w, size.h); // buf_printf(2, 4, 7, "vsize.x=%2d, vsize.y=%2d, vsize.w=%2d, vsize.h=%2d", vsize.x, vsize.y, vsize.w, vsize.h); // buf_printf(2, 5, 7, "bsize.x=%2d, bsize.y=%2d, bsize.w=%2d, bsize.h=%2d", buf->size.x, buf->size.y, buf->size.w, buf->size.h); // buf_printf(20, 7, 7, "size.x=%2d, size.y=%2d, size.w=%2d, size.h=%2d", group->group->size.x, group->group->size.y, group->group->size.w, group->group->size.h); // buf_printf(20, 8, 7, "vsize.x=%2d, vsize.y=%2d, vsize.w=%2d, vsize.h=%2d", group->group->vsize.x, group->group->vsize.y, group->group->vsize.w, group->group->vsize.h); // buf_printf(0, 7, 7, "vx=%2d, vl=%2d, ypos=%2d", cursor_visual_xpos, cursor_visual_length, cursor_ypos); // buf->printf(0, 2, 7, CP_DEVICE, "cursor_micropos=%d", cursor_tag_micropos); // buf_printf(0, 2, 7, "%x, %x, %x, %x, %x, c_tagidx", cursor.line_id.id1, cursor.line_id.id2, cursor.line_id.id3, cursor.line_id.id4, cursor.line_id.id5, cursor.tag_idx); // buf_printf(0, 3, 7, "(%c)", "vid"[cursor_state]); // buf_printf(0, 6, 7, "cursor.tag_idx=%d", cursor.tag_idx); /* if (cursor_tag_class==tag_class_edit) { buf_printf(30, 7, 7, "class=edit, addr=%08x", cursor_tag_offset); } else { buf_printf(30, 7, 7, "class=sel, id_low=%08x, id_high=%08x", 0,0); }*/ } bool ht_uformat_viewer::edit() { return (file && (file->getAccessMode() & IOAM_WRITE)); } bool ht_uformat_viewer::edit_end() { if (!edit()) { hidecursor(); set_cursor(cursor); #if 0 uformat_viewer_pos p = cursor; if (find_first_tag(&p, size.h)) { set_cursor(p); } else { // if (cursor_state!=cursor_state_disabled) { /* is that all we have to do ??? testing needed */ // cursor_state=cursor_state_invisible; // assert(0); /* FIXME: not yet implemented */ // } } #endif cursorline_dirty(); adjust_cursor_idx(); update_visual_info(); update_misc_info(); dirtyview(); return true; } return false; } bool ht_uformat_viewer::edit_input(byte b) { cursorline_get(); char *t = tag_get_selectable_tag(cursor_line, cursor.tag_idx, cursor.tag_group); switch (t[1]) { case HT_TAG_EDIT_BYTE: case HT_TAG_EDIT_WORD_LE: case HT_TAG_EDIT_DWORD_LE: case HT_TAG_EDIT_QWORD_LE: case HT_TAG_EDIT_WORD_BE: case HT_TAG_EDIT_DWORD_BE: case HT_TAG_EDIT_QWORD_BE: { int nibval = edit_input_c2h(b); if (nibval == -1) break; int size = 0; bool bigendian = true; switch (t[1]) { case HT_TAG_EDIT_BYTE: size = 1; break; case HT_TAG_EDIT_WORD_LE: size = 2; bigendian=false; break; case HT_TAG_EDIT_DWORD_LE: size = 4; bigendian=false; break; case HT_TAG_EDIT_QWORD_LE: size = 8; bigendian=false; break; case HT_TAG_EDIT_WORD_BE: size = 2; bigendian=true; break; case HT_TAG_EDIT_DWORD_BE: size = 4; bigendian=true; break; case HT_TAG_EDIT_QWORD_BE: size = 8; bigendian=true; break; } uint shift = 4 - (cursor_tag_micropos&1)*4; uint m = ~(0xf << shift); uint o = nibval << shift; int b; if (bigendian) { b = cursor_tag_micropos/2; } else { b = size - cursor_tag_micropos/2 - 1; } byte buf; pread(cursor_tag_offset + b, &buf, 1); buf &= m; buf |= o; pwrite(cursor_tag_offset + b, &buf, 1); cursormicroedit_forward(); return true; } case HT_TAG_EDIT_CHAR: { if (b >= 32 && b < 128) { pwrite(cursor_tag_offset, &b, 1); cursormicroedit_forward(); return true; } break; } case HT_TAG_EDIT_BIT: { if (b == '1' || b == '0' || b == ' ') { byte d; cursorline_get(); char *t = tag_get_selectable_tag(cursor_line, cursor.tag_idx, cursor.tag_group); int shift = ((ht_tag_edit_bit*)t)->bitidx; uint32 mask = 1 << (shift%8); int op = shift/8; pread(cursor_tag_offset+op, &d, 1); switch (b) { case '0': d &= ~mask; break; case '1': d |= mask; break; case K_Space: d ^= mask; break; } pwrite(cursor_tag_offset+op, &d, 1); cursormicroedit_forward(); return true; } break; } case HT_TAG_EDIT_TIME_BE: case HT_TAG_EDIT_TIME_LE: { uint32 d; int h = edit_input_c2d(b); byte buf[4]; if (pread(cursor_tag_offset, &buf, 4)==4 && h!=-1) { if (t[1] == HT_TAG_EDIT_TIME_LE) { d=(buf[3]<<24) | (buf[2]<<16) | (buf[1]<<8) | buf[0]; } else { d=(buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; } time_t tt = d; tm *ti = gmtime(&tt); tm q = *ti; int k; bool worked = false; #define DEC_MASK(value, mask) ((value) - (value) / (mask) % 10 * (mask)) switch (cursor_tag_micropos) { case 0: k = q.tm_hour % 10 + h * 10; if (k < 24) { q.tm_hour = k; worked = true; } break; case 1: k = q.tm_hour - q.tm_hour % 10 + h; if (k < 24) { q.tm_hour = k; worked = true; } break; case 2: k = q.tm_min % 10 + h * 10; if (k < 60) { q.tm_min = k; worked = true; } break; case 3: k = q.tm_min - q.tm_min % 10 + h; if (k < 60) { q.tm_min = k; worked = true; } break; case 4: k = q.tm_sec % 10 + h * 10; if (k < 60) { q.tm_sec = k; worked = true; } break; case 5: k = q.tm_sec - q.tm_sec % 10 + h; if (k < 60) { q.tm_sec = k; worked = true; } break; case 6: k = (q.tm_mday % 10) + h * 10; if (k <= 31) { q.tm_mday = k; worked = true; } break; case 7: k = q.tm_mday - q.tm_mday % 10 + h; if (k <= 31) { q.tm_mday = k; worked = true; } break; case 8: k = (q.tm_mon+1) % 10 + h * 10; if (k <= 12) { q.tm_mon = k-1; worked = true; } break; case 9: k = q.tm_mon - q.tm_mon % 10 + h; if (k <= 12) { q.tm_mon = k-1; worked = true; } break; case 10: k = DEC_MASK(q.tm_year, 1000) + h * 1000; if ((k+1900 >= 1970 ) && (k+1900 < 2106)) { q.tm_year = k; worked = true; } break; case 11: k = DEC_MASK(q.tm_year, 100) + h * 100; if ((k+1900 >= 1970 ) && (k+1900 < 2106)) { q.tm_year = k; worked = true; } break; case 12: k = DEC_MASK(q.tm_year, 10) + h * 10; if ((k+1900 >= 1970 ) && (k+1900 < 2106)) { q.tm_year = k; worked = true; } break; case 13: k = DEC_MASK(q.tm_year, 1) + h * 1; if ((k+1900 >= 1970 ) && (k+1900 < 2106)) { q.tm_year = k; worked = true; } break; } /* FIXME: big bad hack... */ if (sizeof(uint32) == sizeof(time_t)) if (worked) { /* FIXME: !!! */ uint32 tz; time_t l = time(NULL); time_t g = l; struct tm *gtm = gmtime(&g); g = mktime(gtm); tz = (uint32)difftime(g, l); time_t tt = mktime(&q); d = tt; d -= tz; if (t[1] == HT_TAG_EDIT_TIME_LE) { buf[0] = d>>0; buf[1] = d>>8; buf[2] = d>>16; buf[3] = d>>24; } else { buf[3] = d>>0; buf[2] = d>>8; buf[1] = d>>16; buf[0] = d>>24; } pwrite(cursor_tag_offset, &buf, 4); cursormicroedit_forward(); return true; } } } } return false; } int ht_uformat_viewer::edit_input_c2h(byte b) { int h = -1; if (b >= '0' && b <= '9') { h = b-'0'; } else if (b >= 'a' && b <= 'f') { h = b-'a'+10; } else if (b >= 'A' && b <= 'F') { h = b-'A'+10; } return h; } int ht_uformat_viewer::edit_input_c2d(byte b) { int h = -1; if (b >= '0' && b <= '9') { h = b-'0'; } return h; } void ht_uformat_viewer::edit_input_correctpos() { uformat_viewer_pos p = top; /* try finding edited tag by its offset */ char c_line[1024]; int g=cursor.tag_group; for (int y=0; y < size.h+10; y++) { if (!p.sub->getline(c_line, sizeof c_line, p.line_id)) break; int c = tag_count_selectable_tags_in_group(c_line, cursor.tag_group); for (int i=0; i < c; i++) { char *t = tag_get_selectable_tag(c_line, i, cursor.tag_group); if (tag_get_class(t) == tag_class_edit && tag_get_offset(t) == cursor_tag_offset) { set_cursor(p); cursorline_dirty(); cursor.tag_idx = i; cursor.tag_group = g; update_misc_info(); update_visual_info(); return; } } if (!next_line(&p, 1)) break; } /* try finding edited tag by cursor_ypos */ p = top; next_line(&p, cursor_ypos); int ci = cursor.tag_idx; set_cursor(p); cursorline_dirty(); cursorline_get(); int x = tag_count_selectable_tags(cursor_line); if (ci >= x) ci = x-1; cursor.tag_idx = ci; update_misc_info(); update_visual_info(); } bool ht_uformat_viewer::edit_start() { if (edit() && cursor.sub) { cursor_tag_micropos=0; cursorline_dirty(); adjust_cursor_idx(); update_visual_info(); update_misc_info(); dirtyview(); return true; } return false; } bool ht_uformat_viewer::edit_update() { if (edit()) { file->cntl(FCNTL_MODS_FLUSH); dirtyview(); return true; } return false; } bool ht_uformat_viewer::find_first_tag(uformat_viewer_pos *p, int limit) { char line[1024]; int i=0; uformat_viewer_pos q = *p; if (!q.sub) return false; do { q.sub->getline(line, sizeof line, q.line_id); if (tag_get_selectable_tag(line, 0, 0)) { *p = q; p->tag_idx = 0; p->tag_group = 0; return true; } } while ((next_line(&q, 1)) && (i++getline(line, sizeof line, q.line_id); int c = tag_count_selectable_tags(line); char *t = line; for (int j=0; jtag_idx = j; p->tag_group = 0; /* FIXME: what about groups ??? */ return true; } t += tag_get_len(t); } } while (next_line(&q, 1) && i++ < limit); return false; } void ht_uformat_viewer::focus_cursor() { // why ? /* if (cursor_state==cursor_state_invisible) { center_view(cursor_sub, cursor_id1, cursor_id2); cursor_state=cursor_state_visible; }*/ update_visual_info(); if (cursor_visual_xpos-xscroll <= 1) { if (cursor_visual_xpos>=1) xscroll = cursor_visual_xpos-1; else xscroll = 0; } else if (cursor_visual_xpos+cursor_visual_length-xscroll > size.w-1) { xscroll = cursor_visual_xpos+cursor_visual_length-size.w+1; } } const char *ht_uformat_viewer::func(uint i, bool execute) { switch (i) { case 2: if (caps & VC_EDIT) { if (edit()) { if (execute) app->sendmsg(cmd_file_save); // if (execute) edit_update(); return "save"; } else { return "~save"; } } break; /* case 3: if (caps & VC_REPLACE) { if (edit()) { if (execute) sendmsg(cmd_file_replace); return "replace"; } else { return "~replace"; } } break;*/ case 4: if (caps & VC_EDIT) { if (edit()) { if (execute) { FileOfs start = 0; FileOfs size = file->getSize(); bool isdirty = false; file->cntl(FCNTL_MODS_IS_DIRTY, start, size, &isdirty); char q[1024]; String fn; if (!file->getFilename(fn).isEmpty()) { ht_snprintf(q, sizeof q, "file %y has been modified, apply changes?", &fn); } else { ht_snprintf(q, sizeof q, "untitled file has been modified, apply changes?"); } if (isdirty && confirmbox(q) == button_yes) { file->cntl(FCNTL_MODS_FLUSH); } else { file->cntl(FCNTL_MODS_INVD); } if (size != file->getSize()) { htmsg m; m.msg = msg_filesize_changed; m.type = mt_broadcast; sendmsg(&m); } baseview->sendmsg(cmd_view_mode_i, file, NULL); } return "view"; } else { if (execute) baseview->sendmsg(cmd_edit_mode_i, file, NULL); return "edit"; } } break; case 5: if (caps & VC_GOTO) { if (execute) sendmsg(cmd_file_goto); return "goto"; } break; case 7: if (caps & VC_SEARCH) { if (execute) sendmsg(cmd_file_search); return "search"; } break; case 8: if (caps & VC_RESIZE) { if (edit()) { if (execute) sendmsg(cmd_file_resize); return "resize"; } else { return "~resize"; } } break; case 9: { if (execute) { FileOfs o; if (get_current_real_offset(&o)) { char title[128]; ht_snprintf(title, sizeof title, "view offset %08qx in...", o); ht_view *v = ((ht_app*)app)->popup_view_list(title); if (v) { htmsg m; m.msg = msg_goto_offset; m.type = mt_empty; m.data1.q = o; v->sendmsg(&m); if (m.msg == msg_empty) { vstate_save(); app->focus(v); } else { errorbox("offset %08qx is not supported/invalid in '%s'", o, v->desc); } } } } return "viewin..."; } } return ht_format_viewer::func(i, execute); } vcp ht_uformat_viewer::getcolor_tag(uint pal_index) { return getcolorv(&tagpal, pal_index); } bool ht_uformat_viewer::get_current_offset(FileOfs *offset) { if (cursor_state != cursor_state_disabled && cursor_tag_class == tag_class_edit) { *offset = cursor_tag_offset; return true; } return false; } bool ht_uformat_viewer::get_current_pos(viewer_pos *pos) { clear_viewer_pos(pos); pos->u = cursor; return true; } bool ht_uformat_viewer::get_current_tag(char **tag) { cursorline_get(); char *e = tag_get_selectable_tag(cursor_line, cursor.tag_idx, cursor.tag_group); if (e) { *tag = e; return true; } return false; } bool ht_uformat_viewer::get_current_tag_size(uint32 *size) { if (cursor_tag_class == tag_class_edit) { cursorline_get(); char *e = tag_get_selectable_tag(cursor_line, cursor.tag_idx, cursor.tag_group); if (e) { *size = tag_get_size(e); return true; } } return false; } void ht_uformat_viewer::handlemsg(htmsg *msg) { switch (msg->msg) { case msg_get_pindicator: msg->data1.integer = get_pindicator_str((char*)msg->data2.ptr, msg->data1.integer); clearmsg(msg); return; case msg_get_scrollinfo: switch (msg->data1.integer) { case gsi_hscrollbar: { gsi_scrollbar_t *p = (gsi_scrollbar_t*)msg->data2.ptr; if (!get_hscrollbar_pos(&p->pstart, &p->psize)) { p->pstart = 0; p->psize = 100; } clearmsg(msg); return; } case gsi_vscrollbar: { gsi_scrollbar_t *p = (gsi_scrollbar_t*)msg->data2.ptr; if (!get_vscrollbar_pos(&p->pstart, &p->psize)) { p->pstart = 0; p->psize = 100; } clearmsg(msg); return; } } break; case msg_complete_init: complete_init(); clearmsg(msg); return; case msg_keypressed: switch (msg->data1.integer) { case K_Meta_S: if (cursor_select) { select_mode_off(); } else { select_mode_on(); } clearmsg(msg); dirtyview(); return; case K_Up: select_mode_pre(); cursor_up(1); select_mode_post(0); clearmsg(msg); dirtyview(); return; case K_Down: select_mode_pre(); cursor_down(1); select_mode_post(0); clearmsg(msg); dirtyview(); return; case K_PageUp: select_mode_pre(); cursor_up(size.h); select_mode_post(0); clearmsg(msg); dirtyview(); return; case K_PageDown: select_mode_pre(); cursor_down(size.h); select_mode_post(0); clearmsg(msg); dirtyview(); return; case K_Left: if (cursor_state!=cursor_state_disabled) { select_mode_pre(); if (edit()) cursormicro_backward(); else cursor_left(); select_mode_post(0); focus_cursor(); clearmsg(msg); dirtyview(); return; } break; case K_Right: if (cursor_state!=cursor_state_disabled) { int r; select_mode_pre(); if (edit()) r=cursormicro_forward(); else r=cursor_right(); select_mode_post(!r); focus_cursor(); clearmsg(msg); dirtyview(); return; } break; case K_Return: switch (cursor_tag_class) { case tag_class_sel: ref(); break; case tag_class_edit: if (edit()) { edit_input(msg->data1.integer); } break; } dirtyview(); clearmsg(msg); return; case K_Backspace: { FileOfs f; if (edit() && (cursor_tag_class == tag_class_edit) && get_current_offset(&f)) { file->cntl(FCNTL_MODS_CLEAR_DIRTY_RANGE, f, 1); cursor_left(); focus_cursor(); dirtyview(); clearmsg(msg); } return; } case K_Tab: { int c=cursor.tag_group; cursor_tab(); if (cursor.tag_group!=c) { focus_cursor(); update_visual_info(); dirtyview(); clearmsg(msg); return; } break; } case K_Home: if (cursor_state==cursor_state_visible) { select_mode_pre(); cursor_home(); select_mode_post(0); focus_cursor(); clearmsg(msg); dirtyview(); return; } break; case K_End: if (cursor_state==cursor_state_visible) { select_mode_pre(); cursor_end(); select_mode_post(0); focus_cursor(); clearmsg(msg); dirtyview(); return; } break; case K_Control_Left: xscroll-=2; if (xscroll<0) xscroll=0; dirtyview(); clearmsg(msg); return; case K_Control_Right: xscroll+=2; dirtyview(); clearmsg(msg); return; case K_Control_PageUp: { top.sub = first_sub; if (top.sub) { vstate_save(); select_mode_pre(); top.sub->first_line_id(&top.line_id); uformat_viewer_pos p = top; p.tag_group = cursor.tag_group; if (find_first_tag(&p, size.h)) { set_cursor(p); } else { cursor_ypos = 0x7fffffff; update_misc_info(); update_visual_info(); check_cursor_visibility(); } select_mode_post(0); } clearmsg(msg); dirtyview(); return; } case K_Control_PageDown: { top.sub = last_sub; if (top.sub) { vstate_save(); select_mode_pre(); top.sub->last_line_id(&top.line_id); uformat_viewer_pos p = top; p.tag_group = cursor.tag_group; if (find_first_tag(&p, 1)) { set_cursor(p); } else { cursor_ypos = 0x7fffffff; update_misc_info(); update_visual_info(); check_cursor_visibility(); } cursor_up(size.h); cursor_down(size.h); select_mode_post(0); } clearmsg(msg); dirtyview(); return; } case K_Shift_Up: { focus_cursor(); FileOfs s, e; uint32 ts; if (cursor_tag_class == tag_class_edit) s = cursor_tag_offset; else s = (sel_end > sel_start) ? sel_end : -1ULL; e = get_current_tag_size(&ts) ? s+ts : -1ULL; cursor_up(1); if (s != -1ULL) { if (cursor_tag_class == tag_class_edit) { pselect_add(s, cursor_tag_offset); } else if (cursor_tag_class == tag_class_sel && e != -1ULL) { pselect_add(s, e); } } clearmsg(msg); dirtyview(); return; } case K_Shift_Down: { focus_cursor(); FileOfs s, e; uint32 ts; if (cursor_tag_class == tag_class_edit) s = cursor_tag_offset; else s = (sel_end > sel_start) ? sel_end : -1ULL; e = get_current_tag_size(&ts) ? s+ts : -1ULL; cursor_down(1); if (s != -1ULL) { if (cursor_tag_class == tag_class_edit) { pselect_add(s, cursor_tag_offset); } else if (cursor_tag_class == tag_class_sel && e != -1ULL) { pselect_add(s, e); } } clearmsg(msg); dirtyview(); return; } case K_Shift_Left: { focus_cursor(); FileOfs s, e; uint32 ts; if (cursor_tag_class==tag_class_edit) s = cursor_tag_offset; else s = sel_end > sel_start ? sel_end : -1ULL; e = get_current_tag_size(&ts) ? s+ts : -1ULL; int r; if (edit()) r = cursormicro_backward(); else r = cursor_left(); if (s != -1ULL && r) { if (cursor_tag_class == tag_class_edit) { pselect_add(s, cursor_tag_offset); } else if (cursor_tag_class == tag_class_sel && e != -1ULL) { pselect_add(s, e); } } clearmsg(msg); dirtyview(); return; } case K_Shift_Right: { focus_cursor(); FileOfs s, e; uint32 ts; if (cursor_tag_class == tag_class_edit) s = cursor_tag_offset; else s = (sel_end > sel_start) ? sel_end : -1ULL; e=get_current_tag_size(&ts) ? s+ts : -1ULL; int r; if (edit()) r = cursormicro_forward(); else r = cursor_right(); if (s != -1ULL) { if (r) { if (cursor_tag_class == tag_class_edit) { pselect_add(s, cursor_tag_offset); } else if (cursor_tag_class == tag_class_sel && e != -1ULL) { pselect_add(s, e); } } else { if (cursor_tag_class == tag_class_edit && sel_end != e) { pselect_add(s, e); } } } clearmsg(msg); dirtyview(); return; } case K_Shift_PageUp: { focus_cursor(); FileOfs s, e; uint32 ts; if (cursor_tag_class == tag_class_edit) s = cursor_tag_offset; else s = (sel_end > sel_start) ? sel_end : -1ULL; e = get_current_tag_size(&ts) ? s+ts : -1ULL; cursor_up(size.h); if (s != -1ULL) { if (cursor_tag_class == tag_class_edit) { pselect_add(s, cursor_tag_offset); } else if (cursor_tag_class == tag_class_sel && e != -1ULL) { pselect_add(s, e); } } clearmsg(msg); dirtyview(); return; } case K_Shift_PageDown: { focus_cursor(); FileOfs s, e; uint32 ts; if (cursor_tag_class==tag_class_edit) s=cursor_tag_offset; else s=(sel_end>sel_start) ? sel_end : -1ULL; e=get_current_tag_size(&ts) ? s+ts : -1ULL; cursor_down(size.h); if (s != -1ULL) { if (cursor_tag_class==tag_class_edit) { pselect_add(s, cursor_tag_offset); } else if (cursor_tag_class == tag_class_sel && e != -1ULL) { pselect_add(s, e); } } clearmsg(msg); dirtyview(); return; } case K_Shift_Home: { focus_cursor(); FileOfs s, e; uint32 ts; if (cursor_tag_class==tag_class_edit) s=cursor_tag_offset; else s=(sel_end>sel_start) ? sel_end : -1ULL; e=get_current_tag_size(&ts) ? s+ts : -1ULL; int r=cursor_home(); if (s != -1ULL && r) { if (cursor_tag_class == tag_class_edit) { pselect_add(cursor_tag_offset, s); } else if (cursor_tag_class == tag_class_sel && e != -1ULL) { pselect_add(e, s); } } clearmsg(msg); dirtyview(); return; } case K_Shift_End: { focus_cursor(); FileOfs s, e; uint32 ts; if (cursor_tag_class==tag_class_edit) s=cursor_tag_offset; else s=(sel_end>sel_start) ? sel_end : -1ULL; e=get_current_tag_size(&ts) ? s+ts : -1ULL; int r=cursor_end(); if (s != -1ULL && r){ if (cursor_tag_class == tag_class_edit) { pselect_add(s, cursor_tag_offset); } else if (cursor_tag_class == tag_class_sel && e != -1ULL) { pselect_add(s, e); } } clearmsg(msg); dirtyview(); return; } case K_Control_F: if (caps & VC_SEARCH) { sendmsg(cmd_file_search); dirtyview(); clearmsg(msg); return; } break; case K_Control_L: case K_Shift_F7: if (caps & VC_SEARCH) { if (!continue_search()) { if (last_search_request) { infobox("no further matches"); } else { infobox("you must 'search' first!"); } } dirtyview(); clearmsg(msg); return; } break; case K_Meta_C: case K_Control_Insert: sendmsg(cmd_edit_copy); dirtyview(); clearmsg(msg); return; case K_Meta_V: case K_Shift_Insert: sendmsg(cmd_edit_paste); dirtyview(); clearmsg(msg); return; case K_Escape: if (caps & VC_EDIT) { baseview->sendmsg(cmd_view_mode_i, file, NULL); return; } break; default: { if (((uint32)msg->data1.integer<=255) && (edit())) { if (cursor_tag_class==tag_class_edit) { focus_cursor(); if (edit_input(msg->data1.integer)) { dirtyview(); clearmsg(msg); return; } } } } } break; case cmd_edit_copy: if (sel_end > sel_start) { char dsc[1024]; String fn; ht_snprintf(dsc, sizeof dsc, "%y::%s", &file->getFilename(fn), desc); clipboard_copy(dsc, file, sel_start, sel_end-sel_start); } clearmsg(msg); return; case cmd_edit_paste: FileOfs ofs; if (get_current_offset(&ofs)) { baseview->sendmsg(cmd_edit_mode_i, file, NULL); if (file->getAccessMode() & IOAM_WRITE) { FileOfs s = clipboard_paste(file, ofs); if (s) { pselect_set(ofs, ofs+s); sendmsg(cmd_edit_mode_i); } } } dirtyview(); clearmsg(msg); return; case cmd_edit_mode: edit_start(); dirtyview(); return; case cmd_view_mode: edit_end(); dirtyview(); return; case cmd_file_goto: { char addrstr[1024]; addrstr[0] = 0; while (address_input("goto", addrstr, sizeof addrstr, HISTATOM_GOTO) != button_cancel) { if (addrstr[0]) { viewer_pos pos; globalerror[0] = 0; if (string_to_pos(addrstr, &pos) && goto_pos(pos, this)) { focus_cursor(); break; } if (globalerror[0]) { infobox("error: %s\nin '%s'", globalerror, addrstr); } else { infobox("invalid address: '%s'", addrstr); } } } clearmsg(msg); dirtyview(); return; } case cmd_file_search: { viewer_pos start_pos, end_pos; get_current_pos(&start_pos); clear_viewer_pos(&end_pos); end_pos.u.sub = last_sub; end_pos.u.tag_idx = -1; last_sub->last_line_id(&end_pos.u.line_id); ht_search_request *request = search_dialog(this, search_caps, &start_pos, &end_pos); ht_search_result *result = NULL; if (request) { switch (request->search_class) { case SC_PHYSICAL: { try { FileOfs start, end; if (pos_to_offset(start_pos, &start)) { if (!pos_to_offset(end_pos, &end)) { end = FileOfs(-1); } result = psearch(request, start, end); } } catch (const Exception &e) { errorbox("error: %y", &e); } break; } case SC_VISUAL: { try { result = vsearch(request, start_pos, end_pos); } catch (const Exception &e) { errorbox("error: %y", &e); } break; } } delete request; if (result) { // FIXME: !!!!!!!! if (!show_search_result(result)) infobox("couldn't display result (internal error)"); delete result; } else infobox("not found"); } clearmsg(msg); dirtyview(); return; } case cmd_file_replace: { sendmsg(cmd_edit_mode_i); if (edit()) { bool cancel; FileOfs s = get_file()->getSize(); uint repls = replace_dialog(this, search_caps, &cancel); if (repls) { if (s != get_file()->getSize()) { sendmsg(msg_filesize_changed); } infobox("%d replacement(s) made", repls); } } clearmsg(msg); dirtyview(); return; } case msg_filesize_changed: { htmsg m; m.msg = msg_filesize_changed; m.type = mt_broadcast; sendsubmsg(&m); break; } case cmd_file_save: { if (edit()) edit_update(); clearmsg(msg); return; } case cmd_file_resize: { FileOfs o = 0; if (get_current_offset(&o)) { uint32 s; if (get_current_tag_size(&s)) { o += s; } } if (!o) o = clipboard_getsize(); FileOfs s = file->getSize(); char buf[32]; ht_snprintf(buf, sizeof buf, "%qd", o); if (inputbox("resize", "new file size", buf, sizeof buf, 0)==button_ok) { eval_scalar r; if (eval(&r, buf, NULL, NULL, NULL)) { eval_int i; scalar_context_int(&r, &i); scalar_destroy(&r); o = i.value; if (o < s) { /* truncate */ htmsg m; m.msg = cmd_file_truncate; m.type = mt_broadcast; m.data1.ptr = file; m.data2.q = o; baseview->sendmsg(&m); m.msg = msg_filesize_changed; m.type = mt_broadcast; sendsubmsg(&m); sendmsg(&m); } else if (o>s) { /* extend */ htmsg m; m.msg = cmd_file_extend; m.type = mt_broadcast; m.data1.ptr = file; m.data2.q = o; baseview->sendmsg(&m); m.msg = msg_filesize_changed; m.type = mt_broadcast; sendsubmsg(&m); sendmsg(&m); } } else { const char *errmsg="?"; int errpos=0; get_eval_error(&errmsg, &errpos); errorbox("eval error: %s at %d\n in '%s'", errmsg, errpos, buf); } update_misc_info(); } clearmsg(msg); dirtyview(); return; } case cmd_file_blockop: { if (sel_end>sel_start) { blockop_dialog(this, sel_start, sel_end); } else { FileOfs o = 0; get_current_offset(&o); blockop_dialog(this, o, file->getSize()); } clearmsg(msg); dirtyview(); return; } } ht_format_viewer::handlemsg(msg); } void ht_uformat_viewer::insertsub(ht_sub *sub) { if (last_sub) last_sub->next = sub; sub->uformat_viewer = this; sub->prev = last_sub; last_sub = sub; if (!first_sub) first_sub = sub; } bool ht_uformat_viewer::goto_offset(FileOfs offset, bool save_vstate) { uformat_viewer_pos p; p.sub = first_sub; p.tag_group = cursor.tag_group; while (p.sub) { if (p.sub->convert_ofs_to_id(offset, &p.line_id)) { if (save_vstate) vstate_save(); switch (cursor_state) { case cursor_state_visible: { select_mode_pre(); /* FIXME: magic 42 */ if (!find_first_edit_tag_with_offset(&p, 42, offset) && !find_first_tag(&p, size.h)) break; bool r = set_cursor(p); select_mode_post(false); return r; } case cursor_state_invisible: select_mode_pre(); p.tag_group = -1; p.tag_idx = -1; bool r = set_cursor(p); select_mode_post(false); return r; } break; } p.sub = p.sub->next; } return false; } bool ht_uformat_viewer::goto_pos(viewer_pos pos, bool save_vstate) { if (save_vstate) vstate_save(); select_mode_pre(); set_cursor(pos.u); select_mode_post(false); return true; } bool ht_uformat_viewer::next_logical_pos(viewer_pos pos, viewer_pos *npos) { if (next_line(&pos.u, 1) == 1) { *npos = pos; return true; } return false; } bool ht_uformat_viewer::next_logical_offset(FileOfs ofs, FileOfs *nofs) { *nofs = ofs + 1; return true; } int ht_uformat_viewer::next_line(uformat_viewer_pos *p, int n) { int n0 = n; while (n) { if (n -= p->sub->next_line_id(&p->line_id, n)) { if (!p->sub->next) return n0 - n; p->sub = p->sub->next; p->sub->first_line_id(&p->line_id); p->tag_idx = -1; n--; } } return n0 - n; } int ht_uformat_viewer::prev_line(uformat_viewer_pos *p, int n) { int n0 = n; while (n){ if (n -= p->sub->prev_line_id(&p->line_id, n)) { if (!p->sub->prev) return n0 - n; p->sub = p->sub->prev; p->sub->last_line_id(&p->line_id); p->tag_idx = -1; n--; } } return n0 - n; } vcp ht_uformat_viewer::get_tag_color_edit(FileOfs tag_offset, uint size, bool atcursoroffset, bool iscursor) { vcp tag_color = getcolor_tag(palidx_tags_edit_tag); bool isdirty = false; FileOfs fsize = size; file->cntl(FCNTL_MODS_IS_DIRTY, tag_offset, fsize, &isdirty); if (isdirty) tag_color = mixColors(tag_color, getcolor_tag(palidx_tags_edit_tag_modified)); if (tag_offset >= sel_start && tag_offset < sel_end) tag_color = mixColors(tag_color, getcolor_tag(palidx_tags_edit_tag_selected)); if (iscursor) { int coloridx; if (atcursoroffset) { if (edit()) { coloridx = palidx_tags_edit_tag_cursor_edit; } else { coloridx = palidx_tags_edit_tag_cursor_select; } } else { coloridx = palidx_tags_edit_tag_cursor_unfocused; } tag_color = mixColors(tag_color, getcolor_tag(coloridx)); } return tag_color; } void ht_uformat_viewer::render_tagstring_desc(const char **string, int *length, vcp *tc, char *tag, uint size, bool bigendian, bool is_cursor) { ID id; vcp tag_color = getcolor_tag(palidx_tags_sel_tag); if (is_cursor) tag_color = getcolor_tag(palidx_tags_sel_tag_cursor_focused); *string = "?"; *length = 1; *tc = tag_color; if (tag_get_desc_id(tag, &id)) { int_hash *tbl; if ((tbl = (int_hash*)getAtomValue(id))) { const char *str; uint64 q = 0; FileOfs tag_offset = tag_get_offset(tag); byte buf[8]; if (pread(tag_offset, buf, size) == size) { switch (size) { case 1: q = buf[0]; break; case 2: if (bigendian) { q = (buf[0]<<8) | buf[1]; } else { q = (buf[1]<<8) | buf[0]; } break; case 4: if (bigendian) { q = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; } else { q = (buf[3]<<24) | (buf[2]<<16) | (buf[1]<<8) | buf[0]; } break; case 8: if (bigendian) { q = ((uint64)buf[0] << 56) | ((uint64)buf[1] << 48) | ((uint64)buf[2] << 40) | ((uint64)buf[3] << 32) | ((uint64)buf[4] << 24) | ((uint64)buf[5] << 16) | ((uint64)buf[6] << 8) | (uint64)buf[7]; } else { q = ((uint64)buf[7] << 56) | ((uint64)buf[6] << 48) | ((uint64)buf[5] << 40) | ((uint64)buf[4] << 32) | ((uint64)buf[3] << 24) | ((uint64)buf[2] << 16) | ((uint64)buf[1] << 8) | (uint64)buf[0]; } break; } /* FIXME: uint64 ? */ if ((str = matchhash(q, tbl))) { *string = str; *length = strlen(*string); } } else { *string = "?"; *length = strlen(*string); } } } } void ht_uformat_viewer::reloadpalette() { ht_format_viewer::reloadpalette(); free(tagpal.data); tagpal.data = NULL; load_pal(palclasskey_tags, palkey_tags_default, &tagpal); } uint ht_uformat_viewer::render_tagstring(char *chars, vcp *colors, uint maxlen, char *tagstring, bool cursor_in_line) { char *n = tagstring; uint c = 0; int i = 0, g = 0; bool is_cursor; vcp color_normal = getcolor(palidx_generic_body); do { int l = 0; while (n[l] && n[l] != '\e') l++; c += render_tagstring_single(chars, colors, maxlen, c, n, l, color_normal); n += l; is_cursor = cursor_in_line && i == cursor.tag_idx; if (*n == '\e') { FileOfs tag_offset; vcp tag_color; char str[64]; switch (n[1]) { case HT_TAG_EDIT_BYTE: { byte d; tag_offset = tag_get_offset(n); tag_color = get_tag_color_edit(tag_offset, 1, focused && (g==cursor.tag_group), is_cursor); if (pread(tag_offset, &d, 1) == 1) { ht_snprintf(str, sizeof str, "%02x", d); } else { strcpy(str, "??"); } c += render_tagstring_single(chars, colors, maxlen, c, str, 2, tag_color); n += HT_TAG_EDIT_BYTE_LEN; break; } case HT_TAG_EDIT_WORD_LE: { uint16 d; tag_offset = tag_get_offset(n); tag_color = get_tag_color_edit(tag_offset, 2, (g==cursor.tag_group), is_cursor); byte buf[2]; if (pread(tag_offset, &buf, 2) == 2) { /* little endian */ d = (buf[1] << 8) | buf[0]; ht_snprintf(str, sizeof str, "%04x", d); } else { strcpy(str, "????"); } c += render_tagstring_single(chars, colors, maxlen, c, str, 4, tag_color); n += HT_TAG_EDIT_WORD_LE_LEN; break; } case HT_TAG_EDIT_DWORD_LE: { uint32 d; tag_offset=tag_get_offset(n); tag_color=get_tag_color_edit(tag_offset, 4, (g==cursor.tag_group), is_cursor); byte buf[4]; if (pread(tag_offset, &buf, 4) == 4) { /* little endian */ d = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0]; ht_snprintf(str, sizeof str, "%08x", d); } else { strcpy(str, "????????"); } c += render_tagstring_single(chars, colors, maxlen, c, str, 8, tag_color); n += HT_TAG_EDIT_DWORD_LE_LEN; break; } case HT_TAG_EDIT_QWORD_LE: { uint64 q; tag_offset = tag_get_offset(n); tag_color = get_tag_color_edit(tag_offset, 8, (g==cursor.tag_group), is_cursor); byte buf[8]; if (pread(tag_offset, &buf, 8)==8) { /* little endian */ q = ((uint64)buf[7] << 56) | ((uint64)buf[6] << 48) | ((uint64)buf[5] << 40) | ((uint64)buf[4] << 32) | ((uint64)buf[3] << 24) | ((uint64)buf[2] << 16) | ((uint64)buf[1] << 8) | (uint64)buf[0]; ht_snprintf(str, sizeof str, "%016qx", q); } else { strcpy(str, "????????????????"); } c += render_tagstring_single(chars, colors, maxlen, c, str, 16, tag_color); n += HT_TAG_EDIT_QWORD_LE_LEN; break; } case HT_TAG_EDIT_WORD_BE: { uint16 d; tag_offset = tag_get_offset(n); tag_color = get_tag_color_edit(tag_offset, 2, (g==cursor.tag_group), is_cursor); byte buf[2]; if (pread(tag_offset, &buf, 2)==2) { /* big endian */ d = (buf[0] << 8) | buf[1]; ht_snprintf(str, sizeof str, "%04x", d); } else { strcpy(str, "????"); } c += render_tagstring_single(chars, colors, maxlen, c, str, 4, tag_color); n += HT_TAG_EDIT_WORD_BE_LEN; break; } case HT_TAG_EDIT_DWORD_BE: { uint32 d; tag_offset = tag_get_offset(n); tag_color = get_tag_color_edit(tag_offset, 4, (g==cursor.tag_group), is_cursor); byte buf[4]; if (pread(tag_offset, &buf, 4) == 4) { /* big endian */ d = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; ht_snprintf(str, sizeof str, "%08x", d); } else { strcpy(str, "????????"); } c += render_tagstring_single(chars, colors, maxlen, c, str, 8, tag_color); n += HT_TAG_EDIT_DWORD_BE_LEN; break; } case HT_TAG_EDIT_QWORD_BE: { uint64 q; tag_offset = tag_get_offset(n); tag_color = get_tag_color_edit(tag_offset, 8, (g==cursor.tag_group), is_cursor); byte buf[8]; if (pread(tag_offset, &buf, 8) == 8) { /* big endian */ q = ((uint64)buf[0] << 56) | ((uint64)buf[1] << 48) | ((uint64)buf[2] << 40) | ((uint64)buf[3] << 32) | ((uint64)buf[4] << 24) | ((uint64)buf[5] << 16) | ((uint64)buf[6] << 8) | (uint64)buf[7]; ht_snprintf(str, sizeof str, "%016qx", q); } else { strcpy(str, "????????????????"); } c += render_tagstring_single(chars, colors, maxlen, c, str, 16, tag_color); n += HT_TAG_EDIT_QWORD_BE_LEN; break; } case HT_TAG_EDIT_TIME_LE: case HT_TAG_EDIT_TIME_BE: { uint32 d; tag_offset = tag_get_offset(n); tag_color = get_tag_color_edit(tag_offset, 4, (g==cursor.tag_group), is_cursor); byte buf[4]; if (pread(tag_offset, &buf, 4) == 4) { if (n[1] == HT_TAG_EDIT_TIME_LE) { d = (buf[3]<<24) | (buf[2]<<16) | (buf[1]<<8) | buf[0]; } else { d = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; } time_t tt = d; tm *t = gmtime(&tt); sprintf(str, "%02d:%02d:%02d %02d.%02d.%04d +1900", t->tm_hour, t->tm_min, t->tm_sec, t->tm_mday, t->tm_mon+1, t->tm_year); } else { strcpy(str, "?"); } c += render_tagstring_single(chars, colors, maxlen, c, str, strlen(str), tag_color); n += HT_TAG_EDIT_TIME_LE_LEN; break; } case HT_TAG_EDIT_CHAR: { char d; tag_offset = tag_get_offset(n); tag_color = get_tag_color_edit(tag_offset, 1, (g==cursor.tag_group), is_cursor); if (pread(tag_offset, &d, 1) != 1) { d = '?'; } c += render_tagstring_single(chars, colors, maxlen, c, &d, 1, tag_color); n += HT_TAG_EDIT_CHAR_LEN; break; } case HT_TAG_EDIT_BIT: { int shift = ((ht_tag_edit_bit*)n)->bitidx; int op = shift/8; byte d; tag_offset=tag_get_offset(n); tag_color=getcolor_tag(palidx_tags_edit_tag); bool isdirty = false; FileOfs o = IS_DIRTY_SINGLEBIT | (shift & 7); file->cntl(FCNTL_MODS_IS_DIRTY, tag_offset+op, o, &isdirty); if (isdirty) tag_color = mixColors(tag_color, getcolor_tag(palidx_tags_edit_tag_modified)); if (tag_offset >= sel_start && tag_offset < sel_end) tag_color = mixColors(tag_color, getcolor_tag(palidx_tags_edit_tag_selected)); if (is_cursor) tag_color = mixColors(tag_color, getcolor_tag(edit() ? palidx_tags_edit_tag_cursor_edit : palidx_tags_edit_tag_cursor_select)); if (pread(tag_offset+op, &d, 1)==1) { str[0]=(d& (1 << (shift%8))) ? '1' : '0'; str[1]=0; } else { strcpy(str, "?"); } c += render_tagstring_single(chars, colors, maxlen, c, str, 1, tag_color); n += HT_TAG_EDIT_BIT_LEN; break; } case HT_TAG_EDIT_SELVIS: { tag_offset=tag_get_offset(n); tag_color=getcolor_tag(palidx_tags_edit_tag); if (tag_offset >= sel_start && tag_offset < sel_end) tag_color = mixColors(tag_color, getcolor_tag(palidx_tags_edit_tag_selected)); c += render_tagstring_single(chars, colors, maxlen, c, &((ht_tag_edit_selvis*)n)->ch, 1, tag_color); n += HT_TAG_EDIT_SELVIS_LEN; continue; } case HT_TAG_SEL: { int tag_textlen = tag_get_seltextlen(n); if (is_cursor) { tag_color = getcolor_tag( (focused && (g == cursor.tag_group)) ? palidx_tags_sel_tag_cursor_focused : palidx_tags_sel_tag_cursor_unfocused ); } else { tag_color = getcolor_tag(palidx_tags_sel_tag); } n += HT_TAG_SEL_LEN(0); c += render_tagstring_single(chars, colors, maxlen, c, n, tag_textlen, tag_color); n += tag_textlen; break; } case HT_TAG_DESC_BYTE: { const char *str; int l; render_tagstring_desc(&str, &l, &tag_color, n, 1, true, is_cursor); c += render_tagstring_single(chars, colors, maxlen, c, str, l, tag_color); n += HT_TAG_DESC_BYTE_LEN; break; } case HT_TAG_DESC_WORD_LE: { const char *str; int l; render_tagstring_desc(&str, &l, &tag_color, n, 2, false, is_cursor); c += render_tagstring_single(chars, colors, maxlen, c, str, l, tag_color); n += HT_TAG_DESC_WORD_LE_LEN; break; } case HT_TAG_DESC_DWORD_LE: { const char *str; int l; render_tagstring_desc(&str, &l, &tag_color, n, 4, false, is_cursor); c += render_tagstring_single(chars, colors, maxlen, c, str, l, tag_color); n += HT_TAG_DESC_DWORD_LE_LEN; break; } case HT_TAG_DESC_QWORD_LE: { const char *str; int l; render_tagstring_desc(&str, &l, &tag_color, n, 8, false, is_cursor); c += render_tagstring_single(chars, colors, maxlen, c, str, l, tag_color); n += HT_TAG_DESC_QWORD_LE_LEN; break; } case HT_TAG_DESC_WORD_BE: { const char *str; int l; render_tagstring_desc(&str, &l, &tag_color, n, 2, true, is_cursor); c += render_tagstring_single(chars, colors, maxlen, c, str, l, tag_color); n += HT_TAG_DESC_WORD_BE_LEN; break; } case HT_TAG_DESC_DWORD_BE: { const char *str; int l; render_tagstring_desc(&str, &l, &tag_color, n, 4, true, is_cursor); c += render_tagstring_single(chars, colors, maxlen, c, str, l, tag_color); n += HT_TAG_DESC_DWORD_BE_LEN; break; } case HT_TAG_DESC_QWORD_BE: { const char *str; int l; render_tagstring_desc(&str, &l, &tag_color, n, 8, true, is_cursor); c += render_tagstring_single(chars, colors, maxlen, c, str, l, tag_color); n += HT_TAG_DESC_DWORD_BE_LEN; break; } case HT_TAG_FLAGS: n += HT_TAG_FLAGS_LEN; tag_color = getcolor_tag(palidx_tags_sel_tag); if (is_cursor) tag_color = getcolor_tag(palidx_tags_sel_tag_cursor_focused); c += render_tagstring_single(chars, colors, maxlen, c, "details", 7, tag_color); break; case HT_TAG_GROUP: n += HT_TAG_GROUP_LEN; g++; i = 0; continue; case HT_TAG_COLOR: color_normal = tag_get_color(n); if (color_normal == -1) { color_normal = getcolor(palidx_generic_body); } n += HT_TAG_COLOR_LEN; continue; default: { assert(0); } } } i++; } while (*n); return c; } uint ht_uformat_viewer::render_tagstring_single(char *chars, vcp *colors, uint maxlen, uint offset, const char *text, uint len, vcp color) { if (offset >= maxlen) { return 0; } maxlen -= offset; if (chars) chars += offset; if (colors) colors += offset; uint l = MIN(len, maxlen); uint r = 0; while (l--) { if (chars) *chars++ = *text++; if (colors) *colors++ = color; r++; } return r; } #define MAX_PRINT_TAGSTRING_LINELENGTH 256 void ht_uformat_viewer::print_tagstring(int x, int y, int maxlen, int xscroll, char *tagstring, bool cursor_in_line) { char text[MAX_PRINT_TAGSTRING_LINELENGTH]; char *t = text+xscroll; vcp color[MAX_PRINT_TAGSTRING_LINELENGTH]; vcp *c = color+xscroll; int l = render_tagstring(text, color, (maxlen+xscroll+1 > MAX_PRINT_TAGSTRING_LINELENGTH) ? MAX_PRINT_TAGSTRING_LINELENGTH : maxlen+xscroll+1, tagstring, cursor_in_line); if (l > xscroll) { l -= xscroll; while (l--) { if (x >= size.w) { buf->printChar(x-1, y, VCP(VC_GREEN, VC_TRANSPARENT), '>'); break; } buf->printChar(x, y, *c, (unsigned char)*t); t++; c++; x++; } } } void ht_uformat_viewer::select_mode_off() { if (cursor_select) { cursor_select = 0; } } void ht_uformat_viewer::select_mode_on() { if (!cursor_select) { cursor_select = 1; } } void ht_uformat_viewer::select_mode_pre() { if (cursor_select) { if (cursor_tag_class == tag_class_edit) { cursor_select_start = cursor_tag_offset; } else { cursor_select_start = (sel_end > sel_start) ? sel_end : -1ULL; } if (!get_current_tag_size(&cursor_select_cursor_length)) { cursor_select_cursor_length = -1; } } } void ht_uformat_viewer::select_mode_post(bool lastpos) { if (cursor_select) { if (cursor_select_start != -1ULL) { if (cursor_tag_class == tag_class_edit) { if (lastpos && cursor_select_cursor_length != uint32(-1)) { FileOfs s, e; pselect_get(&s, &e); if (e != cursor_tag_offset+cursor_select_cursor_length) { pselect_add(cursor_select_start, cursor_tag_offset+cursor_select_cursor_length); } } else { pselect_add(cursor_select_start, cursor_tag_offset); } } else if (cursor_tag_class == tag_class_sel && cursor_select_cursor_length != uint32(-1)) { pselect_add(cursor_select_start, cursor_select_start+cursor_select_cursor_length); } } } } uint ht_uformat_viewer::pwrite(FileOfs ofs, void *buf, uint size) { cursorline_dirty(); return ht_format_viewer::pwrite(ofs, buf, size); } bool ht_uformat_viewer::ref() { cursorline_get(); char *e = tag_get_selectable_tag(cursor_line, cursor.tag_idx, cursor.tag_group); if (!e) return false; if (tag_get_class(e) == tag_class_sel) { if (!cursor.sub->ref(&cursor_tag_id.id)) { switch (e[1]) { case HT_TAG_SEL: return ref_sel(&cursor_tag_id.id); case HT_TAG_FLAGS: return ref_flags(((ht_tag_flags*)e)->id, ((ht_tag_flags*)e)->offset); case HT_TAG_DESC_BYTE: return ref_desc(((ht_tag_desc_byte*)e)->id, ((ht_tag_desc_byte*)e)->offset, 1, true); case HT_TAG_DESC_WORD_LE: return ref_desc(((ht_tag_desc_byte*)e)->id, ((ht_tag_desc_byte*)e)->offset, 2, false); case HT_TAG_DESC_DWORD_LE: return ref_desc(((ht_tag_desc_byte*)e)->id, ((ht_tag_desc_byte*)e)->offset, 4, false); case HT_TAG_DESC_QWORD_LE: return ref_desc(((ht_tag_desc_byte*)e)->id, ((ht_tag_desc_byte*)e)->offset, 8, false); case HT_TAG_DESC_WORD_BE: return ref_desc(((ht_tag_desc_byte*)e)->id, ((ht_tag_desc_byte*)e)->offset, 2, true); case HT_TAG_DESC_DWORD_BE: return ref_desc(((ht_tag_desc_byte*)e)->id, ((ht_tag_desc_byte*)e)->offset, 4, true); case HT_TAG_DESC_QWORD_BE: return ref_desc(((ht_tag_desc_byte*)e)->id, ((ht_tag_desc_byte*)e)->offset, 8, true); } } } return false; } bool ht_uformat_viewer::ref_desc(ID id, FileOfs offset, uint size, bool bigendian) { Endianess end = bigendian ? big_endian : little_endian; int_hash *desc=(int_hash*)getAtomValue(id); if (desc) { byte buf[4]; if (pread(offset, buf, size) != size) return false; Bounds b; b.w = 60; b.h = 14; b.x = (screen->w - b.w)/2; b.y = (screen->h - b.h)/2; ht_dialog *g=new ht_dialog(); g->init(&b, "desc", FS_KILLER | FS_MOVE); b.x = 0; b.y = 0; b.w -= 2; b.h -= 2; ht_itext_listbox *l = new ht_itext_listbox(); l->init(&b, 2, 1); int curpos = 0; int i = 0; int d = 0; switch (size) { case 1: d = buf[0]; break; case 2: if (bigendian) { d=(buf[0]<<8) | buf[1]; } else { d=(buf[1]<<8) | buf[0]; } break; case 4: if (bigendian) { d=(buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3]; } else { d=(buf[3]<<24) | (buf[2]<<16) | (buf[1]<<8) | buf[0]; } break; } int_hash *dsc = desc; while (dsc->desc) { char buf[32]; switch (size) { case 1: sprintf(buf, "0x%02x", dsc->value); break; case 2: sprintf(buf, "0x%04x", dsc->value); break; case 4: sprintf(buf, "0x%08x", dsc->value); break; } if (dsc->value == d) { curpos = i; } l->insert_str(i, buf, dsc->desc); dsc++; i++; } l->update(); l->gotoItemByPosition(curpos); g->insert(l); g->setpalette(palkey_generic_window_default); if (g->run(false) == button_ok) { ht_listbox_data da; ViewDataBuf vdb(l, &da, sizeof da); int i = l->getID(da.data->cursor_ptr); if (desc[i].value != d) { baseview->sendmsg(cmd_edit_mode_i, file, NULL); if (edit()) { byte buf[4]; uint v = desc[i].value; createForeignInt(buf, v, size, end); pwrite(offset, buf, size); dirtyview(); } } } g->done(); delete g; return true; } return false; } bool ht_uformat_viewer::ref_flags(ID id, FileOfs offset) { ht_tag_flags_s *flags = (ht_tag_flags_s*)getAtomValue(id); if (flags) { Bounds b; b.w = 60; b.h = 14; b.x = (screen->w-b.w)/2; b.y = (screen->h-b.h)/2; ht_dialog *d = new ht_dialog(); d->init(&b, (flags->bitidx==-1) ? flags->desc : 0, FS_KILLER | FS_TITLE | FS_MOVE); b.x = 0; b.y = 0; b.w -= 2; b.h -= 2; ht_uformat_viewer *u = new ht_uformat_viewer(); u->init(&b, 0, VC_EDIT, file, 0); ht_mask_sub *m = new ht_mask_sub(); m->init(file, 0); char *t, x[256]; int width = 0; ht_tag_flags_s *fl = flags; if (fl->bitidx == -1) fl++; do { int l = strlen(fl->desc); if (l > width) width = l; fl++; } while (fl->desc); width = MAX(width, 25); width++; fl = flags; if (fl->bitidx == -1) fl++; do { t = x; int l = strlen(fl->desc); memcpy(t, fl->desc, l); t += l; while (t < x+width) *(t++) = ' '; t = tag_make_edit_bit(t, sizeof x, offset, fl->bitidx); *t = 0; m->add_mask(x); fl++; } while (fl->desc); u->insertsub(m); u->sendmsg(msg_complete_init, 0); d->insert(u); d->setpalette(palkey_generic_window_default); uint pmode = file->getAccessMode() & IOAM_WRITE; if (d->run(false) == button_ok) u->edit_update(); if (pmode != (file->getAccessMode() & IOAM_WRITE)) { if (pmode) { baseview->sendmsg(cmd_view_mode_i, file, NULL); } else { baseview->sendmsg(cmd_edit_mode_i, file, NULL); } } d->done(); delete d; return true; } return false; } bool ht_uformat_viewer::ref_sel(LINE_ID *id) { return false; } ht_search_result *ht_uformat_viewer::psearch(ht_search_request *request, FileOfs start, FileOfs end) { if (request != last_search_request) { delete last_search_request; last_search_request = request->clone(); } last_search_physical = true; last_search_end_ofs = end; ht_sub *sub=first_sub; while (sub) { ht_search_result *r = sub->search(request, start, end); if (r) return r; sub = sub->next; } return NULL; } ht_search_result *ht_uformat_viewer::vsearch(ht_search_request *request, viewer_pos start, viewer_pos end) { if (request != last_search_request) { delete last_search_request; last_search_request = request->clone(); } last_search_physical = false; last_search_end_pos = end; if (request->search_class == SC_VISUAL && request->type == ST_REGEX) { if (!cursor.sub) return 0; ht_regex_search_request *s=(ht_regex_search_request*)request; /* build progress indicator */ Bounds b; get_std_progress_indicator_metrics(&b); ht_progress_indicator *progress_indicator=new ht_progress_indicator(); progress_indicator->init(&b, "ESC to cancel"); uint lines=0; uformat_viewer_pos p = start.u; while (p.sub) { do { char line[1024]; if (!p.sub->getline(line, sizeof line, p.line_id)) assert(0); char rdrd[256]; int c = render_tagstring(rdrd, 0, sizeof rdrd-1, line, 0); rdrd[c] = 0; regmatch_t pos; if (!regexec(&s->rx, rdrd, 1, &pos, 0)) { ht_visual_search_result *r = new ht_visual_search_result(); r->pos.u = p; r->xpos = pos.rm_so; r->length = pos.rm_eo-pos.rm_so; progress_indicator->done(); delete progress_indicator; return r; } lines++; if (lines % 500==0) { if (keyb_keypressed()) { if (keyb_getkey() == K_Escape) goto leave; } char text[256]; /* if (highest_va>lowest_va) { int p=100*((double)(va-lowest_va))/(highest_va-lowest_va); sprintf(text, "searching for '%s'... %d%% complete (%d lines)", s->rx_str, p, lines); } else*/ { ht_snprintf(text, sizeof text, "searching for '%s'... %d lines", s->rx_str, lines); } progress_indicator->settext(text); progress_indicator->sendmsg(msg_draw, 0); screen->show(); } } while (p.sub->next_line_id(&p.line_id, 1)); p.sub = p.sub->next; if (p.sub) p.sub->first_line_id(&p.line_id); } leave: progress_indicator->done(); delete progress_indicator; } return NULL; } void ht_uformat_viewer::pselect_add(FileOfs start, FileOfs end) { bool downward = (startsel_end) { FileOfs temp=sel_start; sel_start=sel_end; sel_end=temp; } } void ht_uformat_viewer::pselect_get(FileOfs *start, FileOfs *end) { *start=sel_start; *end=sel_end; } void ht_uformat_viewer::pselect_set(FileOfs start, FileOfs end) { sel_start=start; sel_end=end; } void ht_uformat_viewer::clear_subs() { ht_sub *s = first_sub, *t; while (s) { t = s->next; s->done(); delete s; s = t; } uf_initialized = false; cursor_ypos = 0; clear_viewer_pos(&top); clear_viewer_pos(&cursor); first_sub = 0; last_sub = 0; } void ht_uformat_viewer::clear_viewer_pos(viewer_pos *p) { clear_viewer_pos(&p->u); } void ht_uformat_viewer::clear_viewer_pos(uformat_viewer_pos *p) { p->sub = NULL; clear_line_id(&p->line_id); p->tag_idx = 0; p->tag_group = 0; } bool ht_uformat_viewer::compeq_viewer_pos(viewer_pos *a, viewer_pos *b) { return compeq_viewer_pos(&a->u, &b->u); } bool ht_uformat_viewer::compeq_viewer_pos(uformat_viewer_pos *a, uformat_viewer_pos *b) { return (a->sub == b->sub && compeq_line_id(a->line_id, b->line_id) && a->tag_idx == b->tag_idx && a->tag_group == b->tag_group); } void ht_uformat_viewer::sendsubmsg(int msg) { htmsg m; m.msg = msg; sendsubmsg(&m); } void ht_uformat_viewer::sendsubmsg(htmsg *msg) { if (msg->type == mt_broadcast) { ht_sub *s = first_sub; while (s) { s->handlemsg(msg); s=s->next; } } else cursor.sub->handlemsg(msg); } bool ht_uformat_viewer::set_cursor(uformat_viewer_pos p) { int scrolloff = MIN(scroll_offset, size.h/2); cursorline_dirty(); uformat_viewer_pos t = top; int ty = 0; bool on_screen = false; bool half_screen_above = false; bool half_screen_below = false; if (cursor_state != cursor_state_visible) { return false; } while (ty < scrolloff && next_line(&t, 1)) { ty++; } while (prev_line(&t, 1) && ty-- > -size.h/2) { if (t.sub == p.sub && compeq_line_id(t.line_id, p.line_id)) { half_screen_above = true; break; } } if (!half_screen_above) { t = top; ty = 0; do { if (t.sub == p.sub && compeq_line_id(t.line_id, p.line_id)) { if (ty < size.h - scrolloff) { on_screen = true; } else { half_screen_below = true; } break; } } while (next_line(&t, 1) && ty++ < size.h*3/2); } char line[1024]; char *e; p.sub->getline(line, sizeof line, p.line_id); e = tag_get_selectable_tag(line, 0, 0); if (!e) return false; cursor = p; if (p.tag_group != -1) cursor.tag_group = p.tag_group; adjust_cursor_group(); if (p.tag_idx != -1) cursor.tag_idx = p.tag_idx; adjust_cursor_idx(); if (on_screen) { cursor_ypos = ty; } else if (half_screen_above) { cursor_ypos = scrolloff; top = p; ty = 0; while (ty < scrolloff && prev_line(&top, 1)) { ty++; } } else if (half_screen_below) { cursor_ypos = size.h - 1; while (next_line(&top, 1) && (ty-- > size.h-scrolloff)) {} } else { ty = 0; top = p; while (prev_line(&top, 1) && (ty++ < size.h/2-1)) { } cursor_ypos=size.h/2-1; } update_misc_info(); update_visual_info(); check_cursor_visibility(); cursorline_dirty(); dirtyview(); return true; } void ht_uformat_viewer::scroll_up(int n) { cursor_ypos += prev_line(&top, n); cursorline_dirty(); check_cursor_visibility(); } void ht_uformat_viewer::scroll_down(int n) { cursor_ypos -= next_line(&top, n); cursorline_dirty(); check_cursor_visibility(); } bool ht_uformat_viewer::qword_to_offset(uint64 q, FileOfs *ofs) { *ofs = q; return true; } void ht_uformat_viewer::update_micropos() { cursorline_get(); char *e=tag_get_selectable_tag(cursor_line, cursor.tag_idx, cursor.tag_group); if (e) { int s=tag_get_microsize(e); if (cursor_tag_micropos>=s) cursor_tag_micropos=s-1; } } void ht_uformat_viewer::update_misc_info() { cursorline_get(); char *e = tag_get_selectable_tag(cursor_line, cursor.tag_idx, cursor.tag_group); if (e) { cursor_tag_class = tag_get_class(e); switch (cursor_tag_class) { case tag_class_edit: cursor_tag_offset = tag_get_offset(e); break; case tag_class_sel: clear_line_id(&cursor_tag_id.id); tag_get_id(e, &cursor_tag_id.id.id1, &cursor_tag_id.id.id2, &cursor_tag_id.id.id3, &cursor_tag_id.id.id4); break; } } } void ht_uformat_viewer::update_visual_info() { cursorline_get(); const char *s, *t = cursor_line; int v = 0, vl = 0; int i = 0, g = 0; while ((s=tag_findnext(t))) { int cl = tag_get_class(s); if (s[1] == HT_TAG_GROUP) { i = 0; g++; } v += s-t; vl = tag_get_vlen(s); if (i == cursor.tag_idx && g == cursor.tag_group && cl != tag_class_no) break; v += vl; t = s+tag_get_len(s); if (cl != tag_class_no) i++; } if (cursor_tag_micropos > vl-1) cursor_tag_micropos = vl ? vl-1 : 0; cursor_visual_xpos = v; cursor_visual_length = vl; } void ht_uformat_viewer::update_ypos() { uformat_viewer_pos p = top; int y = 0; while (next_line(&p, 1) && y < size.h) { if (compeq_viewer_pos(&p, &cursor)) { cursor_ypos = y; break; } y++; } } void ht_uformat_viewer::vstate_restore(Object *data) { ht_uformat_viewer_vstate *vs = (ht_uformat_viewer_vstate*)data; first_sub = vs->first_sub; last_sub = vs->last_sub; /* top line position */ top = vs->top; /* cursor line and tag position */ cursor = vs->cursor; cursor_state = vs->cursor_state; cursor_ypos = vs->cursor_ypos; /* selection*/ sel_start = vs->sel_start; sel_end = vs->sel_end; /**/ cursorline_dirty(); update_misc_info(); update_visual_info(); } Object *ht_uformat_viewer::vstate_create() { ht_uformat_viewer_vstate *vs = new ht_uformat_viewer_vstate(); vs->first_sub = first_sub; vs->last_sub = last_sub; /* top line position */ vs->top = top; /* cursor line and tag position */ vs->cursor = cursor; vs->cursor_state = cursor_state; vs->cursor_ypos = cursor_ypos; /* selection*/ vs->sel_start = sel_start; vs->sel_end = sel_end; /**/ return vs; } /* * CLASS ht_sub */ void ht_sub::init(File *f) { Object::init(); uformat_viewer=NULL; prev=NULL; next=NULL; file=f; } bool ht_sub::closest_line_id(LINE_ID *line_id) { first_line_id(line_id); return true; } bool ht_sub::convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id) { return false; } bool ht_sub::convert_id_to_ofs(const LINE_ID line_id, FileOfs *offset) { return false; } bool ht_sub::getline(char *line, int maxlen, const LINE_ID line_id) { return false; } void ht_sub::handlemsg(htmsg *msg) { } void ht_sub::first_line_id(LINE_ID *line_id) { } void ht_sub::last_line_id(LINE_ID *line_id) { } int ht_sub::prev_line_id(LINE_ID *line_id, int n) { return 0; } int ht_sub::next_line_id(LINE_ID *line_id, int n) { return 0; } bool ht_sub::ref(LINE_ID *id) { return false; } ht_search_result *ht_sub::search(ht_search_request *search, FileOfs start, FileOfs end) { return NULL; } /* * CLASS ht_linear_sub */ void ht_linear_sub::init(File *f, FileOfs ofs, FileOfs size) { ht_sub::init(f); fofs = ofs; fsize = size; } void ht_linear_sub::handlemsg(htmsg *msg) { if (msg->msg == msg_filesize_changed) { FileOfs s = file->getSize(); if (fofs > s) { fsize = 0; } else if (fofs+fsize > s) { fsize = s-fofs; } return; } } static int ht_linear_func_readbyte(eval_scalar *result, eval_int *offset) { struct context_t { ht_linear_sub *sub; ht_format_viewer *fv; int i, o; }; ht_format_viewer *f=((context_t*)eval_get_context())->fv; byte b; if (f->pread(offset->value, &b, 1) != 1) { set_eval_error("i/o error (requested %d, read %d from ofs 0x%08qx)", 1, 0, offset->value); return 0; } scalar_create_int_c(result, b); return 1; } static int ht_linear_func_readstring(eval_scalar *result, eval_int *offset, eval_int *len) { struct context_t { ht_linear_sub *sub; ht_format_viewer *fv; int i, o; }; ht_format_viewer *f = ((context_t*)eval_get_context())->fv; uint l = len->value; void *buf = malloc(l); /* FIXME: may be too slow... */ if (buf) { eval_str s; uint c = f->pread(offset->value, buf, l); if (c != l) { free(buf); set_eval_error("i/o error (requested %d, read %d from ofs 0x%08qx)", l, c, offset->value); return 0; } s.value = (char*)buf; s.len = l; scalar_create_str(result, &s); free(buf); return 1; } set_eval_error("out of memory"); return 0; } static int ht_linear_func_entropy(eval_scalar *result, eval_str *buf) { scalar_create_int_c(result, calc_entropy2((byte *)buf->value, buf->len)); return 1; } static int ht_linear_func_entropy2(eval_scalar *result, eval_str *buf) { scalar_create_float_c(result, calc_entropy((byte *)buf->value, buf->len)); return 1; } struct search_expr_eval_context_t { ht_sub *sub; ht_format_viewer *fv; FileOfs i, o; }; static bool ht_linear_sub_func_handler(eval_scalar *result, char *name, eval_scalarlist *params) { eval_func myfuncs[] = { {"entropy", (void*)&ht_linear_func_entropy, {SCALAR_STR}}, {"entropy2", (void*)&ht_linear_func_entropy2, {SCALAR_STR}}, {"readbyte", (void*)&ht_linear_func_readbyte, {SCALAR_INT}}, {"readstring", (void*)&ht_linear_func_readstring, {SCALAR_INT, SCALAR_INT}}, {NULL} }; return std_eval_func_handler(result, name, params, myfuncs); } static bool ht_linear_sub_symbol_handler(eval_scalar *result, char *name) { search_expr_eval_context_t *context = (search_expr_eval_context_t*)eval_get_context(); if (strcmp(name, "i")==0) { scalar_create_int_q(result, context->i); return true; } else if (strcmp(name, "o")==0) { scalar_create_int_q(result, context->o); return true; } else return false; } class ht_expr_search_pcontext: public Object { public: /* in */ ht_search_request *request; ht_sub *sub; ht_format_viewer *fv; FileOfs start; FileOfs end; int i; FileOfs o; /* out */ ht_search_result **result; }; bool process_search_expr(Object *ctx, ht_text *progress_indicator) { #define PROCESS_EXPR_SEARCH_BYTES_PER_CALL 256 ht_expr_search_pcontext *c = (ht_expr_search_pcontext*)ctx; ht_expr_search_request *s = (ht_expr_search_request*)c->request; search_expr_eval_context_t context; context.sub = c->sub; context.fv = c->fv; int w = PROCESS_EXPR_SEARCH_BYTES_PER_CALL; while (c->o < c->end) { eval_scalar r; context.i = c->i; context.o = c->o; if (eval(&r, s->expr, ht_linear_sub_func_handler, ht_linear_sub_symbol_handler, &context)) { eval_int i; scalar_context_int(&r, &i); if (i.value != 0) { ht_physical_search_result *r=new ht_physical_search_result(); r->offset = c->o; r->size = 1; *c->result = r; return false; } } else { const char *str; int pos; get_eval_error(&str, &pos); throw MsgfException("eval error at pos %d: %s", pos, str); } c->i++; c->o++; if (!--w) { char text[64]; if (c->end > c->start) { ht_snprintf(text, 100, "%qd %% done", (c->o - c->start) * 100 / (c->end - c->start)); } else { strcpy(text, "? % done"); } progress_indicator->settext(text); return true; } } return false; } ht_search_result *linear_expr_search(ht_search_request *search, FileOfs start, FileOfs end, ht_sub *sub, ht_uformat_viewer *ufv, FileOfs fofs, FileOfs fsize) { if (start < fofs) start = fofs; if (end > fofs + fsize) end = fofs+fsize; if (fsize) { ht_search_result *r = NULL; ht_expr_search_pcontext c; c.request = search; c.sub = sub; c.fv =ufv; c.start = start; c.end = end; c.result = &r; c.i = 0; c.o = start; if (execute_process(process_search_expr, &c)) return r; } return NULL; } ht_search_result *ht_linear_sub::search(ht_search_request *search, FileOfs start, FileOfs end) { ht_search_result *r = NULL; if (search->search_class == SC_PHYSICAL && search->type == ST_EXPR) { r = linear_expr_search(search, start, end, this, uformat_viewer, fofs, fsize); } else if (search->search_class == SC_PHYSICAL && search->type == ST_FXBIN) { r = linear_bin_search(search, start, end, file, fofs, fsize); } return r; } /* * CLASS ht_hex_sub */ void ht_hex_sub::init(File *f, FileOfs ofs, FileOfs size, uint Line_length, uint u, int Disp) { line_length = Line_length; ht_linear_sub::init(f, ofs, size); if (Disp == -1) { disp = line_length - ofs % line_length; if (disp == line_length) disp = 0; } else { disp = Disp; } uid = u; } int ht_hex_sub::get_line_length() { return line_length; } void ht_hex_sub::set_line_length(uint Line_length) { if (Line_length > 0 && Line_length > disp) { line_length = Line_length; } } int ht_hex_sub::get_disp() { return disp; } void ht_hex_sub::set_disp(uint Disp) { if (Disp >= 0 && Disp < line_length) { disp = Disp; } } bool ht_hex_sub::convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id) { if (offset >= fofs && offset < fofs+fsize) { clear_line_id(line_id); FileOfs o = offset - fofs; FileOfs begin; if (o < disp) { begin = 0; } else { begin = o - (o - disp)%line_length; } line_id->id1 = begin >> 32; line_id->id2 = begin; line_id->id3 = uid; return true; } return false; } bool ht_hex_sub::convert_id_to_ofs(const LINE_ID line_id, FileOfs *ofs) { *ofs = (uint64(line_id.id1) << 32) + line_id.id2 + fofs; return true; } bool ht_hex_sub::getline(char *line, int maxlen, const LINE_ID line_id) { if (line_id.id3 != uid || maxlen < 1) return false; FileOfs ofs = (uint64(line_id.id1) << 32) + line_id.id2; uint c = MIN(uint64(line_length), fsize - ofs); if (c <= 0) return false; char *l = line; char *l_end = line+maxlen-1; l += ht_snprintf(l, l_end - l, "%08qx ", ofs + fofs); uint start = 0; if (ofs < disp) { start = line_length - disp; } uint end = line_length; if (c < line_length - start) { end = start + c; } ofs -= start; ofs += fofs; for (uint i = 0; i < line_length; i++) { if (i >= start && i < end) { l = tag_make_edit_byte(l, l_end - l, ofs); } else { l += ht_snprintf(l, l_end - l, " "); } if (i+1 > start && i+1 < end) { if (i%8 == 7) { l = tag_make_edit_selvis(l, l_end-l, ofs, '-'); } else { l = tag_make_edit_selvis(l, l_end-l, ofs, ' '); } } else { l += ht_snprintf(l, l_end - l, " "); } ofs++; } ofs -= line_length; l = tag_make_group(l, l_end-l); l += ht_snprintf(l, l_end - l, "|"); for (uint i=0; i < line_length; i++) { if (i >= start && i < end) { l = tag_make_edit_char(l, l_end-l, ofs); } else { l += ht_snprintf(l, l_end-l , " "); } ofs++; } l += ht_snprintf(l, l_end - l, "|"); *l = 0; return true; } void ht_hex_sub::first_line_id(LINE_ID *line_id) { clear_line_id(line_id); line_id->id1 = 0; line_id->id2 = 0; line_id->id3 = uid; } void ht_hex_sub::last_line_id(LINE_ID *line_id) { clear_line_id(line_id); FileOfs ofs = fsize - 1; if (!fsize || ofs < disp) { ofs = 0; } else { ofs = ofs - (ofs-disp)%line_length; } line_id->id1 = ofs >> 32; line_id->id2 = ofs; line_id->id3 = uid; } int ht_hex_sub::prev_line_id(LINE_ID *line_id, int n) { if (line_id->id3 != uid) return 0; int c = 0; FileOfs o = (uint64(line_id->id1) << 32) + line_id->id2; while (n--) { if (!o) break; if (line_length > o) { o = 0; } else { o -= line_length; } c++; } if (o < disp) { o = 0; } else { o = o - (o-disp)%line_length; } line_id->id1 = o >> 32; line_id->id2 = o; return c; } int ht_hex_sub::next_line_id(LINE_ID *line_id, int n) { if (line_id->id3 != uid) return 0; int c = 0; FileOfs o = (uint64(line_id->id1) << 32) + line_id->id2; if (o < disp && disp < fsize) { o = disp; c++; n--; } while (n--) { if (o + line_length >= fsize) break; o += line_length; c++; } if (o < disp) { o = 0; } else { o = o - (o-disp)%line_length; } line_id->id1 = o >> 32; line_id->id2 = o; return c; } /* * CLASS ht_mask */ void ht_mask_sub::init(File *f, uint u) { ht_sub::init(f); uid = u; } void ht_mask_sub::first_line_id(LINE_ID *line_id) { clear_line_id(line_id); line_id->id1 = 0; line_id->id2 = uid; } bool ht_mask_sub::getline(char *line, int maxlen, const LINE_ID line_id) { if (line_id.id2 != uid) return false; const char *s = ((ht_data_tagstring *)masks[line_id.id1])->value; if (s) { tag_strcpy(line, maxlen, s); return true; } return false; } void ht_mask_sub::last_line_id(LINE_ID *line_id) { clear_line_id(line_id); line_id->id1 = masks.count()-1; line_id->id2 = uid; } int ht_mask_sub::next_line_id(LINE_ID *line_id, int n) { int r=n; if (line_id->id2 != uid) return 0; int c = masks.count(); ID i1 = line_id->id1; i1 += n; if ((int)i1 > c-1) { r -= i1-c+1; i1 = c-1; } if (r) line_id->id1 = i1; return r; } int ht_mask_sub::prev_line_id(LINE_ID *line_id, int n) { int r; if (line_id->id2 != uid) return 0; ID i1 = line_id->id1; if (i1 < (uint32)n) { r = i1; i1 = 0; } else { r = n; i1 -= n; } if (r) line_id->id1 = i1; return r; } void ht_mask_sub::add_mask(const char *tagstr) { masks += new ht_data_tagstring(tagstr); } void ht_mask_sub::add_mask_table(char **tagstr) { while (*tagstr) add_mask(*tagstr++); } void ht_mask_sub::add_staticmask(const char *statictag_str, FileOfs reloc, bool std_bigendian) { char tag_str[1024]; statictag_to_tag(statictag_str, tag_str, sizeof tag_str, reloc, std_bigendian); masks += new ht_data_tagstring(tag_str); } void ht_mask_sub::add_staticmask_table(char **statictag_table, FileOfs reloc, bool std_bigendian) { while (*statictag_table) add_staticmask(*(statictag_table++), reloc, std_bigendian); } #define ht_MASK_STD_INDENT 50 void ht_mask_sub::add_staticmask_ptable(ht_mask_ptable *statictag_ptable, FileOfs reloc, bool std_bigendian) { char s[1024]; /* FIXME: possible buffer overflow */ while (statictag_ptable->desc || statictag_ptable->fields) { s[0] = 0; if (statictag_ptable->desc) strcpy(s, statictag_ptable->desc); int n = strlen(s); while (n < ht_MASK_STD_INDENT) { s[n]=' '; n++; } s[n]=0; if (statictag_ptable->fields) strcat(s, statictag_ptable->fields); add_staticmask(s, reloc, std_bigendian); statictag_ptable++; } } /* * CLASS ht_layer_sub */ void ht_layer_sub::init(File *file, ht_sub *s, bool own_s) { ht_sub::init(file); sub = s; own_sub = own_s; } void ht_layer_sub::done() { if (own_sub) { sub->done(); delete sub; } ht_sub::done(); } bool ht_layer_sub::closest_line_id(LINE_ID *line_id) { return sub->closest_line_id(line_id); } bool ht_layer_sub::convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id) { return sub->convert_ofs_to_id(offset, line_id); } bool ht_layer_sub::convert_id_to_ofs(const LINE_ID line_id, FileOfs *offset) { return sub->convert_id_to_ofs(line_id, offset); } void ht_layer_sub::first_line_id(LINE_ID *line_id) { return sub->first_line_id(line_id); } bool ht_layer_sub::getline(char *line, int maxlen, const LINE_ID line_id) { return sub->getline(line, maxlen, line_id); } void ht_layer_sub::handlemsg(htmsg *msg) { sub->handlemsg(msg); } void ht_layer_sub::last_line_id(LINE_ID *line_id) { return sub->last_line_id(line_id); } int ht_layer_sub::next_line_id(LINE_ID *line_id, int n) { return sub->next_line_id(line_id, n); } int ht_layer_sub::prev_line_id(LINE_ID *line_id, int n) { return sub->prev_line_id(line_id, n); } bool ht_layer_sub::ref(LINE_ID *id) { return sub->ref(id); } ht_search_result *ht_layer_sub::search(ht_search_request *search, FileOfs start, FileOfs end) { return sub->search(search, start, end); } /* * CLASS ht_collapsable_sub */ static ID ht_collapsable_sub_globalfaddr = -1; void ht_collapsable_sub::init(File *file, ht_sub *sub, bool own_sub, const char *ns, bool c) { ht_layer_sub::init(file, sub, own_sub); nodestring = ht_strdup(ns); collapsed = c; ht_layer_sub::first_line_id(&fid); clear_line_id(&myfid); myfid.id1 = 0; myfid.id2 = ht_collapsable_sub_globalfaddr--; } void ht_collapsable_sub::done() { free(nodestring); ht_layer_sub::done(); } bool ht_collapsable_sub::convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id) { /* if (offset==myfaddr) { first_line_id(id1, id2); return true; } else*/ // FIXME: The Right Thing ? if (!collapsed) { return ht_layer_sub::convert_ofs_to_id(offset, line_id); } return false; } bool ht_collapsable_sub::convert_id_to_ofs(const LINE_ID line_id, FileOfs *offset) { return ht_layer_sub::convert_id_to_ofs(line_id, offset); } void ht_collapsable_sub::first_line_id(LINE_ID *line_id) { clear_line_id(line_id); *line_id = myfid; } bool ht_collapsable_sub::getline(char *line, int maxlen, const LINE_ID line_id) { char *l = line; char *l_end = line+maxlen; if (compeq_line_id(line_id, myfid)) { line += ht_snprintf(line, l_end-l, "[%c] ", collapsed ? '+' : '-'); line = tag_make_ref(line, l_end-l, myfid.id1, myfid.id2, 0, 0, nodestring); *line = 0; return true; } else if (collapsed) { return false; } if (ht_layer_sub::getline(line, maxlen, line_id)) { if (maxlen < 3) { return false; } int l = tag_strlen(line)+1; memmove(line+2, line, MIN(l, maxlen-2)); line[0]=' '; line[1]=' '; return true; } return false; } void ht_collapsable_sub::last_line_id(LINE_ID *line_id) { if (collapsed) return first_line_id(line_id); else return ht_layer_sub::last_line_id(line_id); } int ht_collapsable_sub::next_line_id(LINE_ID *line_id, int n) { if (collapsed) return 0; int r=0; LINE_ID t; if (compeq_line_id(*line_id, myfid)) { ht_layer_sub::first_line_id(&t); n--; r++; } else { t = *line_id; } if (n) r+=ht_layer_sub::next_line_id(&t, n); if (r) { *line_id = t; } return r; } int ht_collapsable_sub::prev_line_id(LINE_ID *line_id, int n) { if (collapsed) return 0; if (compeq_line_id(*line_id, myfid)) return 0; int r=ht_layer_sub::prev_line_id(line_id, n); if (compeq_line_id(*line_id, fid) && (rfirst_line_id(line_id); } bool ht_group_sub::getline(char *line, int maxlen, const LINE_ID line_id) { ht_sub *s; uint c = subs->count(); for (uint i=0; igetline(line, maxlen, line_id)) return true; } return false; } void ht_group_sub::handlemsg(htmsg *msg) { ht_sub::handlemsg(msg); } void ht_group_sub::last_line_id(LINE_ID *line_id) { ht_sub *s = (ht_sub*)(*subs)[subs->count()-1]; if (s) s->last_line_id(line_id); } int ht_group_sub::next_line_id(LINE_ID *line_id, int n) { ht_sub *s; uint c=subs->count(); int on=n; for (uint i=0; ilast_line_id(&t); if (compeq_line_id(t, *line_id)) { s=(ht_sub*)(*subs)[i+1]; if (s) { s->first_line_id(line_id); n--; } } else { n-=s->next_line_id(line_id, n); } if (!n) break; } return on-n; } int ht_group_sub::prev_line_id(LINE_ID *line_id, int n) { ht_sub *s; uint c=subs->count(); int on=n; for (uint i=0; ifirst_line_id(&t); if (compeq_line_id(t, *line_id)) { s=(ht_sub*)(*subs)[i-1]; if (s) { s->last_line_id(line_id); n--; } } else { n-=s->prev_line_id(line_id, n); } if (!n) break; } return on-n; } bool ht_group_sub::ref(LINE_ID *id) { foreach(ht_sub, s, *subs, if (s->ref(id)) return true; ); return false; } ht_search_result *ht_group_sub::search(ht_search_request *search, FileOfs start, FileOfs end) { return NULL; } void ht_group_sub::insertsub(ht_sub *sub) { subs->insert(sub); } ht-2.0.22/htneobj.cc0000644000175000001440000000530210615341623011066 00000000000000/* * HT Editor * htneobj.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "atom.h" #include "endianess.h" #include "htnewexe.h" #include "htne.h" #include "htneobj.h" #include "httag.h" #include "strtools.h" #include "formats.h" #include "snprintf.h" #include "nestruct.h" #include #include static ht_mask_ptable neobj[]= { {"offset", STATICTAG_EDIT_WORD_LE("00000000")}, {"size", STATICTAG_EDIT_WORD_LE("00000002")}, {"flags", STATICTAG_EDIT_WORD_LE("00000004")" "STATICTAG_FLAGS("00000004", ATOM_NE_SEGFLAGS_STR)}, {"minalloc", STATICTAG_EDIT_WORD_LE("00000006")}, {0, 0} }; static ht_tag_flags_s ne_segflags[] = { {0, "[00] data"}, {1, "[01] reserved"}, {2, "[02] reserved"}, {3, "[03] iterated"}, {4, "[04] movable"}, {5, "[05] sharable"}, {6, "[06] preload"}, {7, "[07] read only"}, {8, "[08] relocations"}, {9, "[09] conforming"}, {10, "[10] pl0"}, {11, "[11] pl1"}, {12, "[12] discardable"}, {13, "[13] 32bit"}, {14, "[14] huge"}, {15, "[15] reserved"}, {0, 0} }; static ht_view *htnesegments_init(Bounds *b, File *file, ht_format_group *group) { ht_ne_shared_data *ne_shared=(ht_ne_shared_data *)group->get_shared_data(); uint32 h=ne_shared->hdr_ofs; ht_uformat_viewer *v=new ht_uformat_viewer(); v->init(b, DESC_NE_SEGMENTS, VC_EDIT | VC_SEARCH, file, group); ht_mask_sub *m=new ht_mask_sub(); m->init(file, 0); registerAtom(ATOM_NE_SEGFLAGS, ne_segflags); char t[64]; ht_snprintf(t, sizeof t, "* NE segment table at offset 0x%08qx", h+ne_shared->hdr.segtab); m->add_mask(t); m->add_mask("note: 0 means 65536 for segment size and minalloc"); file->seek(h+ne_shared->hdr.segtab); for (uint32 i=0; ihdr.cseg; i++) { NE_SEGMENT s; file->read(&s, sizeof s); createHostStruct(&s, NE_SEGMENT_struct, little_endian); ht_snprintf(t, sizeof t, "--- segment %d (%s) ---", i+1, (s.flags & NE_DATA) ? "data" : "code"); m->add_mask(t); m->add_staticmask_ptable(neobj, h+ne_shared->hdr.segtab+i*8, false); } v->insertsub(m); return v; } format_viewer_if htnesegments_if = { htnesegments_init, 0 }; ht-2.0.22/htpefimg.h0000644000175000001440000000225711010143337011100 00000000000000/* * HT Editor * htpefimg.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTPEFIMG_H__ #define __HTPEFIMG_H__ #include "htanaly.h" #include "htpef.h" #include "formats.h" extern format_viewer_if htpefimage_if; /* * ht_pef_aviewer */ class ht_pef_aviewer: public ht_aviewer { public: ht_pef_shared_data *pef_shared; void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Analyser *Analyser, ht_pef_shared_data *pef_shared); virtual void setAnalyser(Analyser *a); }; #endif /* !__HTPEFIMG_H__ */ ht-2.0.22/htnenms.h0000644000175000001440000000152310206756710010757 00000000000000/* * HT Editor * htnenms.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTNENMS_H__ #define __HTNENMS_H__ #include "formats.h" extern format_viewer_if htnenames_if; #endif /* !__HTNENMS_H__ */ ht-2.0.22/blockop.cc0000644000175000017500000004077012127651416011106 00000000000000/* * HT Editor * blockop.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "blockop.h" #include "cmds.h" #include "atom.h" #include "htctrl.h" #include "endianess.h" #include "hteval.h" #include "except.h" #include "hthist.h" #include "htiobox.h" #include "keyb.h" #include "strtools.h" #include "htprocess.h" #include "snprintf.h" #include "evalx.h" /* * CLASS ht_blockop_dialog */ void ht_blockop_dialog::init(Bounds *b, FileOfs pstart, FileOfs pend, List *history) { ht_dialog::init(b, "operate on block", FS_TITLE | FS_KILLER | FS_MOVE); Bounds c; bool prerange = (pend > pstart); ht_statictext *text; ht_label *s; List *addrhist = (List*)getAtomValue(HISTATOM_GOTO); /* start */ c = *b; c.h = 1; c.w = 13; c.x = 7; c.y = 1; start = new ht_strinputfield(); start->init(&c, 64, addrhist); insert(start); if (prerange) { char t[32]; ht_snprintf(t, sizeof t, "0x%qx", pstart); ht_inputfield_data d; d.textlen = strlen(t); d.text = (byte*)t; start->databuf_set(&d, sizeof d); } /* start_desc */ c.x = 1; c.w = 6; s = new ht_label(); s->init(&c, "~start", start); insert(s); /* end */ c = *b; c.h = 1; c.w = 13; c.x = 27; c.y = 1; end=new ht_strinputfield(); end->init(&c, 64, addrhist); insert(end); if (prerange) { char t[32]; ht_snprintf(t, sizeof t, "0x%qx", pend); ht_inputfield_data d; d.textlen = strlen(t); d.text = (byte*)t; end->databuf_set(&d, sizeof d); } /* end_desc */ c.x = 23; c.w = 3; s = new ht_label(); s->init(&c, "~end", end); insert(s); /* mode */ c = *b; c.h = 1; c.w = 16; c.x = 7; c.y = 3; mode = new ht_listpopup(); mode->init(&c); mode->insertstring("byte (8-bit)"); mode->insertstring("word (16-bit)"); mode->insertstring("dword (32-bit)"); mode->insertstring("qword (64-bit)"); mode->insertstring("string"); insert(mode); /* mode_desc */ c.x = 1; c.w = 12; c.y = 3; s = new ht_label(); s->init(&c, "~mode", mode); insert(s); /* action_expl */ c = *b; c.x = 1; c.y = 5; c.w -= 3; c.h = 1; text = new ht_statictext(); text->init(&c, "set each element to", align_left); insert(text); /* action */ List *ehist = (List*)getAtomValue(HISTATOM_EVAL_EXPR); c = *b; c.h = 1; c.w = 40; c.x = 7; c.y = 6; action = new ht_strinputfield(); action->init(&c, 4096, ehist); insert(action); /* action_desc */ c.x = 1; c.w = 27; c.y = 6; s = new ht_label(); s->init(&c, "e~xpr", action); insert(s); /* help */ /* c=*b; c.x=1; c.y=8; c.w-=c.x+2; c.h-=c.y+2; text=new ht_statictext(); text->init(&c, "special vars: special funcs:\n" "o - file offset readbyte(ofs)\n" "i - iteration index readstring(ofs, n)", align_left); insert(text);*/ /* functions */ ht_button *bhelp = new ht_button(); c = *b; c.x = 1; c.y = 8; c.w = 12; c.h = 2; bhelp->init(&c, "~Functions", 100); insert(bhelp); } void ht_blockop_dialog::done() { ht_dialog::done(); } struct ht_blockop_dialog_data { ht_inputfield_data start; ht_inputfield_data end; ht_listpopup_data mode; ht_inputfield_data action; }; /* * blockop_dialog */ static FileOfs blockop_i; static FileOfs blockop_o; static bool blockop_expr_is_const; static bool blockop_symbol_eval(eval_scalar *r, char *symbol) { if (strcmp(symbol, "i") == 0) { r->type = SCALAR_INT; r->scalar.integer.value = blockop_i; r->scalar.integer.type = TYPE_UNKNOWN; blockop_expr_is_const = false; return true; } else if (strcmp(symbol, "o") == 0) { r->type = SCALAR_INT; r->scalar.integer.value = blockop_o; r->scalar.integer.type = TYPE_UNKNOWN; blockop_expr_is_const = false; return true; } return false; } static int func_readint(eval_scalar *result, eval_int *offset, int size, Endianess e) { File *f = (File*)eval_get_context(); byte buf[8]; try { f->seek(offset->value); f->readx(buf, size); } catch (const IOException&) { set_eval_error("i/o error (couldn't read %d bytes from ofs %qd (0x%qx))", size, offset->value, offset->value); return 0; } scalar_create_int_q(result, createHostInt64(buf, size, e)); return 1; } static int func_readbyte(eval_scalar *result, eval_int *offset) { return func_readint(result, offset, 1, little_endian); } static int func_read16le(eval_scalar *result, eval_int *offset) { return func_readint(result, offset, 2, little_endian); } static int func_read32le(eval_scalar *result, eval_int *offset) { return func_readint(result, offset, 4, little_endian); } static int func_read64le(eval_scalar *result, eval_int *offset) { return func_readint(result, offset, 8, little_endian); } static int func_read16be(eval_scalar *result, eval_int *offset) { return func_readint(result, offset, 2, big_endian); } static int func_read32be(eval_scalar *result, eval_int *offset) { return func_readint(result, offset, 4, big_endian); } static int func_read64be(eval_scalar *result, eval_int *offset) { return func_readint(result, offset, 8, big_endian); } static int func_readstring(eval_scalar *result, eval_int *offset, eval_int *len) { File *f = (File*)eval_get_context(); uint l = len->value; void *buf = malloc(l); /* FIXME: may be too slow... */ if (buf) { eval_str s; uint c = 0; try { f->seek(offset->value); f->readx(buf, l); } catch (const IOException&) { free(buf); set_eval_error("i/o error (couldn't read %d bytes from ofs %d (0x%qx))", l, c, offset->value, offset->value); return 0; } s.value = (char*)buf; s.len = l; scalar_create_str(result, &s); free(buf); return 1; } set_eval_error("out of memory"); return 0; } static bool blockop_func_eval(eval_scalar *result, char *name, eval_scalarlist *params) { /* FIXME: non-constant funcs (e.g. rand()) should set blockop_expr_is_const to false */ eval_func myfuncs[] = { {"i", 0, {SCALAR_INT}, "iteration index"}, {"o", 0, {SCALAR_INT}, "current offset"}, {"readbyte", (void*)&func_readbyte, {SCALAR_INT}, "read byte from offset"}, {"read16le", (void*)&func_read16le, {SCALAR_INT}, "read little endian 16 bit word from offset"}, {"read32le", (void*)&func_read32le, {SCALAR_INT}, "read little endian 32 bit word from offset"}, {"read64le", (void*)&func_read64le, {SCALAR_INT}, "read little endian 64 bit word from offset"}, {"read16be", (void*)&func_read16be, {SCALAR_INT}, "read big endian 16 bit word from offset"}, {"read32be", (void*)&func_read32be, {SCALAR_INT}, "read big endian 32 bit word from offset"}, {"read64be", (void*)&func_read64be, {SCALAR_INT}, "read big endian 64 bit word from offset"}, {"readstring", (void*)&func_readstring, {SCALAR_INT, SCALAR_INT}, "read string (offset, length)"}, {NULL} }; blockop_expr_is_const = false; return std_eval_func_handler(result, name, params, myfuncs); } /* * BLOCKOP STRING */ class ht_blockop_str_context: public Object { public: File *file; FileOfs ofs; uint len; uint size; bool netendian; char *action; uint i; FileOfs o; bool expr_const; eval_str v; ~ht_blockop_str_context() { free(action); if (expr_const) string_destroy(&v); } }; Object *create_blockop_str_context(File *file, FileOfs ofs, uint len, uint size, bool netendian, char *action) { ht_blockop_str_context *ctx = new ht_blockop_str_context(); ctx->file = file; ctx->ofs = ofs; ctx->len = len; ctx->size = size; ctx->netendian = netendian; ctx->action = strdup(action); ctx->i = 0; ctx->o = ofs; blockop_expr_is_const = true; // test if first eval works blockop_i = ctx->i; blockop_o = ctx->o; eval_scalar r; if (!eval(&r, action, blockop_func_eval, blockop_symbol_eval, file)) { const char *s; int p; get_eval_error(&s, &p); delete ctx; throw MsgfException("error evaluating '%s': %s at %d", action, s, p); } ctx->expr_const = blockop_expr_is_const; if (ctx->expr_const) { scalar_context_str(&r, &ctx->v); } scalar_destroy(&r); return ctx; } #define BLOCKOP_STR_MAX_ITERATIONS 1024 bool blockop_str_process(Object *context, ht_text *progress_indicator) { char status[64]; ht_blockop_str_context *ctx = (ht_blockop_str_context*)context; if (ctx->expr_const) { ht_snprintf(status, sizeof status, "operating (constant string)... %d%% complete", (int)(((double)(ctx->o-ctx->ofs)) * 100 / ctx->len)); progress_indicator->settext(status); for (uint i=0; i < BLOCKOP_STR_MAX_ITERATIONS; i++) if (ctx->o < ctx->ofs + ctx->len) { uint s = ctx->v.len; if (ctx->o + s > ctx->ofs + ctx->len) s = ctx->ofs + ctx->len - ctx->o; ctx->file->seek(ctx->o); ctx->file->writex(ctx->v.value, s); /* !=s) { throw ht_io_exception("blockop_str(): write error at pos %08qx, size %08qx", ctx->o, s); }*/ ctx->o += s; } else { return false; } } else { ht_snprintf(status, sizeof status, "operating (variable string)... %d%% complete", (int)(((double)(ctx->o-ctx->ofs)) * 100 / ctx->len)); progress_indicator->settext(status); eval_scalar r; eval_str sr; for (uint i=0; i < BLOCKOP_STR_MAX_ITERATIONS; i++) if (ctx->o < ctx->ofs + ctx->len) { blockop_i = ctx->i; blockop_o = ctx->o; if (!eval(&r, ctx->action, blockop_func_eval, blockop_symbol_eval, ctx->file)) { const char *s; int p; get_eval_error(&s, &p); throw MsgfException("error evaluating '%s': %s at %d", ctx->action, s, p); } scalar_context_str(&r, &sr); scalar_destroy(&r); uint s = sr.len; if (ctx->o+s > ctx->ofs+ctx->len) s = ctx->ofs+ctx->len-ctx->o; ctx->file->seek(ctx->o); ctx->file->writex(sr.value, s); /* !=s) { throw ht_io_exception("blockop_str(): write error at pos %08x, size %08x", ctx->o, s); }*/ string_destroy(&sr); ctx->o += s; ctx->i++; } else { return false; } } return true; } /* * BLOCKOP INTEGER */ class ht_blockop_int_context: public Object { public: File *file; FileOfs ofs; uint len; uint size; Endianess endian; char *action; uint i; FileOfs o; bool expr_const; uint64 v; ~ht_blockop_int_context() { free(action); } }; Object *create_blockop_int_context(File *file, FileOfs ofs, uint len, uint size, Endianess endian, char *action) { ht_blockop_int_context *ctx = new ht_blockop_int_context(); ctx->file = file; ctx->ofs = ofs; ctx->len = len; ctx->size = size; ctx->endian = endian; ctx->action = ht_strdup(action); ctx->i = 0; ctx->o = ofs; blockop_expr_is_const = true; // test if first eval works blockop_i = ctx->i; blockop_o = ctx->o; eval_scalar r; eval_int ir; if (!eval(&r, action, blockop_func_eval, blockop_symbol_eval, file)) { const char *s; int p; get_eval_error(&s, &p); delete ctx; throw MsgfException("error evaluating '%s': %s at %d", action, s, p); } ctx->expr_const = blockop_expr_is_const; if (ctx->expr_const) { scalar_context_int(&r, &ir); ctx->v = ir.value; } scalar_destroy(&r); return ctx; } #define BLOCKOP_INT_MAX_ITERATIONS 1024 bool blockop_int_process(Object *context, ht_text *progress_indicator) { ht_blockop_int_context *ctx = (ht_blockop_int_context*)context; char status[64]; if (ctx->expr_const) { ht_snprintf(status, sizeof status, "operating (constant integer)... %d%% complete", (int)(((double)(ctx->o-ctx->ofs)) * 100 / ctx->len)); progress_indicator->settext(status); byte ibuf[8]; createForeignInt64(ibuf, ctx->v, ctx->size, ctx->endian); ctx->file->seek(ctx->o); for (uint i=0; i < BLOCKOP_INT_MAX_ITERATIONS; i++) { if (ctx->o < ctx->ofs + ctx->len) { uint s = ctx->size; if (ctx->o + s > ctx->ofs + ctx->len) s = ctx->ofs + ctx->len - ctx->o; ctx->file->writex(ibuf, s); ctx->o += s; } else { return false; } } } else { ht_snprintf(status, sizeof status, "operating (variable integer)... %d%% complete", (int)(((double)(ctx->o-ctx->ofs)) * 100 / ctx->len)); progress_indicator->settext(status); eval_scalar r; eval_int ir; for (uint i=0; i < BLOCKOP_INT_MAX_ITERATIONS; i++) if (ctx->o < ctx->ofs + ctx->len) { blockop_o = ctx->o; blockop_i = ctx->i; if (!eval(&r, ctx->action, blockop_func_eval, blockop_symbol_eval, ctx->file)) { const char *s; int p; get_eval_error(&s, &p); throw MsgfException("error evaluating '%s': %s at %d", ctx->action, s, p); } scalar_context_int(&r, &ir); scalar_destroy(&r); ctx->v = ir.value; uint s = ctx->size; if (ctx->o+s > ctx->ofs+ctx->len) s = ctx->ofs + ctx->len - ctx->o; byte ibuf[8]; createForeignInt64(ibuf, ctx->v, ctx->size, ctx->endian); ctx->file->seek(ctx->o); ctx->file->writex(ibuf, s); ctx->o += s; ctx->i++; } else { return false; } } return true; } bool format_string_to_offset_if_avail(ht_format_viewer *format, byte *string, int stringlen, const char *string_desc, FileOfs *ofs) { if (string && *string && stringlen < 64) { char str[64]; memcpy(str, string, stringlen); str[stringlen] = 0; if (!format->string_to_offset(str, ofs)) { errorbox("%s: '%s' doesn't seem to be a valid offset", string_desc, str); return false; } return true; } return false; } void blockop_dialog(ht_format_viewer *format, FileOfs pstart, FileOfs pend) { Bounds b; b.w = 65; b.h = 15; b.x = (screen->w - b.w)/2; b.y = (screen->h - b.h)/2; ht_blockop_dialog *d=new ht_blockop_dialog(); d->init(&b, pstart, pend, 0); bool run = true; int r; while (run && (r = d->run(false)) != button_cancel) { switch (r) { case 100: dialog_eval_help(blockop_func_eval, blockop_symbol_eval, NULL); break; default: { ht_blockop_dialog_data t; ViewDataBuf vdb(d, &t, sizeof t); File *file = format->get_file(); baseview->sendmsg(cmd_edit_mode_i, file, NULL); if (file->getAccessMode() & IOAM_WRITE) { FileOfs start = pstart, end = pend; if (format_string_to_offset_if_avail(format, t.start.text, t.start.textlen, "start", &start) && format_string_to_offset_if_avail(format, t.end.text, t.end.textlen, "end", &end)) { if (end > start) { int esize = 0; int esizes[4] = {8, 4, 2, 1}; switch (t.mode.cursor_pos) { /* element type: byte */ case 0: esize++; /* element type: uint16 */ case 1: esize++; /* element type: uint32 */ case 2: esize++; /* element type: uint64 */ case 3: { char a[4096]; bin2str(a, t.action.text, MIN(sizeof a, t.action.textlen)); insert_history_entry((List*)getAtomValue(HISTATOM_EVAL_EXPR), a, NULL); char addr[128]; bin2str(addr, t.start.text, MIN(sizeof addr, t.start.textlen)); insert_history_entry((List*)getAtomValue(HISTATOM_GOTO), addr, NULL); bin2str(addr, t.end.text, MIN(sizeof addr, t.end.textlen)); insert_history_entry((List*)getAtomValue(HISTATOM_GOTO), addr, NULL); esize = esizes[esize]; Object *ctx = NULL; try { ctx = create_blockop_int_context(file, start, end-start, esize, little_endian, a); if (ctx) { /*bool b = */execute_process(blockop_int_process, ctx); } } catch (const Exception &e) { errorbox("error: %y", &e); } delete ctx; break; } /* element type: string */ case 4: { char a[256]; bin2str(a, t.action.text, MIN(sizeof a, t.action.textlen)); insert_history_entry((List*)getAtomValue(HISTATOM_EVAL_EXPR), a, NULL); char addr[128]; bin2str(addr, t.start.text, MIN(sizeof addr, t.start.textlen)); insert_history_entry((List*)getAtomValue(HISTATOM_GOTO), addr, NULL); bin2str(addr, t.end.text, MIN(sizeof addr, t.end.textlen)); insert_history_entry((List*)getAtomValue(HISTATOM_GOTO), addr, NULL); Object *ctx = NULL; try { ctx = create_blockop_str_context(file, start, end-start, esize, little_endian, a); if (ctx) { /*bool b = */execute_process(blockop_str_process, ctx); } } catch (const Exception &e) { errorbox("error: %y", &e); } delete ctx; break; } default: errorbox("mode %d not supported", t.mode.cursor_pos); } } else { errorbox("end offset must be greater than start offset"); } } } run = false; } } } d->done(); delete d; } ht-2.0.22/htmzrel.cc0000644000175000001440000000335110620204005011110 00000000000000/* * HT Editor * htmzrel.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "htmz.h" #include "htmzrel.h" #include "htpal.h" #include "httag.h" #include "formats.h" #include "snprintf.h" static int htmzrel_detect(File *file) { uint16 rcount; file->seek(6); file->read(&rcount, 2); return rcount; } static ht_view *htmzrel_init(Bounds *b, File *file, ht_format_group *group) { ht_uformat_viewer *v=new ht_uformat_viewer(); v->init(b, DESC_MZ_REL, VC_EDIT | VC_SEARCH, file, group); uint32 r = 0; uint32 rc = 0; file->seek(6); file->read(&rc, 2); file->seek(24); file->read(&r, 2); char buf[256]; ht_mask_sub *m=new ht_mask_sub(); m->init(file, 0); char info[128]; ht_snprintf(info, sizeof info, "* MZ relocations at offset %08x", r); m->add_mask(info); for (int i=rc; i>0; i--) { int so; file->seek(r); file->read(&so, 4); char *b = tag_make_edit_word(buf, sizeof buf, r+2, tag_endian_little); b += ht_snprintf(b, sizeof buf - (b-buf), ":"); b = tag_make_edit_word(b, sizeof buf - (b-buf), r, tag_endian_little); *b = 0; m->add_mask(buf); r+=4; } v->insertsub(m); return v; } ht-2.0.22/lestruct.h0000644000175000001440000002256010615341624011152 00000000000000/* * HT Editor * lestruct.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __LESTRUCT_H_ #define __LESTRUCT_H_ #include "io/types.h" #define LE_CPU_286 0x01 #define LE_CPU_386 0x02 #define LE_CPU_486 0x03 #define LE_CPU_586 0x04 #define LE_CPU_N10 0x20 #define LE_CPU_N11 0x21 #define LE_CPU_R2000 0x40 #define LE_CPU_R6000 0x41 #define LE_CPU_R4000 0x42 #define LE_OS_OS2 0x01 #define LE_OS_WIN 0x02 #define LE_OS_DOS4 0x03 #define LE_OS_WIN386 0x04 #define LE_MAGIC0 'L' #define LE_MAGIC1 'E' #define LE_SIZEOF_HEADER 196 struct LE_HEADER { uint16 magic; // Magic number byte border; // The byte ordering for the VXD byte worder; // The uint16 ordering for the VXD uint32 level; // The EXE format level for now = 0 uint16 cpu; // The CPU type uint16 os; // The OS type uint32 ver; // Module version uint32 mflags; // Module flags uint32 pagecnt; // Module # pages uint32 startobj; // Object # for instruction pointer uint32 eip; // Extended instruction pointer uint32 stackobj; // Object # for stack pointer uint32 esp; // Extended stack pointer uint32 pagesize; // VXD page size uint32 lastpagesize; // Last page size in VXD uint32 fixupsize; // Fixup section size uint32 fixupsum; // Fixup section checksum uint32 ldrsize; // Loader section size uint32 ldrsum; // Loader section checksum uint32 objtab; // Object table offset uint32 objcnt; // Number of objects in module uint32 pagemap; // Object page map offset uint32 itermap; // Object iterated data map offset uint32 rsrctab; // Offset of Resource Table uint32 rsrccnt; // Number of resource entries uint32 restab; // Offset of resident name table uint32 enttab; // Offset of Entry Table uint32 dirtab; // Offset of Module Directive Table uint32 dircnt; // Number of module directives uint32 fpagetab; // Offset of Fixup Page Table uint32 frectab; // Offset of Fixup Record Table uint32 impmod; // Offset of Import Module Name Table uint32 impmodcnt; // Number of entries in Import Module Name Table uint32 impproc; // Offset of Import Procedure Name Table uint32 pagesum; // Offset of Per-Page Checksum Table uint32 datapage; // Offset of Enumerated Data Pages uint32 preload; // Number of preload pages uint32 nrestab; // Offset of Non-resident Names Table uint32 cbnrestab; // Size of Non-resident Name Table uint32 nressum; // Non-resident Name Table Checksum uint32 autodata; // Object # for automatic data object uint32 debuginfo; // Offset of the debugging information uint32 debuglen; // The length of the debugging info. in bytes uint32 instpreload; // Number of instance pages in preload section of VXD file uint32 instdemand; // Number of instance pages in demand load section of VXD file uint32 heapsize; // Size of heap - for 16-bit apps byte res3[12]; // Reserved words uint32 winresoff; uint32 winreslen; uint16 devid; // Device ID for VxD uint16 ddkver; // DDK version for VxD } PACKED; /* 1 1 1 1 1 1 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 þ þ þ þ þ þ þ þ þ þ þ þ þ þ þ þ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÅÄÙ ³ ³ ÀÄÄÄÄÄ2ÄInitialization ( Only for DLL ): ³ ³ ³ ³ ³ 0: Global ³ ³ ³ ³ ³ 1: Per-Process ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄ4Ä1:No internal fixup in exe image ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄ5Ä1:No external fixup in exe image ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ8,9,10Ä 0 - Unknown ³ ³ 1 - Incompatible with PM windowing ³ ³ 2 - Compatible with PM windowing ³ ³ 3 - Uses PM windowing API ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ13Ä1: Module not loadable ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ15Ä1: Module is DLL rather then program */ #define LE_MODULE_FLAG_INIT_PER_PROCESS (1<<2) #define LE_MODULE_FLAG_NO_EXT_FIXUP (1<<4) #define LE_MODULE_FLAG_NO_INT_FIXUP (1<<5) #define LE_MODULE_FLAG_WINDOWING_MASK (7<<8) #define LE_MODULE_FLAG_NOT_LOADABLE (1<<13) #define LE_MODULE_FLAG_LIBRARY (1<<15) /* * LE Objects (aka segments, aka sections) */ /* ³ ³ ³ ³ ³ ÀÂÙ ³ ³ ³ ³ ³ ³ ³ ÀÄ0Ä 1: Readable ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄ1Ä 1: Writable ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄ2Ä 1: Executable ³ ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄ3Ä 1: Resource ³ ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄ4Ä 1: Discardable ³ ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄ5Ä 1: Shared ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄ6Ä 1: Preloaded ³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ7Ä 1: Invalid ³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ8,9ÄÄ Type: 00 - Normal ³ ³ ³ ³ ³ 01 - Zero-filled ³ ³ ³ ³ ³ 10 - Resident ³ ³ ³ ³ ³ 11 - Resident/contiguous ³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ10Ä "RESIDENT/LONG_LOCABLE" ³ ³ ³ ³ ³ ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ12Ä "16:16_ALIAS" ³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ13Ä 1: "BIG" (USE32) ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ14Ä 1: Conforming ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ15Ä "Object_i/o_privilege_level" */ #define LE_OBJECT_FLAG_READABLE (1<<0) #define LE_OBJECT_FLAG_WRITEABLE (1<<1) #define LE_OBJECT_FLAG_EXECUTABLE (1<<2) #define LE_OBJECT_FLAG_RESOURCE (1<<3) #define LE_OBJECT_FLAG_DISCARDABLE (1<<4) #define LE_OBJECT_FLAG_SHARED (1<<5) #define LE_OBJECT_FLAG_PRELOADED (1<<6) #define LE_OBJECT_FLAG_INVALID (1<<7) #define LE_OBJECT_FLAG_USE32 (1<<13) #define LE_SIZEOF_OBJECT 24 struct LE_OBJECT { uint32 vsize; uint32 base_reloc_addr; uint32 flags; uint32 page_map_index; uint32 page_map_count; byte name[4]; } PACKED; struct LE_PAGE_MAP_ENTRY { uint16 high; byte low; byte flags; } PACKED; /* * ENTRYPOINTS */ #define LE_ENTRYPOINT_BUNDLE_VALID (1<<0) #define LE_ENTRYPOINT_BUNDLE_32BIT (1<<1) struct LE_ENTRYPOINT_BUNDLE { byte entry_count; byte flags; uint16 obj_index; } PACKED; #define LE_ENTRYPOINT_EXPORTED (1<<0) #define LE_ENTRYPOINT_SHARED (1<<1) struct LE_ENTRYPOINT16 { byte flags; uint16 offset; } PACKED; struct LE_ENTRYPOINT32 { byte flags; uint32 offset; } PACKED; /* * FIXUPS */ #define LE_FIXUP_ADDR_TYPE_MASK (15<<0) #define LE_FIXUP_ADDR_TYPE_0_8 0 #define LE_FIXUP_ADDR_TYPE_16_0 2 #define LE_FIXUP_ADDR_TYPE_16_16 3 #define LE_FIXUP_ADDR_TYPE_0_16 5 #define LE_FIXUP_ADDR_TYPE_16_32 6 #define LE_FIXUP_ADDR_TYPE_0_32 7 #define LE_FIXUP_ADDR_TYPE_REL32 8 #define LE_FIXUP_ADDR_16_16 (1<<4) #define LE_FIXUP_ADDR_MULTIPLE (1<<5) #define LE_FIXUP_RELOC_TYPE_MASK (3<<0) #define LE_FIXUP_RELOC_TYPE_INTERNAL 0 #define LE_FIXUP_RELOC_TYPE_IMPORT_ORD 1 #define LE_FIXUP_RELOC_TYPE_IMPORT_NAME 2 #define LE_FIXUP_RELOC_TYPE_OSFIXUP 3 // ? #define LE_FIXUP_RELOC_ADDITIVE (1<<2) #define LE_FIXUP_RELOC_TARGET32 (1<<4) #define LE_FIXUP_RELOC_ADDITIVE32 (1<<5) #define LE_FIXUP_RELOC_ORDINAL16 (1<<6) #define LE_FIXUP_RELOC_IORD8 (1<<7) struct LE_FIXUP { uint8 address_type; uint8 reloc_type; } PACKED; // if address_type == 8, reloc_type = 0 struct LE_FIXUP_INTERNAL16 { uint8 seg; uint16 ofs; } PACKED; struct LE_FIXUP_INTERNAL32 { uint8 seg; uint32 ofs; } PACKED; /* * VxD specific */ struct LE_VXD_DESCRIPTOR { uint32 next; uint16 sdk_version; uint16 device_number; uint8 version_major; uint8 version_minor; uint16 flags; uint8 name[8]; // not (null-)terminated, fill with spaces uint32 init_order; uint32 ctrl_ofs; uint32 v86_ctrl_ofs; uint32 pm_ctrl_ofs; uint32 v86_ctrl_csip; uint32 pm_ctrl_csip; uint32 rm_ref_data; // "Reference data from real mode" uint32 service_table_ofs; uint32 service_table_size; uint32 win32_service_table_ofs; uint32 prev; // normally 'verP' (Prev) uint32 size; // size of this structure (0x50 = 80) uint32 reserved0; // normally '1vsR' (Rsv1) uint32 reserved1; // normally '2vsR' (Rsv2) uint32 reserved2; // normally '3vsR' (Rsv3) } PACKED; /* * internal */ struct ht_le_objmap { LE_OBJECT *header; uint *psize; uint *vsize; uint count; }; struct ht_le_pagemap { uint *offset; uint *psize; uint *vsize; uint count; }; /**/ extern byte LE_HEADER_struct[]; extern byte LE_FIXUP_struct[]; extern byte LE_ENTRYPOINT16_struct[]; extern byte LE_ENTRYPOINT32_struct[]; extern byte LE_VXD_DESCRIPTOR_struct[]; extern byte LE_FIXUP_INTERNAL_struct[]; extern byte LE_OBJECT_HEADER_struct[]; extern byte LE_PAGE_MAP_ENTRY_struct[]; extern byte LE_FIXUP_INTERNAL16_struct[]; extern byte LE_FIXUP_INTERNAL32_struct[]; #endif /* __LESTRUCT_H_ */ ht-2.0.22/htxex.h0000755000175000001440000000506610615345251010452 00000000000000/* * HT Editor * htxex.h * * Copyright (C) 2006 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTXEX_H__ #define __HTXEX_H__ #include "formats.h" #include "xexstruct.h" #define DESC_XEX "xex - xenon executable" #define DESC_XEX_HEADER "xex/header" extern format_viewer_if htxex_if; struct xex_info_entry { FileOfs start; FileOfs size; uint32 type; }; struct xex_loader_info_raw { Array *sections; }; struct xex_loader_info_compressed { uint32 window; }; class XEXLoaderRawSection: public Object { public: uint32 raw; uint32 pad; XEXLoaderRawSection(uint32 aRaw, uint32 aPad) : raw(aRaw), pad(aPad) {} }; struct xex_loader_info { int type; union { xex_loader_info_raw raw; xex_loader_info_compressed compressed; }; }; struct XexImportFunc { uint32 ord; uint32 patch; uint32 ia; }; struct XexImportLib { char *name; int func_count; XexImportFunc *funcs; }; struct XexImports { FileOfs ofs; uint32 lib_count; XexImportLib *libs; }; struct XexPage { uint32 flags; }; struct XexPages { uint32 page_shift; XexPage *page; }; struct ht_xex_shared_data { XEX_IMAGE_HEADER header; XEX_IMAGE_HEADER_INFO_ENTRY *info_table; xex_info_entry *info_table_cooked; XEX_FILE_HEADER file_header; xex_loader_info loader_info; XexImports imports; XexPages pages; uint32 original_base_address; uint32 image_base; uint32 image_size; uint32 entrypoint; MemoryFile *image; ht_format_viewer *v_header; ht_view *v_imports; ht_format_viewer *v_image; }; /* * ht_xex */ class ht_xex: public ht_format_group { protected: bool loc_enum; public: void init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs); virtual void done(); }; bool xex_rva_to_ofs(ht_xex_shared_data *xex_shared, RVA rva, FileOfs &ofs); bool xex_ofs_to_rva(ht_xex_shared_data *xex_shared, FileOfs ofs, RVA &rva); uint32 xex_get_rva_flags(ht_xex_shared_data *xex_shared, RVA rva); #endif /* !__HTXEX_H__ */ ht-2.0.22/htleimg.h0000644000175000001440000000264010615341620010727 00000000000000/* * HT Editor * htleimg.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTLEIMG_H__ #define __HTLEIMG_H__ #include "htanaly.h" #include "htle.h" #include "formats.h" extern format_viewer_if htleimage_if; /* * CLASS ht_le_aviewer */ class ht_le_aviewer: public ht_aviewer { public: ht_le_shared_data *le_shared; File *file; void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Analyser *Analyser, ht_le_shared_data *le_shared); /* overwritten */ virtual const char *func(uint i, bool execute); virtual void setAnalyser(Analyser *a); virtual bool get_current_real_offset(FileOfs *ofs); virtual bool offset_to_pos(FileOfs ofs, viewer_pos *p); virtual bool pos_to_offset(viewer_pos p, FileOfs *ofs); }; #endif /* !__HTLEIMG_H__ */ ht-2.0.22/htxex.cc0000755000175000001440000002643610615345251010614 00000000000000/* * HT Editor * htxex.cc * * Copyright (C) 2006 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "log.h" #include "endianess.h" #include "htxex.h" #include "htxexhead.h" #include "htxeximg.h" #include "stream.h" #include "tools.h" static format_viewer_if *htxex_ifs[] = { &htxexheader_if, &htxeximage_if, 0 }; static ht_view *htxex_init(Bounds *b, File *file, ht_format_group *format_group) { byte xexmagic[4]; file->seek(0); file->read(xexmagic, 4); if (xexmagic[0]!=XEX_MAGIC0 || xexmagic[1]!=XEX_MAGIC1 || xexmagic[2]!=XEX_MAGIC2 || xexmagic[3]!=XEX_MAGIC3) return 0; ht_xex *g=new ht_xex(); g->init(b, file, htxex_ifs, format_group, 0); return g; } format_viewer_if htxex_if = { htxex_init, 0 }; /* * CLASS ht_xex */ void ht_xex::init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs) { ht_format_group::init(b, VO_BROWSABLE | VO_SELECTABLE | VO_RESIZE, DESC_XEX, file, false, true, 0, format_group); VIEW_DEBUG_NAME("ht_xex"); ht_xex_shared_data *xex_shared = ht_malloc(sizeof (ht_xex_shared_data)); shared_data = xex_shared; xex_shared->v_header = NULL; xex_shared->image = NULL; xex_shared->loader_info.type = XEX_LOADER_NONE; xex_shared->imports.ofs = 0; /* read header */ file->seek(0); file->read(&xex_shared->header, sizeof xex_shared->header); createHostStruct(&xex_shared->header, XEX_IMAGE_HEADER_struct, big_endian); xex_shared->info_table = ht_malloc(xex_shared->header.number_of_sections * sizeof *xex_shared->info_table); xex_shared->info_table_cooked = ht_malloc(xex_shared->header.number_of_sections * sizeof *xex_shared->info_table_cooked); for (uint i=0; i < xex_shared->header.number_of_sections; i++) { file->read(xex_shared->info_table+i, sizeof *xex_shared->info_table); createHostStruct(xex_shared->info_table+i, XEX_IMAGE_HEADER_INFO_ENTRY_struct, big_endian); xex_shared->info_table_cooked[i].type = createHostInt(&xex_shared->info_table[i].type, 4, big_endian); xex_shared->info_table_cooked[i].start = 0; xex_shared->info_table_cooked[i].size = xex_shared->info_table[i].b.size; if (xex_shared->info_table[i].b.size == 0xff) { FileOfs ofs = file->tell(); file->seek(xex_shared->info_table[i].value); uint32 s; if (file->read(&s, 4) == 4) { xex_shared->info_table_cooked[i].start = xex_shared->info_table[i].value + 4; xex_shared->info_table_cooked[i].size = createHostInt(&s, 4, big_endian) - 4; } file->seek(ofs); } else if (xex_shared->info_table[i].b.size > 1) { xex_shared->info_table_cooked[i].start = xex_shared->info_table[i].value; xex_shared->info_table_cooked[i].size = xex_shared->info_table[i].b.size * 4; } } for (uint i=0; i < xex_shared->header.number_of_sections; i++) { switch (xex_shared->info_table_cooked[i].type) { case XEX_HEADER_FIELD_LOADERINFO: { uint32 size = xex_shared->info_table_cooked[i].size; if (size > 4) { XEX_LOADER_INFO_HEADER ldhdr; file->seek(xex_shared->info_table_cooked[i].start); if (file->read(&ldhdr, sizeof ldhdr) == sizeof ldhdr) { size -= 4; createHostStruct(&ldhdr, XEX_LOADER_INFO_HEADER_struct, big_endian); if (!ldhdr.crypted && ldhdr.type == XEX_LOADER_RAW) { int entries = size / 8; xex_shared->loader_info.type = XEX_LOADER_RAW; xex_shared->loader_info.raw.sections = new Array(true, entries); for (int j=0; j < entries; j++) { XEX_RAW_LOADER_ENTRY e; if (file->read(&e, sizeof e) != sizeof e) break; createHostStruct(&e, XEX_RAW_LOADER_ENTRY_struct, big_endian); xex_shared->loader_info.raw.sections->insert( new XEXLoaderRawSection(e.raw, e.pad)); } } } } break; } case XEX_HEADER_FIELD_IMPORT: xex_shared->imports.ofs = xex_shared->info_table[i].value; break; case XEX_HEADER_FIELD_ENTRY: xex_shared->entrypoint = xex_shared->info_table[i].value; break; case XEX_HEADER_FIELD_BASE: xex_shared->image_base = xex_shared->info_table[i].value; break; } } file->seek(xex_shared->header.file_header_offset); if (file->read(&xex_shared->file_header, sizeof xex_shared->file_header) == sizeof xex_shared->file_header) { createHostStruct(&xex_shared->file_header, XEX_FILE_HEADER_struct, big_endian); xex_shared->image_base = xex_shared->file_header.load_address; xex_shared->image_size = xex_shared->file_header.image_size; file->seek(xex_shared->header.file_header_offset+0x184); xex_shared->pages.page = new XexPage[xex_shared->file_header.pages]; for (int i=0; i < xex_shared->file_header.pages; i++) { uint32 flags; file->read(&flags, 4); flags = createHostInt(&flags, 4, big_endian); xex_shared->pages.page[i].flags = flags; file->seek(file->tell()+20); } xex_shared->pages.page_shift = 16; // FIXME: can also be 12 } else { xex_shared->pages.page = NULL; xex_shared->file_header.hdr_size = 0; xex_shared->image_size = 0; xex_shared->image_base = 0; } xex_shared->imports.lib_count = 0; xex_shared->imports.libs = NULL; try { if (xex_shared->imports.ofs) { file->seek(xex_shared->imports.ofs); uint32 size, sizen, l; file->readx(&size, 4); file->readx(&sizen, 4); file->readx(&l, 4); size = createHostInt(&size, 4, big_endian); sizen = createHostInt(&sizen, 4, big_endian); l = createHostInt(&l, 4, big_endian); FileOfs ofs = xex_shared->imports.ofs + 3*4 + sizen; XexImportLib *libs = new XexImportLib[l]; if (l) { String s; for (uint i=0; i < l; i++) { s.clear(); file->readStringz(s); libs[i].name = strdup(s.contentChar()); } // patch table for (uint i=0; i < l; i++) { file->seek(ofs); file->readx(&sizen, 4); sizen = createHostInt(&sizen, 4, big_endian); ofs += sizen; file->seek(36 + file->tell()); // skip garbage int count = (sizen - 40) / 4; libs[i].func_count = count; if (count) { libs[i].funcs = new XexImportFunc[count]; } else { libs[i].funcs = NULL; } for (int j=0; j < count; j++) { uint32 patch; file->readx(&patch, 4); libs[i].funcs[j].patch = createHostInt(&patch, 4, big_endian); libs[i].funcs[j].ord = libs[i].funcs[j].ia = 0; } } } xex_shared->imports.libs = libs; xex_shared->imports.lib_count = l; } } catch (...) {} xex_shared->image = new MemoryFile(0, xex_shared->image_size); try { if (xex_shared->loader_info.type == XEX_LOADER_RAW) { file->seek(xex_shared->header.size); FileOfs ofs = 0; foreach(XEXLoaderRawSection, section, *xex_shared->loader_info.raw.sections, { xex_shared->image->seek(ofs); file->copyTo(xex_shared->image, section->raw); ofs += section->raw + section->pad; }); } } catch (...) {} uint32 *iat = new uint32[0x8000]; byte *image_ptr = xex_shared->image->getBufPtr(); for (int i=0; i < xex_shared->imports.lib_count; i++) { memset(iat, 0, 4*0x8000); // get import ordinals XexImportLib *lib = xex_shared->imports.libs+i; for (int j=0; j < lib->func_count; j++) { uint32 ord; ord = lib->funcs[j].ord = createHostInt(&image_ptr[lib->funcs[j].patch - xex_shared->image_base], 4, big_endian); if ((ord & 0xff000000) == 0) { ord &= 0x7fff; if (iat[ord]) { // fprintf(stderr, "%s: warning: duplicate import %d from library '%s'\n", infn, ord, imports[i].lib); } else { iat[ord] = lib->funcs[j].patch; } } } // printf("\n; Library '%s':\n", lib.name); // resolve imports for (int j=0; j < lib->func_count; j++) { uint32 ord = lib->funcs[j].ord; if (ord & 0xff000000) { int libidx = (ord & 0x00ff0000) >> 16; ord &= 0x7fff; if (libidx != i) { /* if (libidx < import_count) { fprintf(stderr, "%s: import %d from library '%s', but in section of library '%s'\n", infn, ord, imports[libidx].lib, imports[i].lib); } else { fprintf(stderr, "%s: import %d from unknown library %d, but in section of library '%s'\n", infn, ord, libidx, imports[i].lib); } return 1;*/ continue; } if (!iat[ord]) { /* fprintf(stderr, "%s: import %d from library '%s' need to be resolved but is not imported\n", infn, ord, imports[i].lib); return 1;*/ continue; } uint32 ia = iat[ord]; // patch it uint32 lis_r11 = (0x3d600000 | (ia >> 16)) + !!(ia & 0x8000); uint32 lwz_r11 = (0x816b0000 | (ia & 0xffff)); createForeignInt(&image_ptr[lib->funcs[j].patch-xex_shared->image_base], lis_r11, 4, big_endian); createForeignInt(&image_ptr[lib->funcs[j].patch-xex_shared->image_base+4], lwz_r11, 4, big_endian); lib->funcs[j].ia = ia; /* char s[100]; snprintf(s, sizeof s, "wrapper_import_%s_%d", imports[i].lib, ord); printf("function 0x%08x name '%s'\n", imports[i].func[j].patch, s); printf("xref 0x%08x -> 0x%08x\n", ia, imports[i].func[j].patch + 12);*/ } else { /* ord &= 0x7fff; char s[100]; snprintf(s, sizeof s, "import_%s_%d", imports[i].lib, ord); printf("function_ptr 0x%08x name '%s'\n", imports[i].func[j].patch, s);*/ } } } delete[] iat; ht_format_group::init_ifs(ifs); } void ht_xex::done() { ht_format_group::done(); ht_xex_shared_data *xex_shared = (ht_xex_shared_data*)shared_data; delete[] xex_shared->pages.page; for (int i=0; i < xex_shared->imports.lib_count; i++) { free(xex_shared->imports.libs[i].name); delete[] xex_shared->imports.libs[i].funcs; } delete[] xex_shared->imports.libs; free(xex_shared->info_table); free(xex_shared->info_table_cooked); delete xex_shared->image; free(xex_shared); } bool xex_ofs_to_rva(ht_xex_shared_data *xex_shared, FileOfs ofs, RVA &rva) { #if 0 FileOfs xex_ofs = 0; RVA xex_va = 0; for (int i = 0; i < g_entry_count; i++) { if (xex_ofs <= ofs && xex_ofs+g_entries[i].raw > ofs) { res = xex_va + (ofs - xex_ofs); return true; } xex_va += g_entries[i].raw + g_entries[i].pad; xex_ofs += g_entries[i].raw; if (xex_ofs > ofs) return false; } return false; #else if (ofs < xex_shared->image_size) { rva = ofs; return true; } else { return false; } #endif } bool xex_rva_to_ofs(ht_xex_shared_data *xex_shared, RVA rva, FileOfs &ofs) { #if 0 FileOfs xex_ofs = 0; RVA xex_va = 0; for (int i = 0; i < g_entry_count; i++) { if (xex_va <= va && xex_va + g_entries[i].read > va) { res = xex_ofs + (va - xex_va); return true; } xex_va += g_entries[i].read + g_entries[i].pad; xex_ofs += g_entries[i].read; if (xex_va > va) return false; } return false; #else if (rva < xex_shared->image_size) { ofs = rva; return true; } else { return false; } #endif } uint32 xex_get_rva_flags(ht_xex_shared_data *xex_shared, RVA rva) { uint pagen = rva >> xex_shared->pages.page_shift; XexPage *p = xex_shared->pages.page + pagen; return p->flags; } ht-2.0.22/demangle.h0000644000175000001440000006236411655554027011077 00000000000000/* Defs for interface to demanglers. Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. In addition to the permissions in the GNU Library General Public License, the Free Software Foundation gives you unlimited permission to link the compiled version of this file into combinations with other programs, and to distribute those combinations without any restriction coming from the use of this file. (The Library Public License restrictions do apply in other respects; for example, they cover modification of the file, and distribution when not linked into a combined executable.) This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ #if !defined (DEMANGLE_H) #define DEMANGLE_H #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ /* These macros provide a K&R/C89/C++-friendly way of allocating structures with nice encapsulation. The XDELETE*() macros are technically superfluous, but provided here for symmetry. Using them consistently makes it easier to update client code to use different allocators such as new/delete and new[]/delete[]. */ /* Scalar allocators. */ #define XNEW(T) ((T *) xmalloc (sizeof (T))) #define XCNEW(T) ((T *) xcalloc (1, sizeof (T))) #define XDELETE(P) free ((void*) (P)) /* Array allocators. */ #define XNEWVEC(T, N) ((T *) xmalloc (sizeof (T) * (N))) #define XCNEWVEC(T, N) ((T *) xcalloc ((N), sizeof (T))) #define XRESIZEVEC(T, P, N) ((T *) xrealloc ((void *) (P), sizeof (T) * (N))) #define XDELETEVEC(P) free ((void*) (P)) /* Allocators for variable-sized structures and raw buffers. */ #define XNEWVAR(T, S) ((T *) xmalloc ((S))) #define XCNEWVAR(T, S) ((T *) xcalloc (1, (S))) #define XRESIZEVAR(T, P, S) ((T *) xrealloc ((P), (S))) #define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) /* Options passed to cplus_demangle (in 2nd parameter). */ #define DMGL_NO_OPTS 0 /* For readability... */ #define DMGL_PARAMS (1 << 0) /* Include function args */ #define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */ #define DMGL_JAVA (1 << 2) /* Demangle as Java rather than C++. */ #define DMGL_VERBOSE (1 << 3) /* Include implementation details. */ #define DMGL_TYPES (1 << 4) /* Also try to demangle type encodings. */ #define DMGL_RET_POSTFIX (1 << 5) /* Print function return types (when present) after function signature */ #define DMGL_AUTO (1 << 8) #define DMGL_GNU (1 << 9) #define DMGL_LUCID (1 << 10) #define DMGL_ARM (1 << 11) #define DMGL_HP (1 << 12) /* For the HP aCC compiler; same as ARM except for template arguments, etc. */ #define DMGL_EDG (1 << 13) #define DMGL_GNU_V3 (1 << 14) #define DMGL_GNAT (1 << 15) /* If none of these are set, use 'current_demangling_style' as the default. */ #define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT) /* Enumeration of possible demangling styles. Lucid and ARM styles are still kept logically distinct, even though they now both behave identically. The resulting style is actual the union of both. I.E. either style recognizes both "__pt__" and "__rf__" for operator "->", even though the first is lucid style and the second is ARM style. (FIXME?) */ extern enum demangling_styles { no_demangling = -1, unknown_demangling = 0, auto_demangling = DMGL_AUTO, gnu_demangling = DMGL_GNU, lucid_demangling = DMGL_LUCID, arm_demangling = DMGL_ARM, hp_demangling = DMGL_HP, edg_demangling = DMGL_EDG, gnu_v3_demangling = DMGL_GNU_V3, java_demangling = DMGL_JAVA, gnat_demangling = DMGL_GNAT } current_demangling_style; /* Define string names for the various demangling styles. */ #define NO_DEMANGLING_STYLE_STRING "none" #define AUTO_DEMANGLING_STYLE_STRING "auto" #define GNU_DEMANGLING_STYLE_STRING "gnu" #define LUCID_DEMANGLING_STYLE_STRING "lucid" #define ARM_DEMANGLING_STYLE_STRING "arm" #define HP_DEMANGLING_STYLE_STRING "hp" #define EDG_DEMANGLING_STYLE_STRING "edg" #define GNU_V3_DEMANGLING_STYLE_STRING "gnu-v3" #define JAVA_DEMANGLING_STYLE_STRING "java" #define GNAT_DEMANGLING_STYLE_STRING "gnat" /* Some macros to test what demangling style is active. */ #define CURRENT_DEMANGLING_STYLE current_demangling_style #define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO) #define GNU_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU) #define LUCID_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_LUCID) #define ARM_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_ARM) #define HP_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_HP) #define EDG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_EDG) #define GNU_V3_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU_V3) #define JAVA_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_JAVA) #define GNAT_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNAT) /* Provide information about the available demangle styles. This code is pulled from gdb into libiberty because it is useful to binutils also. */ extern const struct demangler_engine { const char *const demangling_style_name; const enum demangling_styles demangling_style; const char *const demangling_style_doc; } libiberty_demanglers[]; extern char * cplus_demangle (const char *mangled, int options); extern int cplus_demangle_opname (const char *opname, char *result, int options); extern const char * cplus_mangle_opname (const char *opname, int options); /* Note: This sets global state. FIXME if you care about multi-threading. */ extern void set_cplus_marker_for_demangling (int ch); extern enum demangling_styles cplus_demangle_set_style (enum demangling_styles style); extern enum demangling_styles cplus_demangle_name_to_style (const char *name); /* Callback typedef for allocation-less demangler interfaces. */ typedef void (*demangle_callbackref) (const char *, size_t, void *); /* V3 ABI demangling entry points, defined in cp-demangle.c. Callback variants return non-zero on success, zero on error. char* variants return a string allocated by malloc on success, NULL on error. */ extern int cplus_demangle_v3_callback (const char *mangled, int options, demangle_callbackref callback, void *opaque); extern char* cplus_demangle_v3 (const char *mangled, int options); extern int java_demangle_v3_callback (const char *mangled, demangle_callbackref callback, void *opaque); extern char* java_demangle_v3 (const char *mangled); char * ada_demangle (const char *mangled, int options); enum gnu_v3_ctor_kinds { gnu_v3_complete_object_ctor = 1, gnu_v3_base_object_ctor, gnu_v3_complete_object_allocating_ctor }; /* Return non-zero iff NAME is the mangled form of a constructor name in the G++ V3 ABI demangling style. Specifically, return an `enum gnu_v3_ctor_kinds' value indicating what kind of constructor it is. */ extern enum gnu_v3_ctor_kinds is_gnu_v3_mangled_ctor (const char *name); enum gnu_v3_dtor_kinds { gnu_v3_deleting_dtor = 1, gnu_v3_complete_object_dtor, gnu_v3_base_object_dtor }; /* Return non-zero iff NAME is the mangled form of a destructor name in the G++ V3 ABI demangling style. Specifically, return an `enum gnu_v3_dtor_kinds' value, indicating what kind of destructor it is. */ extern enum gnu_v3_dtor_kinds is_gnu_v3_mangled_dtor (const char *name); /* The V3 demangler works in two passes. The first pass builds a tree representation of the mangled name, and the second pass turns the tree representation into a demangled string. Here we define an interface to permit a caller to build their own tree representation, which they can pass to the demangler to get a demangled string. This can be used to canonicalize user input into something which the demangler might output. It could also be used by other demanglers in the future. */ /* These are the component types which may be found in the tree. Many component types have one or two subtrees, referred to as left and right (a component type with only one subtree puts it in the left subtree). */ enum demangle_component_type { /* A name, with a length and a pointer to a string. */ DEMANGLE_COMPONENT_NAME, /* A qualified name. The left subtree is a class or namespace or some such thing, and the right subtree is a name qualified by that class. */ DEMANGLE_COMPONENT_QUAL_NAME, /* A local name. The left subtree describes a function, and the right subtree is a name which is local to that function. */ DEMANGLE_COMPONENT_LOCAL_NAME, /* A typed name. The left subtree is a name, and the right subtree describes that name as a function. */ DEMANGLE_COMPONENT_TYPED_NAME, /* A template. The left subtree is a template name, and the right subtree is a template argument list. */ DEMANGLE_COMPONENT_TEMPLATE, /* A template parameter. This holds a number, which is the template parameter index. */ DEMANGLE_COMPONENT_TEMPLATE_PARAM, /* A function parameter. This holds a number, which is the index. */ DEMANGLE_COMPONENT_FUNCTION_PARAM, /* A constructor. This holds a name and the kind of constructor. */ DEMANGLE_COMPONENT_CTOR, /* A destructor. This holds a name and the kind of destructor. */ DEMANGLE_COMPONENT_DTOR, /* A vtable. This has one subtree, the type for which this is a vtable. */ DEMANGLE_COMPONENT_VTABLE, /* A VTT structure. This has one subtree, the type for which this is a VTT. */ DEMANGLE_COMPONENT_VTT, /* A construction vtable. The left subtree is the type for which this is a vtable, and the right subtree is the derived type for which this vtable is built. */ DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, /* A typeinfo structure. This has one subtree, the type for which this is the tpeinfo structure. */ DEMANGLE_COMPONENT_TYPEINFO, /* A typeinfo name. This has one subtree, the type for which this is the typeinfo name. */ DEMANGLE_COMPONENT_TYPEINFO_NAME, /* A typeinfo function. This has one subtree, the type for which this is the tpyeinfo function. */ DEMANGLE_COMPONENT_TYPEINFO_FN, /* A thunk. This has one subtree, the name for which this is a thunk. */ DEMANGLE_COMPONENT_THUNK, /* A virtual thunk. This has one subtree, the name for which this is a virtual thunk. */ DEMANGLE_COMPONENT_VIRTUAL_THUNK, /* A covariant thunk. This has one subtree, the name for which this is a covariant thunk. */ DEMANGLE_COMPONENT_COVARIANT_THUNK, /* A Java class. This has one subtree, the type. */ DEMANGLE_COMPONENT_JAVA_CLASS, /* A guard variable. This has one subtree, the name for which this is a guard variable. */ DEMANGLE_COMPONENT_GUARD, /* A reference temporary. This has one subtree, the name for which this is a temporary. */ DEMANGLE_COMPONENT_REFTEMP, /* A hidden alias. This has one subtree, the encoding for which it is providing alternative linkage. */ DEMANGLE_COMPONENT_HIDDEN_ALIAS, /* A standard substitution. This holds the name of the substitution. */ DEMANGLE_COMPONENT_SUB_STD, /* The restrict qualifier. The one subtree is the type which is being qualified. */ DEMANGLE_COMPONENT_RESTRICT, /* The volatile qualifier. The one subtree is the type which is being qualified. */ DEMANGLE_COMPONENT_VOLATILE, /* The const qualifier. The one subtree is the type which is being qualified. */ DEMANGLE_COMPONENT_CONST, /* The restrict qualifier modifying a member function. The one subtree is the type which is being qualified. */ DEMANGLE_COMPONENT_RESTRICT_THIS, /* The volatile qualifier modifying a member function. The one subtree is the type which is being qualified. */ DEMANGLE_COMPONENT_VOLATILE_THIS, /* The const qualifier modifying a member function. The one subtree is the type which is being qualified. */ DEMANGLE_COMPONENT_CONST_THIS, /* A vendor qualifier. The left subtree is the type which is being qualified, and the right subtree is the name of the qualifier. */ DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, /* A pointer. The one subtree is the type which is being pointed to. */ DEMANGLE_COMPONENT_POINTER, /* A reference. The one subtree is the type which is being referenced. */ DEMANGLE_COMPONENT_REFERENCE, /* C++0x: An rvalue reference. The one subtree is the type which is being referenced. */ DEMANGLE_COMPONENT_RVALUE_REFERENCE, /* A complex type. The one subtree is the base type. */ DEMANGLE_COMPONENT_COMPLEX, /* An imaginary type. The one subtree is the base type. */ DEMANGLE_COMPONENT_IMAGINARY, /* A builtin type. This holds the builtin type information. */ DEMANGLE_COMPONENT_BUILTIN_TYPE, /* A vendor's builtin type. This holds the name of the type. */ DEMANGLE_COMPONENT_VENDOR_TYPE, /* A function type. The left subtree is the return type. The right subtree is a list of ARGLIST nodes. Either or both may be NULL. */ DEMANGLE_COMPONENT_FUNCTION_TYPE, /* An array type. The left subtree is the dimension, which may be NULL, or a string (represented as DEMANGLE_COMPONENT_NAME), or an expression. The right subtree is the element type. */ DEMANGLE_COMPONENT_ARRAY_TYPE, /* A pointer to member type. The left subtree is the class type, and the right subtree is the member type. CV-qualifiers appear on the latter. */ DEMANGLE_COMPONENT_PTRMEM_TYPE, /* A fixed-point type. */ DEMANGLE_COMPONENT_FIXED_TYPE, /* A vector type. The left subtree is the number of elements, the right subtree is the element type. */ DEMANGLE_COMPONENT_VECTOR_TYPE, /* An argument list. The left subtree is the current argument, and the right subtree is either NULL or another ARGLIST node. */ DEMANGLE_COMPONENT_ARGLIST, /* A template argument list. The left subtree is the current template argument, and the right subtree is either NULL or another TEMPLATE_ARGLIST node. */ DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, /* An operator. This holds information about a standard operator. */ DEMANGLE_COMPONENT_OPERATOR, /* An extended operator. This holds the number of arguments, and the name of the extended operator. */ DEMANGLE_COMPONENT_EXTENDED_OPERATOR, /* A typecast, represented as a unary operator. The one subtree is the type to which the argument should be cast. */ DEMANGLE_COMPONENT_CAST, /* A unary expression. The left subtree is the operator, and the right subtree is the single argument. */ DEMANGLE_COMPONENT_UNARY, /* A binary expression. The left subtree is the operator, and the right subtree is a BINARY_ARGS. */ DEMANGLE_COMPONENT_BINARY, /* Arguments to a binary expression. The left subtree is the first argument, and the right subtree is the second argument. */ DEMANGLE_COMPONENT_BINARY_ARGS, /* A trinary expression. The left subtree is the operator, and the right subtree is a TRINARY_ARG1. */ DEMANGLE_COMPONENT_TRINARY, /* Arguments to a trinary expression. The left subtree is the first argument, and the right subtree is a TRINARY_ARG2. */ DEMANGLE_COMPONENT_TRINARY_ARG1, /* More arguments to a trinary expression. The left subtree is the second argument, and the right subtree is the third argument. */ DEMANGLE_COMPONENT_TRINARY_ARG2, /* A literal. The left subtree is the type, and the right subtree is the value, represented as a DEMANGLE_COMPONENT_NAME. */ DEMANGLE_COMPONENT_LITERAL, /* A negative literal. Like LITERAL, but the value is negated. This is a minor hack: the NAME used for LITERAL points directly to the mangled string, but since negative numbers are mangled using 'n' instead of '-', we want a way to indicate a negative number which involves neither modifying the mangled string nor allocating a new copy of the literal in memory. */ DEMANGLE_COMPONENT_LITERAL_NEG, /* A libgcj compiled resource. The left subtree is the name of the resource. */ DEMANGLE_COMPONENT_JAVA_RESOURCE, /* A name formed by the concatenation of two parts. The left subtree is the first part and the right subtree the second. */ DEMANGLE_COMPONENT_COMPOUND_NAME, /* A name formed by a single character. */ DEMANGLE_COMPONENT_CHARACTER, /* A number. */ DEMANGLE_COMPONENT_NUMBER, /* A decltype type. */ DEMANGLE_COMPONENT_DECLTYPE, /* Global constructors keyed to name. */ DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS, /* Global destructors keyed to name. */ DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS, /* A lambda closure type. */ DEMANGLE_COMPONENT_LAMBDA, /* A default argument scope. */ DEMANGLE_COMPONENT_DEFAULT_ARG, /* An unnamed type. */ DEMANGLE_COMPONENT_UNNAMED_TYPE, /* A pack expansion. */ DEMANGLE_COMPONENT_PACK_EXPANSION }; /* Types which are only used internally. */ struct demangle_operator_info; struct demangle_builtin_type_info; /* A node in the tree representation is an instance of a struct demangle_component. Note that the field names of the struct are not well protected against macros defined by the file including this one. We can fix this if it ever becomes a problem. */ struct demangle_component { /* The type of this component. */ enum demangle_component_type type; union { /* For DEMANGLE_COMPONENT_NAME. */ struct { /* A pointer to the name (which need not NULL terminated) and its length. */ const char *s; int len; } s_name; /* For DEMANGLE_COMPONENT_OPERATOR. */ struct { /* Operator. */ const struct demangle_operator_info *op; } s_operator; /* For DEMANGLE_COMPONENT_EXTENDED_OPERATOR. */ struct { /* Number of arguments. */ int args; /* Name. */ struct demangle_component *name; } s_extended_operator; /* For DEMANGLE_COMPONENT_FIXED_TYPE. */ struct { /* The length, indicated by a C integer type name. */ struct demangle_component *length; /* _Accum or _Fract? */ short accum; /* Saturating or not? */ short sat; } s_fixed; /* For DEMANGLE_COMPONENT_CTOR. */ struct { /* Kind of constructor. */ enum gnu_v3_ctor_kinds kind; /* Name. */ struct demangle_component *name; } s_ctor; /* For DEMANGLE_COMPONENT_DTOR. */ struct { /* Kind of destructor. */ enum gnu_v3_dtor_kinds kind; /* Name. */ struct demangle_component *name; } s_dtor; /* For DEMANGLE_COMPONENT_BUILTIN_TYPE. */ struct { /* Builtin type. */ const struct demangle_builtin_type_info *type; } s_builtin; /* For DEMANGLE_COMPONENT_SUB_STD. */ struct { /* Standard substitution string. */ const char* string; /* Length of string. */ int len; } s_string; /* For DEMANGLE_COMPONENT_*_PARAM. */ struct { /* Parameter index. */ long number; } s_number; /* For DEMANGLE_COMPONENT_CHARACTER. */ struct { int character; } s_character; /* For other types. */ struct { /* Left (or only) subtree. */ struct demangle_component *left; /* Right subtree. */ struct demangle_component *right; } s_binary; struct { /* subtree, same place as d_left. */ struct demangle_component *sub; /* integer. */ int num; } s_unary_num; } u; }; /* People building mangled trees are expected to allocate instances of struct demangle_component themselves. They can then call one of the following functions to fill them in. */ /* Fill in most component types with a left subtree and a right subtree. Returns non-zero on success, zero on failure, such as an unrecognized or inappropriate component type. */ extern int cplus_demangle_fill_component (struct demangle_component *fill, enum demangle_component_type, struct demangle_component *left, struct demangle_component *right); /* Fill in a DEMANGLE_COMPONENT_NAME. Returns non-zero on success, zero for bad arguments. */ extern int cplus_demangle_fill_name (struct demangle_component *fill, const char *, int); /* Fill in a DEMANGLE_COMPONENT_BUILTIN_TYPE, using the name of the builtin type (e.g., "int", etc.). Returns non-zero on success, zero if the type is not recognized. */ extern int cplus_demangle_fill_builtin_type (struct demangle_component *fill, const char *type_name); /* Fill in a DEMANGLE_COMPONENT_OPERATOR, using the name of the operator and the number of arguments which it takes (the latter is used to disambiguate operators which can be both binary and unary, such as '-'). Returns non-zero on success, zero if the operator is not recognized. */ extern int cplus_demangle_fill_operator (struct demangle_component *fill, const char *opname, int args); /* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR, providing the number of arguments and the name. Returns non-zero on success, zero for bad arguments. */ extern int cplus_demangle_fill_extended_operator (struct demangle_component *fill, int numargs, struct demangle_component *nm); /* Fill in a DEMANGLE_COMPONENT_CTOR. Returns non-zero on success, zero for bad arguments. */ extern int cplus_demangle_fill_ctor (struct demangle_component *fill, enum gnu_v3_ctor_kinds kind, struct demangle_component *name); /* Fill in a DEMANGLE_COMPONENT_DTOR. Returns non-zero on success, zero for bad arguments. */ extern int cplus_demangle_fill_dtor (struct demangle_component *fill, enum gnu_v3_dtor_kinds kind, struct demangle_component *name); /* This function translates a mangled name into a struct demangle_component tree. The first argument is the mangled name. The second argument is DMGL_* options. This returns a pointer to a tree on success, or NULL on failure. On success, the third argument is set to a block of memory allocated by malloc. This block should be passed to free when the tree is no longer needed. */ extern struct demangle_component * cplus_demangle_v3_components (const char *mangled, int options, void **mem); /* This function takes a struct demangle_component tree and returns the corresponding demangled string. The first argument is DMGL_* options. The second is the tree to demangle. The third is a guess at the length of the demangled string, used to initially allocate the return buffer. The fourth is a pointer to a size_t. On success, this function returns a buffer allocated by malloc(), and sets the size_t pointed to by the fourth argument to the size of the allocated buffer (not the length of the returned string). On failure, this function returns NULL, and sets the size_t pointed to by the fourth argument to 0 for an invalid tree, or to 1 for a memory allocation error. */ extern char * cplus_demangle_print (int options, const struct demangle_component *tree, int estimated_length, size_t *p_allocated_size); /* This function takes a struct demangle_component tree and passes back a demangled string in one or more calls to a callback function. The first argument is DMGL_* options. The second is the tree to demangle. The third is a pointer to a callback function; on each call this receives an element of the demangled string, its length, and an opaque value. The fourth is the opaque value passed to the callback. The callback is called once or more to return the full demangled string. The demangled element string is always nul-terminated, though its length is also provided for convenience. In contrast to cplus_demangle_print(), this function does not allocate heap memory to grow output strings (except perhaps where alloca() is implemented by malloc()), and so is normally safe for use where the heap has been corrupted. On success, this function returns 1; on failure, 0. */ extern int cplus_demangle_print_callback (int options, const struct demangle_component *tree, demangle_callbackref callback, void *opaque); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* DEMANGLE_H */ ht-2.0.22/htleobj.cc0000644000175000001440000000612410620177260011067 00000000000000/* * HT Editor * htleobj.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "atom.h" #include "htnewexe.h" #include "htle.h" #include "htleobj.h" #include "httag.h" #include "strtools.h" #include "formats.h" #include "snprintf.h" #include "lestruct.h" #include #include static ht_mask_ptable leobj[]= { {"virtual size", STATICTAG_EDIT_DWORD_LE("00000000")}, {"relocation base address", STATICTAG_EDIT_DWORD_LE("00000004")}, {"flags", STATICTAG_EDIT_DWORD_LE("00000008")" "STATICTAG_FLAGS("00000008", ATOM_LE_OBJFLAGS_STR)}, {"page map index", STATICTAG_EDIT_DWORD_LE("0000000c")}, {"page map count", STATICTAG_EDIT_DWORD_LE("00000010")}, {"name", STATICTAG_EDIT_CHAR("00000014")""STATICTAG_EDIT_CHAR("00000015")""STATICTAG_EDIT_CHAR("00000016")""STATICTAG_EDIT_CHAR("00000017")}, {0, 0} }; static ht_tag_flags_s le_objflags[] = { {0, "[00] readable"}, {1, "[01] writable"}, {2, "[02] executable"}, {3, "[03] resource"}, {4, "[04] discardable"}, {5, "[05] shared"}, {6, "[06] preloaded"}, {7, "[07] * reserved"}, {8, "[08] * reserved"}, {9, "[09] * reserved"}, {10, "[10] resident"}, {11, "[11] * reserved"}, {12, "[12] 16:16 alias"}, {13, "[13] use32"}, {14, "[14] conforming"}, {15, "[15] object i/o privilege level"}, {0, 0} }; static ht_view *htleobjects_init(Bounds *b, File *file, ht_format_group *group) { ht_le_shared_data *le_shared=(ht_le_shared_data *)group->get_shared_data(); uint32 h=le_shared->hdr_ofs; ht_uformat_viewer *v=new ht_uformat_viewer(); v->init(b, DESC_LE_OBJECTS, VC_EDIT, file, group); ht_mask_sub *m=new ht_mask_sub(); m->init(file, 0); registerAtom(ATOM_LE_OBJFLAGS, le_objflags); /* FIXME: */ bool le_bigendian = false; char t[64]; ht_snprintf(t, sizeof t, "* LE object headers at offset 0x%08qx", h+le_shared->hdr.objtab); m->add_mask(t); v->insertsub(m); for (uint32 i=0; ihdr.objcnt; i++) { m=new ht_mask_sub(); m->init(file, i); char n[5]; m->add_staticmask_ptable(leobj, h+le_shared->hdr.objtab+i*24, le_bigendian); memcpy(&n, le_shared->objmap.header[i].name, 4); n[4]=0; bool use32=le_shared->objmap.header[i].flags & LE_OBJECT_FLAG_USE32; ht_snprintf(t, sizeof t, "--- object %d USE%d: %s ---", i+1, use32 ? 32 : 16, (char*)&n); ht_collapsable_sub *cs=new ht_collapsable_sub(); cs->init(file, m, 1, t, 1); v->insertsub(cs); } le_shared->v_objects = v; return v; } format_viewer_if htleobjects_if = { htleobjects_init, 0 }; ht-2.0.22/htne.h0000644000175000001440000000767110615341620010245 00000000000000/* * HT Editor * htne.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTNE_H__ #define __HTNE_H__ #include "htobj.h" #include "formats.h" #include "relfile.h" #include "nestruct.h" #define DESC_NE "ne - win16,os2 new exe" #define DESC_NE_HEADER "ne/header" #define DESC_NE_SEGMENTS "ne/segments" #define DESC_NE_IMPORTS "ne/imports" #define DESC_NE_ENTRYPOINTS "ne/entrypoints" #define DESC_NE_NAMES "ne/names" #define DESC_NE_IMAGE "ne/image" #define ATOM_NE_FLAGS 0x4e450000 #define ATOM_NE_FLAGS_STR "4e450000" #define ATOM_NE_OS 0x4e450001 #define ATOM_NE_OS_STR "4e450001" #define ATOM_NE_SEGFLAGS 0x4e450002 #define ATOM_NE_SEGFLAGS_STR "4e450002" #define ATOM_NE_ENTFLAGS 0x4e450003 #define ATOM_NE_ENTFLAGS_STR "4e450003" struct ne_segment_headers { uint segment_count; NE_SEGMENT *segments; }; class ne_import_rec: public Object { public: uint addr; uint module; bool byname; union { uint name_ofs; uint ord; }; ne_import_rec(uint a, uint mod, bool b, uint i); virtual int compareTo(const Object *obj) const; }; class ht_aviewer; struct ht_ne_shared_data { uint32 hdr_ofs; NE_HEADER hdr; ne_segment_headers segments; uint modnames_count; char **modnames; uint fake_segment; Container *entrypoints; Container *imports; ht_aviewer *v_image; }; class ht_ne: public ht_format_group { protected: bool loc_enum; bool create_fake_segment(); bool relocate(ht_reloc_file *rf); bool relocate_single(ht_reloc_file *rf, uint seg, FileOfs ofs, uint type, uint flags, uint16 value_seg, uint16 value_ofs); public: void init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs h); virtual void done(); /* overwritten */ virtual void loc_enum_start(); virtual bool loc_enum_next(ht_format_loc *loc); }; extern format_viewer_if htne_if; /* * CLASS ht_ne_entrypoint */ class ht_ne_entrypoint: public Object { public: uint ordinal; uint seg; uint offset; uint flags; char *name; ht_ne_entrypoint(uint ordinal, uint seg, uint offset, uint flags); virtual ~ht_ne_entrypoint(); }; /* * CLASS ht_ne_reloc_entry */ class ht_ne_reloc_entry: public Object { public: uint mode; bool add; uint16 seg; uint16 ofs; ht_ne_reloc_entry(uint mode, bool add, uint16 seg, uint16 ofs); }; /* * CLASS ht_ne_reloc_file */ class ht_ne_reloc_file: public ht_reloc_file { protected: ht_ne_shared_data *data; /* overwritten */ virtual void reloc_apply(Object *reloc, byte *data); virtual bool reloc_unapply(Object *reloc, byte *data); public: ht_ne_reloc_file(File *streamfile, bool own_streamfile, ht_ne_shared_data *data); }; /* * */ FileOfs NE_get_seg_ofs(ht_ne_shared_data *NE_shared, uint i); uint32 NE_get_seg_addr(ht_ne_shared_data *NE_shared, uint i); uint NE_get_seg_psize(ht_ne_shared_data *NE_shared, uint i); uint NE_get_seg_vsize(ht_ne_shared_data *NE_shared, uint i); bool NE_addr_to_segment(ht_ne_shared_data *NE_shared, uint32 Addr, int *segment); bool NE_addr_is_physical(ht_ne_shared_data *NE_shared, uint32 Addr); bool NE_addr_to_ofs(ht_ne_shared_data *NE_shared, uint32 Addr, FileOfs *ofs); bool NE_ofs_to_addr(ht_ne_shared_data *NE_shared, FileOfs ofs, uint32 *Addr); #define NEAddress uint32 #define NE_MAKE_ADDR(seg, ofs) ((seg)*0x10000+(ofs)) #define NE_ADDR_SEG(a) ((a)>>16) #define NE_ADDR_OFS(a) ((a)&0xffff) #endif /* __HTNE_H__ */ ht-2.0.22/mzstruct.cc0000644000175000001440000000401410615341624011330 00000000000000/* * HT Editor * mzstruct.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "endianess.h" #include "mzstruct.h" #include "coff_s.h" byte MZ_HEADER_struct[] = { STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; ht-2.0.22/log.cc0000644000175000001440000000210310206756711010216 00000000000000/* * HT Editor * log.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "htapp.h" #include "log.h" #include "snprintf.h" void ht_logf(int color, const char *format, ...) { char buf[256]; va_list arg; va_start(arg, format); ht_vsnprintf(buf, sizeof buf, format, arg); va_end(arg); loglines->log(color, buf); ht_window *w = ((ht_app*)app)->get_window_by_type(AWT_LOG); if (w) w->sendmsg(msg_log_changed); app->sendmsg(msg_draw); } ht-2.0.22/htmachohd.cc0000644000175000001440000004020410660121021011360 00000000000000/* * HT Editor * htmachohd.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "machostruc.h" #include "atom.h" #include "htmacho.h" #include "htmachohd.h" #include "httag.h" #include "formats.h" #include "snprintf.h" static ht_mask_ptable machoheader[]= { {"magic", STATICTAG_EDIT_DWORD_VE("00000000")}, {"cputype", STATICTAG_EDIT_DWORD_VE("00000004")}, {"cpusubtype", STATICTAG_EDIT_DWORD_VE("00000008")}, {"filetype", STATICTAG_EDIT_DWORD_VE("0000000c")}, {"number of cmds", STATICTAG_EDIT_DWORD_VE("00000010")}, {"size of cmds", STATICTAG_EDIT_DWORD_VE("00000014")}, {"flags", STATICTAG_EDIT_DWORD_VE("00000018")}, {0, 0} }; static ht_mask_ptable macho_segment_header[]= { {"cmd", STATICTAG_EDIT_DWORD_VE("00000000")}, {"cmdsize", STATICTAG_EDIT_DWORD_VE("00000004")}, {"name", STATICTAG_EDIT_CHAR("00000008")STATICTAG_EDIT_CHAR("00000009") STATICTAG_EDIT_CHAR("0000000a")STATICTAG_EDIT_CHAR("0000000b") STATICTAG_EDIT_CHAR("0000000c")STATICTAG_EDIT_CHAR("0000000d") STATICTAG_EDIT_CHAR("0000000e")STATICTAG_EDIT_CHAR("0000000f") STATICTAG_EDIT_CHAR("00000010")STATICTAG_EDIT_CHAR("00000011") STATICTAG_EDIT_CHAR("00000012")STATICTAG_EDIT_CHAR("00000013") STATICTAG_EDIT_CHAR("00000014")STATICTAG_EDIT_CHAR("00000015") STATICTAG_EDIT_CHAR("00000016")STATICTAG_EDIT_CHAR("00000017") }, {"virtual address", STATICTAG_EDIT_DWORD_VE("00000018")}, {"virtual size", STATICTAG_EDIT_DWORD_VE("0000001c")}, {"file offset", STATICTAG_EDIT_DWORD_VE("00000020")}, {"file size", STATICTAG_EDIT_DWORD_VE("00000024")}, {"max VM protection", STATICTAG_EDIT_DWORD_VE("00000028")}, {"init VM protection", STATICTAG_EDIT_DWORD_VE("0000002c")}, {"number of sections", STATICTAG_EDIT_DWORD_VE("00000030")}, {"flags", STATICTAG_EDIT_DWORD_VE("00000034")}, {0, 0} }; static ht_mask_ptable macho_segment_64_header[]= { {"cmd", STATICTAG_EDIT_DWORD_VE("00000000")}, {"cmdsize", STATICTAG_EDIT_DWORD_VE("00000004")}, {"name", STATICTAG_EDIT_CHAR("00000008")STATICTAG_EDIT_CHAR("00000009") STATICTAG_EDIT_CHAR("0000000a")STATICTAG_EDIT_CHAR("0000000b") STATICTAG_EDIT_CHAR("0000000c")STATICTAG_EDIT_CHAR("0000000d") STATICTAG_EDIT_CHAR("0000000e")STATICTAG_EDIT_CHAR("0000000f") STATICTAG_EDIT_CHAR("00000010")STATICTAG_EDIT_CHAR("00000011") STATICTAG_EDIT_CHAR("00000012")STATICTAG_EDIT_CHAR("00000013") STATICTAG_EDIT_CHAR("00000014")STATICTAG_EDIT_CHAR("00000015") STATICTAG_EDIT_CHAR("00000016")STATICTAG_EDIT_CHAR("00000017") }, {"virtual address", STATICTAG_EDIT_QWORD_VE("00000018")}, {"virtual size", STATICTAG_EDIT_QWORD_VE("00000020")}, {"file offset", STATICTAG_EDIT_QWORD_VE("00000028")}, {"file size", STATICTAG_EDIT_QWORD_VE("00000030")}, {"max VM protection", STATICTAG_EDIT_DWORD_VE("00000038")}, {"init VM protection", STATICTAG_EDIT_DWORD_VE("0000003c")}, {"number of sections", STATICTAG_EDIT_DWORD_VE("00000040")}, {"flags", STATICTAG_EDIT_DWORD_VE("00000044")}, {0, 0} }; static ht_mask_ptable macho_section_header[]= { {"section name", STATICTAG_EDIT_CHAR("00000000")STATICTAG_EDIT_CHAR("00000001") STATICTAG_EDIT_CHAR("00000002")STATICTAG_EDIT_CHAR("00000003") STATICTAG_EDIT_CHAR("00000004")STATICTAG_EDIT_CHAR("00000005") STATICTAG_EDIT_CHAR("00000006")STATICTAG_EDIT_CHAR("00000007") STATICTAG_EDIT_CHAR("00000008")STATICTAG_EDIT_CHAR("00000009") STATICTAG_EDIT_CHAR("0000000a")STATICTAG_EDIT_CHAR("0000000b") STATICTAG_EDIT_CHAR("0000000c")STATICTAG_EDIT_CHAR("0000000d") STATICTAG_EDIT_CHAR("0000000e")STATICTAG_EDIT_CHAR("0000000f") }, {"segment name", STATICTAG_EDIT_CHAR("00000010")STATICTAG_EDIT_CHAR("00000011") STATICTAG_EDIT_CHAR("00000012")STATICTAG_EDIT_CHAR("00000013") STATICTAG_EDIT_CHAR("00000014")STATICTAG_EDIT_CHAR("00000015") STATICTAG_EDIT_CHAR("00000016")STATICTAG_EDIT_CHAR("00000017") STATICTAG_EDIT_CHAR("00000018")STATICTAG_EDIT_CHAR("00000019") STATICTAG_EDIT_CHAR("0000001a")STATICTAG_EDIT_CHAR("0000001b") STATICTAG_EDIT_CHAR("0000001c")STATICTAG_EDIT_CHAR("0000001d") STATICTAG_EDIT_CHAR("0000001e")STATICTAG_EDIT_CHAR("0000001f") }, {"virtual address", STATICTAG_EDIT_DWORD_VE("00000020")}, {"virtual size", STATICTAG_EDIT_DWORD_VE("00000024")}, {"file offset", STATICTAG_EDIT_DWORD_VE("00000028")}, {"alignment", STATICTAG_EDIT_DWORD_VE("0000002c")}, {"relocation file offset", STATICTAG_EDIT_DWORD_VE("00000030")}, {"number of relocation entries",STATICTAG_EDIT_DWORD_VE("00000034")}, {"flags", STATICTAG_EDIT_DWORD_VE("00000038")}, {"reserved1", STATICTAG_EDIT_DWORD_VE("0000003c")}, {"reserved2", STATICTAG_EDIT_DWORD_VE("00000040")}, {0, 0} }; static ht_mask_ptable macho_section_64_header[]= { {"section name", STATICTAG_EDIT_CHAR("00000000")STATICTAG_EDIT_CHAR("00000001") STATICTAG_EDIT_CHAR("00000002")STATICTAG_EDIT_CHAR("00000003") STATICTAG_EDIT_CHAR("00000004")STATICTAG_EDIT_CHAR("00000005") STATICTAG_EDIT_CHAR("00000006")STATICTAG_EDIT_CHAR("00000007") STATICTAG_EDIT_CHAR("00000008")STATICTAG_EDIT_CHAR("00000009") STATICTAG_EDIT_CHAR("0000000a")STATICTAG_EDIT_CHAR("0000000b") STATICTAG_EDIT_CHAR("0000000c")STATICTAG_EDIT_CHAR("0000000d") STATICTAG_EDIT_CHAR("0000000e")STATICTAG_EDIT_CHAR("0000000f") }, {"segment name", STATICTAG_EDIT_CHAR("00000010")STATICTAG_EDIT_CHAR("00000011") STATICTAG_EDIT_CHAR("00000012")STATICTAG_EDIT_CHAR("00000013") STATICTAG_EDIT_CHAR("00000014")STATICTAG_EDIT_CHAR("00000015") STATICTAG_EDIT_CHAR("00000016")STATICTAG_EDIT_CHAR("00000017") STATICTAG_EDIT_CHAR("00000018")STATICTAG_EDIT_CHAR("00000019") STATICTAG_EDIT_CHAR("0000001a")STATICTAG_EDIT_CHAR("0000001b") STATICTAG_EDIT_CHAR("0000001c")STATICTAG_EDIT_CHAR("0000001d") STATICTAG_EDIT_CHAR("0000001e")STATICTAG_EDIT_CHAR("0000001f") }, {"virtual address", STATICTAG_EDIT_QWORD_VE("00000020")}, {"virtual size", STATICTAG_EDIT_QWORD_VE("00000028")}, {"file offset", STATICTAG_EDIT_DWORD_VE("00000030")}, {"alignment", STATICTAG_EDIT_DWORD_VE("00000034")}, {"relocation file offset", STATICTAG_EDIT_DWORD_VE("00000038")}, {"number of relocation entries",STATICTAG_EDIT_DWORD_VE("0000003c")}, {"flags", STATICTAG_EDIT_DWORD_VE("00000040")}, {"reserved1", STATICTAG_EDIT_DWORD_VE("00000044")}, {"reserved2", STATICTAG_EDIT_DWORD_VE("00000048")}, {"reserved3", STATICTAG_EDIT_DWORD_VE("0000004c")}, {0, 0} }; static ht_mask_ptable macho_thread_header[]= { {"cmd", STATICTAG_EDIT_DWORD_VE("00000000")}, {"cmdsize", STATICTAG_EDIT_DWORD_VE("00000004")}, {"flavor", STATICTAG_EDIT_DWORD_VE("00000008")}, {"count (of 32bit words)", STATICTAG_EDIT_DWORD_VE("0000000c")}, {0, 0} }; static ht_mask_ptable macho_ppc_thread_state[]= { {"srr0", STATICTAG_EDIT_DWORD_VE("00000000")}, {"srr1", STATICTAG_EDIT_DWORD_VE("00000004")}, {"flavor", STATICTAG_EDIT_DWORD_VE("00000008")}, {"r0", STATICTAG_EDIT_DWORD_VE("0000000c")}, {"r1", STATICTAG_EDIT_DWORD_VE("00000010")}, {"r2", STATICTAG_EDIT_DWORD_VE("00000014")}, {"r3", STATICTAG_EDIT_DWORD_VE("00000018")}, {"r4", STATICTAG_EDIT_DWORD_VE("0000001c")}, {"r5", STATICTAG_EDIT_DWORD_VE("00000020")}, {"r6", STATICTAG_EDIT_DWORD_VE("00000024")}, {"r7", STATICTAG_EDIT_DWORD_VE("00000028")}, {"r8", STATICTAG_EDIT_DWORD_VE("0000002c")}, {"r9", STATICTAG_EDIT_DWORD_VE("00000030")}, {"r10", STATICTAG_EDIT_DWORD_VE("00000034")}, {"r11", STATICTAG_EDIT_DWORD_VE("00000038")}, {"r12", STATICTAG_EDIT_DWORD_VE("0000003c")}, {"r13", STATICTAG_EDIT_DWORD_VE("00000040")}, {"r14", STATICTAG_EDIT_DWORD_VE("00000044")}, {"r15", STATICTAG_EDIT_DWORD_VE("00000048")}, {"r16", STATICTAG_EDIT_DWORD_VE("0000004c")}, {"r17", STATICTAG_EDIT_DWORD_VE("00000050")}, {"r18", STATICTAG_EDIT_DWORD_VE("00000054")}, {"r19", STATICTAG_EDIT_DWORD_VE("00000058")}, {"r20", STATICTAG_EDIT_DWORD_VE("0000005c")}, {"r21", STATICTAG_EDIT_DWORD_VE("00000060")}, {"r22", STATICTAG_EDIT_DWORD_VE("00000064")}, {"r23", STATICTAG_EDIT_DWORD_VE("00000068")}, {"r24", STATICTAG_EDIT_DWORD_VE("0000006c")}, {"r25", STATICTAG_EDIT_DWORD_VE("00000070")}, {"r26", STATICTAG_EDIT_DWORD_VE("00000074")}, {"r27", STATICTAG_EDIT_DWORD_VE("00000078")}, {"r28", STATICTAG_EDIT_DWORD_VE("0000007c")}, {"r29", STATICTAG_EDIT_DWORD_VE("00000080")}, {"r30", STATICTAG_EDIT_DWORD_VE("00000084")}, {"r31", STATICTAG_EDIT_DWORD_VE("00000088")}, {"cr", STATICTAG_EDIT_DWORD_VE("0000008c")}, {"xer", STATICTAG_EDIT_DWORD_VE("00000090")}, {"lr", STATICTAG_EDIT_DWORD_VE("00000094")}, {"ctr", STATICTAG_EDIT_DWORD_VE("00000098")}, {"mq", STATICTAG_EDIT_DWORD_VE("0000009c")}, {"vrsave", STATICTAG_EDIT_DWORD_VE("000000a0")}, {0, 0} }; static ht_mask_ptable macho_i386_thread_state[]= { {"eax", STATICTAG_EDIT_DWORD_VE("00000000")}, {"ebx", STATICTAG_EDIT_DWORD_VE("00000004")}, {"ecx", STATICTAG_EDIT_DWORD_VE("00000008")}, {"edx", STATICTAG_EDIT_DWORD_VE("0000000c")}, {"edi", STATICTAG_EDIT_DWORD_VE("00000010")}, {"esi", STATICTAG_EDIT_DWORD_VE("00000014")}, {"ebp", STATICTAG_EDIT_DWORD_VE("00000018")}, {"esp", STATICTAG_EDIT_DWORD_VE("0000001c")}, {"ss", STATICTAG_EDIT_DWORD_VE("00000020")}, {"eflags", STATICTAG_EDIT_DWORD_VE("00000024")}, {"eip", STATICTAG_EDIT_DWORD_VE("00000028")}, {"cs", STATICTAG_EDIT_DWORD_VE("0000002c")}, {"ds", STATICTAG_EDIT_DWORD_VE("00000030")}, {"es", STATICTAG_EDIT_DWORD_VE("00000034")}, {"fs", STATICTAG_EDIT_DWORD_VE("00000038")}, {"gs", STATICTAG_EDIT_DWORD_VE("0000003c")}, {0, 0} }; static ht_view *htmachoheader_init(Bounds *b, File *file, ht_format_group *group) { ht_macho_shared_data *macho_shared=(ht_macho_shared_data *)group->get_shared_data(); ht_uformat_viewer *v=new ht_uformat_viewer(); v->init(b, DESC_MACHO_HEADER, VC_EDIT, file, group); ht_mask_sub *m = new ht_mask_sub(); m->init(file, 0); char info[128]; ht_snprintf(info, sizeof info, "* Mach-O header at offset %08qx", macho_shared->header_ofs); bool isbigendian; switch (macho_shared->image_endianess) { case little_endian: isbigendian = false; break; case big_endian: isbigendian = true; break; } m->add_mask(info); m->add_staticmask_ptable(machoheader, macho_shared->header_ofs, isbigendian); FileOfs ofs = macho_shared->header_ofs; if (macho_shared->_64) { ofs += 8*4; } else { ofs += 7*4; } for (uint i=0; icmds.count; i++) { switch (macho_shared->cmds.cmds[i]->cmd.cmd) { case LC_SEGMENT: { MACHO_SEGMENT_COMMAND *c = (MACHO_SEGMENT_COMMAND *)macho_shared->cmds.cmds[i]; char info[128]; ht_snprintf(info, sizeof info, "** segment %s", c->segname); m->add_mask(info); m->add_staticmask_ptable(macho_segment_header, ofs, isbigendian); FileOfs sofs = sizeof (MACHO_SEGMENT_COMMAND); for (uint j=0; j < c->nsects; j++) { ht_snprintf(info, sizeof info, "**** section %d ****", j); m->add_mask(info); m->add_staticmask_ptable(macho_section_header, ofs+sofs, isbigendian); sofs += 9*4+16+16; } break; } case LC_SEGMENT_64: { MACHO_SEGMENT_64_COMMAND *c = (MACHO_SEGMENT_64_COMMAND *)macho_shared->cmds.cmds[i]; char info[128]; ht_snprintf(info, sizeof info, "** segment64 %s", c->segname); m->add_mask(info); m->add_staticmask_ptable(macho_segment_64_header, ofs, isbigendian); FileOfs sofs = sizeof (MACHO_SEGMENT_64_COMMAND); for (uint j=0; j < c->nsects; j++) { ht_snprintf(info, sizeof info, "**** section %d ****", j); m->add_mask(info); m->add_staticmask_ptable(macho_section_64_header, ofs+sofs, isbigendian); sofs += 2*8+8*4+16+16; } break; } case LC_SYMTAB: { char info[128]; ht_snprintf(info, sizeof info, "** SYMTAB cmdsize %08x", macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); break; } case LC_SYMSEG: { char info[128]; ht_snprintf(info, sizeof info, "** SYMSEG cmdsize %08x", macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); break; } case LC_UNIXTHREAD: case LC_THREAD: { MACHO_THREAD_COMMAND *c = &macho_shared->cmds.cmds[i]->thread; char info[128]; ht_snprintf(info, sizeof info, "** %s", (macho_shared->cmds.cmds[i]->cmd.cmd == LC_UNIXTHREAD) ? "UNIXTHREAD" : "THREAD"); m->add_mask(info); m->add_staticmask_ptable(macho_thread_header, ofs, isbigendian); switch (macho_shared->header.cputype) { case MACHO_CPU_TYPE_I386: switch (c->flavor) { case -1: m->add_staticmask_ptable(macho_i386_thread_state, ofs+4*4/*4 32bit words in thread_header*/, isbigendian); break; } break; case MACHO_CPU_TYPE_POWERPC: switch (c->flavor) { case FLAVOR_PPC_THREAD_STATE: m->add_staticmask_ptable(macho_ppc_thread_state, ofs+4*4/*4 32bit words in thread_header*/, isbigendian); break; } break; } break; } /* case LC_THREAD: { char info[128]; ht_snprintf(info, sizeof info, "** THREAD cmdsize %08x", macho_shared->cmds[i]->cmdsize); m->add_mask(info); break; } case LC_UNIXTHREAD: { char info[128]; ht_snprintf(info, sizeof info, "** UNIXTHREAD cmdsize %08x", macho_shared->cmds[i]->cmdsize); m->add_mask(info); break; }*/ case LC_LOADFVMLIB: { char info[128]; ht_snprintf(info, sizeof info, "** LOADFVMLIB cmdsize %08x", macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); break; } case LC_IDFVMLIB: { char info[128]; ht_snprintf(info, sizeof info, "** IDFVMLIB cmdsize %08x", macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); break; } case LC_IDENT: { char info[128]; ht_snprintf(info, sizeof info, "** IDENT (obsolete) cmdsize %08x", macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); break; } case LC_FVMFILE: { char info[128]; ht_snprintf(info, sizeof info, "** FVMFILE cmdsize %08x", macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); break; } case LC_PREPAGE: { char info[128]; ht_snprintf(info, sizeof info, "** PREPAGE cmdsize %08x", macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); break; } case LC_DYSYMTAB: { char info[128]; ht_snprintf(info, sizeof info, "** DYSYMTAB cmdsize %08x", macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); break; } case LC_LOAD_DYLIB: { char info[128]; ht_snprintf(info, sizeof info, "** LOAD_DYLIB cmdsize %08x", macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); break; } case LC_ID_DYLIB: { char info[128]; ht_snprintf(info, sizeof info, "** ID_DYLIB cmdsize %08x", macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); break; } case LC_LOAD_DYLINKER: { char info[128]; ht_snprintf(info, sizeof info, "** LOAD_DYLINKER cmdsize %08x", macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); break; } case LC_ID_DYLINKER: { char info[128]; ht_snprintf(info, sizeof info, "** ID_DYLINKER cmdsize %08x", macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); break; } case LC_PREBOUND_DYLIB: { char info[128]; ht_snprintf(info, sizeof info, "** PREBOUND_DYLIB cmdsize %08x", macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); break; } case LC_UUID: { char info[128]; ht_snprintf(info, sizeof info, "** UUID cmdsize %08x", macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); break; } default: { char info[128]; ht_snprintf(info, sizeof info, "** unsupported load command %08x, size %08x", macho_shared->cmds.cmds[i]->cmd.cmd, macho_shared->cmds.cmds[i]->cmd.cmdsize); m->add_mask(info); } } ofs += macho_shared->cmds.cmds[i]->cmd.cmdsize; } v->insertsub(m); return v; } format_viewer_if htmachoheader_if = { htmachoheader_init, 0 }; ht-2.0.22/htpedimp.cc0000644000175000001440000001506210771304342011253 00000000000000/* * HT Editor * htpedimp.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "formats.h" #include "htanaly.h" #include "htctrl.h" #include "endianess.h" #include "htiobox.h" #include "htnewexe.h" #include "htpal.h" #include "htpe.h" #include "htpeimp.h" #include "htpedimp.h" #include "httag.h" #include "strtools.h" #include "log.h" #include "pe_analy.h" #include "snprintf.h" #include "stream.h" #include static ht_view *htpedelayimports_init(Bounds *b, File *file, ht_format_group *group) { ht_pe_shared_data *pe_shared=(ht_pe_shared_data *)group->get_shared_data(); String fn; if (pe_shared->opt_magic!=COFF_OPTMAGIC_PE32) return NULL; RVA sec_rva = pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_DELAY_IMPORT].address; uint sec_size = pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_DELAY_IMPORT].size; if (!sec_rva || !sec_size) return NULL; int h0=new_timer(); start_timer(h0); uint dll_count=0; uint function_count=0; ht_group *g; Bounds c; ht_statictext *head; c=*b; g=new ht_group(); g->init(&c, VO_RESIZE, DESC_PE_DIMPORTS"-g"); c.y++; c.h--; ht_pe_dimport_viewer *v=new ht_pe_dimport_viewer(); v->init(&c, DESC_PE_DIMPORTS, group); PE_DELAY_IMPORT_DESCRIPTOR dimport; uint dll_index; char iline[256]; c.y--; c.h=1; /* get delay import directory offset */ /* 1. get import directory rva */ FileOfs iofs; RVA irva=pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_DELAY_IMPORT].address; // uint isize=pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_DELAY_IMPORT].size; /* 2. transform it into an offset */ if (!pe_rva_to_ofs(&pe_shared->sections, irva, &iofs)) goto pe_read_error; LOG("%y: PE: reading delay-import directory at offset 0x%08qx, rva 0x%08x, size 0x%08x...", &file->getFilename(fn), iofs, irva, pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_DELAY_IMPORT].size); /*** read delay import directory ***/ dll_index=0; while (1) { file->seek(iofs); file->read(&dimport, sizeof dimport); createHostStruct(&dimport, PE_DELAY_IMPORT_DESCRIPTOR_struct, little_endian); if (!dimport.name) break; uint32 base = dimport.attributes & 1 ? 0 : pe_shared->pe32.header_nt.image_base; FileOfs dllname_ofs; if (!pe_rva_to_ofs(&pe_shared->sections, dimport.name-base, &dllname_ofs)) goto pe_read_error; file->seek(dllname_ofs); char *dllname = file->fgetstrz(); ht_pe_import_library *lib=new ht_pe_import_library(dllname); pe_shared->dimports.libs->insert(lib); dll_count++; FileOfs ntofs, atofs; uint nva, ava; if (!pe_rva_to_ofs(&pe_shared->sections, dimport.delay_int-base, &ntofs)) goto pe_read_error; if (!pe_rva_to_ofs(&pe_shared->sections, dimport.delay_iat-base, &atofs)) goto pe_read_error; while (1) { ht_pe_import_function *func; file->seek(ntofs); file->read(&nva, 4); nva = createHostInt(&nva, 4, little_endian); if (!nva) break; function_count++; file->seek(atofs); file->read(&ava, 4); ava = createHostInt(&ava, 4, little_endian); if (nva & 0x80000000) { /* import by ordinal */ func=new ht_pe_import_function(dll_index, ava, nva&0xffff); } else { FileOfs nofs; /* import by name */ if (!pe_rva_to_ofs(&pe_shared->sections, nva-base, &nofs)) goto pe_read_error; uint16 hint=0; file->seek(nofs); file->read(&hint, 2); hint = createHostInt(&hint, 2, little_endian); char *name = file->fgetstrz(); func=new ht_pe_import_function(dll_index, ava, name, hint); free(name); } pe_shared->dimports.funcs->insert(func); ntofs+=4; atofs+=4; } free(dllname); iofs+=sizeof dimport; dll_index++; } stop_timer(h0); // LOG("%y: PE: %d ticks (%d msec) to read delay-imports", file->get_name(), get_timer_tick(h0), get_timer_msec(h0)); delete_timer(h0); ht_snprintf(iline, sizeof iline, "* PE delay-import directory at offset %08x (%d delay-imports from %d libraries)", iofs, function_count, dll_count); head=new ht_statictext(); head->init(&c, iline, align_left); g->insert(head); g->insert(v); // for (uint i=0; i < pe_shared->dimports.funcs->count(); i++) { ht_pe_import_function *func = (ht_pe_import_function*)(*pe_shared->dimports.funcs)[i]; assert(func); ht_pe_import_library *lib = (ht_pe_import_library*)(*pe_shared->dimports.libs)[func->libidx]; assert(lib); char addr[32], name[256]; ht_snprintf(addr, sizeof addr, "%08x", func->address); if (func->byname) { ht_snprintf(name, sizeof name, "%s", func->name.name); } else { ht_snprintf(name, sizeof name, "%04x (by ordinal)", func->ordinal); } v->insert_str(i, lib->name, addr, name); } // v->update(); g->setpalette(palkey_generic_window_default); pe_shared->v_dimports=v; return g; pe_read_error: delete_timer(h0); errorbox("%y: PE delay-import directory seems to be corrupted.", &file->getFilename(fn)); v->done(); delete v; g->done(); delete g; return NULL; } format_viewer_if htpedelayimports_if = { htpedelayimports_init, NULL }; /* * CLASS ht_pe_dimport_viewer */ bool ht_pe_dimport_viewer::select_entry(void *entry) { ht_text_listbox_item *i = (ht_text_listbox_item *)entry; ht_pe_shared_data *pe_shared=(ht_pe_shared_data *)format_group->get_shared_data(); ht_pe_import_function *e = (ht_pe_import_function*)(*pe_shared->dimports.funcs)[i->id]; if (!e) return true; if (pe_shared->v_image) { ht_aviewer *av = (ht_aviewer*)pe_shared->v_image; PEAnalyser *a = (PEAnalyser*)av->analy; Address *addr; if (pe_shared->opt_magic == COFF_OPTMAGIC_PE32) { addr = a->createAddress32(e->address/*+pe_shared->pe32.header_nt.image_base*/); } else { addr = a->createAddress64(e->address/*+pe_shared->pe64.header_nt.image_base*/); } if (av->gotoAddress(addr, NULL)) { app->focus(av); vstate_save(); } else { global_analyser_address_string_format = ADDRESS_STRING_FORMAT_COMPACT | ADDRESS_STRING_FORMAT_ADD_0X; errorbox("can't follow: %s %y is not valid!", "delay-import address", addr); } delete addr; } else errorbox("can't follow: no image viewer"); return true; } ht-2.0.22/pestruct.h0000644000175000001440000001631010615341624011152 00000000000000/* * HT Editor * pestruct.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __PESTRUCT_H_ #define __PESTRUCT_H_ #include "io/types.h" #include "tools.h" #include "coff_s.h" #define PE_MAGIC0 'P' #define PE_MAGIC1 'E' #define PE_MAGIC2 0 #define PE_MAGIC3 0 // // Directory format. // struct PE_DATA_DIRECTORY { uint32 address; uint32 size; } PACKED; #define PE_NUMBEROF_DIRECTORY_ENTRIES 16 // // Optional header format. // struct PE_OPTIONAL_HEADER32_NT { // NT additional fields. uint32 image_base; uint32 section_alignment; uint32 file_alignment; uint16 major_os_version; uint16 minor_os_version; uint16 major_image_version; uint16 minor_image_version; uint16 major_subsystem_version; uint16 minor_subsystem_version; uint32 win32_version; uint32 image_size; uint32 header_size; uint32 checksum; uint16 subsystem; uint16 dll_characteristics; uint32 stack_reserve_size; uint32 stack_commit_size; uint32 heap_reserve_size; uint32 heap_commit_size; uint32 loader_flags; uint32 directory_count; PE_DATA_DIRECTORY directory[PE_NUMBEROF_DIRECTORY_ENTRIES]; } PACKED; struct PE_OPTIONAL_HEADER64_NT { // NT additional fields. uint64 image_base; uint32 section_alignment; uint32 file_alignment; uint16 major_os_version; uint16 minor_os_version; uint16 major_image_version; uint16 minor_image_version; uint16 major_subsystem_version; uint16 minor_subsystem_version; uint32 win32_version; uint32 image_size; uint32 header_size; uint32 checksum; uint16 subsystem; uint16 dll_characteristics; uint64 stack_reserve_size; uint64 stack_commit_size; uint64 heap_reserve_size; uint64 heap_commit_size; uint32 loader_flags; uint32 directory_count; PE_DATA_DIRECTORY directory[PE_NUMBEROF_DIRECTORY_ENTRIES]; } PACKED; // Subsystem Values #define PE_SUBSYSTEM_NATIVE 1 // image doesn't require a subsystem. #define PE_SUBSYSTEM_WINDOWS_GUI 2 // image runs in the Windows GUI subsystem. #define PE_SUBSYSTEM_WINDOWS_CUI 3 // image runs in the Windows character subsystem. #define PE_SUBSYSTEM_OS2_CUI 5 // image runs in the OS/2 character subsystem. #define PE_SUBSYSTEM_POSIX_CUI 7 // image run in the Posix character subsystem. #define PE_SUBSYSTEM_RESERVED8 8 // image run in the 8 subsystem. #define PE_SUBSYSTEM_CE_GUI 9 // image runs in the Windows CE subsystem. #define PE_SUBSYSTEM_EFI_APPLICATION 10 // image is an EFI application. #define PE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11 // image is an EFI driver that provides boot services. #define PE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12 // image is an EFI driver that provides runtime services. // Directory Entries #define PE_DIRECTORY_ENTRY_EXPORT 0 // Export Directory #define PE_DIRECTORY_ENTRY_IMPORT 1 // Import Directory #define PE_DIRECTORY_ENTRY_RESOURCE 2 // Resource Directory #define PE_DIRECTORY_ENTRY_EXCEPTION 3 // Exception Directory #define PE_DIRECTORY_ENTRY_SECURITY 4 // Security Directory #define PE_DIRECTORY_ENTRY_BASERELOC 5 // Base Relocation Table #define PE_DIRECTORY_ENTRY_DEBUG 6 // Debug Directory #define PE_DIRECTORY_ENTRY_COPYRIGHT 7 // Description String #define PE_DIRECTORY_ENTRY_GLOBALPTR 8 // Machine Value (MIPS GP) #define PE_DIRECTORY_ENTRY_TLS 9 // TLS Directory #define PE_DIRECTORY_ENTRY_LOAD_CONFIG 10 // Load Configuration Directory #define PE_DIRECTORY_ENTRY_BOUND_IMPORT 11 // Bound Import Directory in headers #define PE_DIRECTORY_ENTRY_IAT 12 // Import Address Table #define PE_DIRECTORY_ENTRY_DELAY_IMPORT 13 // Delay Import Directory #define PE_DIRECTORY_ENTRY_IL 14 // IL (e.g. MS .NET) /* * Export */ struct PE_EXPORT_DIRECTORY { uint32 characteristics; uint32 timestamp; uint16 major_version; uint16 minor_version; uint32 name_address; uint32 ordinal_base; uint32 function_count; uint32 name_count; uint32 function_table_address; uint32 name_table_address; uint32 ordinal_table_address; } PACKED; /* * Import */ struct PE_THUNK_DATA { union { uint32 forwarder_string; uint32 function_desc_address; uint32 ordinal; uint32 data_address; }; } PACKED; struct PE_THUNK_DATA_64 { union { uint64 forwarder_string; uint64 function_desc_address; uint64 ordinal; uint64 data_address; }; } PACKED; struct PE_IMPORT_DESCRIPTOR { union { uint32 characteristics; // 0 for terminating null import descriptor uint32 original_first_thunk; // rva to original unbound IAT }; uint32 timestamp; // 0 if not bound, // -1 if bound, and real date\time stamp // in IMAGE_DIRECTORY_ENTRY_BOUND_IMPORT (new BIND) // O.W. date/time stamp of DLL bound to (Old BIND) uint32 forwarder_chain; // -1 if no forwarders uint32 name; uint32 first_thunk; // rva to IAT (if bound this IAT has actual addresses) } PACKED; /* * Delay Import */ struct PE_DELAY_IMPORT_DESCRIPTOR { uint32 attributes; uint32 name; uint32 module_handle; uint32 delay_iat; uint32 delay_int; uint32 bound_delay_import_table; uint32 unload_delay_import_table; uint32 timestamp; } PACKED; /* * Resource */ struct PE_RESOURCE_DIRECTORY { uint32 characteristics; uint32 timedate_stamp; uint16 major_version; uint16 minor_version; uint16 name_count; uint16 id_count; // PE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[]; } PACKED; #define PE_RESOURCE_NAME_IS_STRING 0x80000000 #define PE_RESOURCE_DATA_IS_DIRECTORY 0x80000000 struct PE_RESOURCE_DIRECTORY_ENTRY { uint32 name; // or id uint32 offset_to_directory; // or data } PACKED; /* struct PE_RESOURCE_DIRECTORY_STRING { uint16 Length; CHAR NameString[ 1 ]; } PACKED; struct PE_RESOURCE_DIR_STRING_U { uint16 Length; WCHAR NameString[ 1 ]; } PACKED;*/ struct PE_RESOURCE_DATA_ENTRY { uint32 offset_to_data; uint32 size; uint32 codepage; uint32 reserved; } PACKED; /* * IL */ #define PE_IL_DIRECTORY_ATTRIBUTES_HAD_NATIVE 0x1 #define PE_IL_DIRECTORY_ATTRIBUTES_INT64 0x2 struct PE_IL_DIRECTORY { uint32 size; uint16 major_version; uint16 minor_version; uint32 metadata_section_rva; uint32 metadata_section_size; uint32 attributes; } PACKED; extern byte PE_DATA_DIRECTORY_struct[]; extern byte PE_OPTIONAL_HEADER32_NT_struct[]; extern byte PE_OPTIONAL_HEADER64_NT_struct[]; extern byte PE_EXPORT_DIRECTORY_struct[]; extern byte PE_THUNK_DATA_struct[]; extern byte PE_THUNK_DATA_64_struct[]; extern byte PE_IMPORT_DESCRIPTOR_struct[]; extern byte PE_DELAY_IMPORT_DESCRIPTOR_struct[]; extern byte PE_RESOURCE_DIRECTORY_struct[]; extern byte PE_RESOURCE_DIRECTORY_ENTRY_struct[]; extern byte PE_RESOURCE_DATA_ENTRY_struct[]; extern byte PE_IL_DIRECTORY_struct[]; #endif ht-2.0.22/pestruct.cc0000644000175000001440000001137610615341624011317 00000000000000/* * HT Editor * pestruct.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "endianess.h" #include "pestruct.h" #include "coff_s.h" byte PE_DATA_DIRECTORY_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte PE_OPTIONAL_HEADER32_NT_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte PE_OPTIONAL_HEADER64_NT_struct[] = { STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte PE_EXPORT_DIRECTORY_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte PE_THUNK_DATA_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte PE_THUNK_DATA_64_struct[] = { STRUCT_ENDIAN_64 | STRUCT_ENDIAN_HOST, 0 }; byte PE_IMPORT_DESCRIPTOR_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte PE_DELAY_IMPORT_DESCRIPTOR_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte PE_RESOURCE_DIRECTORY_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, 0 }; byte PE_RESOURCE_DIRECTORY_ENTRY_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte PE_RESOURCE_DATA_ENTRY_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte PE_IL_DIRECTORY_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; ht-2.0.22/htsearch.h0000644000175000001440000001662710615341624011115 00000000000000/* * HT Editor * htsearch.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTSEARCH_H__ #define __HTSEARCH_H__ #include "atom.h" #include "htdialog.h" #include "except.h" #include "htformat.h" #include "htobj.h" #include "strtools.h" #include "stream.h" #include extern "C" { #include "regex.h" } /* * searching */ // search types + flags #define ST_FXBIN 0 // search using fixed binary pattern #define SF_FXBIN_CASEINSENSITIVE 1 #define SF_FXBIN_IDLE 2 #define ST_REGEX 1 // search using regular expression #define SF_REGEX_CASEINSENSITIVE 1 #define SF_REGEX_IDLE 2 #define ST_EXPR 3 // search stops when expression evals to non-zero typedef ht_view* (*create_form_func)(Bounds *b, uint histid); typedef void (*create_desc_func)(char *buf, int buflen, ht_view *form); /* * CLASS ht_fxbin_search_request */ class ht_fxbin_search_request: public ht_search_request { public: uint data_size; byte *data; ht_fxbin_search_request(uint search_class, uint flags, uint data_size, byte *data); virtual ~ht_fxbin_search_request(); /* overwritten */ virtual ht_fxbin_search_request *clone() const; }; /* * CLASS ht_regex_search_request */ class ht_regex_search_exception: public Exception { protected: char rxerr[128]; public: ht_regex_search_exception(int e, regex_t *r); virtual String &reason(String &) const; }; class ht_regex_search_request: public ht_search_request { public: char *rx_str; regex_t rx; ht_regex_search_request(uint search_class, uint flags, char *regex); virtual ~ht_regex_search_request(); /* overwritten */ virtual ht_regex_search_request* clone() const; }; /* * CLASS ht_expr_search_request */ class ht_expr_search_request: public ht_search_request { public: char *expr; ht_expr_search_request(uint search_class, uint flags, char *Expr); virtual ~ht_expr_search_request(); /* overwritten */ virtual ht_expr_search_request *clone() const; }; /* binary search function */ /* * CLASS ht_hexascii_search_form */ struct ht_hexascii_search_form_data { ht_strinputfield_data str; // ht_hexinputfield_data hex; // is attached to |str| ht_strinputfield_data start; ht_strinputfield_data end; ht_checkboxes_data options; }; class ht_hexascii_search_form: public ht_group { protected: ht_strinputfield *str; ht_strinputfield *range_start; ht_strinputfield *range_end; ht_checkboxes *option_boxes; public: void init(Bounds *b, int options, List *history=0); }; /* * CLASS ht_evalstr_search_form */ struct ht_evalstr_search_form_data { ht_strinputfield_data str; ht_strinputfield_data start; ht_strinputfield_data end; ht_checkboxes_data options; }; class ht_evalstr_search_form: public ht_group { protected: ht_strinputfield *str; ht_strinputfield *range_start; ht_strinputfield *range_end; ht_checkboxes *option_boxes; public: void init(Bounds *b, int options, List *history=0); }; /* * CLASS ht_vregex_search_form */ struct ht_vregex_search_form_data { ht_strinputfield_data str; ht_strinputfield_data start; ht_strinputfield_data end; ht_checkboxes_data options; }; class ht_vregex_search_form: public ht_group { protected: ht_strinputfield *str; ht_strinputfield *range_start; ht_strinputfield *range_end; ht_checkboxes *option_boxes; public: void init(Bounds *b, int options, List *history=0); }; /* * CLASS ht_expr_search_form */ struct ht_expr_search_form_data { ht_strinputfield_data str; ht_strinputfield_data start; ht_strinputfield_data end; ht_checkboxes_data options; }; class ht_expr_search_form: public ht_group { protected: ht_strinputfield *str; ht_strinputfield *range_start; ht_strinputfield *range_end; ht_checkboxes *option_boxes; public: void init(Bounds *b, int options, List *history=0); }; /* * CLASS ht_replace_hexascii_search_form */ struct ht_replace_hexascii_search_form_data { ht_strinputfield_data str; ht_hexinputfield_data hex; }; class ht_replace_hexascii_search_form: public ht_group { protected: ht_strinputfield *str; public: void init(Bounds *b, int options, List *history=0); }; /* * CLASS ht_search_dialog */ struct ht_search_dialog_mode { int id; ht_view *view; }; #define MAX_SEARCH_DIALOG_MODES 16 class ht_search_dialog: public ht_dialog { protected: ht_listpopup *search_mode_popup; int smodeidx; int smodecount; ht_search_dialog_mode smodes[MAX_SEARCH_DIALOG_MODES]; int find_search_mode(int id); void select_search_mode_bymodeidx(); public: ht_xgroup *search_mode_xgroup; void init(Bounds *b, const char *title); virtual void done(); /* overwritten */ virtual void handlemsg(htmsg *msg); /* new */ void insert_search_mode(int id, const char *desc, ht_view *v); void select_search_mode(int id); ht_view *get_search_modeform(); int get_search_modeid(); }; /* * CLASS ht_replace_dialog */ #define MAX_REPLACE_DIALOG_MODES 16 class ht_replace_dialog: public ht_search_dialog { protected: ht_listpopup *replace_mode_popup; int rmodeidx; int rmodecount; ht_search_dialog_mode rmodes[MAX_REPLACE_DIALOG_MODES]; int find_replace_mode(int id); void select_replace_mode_bymodeidx(); public: ht_xgroup *replace_mode_xgroup; void init(Bounds *b); virtual void done(); /* overwritten */ virtual void handlemsg(htmsg *msg); /* new */ void insert_replace_mode(int id, const char *desc, ht_view *v); void select_replace_mode(int id); ht_view *get_replace_modeform(); int get_replace_modeid(); }; /* * */ #define SEARCHMODE_BIN 1 #define SEARCHMODE_EVALSTR 2 #define SEARCHMODE_VREGEX 4 #define SEARCHMODE_EXPR 8 ht_search_request *search_dialog(ht_format_viewer *format, uint searchmodes, viewer_pos *start, viewer_pos *end); uint replace_dialog(ht_format_viewer *format, uint searchmodes, bool *cancelled); class ht_search_bin_context: public Object { public: File *file; bool file_end; uint flags; FileOfs ofs; FileOfs len; byte *pat; uint patlen; FileOfs o; uint c; byte *buf; byte *bufptr; bool *return_success; FileOfs *return_ofs; ~ht_search_bin_context(); }; // flags #define SFBIN_CASEINSENSITIVE 1 Object* create_search_bin_context(File *file, FileOfs ofs, FileOfs len, byte *pat, uint patlen, uint flags, FileOfs *return_ofs, bool *return_success); bool search_bin_process(Object *context, ht_text *progress_indicator); ht_view* create_form_hexascii(Bounds *b, uint histid); void create_desc_hexascii(char *buf, int buflen, ht_view *f); /* * */ class ht_replace_bin_context: public Object { public: File *file; FileOfs ofs; FileOfs len; FileOfs repllen; byte *repl; FileOfs o; FileOfs z; byte *buf; FileOfs *return_repllen; ~ht_replace_bin_context(); }; Object* create_replace_bin_context(File *file, FileOfs ofs, FileOfs len, byte *repl, FileOfs repllen, FileOfs *return_repllen); bool replace_bin_process(Object *context, ht_text *progress_indicator); #endif /* __HTSEARCH_H__ */ ht-2.0.22/pefstruc.h0000644000175000001440000000627410615341624011144 00000000000000/* * HT Editor * peffstruc.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* mostly assembled from TIS ELF 1.1g and BFD-ELF */ #ifndef __PEFFSTRUC_H__ #define __PEFFSTRUC_H__ #include "io/types.h" enum PEF_ARCH { PEFARCH_PowerPC, PEFARCH_M68K }; struct PEF_CONTAINER_HEADER { byte tag1[4]; byte tag2[4]; byte architecture[4]; uint32 formatVersion; // normally 1 uint32 dateTimeStamp; // number of seconds measured from January 1, 1904 uint32 oldDefVersion; uint32 oldImpVersion; uint32 currentVersion; uint16 sectionCount; uint16 instSectionCount; uint32 reservedA; } PACKED; struct PEF_SECTION_HEADER { sint32 nameOffset; // 0xffffffff for no name uint32 defaultAddress; uint32 totalSize; uint32 unpackedSize; uint32 packedSize; uint32 containerOffset; byte sectionKind; byte shareKind; byte alignment; byte reservedA; } PACKED; // sectionKind #define PEF_SK_Code 0 // R-x #define PEF_SK_UnpackedData 1 // RW- #define PEF_SK_PatternInitData 2 // RW- #define PEF_SK_ConstData 3 // R-- #define PEF_SK_Loader 4 #define PEF_SK_Debug 5 #define PEF_SK_ExecutableData 6 // RWX #define PEF_SK_Exception 7 #define PEF_SK_Traceback 8 // shareKind #define PEF_SHK_ProcessShare 1 #define PEF_SHK_GlobalShare 4 #define PEF_SHK_ProtectedShare 5 struct PEF_LOADER_INFO_HEADER { sint32 mainSection; uint32 mainOffset; sint32 initSection; uint32 initOffset; sint32 termSection; uint32 termOffset; uint32 importedLibraryCount; uint32 totalImportedSymbolCount; uint32 relocSectionCount; uint32 relocInstrOffset; uint32 loaderStringsOffset; uint32 exportHashOffset; uint32 exportHashTablePower; uint32 exportedSymbolCount; } PACKED; struct PEFAddress { uint32 a32; } PACKED; struct PEF_ImportedLibrary { uint32 nameOffset; uint32 oldImpVersion; uint32 currentVersion; uint32 importedSymbolCount; uint32 firstImportedSymbol; uint8 options; uint8 reservedA; uint16 reservedB; } PACKED; #define PEF_CODE_SYMBOL 0 // code address #define PEF_DATA_SYMBOL 1 // data address #define PEF_TVECT_SYMBOL 2 // standard procedure pointer #define PEF_TOC_SYMBOL 3 // direct data area (table of contents) symbol #define PEF_GLUE_SYMBOL 4 // linker-inserted glue symbol struct PEF_LoaderRelocationHeader { uint16 sectionIndex; uint16 reservedA; uint32 relocCount; uint32 firstRelocOffset; } PACKED; //#define PEF_ extern byte PEF_SECTION_HEADER_struct[]; extern byte PEF_CONTAINER_HEADER_struct[]; extern byte PEF_LOADER_INFO_HEADER_struct[]; extern byte PEF_ImportedLibrary_struct[]; #endif /* __PEFFSTRUC_H__ */ ht-2.0.22/htclipboard.h0000644000175000001440000000435510615341616011603 00000000000000/* * HT Editor * htclipboard.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTCLIPBOARD_H__ #define __HTCLIPBOARD_H__ #include "io/types.h" #include "stream.h" #include "htformat.h" /* * CLASS ht_clipboard */ class ht_clipboard: public MemoryFile { public: List *copy_history; FileOfs select_start, select_len; ht_clipboard(); virtual ~ht_clipboard(); /* overwritten */ virtual uint write(const void *buf, uint size); /* new */ void clear(); }; /* * CLASS ht_clipboard_viewer */ class ht_clipboard_viewer: public ht_uformat_viewer { protected: uint lastwritecount; uint lastentrycount; int get_pindicator_str(char *buf, int max_len); void selection_changed(); public: void init(Bounds *b, const char *desc, int caps, ht_clipboard *clipboard, ht_format_group *format_group); /* overwritten */ virtual void draw(); virtual void handlemsg(htmsg *msg); virtual void pselect_add(FileOfs start, FileOfs end); virtual void pselect_set(FileOfs start, FileOfs end); /* new */ void update_content(); }; /* clipboard functions */ void clipboard_add_copy_history_entry(const char *source, FileOfs start, FileOfs size, time_t time); FileOfs clipboard_copy(const char *source_desc, void *buf, uint len); FileOfs clipboard_copy(const char *source_desc, File *streamfile, FileOfs offset, FileOfs len); FileOfs clipboard_paste(void *buf, FileOfs maxlen); FileOfs clipboard_paste(File *streamfile, FileOfs offset); bool clipboard_clear(); FileOfs clipboard_getsize(); /* * INIT */ bool init_clipboard(); /* * DONE */ void done_clipboard(); extern ht_clipboard *clipboard; #endif /* __HTCLIPBOARD_H__ */ ht-2.0.22/htxbehead.h0000644000175000001440000000210510615341624011232 00000000000000/* * HT Editor * htxbehead.h * * Copyright (C) 2003 Stefan Esser * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTXBEHEAD_H__ #define __HTXBEHEAD_H__ #include "formats.h" extern format_viewer_if htxbeheader_if; /* * ht_xbe_header_viewer */ class ht_xbe_header_viewer: public ht_uformat_viewer { public: void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *group); /* overwritten */ virtual bool ref_sel(LINE_ID *id); }; #endif /* !__HTXBEHEAD_H__ */ ht-2.0.22/htinfo.h0000644000175000017500000000212412127651417010576 00000000000000/* * HTE Editor * htinfo.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTINFO_H__ #define __HTINFO_H__ #define ht_url "http://hte.sourceforge.net" #define ht_name "ht" #define ht_version "2.0.22" #define ht_author1 "Stefan Weyergraf" #define ht_copyright1 "(c) 1999-2004 "ht_author1 #define ht_author2 "Sebastian Biallas" #define ht_mail2 "sb@biallas.net" #define ht_copyright2 "(c) 1999-2013 "ht_author2" <"ht_mail2">" #endif /* !__HTINFO_H__ */ ht-2.0.22/config.sub0000755000175000017500000010565712146142707011136 00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright 1992-2013 Free Software Foundation, Inc. timestamp='2013-04-24' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, see . # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that # program. This Exception is an additional permission under section 7 # of the GNU General Public License, version 3 ("GPLv3"). # Please send patches with a ChangeLog entry to config-patches@gnu.org. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright 1992-2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; android-linux) os=-linux-android basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze*) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*178) os=-lynxos178 ;; -lynx*5) os=-lynxos5 ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | aarch64 | aarch64_be \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arceb \ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ | avr | avr32 \ | be32 | be64 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx | dvp \ | epiphany \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \ | open8 \ | or1k | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rl78 | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip) basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xgate) basic_machine=$basic_machine-unknown os=-none ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | aarch64-* | aarch64_be-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | be32-* | be64-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ | microblaze-* | microblazeel-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | rl78-* | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile*-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze*) basic_machine=microblaze-xilinx ;; mingw64) basic_machine=x86_64-pc os=-mingw64 ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mipsEE* | ee | ps2) basic_machine=mips64r5900el-scei case $os in -linux*) ;; *) os=-elf ;; esac ;; iop) basic_machine=mipsel-scei os=-irx ;; dvp) basic_machine=dvp-scei os=-elf ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; msys) basic_machine=i386-pc os=-msys ;; mvs) basic_machine=i370-ibm os=-mvs ;; nacl) basic_machine=le32-unknown os=-nacl ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos | rdos64) basic_machine=x86_64-pc os=-rdos ;; rdos32) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tile*) basic_machine=$basic_machine-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* | -plan9* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -bitrig* | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-musl* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -irx* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; hexagon-*) os=-elf ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or1k-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: ht-2.0.22/httag.h0000644000175000017500000004136611724770012010424 00000000000000/* * HT Editor * httag.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTTAG_H__ #define __HTTAG_H__ #include #include "io/types.h" #include "io/display.h" #include "stream.h" #define HT_TAG_BUFOP(cl) \ inline cl(void) {}; \ inline cl(const void *b) { memcpy(this, b, sizeof(*this)); }; \ inline void flush(void *b) const { memcpy(b, this, sizeof(*this)); }; /* SELECTION-TAG */ #define HT_TAG_SEL 0x01 #define HT_TAG_SEL_LEN(n) (sizeof(ht_tag_sel)+(n)) #define HT_TAG_SEL_VLEN(n) (n) #define HT_STATICTAG_SEL 0x81 #define HT_STATICTAG_SEL_CH "\e\x81" struct ht_tag_sel { byte escape; byte magic; ID id128_1; ID id128_2; ID id128_3; ID id128_4; byte strlen; HT_TAG_BUFOP(ht_tag_sel); } PACKED; /* FLAGS-TAG */ #define HT_TAG_FLAGS 0x02 #define HT_TAG_FLAGS_LEN sizeof(ht_tag_flags) #define HT_TAG_FLAGS_VLEN 1 #define HT_STATICTAG_FLAGS 0x82 #define HT_STATICTAG_FLAGS_CH "\e\x82" struct ht_tag_flags { byte escape; byte magic; FileOfs offset; ID id; HT_TAG_BUFOP(ht_tag_flags); } PACKED; struct ht_tag_flags_s { char bitidx; const char *desc; } PACKED; /* GROUP-TAG */ #define HT_TAG_GROUP 0x03 #define HT_TAG_GROUP_LEN sizeof(ht_tag_group) #define HT_STATICTAG_GROUP 0x83 #define HT_STATICTAG_GROUP_CH "\e\x83" struct ht_tag_group { byte escape; byte magic; HT_TAG_BUFOP(ht_tag_group); } PACKED; /* COLOR-TAG */ #define HT_TAG_COLOR 0x04 #define HT_TAG_COLOR_LEN sizeof(ht_tag_color) #define HT_STATICTAG_COLOR 0x84 #define HT_STATICTAG_COLOR_CH "\e\x84" struct ht_tag_color { byte escape; byte magic; uint32 color; HT_TAG_BUFOP(ht_tag_color); } PACKED; /* EDIT-BYTE-TAG */ #define HT_TAG_EDIT_BYTE 0x10 #define HT_TAG_EDIT_BYTE_LEN sizeof(ht_tag_edit_byte) #define HT_TAG_EDIT_BYTE_VLEN (2) #define HT_TAG_EDIT_BYTE_SIZE (1) #define HT_STATICTAG_EDIT_BYTE 0x90 #define HT_STATICTAG_EDIT_BYTE_CH "\e\x90" struct ht_tag_edit_byte { byte escape; byte magic; FileOfs offset; HT_TAG_BUFOP(ht_tag_edit_byte); } PACKED; /* EDIT WORD */ struct ht_tag_edit_word_generic { byte escape; byte magic; FileOfs offset; HT_TAG_BUFOP(ht_tag_edit_word_generic); } PACKED; /* EDIT DWORD */ struct ht_tag_edit_dword_generic { byte escape; byte magic; FileOfs offset; HT_TAG_BUFOP(ht_tag_edit_dword_generic); } PACKED; /* EDIT QWORD */ struct ht_tag_edit_qword_generic { byte escape; byte magic; FileOfs offset; HT_TAG_BUFOP(ht_tag_edit_qword_generic); } PACKED; /* EDIT-WORD-TAG (little-endian) */ #define HT_TAG_EDIT_WORD_LE 0x11 #define HT_TAG_EDIT_WORD_LE_LEN sizeof(ht_tag_edit_word_generic) #define HT_TAG_EDIT_WORD_LE_VLEN (4) #define HT_TAG_EDIT_WORD_LE_SIZE (2) #define HT_STATICTAG_EDIT_WORD_LE 0x91 #define HT_STATICTAG_EDIT_WORD_LE_CH "\e\x91" /* EDIT-DWORD-TAG (little-endian) */ #define HT_TAG_EDIT_DWORD_LE 0x12 #define HT_TAG_EDIT_DWORD_LE_LEN sizeof(ht_tag_edit_dword_generic) #define HT_TAG_EDIT_DWORD_LE_VLEN (8) #define HT_TAG_EDIT_DWORD_LE_SIZE (4) #define HT_STATICTAG_EDIT_DWORD_LE 0x92 #define HT_STATICTAG_EDIT_DWORD_LE_CH "\e\x92" /* EDIT-QWORD-TAG (little-endian) */ #define HT_TAG_EDIT_QWORD_LE 0x13 #define HT_TAG_EDIT_QWORD_LE_LEN sizeof(ht_tag_edit_qword_generic) #define HT_TAG_EDIT_QWORD_LE_VLEN (16) #define HT_TAG_EDIT_QWORD_LE_SIZE (8) #define HT_STATICTAG_EDIT_QWORD_LE 0x93 #define HT_STATICTAG_EDIT_QWORD_LE_CH "\e\x93" /* EDIT-WORD-TAG (big-endian) */ #define HT_TAG_EDIT_WORD_BE 0x14 #define HT_TAG_EDIT_WORD_BE_LEN sizeof(ht_tag_edit_word_generic) #define HT_TAG_EDIT_WORD_BE_VLEN (4) #define HT_TAG_EDIT_WORD_BE_SIZE (2) #define HT_STATICTAG_EDIT_WORD_BE 0x94 #define HT_STATICTAG_EDIT_WORD_BE_CH "\e\x94" /* EDIT-DWORD-TAG (big-endian) */ #define HT_TAG_EDIT_DWORD_BE 0x15 #define HT_TAG_EDIT_DWORD_BE_LEN sizeof(ht_tag_edit_dword_generic) #define HT_TAG_EDIT_DWORD_BE_VLEN (8) #define HT_TAG_EDIT_DWORD_BE_SIZE (4) #define HT_STATICTAG_EDIT_DWORD_BE 0x95 #define HT_STATICTAG_EDIT_DWORD_BE_CH "\e\x95" /* EDIT-QWORD-TAG (big-endian) */ #define HT_TAG_EDIT_QWORD_BE 0x16 #define HT_TAG_EDIT_QWORD_BE_LEN sizeof(ht_tag_edit_qword_generic) #define HT_TAG_EDIT_QWORD_BE_VLEN (16) #define HT_TAG_EDIT_QWORD_BE_SIZE (8) #define HT_STATICTAG_EDIT_QWORD_BE 0x96 #define HT_STATICTAG_EDIT_QWORD_BE_CH "\e\x96" /* EDIT-WORD-TAG (var-endian) */ #define HT_TAG_EDIT_WORD_VE 0x17 #define HT_TAG_EDIT_WORD_VE_LEN sizeof(ht_tag_edit_word_generic) #define HT_TAG_EDIT_WORD_VE_VLEN (4) #define HT_TAG_EDIT_WORD_VE_SIZE (2) #define HT_STATICTAG_EDIT_WORD_VE 0x97 #define HT_STATICTAG_EDIT_WORD_VE_CH "\e\x97" /* EDIT-DWORD-TAG (var-endian) */ #define HT_TAG_EDIT_DWORD_VE 0x18 #define HT_TAG_EDIT_DWORD_VE_LEN sizeof(ht_tag_edit_dword_generic) #define HT_TAG_EDIT_DWORD_VE_VLEN (8) #define HT_TAG_EDIT_DWORD_VE_SIZE (4) #define HT_STATICTAG_EDIT_DWORD_VE 0x98 #define HT_STATICTAG_EDIT_DWORD_VE_CH "\e\x98" /* EDIT-QWORD-TAG (var-endian) */ #define HT_TAG_EDIT_QWORD_VE 0x19 #define HT_TAG_EDIT_QWORD_VE_LEN sizeof(ht_tag_edit_qword_generic) #define HT_TAG_EDIT_QWORD_VE_VLEN (16) #define HT_TAG_EDIT_QWORD_VE_SIZE (8) #define HT_STATICTAG_EDIT_QWORD_VE 0x99 #define HT_STATICTAG_EDIT_QWORD_VE_CH "\e\x99" /* EDIT-TIME-TAG */ #define HT_TAG_EDIT_TIME_BE 0x1a #define HT_TAG_EDIT_TIME_BE_LEN sizeof(ht_tag_edit_time) #define HT_TAG_EDIT_TIME_BE_VLEN (19) #define HT_TAG_EDIT_TIME_BE_SIZE (4) #define HT_STATICTAG_EDIT_TIME_BE 0x9a #define HT_STATICTAG_EDIT_TIME_BE_CH "\e\x9a" #define HT_TAG_EDIT_TIME_LE 0x1b #define HT_TAG_EDIT_TIME_LE_LEN sizeof(ht_tag_edit_time) #define HT_TAG_EDIT_TIME_LE_VLEN (19) #define HT_TAG_EDIT_TIME_LE_SIZE (4) #define HT_STATICTAG_EDIT_TIME_LE 0x9b #define HT_STATICTAG_EDIT_TIME_LE_CH "\e\x9b" #define HT_TAG_EDIT_TIME_VE 0x1c #define HT_TAG_EDIT_TIME_VE_LEN sizeof(ht_tag_edit_time) #define HT_TAG_EDIT_TIME_VE_VLEN (19) #define HT_TAG_EDIT_TIME_VE_SIZE (4) #define HT_STATICTAG_EDIT_TIME_VE 0x9c #define HT_STATICTAG_EDIT_TIME_VE_CH "\e\x9c" struct ht_tag_edit_time { byte escape; byte magic; FileOfs offset; HT_TAG_BUFOP(ht_tag_edit_time); } PACKED; /* EDIT-CHAR-TAG */ #define HT_TAG_EDIT_CHAR 0x1d #define HT_TAG_EDIT_CHAR_LEN sizeof(ht_tag_edit_char) #define HT_TAG_EDIT_CHAR_VLEN (1) #define HT_TAG_EDIT_CHAR_SIZE (1) #define HT_STATICTAG_EDIT_CHAR 0x9d #define HT_STATICTAG_EDIT_CHAR_CH "\e\x9d" struct ht_tag_edit_char { byte escape; byte magic; FileOfs offset; HT_TAG_BUFOP(ht_tag_edit_char); } PACKED; /* EDIT-BIT-TAG */ #define HT_TAG_EDIT_BIT 0x1e #define HT_TAG_EDIT_BIT_LEN sizeof(ht_tag_edit_bit) #define HT_TAG_EDIT_BIT_VLEN (1) #define HT_TAG_EDIT_BIT_SIZE (1) #define HT_STATICTAG_EDIT_BIT 0x9e #define HT_STATICTAG_EDIT_BIT_CH "\e\x9e" struct ht_tag_edit_bit { byte escape; byte magic; FileOfs offset; byte bitidx; HT_TAG_BUFOP(ht_tag_edit_bit); } PACKED; /* EDIT-SELVIS-TAG */ #define HT_TAG_EDIT_SELVIS 0x1f #define HT_TAG_EDIT_SELVIS_LEN sizeof(ht_tag_edit_selvis) #define HT_TAG_EDIT_SELVIS_VLEN (1) #define HT_STATICTAG_EDIT_SELVIS 0x9f #define HT_STATICTAG_EDIT_SELVIS_CH "\e\x9f" struct ht_tag_edit_selvis { byte escape; byte magic; FileOfs offset; char ch; HT_TAG_BUFOP(ht_tag_edit_selvis); } PACKED; /* DESC-BYTE-TAG */ #define HT_TAG_DESC_BYTE 0x20 #define HT_TAG_DESC_BYTE_LEN sizeof(ht_tag_desc_byte) #define HT_STATICTAG_DESC_BYTE 0xa0 #define HT_STATICTAG_DESC_BYTE_CH "\e\xa0" struct ht_tag_desc_byte { byte escape; byte magic; ID id; FileOfs offset; HT_TAG_BUFOP(ht_tag_desc_byte); } PACKED; /* DESC WORD */ struct ht_tag_desc_word_generic { byte escape; byte magic; ID id; FileOfs offset; HT_TAG_BUFOP(ht_tag_desc_word_generic); } PACKED; /* DESC DWORD */ struct ht_tag_desc_dword_generic { byte escape; byte magic; ID id; FileOfs offset; HT_TAG_BUFOP(ht_tag_desc_dword_generic); } PACKED; /* DESC QWORD */ struct ht_tag_desc_qword_generic { byte escape; byte magic; ID id; FileOfs offset; HT_TAG_BUFOP(ht_tag_desc_qword_generic); } PACKED; /* DESC-WORD-TAG (little-endian) */ #define HT_TAG_DESC_WORD_LE 0x21 #define HT_TAG_DESC_WORD_LE_LEN sizeof(ht_tag_desc_word_generic) #define HT_STATICTAG_DESC_WORD_LE 0xa1 #define HT_STATICTAG_DESC_WORD_LE_CH "\e\xa1" /* DESC-DWORD-TAG (little-endian) */ #define HT_TAG_DESC_DWORD_LE 0x22 #define HT_TAG_DESC_DWORD_LE_LEN sizeof(ht_tag_desc_dword_generic) #define HT_STATICTAG_DESC_DWORD_LE 0xa2 #define HT_STATICTAG_DESC_DWORD_LE_CH "\e\xa2" /* DESC-QWORD-TAG (little-endian) */ #define HT_TAG_DESC_QWORD_LE 0x23 #define HT_TAG_DESC_QWORD_LE_LEN sizeof(ht_tag_desc_qword_generic) #define HT_STATICTAG_DESC_QWORD_LE 0xa3 #define HT_STATICTAG_DESC_QWORD_LE_CH "\e\xa3" /* DESC-WORD-TAG (big-endian) */ #define HT_TAG_DESC_WORD_BE 0x24 #define HT_TAG_DESC_WORD_BE_LEN sizeof(ht_tag_desc_word_generic) #define HT_STATICTAG_DESC_WORD_BE 0xa4 #define HT_STATICTAG_DESC_WORD_BE_CH "\e\xa4" /* DESC-DWORD-TAG (big-endian) */ #define HT_TAG_DESC_DWORD_BE 0x25 #define HT_TAG_DESC_DWORD_BE_LEN sizeof(ht_tag_desc_dword_generic) #define HT_STATICTAG_DESC_DWORD_BE 0xa5 #define HT_STATICTAG_DESC_DWORD_BE_CH "\e\xa5" /* DESC-QWORD-TAG (big-endian) */ #define HT_TAG_DESC_QWORD_BE 0x26 #define HT_TAG_DESC_QWORD_BE_LEN sizeof(ht_tag_desc_qword_generic) #define HT_STATICTAG_DESC_QWORD_BE 0xa6 #define HT_STATICTAG_DESC_QWORD_BE_CH "\e\xa6" /* DESC-WORD-TAG (var-endian) */ #define HT_TAG_DESC_WORD_VE 0x27 #define HT_TAG_DESC_WORD_VE_LEN sizeof(ht_tag_desc_word_generic) #define HT_STATICTAG_DESC_WORD_VE 0xa7 #define HT_STATICTAG_DESC_WORD_VE_CH "\e\xa7" /* DESC-DWORD-TAG (var-endian) */ #define HT_TAG_DESC_DWORD_VE 0x28 #define HT_TAG_DESC_DWORD_VE_LEN sizeof(ht_tag_desc_dword_generic) #define HT_STATICTAG_DESC_DWORD_VE 0xa8 #define HT_STATICTAG_DESC_DWORD_VE_CH "\e\xa8" /* DESC-QWORD-TAG (var-endian) */ #define HT_TAG_DESC_QWORD_VE 0x29 #define HT_TAG_DESC_QWORD_VE_LEN sizeof(ht_tag_desc_qword_generic) #define HT_STATICTAG_DESC_QWORD_VE 0xa9 #define HT_STATICTAG_DESC_QWORD_VE_CH "\e\xa9" enum tag_endian { tag_endian_big, tag_endian_little, tag_endian_var }; /* * tag palette */ #define palkey_tags_default "default" #define palidx_tags_edit_tag_cursor_select 0 #define palidx_tags_edit_tag_cursor_edit 1 #define palidx_tags_edit_tag_cursor_unfocused 2 #define palidx_tags_edit_tag_selected 3 #define palidx_tags_edit_tag_modified 4 #define palidx_tags_edit_tag 5 #define palidx_tags_sel_tag_cursor_focused 6 #define palidx_tags_sel_tag_cursor_unfocused 7 #define palidx_tags_sel_tag 8 #define STATICTAG_SEL(len8, str) HT_STATICTAG_SEL_CH "0000000000000000" "0000000000000000" len8 str #define STATICTAG_REF(id64, len8, str) HT_STATICTAG_SEL_CH id64 "0000000000000000" len8 str #define STATICTAG_FLAGS(ofs32, id32) HT_STATICTAG_FLAGS_CH ofs32 id32 #define STATICTAG_GROUP() HT_STATICTAG_GROUP_CH #define STATICTAG_COLOR(color8) HT_STATICTAG_COLOR_CH color8 #define STATICTAG_EDIT_BYTE(ofs) HT_STATICTAG_EDIT_BYTE_CH ofs #define STATICTAG_EDIT_WORD_LE(ofs) HT_STATICTAG_EDIT_WORD_LE_CH ofs #define STATICTAG_EDIT_DWORD_LE(ofs) HT_STATICTAG_EDIT_DWORD_LE_CH ofs #define STATICTAG_EDIT_QWORD_LE(ofs) HT_STATICTAG_EDIT_QWORD_LE_CH ofs #define STATICTAG_EDIT_WORD_BE(ofs) HT_STATICTAG_EDIT_WORD_BE_CH ofs #define STATICTAG_EDIT_DWORD_BE(ofs) HT_STATICTAG_EDIT_DWORD_BE_CH ofs #define STATICTAG_EDIT_QWORD_BE(ofs) HT_STATICTAG_EDIT_QWORD_BE_CH ofs #define STATICTAG_EDIT_WORD_VE(ofs) HT_STATICTAG_EDIT_WORD_VE_CH ofs #define STATICTAG_EDIT_DWORD_VE(ofs) HT_STATICTAG_EDIT_DWORD_VE_CH ofs #define STATICTAG_EDIT_QWORD_VE(ofs) HT_STATICTAG_EDIT_QWORD_VE_CH ofs #define STATICTAG_EDIT_TIME_BE(ofs) HT_STATICTAG_EDIT_TIME_BE_CH ofs #define STATICTAG_EDIT_TIME_LE(ofs) HT_STATICTAG_EDIT_TIME_LE_CH ofs #define STATICTAG_EDIT_TIME_VE(ofs) HT_STATICTAG_EDIT_TIME_VE_CH ofs #define STATICTAG_EDIT_CHAR(ofs) HT_STATICTAG_EDIT_CHAR_CH ofs #define STATICTAG_EDIT_BIT(ofs, bitidx8) HT_STATICTAG_EDIT_BIT_CH ofs bitidx8 #define STATICTAG_EDIT_SELVIS(ofs, char8) HT_STATICTAG_EDIT_SELVIS_CH ofs char8 #define STATICTAG_DESC_BYTE(ofs32, id32) HT_STATICTAG_DESC_BYTE_CH ofs32 id32 #define STATICTAG_DESC_WORD_LE(ofs32, id32) HT_STATICTAG_DESC_WORD_LE_CH ofs32 id32 #define STATICTAG_DESC_DWORD_LE(ofs32, id32) HT_STATICTAG_DESC_DWORD_LE_CH ofs32 id32 #define STATICTAG_DESC_QWORD_LE(ofs32, id32) HT_STATICTAG_DESC_QWORD_LE_CH ofs32 id32 #define STATICTAG_DESC_WORD_BE(ofs32, id32) HT_STATICTAG_DESC_WORD_BE_CH ofs32 id32 #define STATICTAG_DESC_DWORD_BE(ofs32, id32) HT_STATICTAG_DESC_DWORD_BE_CH ofs32 id32 #define STATICTAG_DESC_QWORD_BE(ofs32, id32) HT_STATICTAG_DESC_QWORD_BE_CH ofs32 id32 #define STATICTAG_DESC_WORD_VE(ofs32, id32) HT_STATICTAG_DESC_WORD_VE_CH ofs32 id32 #define STATICTAG_DESC_DWORD_VE(ofs32, id32) HT_STATICTAG_DESC_DWORD_VE_CH ofs32 id32 #define STATICTAG_DESC_QWORD_VE(ofs32, id32) HT_STATICTAG_DESC_QWORD_VE_CH ofs32 id32 #define tag_class_no 0 #define tag_class_edit 1 #define tag_class_sel 2 typedef char TAGSTRING; void statictag_to_tag(const char *statictag_str, TAGSTRING *tag_str, int maxlen, uint64 relocation, bool std_bigendian); const TAGSTRING *tag_findnext(const TAGSTRING *tagstring); vcp tag_get_color(const TAGSTRING *tagstring); void tag_get_id(const TAGSTRING *tagstring, uint32 *id128_1, uint32 *id128_2, uint32 *id128_3, uint32 *id128_4); int tag_get_len(const TAGSTRING *tagstring); FileOfs tag_get_offset(const TAGSTRING *tagstring); int tag_get_size(const TAGSTRING *tagstring); int tag_get_vlen(const TAGSTRING *tagstring); int tag_get_seltextlen(const TAGSTRING *tagstring); TAGSTRING *tag_get_seltext(const TAGSTRING *tagstring); int tag_get_micropos(const TAGSTRING *tagstring, int i); int tag_get_microsize(const TAGSTRING *tagstring); bool tag_get_desc_id(const TAGSTRING *tagstring, uint32 *id); void tag_set_offset(TAGSTRING *tagstring, FileOfs offset); void tag_set_value(TAGSTRING *tagstring, uint32 value); bool tag_is_editable(const TAGSTRING *tagstring); void tag_strcat(TAGSTRING *dest, int maxlen, const TAGSTRING *src); void tag_strcpy(TAGSTRING *dest, int maxlen, const TAGSTRING *src); TAGSTRING *tag_strdup(const TAGSTRING *tagstring); int tag_strlen(const TAGSTRING *tagstring); int tag_strvlen(const TAGSTRING *tagstring); int tag_count_selectable_tags_in_group(const TAGSTRING *tagstring, int group); int tag_count_selectable_tags(const TAGSTRING *tagstring); int tag_count_groups(const TAGSTRING *tagstring); TAGSTRING *tag_get_selectable_tag(const TAGSTRING *tagstring, int n, int group); TAGSTRING *tag_get_group(const TAGSTRING *tagstring, int group); int tag_get_class(const TAGSTRING *tagstring); TAGSTRING *tag_make_sel(TAGSTRING *buf, int maxlen, const char *string); TAGSTRING *tag_make_ref(TAGSTRING *buf, int maxlen, uint32 id128_1, uint32 id128_2, uint32 id128_3, uint32 id128_4, const char *string); TAGSTRING *tag_make_ref_len(TAGSTRING *buf, int maxlen, uint32 id128_1, uint32 id128_2, uint32 id128_3, uint32 id128_4, const char *string, int strlen); TAGSTRING *tag_make_flags(TAGSTRING *buf, int maxlen, uint32 id, FileOfs offset); TAGSTRING *tag_make_group(TAGSTRING *buf, int maxlen); TAGSTRING *tag_make_color(TAGSTRING *buf, int maxlen, uint32 color); TAGSTRING *tag_make_default_color(TAGSTRING *buf, int maxlen); TAGSTRING *tag_make_edit_byte(TAGSTRING *buf, int maxlen, FileOfs ofs); TAGSTRING *tag_make_edit_word(TAGSTRING *buf, int maxlen, FileOfs ofs, tag_endian e); TAGSTRING *tag_make_edit_dword(TAGSTRING *buf, int maxlen, FileOfs ofs, tag_endian e); TAGSTRING *tag_make_edit_qword(TAGSTRING *buf, int maxlen, FileOfs ofs, tag_endian e); TAGSTRING *tag_make_edit_time(TAGSTRING *buf, int maxlen, FileOfs ofs, tag_endian e); TAGSTRING *tag_make_edit_char(TAGSTRING *buf, int maxlen, FileOfs ofs); TAGSTRING *tag_make_edit_bit(TAGSTRING *buf, int maxlen, FileOfs ofs, int bitidx); TAGSTRING *tag_make_edit_selvis(TAGSTRING *buf, int maxlen, FileOfs offset, char ch); TAGSTRING *tag_make_desc_byte(TAGSTRING *buf, int maxlen, FileOfs ofs, uint32 id32); TAGSTRING *tag_make_desc_word(TAGSTRING *buf, int maxlen, FileOfs ofs, uint32 id32, tag_endian e); TAGSTRING *tag_make_desc_dword(TAGSTRING *buf, int maxlen, FileOfs ofs, uint32 id32, tag_endian e); TAGSTRING *tag_make_desc_qword(TAGSTRING *buf, int maxlen, FileOfs ofs, uint32 id32, tag_endian e); char *tag_striptags(char *dest, const TAGSTRING *src); #endif /* !__HTTAG_H__ */ ht-2.0.22/htleent.h0000644000175000001440000000153110206756710010745 00000000000000/* * HT Editor * htleent.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTLEENT_H__ #define __HTLEENT_H__ #include "formats.h" extern format_viewer_if htleentrypoints_if; #endif /* !__HTLEENT_H__ */ ht-2.0.22/htnenms.cc0000644000175000001440000000545410615341623011121 00000000000000/* * HT Editor * htnenms.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "atom.h" #include "endianess.h" #include "htne.h" #include "htnenms.h" #include "httag.h" #include "formats.h" #include "snprintf.h" #include #include static void assign_entrypoint_name(ht_ne_shared_data *ne_shared, uint i, char *name) { if (ne_shared->entrypoints) { ht_ne_entrypoint *e = (ht_ne_entrypoint*)(*ne_shared->entrypoints)[i]; if (e) { e->name = strdup(name); } /*else fprintf(stderr, "entry %d not available\n", i);*/ } /* else trouble :-) */ } static ht_view *htnenames_init(Bounds *b, File *file, ht_format_group *group) { ht_ne_shared_data *ne_shared=(ht_ne_shared_data *)group->get_shared_data(); uint32 h=ne_shared->hdr_ofs; ht_uformat_viewer *v=new ht_uformat_viewer(); v->init(b, DESC_NE_NAMES, VC_EDIT | VC_SEARCH, file, group); ht_mask_sub *m=new ht_mask_sub(); m->init(file, 0); char line[256]; /* secure */ char *n; int i; ht_snprintf(line, sizeof line, "* NE resident names table at offset 0x%08qx", h+ne_shared->hdr.restab); m->add_mask(line); file->seek(h+ne_shared->hdr.restab); i=0; while (*(n = file->readstrp())) { char buf[2]; file->read(buf, 2); uint16 ent = createHostInt(buf, 2, little_endian); if (!i) { ht_snprintf(line, sizeof line, "description: %s", n); } else { ht_snprintf(line, sizeof line, "%04x %s", ent, n); assign_entrypoint_name(ne_shared, ent, n); } free(n); m->add_mask(line); i++; } free(n); m->add_mask("----------------------------------------------------------------"); ht_snprintf(line, sizeof line, "* NE non-resident names table at offset %08x", ne_shared->hdr.nrestab); m->add_mask(line); file->seek(ne_shared->hdr.nrestab); i=0; while (*(n = file->readstrp())) { char buf[2]; file->read(buf, 2); uint16 ent = createHostInt(buf, 2, little_endian); if (!i) { ht_snprintf(line, sizeof line, "description: %s", n); } else { ht_snprintf(line, sizeof line, "%04x %s", ent, n); assign_entrypoint_name(ne_shared, ent, n); } free(n); m->add_mask(line); i++; } free(n); v->insertsub(m); return v; } format_viewer_if htnenames_if = { htnenames_init, NULL }; ht-2.0.22/htcfg.cc0000644000175000017500000001650712127651417010552 00000000000000/* * HT Editor * htcfg.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include "cstream.h" #include "htcfg.h" #include "htctrl.h" #include "htdebug.h" #include "endianess.h" #include "htreg.h" #include "strtools.h" #include "stream.h" #include "store.h" #include "sys.h" #include "tools.h" /* VERSION 2 (for ht-0.4.4 and later) */ /* NOTE: as of Version 2 ALL integers in HT config-files are stored in big-endian format... (non-intel) */ #define object_stream_bin 0 #define object_stream_txt 1 #define object_stream_bin_compressed 2 ObjectStream *create_object_stream(Stream &f, int object_stream_type) { ObjectStream *s; switch (object_stream_type) { case object_stream_bin: s = new ObjectStreamBin(&f, false); break; case object_stream_txt: s = new ObjectStreamText(&f, false); break; case object_stream_bin_compressed: { CompressedStream *cs = new CompressedStream(&f, false); s = new ObjectStreamBin(cs, true); break; } default: return NULL; } return s; } struct config_header { char magic[4]; char version[4]; char stream_type[2]; } PACKED; /* * system configs */ char *systemconfig_file; /**/ loadstore_result save_systemconfig(String &error_info) { try { LocalFile f((String)systemconfig_file, IOAM_WRITE, FOM_CREATE); /* write project config header */ config_header h; memcpy(h.magic, ht_systemconfig_magic, sizeof h.magic); char q[16]; int system_ostream_type = get_config_dword("misc/config format"); sprintf(q, "%04x", ht_systemconfig_fileversion); memcpy(h.version, q, sizeof h.version); sprintf(q, "%02x", system_ostream_type); memcpy(h.stream_type, q, sizeof h.stream_type); f.writex(&h, sizeof h); /* write object stream type */ std::auto_ptr d(create_object_stream(f, system_ostream_type)); switch (system_ostream_type) { case object_stream_bin: break; case object_stream_txt: f.writex((void*)"\n#\n#\tThis is a generated file!\n#\n", 33); break; } /* write config */ app->store(*d); } catch (const Exception &e) { e.reason(error_info); return LS_ERROR_WRITE; } return LS_OK; } bool load_systemconfig(loadstore_result *result, int *error_info) { uint8 object_stream_type = 128; std::auto_ptr d(NULL); *error_info = 0; try { LocalFile f((String)systemconfig_file, IOAM_READ, FOM_EXISTS); /* read project config header */ config_header h; if (f.read(&h, sizeof h) != sizeof h || memcmp(h.magic, ht_systemconfig_magic, sizeof h.magic) != 0) { *result = LS_ERROR_MAGIC; return false; } uint16 readver; if (!hexw_ex(readver, (char*)h.version) || (readver != ht_systemconfig_fileversion)) { *result = LS_ERROR_VERSION; *error_info = readver; return false; } /* object stream type */ if (!hexb_ex(object_stream_type, (char*)h.stream_type)) { *result = LS_ERROR_FORMAT; return false; } d.reset(create_object_stream(f, object_stream_type)); if (!d.get()) { *result = LS_ERROR_FORMAT; return false; } /* read config */ app->load(*d); } catch (const ObjectNotRegisteredException &) { *result = LS_ERROR_CORRUPTED; if (object_stream_type==object_stream_txt && d.get()) { *error_info = ((ObjectStreamText*)d.get())->getErrorLine(); } return false; } catch (const IOException &e) { if (e.mPosixErrno == ENOENT) { *result = LS_ERROR_NOT_FOUND; } else { *result = LS_ERROR_READ; if (object_stream_type == object_stream_txt && d.get()) { *error_info = ((ObjectStreamText*)d.get())->getErrorLine(); } } return false; } *result = LS_OK; return true; } /**/ loadstore_result save_fileconfig(const char *fileconfig_file, const char *magic, uint version, store_fcfg_func store_func, void *context, String &error_info) { try { LocalFile f((String)fileconfig_file, IOAM_WRITE, FOM_CREATE); /* write file config header */ config_header h; memcpy(h.magic, magic, sizeof h.magic); char q[16]; int file_ostream_type = get_config_dword("misc/config format"); sprintf(q, "%04x", version); memcpy(h.version, q, sizeof h.version); sprintf(q, "%02x", file_ostream_type); memcpy(h.stream_type, q, sizeof h.stream_type); f.writex(&h, sizeof h); /* object stream type */ std::auto_ptr d(create_object_stream(f, file_ostream_type)); switch (file_ostream_type) { case object_stream_bin: break; case object_stream_txt: f.writex((void*)"\n#\n#\tThis is a generated file!\n#\n", 33); break; } /* write config */ store_func(*d.get(), context); } catch (const Exception &e) { e.reason(error_info); return LS_ERROR_WRITE; } return LS_OK; } loadstore_result load_fileconfig(const char *fileconfig_file, const char *magic, uint version, load_fcfg_func load_func, void *context, String &error_info) { uint8 object_stream_type = 128; error_info.clear(); std::auto_ptr d(NULL); try { LocalFile f((String)fileconfig_file, IOAM_READ, FOM_EXISTS); /* read file config header */ config_header h; if (f.read(&h, sizeof h) != sizeof h || memcmp(h.magic, magic, sizeof h.magic) != 0) { return LS_ERROR_MAGIC; } uint16 readver; if (!hexw_ex(readver, (char*)h.version) || readver != version) { error_info.assignFormat("%d", readver); return LS_ERROR_VERSION; } if (!hexb_ex(object_stream_type, (char*)h.stream_type)) { return LS_ERROR_FORMAT; } /* object stream type */ d.reset(create_object_stream(f, object_stream_type)); if (!d.get()) { return LS_ERROR_FORMAT; } load_func(*d.get(), context); } catch (const ObjectNotRegisteredException &e) { e.reason(error_info); if (object_stream_type==object_stream_txt && d.get()) { String blub; blub.assignFormat(" (in line %d)", ((ObjectStreamText*)d.get())->getErrorLine()); error_info += blub; } return LS_ERROR_CORRUPTED; } catch (const IOException &e) { e.reason(error_info); if (e.mPosixErrno == ENOENT) { return LS_ERROR_NOT_FOUND; } else { return LS_ERROR_READ; } } catch (const Exception &e) { e.reason(error_info); return LS_ERROR_CORRUPTED; } return LS_OK; } /* * INIT */ bool ht_cfg_use_homedir = true; bool init_cfg() { char *d = NULL; if (ht_cfg_use_homedir) d = sys_get_home_dir(); if (!d || !ht_cfg_use_homedir) d = sys_dirname(appname); if (!d) d = ht_strdup(""); #if !defined(WIN32) && !defined(__WIN32__) && !defined(DJGPP) && !defined(MSDOS) const char *b = "/"SYSTEM_CONFIG_FILE_NAME; #else const char *b = "\\"SYSTEM_CONFIG_FILE_NAME; #endif systemconfig_file = ht_malloc(strlen(d)+strlen(b)+1); strcpy(systemconfig_file, d); strcat(systemconfig_file, b); free(d); return true; } /* * DONE */ void done_cfg() { free(systemconfig_file); } ht-2.0.22/safe-ctype.h0000644000175000001440000001044510763611313011343 00000000000000/* replacement macros. Copyright (C) 2000, 2001 Free Software Foundation, Inc. Contributed by Zack Weinberg . This file is part of the libiberty library. Libiberty is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. Libiberty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with libiberty; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ /* This is a compatible replacement of the standard C library's with the following properties: - Implements all isxxx() macros required by C99. - Also implements some character classes useful when parsing C-like languages. - Does not change behavior depending on the current locale. - Behaves properly for all values in the range of a signed or unsigned char. To avoid conflicts, this header defines the isxxx functions in upper case, e.g. ISALPHA not isalpha. */ #ifndef SAFE_CTYPE_H #define SAFE_CTYPE_H #ifdef isalpha #error "safe-ctype.h and ctype.h may not be used simultaneously" #endif /* Determine host character set. */ #define HOST_CHARSET_UNKNOWN 0 #define HOST_CHARSET_ASCII 1 #define HOST_CHARSET_EBCDIC 2 #if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \ && 'A' == 0x41 && 'a' == 0x61 && '!' == 0x21 # define HOST_CHARSET HOST_CHARSET_ASCII #else # if '\n' == 0x15 && ' ' == 0x40 && '0' == 0xF0 \ && 'A' == 0xC1 && 'a' == 0x81 && '!' == 0x5A # define HOST_CHARSET HOST_CHARSET_EBCDIC # else # define HOST_CHARSET HOST_CHARSET_UNKNOWN # endif #endif /* Categories. */ enum { /* In C99 */ _sch_isblank = 0x0001, /* space \t */ _sch_iscntrl = 0x0002, /* nonprinting characters */ _sch_isdigit = 0x0004, /* 0-9 */ _sch_islower = 0x0008, /* a-z */ _sch_isprint = 0x0010, /* any printing character including ' ' */ _sch_ispunct = 0x0020, /* all punctuation */ _sch_isspace = 0x0040, /* space \t \n \r \f \v */ _sch_isupper = 0x0080, /* A-Z */ _sch_isxdigit = 0x0100, /* 0-9A-Fa-f */ /* Extra categories useful to cpplib. */ _sch_isidst = 0x0200, /* A-Za-z_ */ _sch_isvsp = 0x0400, /* \n \r */ _sch_isnvsp = 0x0800, /* space \t \f \v \0 */ /* Combinations of the above. */ _sch_isalpha = _sch_isupper|_sch_islower, /* A-Za-z */ _sch_isalnum = _sch_isalpha|_sch_isdigit, /* A-Za-z0-9 */ _sch_isidnum = _sch_isidst|_sch_isdigit, /* A-Za-z0-9_ */ _sch_isgraph = _sch_isalnum|_sch_ispunct, /* isprint and not space */ _sch_iscppsp = _sch_isvsp|_sch_isnvsp, /* isspace + \0 */ _sch_isbasic = _sch_isprint|_sch_iscppsp /* basic charset of ISO C (plus ` and @) */ }; /* Character classification. */ extern const unsigned short _sch_istable[256]; #define _sch_test(c, bit) (_sch_istable[(c) & 0xff] & (unsigned short)(bit)) #define ISALPHA(c) _sch_test(c, _sch_isalpha) #define ISALNUM(c) _sch_test(c, _sch_isalnum) #define ISBLANK(c) _sch_test(c, _sch_isblank) #define ISCNTRL(c) _sch_test(c, _sch_iscntrl) #define ISDIGIT(c) _sch_test(c, _sch_isdigit) #define ISGRAPH(c) _sch_test(c, _sch_isgraph) #define ISLOWER(c) _sch_test(c, _sch_islower) #define ISPRINT(c) _sch_test(c, _sch_isprint) #define ISPUNCT(c) _sch_test(c, _sch_ispunct) #define ISSPACE(c) _sch_test(c, _sch_isspace) #define ISUPPER(c) _sch_test(c, _sch_isupper) #define ISXDIGIT(c) _sch_test(c, _sch_isxdigit) #define ISIDNUM(c) _sch_test(c, _sch_isidnum) #define ISIDST(c) _sch_test(c, _sch_isidst) #define IS_ISOBASIC(c) _sch_test(c, _sch_isbasic) #define IS_VSPACE(c) _sch_test(c, _sch_isvsp) #define IS_NVSPACE(c) _sch_test(c, _sch_isnvsp) #define IS_SPACE_OR_NUL(c) _sch_test(c, _sch_iscppsp) /* Character transformation. */ extern const unsigned char _sch_toupper[256]; extern const unsigned char _sch_tolower[256]; #define TOUPPER(c) _sch_toupper[(c) & 0xff] #define TOLOWER(c) _sch_tolower[(c) & 0xff] #endif /* SAFE_CTYPE_H */ ht-2.0.22/htanaly.cc0000644000175000017500000014744112127651417011121 00000000000000/* * HT Editor * htanaly.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "analy.h" #include "analy_names.h" #include "log.h" #include "htanaly.h" #include "htctrl.h" // FIXME: globalerror #include "htdialog.h" #include "htdisasm.h" #include "hthist.h" #include "htidle.h" #include "htiobox.h" #include "keyb.h" #include "htmenu.h" #include "htsearch.h" #include "strtools.h" #include "httag.h" #include "httree.h" #include "language.h" #include "textedit.h" #include "textfile.h" #include "tools.h" #include "snprintf.h" #include "syntax.h" #include "out.h" #include "out_ht.h" #include "out_txt.h" #include "store.h" extern "C" { #include "evalx.h" } /* FIXME: test */ //#include "srt.h" #include "out_html.h" #include "out_sym.h" /* * AnalyserInformation */ void AnalyserInformation::init(Bounds *b, ht_aviewer *a) { analy = a; assert(a); ht_statictext::init(b, 0, align_left); register_idle_object(this); idle(); } void AnalyserInformation::done() { unregister_idle_object(this); ht_statictext::done(); } int AnalyserInformation::gettext(char *buf, int maxlen) { return ht_snprintf(buf, maxlen, "Analyser statistics:\n" "====================\n\n" "Type: %s\nFile: %y\n" "Using disassembler: %s\n\n" "Known locations: %d\n" "Known symbols: %d\n\n", atype, &aname, adis, addrs, labels); } bool AnalyserInformation::idle() { if (analy && analy->analy) { addrs = analy->analy->getLocationCount(); labels = analy->analy->getSymbolCount(); atype = analy->analy->getType(); analy->analy->getName(aname); if (analy->analy->disasm) { adis = analy->analy->disasm->getName(); } else { adis = "?"; } dirtyview(); } return false; } /* * SymbolBox */ void SymbolBox::init(Bounds *b, Analyser *Analy) { analy = Analy; ht_listbox::init(b); str = ht_malloc(1024); symbols = analy->getSymbolCount(); idle_count = 1; } void SymbolBox::done() { free(str); ht_listbox::done(); } int SymbolBox::calcCount() { return analy->getSymbolCount(); } int SymbolBox::cursorAdjust() { Symbol *l = ((Symbol *)getFirst()); if (!l) return 0; return l->location->addr->stringSize()+10; } int SymbolBox::estimateEntryPos(void *entry) { return 0; } void *SymbolBox::getFirst() { return analy->enumSymbols(NULL); } void *SymbolBox::getLast() { return analy->enumSymbolsReverse(NULL); } void *SymbolBox::getNext(void *entry) { if (!entry) return NULL; return analy->enumSymbols((Symbol *)entry); } void *SymbolBox::getPrev(void *entry) { if (!entry) return NULL; return analy->enumSymbolsReverse((Symbol *)entry); } const char *SymbolBox::getStr(int col, void *entry) { if (!entry) return NULL; Symbol *l = ((Symbol *)entry); switch (col) { case 0: global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_WHITESPACE; ht_snprintf(str, 1024, "%y", l->location->addr); break; case 1: ht_snprintf(str, 1024, "%s", label_type_short(l->type)); break; case 2: ht_snprintf(str, 1024, "%s", l->name); break; } return str; } bool SymbolBox::idle() { if ((idle_count % 500)==0) { update(); redraw(); symbols = analy->getSymbolCount(); idle_count = 1; return 1; } idle_count++; return 0; } int SymbolBox::numColumns() { return 3; } void *SymbolBox::quickfind(const char *s) { Symbol *tmp = analy->getSymbolByName(s); if (tmp) return tmp; tmp = analy->enumSymbolsByName(s); if (tmp) { int slen = strlen(s); int tlen = strlen(tmp->name); if (slen > tlen) return NULL; if (ht_strncmp(tmp->name, s, slen)==0) return tmp; return NULL; } else { return NULL; } } char *SymbolBox::quickfindCompletition(const char *s) { if (analy->getSymbolByName(s)) { return ht_strdup(s); } Symbol *tmp = analy->enumSymbolsByName(s); if (!tmp) { return ht_strdup(s); } Symbol *tmp2 = analy->enumSymbols(tmp); if (!tmp2) { return ht_strdup(tmp->name); } int slen = strlen(s); if (!ht_strncmp(tmp->name, tmp2->name, slen)==0) { return ht_strdup(tmp->name); } char *res = ht_malloc(1024); // buffer bla strcpy(res, tmp->name); while (tmp2 && (ht_strncmp(tmp2->name, s, slen)==0)) { // fprintf(stdout, "while(%s, %s, %d)\n", tmp2->name, s, slen); int a = ht_strccomm(res, tmp2->name); res[a] = 0; tmp2 = analy->enumSymbols(tmp2); } return res; } /* * CLASS CallChain */ void CallChain::init(Bounds *b, Analyser *Analy, Address *a, char *desc) { ht_treeview::init(b, desc); VIEW_DEBUG_NAME("CallChain"); analy = Analy; root = createNode(a); } void CallChain_done(CallChainNode *n) { while (n) { CallChain_done(n->child); CallChainNode *temp = n->next; free(n); n = temp; } } void CallChain::done() { CallChain_done(root); ht_treeview::done(); } void CallChain::adjust(void *node, bool expand) { ((CallChainNode*)node)->expanded = expand; } CallChainNode *CallChain::createNode(Address *a) { CallChainNode *n = ht_malloc(sizeof(CallChainNode)); n->next = NULL; n->prev = NULL; n->child = NULL; n->examined = false; n->xa = a->clone(); n->faddr = analy->getFunctionByAddress(a); assert(n->faddr); n->fa = n->faddr->addr; n->expanded = false; return n; } void CallChain::examineNode(CallChainNode *n) { n->examined = true; if (has_children(n)) { Container *x_tree = n->faddr->xrefs; assert(x_tree); ObjHandle oh = x_tree->findFirst(); AddrXRef *x = (AddrXRef *)x_tree->get(oh); assert(x); CallChainNode *nn = n->child = createNode(x->addr); while ((oh = x_tree->findNext(oh)) != invObjHandle) { x = (AddrXRef *)x_tree->get(oh); nn->next = createNode(x->addr); nn = nn->next; } } } void *CallChain::get_child(void *node, int i) { CallChainNode *p; if (node) { if (!((CallChainNode *)node)->examined) examineNode((CallChainNode*)node); p = ((CallChainNode *)node)->child; } else { p = root; } while (p && (--i)) p = p->next; return p; } void *CallChain::get_next_node(void *node) { return ((CallChainNode*)node)->next; } void *CallChain::get_prev_node(void *node) { return ((CallChainNode*)node)->prev; } void *CallChain::get_root() { return root; } char *CallChain::get_text(void *node) { static char stupid[1024]; // FIXME: static var CallChainNode *n = (CallChainNode*)node; int d = 0; n->xa->difference(d, n->faddr->addr); char sign = '+'; if (d < 0) { d = -d; sign = '-'; } global_analyser_address_string_format = ADDRESS_STRING_FORMAT_COMPACT | ADDRESS_STRING_FORMAT_ADD_0X; ht_snprintf(stupid, sizeof stupid, "%s%c%x (%y)", n->faddr->label ? n->faddr->label->name : "unknown", sign, d, n->xa ); return stupid; } bool CallChain::has_children(void *node) { return ((CallChainNode*)node)->faddr->xrefs != NULL; } bool CallChain::is_expanded(void *node) { return ((CallChainNode*)node)->expanded; } void CallChain::select_node(void *node) { } CallChainNode *CallChain::get_current_node() { return (CallChainNode*)selected; } ///////////////////////////////////////////////////////////////////////////// /* * */ void AnalyInfoline::init(Bounds *b, ht_aviewer *A, const char *Format) { ht_statictext::init(b, 0, align_left); VIEW_DEBUG_NAME("AnalyInfoline"); analy = A; displayformat = ht_strdup(Format); addr = new InvalidAddress(); fofs = INVALID_FILE_OFS; } void AnalyInfoline::done() { free(displayformat); delete addr; ht_statictext::done(); } int AnalyInfoline::gettext(char *buf, int maxlen) { if (maxlen <= 0) return 0; if (valid()) { const char *sec = analy->analy->getSegmentNameByAddress(addr); if (fofs != INVALID_FILE_OFS) { Location *a = analy->analy->getFunctionByAddress(addr); const char *func = analy->analy->getSymbolNameByLocation(a); char *d = displayformat; char *ss = buf, *s = buf; while (*d) { if (*d == '%') { d++; switch (*d) { case ANALY_STATUS_ARG_SECTION: if (sec) ss += ht_snprintf(ss, maxlen-(ss-s), "%s", sec); break; case ANALY_STATUS_ARG_FILEOFFSET: ss += ht_snprintf(ss, maxlen-(ss-s), "%08qx", fofs); break; case ANALY_STATUS_ARG_RAW_UNASM: { int length; ss += ht_snprintf(ss, maxlen-(ss-s), "%s", analy->analy->getDisasmStr(addr, length)); break; } case ANALY_STATUS_ARG_FUNCTION: { if (func) { int d = 0; addr->difference(d, a->addr); char sign = '+'; if (d < 0) { d =- d; sign = '-'; } ss += ht_snprintf(ss, maxlen-(ss-s), "%s%c%x", func, sign, d); } break; } case ANALY_STATUS_ARG_OFFSET: global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; ss += ht_snprintf(ss, maxlen-(ss-s), "%y", addr); break; case '%': if (maxlen-(ss-s) > 1) { *ss++ = '%'; } break; default: ss += ht_snprintf(ss, maxlen-(ss-s), " error in format "); } } else { if (maxlen - (ss-s) > 1) { // leave space for trailing zero *ss++ = *d; } } d++; } *ss = 0; return ss - s; } else { if (!sec) { return ht_strlcpy(buf, "[not in file]", maxlen); } else { return ht_snprintf(buf, maxlen, "<%s> [not in file]", sec); } } } else { return ht_strlcpy(buf, "", maxlen); } } void AnalyInfoline::update(Address *cursor_addr, FileOfs ecursor_addr) { delete addr; if (valid()) { fofs = ecursor_addr; addr = cursor_addr->clone(); } else { fofs = INVALID_FILE_OFS; addr = new InvalidAddress(); } dirtyview(); redraw(); } bool AnalyInfoline::valid() { return analy && analy->analy; } /* * */ void ht_aviewer::init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Analyser *Analy) { analy = Analy; if (Analy) { analy->setDisplayMode(ANALY_SHOW_ADDRESS | ANALY_SHOW_COMMENTS | ANALY_SHOW_LABELS | ANALY_SHOW_XREFS | ANALY_TRANSLATE_SYMBOLS | ANALY_COLLAPSE_XREFS, ANALY_EDIT_BYTES); } analy_sub = NULL; ht_uformat_viewer::init(b, desc, caps, file, format_group); search_caps |= SEARCHMODE_BIN | SEARCHMODE_EVALSTR | SEARCHMODE_EXPR; infoline = NULL; idle_count = 0; last_active = true; pause = false; register_idle_object(this); one_load_hack = false; } void ht_aviewer::done() { unregister_idle_object(this); ht_uformat_viewer::done(); if (analy) { analy->done(); // FIXME: this musnt be here delete analy; } } void ht_aviewer::attachInfoline(AnalyInfoline *V) { infoline = V; } bool ht_aviewer::pos_to_offset(viewer_pos p, FileOfs *ofs) { if (analy) { Address *addr; if (!convertViewerPosToAddress(p, &addr)) return false; FileOfs o=analy->addressToFileofs(addr); delete addr; if (o != INVALID_FILE_OFS) { *ofs=o; return true; } } return false; } bool ht_aviewer::pos_to_string(viewer_pos p, char *result, int maxlen) { if (!analy) return false; Address *a; if (!convertViewerPosToAddress(p, &a)) return false; Location *addr = analy->getLocationByAddress(a); if (addr && addr->label) { ht_strlcpy(result, addr->label->name, maxlen); return true; } addr = analy->getFunctionByAddress(a); if (addr && addr->label) { int d = 0; a->difference(d, addr->addr); ht_snprintf(result, maxlen, "%s+0%xh", addr->label->name, d); return true; } global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS | ADDRESS_STRING_FORMAT_ADD_H; ht_snprintf(result, maxlen, "%y", a); return true; } bool ht_aviewer::convertViewerPosToAddress(const viewer_pos &p, Address **a) { *a = analy->createAddress(); (*a)->getFromUInt64((uint64(p.u.line_id.id1) << 32) + p.u.line_id.id2); return true; } bool ht_aviewer::convertAddressToViewerPos(Address *a, viewer_pos *p) { if (a && a->isValid()) { clear_viewer_pos(p); p->u.sub = analy_sub; uint64 u; a->putIntoUInt64(u); p->u.line_id.id1 = u >> 32; p->u.line_id.id2 = u; p->u.line_id.id3 = 0; return true; } else { return false; } } const char *ht_aviewer::func(uint i, bool execute) { switch (i) { case 8: if (execute) { sendmsg(cmd_analyser_symbols); } return "symbols"; default: return ht_uformat_viewer::func(i, execute); } return NULL; } static int aviewer_func_addr(eval_scalar *result, eval_str *str) { ht_aviewer *aviewer = (ht_aviewer*)eval_get_context(); Address *addr = aviewer->analy->createAddress(); int l = addr->parseString(str->value, str->len, aviewer->analy); if (l) { uint64 q; if (addr->putIntoUInt64(q)) { scalar_create_int_q(result, q); return 1; } } else { char buffer[1024]; bin2str(buffer, str->value, MIN((uint)str->len, sizeof buffer)); set_eval_error("invalid address '%s'", buffer); } return 0; } static int aviewer_func_address_of(eval_scalar *result, eval_str *str) { ht_aviewer *aviewer = (ht_aviewer*)eval_get_context(); char buffer[1024]; bin2str(buffer, str->value, MIN((uint)str->len, sizeof buffer)); Symbol *l; if ((l = aviewer->analy->getSymbolByName(buffer))) { uint64 q; if (l->location->addr->putIntoUInt64(q)) { scalar_create_int_q(result, q); return 1; } } else { set_eval_error("invalid label '%s'", buffer); } return 0; } static int aviewer_func_fileofs(eval_scalar *result, eval_int *i) { ht_aviewer *aviewer = (ht_aviewer*)eval_get_context(); viewer_pos p; if (aviewer->offset_to_pos(i->value, &p)) { Address *a; uint64 q; aviewer->convertViewerPosToAddress(p, &a); std::auto_ptr
blub(a); if (a->putIntoUInt64(q)) { scalar_create_int_q(result, q); return 1; } } else { set_eval_error("invalid file offset or no corresponding address for '0%xh'", i->value); } return 0; } /* * for assembler */ static int ht_aviewer_symbol_to_addr(void *Aviewer, const char *s, uint64 &v) { // FIXNEW ht_aviewer *aviewer = (ht_aviewer*)Aviewer; Address *a; if (*s == '@') { s++; if (str2int(s, v, 10)) { viewer_pos vp; if (!aviewer->offset_to_pos(v, &vp)) { set_eval_error("invalid offset: %08qx", v); return false; } aviewer->convertViewerPosToAddress(vp, &a); std::auto_ptr
blub(a); if (a->putIntoUInt64(v)) { return true; } } // invalid number after @ return false; } else if (strcmp(s, "&") ==0) { if (aviewer->getCurrentAddress(&a)) { a->putIntoUInt64(v); delete a; return true; } else { return false; } } else { Symbol *l = aviewer->analy->getSymbolByName(s); if (l) { // Label a = l->location->addr; if (a->putIntoUInt64(v)) { return true; } } } return false; } static void setdatastr(ht_view *v, char *str) { ht_inputfield_data id; id.textlen = strlen(str); id.text = (byte*)str; v->databuf_set(&id, sizeof id); } static void getdatastr(ht_inputfield_data *id, char *result) { memcpy(result, id->text, id->textlen); result[id->textlen]=0; } struct output_dialog_data { ht_inputfield_data id1; ht_listpopup_data lp; ht_inputfield_data id2; ht_inputfield_data id3; }; void ht_aviewer::generateOutputDialog() { if (!analy) return; if (analy->active) { infobox("Please wait until analyser has finished before generating output file!"); if (analy->active) return; } Bounds b; b.w=50; b.h=15; center_bounds(&b); ht_dialog *dialog; NEW_OBJECT(dialog, ht_dialog, &b, "generate analyser output", FS_KILLER | FS_TITLE | FS_MOVE); ht_view *v1, *v2; b.assign(2, 2, 25, 1); NEW_OBJECT(v1, ht_strinputfield, &b, 260); dialog->insert(v1); b.assign(2, 1, 25, 1); NEW_OBJECT(v2, ht_label, &b, "output ~filename:", v1); dialog->insert(v2); String filename, basename, basename2, suffix; file->getFilename(filename); filename.rightSplit('/', suffix, basename2); basename2.rightSplit('.', basename, suffix); basename += ".out"; setdatastr(v1, basename.contentChar()); b.assign(29, 2, 15, 1); NEW_OBJECT(v1, ht_listpopup, &b); ((ht_listpopup*)v1)->insertstring("HTML"); ((ht_listpopup*)v1)->insertstring("plain text"); dialog->insert(v1); b.assign(29, 1, 15, 1); NEW_OBJECT(v2, ht_label, &b, "~output format:", v1); dialog->insert(v2); b.assign(2, 5, 35, 1); NEW_OBJECT(v1, ht_strinputfield, &b, 260); dialog->insert(v1); b.assign(2, 4, 35, 1); NEW_OBJECT(v2, ht_label, &b, "~start address:", v1); viewer_pos cur; if (get_current_pos(&cur)) { char str[1024]; pos_to_string(cur, str, sizeof str); setdatastr(v1, str); } dialog->insert(v2); b.assign(2, 8, 35, 1); NEW_OBJECT(v1, ht_strinputfield, &b, 260); dialog->insert(v1); b.assign(2, 7, 35, 1); NEW_OBJECT(v2, ht_label, &b, "~end address:", v1); dialog->insert(v2); // setdatastr(v1, "#1000"); if (get_current_pos(&cur)) { char str[1024]; pos_to_string(cur, str, sizeof str); strcat(str, "+20"); setdatastr(v1, str); } b.assign(13, 11, 9, 2); NEW_OBJECT(v1, ht_button, &b, "O~k", button_ok); dialog->insert(v1); b.assign(27, 11, 9, 2); NEW_OBJECT(v1, ht_button, &b, "~Cancel", button_cancel); dialog->insert(v1); while (dialog->run(false) == button_ok) { char filename[260]; char start_str[1024], end_str[1024]; viewer_pos start, end; output_dialog_data odd; ViewDataBuf vdb(dialog, &odd, sizeof odd); getdatastr(&odd.id1, filename); getdatastr(&odd.id2, start_str); getdatastr(&odd.id3, end_str); if (start_str[0] == 0) { convertAddressToViewerPos(analy_sub->lowestaddress, &start); } else { if (!string_to_pos(start_str, &start)) { errorbox(globalerror); continue; } } if (end_str[0] == 0) { convertAddressToViewerPos(analy_sub->highestaddress, &end); } else { if (!string_to_pos(end_str, &end)) { errorbox(globalerror); continue; } } Address *start_addr, *end_addr; if (!convertViewerPosToAddress(start, &start_addr) || !convertViewerPosToAddress(end, &end_addr)) { errorbox("invalid address"); continue; } try { String name(filename); LocalFile s(name, IOAM_WRITE, FOM_CREATE); AnalyserOutput *out = NULL; switch (odd.lp.cursor_pos) { case 0: out = new AnalyserHTMLOutput(); ((AnalyserHTMLOutput*)out)->init(analy, &s); break; case 1: out = new AnalyserTxtOutput(); ((AnalyserTxtOutput*)out)->init(analy, &s); break; } out->generateFile(start_addr, end_addr); out->done(); delete out; } catch (const IOException &e) { infobox("couldnt create file '%y': %y.", &filename, &e); continue; } break; } dialog->done(); delete dialog; } bool ht_aviewer::canCreateAddress(Address *addr, bool error_msg) { Location *ctx = analy->getLocationContextByAddress(addr); if (ctx && ctx->addr->compareTo(addr) != 0) { if (error_msg) { global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; errorbox("Can't create new symbol: Address %y belongs to %y (%s)", addr, ctx->addr, ctx->label ? ctx->label->name : "unnamed"); } return false; } return true; } void ht_aviewer::dataIntDialog(taddr_int_subtype subtype, int length) { if (!analy) return; Address *current_address; if (!getCurrentAddress(¤t_address)) return; if (!canCreateAddress(current_address, true)) { delete current_address; return; } if (analy->validAddress(current_address, scinitialized)) { analy->data->setIntAddressType(current_address, subtype, length); } delete current_address; } void ht_aviewer::dataStringDialog() { if (!analy) return; Address *current_address; if (!getCurrentAddress(¤t_address)) return; if (!canCreateAddress(current_address, true)) { delete current_address; return; } /* Bounds b; b.w=50; b.h=15; center_bounds(&b); ht_dialog *dialog; NEW_OBJECT(dialog, ht_dialog, &b, "interprete data as string", FS_KILLER | FS_TITLE | FS_MOVE); while (dialog->run(false)==button_ok) { } dialog->done(); delete dialog;*/ if (analy->validAddress(current_address, scinitialized)) { byte buffer[1024]; Location *a = analy->enumLocations(current_address); int d = sizeof buffer; if (a) a->addr->difference(d, current_address); uint bz = analy->bufPtr(current_address, buffer, MIN(sizeof buffer, (uint)d)); if (bz > 2) { analy_string *str = string_test(buffer, bz); if (str) { char string1[128], string2[128]; str->render_string(string2, sizeof string2); ht_snprintf(string1, sizeof string1, "%s_%s", str->name(), string2); make_valid_name(string2, string1); if (analy->addAddressSymbol(current_address, string2, label_data)) { analy->addComment(current_address, 0, ""); } analy->data->setArrayAddressType(current_address, dst_string, str->length()); str->done(); delete str; } } } delete current_address; } struct export_dialog_data { ht_inputfield_data id1; ht_listpopup_data lp; }; void ht_aviewer::exportFileDialog() { if (!analy) return; if (analy->active) { infobox("Please wait until analyser has finished before exporting file!"); if (analy->active) return; } Bounds b; b.w=50; b.h=12; center_bounds(&b); ht_dialog *dialog; NEW_OBJECT(dialog, ht_dialog, &b, "export analyser information", FS_KILLER | FS_TITLE | FS_MOVE); ht_view *v1, *v2; b.assign(2, 2, 35, 1); NEW_OBJECT(v1, ht_strinputfield, &b, 260); dialog->insert(v1); b.assign(2, 1, 35, 1); NEW_OBJECT(v2, ht_label, &b, "output ~filename:", v1); dialog->insert(v2); String filename, basename, suffix; file->getFilename(filename); filename.rightSplit('.', basename, suffix); basename += ".exp"; setdatastr(v1, basename.contentChar()); b.assign(2, 5, 25, 1); NEW_OBJECT(v1, ht_listpopup, &b); ((ht_listpopup*)v1)->insertstring(".sym symbol file"); dialog->insert(v1); b.assign(2, 4, 25, 1); NEW_OBJECT(v2, ht_label, &b, "~export format:", v1); dialog->insert(v2); b.assign(13, 8, 9, 2); NEW_OBJECT(v1, ht_button, &b, "O~k", button_ok); dialog->insert(v1); b.assign(27, 8, 9, 2); NEW_OBJECT(v1, ht_button, &b, "~Cancel", button_cancel); dialog->insert(v1); while (dialog->run(false) == button_ok) { char filename[260]; export_dialog_data edd; ViewDataBuf vdb(dialog, &edd, sizeof edd); getdatastr(&edd.id1, filename); String name(filename); LocalFile s(name, IOAM_WRITE, FOM_CREATE); try { switch (edd.lp.cursor_pos) { case 0: export_to_sym(analy, &s); break; } } catch (const IOException &) { infobox("couldnt create file '%s'.", filename); continue; } break; } dialog->done(); delete dialog; } bool ht_aviewer::getCurrentAddress(Address **a) { viewer_pos vp; if (!get_current_pos(&vp)) return false; return convertViewerPosToAddress(vp, a); } bool ht_aviewer::get_current_offset(FileOfs *ofs) { if (ht_uformat_viewer::get_current_offset(ofs)) { return true; } else { Address *a; if (!getCurrentAddress(&a)) return false; *ofs = analy->addressToFileofs(a); delete a; return *ofs != INVALID_FILE_OFS; } } bool ht_aviewer::get_hscrollbar_pos(int *pstart, int *psize) { if (analy_sub) { // FIXNEW /* if (analy_sub->highestaddress->difference(s, analy_sub->lowestaddress) && s) { int z=MIN(size.h*16, (int)(top.line_id.id1-analy_sub->lowestaddress)); return scrollbar_pos(top.line_id.id1-analy_sub->lowestaddress, z, s, pstart, psize); }*/ } return false; } void ht_aviewer::getminbounds(int *width, int *height) { *width = 25; *height = 4; } int ht_aviewer::get_pindicator_str(char *buf, int max_len) { Address *addr; if (analy && getCurrentAddress(&addr)) { std::auto_ptr
blub(addr); FileOfs o; global_analyser_address_string_format = ADDRESS_STRING_FORMAT_COMPACT; if (get_current_offset(&o)) { return ht_snprintf(buf, max_len, " %y/@%08qx%s ", addr, o, (analy->isDirty())?" dirty":""); } else { return ht_snprintf(buf, max_len, " %y%s ", addr, (analy->isDirty())?" dirty":""); } } else { return ht_snprintf(buf, max_len, " ? "); } } bool ht_aviewer::gotoAddress(Address *a, ht_view *source_object) { viewer_pos p; if (analy) { if (!analy->validAddress(a, scvalid)) return false; } // FIXME: insert a->compare(hi, low address) here if (convertAddressToViewerPos(a, &p)) { return goto_pos(p, source_object); } return false; } void ht_aviewer::handlemsg(htmsg *msg) { switch (msg->msg) { case msg_contextmenuquery: { ht_static_context_menu *m = new ht_static_context_menu(); m->init("~Analyser"); m->insert_entry("~Assemble...", "Ctrl-A", cmd_analyser_call_assembler, K_Control_A, 1); m->insert_separator(); ht_static_context_menu *sub=new ht_static_context_menu(); sub->init("~Control"); sub->insert_entry("~Information...", NULL, cmd_analyser_info, 0, 1); sub->insert_separator(); sub->insert_entry("~Save state", NULL, cmd_analyser_save, 0, 1); sub->insert_entry("~Export to file...", "Ctrl-O", cmd_analyser_generate_output, K_Control_O, 1); sub->insert_separator(); sub->insert_entry("~Continue at address", "c", cmd_analyser_continue, 0, 1); sub->insert_entry("~Pause / resume", "p", cmd_analyser_pause_resume, 0, 1); m->insert_submenu(sub); sub=new ht_static_context_menu(); sub->init("~Jump"); sub->insert_entry("~Symbol list", "F8", cmd_analyser_symbols, 0, 1); sub->insert_entry("~Function start", "Ctrl-F", cmd_analyser_this_function, K_Control_F, 1); sub->insert_entry("Prev ~label", "Ctrl-L", cmd_analyser_previous_label, K_Control_L, 1); sub->insert_entry("Follow ~ptr", "f", cmd_analyser_follow, 0, 1); m->insert_submenu(sub); sub=new ht_static_context_menu(); sub->init("~Location"); sub->insert_entry("~Name address (label)...", "n", cmd_analyser_name_addr, 0, 1); sub->insert_entry("Edit co~mments", "#", cmd_analyser_comments, 0, 1); sub->insert_entry("Show ~xrefs", "x", cmd_analyser_xrefs, 0, 1); sub->insert_entry("~Delete location", "Del", cmd_analyser_del_addr_bindings, 0, 1); sub->insert_entry("~Callchain", "Ctrl-T", cmd_analyser_call_chain, K_Control_T, 1); m->insert_submenu(sub); sub=new ht_static_context_menu(); sub->init("~Data"); sub->insert_entry("Data ~string", "s", cmd_analyser_data_string, 0, 1); sub->insert_entry("Data ~word 32", "i", cmd_analyser_data_int, 0, 1); sub->insert_entry("Data ~halfword 16", "h", cmd_analyser_data_half, 0, 1); sub->insert_entry("Data ~byte 8", "b", cmd_analyser_data_byte, 0, 1); m->insert_submenu(sub); // m->insert_separator(); // m->insert_entry("Symbol reg trace (exp!)", "Alt-Q", cmd_analyser_srt, K_Meta_Q, 1); msg->msg = msg_retval; msg->data1.ptr = m; return; } case msg_keypressed: switch (msg->data1.integer) { case K_Control_L: sendmsg(cmd_analyser_previous_label); clearmsg(msg); return; case K_Control_F: sendmsg(cmd_analyser_this_function); clearmsg(msg); return; case 'c': if (cursor_tag_class == tag_class_sel) { sendmsg(cmd_analyser_continue); clearmsg(msg); return; } break; case '#': sendmsg(cmd_analyser_comments); clearmsg(msg); return; case 'F': if (cursor_tag_class == tag_class_sel) { sendmsg(cmd_analyser_follow_ex); clearmsg(msg); return; } break; case 'f': if (cursor_tag_class == tag_class_sel) { sendmsg(cmd_analyser_follow); clearmsg(msg); return; } break; case 'n': sendmsg(cmd_analyser_name_addr); clearmsg(msg); return; case 'p': sendmsg(cmd_analyser_pause_resume); clearmsg(msg); return; case 'i': if (cursor_tag_class == tag_class_sel) { sendmsg(cmd_analyser_data_int); clearmsg(msg); } return; case 'h': if (cursor_tag_class == tag_class_sel) { sendmsg(cmd_analyser_data_half); clearmsg(msg); return; } break; case 'b': if (cursor_tag_class == tag_class_sel) { sendmsg(cmd_analyser_data_byte); clearmsg(msg); return; } break; case 's': sendmsg(cmd_analyser_data_string); clearmsg(msg); return; case 'x': sendmsg(cmd_analyser_xrefs); clearmsg(msg); return; case K_Control_D: case K_Delete: sendmsg(cmd_analyser_del_addr_bindings); clearmsg(msg); return; } break; case cmd_analyser_call_assembler: { if (!analy) break; Assembler *a = analy->createAssembler(); if (!a) { // FIXME: select assembler for list infobox("no assembler available."); clearmsg(msg); return; } viewer_pos current_pos; Address *current_address; if (get_current_pos(¤t_pos) && getCurrentAddress(¤t_address)) { a->set_imm_eval_proc(ht_aviewer_symbol_to_addr, (void*)this); int want_length; analy->getDisasmStr(current_address, want_length); dialog_assemble(this, current_pos, analy->mapAddr(current_address), a, analy->disasm, analy->getDisasmStrFormatted(current_address), want_length); delete current_address; } a->done(); delete a; clearmsg(msg); return; } case cmd_analyser_this_function: { if (!analy) break; Address *c; if (!getCurrentAddress(&c)) break; Location *a = analy->getFunctionByAddress(c); if (a) { gotoAddress(a->addr, this); } else { global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; errorbox("Address %y doesn't belong to a function.", c); } delete c; clearmsg(msg); return; } case cmd_analyser_previous_label: { if (!analy) break; Address *c; if (!getCurrentAddress(&c)) break; Location *a = analy->getPreviousSymbolByAddress(c); if (a) { gotoAddress(a->addr, this); } else { global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; errorbox("Address %y doesn't belong to a symbol.", c); } delete c; clearmsg(msg); return; } case cmd_analyser_continue: { if (!analy) break; Address *a; if (!getCurrentAddress(&a)) break; analy->continueAnalysisAt(a); delete a; analy->makeDirty(); analy_sub->output->invalidateCache(); clearmsg(msg); return; } case cmd_analyser_comments: { if (!analy) break; Address *current_address; if (getCurrentAddress(¤t_address)) { showComments(current_address); delete current_address; } clearmsg(msg); return; } case cmd_analyser_name_addr: { if (!analy) break; Address *addr = NULL; if (!getCurrentAddress(&addr) || !canCreateAddress(addr, true)) { delete addr; clearmsg(msg); return; } global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; if (analy->validAddress(addr, scvalid)) { char n[256]; char str[1024]; Symbol *l = analy->getSymbolByAddress(addr); if (l) ht_strlcpy(n, l->name, sizeof n); else n[0] = 0; ht_snprintf(str, sizeof str, "name for address %y", addr); while (inputbox(str, "~label name:", n, 255, HISTATOM_NAME_ADDR)) { if (n[0]) { if (valid_name(n)) { char *n2 = ht_strdup(n); if (!analy->assignSymbol(addr, n2, (l)?l->type:label_unknown)) { l = analy->getSymbolByName(n); global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; errorbox("Label '%s' already exists at address %y!", n, l->location->addr); free(n2); } else { analy->makeDirty(); analy_sub->output->invalidateCache(); break; } } else { global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; if (confirmbox("'%s' is an invalid label name.\nMake valid?", n)==button_yes) { make_valid_name(n, n); } } } else { if (l) { // delete label if applicable global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; if (confirmbox("Really delete label '%s' at address %y?", l->name, addr)==button_yes) { analy->deleteSymbol(addr); analy->makeDirty(); analy_sub->output->invalidateCache(); } } break; } } } else { global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; errorbox("Address %y is invalid!", addr); } delete addr; clearmsg(msg); return; } case cmd_analyser_xrefs: { if (!analy) break; Address *a; if (!getCurrentAddress(&a)) break; showXRefs(a); delete a; clearmsg(msg); return; } case cmd_analyser_follow: { if (!analy) break; Address *c; if (!getCurrentAddress(&c)) break; std::auto_ptr
blub(c); if (!analy->validAddress(c, scinitialized)) break; Address *b = analy->createAddress(); std::auto_ptr
blub2(b); uint bz = b->byteSize(); if (!bz) break; byte buf[bz]; if (analy->bufPtr(c, buf, bz) != bz) break; b->getFromArray(buf); if (analy->validAddress(b, scvalid)) { gotoAddress(b, this); } else { global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; errorbox("Follow: address %y is invalid!", b); } clearmsg(msg); return; } case cmd_analyser_follow_ex: if (!analy) break; clearmsg(msg); return; case cmd_analyser_pause_resume: if (!analy) break; pause = !pause; clearmsg(msg); return; case cmd_analyser_del_addr_bindings: { if (!analy) break; Address *addr; global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; if (getCurrentAddress(&addr)) { if (confirmbox("Forget about address' %y bindings?\n(name, comments, xrefs, etc.)", addr)==button_yes) { analy->deleteLocation(addr); analy->makeDirty(); analy_sub->output->invalidateCache(); } delete addr; } clearmsg(msg); return; } case cmd_analyser_generate_output: if (!analy) break; generateOutputDialog(); clearmsg(msg); return; case cmd_analyser_export_file: if (!analy) break; exportFileDialog(); clearmsg(msg); return; case cmd_analyser_data_int: if (!analy) break; dataIntDialog(dst_idword, 4); analy->makeDirty(); analy_sub->output->invalidateCache(); dirtyview(); clearmsg(msg); return; case cmd_analyser_data_half: if (!analy) break; dataIntDialog(dst_iword, 2); analy->makeDirty(); analy_sub->output->invalidateCache(); dirtyview(); clearmsg(msg); return; case cmd_analyser_data_byte: if (!analy) break; dataIntDialog(dst_ibyte, 1); analy->makeDirty(); analy_sub->output->invalidateCache(); dirtyview(); clearmsg(msg); return; case cmd_analyser_data_string: if (!analy) break; dataStringDialog(); analy->makeDirty(); analy_sub->output->invalidateCache(); dirtyview(); clearmsg(msg); return; case cmd_analyser_info: if (!analy) break; Address *current_address; if (!getCurrentAddress(¤t_address)) { showInfo(0); } else { showInfo(current_address); delete current_address; } dirtyview(); clearmsg(msg); return; case cmd_analyser_symbols: { Address *current_address; if (!getCurrentAddress(¤t_address)) return; showSymbols(current_address); delete current_address; clearmsg(msg); return; } case cmd_edit_mode: case cmd_view_mode: if (analy) { if (edit()) { analy->setDisplayMode(ANALY_EDIT_BYTES, 0); } else { analy->setDisplayMode(0, ANALY_EDIT_BYTES); } } analy_sub->output->invalidateCache(); break; case msg_file_changed: { analy_sub->output->invalidateCache(); break; } case cmd_analyser_call_chain: { if (!analy) break; Address *addr; if (getCurrentAddress(&addr)) { showCallChain(addr); delete addr; } return; } /* FIXME: srt-experimental */ /* case cmd_analyser_srt: { Address *current_addr; if (getCurrentAddress(¤t_addr)) { test_srt(analy, current_addr); delete current_addr; } clearmsg(msg); return; }*/ case msg_get_analyser: { msg->msg = msg_retval; msg->data1.ptr = analy; return; } case msg_set_analyser: { Analyser *a = (Analyser*)msg->data1.ptr; if (analy) { analy->done(); delete analy; } a->setDisplayMode(0, ANALY_EDIT_BYTES); setAnalyser(a); analy_sub->output->invalidateCache(); clearmsg(msg); one_load_hack = true; return; } case msg_postinit: if (analy && !one_load_hack) { analy->beginAnalysis(); analy_sub->output->invalidateCache(); } return; } ht_uformat_viewer::handlemsg(msg); switch (msg->msg) { case msg_draw: if (infoline) { FileOfs a; Address *addr; if (!getCurrentAddress(&addr)) { addr = new InvalidAddress(); } infoline->update(addr, (get_current_real_offset(&a)) ? a : INVALID_FILE_OFS); delete addr; } break; } } bool ht_aviewer::idle() { if (!analy) return false; last_active = analy->active; if (!pause) analy->continueAnalysis(); if (last_active && !analy->active) { String name; LOG("%y: analyser finished after %d ops.", &analy->getName(name), analy->ops_parsed); dirtyview(); app->sendmsg(msg_draw, 0); } idle_count++; /* if (idle_count % 565 == 0) { analy_sub->output->invalidateCache(); dirtyview(); app->sendmsg(msg_draw, 0); }*/ if (analy->active) { if (idle_count%53==0) { analy_sub->output->invalidateCache(); dirtyview(); app->sendmsg(msg_draw, 0); } } return last_active && !pause; } bool ht_aviewer::offset_to_pos(FileOfs ofs, viewer_pos *p) { if (!analy) return false; Address *a = analy->fileofsToAddress(ofs); bool res = convertAddressToViewerPos(a, p); delete a; return res; } bool ht_aviewer::ref_sel(LINE_ID *id) { if (!id->id1 && !id->id2 && !id->id3 && !id->id4) return 0; switch (id->id4) { case 0: if (analy) { Address *a = analy->createAddress(); a->getFromUInt64((uint64(id->id1) << 32) + id->id2); bool res = gotoAddress(a, this); delete a; return res; } else { return false; } case 1: if (analy) { Address *a = analy->createAddress(); a->getFromUInt64((uint64(id->id1) << 32) + id->id2); showXRefs(a); delete a; } return false; } return false; } void ht_aviewer::reloadpalette() { ht_uformat_viewer::reloadpalette(); if (analy_sub) analy_sub->output->changeConfig(); } void ht_aviewer::searchForXRefs(Address *Addr) { // FIXME: viewer_pos && FIXNEW char str[100]; global_analyser_address_string_format = ADDRESS_STRING_FORMAT_COMPACT; ht_snprintf(str, sizeof str, "%y", Addr); ht_regex_search_request *q = new ht_regex_search_request(SC_VISUAL, SF_REGEX_CASEINSENSITIVE, str); viewer_pos vp_start, vp_end; convertAddressToViewerPos(analy_sub->lowestaddress, &vp_start); convertAddressToViewerPos(analy_sub->highestaddress, &vp_end); int oldmode = analy->getDisplayMode(); analy->setDisplayMode(0, -1); analy_sub->output->invalidateCache(); ht_visual_search_result *r = (ht_visual_search_result *)vsearch(q, vp_start, vp_end); while (r) { Address *to; convertViewerPosToAddress(r->pos, &to); analy->addXRef(Addr, to, xrefoffset); viewer_pos na; next_logical_pos(r->pos, &na); delete to; delete r; r = (ht_visual_search_result *)vsearch(q, na, vp_end); } analy->setDisplayMode(oldmode, -1); analy->makeDirty(); analy_sub->output->invalidateCache(); delete q; } void ht_aviewer::showCallChain(Address *Addr) { Location *a = analy->getFunctionByAddress(Addr); if (!a) return; Bounds b; b.w = 60; b.h = 16; center_bounds(&b); char str[256]; global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; ht_snprintf(str, sizeof str, "call chain of address %y", Addr); ht_dialog *dialog = new ht_dialog(); dialog->init(&b, str, FS_KILLER | FS_TITLE | FS_MOVE); b.assign(1, 0, 56, 10); ht_statictext *text = new ht_statictext(); if (a->label) { ht_snprintf(str, sizeof str, "function %s %s", a->label->name, "is referenced by .."); } else { ht_snprintf(str, sizeof str, "address %y %s", a->addr, "is referenced by .."); } text->init(&b, str, align_left); dialog->insert(text); b.assign(1, 1, 56, 10); CallChain *cc; NEW_OBJECT(cc, CallChain, &b, analy, Addr, NULL); cc->adjust(cc->get_root(), true); dialog->insert(cc); b.assign(15, 12, 9, 2); ht_button *bt; NEW_OBJECT(bt, ht_button, &b, "O~k", button_ok); dialog->insert(bt); b.assign(35, 12, 9, 2); NEW_OBJECT(bt, ht_button, &b, "~Cancel", button_cancel); dialog->insert(bt); int r = dialog->run(false); if (r == button_ok) { gotoAddress(cc->get_current_node()->xa, this); } dialog->done(); delete dialog; } void ht_aviewer::showComments(Address *Addr) { if (!analy) return; if (!canCreateAddress(Addr, true)) { return; } CommentList *comment = analy->getComments(Addr); // prepare mem_file MemoryFile *mem_file = new MemoryFile(); if (comment) { int c1 = comment->count(); for (int i=0; i < c1; i++) { const char *c = comment->getName(i); int len = strlen(c); if (len) mem_file->write(c, len); if (i+1write((void*)"\n", 1); } } /* ht_c_syntax_lexer *lexer = new ht_c_syntax_lexer(); lexer->init();*/ // prepare textfile ht_ltextfile text_file(mem_file, true, NULL); // create dialog Bounds b; b.w = 60; b.h = 16; center_bounds(&b); ht_dialog *dialog = new ht_dialog(); dialog->init(&b, "edit comments", FS_KILLER | FS_TITLE | FS_MOVE); b.assign(1, 1, 55, 10); ht_text_editor *text_editor = new ht_text_editor(); text_editor->init(&b, false, &text_file, NULL, TEXTEDITOPT_UNDO); dialog->insert(text_editor); /* FIXME: scrollbar BOUNDS_ASSIGN(b, 56, 1, 1, 10); */ ht_button *b1; b.assign(18, 12, 9, 2); NEW_OBJECT(b1, ht_button, &b, "O~k", button_ok); dialog->insert(b1); b.assign(32, 12, 9, 2); NEW_OBJECT(b1, ht_button, &b, "~Cancel", button_cancel); dialog->insert(b1); if (dialog->run(false) == button_ok) { Location *a = analy->getLocationByAddress(Addr); if (a) analy->freeComments(a); uint c = text_file.linecount(); char buf[1024]; bool empty=false; if (c == 1) { uint l = 0; text_file.getline(0, 0, buf, 1024, &l, NULL); empty=(l==0); } if (!empty) { for (uint i=0; iaddComment(Addr, 0, buf); } } } analy->makeDirty(); analy_sub->output->invalidateCache(); } dialog->done(); delete dialog; } void ht_aviewer::showInfo(Address *Addr) { Bounds c, b; app->getbounds(&c); b.w=c.w*5/6; b.h=c.h*5/6; center_bounds(&b); char str[100]; strcpy(str, "Analyser information"); ht_dialog *dialog = new ht_dialog(); dialog->init(&b, str, FS_KILLER | FS_TITLE | FS_MOVE); b.assign(1, 0, b.w-4, 10); AnalyserInformation *text = new AnalyserInformation(); text->init(&b, this); dialog->insert(text); dialog->run(false); dialog->done(); delete dialog; } void ht_aviewer::showSymbols(Address *addr) { if (!analy) return; Location *loc = analy->getPreviousSymbolByAddress(addr); Bounds b; b.w = 60; b.h = 15; center_bounds(&b); ht_dialog *dialog = new ht_dialog(); dialog->init(&b, "symbols", FS_KILLER | FS_TITLE | FS_MOVE | FS_RESIZE); /* pull down */ b.assign(30, 0, 20, 1); /* ht_listpopup *lp = new ht_listpopup(); lp->init(&b); lp->insertstring("show all"); lp->insertstring("only functions"); lp->insertstring("only labels"); lp->insertstring("only offsets (code)"); lp->insertstring("only data"); dialog->insert(lp);*/ /* text */ b.assign(1, 0, 56, 1); ht_listbox_title *text = new ht_listbox_title(); text->init(&b); text->setText(3, "Address", "Type", "Name"); /* list */ b.assign(1, 1, 56, 12); SymbolBox *sym = new SymbolBox(); sym->init(&b, analy); if (loc && loc->label) { sym->gotoItemByEntry(sym->quickfind(loc->label->name)); } dialog->insert(sym); dialog->insert(text); sym->attachTitle(text); register_idle_object(sym); int r = dialog->run(false); unregister_idle_object(sym); if (r == button_ok) { // goto selected symbol ht_listbox_data d; ViewDataBuf vdb(sym, &d, sizeof d); if (d.data->cursor_ptr) gotoAddress(((Symbol *)d.data->cursor_ptr)->location->addr, this); } dialog->done(); delete dialog; } void ht_aviewer::showXRefs(Address *Addr) { if (!analy->getXRefs(Addr)) { if (confirmbox("No xrefs for address %y!\nSearch for xrefs?", Addr) == button_yes) { searchForXRefs(Addr); } } Bounds c, b; app->getbounds(&c); b.w = c.w*5/6; b.h = c.h*5/6; center_bounds(&b); int result; do { Container *x_tree = analy->getXRefs(Addr); uint bw = b.w; uint bh = b.h; char str[256]; global_analyser_address_string_format = ADDRESS_STRING_FORMAT_COMPACT | ADDRESS_STRING_FORMAT_ADD_0X; ht_snprintf(str, sizeof str, "xrefs of address %y", Addr); ht_dialog *dialog = new ht_dialog(); dialog->init(&b, str, FS_KILLER | FS_TITLE | FS_MOVE | FS_RESIZE); b.assign(1, 0, bw-4, 1); ht_listbox_title *text = new ht_listbox_title(); text->init(&b); text->setText(3, "xref to", "type", "from function"); b.y = 1; b.h = bh-6; ht_text_listbox *list; NEW_OBJECT(list, ht_text_listbox, &b, 3, 2); b.assign(2, bh-4, 26, 2); ht_button *search_for_xrefs; NEW_OBJECT(search_for_xrefs, ht_button, &b, "~Search for more XRefs", 666); search_for_xrefs->growmode = MK_GM(GMH_LEFT, GMV_BOTTOM); b.assign(29, bh-4, 11, 2); ht_button *delete_xref; NEW_OBJECT(delete_xref, ht_button, &b, "~Delete", 667); delete_xref->growmode = MK_GM(GMH_LEFT, GMV_BOTTOM); // FIXME: disable button when possible b.assign(41, bh-4, 10, 2); ht_button *new_xref; NEW_OBJECT(new_xref, ht_button, &b, "~Add", 668); new_xref->growmode = MK_GM(GMH_LEFT, GMV_BOTTOM); char str2[1024]; int xcount=0; if (x_tree) foreach(AddrXRef, x, *x_tree, { xcount++; global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_WHITESPACE; ht_snprintf(str, sizeof str, "%y", x->addr); Location *a = analy->getFunctionByAddress(x->addr); const char *func = analy->getSymbolNameByLocation(a); if (func) { int d=0; x->addr->difference(d, a->addr); char sign = '+'; if (d < 0) { d = -d; sign = '-'; } ht_snprintf(str2, sizeof str2, "%s%c%x", func, sign, d); } else { strcpy(str2, "?"); } list->insert_str_extra(xcount, x->addr, str, xref_type(x->type), str2); }); list->attachTitle(text); list->update(); dialog->insert(text); dialog->insert(list); dialog->insert(search_for_xrefs); dialog->insert(delete_xref); dialog->insert(new_xref); result = dialog->run(false); ht_listbox_data data; ViewDataBuf vdb(list, &data, sizeof data); switch (result) { case 666: searchForXRefs(Addr); break; case 667: if (xcount) { analy->deleteXRef(Addr, (Address*)list->getExtra(data.data->cursor_ptr)); analy->makeDirty(); analy_sub->output->invalidateCache(); } break; case 668: { char result[256]; ht_snprintf(str, sizeof str, "add xref from %y", Addr); result[0] = 0; while (inputbox(str, "to ~address: ", result, 255, HISTATOM_GOTO)) { viewer_pos res_pos; if (!string_to_pos(result, &res_pos)) { errorbox(globalerror); continue; } Address *a; if (!convertViewerPosToAddress(res_pos, &a)) { errorbox("invalid address"); delete a; continue; } if (!analy->addXRef(Addr, a, xrefoffset)) { // FIXME: some error msg } delete a; analy->makeDirty(); analy_sub->output->invalidateCache(); break; } break; } case button_ok: if (xcount) gotoAddress((Address*)list->getExtra(data.data->cursor_ptr), this); break; } dialog->getbounds(&b); dialog->done(); delete dialog; } while (result >= 666 && result <= 668); } bool ht_aviewer::func_handler(eval_scalar *result, char *name, eval_scalarlist *params) { eval_func myfuncs[] = { {"addressOf", (void*)&aviewer_func_address_of, {SCALAR_STR}, "return address of symbol"}, {"fileofs", (void*)&aviewer_func_fileofs, {SCALAR_INT}, "convert file offset to address"}, // {"addr", (void*)&aviewer_func_addr, {SCALAR_STR}}, "", {NULL} }; return std_eval_func_handler(result, name, params, myfuncs); } bool ht_aviewer::symbol_handler(eval_scalar *result, char *name) { uint64 v; viewer_pos vp; Address *w; if (*name == '@') { name++; if (parseIntStr(name, v, 10)) { if (*name) return false; if (!offset_to_pos(v, &vp)) { set_eval_error("invalid offset: %08qx", v); return false; } convertViewerPosToAddress(vp, &w); uint64 b = 0; w->putIntoUInt64(b); delete w; scalar_create_int_q(result, b); return true; } // invalid number after @ } else { if (strcmp(name, "$")==0) { if (getCurrentAddress(&w)) { uint64 b = 0; w->putIntoUInt64(b); scalar_create_int_q(result, b); delete w; return true; } else { return false; } } Symbol *l = analy->getSymbolByName(name); if (l) { w=l->location->addr; uint64 b; w->putIntoUInt64(b); scalar_create_int_q(result, b); return true; } } return ht_uformat_viewer::symbol_handler(result, name); } bool ht_aviewer::qword_to_pos(uint64 q, viewer_pos *pos) { if (!analy) return false; Address *a=analy->createAddress(); a->getFromUInt64(q); if (analy->validAddress(a, scvalid)) { bool res = convertAddressToViewerPos(a, pos); delete a; return res; } else { global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; ht_snprintf(globalerror, GLOBAL_ERROR_SIZE, "address %y is invalid", a); } delete a; return false; } /* * CLASS ht_analy_sub */ void ht_analy_sub::init(File *file, ht_aviewer *A, Analyser *analyser, Address *Lowestaddress, Address *Highestaddress) { ht_sub::init(file); aviewer = A; analy = analyser; output = new AnalyserHTOutput(); ((AnalyserHTOutput*)output)->init(analy); lowestaddress = Lowestaddress->clone(); highestaddress = Highestaddress->clone(); } void ht_analy_sub::done() { delete lowestaddress; delete highestaddress; output->done(); delete output; ht_sub::done(); } bool ht_analy_sub::closest_line_id(LINE_ID *line_id) { if (!prev_line_id(line_id, 1)) { if (!next_line_id(line_id, 1)) { first_line_id(line_id); } } return true; } bool ht_analy_sub::convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id) { viewer_pos a; if (!uformat_viewer->offset_to_pos(offset, &a)) return false; *line_id = a.u.line_id; return true; } void ht_analy_sub::first_line_id(LINE_ID *line_id) { clear_line_id(line_id); uint64 u; lowestaddress->putIntoUInt64(u); line_id->id1 = u >> 32; line_id->id2 = u; } bool ht_analy_sub::getline(char *line, int maxlen, const LINE_ID line_id) { if (!analy) return false; Address *a = analy->createAddress(); a->getFromUInt64((uint64(line_id.id1) << 32) + line_id.id2); bool res = output->getLineString(line, maxlen, a, (int)line_id.id3); delete a; return res; } void ht_analy_sub::last_line_id(LINE_ID *line_id) { clear_line_id(line_id); uint64 u; highestaddress->putIntoUInt64(u); line_id->id1 = u >> 32; line_id->id2 = u; } int ht_analy_sub::next_line_id(LINE_ID *line_id, int n) { if (!analy) return false; Address *a = analy->createAddress(); a->getFromUInt64((uint64(line_id->id1) << 32) + line_id->id2); int line = line_id->id3; int res = output->nextLine(a, line, n, highestaddress); if (res) { line_id->id3 = line; uint64 u; a->putIntoUInt64(u); line_id->id1 = u >> 32; line_id->id2 = u; } delete a; return res; } int ht_analy_sub::prev_line_id(LINE_ID *line_id, int n) { if (!analy) return false; Address *a = analy->createAddress(); a->getFromUInt64((uint64(line_id->id1) << 32) + line_id->id2); int line = line_id->id3; int res = output->prevLine(a, line, n, lowestaddress); if (res) { line_id->id3 = line; uint64 u; a->putIntoUInt64(u); line_id->id1 = u >> 32; line_id->id2 = u; } delete a; return res; } ht_search_result *ht_analy_sub::search(ht_search_request *search, FileOfs start, FileOfs end) { // FIXME: viewer pos Address *st = NULL; ht_search_result *r = NULL; while (!r) { st = (Address *)analy->initialized->findNext(st); if (!st) break; area_s *s = analy->initialized->getArea(st); if (!s) break; st = (Address *)s->end; FileOfs fstart, fend; FileOfs fsize; viewer_pos vp_start, vp_end; aviewer->convertAddressToViewerPos((Address *)s->start, &vp_start); if (!aviewer->pos_to_offset(vp_start, &fstart)) assert(0); Address *send = (Address*)s->end->clone(); send->add(-1); aviewer->convertAddressToViewerPos(send, &vp_end); delete send; if (!aviewer->pos_to_offset(vp_end, &fend)) assert(0); fsize = fend - fstart; if (search->search_class == SC_PHYSICAL && search->type == ST_EXPR) { r = linear_expr_search(search, start, end, this, uformat_viewer, fstart, fsize); } else if (search->search_class == SC_PHYSICAL && search->type == ST_FXBIN) { r = linear_bin_search(search, start, end, file, fstart, fsize); } } return r; } void ht_analy_sub::setAnalyser(Analyser *Analy) { analy = Analy; output->analy = Analy; output->invalidateCache(); } ht-2.0.22/htpeil.cc0000644000175000001440000002017210615341623010724 00000000000000/* * HT Editor * htpeil.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "formats.h" #include "htapp.h" #include "atom.h" #include "htcoff.h" #include "htctrl.h" #include "endianess.h" #include "hthex.h" #include "htiobox.h" #include "htnewexe.h" #include "htpe.h" #include "htpehead.h" #include "htpeil.h" #include "httag.h" #include "strtools.h" #include "snprintf.h" #include "pestruct.h" #include "ilopc.h" #include "ilstruct.h" #include static ht_mask_ptable il_directory[] = { {"size", STATICTAG_EDIT_DWORD_LE("00000000")}, {"major version", STATICTAG_EDIT_WORD_LE("00000004")}, {"minor version", STATICTAG_EDIT_WORD_LE("00000006")}, {"metadata rva", STATICTAG_EDIT_DWORD_LE("00000008")}, {"metadata size", STATICTAG_EDIT_DWORD_LE("0000000c")}, {"attributes", STATICTAG_EDIT_DWORD_LE("00000010")}, {"entrypoint token",STATICTAG_EDIT_DWORD_LE("00000014")}, {"resources rva", STATICTAG_EDIT_DWORD_LE("00000018")}, {"resources size", STATICTAG_EDIT_DWORD_LE("0000001c")}, {"strong name sig", STATICTAG_EDIT_DWORD_LE("00000020")}, {"strong name sig", STATICTAG_EDIT_DWORD_LE("00000024")}, {"code manager rva", STATICTAG_EDIT_DWORD_LE("00000028")}, {"code manager size", STATICTAG_EDIT_DWORD_LE("0000002c")}, {"vtable fixups rva", STATICTAG_EDIT_DWORD_LE("00000030")}, {"vtable fixups size", STATICTAG_EDIT_DWORD_LE("00000034")}, {"export address table", STATICTAG_EDIT_DWORD_LE("00000038")}, {"export address table", STATICTAG_EDIT_DWORD_LE("0000003c")}, {"managed native header", STATICTAG_EDIT_DWORD_LE("00000040")}, {0, 0} }; static ht_mask_ptable metadata_section[] = { {"magic", STATICTAG_EDIT_DWORD_LE("00000000")}, {"major_version", STATICTAG_EDIT_WORD_LE("00000004")}, {"minor_version", STATICTAG_EDIT_WORD_LE("00000006")}, {"unknown", STATICTAG_EDIT_DWORD_LE("00000008")}, {"version_string_length", STATICTAG_EDIT_DWORD_LE("00000010")}, {0, 0} }; static ht_view *htpeil_init(Bounds *b, File *file, ht_format_group *group) { ht_pe_shared_data *pe_shared=(ht_pe_shared_data *)group->get_shared_data(); if (pe_shared->opt_magic!=COFF_OPTMAGIC_PE32) return NULL; uint32 sec_rva, sec_size; FileOfs sec_ofs; sec_rva = pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_IL].address; sec_size = pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_IL].size; if (!sec_rva || !sec_size) return NULL; PE_IL_DIRECTORY dir; bool pe_bigendian = false; ht_pe_il_viewer *v; if (!pe_rva_to_ofs(&pe_shared->sections, sec_rva, &sec_ofs)) goto read_error; file->seek(sec_ofs); if (file->read(&dir, sizeof dir) != sizeof dir) goto read_error; createHostStruct(&dir, PE_IL_DIRECTORY_struct, little_endian); if (sec_size != dir.size) goto read_error; pe_shared->il = new ht_pe_il(); pe_shared->il->dir = dir; v = new ht_pe_il_viewer(); v->init(b, DESC_PE_IL, VC_EDIT | VC_SEARCH, file, group); pe_shared->v_il = v; ht_mask_sub *s; // ht_collapsable_sub *cs; s = new ht_mask_sub(); s->init(file, 0); char info[128]; ht_snprintf(info, sizeof info, "* COM+ directory at offset %08qx", sec_ofs); s->add_mask(info); v->insertsub(s); /* FIXME: */ s=new ht_mask_sub(); s->init(file, 1); s->add_staticmask_ptable(il_directory, sec_ofs, pe_bigendian); v->insertsub(s); FileOfs metadata_ofs; if (pe_rva_to_ofs(&pe_shared->sections, dir.metadata_section_rva, &metadata_ofs)) { /* read metadata section*/ IL_METADATA_SECTION metadata; file->seek(metadata_ofs); if (file->read(&metadata, sizeof metadata) == sizeof metadata) { createHostStruct(&metadata, IL_METADATA_SECTION_struct, little_endian); pe_shared->il->metadata = metadata; uint32 add = 2; if (metadata.minor_version == 1) { // FIXME: align metadata.version_string_length uint32 version_string_length; file->read(&version_string_length, 4); // dummy file->read(&version_string_length, 4); version_string_length = createHostInt(&version_string_length, 4, little_endian); add += version_string_length + 8; } FileOfs ofs = metadata_ofs + sizeof metadata + add; file->seek(ofs); uint16 count; file->read(&count, 2); count = createHostInt(&count, 2, little_endian); pe_shared->il->entries = new Array(true); for (uint i=0; i < count; i++) { IL_METADATA_SECTION_ENTRY sec_entry; ht_il_metadata_entry *entry; // FIXME: error handling file->read(&sec_entry, sizeof sec_entry); createHostStruct(&sec_entry, IL_METADATA_SECTION_ENTRY_struct, little_endian); String name("?"); file->readStringz(name); int nlen = name.length() + 1; uint32 dummy; if (nlen % 4) { // align properly file->read(&dummy, 4 - nlen % 4); } entry = new ht_il_metadata_entry(name.contentChar(), metadata_ofs+sec_entry.offset, sec_entry.size); // fprintf(stderr, "%s %x %x\n", name.contentChar(), metadata_ofs+sec_entry.offset, sec_entry.size); pe_shared->il->entries->insert(entry); } for (uint i=0; iil->entries)[i]; if (strcmp(entry->name, "#~") == 0) { // token index char dummy[8]; uint64 types; file->seek(entry->offset); file->read(&dummy, 8); file->read(&types, 8); // file->read(); } else if (strcmp(entry->name, "#US")==0) { // stringpool pe_shared->il->string_pool = ht_malloc(entry->size); file->seek(entry->offset); pe_shared->il->string_pool_size = file->read(pe_shared->il->string_pool, entry->size); } } } } return v; read_error: return NULL; } format_viewer_if htpeil_if = { htpeil_init, 0 }; /* * CLASS ht_pe_header_viewer */ void ht_pe_il_viewer::init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *group) { ht_uformat_viewer::init(b, desc, caps, file, group); VIEW_DEBUG_NAME("ht_pe_il_viewer"); } void ht_pe_il_viewer::done() { ht_pe_shared_data *pe_shared=(ht_pe_shared_data *)format_group->get_shared_data(); if (pe_shared && pe_shared->il) { free(pe_shared->il->string_pool); delete pe_shared->il->entries; delete pe_shared->il; } ht_uformat_viewer::done(); } ht_il_metadata_entry::ht_il_metadata_entry(const char *n, uint32 o, uint32 s) { name = ht_strdup(n); offset = o; size = s; } ht_il_metadata_entry::~ht_il_metadata_entry() { free(name); } /* * NOTE: ILunpack returns result in host-endianess */ int ILunpackDword(uint32 &result, const byte *buf, int len) { if (len) { result = *(buf++); len--; if (result < 0x80) return 1; // one byte form if (!len) return 0; if ((result & 0xc0) == 0x80) { // two byte form result = ((result & 0x3f) << 8) | buf[0]; return 2; } else if ((result & 0xe0) == 0xc0) { // four byte form if (len < 2) return 0; result = ((result & 0x1F) << 24) | (((uint32)buf[0]) << 16) | (((uint32)buf[1]) << 8) | (uint32)buf[2]; return 4; } else if ((result & 0xf0) == 0xe0) { // five byte form if (len < 3) return 0; result = (((uint32)buf[0]) << 24) | (((uint32)buf[1]) << 16) | (((uint32)buf[2]) << 8) | (uint32)buf[3]; return 5; } } return 0; } int ILunpackToken(uint32 &result, const byte *buf, int len) { int read = ILunpackDword(result, buf, len); if (!read) return 0; uint32 type; switch (result & 0x03) { case 0x00: type = IL_META_TOKEN_TYPE_DEF; break; case 0x01: type = IL_META_TOKEN_TYPE_REF; break; case 0x02: type = IL_META_TOKEN_TYPE_SPEC; break; default: type = IL_META_TOKEN_BASE_TYPE; } result = (result >> 2) | type; return read; } ht-2.0.22/htpefimg.cc0000644000175000001440000001215411010143337011233 00000000000000/* * HT Editor * htpefimg.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "log.h" #include "formats.h" #include "htpal.h" #include "htpefimg.h" #include "strtools.h" #include "pef_analy.h" #include "pefstruc.h" #include "snprintf.h" ht_view *htpefimage_init(Bounds *b, File *file, ht_format_group *group) { ht_pef_shared_data *pef_shared=(ht_pef_shared_data *)group->get_shared_data(); String fn; LOG("%y: PEF: loading image (starting analyser)...", &file->getFilename(fn)); PEFAnalyser *p = new PEFAnalyser(); p->init(pef_shared, file); Bounds c=*b; ht_group *g=new ht_group(); g->init(&c, VO_RESIZE, DESC_PEF_IMAGE"-g"); AnalyInfoline *head; c.y+=2; c.h-=2; ht_pef_aviewer *v=new ht_pef_aviewer(); v->init(&c, DESC_PEF_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, p, pef_shared); c.y-=2; c.h=2; head=new AnalyInfoline(); head->init(&c, v, ANALY_STATUS_DEFAULT); v->attachInfoline(head); /* search for lowest/highest */ uint32 l=0xffffffff, h=0; PEF_SECTION_HEADER *s=pef_shared->sheaders.sheaders; for (uint i=0; isheaders.count; i++) { if (s->defaultAddress < l) l = s->defaultAddress; if ((s->defaultAddress + s->totalSize > h) && s->totalSize && pef_phys_and_mem_section(s)) h = s->defaultAddress + s->totalSize - 1; s++; } /**/ Address *low; Address *high; low = p->createAddress32(l); high = p->createAddress32(h); ht_analy_sub *analy=new ht_analy_sub(); analy->init(file, v, p, low, high); delete low; delete high; v->analy_sub = analy; v->insertsub(analy); v->sendmsg(msg_complete_init, 0); // Address *tmpaddr; // tmpaddr = p->createAddress32(pef_shared->pe32.header.entrypoint_address+pef_shared->pe32.header_nt.image_base); // v->gotoAddress(tmpaddr, NULL); // delete tmpaddr; g->insert(head); g->insert(v); g->setpalette(palkey_generic_window_default); // pef_shared->v_image=v; return g; } format_viewer_if htpefimage_if = { htpefimage_init, 0 }; /*static int pe_viewer_func_rva(eval_scalar *result, eval_int *i) { ht_pe_aviewer *aviewer = (ht_pe_aviewer*)eval_get_context(); RVA rva = QWORD_GET_INT(i->value); viewer_pos p; FileOfs ofs; if (pe_rva_to_ofs(&aviewer->pef_shared->sections, rva, &ofs) && aviewer->offset_to_pos(ofs, &p)) { Address *a; int b; aviewer->convertViewerPosToAddress(p, &a); a->putIntoArray((byte*)&b); delete a; scalar_create_int_c(result, b); return 1; } else { set_eval_error("invalid file offset or no corresponding RVA for '0%xh'", rva); } return 0; } static int pe_viewer_func_section_int(eval_scalar *result, eval_int *q) { ht_pe_aviewer *aviewer = (ht_pe_aviewer*)eval_get_context(); uint i = QWORD_GET_INT(q->value)-1; if (!QWORD_GET_HI(q->value) && (i >= 0) && (i < aviewer->pef_shared->sections.section_count)) { viewer_pos p; FileOfs ofs; if (pe_rva_to_ofs(&aviewer->pef_shared->sections, aviewer->pef_shared->sections.sections[i].data_address, &ofs) && aviewer->offset_to_pos(ofs, &p)) { Address *a; int b; aviewer->convertViewerPosToAddress(p, &a); a->putIntoArray((byte*)&b); delete a; scalar_create_int_c(result, b); return 1; } else { // set_eval_error("invalid file offset or no corresponding RVA for '0%xh'", rva); } } else { set_eval_error("no section number %qd", &q->value); } return 0; } static int pe_viewer_func_section_str(eval_scalar *result, eval_str *str) { ht_pe_aviewer *aviewer = (ht_pe_aviewer*)eval_get_context(); int section; char str2[COFF_SIZEOF_SHORT_NAME+1]; memset(str2, 0, COFF_SIZEOF_SHORT_NAME+1); memmove(str2, str->value, MIN(str->len, COFF_SIZEOF_SHORT_NAME)); if (pe_section_name_to_section(&aviewer->pef_shared->sections, str2, §ion)) { eval_scalar i; scalar_create_int_c(&i, section+1); return pe_viewer_func_section_int(result, &i.scalar.integer); } return 0; } static int pe_viewer_func_section(eval_scalar *result, eval_scalar *q) { if (q->type == SCALAR_STR) return pe_viewer_func_section_str(result, &q->scalar.str); else { eval_int i; scalar_context_int(q, &i); return pe_viewer_func_section_int(result, &i); } }*/ /* * CLASS ht_pef_aviewer */ void ht_pef_aviewer::init(Bounds *b, const char *desc, int caps, File *File, ht_format_group *format_group, Analyser *Analy, ht_pef_shared_data *PEF_shared) { ht_aviewer::init(b, desc, caps, File, format_group, Analy); pef_shared = PEF_shared; } void ht_pef_aviewer::setAnalyser(Analyser *a) { ((PEFAnalyser *)a)->pef_shared = pef_shared; ((PEFAnalyser *)a)->file = file; analy = a; analy_sub->setAnalyser(a); } ht-2.0.22/htelfimg.h0000644000175000001440000000226310615341616011103 00000000000000/* * HT Editor * htelfimg.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTELFIMG_H__ #define __HTELFIMG_H__ #include "htanaly.h" #include "htelf.h" #include "formats.h" extern format_viewer_if htelfimage_if; /* * CLASS ht_elf_aviewer */ class ht_elf_aviewer: public ht_aviewer { public: ht_elf_shared_data *elf_shared; void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Analyser *Analyser, ht_elf_shared_data *elf_shared); virtual void setAnalyser(Analyser *a); }; #endif /* !__HTELFIMG_H__ */ ht-2.0.22/config.h0000644000175000017500000000574112127651431010560 00000000000000/* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.in by autoheader. */ /* This system provides ncurses.h */ #define CURSES_HDR /* Define to 1 if you have the `acosh' function. */ /* #undef HAVE_ACOSH */ /* Define to 1 if you have the `asinh' function. */ /* #undef HAVE_ASINH */ /* Define to 1 if you have the `atanh' function. */ /* #undef HAVE_ATANH */ /* Define to 1 if you have the header file. */ /* #undef HAVE_CURSES_H */ /* Define to 1 if you have the header file. */ /* #undef HAVE_INTTYPES_H */ /* Define to 1 if you have the header file. */ /* #undef HAVE_LZO1X_H */ /* Define to 1 if you have the header file. */ #define HAVE_LZO_LZO1X_H 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_MEMORY_H */ /* Define to 1 if you have the header file. */ /* #undef HAVE_NCURSES_H */ /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_STRINGS_H */ /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_SYS_STAT_H */ /* Define to 1 if you have the header file. */ /* #undef HAVE_SYS_TYPES_H */ /* This system has Xlib support and we shall use it */ #define HAVE_TEXTMODE_X11 1 /* Define to 1 if you have the header file. */ /* #undef HAVE_UNISTD_H */ /* Name of package */ #define PACKAGE "ht" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "https://sourceforge.net/tracker/?group_id=1066" /* Define to the full name of this package. */ #define PACKAGE_NAME "ht" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "ht 2.0.22" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "ht" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "2.0.22" /* The size of `char', as computed by sizeof. */ #define SIZEOF_CHAR 1 /* The size of `int', as computed by sizeof. */ #define SIZEOF_INT 4 /* The size of `long int', as computed by sizeof. */ #define SIZEOF_LONG_INT 8 /* The size of `short', as computed by sizeof. */ #define SIZEOF_SHORT 2 /* Define to 1 if you have the ANSI C header files. */ /* #undef STDC_HEADERS */ /* Location of io/$IO_DIR/types.h */ #define SYSTEM_OSAPI_SPECIFIC_TYPES_HDR "io/posix/types.h" /* whether to use the included minilzo */ /* #undef USE_MINILZO */ /* Version number of package */ #define VERSION "2.0.22" /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a `char[]'. */ #define YYTEXT_POINTER 1 /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ ht-2.0.22/lestruct.cc0000644000175000001440000001147110615341624011307 00000000000000/* * HT Editor * lestruct.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "lestruct.h" #include "endianess.h" byte LE_HEADER_struct[] = { STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, 0 }; byte LE_FIXUP_struct[] = { STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, 0 }; byte LE_ENTRYPOINT16_struct[] = { STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, 0 }; byte LE_ENTRYPOINT32_struct[] = { STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte LE_VXD_DESCRIPTOR_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; byte LE_FIXUP_INTERNAL_struct[] = { STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, 0 }; byte LE_OBJECT_HEADER_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, 0 }; byte LE_PAGE_MAP_ENTRY_struct[] = { STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, 0 }; byte LE_FIXUP_INTERNAL16_struct[] = { STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, 0 }; byte LE_FIXUP_INTERNAL32_struct[] = { STRUCT_ENDIAN_8 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; ht-2.0.22/minilzo/0000755000175000017500000000000012156433676010707 500000000000000ht-2.0.22/minilzo/minilzo.h0000644000175000001440000000664511006065547012457 00000000000000/* minilzo.h -- mini subset of the LZO real-time data compression library This file is part of the LZO real-time data compression library. Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. The LZO library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The LZO library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the LZO library; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Markus F.X.J. Oberhumer http://www.oberhumer.com/opensource/lzo/ */ /* * NOTE: * the full LZO package can be found at * http://www.oberhumer.com/opensource/lzo/ */ #ifndef __MINILZO_H #define __MINILZO_H #define MINILZO_VERSION 0x2030 #ifdef __LZOCONF_H # error "you cannot use both LZO and miniLZO" #endif #undef LZO_HAVE_CONFIG_H #include "lzoconf.h" #if !defined(LZO_VERSION) || (LZO_VERSION != MINILZO_VERSION) # error "version mismatch in header files" #endif #ifdef __cplusplus extern "C" { #endif /*********************************************************************** // ************************************************************************/ /* Memory required for the wrkmem parameter. * When the required size is 0, you can also pass a NULL pointer. */ #define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS #define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) #define LZO1X_MEM_DECOMPRESS (0) /* compression */ LZO_EXTERN(int) lzo1x_1_compress ( const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem ); /* decompression */ LZO_EXTERN(int) lzo1x_decompress ( const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem /* NOT USED */ ); /* safe decompression with overrun testing */ LZO_EXTERN(int) lzo1x_decompress_safe ( const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem /* NOT USED */ ); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* already included */ ht-2.0.22/minilzo/minilzo.c0000644000175000001440000036377111075145726012464 00000000000000/* minilzo.c -- mini subset of the LZO real-time data compression library This file is part of the LZO real-time data compression library. Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. The LZO library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The LZO library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the LZO library; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Markus F.X.J. Oberhumer http://www.oberhumer.com/opensource/lzo/ */ /* * NOTE: * the full LZO package can be found at * http://www.oberhumer.com/opensource/lzo/ */ #define __LZO_IN_MINILZO #define LZO_BUILD #if defined(LZO_CFG_FREESTANDING) # undef MINILZO_HAVE_CONFIG_H # define LZO_LIBC_FREESTANDING 1 # define LZO_OS_FREESTANDING 1 #endif #ifdef MINILZO_HAVE_CONFIG_H # include #endif #include #include #if defined(MINILZO_CFG_USE_INTERNAL_LZODEFS) #ifndef __LZODEFS_H_INCLUDED #define __LZODEFS_H_INCLUDED 1 #if defined(__CYGWIN32__) && !defined(__CYGWIN__) # define __CYGWIN__ __CYGWIN32__ #endif #if defined(__IBMCPP__) && !defined(__IBMC__) # define __IBMC__ __IBMCPP__ #endif #if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) # define __INTEL_COMPILER __ICL #endif #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) # define _ALL_SOURCE 1 #endif #if defined(__mips__) && defined(__R5900__) # if !defined(__LONG_MAX__) # define __LONG_MAX__ 9223372036854775807L # endif #endif #if defined(__INTEL_COMPILER) && defined(__linux__) # pragma warning(disable: 193) #endif #if defined(__KEIL__) && defined(__C166__) # pragma warning disable = 322 #elif 0 && defined(__C251__) # pragma warning disable = 322 #endif #if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) # if (_MSC_VER >= 1300) # pragma warning(disable: 4668) # endif #endif #if 0 && defined(__WATCOMC__) # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) # pragma warning 203 9 # endif #endif #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) # pragma option -h #endif #if 0 #define LZO_0xffffL 0xfffful #define LZO_0xffffffffL 0xfffffffful #else #define LZO_0xffffL 65535ul #define LZO_0xffffffffL 4294967295ul #endif #if (LZO_0xffffL == LZO_0xffffffffL) # error "your preprocessor is broken 1" #endif #if (16ul * 16384ul != 262144ul) # error "your preprocessor is broken 2" #endif #if 0 #if (32767 >= 4294967295ul) # error "your preprocessor is broken 3" #endif #if (65535u >= 4294967295ul) # error "your preprocessor is broken 4" #endif #endif #if (UINT_MAX == LZO_0xffffL) #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) # if !defined(MSDOS) # define MSDOS 1 # endif # if !defined(_MSDOS) # define _MSDOS 1 # endif #elif 0 && defined(__VERSION) && defined(MB_LEN_MAX) # if (__VERSION == 520) && (MB_LEN_MAX == 1) # if !defined(__AZTEC_C__) # define __AZTEC_C__ __VERSION # endif # if !defined(__DOS__) # define __DOS__ 1 # endif # endif #endif #endif #if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL) # define ptrdiff_t long # define _PTRDIFF_T_DEFINED #endif #if (UINT_MAX == LZO_0xffffL) # undef __LZO_RENAME_A # undef __LZO_RENAME_B # if defined(__AZTEC_C__) && defined(__DOS__) # define __LZO_RENAME_A 1 # elif defined(_MSC_VER) && defined(MSDOS) # if (_MSC_VER < 600) # define __LZO_RENAME_A 1 # elif (_MSC_VER < 700) # define __LZO_RENAME_B 1 # endif # elif defined(__TSC__) && defined(__OS2__) # define __LZO_RENAME_A 1 # elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410) # define __LZO_RENAME_A 1 # elif defined(__PACIFIC__) && defined(DOS) # if !defined(__far) # define __far far # endif # if !defined(__near) # define __near near # endif # endif # if defined(__LZO_RENAME_A) # if !defined(__cdecl) # define __cdecl cdecl # endif # if !defined(__far) # define __far far # endif # if !defined(__huge) # define __huge huge # endif # if !defined(__near) # define __near near # endif # if !defined(__pascal) # define __pascal pascal # endif # if !defined(__huge) # define __huge huge # endif # elif defined(__LZO_RENAME_B) # if !defined(__cdecl) # define __cdecl _cdecl # endif # if !defined(__far) # define __far _far # endif # if !defined(__huge) # define __huge _huge # endif # if !defined(__near) # define __near _near # endif # if !defined(__pascal) # define __pascal _pascal # endif # elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) # if !defined(__cdecl) # define __cdecl cdecl # endif # if !defined(__pascal) # define __pascal pascal # endif # endif # undef __LZO_RENAME_A # undef __LZO_RENAME_B #endif #if (UINT_MAX == LZO_0xffffL) #if defined(__AZTEC_C__) && defined(__DOS__) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 #elif defined(_MSC_VER) && defined(MSDOS) # if (_MSC_VER < 600) # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 # endif # if (_MSC_VER < 700) # define LZO_BROKEN_INTEGRAL_PROMOTION 1 # define LZO_BROKEN_SIZEOF 1 # endif #elif defined(__PACIFIC__) && defined(DOS) # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 #elif defined(__TURBOC__) && defined(__MSDOS__) # if (__TURBOC__ < 0x0150) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 # define LZO_BROKEN_INTEGRAL_PROMOTION 1 # endif # if (__TURBOC__ < 0x0200) # define LZO_BROKEN_SIZEOF 1 # endif # if (__TURBOC__ < 0x0400) && defined(__cplusplus) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 # endif #elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 # define LZO_BROKEN_SIZEOF 1 #endif #endif #if defined(__WATCOMC__) && (__WATCOMC__ < 900) # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 #endif #if defined(_CRAY) && defined(_CRAY1) # define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1 #endif #define LZO_PP_STRINGIZE(x) #x #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) #define LZO_PP_CONCAT2(a,b) a ## b #define LZO_PP_CONCAT3(a,b,c) a ## b ## c #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) #if 1 #define LZO_CPP_STRINGIZE(x) #x #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) #define LZO_CPP_CONCAT2(a,b) a ## b #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) #endif #define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) #if 1 && defined(__cplusplus) # if !defined(__STDC_CONSTANT_MACROS) # define __STDC_CONSTANT_MACROS 1 # endif # if !defined(__STDC_LIMIT_MACROS) # define __STDC_LIMIT_MACROS 1 # endif #endif #if defined(__cplusplus) # define LZO_EXTERN_C extern "C" #else # define LZO_EXTERN_C extern #endif #if !defined(__LZO_OS_OVERRIDE) #if defined(LZO_OS_FREESTANDING) # define LZO_INFO_OS "freestanding" #elif defined(LZO_OS_EMBEDDED) # define LZO_INFO_OS "embedded" #elif 1 && defined(__IAR_SYSTEMS_ICC__) # define LZO_OS_EMBEDDED 1 # define LZO_INFO_OS "embedded" #elif defined(__CYGWIN__) && defined(__GNUC__) # define LZO_OS_CYGWIN 1 # define LZO_INFO_OS "cygwin" #elif defined(__EMX__) && defined(__GNUC__) # define LZO_OS_EMX 1 # define LZO_INFO_OS "emx" #elif defined(__BEOS__) # define LZO_OS_BEOS 1 # define LZO_INFO_OS "beos" #elif defined(__Lynx__) # define LZO_OS_LYNXOS 1 # define LZO_INFO_OS "lynxos" #elif defined(__OS400__) # define LZO_OS_OS400 1 # define LZO_INFO_OS "os400" #elif defined(__QNX__) # define LZO_OS_QNX 1 # define LZO_INFO_OS "qnx" #elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" #elif defined(__BORLANDC__) && defined(__DPMI16__) # define LZO_OS_DOS16 1 # define LZO_INFO_OS "dos16" #elif defined(__ZTC__) && defined(DOS386) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" #elif defined(__OS2__) || defined(__OS2V2__) # if (UINT_MAX == LZO_0xffffL) # define LZO_OS_OS216 1 # define LZO_INFO_OS "os216" # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_OS2 1 # define LZO_INFO_OS "os2" # else # error "check your limits.h header" # endif #elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64) # define LZO_OS_WIN64 1 # define LZO_INFO_OS "win64" #elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" #elif defined(__MWERKS__) && defined(__INTEL__) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" #elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) # if (UINT_MAX == LZO_0xffffL) # define LZO_OS_WIN16 1 # define LZO_INFO_OS "win16" # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" # else # error "check your limits.h header" # endif #elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS)) # if (UINT_MAX == LZO_0xffffL) # define LZO_OS_DOS16 1 # define LZO_INFO_OS "dos16" # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" # else # error "check your limits.h header" # endif #elif defined(__WATCOMC__) # if defined(__NT__) && (UINT_MAX == LZO_0xffffL) # define LZO_OS_DOS16 1 # define LZO_INFO_OS "dos16" # elif defined(__NT__) && (__WATCOMC__ < 1100) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" # elif defined(__linux__) || defined(__LINUX__) # define LZO_OS_POSIX 1 # define LZO_INFO_OS "posix" # else # error "please specify a target using the -bt compiler option" # endif #elif defined(__palmos__) # define LZO_OS_PALMOS 1 # define LZO_INFO_OS "palmos" #elif defined(__TOS__) || defined(__atarist__) # define LZO_OS_TOS 1 # define LZO_INFO_OS "tos" #elif defined(macintosh) && !defined(__ppc__) # define LZO_OS_MACCLASSIC 1 # define LZO_INFO_OS "macclassic" #elif defined(__VMS) # define LZO_OS_VMS 1 # define LZO_INFO_OS "vms" #elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) # define LZO_OS_CONSOLE 1 # define LZO_OS_CONSOLE_PS2 1 # define LZO_INFO_OS "console" # define LZO_INFO_OS_CONSOLE "ps2" #elif (defined(__mips__) && defined(__psp__)) # define LZO_OS_CONSOLE 1 # define LZO_OS_CONSOLE_PSP 1 # define LZO_INFO_OS "console" # define LZO_INFO_OS_CONSOLE "psp" #else # define LZO_OS_POSIX 1 # define LZO_INFO_OS "posix" #endif #if (LZO_OS_POSIX) # if defined(_AIX) || defined(__AIX__) || defined(__aix__) # define LZO_OS_POSIX_AIX 1 # define LZO_INFO_OS_POSIX "aix" # elif defined(__FreeBSD__) # define LZO_OS_POSIX_FREEBSD 1 # define LZO_INFO_OS_POSIX "freebsd" # elif defined(__hpux__) || defined(__hpux) # define LZO_OS_POSIX_HPUX 1 # define LZO_INFO_OS_POSIX "hpux" # elif defined(__INTERIX) # define LZO_OS_POSIX_INTERIX 1 # define LZO_INFO_OS_POSIX "interix" # elif defined(__IRIX__) || defined(__irix__) # define LZO_OS_POSIX_IRIX 1 # define LZO_INFO_OS_POSIX "irix" # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) # define LZO_OS_POSIX_LINUX 1 # define LZO_INFO_OS_POSIX "linux" # elif defined(__APPLE__) || defined(__MACOS__) # define LZO_OS_POSIX_MACOSX 1 # define LZO_INFO_OS_POSIX "macosx" # elif defined(__minix__) || defined(__minix) # define LZO_OS_POSIX_MINIX 1 # define LZO_INFO_OS_POSIX "minix" # elif defined(__NetBSD__) # define LZO_OS_POSIX_NETBSD 1 # define LZO_INFO_OS_POSIX "netbsd" # elif defined(__OpenBSD__) # define LZO_OS_POSIX_OPENBSD 1 # define LZO_INFO_OS_POSIX "openbsd" # elif defined(__osf__) # define LZO_OS_POSIX_OSF 1 # define LZO_INFO_OS_POSIX "osf" # elif defined(__solaris__) || defined(__sun) # if defined(__SVR4) || defined(__svr4__) # define LZO_OS_POSIX_SOLARIS 1 # define LZO_INFO_OS_POSIX "solaris" # else # define LZO_OS_POSIX_SUNOS 1 # define LZO_INFO_OS_POSIX "sunos" # endif # elif defined(__ultrix__) || defined(__ultrix) # define LZO_OS_POSIX_ULTRIX 1 # define LZO_INFO_OS_POSIX "ultrix" # elif defined(_UNICOS) # define LZO_OS_POSIX_UNICOS 1 # define LZO_INFO_OS_POSIX "unicos" # else # define LZO_OS_POSIX_UNKNOWN 1 # define LZO_INFO_OS_POSIX "unknown" # endif #endif #endif #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # if (UINT_MAX != LZO_0xffffL) # error "this should not happen" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "this should not happen" # endif #endif #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) # if (UINT_MAX != LZO_0xffffffffL) # error "this should not happen" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "this should not happen" # endif #endif #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) # define LZO_CC_CILLY 1 # define LZO_INFO_CC "Cilly" # if defined(__CILLY__) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__) # else # define LZO_INFO_CCVER "unknown" # endif #elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__) # define LZO_CC_SDCC 1 # define LZO_INFO_CC "sdcc" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) # define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) # define LZO_INFO_CC "Pathscale C" # define LZO_INFO_CCVER __PATHSCALE__ #elif defined(__INTEL_COMPILER) # define LZO_CC_INTELC 1 # define LZO_INFO_CC "Intel C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) # if defined(_WIN32) || defined(_WIN64) # define LZO_CC_SYNTAX_MSC 1 # else # define LZO_CC_SYNTAX_GNUC 1 # endif #elif defined(__POCC__) && defined(_WIN32) # define LZO_CC_PELLESC 1 # define LZO_INFO_CC "Pelles C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) #elif defined(__llvm__) && defined(__GNUC__) && defined(__VERSION__) # if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) # define LZO_CC_LLVM (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) # else # define LZO_CC_LLVM (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) # endif # define LZO_INFO_CC "llvm-gcc" # define LZO_INFO_CCVER __VERSION__ #elif defined(__GNUC__) && defined(__VERSION__) # if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) # define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) # elif defined(__GNUC_MINOR__) # define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) # else # define LZO_CC_GNUC (__GNUC__ * 0x10000L) # endif # define LZO_INFO_CC "gcc" # define LZO_INFO_CCVER __VERSION__ #elif defined(__ACK__) && defined(_ACK) # define LZO_CC_ACK 1 # define LZO_INFO_CC "Amsterdam Compiler Kit C" # define LZO_INFO_CCVER "unknown" #elif defined(__AZTEC_C__) # define LZO_CC_AZTECC 1 # define LZO_INFO_CC "Aztec C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__) #elif defined(__BORLANDC__) # define LZO_CC_BORLANDC 1 # define LZO_INFO_CC "Borland C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__) #elif defined(_CRAYC) && defined(_RELEASE) # define LZO_CC_CRAYC 1 # define LZO_INFO_CC "Cray C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE) #elif defined(__DMC__) && defined(__SC__) # define LZO_CC_DMC 1 # define LZO_INFO_CC "Digital Mars C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__) #elif defined(__DECC) # define LZO_CC_DECC 1 # define LZO_INFO_CC "DEC C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) #elif defined(__HIGHC__) # define LZO_CC_HIGHC 1 # define LZO_INFO_CC "MetaWare High C" # define LZO_INFO_CCVER "unknown" #elif defined(__IAR_SYSTEMS_ICC__) # define LZO_CC_IARC 1 # define LZO_INFO_CC "IAR C" # if defined(__VER__) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__) # else # define LZO_INFO_CCVER "unknown" # endif #elif defined(__IBMC__) # define LZO_CC_IBMC 1 # define LZO_INFO_CC "IBM C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) #elif defined(__KEIL__) && defined(__C166__) # define LZO_CC_KEILC 1 # define LZO_INFO_CC "Keil C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__) #elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL) # define LZO_CC_LCCWIN32 1 # define LZO_INFO_CC "lcc-win32" # define LZO_INFO_CCVER "unknown" #elif defined(__LCC__) # define LZO_CC_LCC 1 # define LZO_INFO_CC "lcc" # if defined(__LCC_VERSION__) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__) # else # define LZO_INFO_CCVER "unknown" # endif #elif defined(_MSC_VER) # define LZO_CC_MSC 1 # define LZO_INFO_CC "Microsoft C" # if defined(_MSC_FULL_VER) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) # else # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) # endif #elif defined(__MWERKS__) # define LZO_CC_MWERKS 1 # define LZO_INFO_CC "Metrowerks C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) # define LZO_CC_NDPC 1 # define LZO_INFO_CC "Microway NDP C" # define LZO_INFO_CCVER "unknown" #elif defined(__PACIFIC__) # define LZO_CC_PACIFICC 1 # define LZO_INFO_CC "Pacific C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) # define LZO_CC_PGI 1 # define LZO_INFO_CC "Portland Group PGI C" # define LZO_INFO_CCVER "unknown" #elif defined(__PUREC__) && defined(__TOS__) # define LZO_CC_PUREC 1 # define LZO_INFO_CC "Pure C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__) #elif defined(__SC__) && defined(__ZTC__) # define LZO_CC_SYMANTECC 1 # define LZO_INFO_CC "Symantec C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) #elif defined(__SUNPRO_C) # define LZO_INFO_CC "SunPro C" # if ((__SUNPRO_C)+0 > 0) # define LZO_CC_SUNPROC __SUNPRO_C # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) # else # define LZO_CC_SUNPROC 1 # define LZO_INFO_CCVER "unknown" # endif #elif defined(__SUNPRO_CC) # define LZO_INFO_CC "SunPro C" # if ((__SUNPRO_CC)+0 > 0) # define LZO_CC_SUNPROC __SUNPRO_CC # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) # else # define LZO_CC_SUNPROC 1 # define LZO_INFO_CCVER "unknown" # endif #elif defined(__TINYC__) # define LZO_CC_TINYC 1 # define LZO_INFO_CC "Tiny C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__) #elif defined(__TSC__) # define LZO_CC_TOPSPEEDC 1 # define LZO_INFO_CC "TopSpeed C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__) #elif defined(__WATCOMC__) # define LZO_CC_WATCOMC 1 # define LZO_INFO_CC "Watcom C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__) #elif defined(__TURBOC__) # define LZO_CC_TURBOC 1 # define LZO_INFO_CC "Turbo C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__) #elif defined(__ZTC__) # define LZO_CC_ZORTECHC 1 # define LZO_INFO_CC "Zortech C" # if (__ZTC__ == 0x310) # define LZO_INFO_CCVER "0x310" # else # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) # endif #else # define LZO_CC_UNKNOWN 1 # define LZO_INFO_CC "unknown" # define LZO_INFO_CCVER "unknown" #endif #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" #endif #if !defined(__LZO_ARCH_OVERRIDE) && !defined(LZO_ARCH_GENERIC) && defined(_CRAY) # if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY) # if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E) # define LZO_ARCH_CRAY_MPP 1 # elif defined(_CRAY1) # define LZO_ARCH_CRAY_PVP 1 # endif # endif #endif #if !defined(__LZO_ARCH_OVERRIDE) #if defined(LZO_ARCH_GENERIC) # define LZO_INFO_ARCH "generic" #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # define LZO_ARCH_I086 1 # define LZO_ARCH_IA16 1 # define LZO_INFO_ARCH "i086" #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) # define LZO_ARCH_ALPHA 1 # define LZO_INFO_ARCH "alpha" #elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E)) # define LZO_ARCH_ALPHA 1 # define LZO_INFO_ARCH "alpha" #elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64) # define LZO_ARCH_AMD64 1 # define LZO_INFO_ARCH "amd64" #elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB)) # define LZO_ARCH_ARM 1 # define LZO_ARCH_ARM_THUMB 1 # define LZO_INFO_ARCH "arm_thumb" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) # define LZO_ARCH_ARM 1 # if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) # define LZO_ARCH_ARM_THUMB 1 # define LZO_INFO_ARCH "arm_thumb" # elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) # define LZO_INFO_ARCH "arm" # else # define LZO_INFO_ARCH "arm" # endif #elif defined(__arm__) || defined(_M_ARM) # define LZO_ARCH_ARM 1 # define LZO_INFO_ARCH "arm" #elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__) # define LZO_ARCH_AVR 1 # define LZO_INFO_ARCH "avr" #elif defined(__bfin__) # define LZO_ARCH_BLACKFIN 1 # define LZO_INFO_ARCH "blackfin" #elif (UINT_MAX == LZO_0xffffL) && defined(__C166__) # define LZO_ARCH_C166 1 # define LZO_INFO_ARCH "c166" #elif defined(__cris__) # define LZO_ARCH_CRIS 1 # define LZO_INFO_ARCH "cris" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__) # define LZO_ARCH_EZ80 1 # define LZO_INFO_ARCH "ez80" #elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) # define LZO_ARCH_H8300 1 # define LZO_INFO_ARCH "h8300" #elif defined(__hppa__) || defined(__hppa) # define LZO_ARCH_HPPA 1 # define LZO_INFO_ARCH "hppa" #elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386) # define LZO_ARCH_I386 1 # define LZO_ARCH_IA32 1 # define LZO_INFO_ARCH "i386" #elif (LZO_CC_ZORTECHC && defined(__I86__)) # define LZO_ARCH_I386 1 # define LZO_ARCH_IA32 1 # define LZO_INFO_ARCH "i386" #elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386) # define LZO_ARCH_I386 1 # define LZO_ARCH_IA32 1 # define LZO_INFO_ARCH "i386" #elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64) # define LZO_ARCH_IA64 1 # define LZO_INFO_ARCH "ia64" #elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__) # define LZO_ARCH_M16C 1 # define LZO_INFO_ARCH "m16c" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__) # define LZO_ARCH_M16C 1 # define LZO_INFO_ARCH "m16c" #elif defined(__m32r__) # define LZO_ARCH_M32R 1 # define LZO_INFO_ARCH "m32r" #elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K) # define LZO_ARCH_M68K 1 # define LZO_INFO_ARCH "m68k" #elif (UINT_MAX == LZO_0xffffL) && defined(__C251__) # define LZO_ARCH_MCS251 1 # define LZO_INFO_ARCH "mcs251" #elif (UINT_MAX == LZO_0xffffL) && defined(__C51__) # define LZO_ARCH_MCS51 1 # define LZO_INFO_ARCH "mcs51" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__) # define LZO_ARCH_MCS51 1 # define LZO_INFO_ARCH "mcs51" #elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000) # define LZO_ARCH_MIPS 1 # define LZO_INFO_ARCH "mips" #elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__) # define LZO_ARCH_MSP430 1 # define LZO_INFO_ARCH "msp430" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__) # define LZO_ARCH_MSP430 1 # define LZO_INFO_ARCH "msp430" #elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR) # define LZO_ARCH_POWERPC 1 # define LZO_INFO_ARCH "powerpc" #elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x) # define LZO_ARCH_S390 1 # define LZO_INFO_ARCH "s390" #elif defined(__sh__) || defined(_M_SH) # define LZO_ARCH_SH 1 # define LZO_INFO_ARCH "sh" #elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8) # define LZO_ARCH_SPARC 1 # define LZO_INFO_ARCH "sparc" #elif defined(__SPU__) # define LZO_ARCH_SPU 1 # define LZO_INFO_ARCH "spu" #elif (UINT_MAX == LZO_0xffffL) && defined(__z80) # define LZO_ARCH_Z80 1 # define LZO_INFO_ARCH "z80" #elif (LZO_ARCH_CRAY_PVP) # if defined(_CRAYSV1) # define LZO_ARCH_CRAY_SV1 1 # define LZO_INFO_ARCH "cray_sv1" # elif (_ADDR64) # define LZO_ARCH_CRAY_T90 1 # define LZO_INFO_ARCH "cray_t90" # elif (_ADDR32) # define LZO_ARCH_CRAY_YMP 1 # define LZO_INFO_ARCH "cray_ymp" # else # define LZO_ARCH_CRAY_XMP 1 # define LZO_INFO_ARCH "cray_xmp" # endif #else # define LZO_ARCH_UNKNOWN 1 # define LZO_INFO_ARCH "unknown" #endif #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2) # error "FIXME - missing define for CPU architecture" #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) # error "FIXME - missing WIN32 define for CPU architecture" #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) # error "FIXME - missing WIN64 define for CPU architecture" #endif #if (LZO_OS_OS216 || LZO_OS_WIN16) # define LZO_ARCH_I086PM 1 # define LZO_ARCH_IA16PM 1 #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) # define LZO_ARCH_I086PM 1 # define LZO_ARCH_IA16PM 1 #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) # define LZO_ARCH_I086PM 1 # define LZO_ARCH_IA16PM 1 #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) # define LZO_ARCH_I086PM 1 # define LZO_ARCH_IA16PM 1 #endif #if defined(LZO_ARCH_ARM_THUMB) && !defined(LZO_ARCH_ARM) # error "this should not happen" #endif #if defined(LZO_ARCH_I086PM) && !defined(LZO_ARCH_I086) # error "this should not happen" #endif #if (LZO_ARCH_I086) # if (UINT_MAX != LZO_0xffffL) # error "this should not happen" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "this should not happen" # endif #endif #if (LZO_ARCH_I386) # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) # error "this should not happen" # endif # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) # error "this should not happen" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "this should not happen" # endif #endif #if !defined(__LZO_MM_OVERRIDE) #if (LZO_ARCH_I086) #if (UINT_MAX != LZO_0xffffL) # error "this should not happen" #endif #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) # define LZO_MM_TINY 1 #elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM) # define LZO_MM_HUGE 1 #elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL) # define LZO_MM_SMALL 1 #elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM) # define LZO_MM_MEDIUM 1 #elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM) # define LZO_MM_COMPACT 1 #elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL) # define LZO_MM_LARGE 1 #elif (LZO_CC_AZTECC) # if defined(_LARGE_CODE) && defined(_LARGE_DATA) # define LZO_MM_LARGE 1 # elif defined(_LARGE_CODE) # define LZO_MM_MEDIUM 1 # elif defined(_LARGE_DATA) # define LZO_MM_COMPACT 1 # else # define LZO_MM_SMALL 1 # endif #elif (LZO_CC_ZORTECHC && defined(__VCM__)) # define LZO_MM_LARGE 1 #else # error "unknown memory model" #endif #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) #define LZO_HAVE_MM_HUGE_PTR 1 #define LZO_HAVE_MM_HUGE_ARRAY 1 #if (LZO_MM_TINY) # undef LZO_HAVE_MM_HUGE_ARRAY #endif #if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC) # undef LZO_HAVE_MM_HUGE_PTR # undef LZO_HAVE_MM_HUGE_ARRAY #elif (LZO_CC_DMC || LZO_CC_SYMANTECC) # undef LZO_HAVE_MM_HUGE_ARRAY #elif (LZO_CC_MSC && defined(_QC)) # undef LZO_HAVE_MM_HUGE_ARRAY # if (_MSC_VER < 600) # undef LZO_HAVE_MM_HUGE_PTR # endif #elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295)) # undef LZO_HAVE_MM_HUGE_ARRAY #endif #if (LZO_ARCH_I086PM) && !defined(LZO_HAVE_MM_HUGE_PTR) # if (LZO_OS_DOS16) # error "this should not happen" # elif (LZO_CC_ZORTECHC) # else # error "this should not happen" # endif #endif #ifdef __cplusplus extern "C" { #endif #if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200)) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295)) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16) # define LZO_MM_AHSHIFT 12 #elif (LZO_CC_WATCOMC) extern unsigned char _HShift; # define LZO_MM_AHSHIFT ((unsigned) _HShift) #else # error "FIXME - implement LZO_MM_AHSHIFT" #endif #ifdef __cplusplus } #endif #endif #elif (LZO_ARCH_C166) #if !defined(__MODEL__) # error "FIXME - C166 __MODEL__" #elif ((__MODEL__) == 0) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 1) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) # define LZO_MM_LARGE 1 #elif ((__MODEL__) == 3) # define LZO_MM_TINY 1 #elif ((__MODEL__) == 4) # define LZO_MM_XTINY 1 #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else # error "FIXME - C166 __MODEL__" #endif #elif (LZO_ARCH_MCS251) #if !defined(__MODEL__) # error "FIXME - MCS251 __MODEL__" #elif ((__MODEL__) == 0) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) # define LZO_MM_LARGE 1 #elif ((__MODEL__) == 3) # define LZO_MM_TINY 1 #elif ((__MODEL__) == 4) # define LZO_MM_XTINY 1 #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else # error "FIXME - MCS251 __MODEL__" #endif #elif (LZO_ARCH_MCS51) #if !defined(__MODEL__) # error "FIXME - MCS51 __MODEL__" #elif ((__MODEL__) == 1) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) # define LZO_MM_LARGE 1 #elif ((__MODEL__) == 3) # define LZO_MM_TINY 1 #elif ((__MODEL__) == 4) # define LZO_MM_XTINY 1 #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else # error "FIXME - MCS51 __MODEL__" #endif #elif (LZO_ARCH_CRAY_PVP) # define LZO_MM_PVP 1 #else # define LZO_MM_FLAT 1 #endif #if (LZO_MM_COMPACT) # define LZO_INFO_MM "compact" #elif (LZO_MM_FLAT) # define LZO_INFO_MM "flat" #elif (LZO_MM_HUGE) # define LZO_INFO_MM "huge" #elif (LZO_MM_LARGE) # define LZO_INFO_MM "large" #elif (LZO_MM_MEDIUM) # define LZO_INFO_MM "medium" #elif (LZO_MM_PVP) # define LZO_INFO_MM "pvp" #elif (LZO_MM_SMALL) # define LZO_INFO_MM "small" #elif (LZO_MM_TINY) # define LZO_INFO_MM "tiny" #else # error "unknown memory model" #endif #endif #if defined(SIZEOF_SHORT) # define LZO_SIZEOF_SHORT (SIZEOF_SHORT) #endif #if defined(SIZEOF_INT) # define LZO_SIZEOF_INT (SIZEOF_INT) #endif #if defined(SIZEOF_LONG) # define LZO_SIZEOF_LONG (SIZEOF_LONG) #endif #if defined(SIZEOF_LONG_LONG) # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) #endif #if defined(SIZEOF___INT16) # define LZO_SIZEOF___INT16 (SIZEOF___INT16) #endif #if defined(SIZEOF___INT32) # define LZO_SIZEOF___INT32 (SIZEOF___INT32) #endif #if defined(SIZEOF___INT64) # define LZO_SIZEOF___INT64 (SIZEOF___INT64) #endif #if defined(SIZEOF_VOID_P) # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) #endif #if defined(SIZEOF_SIZE_T) # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) #endif #if defined(SIZEOF_PTRDIFF_T) # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) #endif #define __LZO_LSR(x,b) (((x)+0ul) >> (b)) #if !defined(LZO_SIZEOF_SHORT) # if (LZO_ARCH_CRAY_PVP) # define LZO_SIZEOF_SHORT 8 # elif (USHRT_MAX == LZO_0xffffL) # define LZO_SIZEOF_SHORT 2 # elif (__LZO_LSR(USHRT_MAX,7) == 1) # define LZO_SIZEOF_SHORT 1 # elif (__LZO_LSR(USHRT_MAX,15) == 1) # define LZO_SIZEOF_SHORT 2 # elif (__LZO_LSR(USHRT_MAX,31) == 1) # define LZO_SIZEOF_SHORT 4 # elif (__LZO_LSR(USHRT_MAX,63) == 1) # define LZO_SIZEOF_SHORT 8 # elif (__LZO_LSR(USHRT_MAX,127) == 1) # define LZO_SIZEOF_SHORT 16 # else # error "LZO_SIZEOF_SHORT" # endif #endif #if !defined(LZO_SIZEOF_INT) # if (LZO_ARCH_CRAY_PVP) # define LZO_SIZEOF_INT 8 # elif (UINT_MAX == LZO_0xffffL) # define LZO_SIZEOF_INT 2 # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_SIZEOF_INT 4 # elif (__LZO_LSR(UINT_MAX,7) == 1) # define LZO_SIZEOF_INT 1 # elif (__LZO_LSR(UINT_MAX,15) == 1) # define LZO_SIZEOF_INT 2 # elif (__LZO_LSR(UINT_MAX,31) == 1) # define LZO_SIZEOF_INT 4 # elif (__LZO_LSR(UINT_MAX,63) == 1) # define LZO_SIZEOF_INT 8 # elif (__LZO_LSR(UINT_MAX,127) == 1) # define LZO_SIZEOF_INT 16 # else # error "LZO_SIZEOF_INT" # endif #endif #if !defined(LZO_SIZEOF_LONG) # if (ULONG_MAX == LZO_0xffffffffL) # define LZO_SIZEOF_LONG 4 # elif (__LZO_LSR(ULONG_MAX,7) == 1) # define LZO_SIZEOF_LONG 1 # elif (__LZO_LSR(ULONG_MAX,15) == 1) # define LZO_SIZEOF_LONG 2 # elif (__LZO_LSR(ULONG_MAX,31) == 1) # define LZO_SIZEOF_LONG 4 # elif (__LZO_LSR(ULONG_MAX,63) == 1) # define LZO_SIZEOF_LONG 8 # elif (__LZO_LSR(ULONG_MAX,127) == 1) # define LZO_SIZEOF_LONG 16 # else # error "LZO_SIZEOF_LONG" # endif #endif #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) # if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) # if (LZO_CC_GNUC >= 0x030300ul) # if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) # define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG # elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) # define LZO_SIZEOF_LONG_LONG 4 # endif # endif # endif #endif #endif #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) #if (LZO_ARCH_I086 && LZO_CC_DMC) #elif (LZO_CC_CILLY) && defined(__GNUC__) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_SIZEOF_LONG_LONG 8 #elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_OS_WIN64 || defined(_WIN64)) # define LZO_SIZEOF___INT64 8 #elif (LZO_ARCH_I386 && (LZO_CC_DMC)) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) # define LZO_SIZEOF___INT64 8 #elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) # define LZO_SIZEOF___INT64 8 #elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) # define LZO_SIZEOF___INT64 8 #elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) # define LZO_SIZEOF___INT64 8 #elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) # define LZO_SIZEOF___INT64 8 #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) # define LZO_SIZEOF_LONG_LONG 8 #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) #elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) # define LZO_SIZEOF_LONG_LONG 8 #endif #endif #endif #if defined(__cplusplus) && defined(LZO_CC_GNUC) # if (LZO_CC_GNUC < 0x020800ul) # undef LZO_SIZEOF_LONG_LONG # endif #endif #if defined(LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) # undef LZO_SIZEOF_LONG_LONG #endif #if !defined(LZO_SIZEOF_VOID_P) #if (LZO_ARCH_I086) # define __LZO_WORDSIZE 2 # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) # define LZO_SIZEOF_VOID_P 2 # elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) # define LZO_SIZEOF_VOID_P 4 # else # error "LZO_MM" # endif #elif (LZO_ARCH_AVR || LZO_ARCH_Z80) # define __LZO_WORDSIZE 1 # define LZO_SIZEOF_VOID_P 2 #elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) # define LZO_SIZEOF_VOID_P 2 #elif (LZO_ARCH_H8300) # if defined(__NORMAL_MODE__) # define __LZO_WORDSIZE 4 # define LZO_SIZEOF_VOID_P 2 # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) # define __LZO_WORDSIZE 4 # define LZO_SIZEOF_VOID_P 4 # else # define __LZO_WORDSIZE 2 # define LZO_SIZEOF_VOID_P 2 # endif # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT # endif #elif (LZO_ARCH_M16C) # define __LZO_WORDSIZE 2 # if defined(__m32c_cpu__) || defined(__m32cm_cpu__) # define LZO_SIZEOF_VOID_P 4 # else # define LZO_SIZEOF_VOID_P 2 # endif #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) # define __LZO_WORDSIZE 8 # define LZO_SIZEOF_VOID_P 4 #elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) # define __LZO_WORDSIZE 8 # define LZO_SIZEOF_VOID_P 8 #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG #elif (LZO_OS_OS400 || defined(__OS400__)) # define __LZO_WORDSIZE LZO_SIZEOF_LONG # define LZO_SIZEOF_VOID_P 16 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) # define LZO_SIZEOF_VOID_P 8 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG #elif (LZO_ARCH_SPU) # if 0 # define __LZO_WORDSIZE 16 # endif # define LZO_SIZEOF_VOID_P 4 #else # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG #endif #endif #if !defined(LZO_WORDSIZE) # if defined(__LZO_WORDSIZE) # define LZO_WORDSIZE __LZO_WORDSIZE # else # define LZO_WORDSIZE LZO_SIZEOF_VOID_P # endif #endif #if !defined(LZO_SIZEOF_SIZE_T) #if (LZO_ARCH_I086 || LZO_ARCH_M16C) # define LZO_SIZEOF_SIZE_T 2 #else # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P #endif #endif #if !defined(LZO_SIZEOF_PTRDIFF_T) #if (LZO_ARCH_I086) # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P # elif (LZO_MM_COMPACT || LZO_MM_LARGE) # if (LZO_CC_BORLANDC || LZO_CC_TURBOC) # define LZO_SIZEOF_PTRDIFF_T 4 # else # define LZO_SIZEOF_PTRDIFF_T 2 # endif # else # error "LZO_MM" # endif #else # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T #endif #endif #if defined(LZO_ABI_NEUTRAL_ENDIAN) # undef LZO_ABI_BIG_ENDIAN # undef LZO_ABI_LITTLE_ENDIAN #elif !defined(LZO_ABI_BIG_ENDIAN) && !defined(LZO_ABI_LITTLE_ENDIAN) #if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) # define LZO_ABI_BIG_ENDIAN 1 #elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) # define LZO_ABI_LITTLE_ENDIAN 1 #elif (LZO_ARCH_M68K || LZO_ARCH_S390) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) # if (__LITTLE_ENDIAN__ == 1) # define LZO_ABI_LITTLE_ENDIAN 1 # else # define LZO_ABI_BIG_ENDIAN 1 # endif #elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) # define LZO_ABI_LITTLE_ENDIAN 1 #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) # define LZO_ABI_LITTLE_ENDIAN 1 #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) # define LZO_ABI_LITTLE_ENDIAN 1 #endif #endif #if defined(LZO_ABI_BIG_ENDIAN) && defined(LZO_ABI_LITTLE_ENDIAN) # error "this should not happen" #endif #if defined(LZO_ABI_BIG_ENDIAN) # define LZO_INFO_ABI_ENDIAN "be" #elif defined(LZO_ABI_LITTLE_ENDIAN) # define LZO_INFO_ABI_ENDIAN "le" #elif defined(LZO_ABI_NEUTRAL_ENDIAN) # define LZO_INFO_ABI_ENDIAN "neutral" #endif #if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) # define LZO_ABI_I8LP16 1 # define LZO_INFO_ABI_PM "i8lp16" #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) # define LZO_ABI_ILP16 1 # define LZO_INFO_ABI_PM "ilp16" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) # define LZO_ABI_ILP32 1 # define LZO_INFO_ABI_PM "ilp32" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) # define LZO_ABI_LLP64 1 # define LZO_INFO_ABI_PM "llp64" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) # define LZO_ABI_LP64 1 # define LZO_INFO_ABI_PM "lp64" #elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) # define LZO_ABI_ILP64 1 # define LZO_INFO_ABI_PM "ilp64" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) # define LZO_ABI_IP32L64 1 # define LZO_INFO_ABI_PM "ip32l64" #endif #if !defined(__LZO_LIBC_OVERRIDE) #if defined(LZO_LIBC_NAKED) # define LZO_INFO_LIBC "naked" #elif defined(LZO_LIBC_FREESTANDING) # define LZO_INFO_LIBC "freestanding" #elif defined(LZO_LIBC_MOSTLY_FREESTANDING) # define LZO_INFO_LIBC "mfreestanding" #elif defined(LZO_LIBC_ISOC90) # define LZO_INFO_LIBC "isoc90" #elif defined(LZO_LIBC_ISOC99) # define LZO_INFO_LIBC "isoc99" #elif defined(__dietlibc__) # define LZO_LIBC_DIETLIBC 1 # define LZO_INFO_LIBC "dietlibc" #elif defined(_NEWLIB_VERSION) # define LZO_LIBC_NEWLIB 1 # define LZO_INFO_LIBC "newlib" #elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) # if defined(__UCLIBC_SUBLEVEL__) # define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) # else # define LZO_LIBC_UCLIBC 0x00090bL # endif # define LZO_INFO_LIBC "uclibc" #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) # define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) # define LZO_INFO_LIBC "glibc" #elif (LZO_CC_MWERKS) && defined(__MSL__) # define LZO_LIBC_MSL __MSL__ # define LZO_INFO_LIBC "msl" #elif 1 && defined(__IAR_SYSTEMS_ICC__) # define LZO_LIBC_ISOC90 1 # define LZO_INFO_LIBC "isoc90" #else # define LZO_LIBC_DEFAULT 1 # define LZO_INFO_LIBC "default" #endif #endif #if !defined(__lzo_gnuc_extension__) #if (LZO_CC_GNUC >= 0x020800ul) # define __lzo_gnuc_extension__ __extension__ #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_gnuc_extension__ __extension__ #else # define __lzo_gnuc_extension__ #endif #endif #if !defined(__lzo_ua_volatile) # define __lzo_ua_volatile volatile #endif #if !defined(__lzo_alignof) #if (LZO_CC_CILLY || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) # define __lzo_alignof(e) __alignof__(e) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) # define __lzo_alignof(e) __alignof__(e) #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) # define __lzo_alignof(e) __alignof(e) #endif #endif #if defined(__lzo_alignof) # define __lzo_HAVE_alignof 1 #endif #if !defined(__lzo_constructor) #if (LZO_CC_GNUC >= 0x030400ul) # define __lzo_constructor __attribute__((__constructor__,__used__)) #elif (LZO_CC_GNUC >= 0x020700ul) # define __lzo_constructor __attribute__((__constructor__)) #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_constructor __attribute__((__constructor__)) #endif #endif #if defined(__lzo_constructor) # define __lzo_HAVE_constructor 1 #endif #if !defined(__lzo_destructor) #if (LZO_CC_GNUC >= 0x030400ul) # define __lzo_destructor __attribute__((__destructor__,__used__)) #elif (LZO_CC_GNUC >= 0x020700ul) # define __lzo_destructor __attribute__((__destructor__)) #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_destructor __attribute__((__destructor__)) #endif #endif #if defined(__lzo_destructor) # define __lzo_HAVE_destructor 1 #endif #if defined(__lzo_HAVE_destructor) && !defined(__lzo_HAVE_constructor) # error "this should not happen" #endif #if !defined(__lzo_inline) #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) #elif defined(__cplusplus) # define __lzo_inline inline #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) # define __lzo_inline __inline #elif (LZO_CC_CILLY || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) # define __lzo_inline __inline__ #elif (LZO_CC_DMC) # define __lzo_inline __inline #elif (LZO_CC_INTELC) # define __lzo_inline __inline #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) # define __lzo_inline __inline #elif (LZO_CC_MSC && (_MSC_VER >= 900)) # define __lzo_inline __inline #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) # define __lzo_inline inline #endif #endif #if defined(__lzo_inline) # define __lzo_HAVE_inline 1 #else # define __lzo_inline #endif #if !defined(__lzo_forceinline) #if (LZO_CC_GNUC >= 0x030200ul) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) # define __lzo_forceinline __forceinline #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) # define __lzo_forceinline __forceinline #endif #endif #if defined(__lzo_forceinline) # define __lzo_HAVE_forceinline 1 #else # define __lzo_forceinline #endif #if !defined(__lzo_noinline) #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) # define __lzo_noinline __attribute__((__noinline__,__used__)) #elif (LZO_CC_GNUC >= 0x030200ul) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) # define __lzo_noinline __declspec(noinline) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) # define __lzo_noinline __declspec(noinline) #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) # if defined(__cplusplus) # else # define __lzo_noinline __declspec(noinline) # endif #endif #endif #if defined(__lzo_noinline) # define __lzo_HAVE_noinline 1 #else # define __lzo_noinline #endif #if (defined(__lzo_HAVE_forceinline) || defined(__lzo_HAVE_noinline)) && !defined(__lzo_HAVE_inline) # error "this should not happen" #endif #if !defined(__lzo_noreturn) #if (LZO_CC_GNUC >= 0x020700ul) # define __lzo_noreturn __attribute__((__noreturn__)) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) # define __lzo_noreturn __declspec(noreturn) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) # define __lzo_noreturn __attribute__((__noreturn__)) #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_noreturn __attribute__((__noreturn__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) # define __lzo_noreturn __declspec(noreturn) #endif #endif #if defined(__lzo_noreturn) # define __lzo_HAVE_noreturn 1 #else # define __lzo_noreturn #endif #if !defined(__lzo_nothrow) #if (LZO_CC_GNUC >= 0x030300ul) # define __lzo_nothrow __attribute__((__nothrow__)) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) # define __lzo_nothrow __declspec(nothrow) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) # define __lzo_nothrow __attribute__((__nothrow__)) #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_nothrow __attribute__((__nothrow__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) # define __lzo_nothrow __declspec(nothrow) #endif #endif #if defined(__lzo_nothrow) # define __lzo_HAVE_nothrow 1 #else # define __lzo_nothrow #endif #if !defined(__lzo_restrict) #if (LZO_CC_GNUC >= 0x030400ul) # define __lzo_restrict __restrict__ #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) # define __lzo_restrict __restrict__ #elif (LZO_CC_LLVM) # define __lzo_restrict __restrict__ #elif (LZO_CC_MSC && (_MSC_VER >= 1400)) # define __lzo_restrict __restrict #endif #endif #if defined(__lzo_restrict) # define __lzo_HAVE_restrict 1 #else # define __lzo_restrict #endif #if !defined(__lzo_likely) && !defined(__lzo_unlikely) #if (LZO_CC_GNUC >= 0x030200ul) # define __lzo_likely(e) (__builtin_expect(!!(e),1)) # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) # define __lzo_likely(e) (__builtin_expect(!!(e),1)) # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_likely(e) (__builtin_expect(!!(e),1)) # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #endif #endif #if defined(__lzo_likely) # define __lzo_HAVE_likely 1 #else # define __lzo_likely(e) (e) #endif #if defined(__lzo_unlikely) # define __lzo_HAVE_unlikely 1 #else # define __lzo_unlikely(e) (e) #endif #if !defined(LZO_UNUSED) # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) # define LZO_UNUSED(var) ((void) &var) # elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) # define LZO_UNUSED(var) if (&var) ; else # elif (LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_UNUSED(var) ((void) var) # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_UNUSED(var) if (&var) ; else # elif (LZO_CC_KEILC) # define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} # elif (LZO_CC_PACIFICC) # define LZO_UNUSED(var) ((void) sizeof(var)) # elif (LZO_CC_WATCOMC) && defined(__cplusplus) # define LZO_UNUSED(var) ((void) var) # else # define LZO_UNUSED(var) ((void) &var) # endif #endif #if !defined(LZO_UNUSED_FUNC) # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) # define LZO_UNUSED_FUNC(func) ((void) func) # elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) # define LZO_UNUSED_FUNC(func) if (func) ; else # elif (LZO_CC_LLVM) # define LZO_UNUSED_FUNC(func) ((void) &func) # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_UNUSED_FUNC(func) if (func) ; else # elif (LZO_CC_MSC) # define LZO_UNUSED_FUNC(func) ((void) &func) # elif (LZO_CC_KEILC || LZO_CC_PELLESC) # define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} # else # define LZO_UNUSED_FUNC(func) ((void) func) # endif #endif #if !defined(LZO_UNUSED_LABEL) # if (LZO_CC_WATCOMC) && defined(__cplusplus) # define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l # elif (LZO_CC_INTELC || LZO_CC_WATCOMC) # define LZO_UNUSED_LABEL(l) if (0) goto l # else # define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l # endif #endif #if !defined(LZO_DEFINE_UNINITIALIZED_VAR) # if 0 # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var # elif 0 && (LZO_CC_GNUC) # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var # else # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init # endif #endif #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; # elif (LZO_CC_DMC || LZO_CC_SYMANTECC) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; # else # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; # endif #endif #if !defined(LZO_COMPILE_TIME_ASSERT) # if (LZO_CC_AZTECC) # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # else # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} # endif #endif #if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) # define __lzo_cdecl __cdecl # define __lzo_cdecl_atexit # define __lzo_cdecl_main __cdecl # if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) # define __lzo_cdecl_qsort __pascal # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) # define __lzo_cdecl_qsort _stdcall # else # define __lzo_cdecl_qsort __cdecl # endif # elif (LZO_CC_WATCOMC) # define __lzo_cdecl __cdecl # else # define __lzo_cdecl __cdecl # define __lzo_cdecl_atexit __cdecl # define __lzo_cdecl_main __cdecl # define __lzo_cdecl_qsort __cdecl # endif # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) # elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) # define __lzo_cdecl_sighandler __pascal # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) # define __lzo_cdecl_sighandler _stdcall # elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) # define __lzo_cdecl_sighandler __clrcall # elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) # if defined(_DLL) # define __lzo_cdecl_sighandler _far _cdecl _loadds # elif defined(_MT) # define __lzo_cdecl_sighandler _far _cdecl # else # define __lzo_cdecl_sighandler _cdecl # endif # else # define __lzo_cdecl_sighandler __cdecl # endif #elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) # define __lzo_cdecl __cdecl #elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) # define __lzo_cdecl cdecl #endif #if !defined(__lzo_cdecl) # define __lzo_cdecl #endif #if !defined(__lzo_cdecl_atexit) # define __lzo_cdecl_atexit #endif #if !defined(__lzo_cdecl_main) # define __lzo_cdecl_main #endif #if !defined(__lzo_cdecl_qsort) # define __lzo_cdecl_qsort #endif #if !defined(__lzo_cdecl_sighandler) # define __lzo_cdecl_sighandler #endif #if !defined(__lzo_cdecl_va) # define __lzo_cdecl_va __lzo_cdecl #endif #if !defined(LZO_CFG_NO_WINDOWS_H) #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) # elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) # elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) # else # define LZO_HAVE_WINDOWS_H 1 # endif #endif #endif #if (LZO_ARCH_ALPHA) # define LZO_OPT_AVOID_UINT_INDEX 1 # define LZO_OPT_AVOID_SHORT 1 # define LZO_OPT_AVOID_USHORT 1 #elif (LZO_ARCH_AMD64) # define LZO_OPT_AVOID_INT_INDEX 1 # define LZO_OPT_AVOID_UINT_INDEX 1 # define LZO_OPT_UNALIGNED16 1 # define LZO_OPT_UNALIGNED32 1 # define LZO_OPT_UNALIGNED64 1 #elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) #elif (LZO_ARCH_ARM) # define LZO_OPT_AVOID_SHORT 1 # define LZO_OPT_AVOID_USHORT 1 #elif (LZO_ARCH_CRIS) # define LZO_OPT_UNALIGNED16 1 # define LZO_OPT_UNALIGNED32 1 #elif (LZO_ARCH_I386) # define LZO_OPT_UNALIGNED16 1 # define LZO_OPT_UNALIGNED32 1 #elif (LZO_ARCH_IA64) # define LZO_OPT_AVOID_INT_INDEX 1 # define LZO_OPT_AVOID_UINT_INDEX 1 # define LZO_OPT_PREFER_POSTINC 1 #elif (LZO_ARCH_M68K) # define LZO_OPT_PREFER_POSTINC 1 # define LZO_OPT_PREFER_PREDEC 1 # if defined(__mc68020__) && !defined(__mcoldfire__) # define LZO_OPT_UNALIGNED16 1 # define LZO_OPT_UNALIGNED32 1 # endif #elif (LZO_ARCH_MIPS) # define LZO_OPT_AVOID_UINT_INDEX 1 #elif (LZO_ARCH_POWERPC) # define LZO_OPT_PREFER_PREINC 1 # define LZO_OPT_PREFER_PREDEC 1 # if defined(LZO_ABI_BIG_ENDIAN) # define LZO_OPT_UNALIGNED16 1 # define LZO_OPT_UNALIGNED32 1 # endif #elif (LZO_ARCH_S390) # define LZO_OPT_UNALIGNED16 1 # define LZO_OPT_UNALIGNED32 1 # if (LZO_SIZEOF_SIZE_T == 8) # define LZO_OPT_UNALIGNED64 1 # endif #elif (LZO_ARCH_SH) # define LZO_OPT_PREFER_POSTINC 1 # define LZO_OPT_PREFER_PREDEC 1 #endif #if !defined(LZO_CFG_NO_INLINE_ASM) #if defined(LZO_CC_LLVM) # define LZO_CFG_NO_INLINE_ASM 1 #endif #endif #if !defined(LZO_CFG_NO_UNALIGNED) #if defined(LZO_ABI_NEUTRAL_ENDIAN) || defined(LZO_ARCH_GENERIC) # define LZO_CFG_NO_UNALIGNED 1 #endif #endif #if defined(LZO_CFG_NO_UNALIGNED) # undef LZO_OPT_UNALIGNED16 # undef LZO_OPT_UNALIGNED32 # undef LZO_OPT_UNALIGNED64 #endif #if defined(LZO_CFG_NO_INLINE_ASM) #elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) # define LZO_ASM_SYNTAX_MSC 1 #elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) #elif (LZO_ARCH_I386 && (LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) # define LZO_ASM_SYNTAX_GNUC 1 #elif (LZO_ARCH_AMD64 && (LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) # define LZO_ASM_SYNTAX_GNUC 1 #endif #if (LZO_ASM_SYNTAX_GNUC) #if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) # define __LZO_ASM_CLOBBER "ax" #elif (LZO_CC_INTELC) # define __LZO_ASM_CLOBBER "memory" #else # define __LZO_ASM_CLOBBER "cc", "memory" #endif #endif #if defined(__LZO_INFOSTR_MM) #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) # define __LZO_INFOSTR_MM "" #elif defined(LZO_INFO_MM) # define __LZO_INFOSTR_MM "." LZO_INFO_MM #else # define __LZO_INFOSTR_MM "" #endif #if defined(__LZO_INFOSTR_PM) #elif defined(LZO_INFO_ABI_PM) # define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM #else # define __LZO_INFOSTR_PM "" #endif #if defined(__LZO_INFOSTR_ENDIAN) #elif defined(LZO_INFO_ABI_ENDIAN) # define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN #else # define __LZO_INFOSTR_ENDIAN "" #endif #if defined(__LZO_INFOSTR_OSNAME) #elif defined(LZO_INFO_OS_CONSOLE) # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE #elif defined(LZO_INFO_OS_POSIX) # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX #else # define __LZO_INFOSTR_OSNAME LZO_INFO_OS #endif #if defined(__LZO_INFOSTR_LIBC) #elif defined(LZO_INFO_LIBC) # define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC #else # define __LZO_INFOSTR_LIBC "" #endif #if defined(__LZO_INFOSTR_CCVER) #elif defined(LZO_INFO_CCVER) # define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER #else # define __LZO_INFOSTR_CCVER "" #endif #define LZO_INFO_STRING \ LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER #endif #endif #undef LZO_HAVE_CONFIG_H #include "minilzo.h" #if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x2030) # error "version mismatch in miniLZO source files" #endif #ifdef MINILZO_HAVE_CONFIG_H # define LZO_HAVE_CONFIG_H #endif #ifndef __LZO_CONF_H #define __LZO_CONF_H #if !defined(__LZO_IN_MINILZO) #if defined(LZO_CFG_FREESTANDING) # define LZO_LIBC_FREESTANDING 1 # define LZO_OS_FREESTANDING 1 # define ACC_LIBC_FREESTANDING 1 # define ACC_OS_FREESTANDING 1 #endif #if defined(LZO_CFG_NO_UNALIGNED) # define ACC_CFG_NO_UNALIGNED 1 #endif #if defined(LZO_ARCH_GENERIC) # define ACC_ARCH_GENERIC 1 #endif #if defined(LZO_ABI_NEUTRAL_ENDIAN) # define ACC_ABI_NEUTRAL_ENDIAN 1 #endif #if defined(LZO_HAVE_CONFIG_H) # define ACC_CONFIG_NO_HEADER 1 #endif #if defined(LZO_CFG_EXTRA_CONFIG_HEADER) # include LZO_CFG_EXTRA_CONFIG_HEADER #endif #if defined(__LZOCONF_H) || defined(__LZOCONF_H_INCLUDED) # error "include this file first" #endif #include "lzo/lzoconf.h" #endif #if (LZO_VERSION < 0x02000) || !defined(__LZOCONF_H_INCLUDED) # error "version mismatch" #endif #if (LZO_CC_BORLANDC && LZO_ARCH_I086) # pragma option -h #endif #if (LZO_CC_MSC && (_MSC_VER >= 1000)) # pragma warning(disable: 4127 4701) #endif #if (LZO_CC_MSC && (_MSC_VER >= 1300)) # pragma warning(disable: 4820) # pragma warning(disable: 4514 4710 4711) #endif #if (LZO_CC_SUNPROC) # pragma error_messages(off,E_END_OF_LOOP_CODE_NOT_REACHED) # pragma error_messages(off,E_LOOP_NOT_ENTERED_AT_TOP) #endif #if defined(__LZO_MMODEL_HUGE) && (!LZO_HAVE_MM_HUGE_PTR) # error "this should not happen - check defines for __huge" #endif #if defined(__LZO_IN_MINILZO) || defined(LZO_CFG_FREESTANDING) #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # define ACC_WANT_ACC_INCD_H 1 # define ACC_WANT_ACC_INCE_H 1 # define ACC_WANT_ACC_INCI_H 1 #elif 1 # include #else # define ACC_WANT_ACC_INCD_H 1 #endif #if (LZO_ARCH_I086) # define ACC_MM_AHSHIFT LZO_MM_AHSHIFT # define ACC_PTR_FP_OFF(x) (((const unsigned __far*)&(x))[0]) # define ACC_PTR_FP_SEG(x) (((const unsigned __far*)&(x))[1]) # define ACC_PTR_MK_FP(s,o) ((void __far*)(((unsigned long)(s)<<16)+(unsigned)(o))) #endif #if !defined(lzo_uintptr_t) # if defined(__LZO_MMODEL_HUGE) # define lzo_uintptr_t unsigned long # elif 1 && defined(LZO_OS_OS400) && (LZO_SIZEOF_VOID_P == 16) # define __LZO_UINTPTR_T_IS_POINTER 1 typedef char* lzo_uintptr_t; # define lzo_uintptr_t lzo_uintptr_t # elif (LZO_SIZEOF_SIZE_T == LZO_SIZEOF_VOID_P) # define lzo_uintptr_t size_t # elif (LZO_SIZEOF_LONG == LZO_SIZEOF_VOID_P) # define lzo_uintptr_t unsigned long # elif (LZO_SIZEOF_INT == LZO_SIZEOF_VOID_P) # define lzo_uintptr_t unsigned int # elif (LZO_SIZEOF_LONG_LONG == LZO_SIZEOF_VOID_P) # define lzo_uintptr_t unsigned long long # else # define lzo_uintptr_t size_t # endif #endif LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) #if 1 && !defined(LZO_CFG_FREESTANDING) #if 1 && !defined(HAVE_STRING_H) #define HAVE_STRING_H 1 #endif #if 1 && !defined(HAVE_MEMCMP) #define HAVE_MEMCMP 1 #endif #if 1 && !defined(HAVE_MEMCPY) #define HAVE_MEMCPY 1 #endif #if 1 && !defined(HAVE_MEMMOVE) #define HAVE_MEMMOVE 1 #endif #if 1 && !defined(HAVE_MEMSET) #define HAVE_MEMSET 1 #endif #endif #if 1 && defined(HAVE_STRING_H) #include #endif #if defined(LZO_CFG_FREESTANDING) # undef HAVE_MEMCMP # undef HAVE_MEMCPY # undef HAVE_MEMMOVE # undef HAVE_MEMSET #endif #if !defined(HAVE_MEMCMP) # undef memcmp # define memcmp(a,b,c) lzo_memcmp(a,b,c) #elif !defined(__LZO_MMODEL_HUGE) # define lzo_memcmp(a,b,c) memcmp(a,b,c) #endif #if !defined(HAVE_MEMCPY) # undef memcpy # define memcpy(a,b,c) lzo_memcpy(a,b,c) #elif !defined(__LZO_MMODEL_HUGE) # define lzo_memcpy(a,b,c) memcpy(a,b,c) #endif #if !defined(HAVE_MEMMOVE) # undef memmove # define memmove(a,b,c) lzo_memmove(a,b,c) #elif !defined(__LZO_MMODEL_HUGE) # define lzo_memmove(a,b,c) memmove(a,b,c) #endif #if !defined(HAVE_MEMSET) # undef memset # define memset(a,b,c) lzo_memset(a,b,c) #elif !defined(__LZO_MMODEL_HUGE) # define lzo_memset(a,b,c) memset(a,b,c) #endif #undef NDEBUG #if defined(LZO_CFG_FREESTANDING) # undef LZO_DEBUG # define NDEBUG 1 # undef assert # define assert(e) ((void)0) #else # if !defined(LZO_DEBUG) # define NDEBUG 1 # endif # include #endif #if 0 && defined(__BOUNDS_CHECKING_ON) # include #else # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr) #endif #if !defined(__lzo_inline) # define __lzo_inline #endif #if !defined(__lzo_forceinline) # define __lzo_forceinline #endif #if !defined(__lzo_noinline) # define __lzo_noinline #endif #if 1 # define LZO_BYTE(x) ((unsigned char) (x)) #else # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff)) #endif #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b)) #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b)) #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c)) #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c)) #define lzo_sizeof(type) ((lzo_uint) (sizeof(type))) #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array)))) #define LZO_SIZE(bits) (1u << (bits)) #define LZO_MASK(bits) (LZO_SIZE(bits) - 1) #define LZO_LSIZE(bits) (1ul << (bits)) #define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1) #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits)) #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1) #if !defined(DMUL) #if 0 # define DMUL(a,b) ((lzo_xint) ((lzo_uint32)(a) * (lzo_uint32)(b))) #else # define DMUL(a,b) ((lzo_xint) ((a) * (b))) #endif #endif #if 1 && !defined(LZO_CFG_NO_UNALIGNED) #if 1 && (LZO_ARCH_AMD64 || LZO_ARCH_I386) # if (LZO_SIZEOF_SHORT == 2) # define LZO_UNALIGNED_OK_2 # endif # if (LZO_SIZEOF_INT == 4) # define LZO_UNALIGNED_OK_4 # endif #endif #endif #if defined(LZO_UNALIGNED_OK_2) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(short) == 2) #endif #if defined(LZO_UNALIGNED_OK_4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4) #elif defined(LZO_ALIGNED_OK_4) LZO_COMPILE_TIME_ASSERT_HEADER(sizeof(lzo_uint32) == 4) #endif #define MEMCPY8_DS(dest,src,len) \ lzo_memcpy(dest,src,len); dest += len; src += len #define BZERO8_PTR(s,l,n) \ lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n)) #define MEMCPY_DS(dest,src,len) \ do *dest++ = *src++; while (--len > 0) __LZO_EXTERN_C int __lzo_init_done; __LZO_EXTERN_C const char __lzo_copyright[]; LZO_EXTERN(const lzo_bytep) lzo_copyright(void); #ifndef __LZO_PTR_H #define __LZO_PTR_H #ifdef __cplusplus extern "C" { #endif #if !defined(lzo_uintptr_t) # if defined(__LZO_MMODEL_HUGE) # define lzo_uintptr_t unsigned long # else # define lzo_uintptr_t acc_uintptr_t # ifdef __ACC_INTPTR_T_IS_POINTER # define __LZO_UINTPTR_T_IS_POINTER 1 # endif # endif #endif #if (LZO_ARCH_I086) #define PTR(a) ((lzo_bytep) (a)) #define PTR_ALIGNED_4(a) ((ACC_PTR_FP_OFF(a) & 3) == 0) #define PTR_ALIGNED2_4(a,b) (((ACC_PTR_FP_OFF(a) | ACC_PTR_FP_OFF(b)) & 3) == 0) #elif (LZO_MM_PVP) #define PTR(a) ((lzo_bytep) (a)) #define PTR_ALIGNED_8(a) ((((lzo_uintptr_t)(a)) >> 61) == 0) #define PTR_ALIGNED2_8(a,b) ((((lzo_uintptr_t)(a)|(lzo_uintptr_t)(b)) >> 61) == 0) #else #define PTR(a) ((lzo_uintptr_t) (a)) #define PTR_LINEAR(a) PTR(a) #define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0) #define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0) #define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0) #define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0) #endif #define PTR_LT(a,b) (PTR(a) < PTR(b)) #define PTR_GE(a,b) (PTR(a) >= PTR(b)) #define PTR_DIFF(a,b) (PTR(a) - PTR(b)) #define pd(a,b) ((lzo_uint) ((a)-(b))) LZO_EXTERN(lzo_uintptr_t) __lzo_ptr_linear(const lzo_voidp ptr); typedef union { char a_char; unsigned char a_uchar; short a_short; unsigned short a_ushort; int a_int; unsigned int a_uint; long a_long; unsigned long a_ulong; lzo_int a_lzo_int; lzo_uint a_lzo_uint; lzo_int32 a_lzo_int32; lzo_uint32 a_lzo_uint32; ptrdiff_t a_ptrdiff_t; lzo_uintptr_t a_lzo_uintptr_t; lzo_voidp a_lzo_voidp; void * a_void_p; lzo_bytep a_lzo_bytep; lzo_bytepp a_lzo_bytepp; lzo_uintp a_lzo_uintp; lzo_uint * a_lzo_uint_p; lzo_uint32p a_lzo_uint32p; lzo_uint32 * a_lzo_uint32_p; unsigned char * a_uchar_p; char * a_char_p; } lzo_full_align_t; #ifdef __cplusplus } #endif #endif #define LZO_DETERMINISTIC #define LZO_DICT_USE_PTR #if 0 && (LZO_ARCH_I086) # undef LZO_DICT_USE_PTR #endif #if defined(LZO_DICT_USE_PTR) # define lzo_dict_t const lzo_bytep # define lzo_dict_p lzo_dict_t __LZO_MMODEL * #else # define lzo_dict_t lzo_uint # define lzo_dict_p lzo_dict_t __LZO_MMODEL * #endif #endif #if !defined(MINILZO_CFG_SKIP_LZO_PTR) LZO_PUBLIC(lzo_uintptr_t) __lzo_ptr_linear(const lzo_voidp ptr) { lzo_uintptr_t p; #if (LZO_ARCH_I086) p = (((lzo_uintptr_t)(ACC_PTR_FP_SEG(ptr))) << (16 - ACC_MM_AHSHIFT)) + (ACC_PTR_FP_OFF(ptr)); #elif (LZO_MM_PVP) p = (lzo_uintptr_t) (ptr); p = (p << 3) | (p >> 61); #else p = (lzo_uintptr_t) PTR_LINEAR(ptr); #endif return p; } LZO_PUBLIC(unsigned) __lzo_align_gap(const lzo_voidp ptr, lzo_uint size) { #if defined(__LZO_UINTPTR_T_IS_POINTER) size_t n = (size_t) ptr; n = (((n + size - 1) / size) * size) - n; #else lzo_uintptr_t p, n; p = __lzo_ptr_linear(ptr); n = (((p + size - 1) / size) * size) - p; #endif assert(size > 0); assert((long)n >= 0); assert(n <= size); return (unsigned)n; } #endif /* If you use the LZO library in a product, I would appreciate that you * keep this copyright string in the executable of your product. */ const char __lzo_copyright[] = #if !defined(__LZO_IN_MINLZO) LZO_VERSION_STRING; #else "\r\n\n" "LZO data compression library.\n" "$Copyright: LZO (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 Markus Franz Xaver Johannes Oberhumer\n" "\n" "http://www.oberhumer.com $\n\n" "$Id: minilzo.c,v 1.5.2.1 2008/10/14 16:41:58 seppel Exp $\n" "$Built: " __DATE__ " " __TIME__ " $\n" "$Info: " LZO_INFO_STRING " $\n"; #endif LZO_PUBLIC(const lzo_bytep) lzo_copyright(void) { #if (LZO_OS_DOS16 && LZO_CC_TURBOC) return (lzo_voidp) __lzo_copyright; #else return (const lzo_bytep) __lzo_copyright; #endif } LZO_PUBLIC(unsigned) lzo_version(void) { return LZO_VERSION; } LZO_PUBLIC(const char *) lzo_version_string(void) { return LZO_VERSION_STRING; } LZO_PUBLIC(const char *) lzo_version_date(void) { return LZO_VERSION_DATE; } LZO_PUBLIC(const lzo_charp) _lzo_version_string(void) { return LZO_VERSION_STRING; } LZO_PUBLIC(const lzo_charp) _lzo_version_date(void) { return LZO_VERSION_DATE; } #define LZO_BASE 65521u #define LZO_NMAX 5552 #define LZO_DO1(buf,i) s1 += buf[i]; s2 += s1 #define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1); #define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2); #define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4); #define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8); LZO_PUBLIC(lzo_uint32) lzo_adler32(lzo_uint32 adler, const lzo_bytep buf, lzo_uint len) { lzo_uint32 s1 = adler & 0xffff; lzo_uint32 s2 = (adler >> 16) & 0xffff; unsigned k; if (buf == NULL) return 1; while (len > 0) { k = len < LZO_NMAX ? (unsigned) len : LZO_NMAX; len -= k; if (k >= 16) do { LZO_DO16(buf,0); buf += 16; k -= 16; } while (k >= 16); if (k != 0) do { s1 += *buf++; s2 += s1; } while (--k > 0); s1 %= LZO_BASE; s2 %= LZO_BASE; } return (s2 << 16) | s1; } #undef LZO_DO1 #undef LZO_DO2 #undef LZO_DO4 #undef LZO_DO8 #undef LZO_DO16 #if !defined(MINILZO_CFG_SKIP_LZO_STRING) #undef lzo_memcmp #undef lzo_memcpy #undef lzo_memmove #undef lzo_memset #if !defined(__LZO_MMODEL_HUGE) # undef LZO_HAVE_MM_HUGE_PTR #endif #define lzo_hsize_t lzo_uint #define lzo_hvoid_p lzo_voidp #define lzo_hbyte_p lzo_bytep #define LZOLIB_PUBLIC(r,f) LZO_PUBLIC(r) f #define lzo_hmemcmp lzo_memcmp #define lzo_hmemcpy lzo_memcpy #define lzo_hmemmove lzo_memmove #define lzo_hmemset lzo_memset #define __LZOLIB_HMEMCPY_CH_INCLUDED 1 #if !defined(LZOLIB_PUBLIC) # define LZOLIB_PUBLIC(r,f) r __LZOLIB_FUNCNAME(f) #endif LZOLIB_PUBLIC(int, lzo_hmemcmp) (const lzo_hvoid_p s1, const lzo_hvoid_p s2, lzo_hsize_t len) { #if (LZO_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMCMP) const lzo_hbyte_p p1 = (const lzo_hbyte_p) s1; const lzo_hbyte_p p2 = (const lzo_hbyte_p) s2; if __lzo_likely(len > 0) do { int d = *p1 - *p2; if (d != 0) return d; p1++; p2++; } while __lzo_likely(--len > 0); return 0; #else return memcmp(s1, s2, len); #endif } LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemcpy) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) { #if (LZO_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMCPY) lzo_hbyte_p p1 = (lzo_hbyte_p) dest; const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; if (!(len > 0) || p1 == p2) return dest; do *p1++ = *p2++; while __lzo_likely(--len > 0); return dest; #else return memcpy(dest, src, len); #endif } LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemmove) (lzo_hvoid_p dest, const lzo_hvoid_p src, lzo_hsize_t len) { #if (LZO_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMMOVE) lzo_hbyte_p p1 = (lzo_hbyte_p) dest; const lzo_hbyte_p p2 = (const lzo_hbyte_p) src; if (!(len > 0) || p1 == p2) return dest; if (p1 < p2) { do *p1++ = *p2++; while __lzo_likely(--len > 0); } else { p1 += len; p2 += len; do *--p1 = *--p2; while __lzo_likely(--len > 0); } return dest; #else return memmove(dest, src, len); #endif } LZOLIB_PUBLIC(lzo_hvoid_p, lzo_hmemset) (lzo_hvoid_p s, int c, lzo_hsize_t len) { #if (LZO_HAVE_MM_HUGE_PTR) || !defined(HAVE_MEMSET) lzo_hbyte_p p = (lzo_hbyte_p) s; if __lzo_likely(len > 0) do *p++ = (unsigned char) c; while __lzo_likely(--len > 0); return s; #else return memset(s, c, len); #endif } #undef LZOLIB_PUBLIC #endif #if !defined(__LZO_IN_MINILZO) #define ACC_WANT_ACC_CHK_CH 1 #undef ACCCHK_ASSERT ACCCHK_ASSERT_IS_SIGNED_T(lzo_int) ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint) ACCCHK_ASSERT_IS_SIGNED_T(lzo_int32) ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uint32) ACCCHK_ASSERT((LZO_UINT32_C(1) << (int)(8*sizeof(LZO_UINT32_C(1))-1)) > 0) ACCCHK_ASSERT(sizeof(lzo_uint32) >= 4) #if !defined(__LZO_UINTPTR_T_IS_POINTER) ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_uintptr_t) #endif ACCCHK_ASSERT(sizeof(lzo_uintptr_t) >= sizeof(lzo_voidp)) ACCCHK_ASSERT_IS_UNSIGNED_T(lzo_xint) ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint32)) ACCCHK_ASSERT(sizeof(lzo_xint) >= sizeof(lzo_uint)) ACCCHK_ASSERT(sizeof(lzo_xint) == sizeof(lzo_uint32) || sizeof(lzo_xint) == sizeof(lzo_uint)) #endif #undef ACCCHK_ASSERT LZO_PUBLIC(int) _lzo_config_check(void) { lzo_bool r = 1; union { unsigned char c[2*sizeof(lzo_xint)]; lzo_xint l[2]; } u; lzo_uintptr_t p; #if !defined(LZO_CFG_NO_CONFIG_CHECK) #if defined(LZO_ABI_BIG_ENDIAN) u.l[0] = u.l[1] = 0; u.c[sizeof(lzo_xint) - 1] = 128; r &= (u.l[0] == 128); #endif #if defined(LZO_ABI_LITTLE_ENDIAN) u.l[0] = u.l[1] = 0; u.c[0] = 128; r &= (u.l[0] == 128); #endif #if defined(LZO_UNALIGNED_OK_2) p = (lzo_uintptr_t) (const lzo_voidp) &u.c[0]; u.l[0] = u.l[1] = 0; r &= ((* (const lzo_ushortp) (p+1)) == 0); #endif #if defined(LZO_UNALIGNED_OK_4) p = (lzo_uintptr_t) (const lzo_voidp) &u.c[0]; u.l[0] = u.l[1] = 0; r &= ((* (const lzo_uint32p) (p+1)) == 0); #endif #endif LZO_UNUSED(u); LZO_UNUSED(p); return r == 1 ? LZO_E_OK : LZO_E_ERROR; } int __lzo_init_done = 0; LZO_PUBLIC(int) __lzo_init_v2(unsigned v, int s1, int s2, int s3, int s4, int s5, int s6, int s7, int s8, int s9) { int r; #if defined(__LZO_IN_MINILZO) #elif (LZO_CC_MSC && ((_MSC_VER) < 700)) #else #define ACC_WANT_ACC_CHK_CH 1 #undef ACCCHK_ASSERT #define ACCCHK_ASSERT(expr) LZO_COMPILE_TIME_ASSERT(expr) #endif #undef ACCCHK_ASSERT __lzo_init_done = 1; if (v == 0) return LZO_E_ERROR; r = (s1 == -1 || s1 == (int) sizeof(short)) && (s2 == -1 || s2 == (int) sizeof(int)) && (s3 == -1 || s3 == (int) sizeof(long)) && (s4 == -1 || s4 == (int) sizeof(lzo_uint32)) && (s5 == -1 || s5 == (int) sizeof(lzo_uint)) && (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) && (s7 == -1 || s7 == (int) sizeof(char *)) && (s8 == -1 || s8 == (int) sizeof(lzo_voidp)) && (s9 == -1 || s9 == (int) sizeof(lzo_callback_t)); if (!r) return LZO_E_ERROR; r = _lzo_config_check(); if (r != LZO_E_OK) return r; return r; } #if !defined(__LZO_IN_MINILZO) #if (LZO_OS_WIN16 && LZO_CC_WATCOMC) && defined(__SW_BD) #if 0 BOOL FAR PASCAL LibMain ( HANDLE hInstance, WORD wDataSegment, WORD wHeapSize, LPSTR lpszCmdLine ) #else int __far __pascal LibMain ( int a, short b, short c, long d ) #endif { LZO_UNUSED(a); LZO_UNUSED(b); LZO_UNUSED(c); LZO_UNUSED(d); return 1; } #endif #endif #define do_compress _lzo1x_1_do_compress #if !defined(MINILZO_CFG_SKIP_LZO1X_1_COMPRESS) #define LZO_NEED_DICT_H #define D_BITS 14 #define D_INDEX1(d,p) d = DM(DMUL(0x21,DX3(p,5,5,6)) >> 5) #define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f) #ifndef __LZO_CONFIG1X_H #define __LZO_CONFIG1X_H #if !defined(LZO1X) && !defined(LZO1Y) && !defined(LZO1Z) # define LZO1X #endif #if !defined(__LZO_IN_MINILZO) #include "lzo/lzo1x.h" #endif #define LZO_EOF_CODE #undef LZO_DETERMINISTIC #define M1_MAX_OFFSET 0x0400 #ifndef M2_MAX_OFFSET #define M2_MAX_OFFSET 0x0800 #endif #define M3_MAX_OFFSET 0x4000 #define M4_MAX_OFFSET 0xbfff #define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET) #define M1_MIN_LEN 2 #define M1_MAX_LEN 2 #define M2_MIN_LEN 3 #ifndef M2_MAX_LEN #define M2_MAX_LEN 8 #endif #define M3_MIN_LEN 3 #define M3_MAX_LEN 33 #define M4_MIN_LEN 3 #define M4_MAX_LEN 9 #define M1_MARKER 0 #define M2_MARKER 64 #define M3_MARKER 32 #define M4_MARKER 16 #ifndef MIN_LOOKAHEAD #define MIN_LOOKAHEAD (M2_MAX_LEN + 1) #endif #if defined(LZO_NEED_DICT_H) #ifndef LZO_HASH #define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B #endif #define DL_MIN_LEN M2_MIN_LEN #ifndef __LZO_DICT_H #define __LZO_DICT_H #ifdef __cplusplus extern "C" { #endif #if !defined(D_BITS) && defined(DBITS) # define D_BITS DBITS #endif #if !defined(D_BITS) # error "D_BITS is not defined" #endif #if (D_BITS < 16) # define D_SIZE LZO_SIZE(D_BITS) # define D_MASK LZO_MASK(D_BITS) #else # define D_SIZE LZO_USIZE(D_BITS) # define D_MASK LZO_UMASK(D_BITS) #endif #define D_HIGH ((D_MASK >> 1) + 1) #if !defined(DD_BITS) # define DD_BITS 0 #endif #define DD_SIZE LZO_SIZE(DD_BITS) #define DD_MASK LZO_MASK(DD_BITS) #if !defined(DL_BITS) # define DL_BITS (D_BITS - DD_BITS) #endif #if (DL_BITS < 16) # define DL_SIZE LZO_SIZE(DL_BITS) # define DL_MASK LZO_MASK(DL_BITS) #else # define DL_SIZE LZO_USIZE(DL_BITS) # define DL_MASK LZO_UMASK(DL_BITS) #endif #if (D_BITS != DL_BITS + DD_BITS) # error "D_BITS does not match" #endif #if (D_BITS < 8 || D_BITS > 18) # error "invalid D_BITS" #endif #if (DL_BITS < 8 || DL_BITS > 20) # error "invalid DL_BITS" #endif #if (DD_BITS < 0 || DD_BITS > 6) # error "invalid DD_BITS" #endif #if !defined(DL_MIN_LEN) # define DL_MIN_LEN 3 #endif #if !defined(DL_SHIFT) # define DL_SHIFT ((DL_BITS + (DL_MIN_LEN - 1)) / DL_MIN_LEN) #endif #define LZO_HASH_GZIP 1 #define LZO_HASH_GZIP_INCREMENTAL 2 #define LZO_HASH_LZO_INCREMENTAL_A 3 #define LZO_HASH_LZO_INCREMENTAL_B 4 #if !defined(LZO_HASH) # error "choose a hashing strategy" #endif #undef DM #undef DX #if (DL_MIN_LEN == 3) # define _DV2_A(p,shift1,shift2) \ (((( (lzo_xint)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2]) # define _DV2_B(p,shift1,shift2) \ (((( (lzo_xint)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0]) # define _DV3_B(p,shift1,shift2,shift3) \ ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0]) #elif (DL_MIN_LEN == 2) # define _DV2_A(p,shift1,shift2) \ (( (lzo_xint)(p[0]) << shift1) ^ p[1]) # define _DV2_B(p,shift1,shift2) \ (( (lzo_xint)(p[1]) << shift1) ^ p[2]) #else # error "invalid DL_MIN_LEN" #endif #define _DV_A(p,shift) _DV2_A(p,shift,shift) #define _DV_B(p,shift) _DV2_B(p,shift,shift) #define DA2(p,s1,s2) \ (((((lzo_xint)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0]) #define DS2(p,s1,s2) \ (((((lzo_xint)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0]) #define DX2(p,s1,s2) \ (((((lzo_xint)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0]) #define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0]) #define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0]) #define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0]) #define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s))) #define DM(v) DMS(v,0) #if (LZO_HASH == LZO_HASH_GZIP) # define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT)) #elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL) # define __LZO_HASH_INCREMENTAL # define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT) # define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2]) # define _DINDEX(dv,p) (dv) # define DVAL_LOOKAHEAD DL_MIN_LEN #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A) # define __LZO_HASH_INCREMENTAL # define DVAL_FIRST(dv,p) dv = _DV_A((p),5) # define DVAL_NEXT(dv,p) \ dv ^= (lzo_xint)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2]) # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5) # define DVAL_LOOKAHEAD DL_MIN_LEN #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B) # define __LZO_HASH_INCREMENTAL # define DVAL_FIRST(dv,p) dv = _DV_B((p),5) # define DVAL_NEXT(dv,p) \ dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_xint)(p[2]) << (2*5))) # define _DINDEX(dv,p) ((DMUL(0x9f5f,dv)) >> 5) # define DVAL_LOOKAHEAD DL_MIN_LEN #else # error "choose a hashing strategy" #endif #ifndef DINDEX #define DINDEX(dv,p) ((lzo_uint)((_DINDEX(dv,p)) & DL_MASK) << DD_BITS) #endif #if !defined(DINDEX1) && defined(D_INDEX1) #define DINDEX1 D_INDEX1 #endif #if !defined(DINDEX2) && defined(D_INDEX2) #define DINDEX2 D_INDEX2 #endif #if !defined(__LZO_HASH_INCREMENTAL) # define DVAL_FIRST(dv,p) ((void) 0) # define DVAL_NEXT(dv,p) ((void) 0) # define DVAL_LOOKAHEAD 0 #endif #if !defined(DVAL_ASSERT) #if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG) static void DVAL_ASSERT(lzo_xint dv, const lzo_bytep p) { lzo_xint df; DVAL_FIRST(df,(p)); assert(DINDEX(dv,p) == DINDEX(df,p)); } #else # define DVAL_ASSERT(dv,p) ((void) 0) #endif #endif #if defined(LZO_DICT_USE_PTR) # define DENTRY(p,in) (p) # define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex] #else # define DENTRY(p,in) ((lzo_uint) ((p)-(in))) # define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex] #endif #if (DD_BITS == 0) # define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in) # define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in) # define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in) #else # define UPDATE_D(dict,drun,dv,p,in) \ dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK # define UPDATE_I(dict,drun,index,p,in) \ dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK # define UPDATE_P(ptr,drun,p,in) \ (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK #endif #if defined(LZO_DICT_USE_PTR) #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \ (m_pos == NULL || (m_off = pd(ip, m_pos)) > max_offset) #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \ (BOUNDS_CHECKING_OFF_IN_EXPR(( \ m_pos = ip - (lzo_uint) PTR_DIFF(ip,m_pos), \ PTR_LT(m_pos,in) || \ (m_off = (lzo_uint) PTR_DIFF(ip,m_pos)) <= 0 || \ m_off > max_offset ))) #else #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \ (m_off == 0 || \ ((m_off = pd(ip, in) - m_off) > max_offset) || \ (m_pos = (ip) - (m_off), 0) ) #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \ (pd(ip, in) <= m_off || \ ((m_off = pd(ip, in) - m_off) > max_offset) || \ (m_pos = (ip) - (m_off), 0) ) #endif #if defined(LZO_DETERMINISTIC) # define LZO_CHECK_MPOS LZO_CHECK_MPOS_DET #else # define LZO_CHECK_MPOS LZO_CHECK_MPOS_NON_DET #endif #ifdef __cplusplus } #endif #endif #endif #endif #define DO_COMPRESS lzo1x_1_compress static __lzo_noinline lzo_uint do_compress ( const lzo_bytep in , lzo_uint in_len, lzo_bytep out, lzo_uintp out_len, lzo_voidp wrkmem ) { register const lzo_bytep ip; lzo_bytep op; const lzo_bytep const in_end = in + in_len; const lzo_bytep const ip_end = in + in_len - M2_MAX_LEN - 5; const lzo_bytep ii; lzo_dict_p const dict = (lzo_dict_p) wrkmem; op = out; ip = in; ii = ip; ip += 4; for (;;) { register const lzo_bytep m_pos; lzo_uint m_off; lzo_uint m_len; lzo_uint dindex; DINDEX1(dindex,ip); GINDEX(m_pos,m_off,dict,dindex,in); if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET)) goto literal; #if 1 if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) goto try_match; DINDEX2(dindex,ip); #endif GINDEX(m_pos,m_off,dict,dindex,in); if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET)) goto literal; if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3]) goto try_match; goto literal; try_match: #if 1 && defined(LZO_UNALIGNED_OK_2) if (* (const lzo_ushortp) m_pos != * (const lzo_ushortp) ip) #else if (m_pos[0] != ip[0] || m_pos[1] != ip[1]) #endif { } else { if __lzo_likely(m_pos[2] == ip[2]) { #if 0 if (m_off <= M2_MAX_OFFSET) goto match; if (lit <= 3) goto match; if (lit == 3) { assert(op - 2 > out); op[-2] |= LZO_BYTE(3); *op++ = *ii++; *op++ = *ii++; *op++ = *ii++; goto code_match; } if (m_pos[3] == ip[3]) #endif goto match; } else { #if 0 #if 0 if (m_off <= M1_MAX_OFFSET && lit > 0 && lit <= 3) #else if (m_off <= M1_MAX_OFFSET && lit == 3) #endif { register lzo_uint t; t = lit; assert(op - 2 > out); op[-2] |= LZO_BYTE(t); do *op++ = *ii++; while (--t > 0); assert(ii == ip); m_off -= 1; *op++ = LZO_BYTE(M1_MARKER | ((m_off & 3) << 2)); *op++ = LZO_BYTE(m_off >> 2); ip += 2; goto match_done; } #endif } } literal: UPDATE_I(dict,0,dindex,ip,in); ++ip; if __lzo_unlikely(ip >= ip_end) break; continue; match: UPDATE_I(dict,0,dindex,ip,in); if (pd(ip,ii) > 0) { register lzo_uint t = pd(ip,ii); if (t <= 3) { assert(op - 2 > out); op[-2] |= LZO_BYTE(t); } else if (t <= 18) *op++ = LZO_BYTE(t - 3); else { register lzo_uint tt = t - 18; *op++ = 0; while (tt > 255) { tt -= 255; *op++ = 0; } assert(tt > 0); *op++ = LZO_BYTE(tt); } do *op++ = *ii++; while (--t > 0); } assert(ii == ip); ip += 3; if (m_pos[3] != *ip++ || m_pos[4] != *ip++ || m_pos[5] != *ip++ || m_pos[6] != *ip++ || m_pos[7] != *ip++ || m_pos[8] != *ip++ #ifdef LZO1Y || m_pos[ 9] != *ip++ || m_pos[10] != *ip++ || m_pos[11] != *ip++ || m_pos[12] != *ip++ || m_pos[13] != *ip++ || m_pos[14] != *ip++ #endif ) { --ip; m_len = pd(ip, ii); assert(m_len >= 3); assert(m_len <= M2_MAX_LEN); if (m_off <= M2_MAX_OFFSET) { m_off -= 1; #if defined(LZO1X) *op++ = LZO_BYTE(((m_len - 1) << 5) | ((m_off & 7) << 2)); *op++ = LZO_BYTE(m_off >> 3); #elif defined(LZO1Y) *op++ = LZO_BYTE(((m_len + 1) << 4) | ((m_off & 3) << 2)); *op++ = LZO_BYTE(m_off >> 2); #endif } else if (m_off <= M3_MAX_OFFSET) { m_off -= 1; *op++ = LZO_BYTE(M3_MARKER | (m_len - 2)); goto m3_m4_offset; } else #if defined(LZO1X) { m_off -= 0x4000; assert(m_off > 0); assert(m_off <= 0x7fff); *op++ = LZO_BYTE(M4_MARKER | ((m_off & 0x4000) >> 11) | (m_len - 2)); goto m3_m4_offset; } #elif defined(LZO1Y) goto m4_match; #endif } else { { const lzo_bytep end = in_end; const lzo_bytep m = m_pos + M2_MAX_LEN + 1; while (ip < end && *m == *ip) m++, ip++; m_len = pd(ip, ii); } assert(m_len > M2_MAX_LEN); if (m_off <= M3_MAX_OFFSET) { m_off -= 1; if (m_len <= 33) *op++ = LZO_BYTE(M3_MARKER | (m_len - 2)); else { m_len -= 33; *op++ = M3_MARKER | 0; goto m3_m4_len; } } else { #if defined(LZO1Y) m4_match: #endif m_off -= 0x4000; assert(m_off > 0); assert(m_off <= 0x7fff); if (m_len <= M4_MAX_LEN) *op++ = LZO_BYTE(M4_MARKER | ((m_off & 0x4000) >> 11) | (m_len - 2)); else { m_len -= M4_MAX_LEN; *op++ = LZO_BYTE(M4_MARKER | ((m_off & 0x4000) >> 11)); m3_m4_len: while (m_len > 255) { m_len -= 255; *op++ = 0; } assert(m_len > 0); *op++ = LZO_BYTE(m_len); } } m3_m4_offset: *op++ = LZO_BYTE((m_off & 63) << 2); *op++ = LZO_BYTE(m_off >> 6); } #if 0 match_done: #endif ii = ip; if __lzo_unlikely(ip >= ip_end) break; } *out_len = pd(op, out); return pd(in_end,ii); } LZO_PUBLIC(int) DO_COMPRESS ( const lzo_bytep in , lzo_uint in_len, lzo_bytep out, lzo_uintp out_len, lzo_voidp wrkmem ) { lzo_bytep op = out; lzo_uint t; if __lzo_unlikely(in_len <= M2_MAX_LEN + 5) t = in_len; else { t = do_compress(in,in_len,op,out_len,wrkmem); op += *out_len; } if (t > 0) { const lzo_bytep ii = in + in_len - t; if (op == out && t <= 238) *op++ = LZO_BYTE(17 + t); else if (t <= 3) op[-2] |= LZO_BYTE(t); else if (t <= 18) *op++ = LZO_BYTE(t - 3); else { lzo_uint tt = t - 18; *op++ = 0; while (tt > 255) { tt -= 255; *op++ = 0; } assert(tt > 0); *op++ = LZO_BYTE(tt); } do *op++ = *ii++; while (--t > 0); } *op++ = M4_MARKER | 1; *op++ = 0; *op++ = 0; *out_len = pd(op, out); return LZO_E_OK; } #endif #undef do_compress #undef DO_COMPRESS #undef LZO_HASH #undef LZO_TEST_OVERRUN #undef DO_DECOMPRESS #define DO_DECOMPRESS lzo1x_decompress #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS) #if defined(LZO_TEST_OVERRUN) # if !defined(LZO_TEST_OVERRUN_INPUT) # define LZO_TEST_OVERRUN_INPUT 2 # endif # if !defined(LZO_TEST_OVERRUN_OUTPUT) # define LZO_TEST_OVERRUN_OUTPUT 2 # endif # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND) # define LZO_TEST_OVERRUN_LOOKBEHIND # endif #endif #undef TEST_IP #undef TEST_OP #undef TEST_LB #undef TEST_LBO #undef NEED_IP #undef NEED_OP #undef HAVE_TEST_IP #undef HAVE_TEST_OP #undef HAVE_NEED_IP #undef HAVE_NEED_OP #undef HAVE_ANY_IP #undef HAVE_ANY_OP #if defined(LZO_TEST_OVERRUN_INPUT) # if (LZO_TEST_OVERRUN_INPUT >= 1) # define TEST_IP (ip < ip_end) # endif # if (LZO_TEST_OVERRUN_INPUT >= 2) # define NEED_IP(x) \ if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun # endif #endif #if defined(LZO_TEST_OVERRUN_OUTPUT) # if (LZO_TEST_OVERRUN_OUTPUT >= 1) # define TEST_OP (op <= op_end) # endif # if (LZO_TEST_OVERRUN_OUTPUT >= 2) # undef TEST_OP # define NEED_OP(x) \ if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun # endif #endif #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun # define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun #else # define TEST_LB(m_pos) ((void) 0) # define TEST_LBO(m_pos,o) ((void) 0) #endif #if !defined(LZO_EOF_CODE) && !defined(TEST_IP) # define TEST_IP (ip < ip_end) #endif #if defined(TEST_IP) # define HAVE_TEST_IP #else # define TEST_IP 1 #endif #if defined(TEST_OP) # define HAVE_TEST_OP #else # define TEST_OP 1 #endif #if defined(NEED_IP) # define HAVE_NEED_IP #else # define NEED_IP(x) ((void) 0) #endif #if defined(NEED_OP) # define HAVE_NEED_OP #else # define NEED_OP(x) ((void) 0) #endif #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) # define HAVE_ANY_IP #endif #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP) # define HAVE_ANY_OP #endif #undef __COPY4 #define __COPY4(dst,src) * (lzo_uint32p)(dst) = * (const lzo_uint32p)(src) #undef COPY4 #if defined(LZO_UNALIGNED_OK_4) # define COPY4(dst,src) __COPY4(dst,src) #elif defined(LZO_ALIGNED_OK_4) # define COPY4(dst,src) __COPY4((lzo_uintptr_t)(dst),(lzo_uintptr_t)(src)) #endif #if defined(DO_DECOMPRESS) LZO_PUBLIC(int) DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, lzo_bytep out, lzo_uintp out_len, lzo_voidp wrkmem ) #endif { register lzo_bytep op; register const lzo_bytep ip; register lzo_uint t; #if defined(COPY_DICT) lzo_uint m_off; const lzo_bytep dict_end; #else register const lzo_bytep m_pos; #endif const lzo_bytep const ip_end = in + in_len; #if defined(HAVE_ANY_OP) lzo_bytep const op_end = out + *out_len; #endif #if defined(LZO1Z) lzo_uint last_m_off = 0; #endif LZO_UNUSED(wrkmem); #if defined(COPY_DICT) if (dict) { if (dict_len > M4_MAX_OFFSET) { dict += dict_len - M4_MAX_OFFSET; dict_len = M4_MAX_OFFSET; } dict_end = dict + dict_len; } else { dict_len = 0; dict_end = NULL; } #endif *out_len = 0; op = out; ip = in; if (*ip > 17) { t = *ip++ - 17; if (t < 4) goto match_next; assert(t > 0); NEED_OP(t); NEED_IP(t+1); do *op++ = *ip++; while (--t > 0); goto first_literal_run; } while (TEST_IP && TEST_OP) { t = *ip++; if (t >= 16) goto match; if (t == 0) { NEED_IP(1); while (*ip == 0) { t += 255; ip++; NEED_IP(1); } t += 15 + *ip++; } assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) #if !defined(LZO_UNALIGNED_OK_4) if (PTR_ALIGNED2_4(op,ip)) { #endif COPY4(op,ip); op += 4; ip += 4; if (--t > 0) { if (t >= 4) { do { COPY4(op,ip); op += 4; ip += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *ip++; while (--t > 0); } else do *op++ = *ip++; while (--t > 0); } #if !defined(LZO_UNALIGNED_OK_4) } else #endif #endif #if !defined(LZO_UNALIGNED_OK_4) { *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; do *op++ = *ip++; while (--t > 0); } #endif first_literal_run: t = *ip++; if (t >= 16) goto match; #if defined(COPY_DICT) #if defined(LZO1Z) m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); last_m_off = m_off; #else m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2); #endif NEED_OP(3); t = 3; COPY_DICT(t,m_off) #else #if defined(LZO1Z) t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); m_pos = op - t; last_m_off = t; #else m_pos = op - (1 + M2_MAX_OFFSET); m_pos -= t >> 2; m_pos -= *ip++ << 2; #endif TEST_LB(m_pos); NEED_OP(3); *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos; #endif goto match_done; do { match: if (t >= 64) { #if defined(COPY_DICT) #if defined(LZO1X) m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3); t = (t >> 5) - 1; #elif defined(LZO1Y) m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2); t = (t >> 4) - 3; #elif defined(LZO1Z) m_off = t & 0x1f; if (m_off >= 0x1c) m_off = last_m_off; else { m_off = 1 + (m_off << 6) + (*ip++ >> 2); last_m_off = m_off; } t = (t >> 5) - 1; #endif #else #if defined(LZO1X) m_pos = op - 1; m_pos -= (t >> 2) & 7; m_pos -= *ip++ << 3; t = (t >> 5) - 1; #elif defined(LZO1Y) m_pos = op - 1; m_pos -= (t >> 2) & 3; m_pos -= *ip++ << 2; t = (t >> 4) - 3; #elif defined(LZO1Z) { lzo_uint off = t & 0x1f; m_pos = op; if (off >= 0x1c) { assert(last_m_off > 0); m_pos -= last_m_off; } else { off = 1 + (off << 6) + (*ip++ >> 2); m_pos -= off; last_m_off = off; } } t = (t >> 5) - 1; #endif TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); goto copy_match; #endif } else if (t >= 32) { t &= 31; if (t == 0) { NEED_IP(1); while (*ip == 0) { t += 255; ip++; NEED_IP(1); } t += 31 + *ip++; } #if defined(COPY_DICT) #if defined(LZO1Z) m_off = 1 + (ip[0] << 6) + (ip[1] >> 2); last_m_off = m_off; #else m_off = 1 + (ip[0] >> 2) + (ip[1] << 6); #endif #else #if defined(LZO1Z) { lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2); m_pos = op - off; last_m_off = off; } #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) m_pos = op - 1; m_pos -= (* (const lzo_ushortp) ip) >> 2; #else m_pos = op - 1; m_pos -= (ip[0] >> 2) + (ip[1] << 6); #endif #endif ip += 2; } else if (t >= 16) { #if defined(COPY_DICT) m_off = (t & 8) << 11; #else m_pos = op; m_pos -= (t & 8) << 11; #endif t &= 7; if (t == 0) { NEED_IP(1); while (*ip == 0) { t += 255; ip++; NEED_IP(1); } t += 7 + *ip++; } #if defined(COPY_DICT) #if defined(LZO1Z) m_off += (ip[0] << 6) + (ip[1] >> 2); #else m_off += (ip[0] >> 2) + (ip[1] << 6); #endif ip += 2; if (m_off == 0) goto eof_found; m_off += 0x4000; #if defined(LZO1Z) last_m_off = m_off; #endif #else #if defined(LZO1Z) m_pos -= (ip[0] << 6) + (ip[1] >> 2); #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) m_pos -= (* (const lzo_ushortp) ip) >> 2; #else m_pos -= (ip[0] >> 2) + (ip[1] << 6); #endif ip += 2; if (m_pos == op) goto eof_found; m_pos -= 0x4000; #if defined(LZO1Z) last_m_off = pd((const lzo_bytep)op, m_pos); #endif #endif } else { #if defined(COPY_DICT) #if defined(LZO1Z) m_off = 1 + (t << 6) + (*ip++ >> 2); last_m_off = m_off; #else m_off = 1 + (t >> 2) + (*ip++ << 2); #endif NEED_OP(2); t = 2; COPY_DICT(t,m_off) #else #if defined(LZO1Z) t = 1 + (t << 6) + (*ip++ >> 2); m_pos = op - t; last_m_off = t; #else m_pos = op - 1; m_pos -= t >> 2; m_pos -= *ip++ << 2; #endif TEST_LB(m_pos); NEED_OP(2); *op++ = *m_pos++; *op++ = *m_pos; #endif goto match_done; } #if defined(COPY_DICT) NEED_OP(t+3-1); t += 3-1; COPY_DICT(t,m_off) #else TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) #if !defined(LZO_UNALIGNED_OK_4) if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) { assert((op - m_pos) >= 4); #else if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) { #endif COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4 - (3 - 1); do { COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *m_pos++; while (--t > 0); } else #endif { copy_match: *op++ = *m_pos++; *op++ = *m_pos++; do *op++ = *m_pos++; while (--t > 0); } #endif match_done: #if defined(LZO1Z) t = ip[-1] & 3; #else t = ip[-2] & 3; #endif if (t == 0) break; match_next: assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); #if 0 do *op++ = *ip++; while (--t > 0); #else *op++ = *ip++; if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } #endif t = *ip++; } while (TEST_IP && TEST_OP); } #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) *out_len = pd(op, out); return LZO_E_EOF_NOT_FOUND; #endif eof_found: assert(t == 1); *out_len = pd(op, out); return (ip == ip_end ? LZO_E_OK : (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); #if defined(HAVE_NEED_IP) input_overrun: *out_len = pd(op, out); return LZO_E_INPUT_OVERRUN; #endif #if defined(HAVE_NEED_OP) output_overrun: *out_len = pd(op, out); return LZO_E_OUTPUT_OVERRUN; #endif #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) lookbehind_overrun: *out_len = pd(op, out); return LZO_E_LOOKBEHIND_OVERRUN; #endif } #endif #define LZO_TEST_OVERRUN #undef DO_DECOMPRESS #define DO_DECOMPRESS lzo1x_decompress_safe #if !defined(MINILZO_CFG_SKIP_LZO1X_DECOMPRESS_SAFE) #if defined(LZO_TEST_OVERRUN) # if !defined(LZO_TEST_OVERRUN_INPUT) # define LZO_TEST_OVERRUN_INPUT 2 # endif # if !defined(LZO_TEST_OVERRUN_OUTPUT) # define LZO_TEST_OVERRUN_OUTPUT 2 # endif # if !defined(LZO_TEST_OVERRUN_LOOKBEHIND) # define LZO_TEST_OVERRUN_LOOKBEHIND # endif #endif #undef TEST_IP #undef TEST_OP #undef TEST_LB #undef TEST_LBO #undef NEED_IP #undef NEED_OP #undef HAVE_TEST_IP #undef HAVE_TEST_OP #undef HAVE_NEED_IP #undef HAVE_NEED_OP #undef HAVE_ANY_IP #undef HAVE_ANY_OP #if defined(LZO_TEST_OVERRUN_INPUT) # if (LZO_TEST_OVERRUN_INPUT >= 1) # define TEST_IP (ip < ip_end) # endif # if (LZO_TEST_OVERRUN_INPUT >= 2) # define NEED_IP(x) \ if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun # endif #endif #if defined(LZO_TEST_OVERRUN_OUTPUT) # if (LZO_TEST_OVERRUN_OUTPUT >= 1) # define TEST_OP (op <= op_end) # endif # if (LZO_TEST_OVERRUN_OUTPUT >= 2) # undef TEST_OP # define NEED_OP(x) \ if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun # endif #endif #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) # define TEST_LB(m_pos) if (m_pos < out || m_pos >= op) goto lookbehind_overrun # define TEST_LBO(m_pos,o) if (m_pos < out || m_pos >= op - (o)) goto lookbehind_overrun #else # define TEST_LB(m_pos) ((void) 0) # define TEST_LBO(m_pos,o) ((void) 0) #endif #if !defined(LZO_EOF_CODE) && !defined(TEST_IP) # define TEST_IP (ip < ip_end) #endif #if defined(TEST_IP) # define HAVE_TEST_IP #else # define TEST_IP 1 #endif #if defined(TEST_OP) # define HAVE_TEST_OP #else # define TEST_OP 1 #endif #if defined(NEED_IP) # define HAVE_NEED_IP #else # define NEED_IP(x) ((void) 0) #endif #if defined(NEED_OP) # define HAVE_NEED_OP #else # define NEED_OP(x) ((void) 0) #endif #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP) # define HAVE_ANY_IP #endif #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP) # define HAVE_ANY_OP #endif #undef __COPY4 #define __COPY4(dst,src) * (lzo_uint32p)(dst) = * (const lzo_uint32p)(src) #undef COPY4 #if defined(LZO_UNALIGNED_OK_4) # define COPY4(dst,src) __COPY4(dst,src) #elif defined(LZO_ALIGNED_OK_4) # define COPY4(dst,src) __COPY4((lzo_uintptr_t)(dst),(lzo_uintptr_t)(src)) #endif #if defined(DO_DECOMPRESS) LZO_PUBLIC(int) DO_DECOMPRESS ( const lzo_bytep in , lzo_uint in_len, lzo_bytep out, lzo_uintp out_len, lzo_voidp wrkmem ) #endif { register lzo_bytep op; register const lzo_bytep ip; register lzo_uint t; #if defined(COPY_DICT) lzo_uint m_off; const lzo_bytep dict_end; #else register const lzo_bytep m_pos; #endif const lzo_bytep const ip_end = in + in_len; #if defined(HAVE_ANY_OP) lzo_bytep const op_end = out + *out_len; #endif #if defined(LZO1Z) lzo_uint last_m_off = 0; #endif LZO_UNUSED(wrkmem); #if defined(COPY_DICT) if (dict) { if (dict_len > M4_MAX_OFFSET) { dict += dict_len - M4_MAX_OFFSET; dict_len = M4_MAX_OFFSET; } dict_end = dict + dict_len; } else { dict_len = 0; dict_end = NULL; } #endif *out_len = 0; op = out; ip = in; if (*ip > 17) { t = *ip++ - 17; if (t < 4) goto match_next; assert(t > 0); NEED_OP(t); NEED_IP(t+1); do *op++ = *ip++; while (--t > 0); goto first_literal_run; } while (TEST_IP && TEST_OP) { t = *ip++; if (t >= 16) goto match; if (t == 0) { NEED_IP(1); while (*ip == 0) { t += 255; ip++; NEED_IP(1); } t += 15 + *ip++; } assert(t > 0); NEED_OP(t+3); NEED_IP(t+4); #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) #if !defined(LZO_UNALIGNED_OK_4) if (PTR_ALIGNED2_4(op,ip)) { #endif COPY4(op,ip); op += 4; ip += 4; if (--t > 0) { if (t >= 4) { do { COPY4(op,ip); op += 4; ip += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *ip++; while (--t > 0); } else do *op++ = *ip++; while (--t > 0); } #if !defined(LZO_UNALIGNED_OK_4) } else #endif #endif #if !defined(LZO_UNALIGNED_OK_4) { *op++ = *ip++; *op++ = *ip++; *op++ = *ip++; do *op++ = *ip++; while (--t > 0); } #endif first_literal_run: t = *ip++; if (t >= 16) goto match; #if defined(COPY_DICT) #if defined(LZO1Z) m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); last_m_off = m_off; #else m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2); #endif NEED_OP(3); t = 3; COPY_DICT(t,m_off) #else #if defined(LZO1Z) t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2); m_pos = op - t; last_m_off = t; #else m_pos = op - (1 + M2_MAX_OFFSET); m_pos -= t >> 2; m_pos -= *ip++ << 2; #endif TEST_LB(m_pos); NEED_OP(3); *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos; #endif goto match_done; do { match: if (t >= 64) { #if defined(COPY_DICT) #if defined(LZO1X) m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3); t = (t >> 5) - 1; #elif defined(LZO1Y) m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2); t = (t >> 4) - 3; #elif defined(LZO1Z) m_off = t & 0x1f; if (m_off >= 0x1c) m_off = last_m_off; else { m_off = 1 + (m_off << 6) + (*ip++ >> 2); last_m_off = m_off; } t = (t >> 5) - 1; #endif #else #if defined(LZO1X) m_pos = op - 1; m_pos -= (t >> 2) & 7; m_pos -= *ip++ << 3; t = (t >> 5) - 1; #elif defined(LZO1Y) m_pos = op - 1; m_pos -= (t >> 2) & 3; m_pos -= *ip++ << 2; t = (t >> 4) - 3; #elif defined(LZO1Z) { lzo_uint off = t & 0x1f; m_pos = op; if (off >= 0x1c) { assert(last_m_off > 0); m_pos -= last_m_off; } else { off = 1 + (off << 6) + (*ip++ >> 2); m_pos -= off; last_m_off = off; } } t = (t >> 5) - 1; #endif TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); goto copy_match; #endif } else if (t >= 32) { t &= 31; if (t == 0) { NEED_IP(1); while (*ip == 0) { t += 255; ip++; NEED_IP(1); } t += 31 + *ip++; } #if defined(COPY_DICT) #if defined(LZO1Z) m_off = 1 + (ip[0] << 6) + (ip[1] >> 2); last_m_off = m_off; #else m_off = 1 + (ip[0] >> 2) + (ip[1] << 6); #endif #else #if defined(LZO1Z) { lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2); m_pos = op - off; last_m_off = off; } #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) m_pos = op - 1; m_pos -= (* (const lzo_ushortp) ip) >> 2; #else m_pos = op - 1; m_pos -= (ip[0] >> 2) + (ip[1] << 6); #endif #endif ip += 2; } else if (t >= 16) { #if defined(COPY_DICT) m_off = (t & 8) << 11; #else m_pos = op; m_pos -= (t & 8) << 11; #endif t &= 7; if (t == 0) { NEED_IP(1); while (*ip == 0) { t += 255; ip++; NEED_IP(1); } t += 7 + *ip++; } #if defined(COPY_DICT) #if defined(LZO1Z) m_off += (ip[0] << 6) + (ip[1] >> 2); #else m_off += (ip[0] >> 2) + (ip[1] << 6); #endif ip += 2; if (m_off == 0) goto eof_found; m_off += 0x4000; #if defined(LZO1Z) last_m_off = m_off; #endif #else #if defined(LZO1Z) m_pos -= (ip[0] << 6) + (ip[1] >> 2); #elif defined(LZO_UNALIGNED_OK_2) && defined(LZO_ABI_LITTLE_ENDIAN) m_pos -= (* (const lzo_ushortp) ip) >> 2; #else m_pos -= (ip[0] >> 2) + (ip[1] << 6); #endif ip += 2; if (m_pos == op) goto eof_found; m_pos -= 0x4000; #if defined(LZO1Z) last_m_off = pd((const lzo_bytep)op, m_pos); #endif #endif } else { #if defined(COPY_DICT) #if defined(LZO1Z) m_off = 1 + (t << 6) + (*ip++ >> 2); last_m_off = m_off; #else m_off = 1 + (t >> 2) + (*ip++ << 2); #endif NEED_OP(2); t = 2; COPY_DICT(t,m_off) #else #if defined(LZO1Z) t = 1 + (t << 6) + (*ip++ >> 2); m_pos = op - t; last_m_off = t; #else m_pos = op - 1; m_pos -= t >> 2; m_pos -= *ip++ << 2; #endif TEST_LB(m_pos); NEED_OP(2); *op++ = *m_pos++; *op++ = *m_pos; #endif goto match_done; } #if defined(COPY_DICT) NEED_OP(t+3-1); t += 3-1; COPY_DICT(t,m_off) #else TEST_LB(m_pos); assert(t > 0); NEED_OP(t+3-1); #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4) #if !defined(LZO_UNALIGNED_OK_4) if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos)) { assert((op - m_pos) >= 4); #else if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) { #endif COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4 - (3 - 1); do { COPY4(op,m_pos); op += 4; m_pos += 4; t -= 4; } while (t >= 4); if (t > 0) do *op++ = *m_pos++; while (--t > 0); } else #endif { copy_match: *op++ = *m_pos++; *op++ = *m_pos++; do *op++ = *m_pos++; while (--t > 0); } #endif match_done: #if defined(LZO1Z) t = ip[-1] & 3; #else t = ip[-2] & 3; #endif if (t == 0) break; match_next: assert(t > 0); assert(t < 4); NEED_OP(t); NEED_IP(t+1); #if 0 do *op++ = *ip++; while (--t > 0); #else *op++ = *ip++; if (t > 1) { *op++ = *ip++; if (t > 2) { *op++ = *ip++; } } #endif t = *ip++; } while (TEST_IP && TEST_OP); } #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP) *out_len = pd(op, out); return LZO_E_EOF_NOT_FOUND; #endif eof_found: assert(t == 1); *out_len = pd(op, out); return (ip == ip_end ? LZO_E_OK : (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN)); #if defined(HAVE_NEED_IP) input_overrun: *out_len = pd(op, out); return LZO_E_INPUT_OVERRUN; #endif #if defined(HAVE_NEED_OP) output_overrun: *out_len = pd(op, out); return LZO_E_OUTPUT_OVERRUN; #endif #if defined(LZO_TEST_OVERRUN_LOOKBEHIND) lookbehind_overrun: *out_len = pd(op, out); return LZO_E_LOOKBEHIND_OVERRUN; #endif } #endif /***** End of minilzo.c *****/ ht-2.0.22/minilzo/lzodefs.h0000644000175000001440000020044211006065547012433 00000000000000/* lzodefs.h -- architecture, OS and compiler specific defines This file is part of the LZO real-time data compression library. Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. The LZO library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The LZO library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the LZO library; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Markus F.X.J. Oberhumer http://www.oberhumer.com/opensource/lzo/ */ #ifndef __LZODEFS_H_INCLUDED #define __LZODEFS_H_INCLUDED 1 #if defined(__CYGWIN32__) && !defined(__CYGWIN__) # define __CYGWIN__ __CYGWIN32__ #endif #if defined(__IBMCPP__) && !defined(__IBMC__) # define __IBMC__ __IBMCPP__ #endif #if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) # define __INTEL_COMPILER __ICL #endif #if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) # define _ALL_SOURCE 1 #endif #if defined(__mips__) && defined(__R5900__) # if !defined(__LONG_MAX__) # define __LONG_MAX__ 9223372036854775807L # endif #endif #if defined(__INTEL_COMPILER) && defined(__linux__) # pragma warning(disable: 193) #endif #if defined(__KEIL__) && defined(__C166__) # pragma warning disable = 322 #elif 0 && defined(__C251__) # pragma warning disable = 322 #endif #if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) # if (_MSC_VER >= 1300) # pragma warning(disable: 4668) # endif #endif #if 0 && defined(__WATCOMC__) # if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) # pragma warning 203 9 # endif #endif #if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) # pragma option -h #endif #if 0 #define LZO_0xffffL 0xfffful #define LZO_0xffffffffL 0xfffffffful #else #define LZO_0xffffL 65535ul #define LZO_0xffffffffL 4294967295ul #endif #if (LZO_0xffffL == LZO_0xffffffffL) # error "your preprocessor is broken 1" #endif #if (16ul * 16384ul != 262144ul) # error "your preprocessor is broken 2" #endif #if 0 #if (32767 >= 4294967295ul) # error "your preprocessor is broken 3" #endif #if (65535u >= 4294967295ul) # error "your preprocessor is broken 4" #endif #endif #if (UINT_MAX == LZO_0xffffL) #if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) # if !defined(MSDOS) # define MSDOS 1 # endif # if !defined(_MSDOS) # define _MSDOS 1 # endif #elif 0 && defined(__VERSION) && defined(MB_LEN_MAX) # if (__VERSION == 520) && (MB_LEN_MAX == 1) # if !defined(__AZTEC_C__) # define __AZTEC_C__ __VERSION # endif # if !defined(__DOS__) # define __DOS__ 1 # endif # endif #endif #endif #if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL) # define ptrdiff_t long # define _PTRDIFF_T_DEFINED #endif #if (UINT_MAX == LZO_0xffffL) # undef __LZO_RENAME_A # undef __LZO_RENAME_B # if defined(__AZTEC_C__) && defined(__DOS__) # define __LZO_RENAME_A 1 # elif defined(_MSC_VER) && defined(MSDOS) # if (_MSC_VER < 600) # define __LZO_RENAME_A 1 # elif (_MSC_VER < 700) # define __LZO_RENAME_B 1 # endif # elif defined(__TSC__) && defined(__OS2__) # define __LZO_RENAME_A 1 # elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410) # define __LZO_RENAME_A 1 # elif defined(__PACIFIC__) && defined(DOS) # if !defined(__far) # define __far far # endif # if !defined(__near) # define __near near # endif # endif # if defined(__LZO_RENAME_A) # if !defined(__cdecl) # define __cdecl cdecl # endif # if !defined(__far) # define __far far # endif # if !defined(__huge) # define __huge huge # endif # if !defined(__near) # define __near near # endif # if !defined(__pascal) # define __pascal pascal # endif # if !defined(__huge) # define __huge huge # endif # elif defined(__LZO_RENAME_B) # if !defined(__cdecl) # define __cdecl _cdecl # endif # if !defined(__far) # define __far _far # endif # if !defined(__huge) # define __huge _huge # endif # if !defined(__near) # define __near _near # endif # if !defined(__pascal) # define __pascal _pascal # endif # elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) # if !defined(__cdecl) # define __cdecl cdecl # endif # if !defined(__pascal) # define __pascal pascal # endif # endif # undef __LZO_RENAME_A # undef __LZO_RENAME_B #endif #if (UINT_MAX == LZO_0xffffL) #if defined(__AZTEC_C__) && defined(__DOS__) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 #elif defined(_MSC_VER) && defined(MSDOS) # if (_MSC_VER < 600) # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 # endif # if (_MSC_VER < 700) # define LZO_BROKEN_INTEGRAL_PROMOTION 1 # define LZO_BROKEN_SIZEOF 1 # endif #elif defined(__PACIFIC__) && defined(DOS) # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 #elif defined(__TURBOC__) && defined(__MSDOS__) # if (__TURBOC__ < 0x0150) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 # define LZO_BROKEN_INTEGRAL_PROMOTION 1 # endif # if (__TURBOC__ < 0x0200) # define LZO_BROKEN_SIZEOF 1 # endif # if (__TURBOC__ < 0x0400) && defined(__cplusplus) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 # endif #elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) # define LZO_BROKEN_CDECL_ALT_SYNTAX 1 # define LZO_BROKEN_SIZEOF 1 #endif #endif #if defined(__WATCOMC__) && (__WATCOMC__ < 900) # define LZO_BROKEN_INTEGRAL_CONSTANTS 1 #endif #if defined(_CRAY) && defined(_CRAY1) # define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1 #endif #define LZO_PP_STRINGIZE(x) #x #define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) #define LZO_PP_CONCAT2(a,b) a ## b #define LZO_PP_CONCAT3(a,b,c) a ## b ## c #define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d #define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e #define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) #define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) #define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) #define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) #if 1 #define LZO_CPP_STRINGIZE(x) #x #define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) #define LZO_CPP_CONCAT2(a,b) a ## b #define LZO_CPP_CONCAT3(a,b,c) a ## b ## c #define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d #define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e #define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) #define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) #define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) #define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) #endif #define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) #if 1 && defined(__cplusplus) # if !defined(__STDC_CONSTANT_MACROS) # define __STDC_CONSTANT_MACROS 1 # endif # if !defined(__STDC_LIMIT_MACROS) # define __STDC_LIMIT_MACROS 1 # endif #endif #if defined(__cplusplus) # define LZO_EXTERN_C extern "C" #else # define LZO_EXTERN_C extern #endif #if !defined(__LZO_OS_OVERRIDE) #if defined(LZO_OS_FREESTANDING) # define LZO_INFO_OS "freestanding" #elif defined(LZO_OS_EMBEDDED) # define LZO_INFO_OS "embedded" #elif 1 && defined(__IAR_SYSTEMS_ICC__) # define LZO_OS_EMBEDDED 1 # define LZO_INFO_OS "embedded" #elif defined(__CYGWIN__) && defined(__GNUC__) # define LZO_OS_CYGWIN 1 # define LZO_INFO_OS "cygwin" #elif defined(__EMX__) && defined(__GNUC__) # define LZO_OS_EMX 1 # define LZO_INFO_OS "emx" #elif defined(__BEOS__) # define LZO_OS_BEOS 1 # define LZO_INFO_OS "beos" #elif defined(__Lynx__) # define LZO_OS_LYNXOS 1 # define LZO_INFO_OS "lynxos" #elif defined(__OS400__) # define LZO_OS_OS400 1 # define LZO_INFO_OS "os400" #elif defined(__QNX__) # define LZO_OS_QNX 1 # define LZO_INFO_OS "qnx" #elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" #elif defined(__BORLANDC__) && defined(__DPMI16__) # define LZO_OS_DOS16 1 # define LZO_INFO_OS "dos16" #elif defined(__ZTC__) && defined(DOS386) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" #elif defined(__OS2__) || defined(__OS2V2__) # if (UINT_MAX == LZO_0xffffL) # define LZO_OS_OS216 1 # define LZO_INFO_OS "os216" # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_OS2 1 # define LZO_INFO_OS "os2" # else # error "check your limits.h header" # endif #elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64) # define LZO_OS_WIN64 1 # define LZO_INFO_OS "win64" #elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" #elif defined(__MWERKS__) && defined(__INTEL__) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" #elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) # if (UINT_MAX == LZO_0xffffL) # define LZO_OS_WIN16 1 # define LZO_INFO_OS "win16" # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" # else # error "check your limits.h header" # endif #elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS)) # if (UINT_MAX == LZO_0xffffL) # define LZO_OS_DOS16 1 # define LZO_INFO_OS "dos16" # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_OS_DOS32 1 # define LZO_INFO_OS "dos32" # else # error "check your limits.h header" # endif #elif defined(__WATCOMC__) # if defined(__NT__) && (UINT_MAX == LZO_0xffffL) # define LZO_OS_DOS16 1 # define LZO_INFO_OS "dos16" # elif defined(__NT__) && (__WATCOMC__ < 1100) # define LZO_OS_WIN32 1 # define LZO_INFO_OS "win32" # elif defined(__linux__) || defined(__LINUX__) # define LZO_OS_POSIX 1 # define LZO_INFO_OS "posix" # else # error "please specify a target using the -bt compiler option" # endif #elif defined(__palmos__) # define LZO_OS_PALMOS 1 # define LZO_INFO_OS "palmos" #elif defined(__TOS__) || defined(__atarist__) # define LZO_OS_TOS 1 # define LZO_INFO_OS "tos" #elif defined(macintosh) && !defined(__ppc__) # define LZO_OS_MACCLASSIC 1 # define LZO_INFO_OS "macclassic" #elif defined(__VMS) # define LZO_OS_VMS 1 # define LZO_INFO_OS "vms" #elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) # define LZO_OS_CONSOLE 1 # define LZO_OS_CONSOLE_PS2 1 # define LZO_INFO_OS "console" # define LZO_INFO_OS_CONSOLE "ps2" #elif (defined(__mips__) && defined(__psp__)) # define LZO_OS_CONSOLE 1 # define LZO_OS_CONSOLE_PSP 1 # define LZO_INFO_OS "console" # define LZO_INFO_OS_CONSOLE "psp" #else # define LZO_OS_POSIX 1 # define LZO_INFO_OS "posix" #endif #if (LZO_OS_POSIX) # if defined(_AIX) || defined(__AIX__) || defined(__aix__) # define LZO_OS_POSIX_AIX 1 # define LZO_INFO_OS_POSIX "aix" # elif defined(__FreeBSD__) # define LZO_OS_POSIX_FREEBSD 1 # define LZO_INFO_OS_POSIX "freebsd" # elif defined(__hpux__) || defined(__hpux) # define LZO_OS_POSIX_HPUX 1 # define LZO_INFO_OS_POSIX "hpux" # elif defined(__INTERIX) # define LZO_OS_POSIX_INTERIX 1 # define LZO_INFO_OS_POSIX "interix" # elif defined(__IRIX__) || defined(__irix__) # define LZO_OS_POSIX_IRIX 1 # define LZO_INFO_OS_POSIX "irix" # elif defined(__linux__) || defined(__linux) || defined(__LINUX__) # define LZO_OS_POSIX_LINUX 1 # define LZO_INFO_OS_POSIX "linux" # elif defined(__APPLE__) || defined(__MACOS__) # define LZO_OS_POSIX_MACOSX 1 # define LZO_INFO_OS_POSIX "macosx" # elif defined(__minix__) || defined(__minix) # define LZO_OS_POSIX_MINIX 1 # define LZO_INFO_OS_POSIX "minix" # elif defined(__NetBSD__) # define LZO_OS_POSIX_NETBSD 1 # define LZO_INFO_OS_POSIX "netbsd" # elif defined(__OpenBSD__) # define LZO_OS_POSIX_OPENBSD 1 # define LZO_INFO_OS_POSIX "openbsd" # elif defined(__osf__) # define LZO_OS_POSIX_OSF 1 # define LZO_INFO_OS_POSIX "osf" # elif defined(__solaris__) || defined(__sun) # if defined(__SVR4) || defined(__svr4__) # define LZO_OS_POSIX_SOLARIS 1 # define LZO_INFO_OS_POSIX "solaris" # else # define LZO_OS_POSIX_SUNOS 1 # define LZO_INFO_OS_POSIX "sunos" # endif # elif defined(__ultrix__) || defined(__ultrix) # define LZO_OS_POSIX_ULTRIX 1 # define LZO_INFO_OS_POSIX "ultrix" # elif defined(_UNICOS) # define LZO_OS_POSIX_UNICOS 1 # define LZO_INFO_OS_POSIX "unicos" # else # define LZO_OS_POSIX_UNKNOWN 1 # define LZO_INFO_OS_POSIX "unknown" # endif #endif #endif #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # if (UINT_MAX != LZO_0xffffL) # error "this should not happen" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "this should not happen" # endif #endif #if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) # if (UINT_MAX != LZO_0xffffffffL) # error "this should not happen" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "this should not happen" # endif #endif #if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) # define LZO_CC_CILLY 1 # define LZO_INFO_CC "Cilly" # if defined(__CILLY__) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__) # else # define LZO_INFO_CCVER "unknown" # endif #elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__) # define LZO_CC_SDCC 1 # define LZO_INFO_CC "sdcc" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) #elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) # define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) # define LZO_INFO_CC "Pathscale C" # define LZO_INFO_CCVER __PATHSCALE__ #elif defined(__INTEL_COMPILER) # define LZO_CC_INTELC 1 # define LZO_INFO_CC "Intel C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) # if defined(_WIN32) || defined(_WIN64) # define LZO_CC_SYNTAX_MSC 1 # else # define LZO_CC_SYNTAX_GNUC 1 # endif #elif defined(__POCC__) && defined(_WIN32) # define LZO_CC_PELLESC 1 # define LZO_INFO_CC "Pelles C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) #elif defined(__llvm__) && defined(__GNUC__) && defined(__VERSION__) # if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) # define LZO_CC_LLVM (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) # else # define LZO_CC_LLVM (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) # endif # define LZO_INFO_CC "llvm-gcc" # define LZO_INFO_CCVER __VERSION__ #elif defined(__GNUC__) && defined(__VERSION__) # if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) # define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) # elif defined(__GNUC_MINOR__) # define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) # else # define LZO_CC_GNUC (__GNUC__ * 0x10000L) # endif # define LZO_INFO_CC "gcc" # define LZO_INFO_CCVER __VERSION__ #elif defined(__ACK__) && defined(_ACK) # define LZO_CC_ACK 1 # define LZO_INFO_CC "Amsterdam Compiler Kit C" # define LZO_INFO_CCVER "unknown" #elif defined(__AZTEC_C__) # define LZO_CC_AZTECC 1 # define LZO_INFO_CC "Aztec C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__) #elif defined(__BORLANDC__) # define LZO_CC_BORLANDC 1 # define LZO_INFO_CC "Borland C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__) #elif defined(_CRAYC) && defined(_RELEASE) # define LZO_CC_CRAYC 1 # define LZO_INFO_CC "Cray C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE) #elif defined(__DMC__) && defined(__SC__) # define LZO_CC_DMC 1 # define LZO_INFO_CC "Digital Mars C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__) #elif defined(__DECC) # define LZO_CC_DECC 1 # define LZO_INFO_CC "DEC C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) #elif defined(__HIGHC__) # define LZO_CC_HIGHC 1 # define LZO_INFO_CC "MetaWare High C" # define LZO_INFO_CCVER "unknown" #elif defined(__IAR_SYSTEMS_ICC__) # define LZO_CC_IARC 1 # define LZO_INFO_CC "IAR C" # if defined(__VER__) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__) # else # define LZO_INFO_CCVER "unknown" # endif #elif defined(__IBMC__) # define LZO_CC_IBMC 1 # define LZO_INFO_CC "IBM C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) #elif defined(__KEIL__) && defined(__C166__) # define LZO_CC_KEILC 1 # define LZO_INFO_CC "Keil C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__) #elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL) # define LZO_CC_LCCWIN32 1 # define LZO_INFO_CC "lcc-win32" # define LZO_INFO_CCVER "unknown" #elif defined(__LCC__) # define LZO_CC_LCC 1 # define LZO_INFO_CC "lcc" # if defined(__LCC_VERSION__) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__) # else # define LZO_INFO_CCVER "unknown" # endif #elif defined(_MSC_VER) # define LZO_CC_MSC 1 # define LZO_INFO_CC "Microsoft C" # if defined(_MSC_FULL_VER) # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) # else # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) # endif #elif defined(__MWERKS__) # define LZO_CC_MWERKS 1 # define LZO_INFO_CC "Metrowerks C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) #elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) # define LZO_CC_NDPC 1 # define LZO_INFO_CC "Microway NDP C" # define LZO_INFO_CCVER "unknown" #elif defined(__PACIFIC__) # define LZO_CC_PACIFICC 1 # define LZO_INFO_CC "Pacific C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) #elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) # define LZO_CC_PGI 1 # define LZO_INFO_CC "Portland Group PGI C" # define LZO_INFO_CCVER "unknown" #elif defined(__PUREC__) && defined(__TOS__) # define LZO_CC_PUREC 1 # define LZO_INFO_CC "Pure C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__) #elif defined(__SC__) && defined(__ZTC__) # define LZO_CC_SYMANTECC 1 # define LZO_INFO_CC "Symantec C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) #elif defined(__SUNPRO_C) # define LZO_INFO_CC "SunPro C" # if ((__SUNPRO_C)+0 > 0) # define LZO_CC_SUNPROC __SUNPRO_C # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) # else # define LZO_CC_SUNPROC 1 # define LZO_INFO_CCVER "unknown" # endif #elif defined(__SUNPRO_CC) # define LZO_INFO_CC "SunPro C" # if ((__SUNPRO_CC)+0 > 0) # define LZO_CC_SUNPROC __SUNPRO_CC # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) # else # define LZO_CC_SUNPROC 1 # define LZO_INFO_CCVER "unknown" # endif #elif defined(__TINYC__) # define LZO_CC_TINYC 1 # define LZO_INFO_CC "Tiny C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__) #elif defined(__TSC__) # define LZO_CC_TOPSPEEDC 1 # define LZO_INFO_CC "TopSpeed C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__) #elif defined(__WATCOMC__) # define LZO_CC_WATCOMC 1 # define LZO_INFO_CC "Watcom C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__) #elif defined(__TURBOC__) # define LZO_CC_TURBOC 1 # define LZO_INFO_CC "Turbo C" # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__) #elif defined(__ZTC__) # define LZO_CC_ZORTECHC 1 # define LZO_INFO_CC "Zortech C" # if (__ZTC__ == 0x310) # define LZO_INFO_CCVER "0x310" # else # define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) # endif #else # define LZO_CC_UNKNOWN 1 # define LZO_INFO_CC "unknown" # define LZO_INFO_CCVER "unknown" #endif #if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) # error "LZO_CC_MSC: _MSC_FULL_VER is not defined" #endif #if !defined(__LZO_ARCH_OVERRIDE) && !defined(LZO_ARCH_GENERIC) && defined(_CRAY) # if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY) # if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E) # define LZO_ARCH_CRAY_MPP 1 # elif defined(_CRAY1) # define LZO_ARCH_CRAY_PVP 1 # endif # endif #endif #if !defined(__LZO_ARCH_OVERRIDE) #if defined(LZO_ARCH_GENERIC) # define LZO_INFO_ARCH "generic" #elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) # define LZO_ARCH_I086 1 # define LZO_ARCH_IA16 1 # define LZO_INFO_ARCH "i086" #elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) # define LZO_ARCH_ALPHA 1 # define LZO_INFO_ARCH "alpha" #elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E)) # define LZO_ARCH_ALPHA 1 # define LZO_INFO_ARCH "alpha" #elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64) # define LZO_ARCH_AMD64 1 # define LZO_INFO_ARCH "amd64" #elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB)) # define LZO_ARCH_ARM 1 # define LZO_ARCH_ARM_THUMB 1 # define LZO_INFO_ARCH "arm_thumb" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) # define LZO_ARCH_ARM 1 # if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) # define LZO_ARCH_ARM_THUMB 1 # define LZO_INFO_ARCH "arm_thumb" # elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) # define LZO_INFO_ARCH "arm" # else # define LZO_INFO_ARCH "arm" # endif #elif defined(__arm__) || defined(_M_ARM) # define LZO_ARCH_ARM 1 # define LZO_INFO_ARCH "arm" #elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__) # define LZO_ARCH_AVR 1 # define LZO_INFO_ARCH "avr" #elif defined(__bfin__) # define LZO_ARCH_BLACKFIN 1 # define LZO_INFO_ARCH "blackfin" #elif (UINT_MAX == LZO_0xffffL) && defined(__C166__) # define LZO_ARCH_C166 1 # define LZO_INFO_ARCH "c166" #elif defined(__cris__) # define LZO_ARCH_CRIS 1 # define LZO_INFO_ARCH "cris" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__) # define LZO_ARCH_EZ80 1 # define LZO_INFO_ARCH "ez80" #elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) # define LZO_ARCH_H8300 1 # define LZO_INFO_ARCH "h8300" #elif defined(__hppa__) || defined(__hppa) # define LZO_ARCH_HPPA 1 # define LZO_INFO_ARCH "hppa" #elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386) # define LZO_ARCH_I386 1 # define LZO_ARCH_IA32 1 # define LZO_INFO_ARCH "i386" #elif (LZO_CC_ZORTECHC && defined(__I86__)) # define LZO_ARCH_I386 1 # define LZO_ARCH_IA32 1 # define LZO_INFO_ARCH "i386" #elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386) # define LZO_ARCH_I386 1 # define LZO_ARCH_IA32 1 # define LZO_INFO_ARCH "i386" #elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64) # define LZO_ARCH_IA64 1 # define LZO_INFO_ARCH "ia64" #elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__) # define LZO_ARCH_M16C 1 # define LZO_INFO_ARCH "m16c" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__) # define LZO_ARCH_M16C 1 # define LZO_INFO_ARCH "m16c" #elif defined(__m32r__) # define LZO_ARCH_M32R 1 # define LZO_INFO_ARCH "m32r" #elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K) # define LZO_ARCH_M68K 1 # define LZO_INFO_ARCH "m68k" #elif (UINT_MAX == LZO_0xffffL) && defined(__C251__) # define LZO_ARCH_MCS251 1 # define LZO_INFO_ARCH "mcs251" #elif (UINT_MAX == LZO_0xffffL) && defined(__C51__) # define LZO_ARCH_MCS51 1 # define LZO_INFO_ARCH "mcs51" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__) # define LZO_ARCH_MCS51 1 # define LZO_INFO_ARCH "mcs51" #elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000) # define LZO_ARCH_MIPS 1 # define LZO_INFO_ARCH "mips" #elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__) # define LZO_ARCH_MSP430 1 # define LZO_INFO_ARCH "msp430" #elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__) # define LZO_ARCH_MSP430 1 # define LZO_INFO_ARCH "msp430" #elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR) # define LZO_ARCH_POWERPC 1 # define LZO_INFO_ARCH "powerpc" #elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x) # define LZO_ARCH_S390 1 # define LZO_INFO_ARCH "s390" #elif defined(__sh__) || defined(_M_SH) # define LZO_ARCH_SH 1 # define LZO_INFO_ARCH "sh" #elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8) # define LZO_ARCH_SPARC 1 # define LZO_INFO_ARCH "sparc" #elif defined(__SPU__) # define LZO_ARCH_SPU 1 # define LZO_INFO_ARCH "spu" #elif (UINT_MAX == LZO_0xffffL) && defined(__z80) # define LZO_ARCH_Z80 1 # define LZO_INFO_ARCH "z80" #elif (LZO_ARCH_CRAY_PVP) # if defined(_CRAYSV1) # define LZO_ARCH_CRAY_SV1 1 # define LZO_INFO_ARCH "cray_sv1" # elif (_ADDR64) # define LZO_ARCH_CRAY_T90 1 # define LZO_INFO_ARCH "cray_t90" # elif (_ADDR32) # define LZO_ARCH_CRAY_YMP 1 # define LZO_INFO_ARCH "cray_ymp" # else # define LZO_ARCH_CRAY_XMP 1 # define LZO_INFO_ARCH "cray_xmp" # endif #else # define LZO_ARCH_UNKNOWN 1 # define LZO_INFO_ARCH "unknown" #endif #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2) # error "FIXME - missing define for CPU architecture" #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) # error "FIXME - missing WIN32 define for CPU architecture" #endif #if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) # error "FIXME - missing WIN64 define for CPU architecture" #endif #if (LZO_OS_OS216 || LZO_OS_WIN16) # define LZO_ARCH_I086PM 1 # define LZO_ARCH_IA16PM 1 #elif 1 && (LZO_OS_DOS16 && defined(BLX286)) # define LZO_ARCH_I086PM 1 # define LZO_ARCH_IA16PM 1 #elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) # define LZO_ARCH_I086PM 1 # define LZO_ARCH_IA16PM 1 #elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) # define LZO_ARCH_I086PM 1 # define LZO_ARCH_IA16PM 1 #endif #if defined(LZO_ARCH_ARM_THUMB) && !defined(LZO_ARCH_ARM) # error "this should not happen" #endif #if defined(LZO_ARCH_I086PM) && !defined(LZO_ARCH_I086) # error "this should not happen" #endif #if (LZO_ARCH_I086) # if (UINT_MAX != LZO_0xffffL) # error "this should not happen" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "this should not happen" # endif #endif #if (LZO_ARCH_I386) # if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) # error "this should not happen" # endif # if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) # error "this should not happen" # endif # if (ULONG_MAX != LZO_0xffffffffL) # error "this should not happen" # endif #endif #if !defined(__LZO_MM_OVERRIDE) #if (LZO_ARCH_I086) #if (UINT_MAX != LZO_0xffffL) # error "this should not happen" #endif #if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) # define LZO_MM_TINY 1 #elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM) # define LZO_MM_HUGE 1 #elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL) # define LZO_MM_SMALL 1 #elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM) # define LZO_MM_MEDIUM 1 #elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM) # define LZO_MM_COMPACT 1 #elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL) # define LZO_MM_LARGE 1 #elif (LZO_CC_AZTECC) # if defined(_LARGE_CODE) && defined(_LARGE_DATA) # define LZO_MM_LARGE 1 # elif defined(_LARGE_CODE) # define LZO_MM_MEDIUM 1 # elif defined(_LARGE_DATA) # define LZO_MM_COMPACT 1 # else # define LZO_MM_SMALL 1 # endif #elif (LZO_CC_ZORTECHC && defined(__VCM__)) # define LZO_MM_LARGE 1 #else # error "unknown memory model" #endif #if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) #define LZO_HAVE_MM_HUGE_PTR 1 #define LZO_HAVE_MM_HUGE_ARRAY 1 #if (LZO_MM_TINY) # undef LZO_HAVE_MM_HUGE_ARRAY #endif #if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC) # undef LZO_HAVE_MM_HUGE_PTR # undef LZO_HAVE_MM_HUGE_ARRAY #elif (LZO_CC_DMC || LZO_CC_SYMANTECC) # undef LZO_HAVE_MM_HUGE_ARRAY #elif (LZO_CC_MSC && defined(_QC)) # undef LZO_HAVE_MM_HUGE_ARRAY # if (_MSC_VER < 600) # undef LZO_HAVE_MM_HUGE_PTR # endif #elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295)) # undef LZO_HAVE_MM_HUGE_ARRAY #endif #if (LZO_ARCH_I086PM) && !defined(LZO_HAVE_MM_HUGE_PTR) # if (LZO_OS_DOS16) # error "this should not happen" # elif (LZO_CC_ZORTECHC) # else # error "this should not happen" # endif #endif #ifdef __cplusplus extern "C" { #endif #if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200)) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295)) extern void __near __cdecl _AHSHIFT(void); # define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) #elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16) # define LZO_MM_AHSHIFT 12 #elif (LZO_CC_WATCOMC) extern unsigned char _HShift; # define LZO_MM_AHSHIFT ((unsigned) _HShift) #else # error "FIXME - implement LZO_MM_AHSHIFT" #endif #ifdef __cplusplus } #endif #endif #elif (LZO_ARCH_C166) #if !defined(__MODEL__) # error "FIXME - C166 __MODEL__" #elif ((__MODEL__) == 0) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 1) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) # define LZO_MM_LARGE 1 #elif ((__MODEL__) == 3) # define LZO_MM_TINY 1 #elif ((__MODEL__) == 4) # define LZO_MM_XTINY 1 #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else # error "FIXME - C166 __MODEL__" #endif #elif (LZO_ARCH_MCS251) #if !defined(__MODEL__) # error "FIXME - MCS251 __MODEL__" #elif ((__MODEL__) == 0) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) # define LZO_MM_LARGE 1 #elif ((__MODEL__) == 3) # define LZO_MM_TINY 1 #elif ((__MODEL__) == 4) # define LZO_MM_XTINY 1 #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else # error "FIXME - MCS251 __MODEL__" #endif #elif (LZO_ARCH_MCS51) #if !defined(__MODEL__) # error "FIXME - MCS51 __MODEL__" #elif ((__MODEL__) == 1) # define LZO_MM_SMALL 1 #elif ((__MODEL__) == 2) # define LZO_MM_LARGE 1 #elif ((__MODEL__) == 3) # define LZO_MM_TINY 1 #elif ((__MODEL__) == 4) # define LZO_MM_XTINY 1 #elif ((__MODEL__) == 5) # define LZO_MM_XSMALL 1 #else # error "FIXME - MCS51 __MODEL__" #endif #elif (LZO_ARCH_CRAY_PVP) # define LZO_MM_PVP 1 #else # define LZO_MM_FLAT 1 #endif #if (LZO_MM_COMPACT) # define LZO_INFO_MM "compact" #elif (LZO_MM_FLAT) # define LZO_INFO_MM "flat" #elif (LZO_MM_HUGE) # define LZO_INFO_MM "huge" #elif (LZO_MM_LARGE) # define LZO_INFO_MM "large" #elif (LZO_MM_MEDIUM) # define LZO_INFO_MM "medium" #elif (LZO_MM_PVP) # define LZO_INFO_MM "pvp" #elif (LZO_MM_SMALL) # define LZO_INFO_MM "small" #elif (LZO_MM_TINY) # define LZO_INFO_MM "tiny" #else # error "unknown memory model" #endif #endif #if defined(SIZEOF_SHORT) # define LZO_SIZEOF_SHORT (SIZEOF_SHORT) #endif #if defined(SIZEOF_INT) # define LZO_SIZEOF_INT (SIZEOF_INT) #endif #if defined(SIZEOF_LONG) # define LZO_SIZEOF_LONG (SIZEOF_LONG) #endif #if defined(SIZEOF_LONG_LONG) # define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) #endif #if defined(SIZEOF___INT16) # define LZO_SIZEOF___INT16 (SIZEOF___INT16) #endif #if defined(SIZEOF___INT32) # define LZO_SIZEOF___INT32 (SIZEOF___INT32) #endif #if defined(SIZEOF___INT64) # define LZO_SIZEOF___INT64 (SIZEOF___INT64) #endif #if defined(SIZEOF_VOID_P) # define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) #endif #if defined(SIZEOF_SIZE_T) # define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) #endif #if defined(SIZEOF_PTRDIFF_T) # define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) #endif #define __LZO_LSR(x,b) (((x)+0ul) >> (b)) #if !defined(LZO_SIZEOF_SHORT) # if (LZO_ARCH_CRAY_PVP) # define LZO_SIZEOF_SHORT 8 # elif (USHRT_MAX == LZO_0xffffL) # define LZO_SIZEOF_SHORT 2 # elif (__LZO_LSR(USHRT_MAX,7) == 1) # define LZO_SIZEOF_SHORT 1 # elif (__LZO_LSR(USHRT_MAX,15) == 1) # define LZO_SIZEOF_SHORT 2 # elif (__LZO_LSR(USHRT_MAX,31) == 1) # define LZO_SIZEOF_SHORT 4 # elif (__LZO_LSR(USHRT_MAX,63) == 1) # define LZO_SIZEOF_SHORT 8 # elif (__LZO_LSR(USHRT_MAX,127) == 1) # define LZO_SIZEOF_SHORT 16 # else # error "LZO_SIZEOF_SHORT" # endif #endif #if !defined(LZO_SIZEOF_INT) # if (LZO_ARCH_CRAY_PVP) # define LZO_SIZEOF_INT 8 # elif (UINT_MAX == LZO_0xffffL) # define LZO_SIZEOF_INT 2 # elif (UINT_MAX == LZO_0xffffffffL) # define LZO_SIZEOF_INT 4 # elif (__LZO_LSR(UINT_MAX,7) == 1) # define LZO_SIZEOF_INT 1 # elif (__LZO_LSR(UINT_MAX,15) == 1) # define LZO_SIZEOF_INT 2 # elif (__LZO_LSR(UINT_MAX,31) == 1) # define LZO_SIZEOF_INT 4 # elif (__LZO_LSR(UINT_MAX,63) == 1) # define LZO_SIZEOF_INT 8 # elif (__LZO_LSR(UINT_MAX,127) == 1) # define LZO_SIZEOF_INT 16 # else # error "LZO_SIZEOF_INT" # endif #endif #if !defined(LZO_SIZEOF_LONG) # if (ULONG_MAX == LZO_0xffffffffL) # define LZO_SIZEOF_LONG 4 # elif (__LZO_LSR(ULONG_MAX,7) == 1) # define LZO_SIZEOF_LONG 1 # elif (__LZO_LSR(ULONG_MAX,15) == 1) # define LZO_SIZEOF_LONG 2 # elif (__LZO_LSR(ULONG_MAX,31) == 1) # define LZO_SIZEOF_LONG 4 # elif (__LZO_LSR(ULONG_MAX,63) == 1) # define LZO_SIZEOF_LONG 8 # elif (__LZO_LSR(ULONG_MAX,127) == 1) # define LZO_SIZEOF_LONG 16 # else # error "LZO_SIZEOF_LONG" # endif #endif #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) # if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) # if (LZO_CC_GNUC >= 0x030300ul) # if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) # define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG # elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) # define LZO_SIZEOF_LONG_LONG 4 # endif # endif # endif #endif #endif #if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) #if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) #if (LZO_ARCH_I086 && LZO_CC_DMC) #elif (LZO_CC_CILLY) && defined(__GNUC__) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_SIZEOF_LONG_LONG 8 #elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_OS_WIN64 || defined(_WIN64)) # define LZO_SIZEOF___INT64 8 #elif (LZO_ARCH_I386 && (LZO_CC_DMC)) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) # define LZO_SIZEOF___INT64 8 #elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) # define LZO_SIZEOF___INT64 8 #elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) # define LZO_SIZEOF___INT64 8 #elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) # define LZO_SIZEOF___INT64 8 #elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) # define LZO_SIZEOF___INT64 8 #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) # define LZO_SIZEOF_LONG_LONG 8 #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) # define LZO_SIZEOF_LONG_LONG 8 #elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) #elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) # define LZO_SIZEOF_LONG_LONG 8 #endif #endif #endif #if defined(__cplusplus) && defined(LZO_CC_GNUC) # if (LZO_CC_GNUC < 0x020800ul) # undef LZO_SIZEOF_LONG_LONG # endif #endif #if defined(LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) # undef LZO_SIZEOF_LONG_LONG #endif #if !defined(LZO_SIZEOF_VOID_P) #if (LZO_ARCH_I086) # define __LZO_WORDSIZE 2 # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) # define LZO_SIZEOF_VOID_P 2 # elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) # define LZO_SIZEOF_VOID_P 4 # else # error "LZO_MM" # endif #elif (LZO_ARCH_AVR || LZO_ARCH_Z80) # define __LZO_WORDSIZE 1 # define LZO_SIZEOF_VOID_P 2 #elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) # define LZO_SIZEOF_VOID_P 2 #elif (LZO_ARCH_H8300) # if defined(__NORMAL_MODE__) # define __LZO_WORDSIZE 4 # define LZO_SIZEOF_VOID_P 2 # elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) # define __LZO_WORDSIZE 4 # define LZO_SIZEOF_VOID_P 4 # else # define __LZO_WORDSIZE 2 # define LZO_SIZEOF_VOID_P 2 # endif # if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT # endif #elif (LZO_ARCH_M16C) # define __LZO_WORDSIZE 2 # if defined(__m32c_cpu__) || defined(__m32cm_cpu__) # define LZO_SIZEOF_VOID_P 4 # else # define LZO_SIZEOF_VOID_P 2 # endif #elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) # define __LZO_WORDSIZE 8 # define LZO_SIZEOF_VOID_P 4 #elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) # define __LZO_WORDSIZE 8 # define LZO_SIZEOF_VOID_P 8 #elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG #elif (LZO_OS_OS400 || defined(__OS400__)) # define __LZO_WORDSIZE LZO_SIZEOF_LONG # define LZO_SIZEOF_VOID_P 16 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG #elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) # define LZO_SIZEOF_VOID_P 8 # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG #elif (LZO_ARCH_SPU) # if 0 # define __LZO_WORDSIZE 16 # endif # define LZO_SIZEOF_VOID_P 4 #else # define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG #endif #endif #if !defined(LZO_WORDSIZE) # if defined(__LZO_WORDSIZE) # define LZO_WORDSIZE __LZO_WORDSIZE # else # define LZO_WORDSIZE LZO_SIZEOF_VOID_P # endif #endif #if !defined(LZO_SIZEOF_SIZE_T) #if (LZO_ARCH_I086 || LZO_ARCH_M16C) # define LZO_SIZEOF_SIZE_T 2 #else # define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P #endif #endif #if !defined(LZO_SIZEOF_PTRDIFF_T) #if (LZO_ARCH_I086) # if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P # elif (LZO_MM_COMPACT || LZO_MM_LARGE) # if (LZO_CC_BORLANDC || LZO_CC_TURBOC) # define LZO_SIZEOF_PTRDIFF_T 4 # else # define LZO_SIZEOF_PTRDIFF_T 2 # endif # else # error "LZO_MM" # endif #else # define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T #endif #endif #if defined(LZO_ABI_NEUTRAL_ENDIAN) # undef LZO_ABI_BIG_ENDIAN # undef LZO_ABI_LITTLE_ENDIAN #elif !defined(LZO_ABI_BIG_ENDIAN) && !defined(LZO_ABI_LITTLE_ENDIAN) #if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) # define LZO_ABI_BIG_ENDIAN 1 #elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) # define LZO_ABI_LITTLE_ENDIAN 1 #elif (LZO_ARCH_M68K || LZO_ARCH_S390) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) # if (__LITTLE_ENDIAN__ == 1) # define LZO_ABI_LITTLE_ENDIAN 1 # else # define LZO_ABI_BIG_ENDIAN 1 # endif #elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) # define LZO_ABI_LITTLE_ENDIAN 1 #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) # define LZO_ABI_LITTLE_ENDIAN 1 #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) # define LZO_ABI_BIG_ENDIAN 1 #elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) # define LZO_ABI_LITTLE_ENDIAN 1 #endif #endif #if defined(LZO_ABI_BIG_ENDIAN) && defined(LZO_ABI_LITTLE_ENDIAN) # error "this should not happen" #endif #if defined(LZO_ABI_BIG_ENDIAN) # define LZO_INFO_ABI_ENDIAN "be" #elif defined(LZO_ABI_LITTLE_ENDIAN) # define LZO_INFO_ABI_ENDIAN "le" #elif defined(LZO_ABI_NEUTRAL_ENDIAN) # define LZO_INFO_ABI_ENDIAN "neutral" #endif #if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) # define LZO_ABI_I8LP16 1 # define LZO_INFO_ABI_PM "i8lp16" #elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) # define LZO_ABI_ILP16 1 # define LZO_INFO_ABI_PM "ilp16" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) # define LZO_ABI_ILP32 1 # define LZO_INFO_ABI_PM "ilp32" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) # define LZO_ABI_LLP64 1 # define LZO_INFO_ABI_PM "llp64" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) # define LZO_ABI_LP64 1 # define LZO_INFO_ABI_PM "lp64" #elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) # define LZO_ABI_ILP64 1 # define LZO_INFO_ABI_PM "ilp64" #elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) # define LZO_ABI_IP32L64 1 # define LZO_INFO_ABI_PM "ip32l64" #endif #if !defined(__LZO_LIBC_OVERRIDE) #if defined(LZO_LIBC_NAKED) # define LZO_INFO_LIBC "naked" #elif defined(LZO_LIBC_FREESTANDING) # define LZO_INFO_LIBC "freestanding" #elif defined(LZO_LIBC_MOSTLY_FREESTANDING) # define LZO_INFO_LIBC "mfreestanding" #elif defined(LZO_LIBC_ISOC90) # define LZO_INFO_LIBC "isoc90" #elif defined(LZO_LIBC_ISOC99) # define LZO_INFO_LIBC "isoc99" #elif defined(__dietlibc__) # define LZO_LIBC_DIETLIBC 1 # define LZO_INFO_LIBC "dietlibc" #elif defined(_NEWLIB_VERSION) # define LZO_LIBC_NEWLIB 1 # define LZO_INFO_LIBC "newlib" #elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) # if defined(__UCLIBC_SUBLEVEL__) # define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) # else # define LZO_LIBC_UCLIBC 0x00090bL # endif # define LZO_INFO_LIBC "uclibc" #elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) # define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) # define LZO_INFO_LIBC "glibc" #elif (LZO_CC_MWERKS) && defined(__MSL__) # define LZO_LIBC_MSL __MSL__ # define LZO_INFO_LIBC "msl" #elif 1 && defined(__IAR_SYSTEMS_ICC__) # define LZO_LIBC_ISOC90 1 # define LZO_INFO_LIBC "isoc90" #else # define LZO_LIBC_DEFAULT 1 # define LZO_INFO_LIBC "default" #endif #endif #if !defined(__lzo_gnuc_extension__) #if (LZO_CC_GNUC >= 0x020800ul) # define __lzo_gnuc_extension__ __extension__ #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_gnuc_extension__ __extension__ #else # define __lzo_gnuc_extension__ #endif #endif #if !defined(__lzo_ua_volatile) # define __lzo_ua_volatile volatile #endif #if !defined(__lzo_alignof) #if (LZO_CC_CILLY || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) # define __lzo_alignof(e) __alignof__(e) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) # define __lzo_alignof(e) __alignof__(e) #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) # define __lzo_alignof(e) __alignof(e) #endif #endif #if defined(__lzo_alignof) # define __lzo_HAVE_alignof 1 #endif #if !defined(__lzo_constructor) #if (LZO_CC_GNUC >= 0x030400ul) # define __lzo_constructor __attribute__((__constructor__,__used__)) #elif (LZO_CC_GNUC >= 0x020700ul) # define __lzo_constructor __attribute__((__constructor__)) #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_constructor __attribute__((__constructor__)) #endif #endif #if defined(__lzo_constructor) # define __lzo_HAVE_constructor 1 #endif #if !defined(__lzo_destructor) #if (LZO_CC_GNUC >= 0x030400ul) # define __lzo_destructor __attribute__((__destructor__,__used__)) #elif (LZO_CC_GNUC >= 0x020700ul) # define __lzo_destructor __attribute__((__destructor__)) #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_destructor __attribute__((__destructor__)) #endif #endif #if defined(__lzo_destructor) # define __lzo_HAVE_destructor 1 #endif #if defined(__lzo_HAVE_destructor) && !defined(__lzo_HAVE_constructor) # error "this should not happen" #endif #if !defined(__lzo_inline) #if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) #elif defined(__cplusplus) # define __lzo_inline inline #elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) # define __lzo_inline __inline #elif (LZO_CC_CILLY || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) # define __lzo_inline __inline__ #elif (LZO_CC_DMC) # define __lzo_inline __inline #elif (LZO_CC_INTELC) # define __lzo_inline __inline #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) # define __lzo_inline __inline #elif (LZO_CC_MSC && (_MSC_VER >= 900)) # define __lzo_inline __inline #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) # define __lzo_inline inline #endif #endif #if defined(__lzo_inline) # define __lzo_HAVE_inline 1 #else # define __lzo_inline #endif #if !defined(__lzo_forceinline) #if (LZO_CC_GNUC >= 0x030200ul) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) # define __lzo_forceinline __forceinline #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_forceinline __inline__ __attribute__((__always_inline__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) # define __lzo_forceinline __forceinline #endif #endif #if defined(__lzo_forceinline) # define __lzo_HAVE_forceinline 1 #else # define __lzo_forceinline #endif #if !defined(__lzo_noinline) #if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) # define __lzo_noinline __attribute__((__noinline__,__used__)) #elif (LZO_CC_GNUC >= 0x030200ul) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) # define __lzo_noinline __declspec(noinline) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_noinline __attribute__((__noinline__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1300)) # define __lzo_noinline __declspec(noinline) #elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) # if defined(__cplusplus) # else # define __lzo_noinline __declspec(noinline) # endif #endif #endif #if defined(__lzo_noinline) # define __lzo_HAVE_noinline 1 #else # define __lzo_noinline #endif #if (defined(__lzo_HAVE_forceinline) || defined(__lzo_HAVE_noinline)) && !defined(__lzo_HAVE_inline) # error "this should not happen" #endif #if !defined(__lzo_noreturn) #if (LZO_CC_GNUC >= 0x020700ul) # define __lzo_noreturn __attribute__((__noreturn__)) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) # define __lzo_noreturn __declspec(noreturn) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) # define __lzo_noreturn __attribute__((__noreturn__)) #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_noreturn __attribute__((__noreturn__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) # define __lzo_noreturn __declspec(noreturn) #endif #endif #if defined(__lzo_noreturn) # define __lzo_HAVE_noreturn 1 #else # define __lzo_noreturn #endif #if !defined(__lzo_nothrow) #if (LZO_CC_GNUC >= 0x030300ul) # define __lzo_nothrow __attribute__((__nothrow__)) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) # define __lzo_nothrow __declspec(nothrow) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) # define __lzo_nothrow __attribute__((__nothrow__)) #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_nothrow __attribute__((__nothrow__)) #elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) # define __lzo_nothrow __declspec(nothrow) #endif #endif #if defined(__lzo_nothrow) # define __lzo_HAVE_nothrow 1 #else # define __lzo_nothrow #endif #if !defined(__lzo_restrict) #if (LZO_CC_GNUC >= 0x030400ul) # define __lzo_restrict __restrict__ #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) # define __lzo_restrict __restrict__ #elif (LZO_CC_LLVM) # define __lzo_restrict __restrict__ #elif (LZO_CC_MSC && (_MSC_VER >= 1400)) # define __lzo_restrict __restrict #endif #endif #if defined(__lzo_restrict) # define __lzo_HAVE_restrict 1 #else # define __lzo_restrict #endif #if !defined(__lzo_likely) && !defined(__lzo_unlikely) #if (LZO_CC_GNUC >= 0x030200ul) # define __lzo_likely(e) (__builtin_expect(!!(e),1)) # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) # define __lzo_likely(e) (__builtin_expect(!!(e),1)) # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #elif (LZO_CC_LLVM || LZO_CC_PATHSCALE) # define __lzo_likely(e) (__builtin_expect(!!(e),1)) # define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) #endif #endif #if defined(__lzo_likely) # define __lzo_HAVE_likely 1 #else # define __lzo_likely(e) (e) #endif #if defined(__lzo_unlikely) # define __lzo_HAVE_unlikely 1 #else # define __lzo_unlikely(e) (e) #endif #if !defined(LZO_UNUSED) # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) # define LZO_UNUSED(var) ((void) &var) # elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) # define LZO_UNUSED(var) if (&var) ; else # elif (LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) # define LZO_UNUSED(var) ((void) var) # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_UNUSED(var) if (&var) ; else # elif (LZO_CC_KEILC) # define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} # elif (LZO_CC_PACIFICC) # define LZO_UNUSED(var) ((void) sizeof(var)) # elif (LZO_CC_WATCOMC) && defined(__cplusplus) # define LZO_UNUSED(var) ((void) var) # else # define LZO_UNUSED(var) ((void) &var) # endif #endif #if !defined(LZO_UNUSED_FUNC) # if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) # define LZO_UNUSED_FUNC(func) ((void) func) # elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) # define LZO_UNUSED_FUNC(func) if (func) ; else # elif (LZO_CC_LLVM) # define LZO_UNUSED_FUNC(func) ((void) &func) # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_UNUSED_FUNC(func) if (func) ; else # elif (LZO_CC_MSC) # define LZO_UNUSED_FUNC(func) ((void) &func) # elif (LZO_CC_KEILC || LZO_CC_PELLESC) # define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} # else # define LZO_UNUSED_FUNC(func) ((void) func) # endif #endif #if !defined(LZO_UNUSED_LABEL) # if (LZO_CC_WATCOMC) && defined(__cplusplus) # define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l # elif (LZO_CC_INTELC || LZO_CC_WATCOMC) # define LZO_UNUSED_LABEL(l) if (0) goto l # else # define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l # endif #endif #if !defined(LZO_DEFINE_UNINITIALIZED_VAR) # if 0 # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var # elif 0 && (LZO_CC_GNUC) # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var # else # define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init # endif #endif #if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) # if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; # elif (LZO_CC_DMC || LZO_CC_SYMANTECC) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; # else # define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; # endif #endif #if !defined(LZO_COMPILE_TIME_ASSERT) # if (LZO_CC_AZTECC) # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} # elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # elif (LZO_CC_MSC && (_MSC_VER < 900)) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) # define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; # else # define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} # endif #endif #if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) # elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) # define __lzo_cdecl __cdecl # define __lzo_cdecl_atexit # define __lzo_cdecl_main __cdecl # if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) # define __lzo_cdecl_qsort __pascal # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) # define __lzo_cdecl_qsort _stdcall # else # define __lzo_cdecl_qsort __cdecl # endif # elif (LZO_CC_WATCOMC) # define __lzo_cdecl __cdecl # else # define __lzo_cdecl __cdecl # define __lzo_cdecl_atexit __cdecl # define __lzo_cdecl_main __cdecl # define __lzo_cdecl_qsort __cdecl # endif # if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) # elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) # define __lzo_cdecl_sighandler __pascal # elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) # define __lzo_cdecl_sighandler _stdcall # elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) # define __lzo_cdecl_sighandler __clrcall # elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) # if defined(_DLL) # define __lzo_cdecl_sighandler _far _cdecl _loadds # elif defined(_MT) # define __lzo_cdecl_sighandler _far _cdecl # else # define __lzo_cdecl_sighandler _cdecl # endif # else # define __lzo_cdecl_sighandler __cdecl # endif #elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) # define __lzo_cdecl __cdecl #elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) # define __lzo_cdecl cdecl #endif #if !defined(__lzo_cdecl) # define __lzo_cdecl #endif #if !defined(__lzo_cdecl_atexit) # define __lzo_cdecl_atexit #endif #if !defined(__lzo_cdecl_main) # define __lzo_cdecl_main #endif #if !defined(__lzo_cdecl_qsort) # define __lzo_cdecl_qsort #endif #if !defined(__lzo_cdecl_sighandler) # define __lzo_cdecl_sighandler #endif #if !defined(__lzo_cdecl_va) # define __lzo_cdecl_va __lzo_cdecl #endif #if !defined(LZO_CFG_NO_WINDOWS_H) #if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) # if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) # elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) # elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) # else # define LZO_HAVE_WINDOWS_H 1 # endif #endif #endif #if (LZO_ARCH_ALPHA) # define LZO_OPT_AVOID_UINT_INDEX 1 # define LZO_OPT_AVOID_SHORT 1 # define LZO_OPT_AVOID_USHORT 1 #elif (LZO_ARCH_AMD64) # define LZO_OPT_AVOID_INT_INDEX 1 # define LZO_OPT_AVOID_UINT_INDEX 1 # define LZO_OPT_UNALIGNED16 1 # define LZO_OPT_UNALIGNED32 1 # define LZO_OPT_UNALIGNED64 1 #elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) #elif (LZO_ARCH_ARM) # define LZO_OPT_AVOID_SHORT 1 # define LZO_OPT_AVOID_USHORT 1 #elif (LZO_ARCH_CRIS) # define LZO_OPT_UNALIGNED16 1 # define LZO_OPT_UNALIGNED32 1 #elif (LZO_ARCH_I386) # define LZO_OPT_UNALIGNED16 1 # define LZO_OPT_UNALIGNED32 1 #elif (LZO_ARCH_IA64) # define LZO_OPT_AVOID_INT_INDEX 1 # define LZO_OPT_AVOID_UINT_INDEX 1 # define LZO_OPT_PREFER_POSTINC 1 #elif (LZO_ARCH_M68K) # define LZO_OPT_PREFER_POSTINC 1 # define LZO_OPT_PREFER_PREDEC 1 # if defined(__mc68020__) && !defined(__mcoldfire__) # define LZO_OPT_UNALIGNED16 1 # define LZO_OPT_UNALIGNED32 1 # endif #elif (LZO_ARCH_MIPS) # define LZO_OPT_AVOID_UINT_INDEX 1 #elif (LZO_ARCH_POWERPC) # define LZO_OPT_PREFER_PREINC 1 # define LZO_OPT_PREFER_PREDEC 1 # if defined(LZO_ABI_BIG_ENDIAN) # define LZO_OPT_UNALIGNED16 1 # define LZO_OPT_UNALIGNED32 1 # endif #elif (LZO_ARCH_S390) # define LZO_OPT_UNALIGNED16 1 # define LZO_OPT_UNALIGNED32 1 # if (LZO_SIZEOF_SIZE_T == 8) # define LZO_OPT_UNALIGNED64 1 # endif #elif (LZO_ARCH_SH) # define LZO_OPT_PREFER_POSTINC 1 # define LZO_OPT_PREFER_PREDEC 1 #endif #if !defined(LZO_CFG_NO_INLINE_ASM) #if defined(LZO_CC_LLVM) # define LZO_CFG_NO_INLINE_ASM 1 #endif #endif #if !defined(LZO_CFG_NO_UNALIGNED) #if defined(LZO_ABI_NEUTRAL_ENDIAN) || defined(LZO_ARCH_GENERIC) # define LZO_CFG_NO_UNALIGNED 1 #endif #endif #if defined(LZO_CFG_NO_UNALIGNED) # undef LZO_OPT_UNALIGNED16 # undef LZO_OPT_UNALIGNED32 # undef LZO_OPT_UNALIGNED64 #endif #if defined(LZO_CFG_NO_INLINE_ASM) #elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) # define LZO_ASM_SYNTAX_MSC 1 #elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) #elif (LZO_ARCH_I386 && (LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) # define LZO_ASM_SYNTAX_GNUC 1 #elif (LZO_ARCH_AMD64 && (LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) # define LZO_ASM_SYNTAX_GNUC 1 #endif #if (LZO_ASM_SYNTAX_GNUC) #if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) # define __LZO_ASM_CLOBBER "ax" #elif (LZO_CC_INTELC) # define __LZO_ASM_CLOBBER "memory" #else # define __LZO_ASM_CLOBBER "cc", "memory" #endif #endif #if defined(__LZO_INFOSTR_MM) #elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) # define __LZO_INFOSTR_MM "" #elif defined(LZO_INFO_MM) # define __LZO_INFOSTR_MM "." LZO_INFO_MM #else # define __LZO_INFOSTR_MM "" #endif #if defined(__LZO_INFOSTR_PM) #elif defined(LZO_INFO_ABI_PM) # define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM #else # define __LZO_INFOSTR_PM "" #endif #if defined(__LZO_INFOSTR_ENDIAN) #elif defined(LZO_INFO_ABI_ENDIAN) # define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN #else # define __LZO_INFOSTR_ENDIAN "" #endif #if defined(__LZO_INFOSTR_OSNAME) #elif defined(LZO_INFO_OS_CONSOLE) # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE #elif defined(LZO_INFO_OS_POSIX) # define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX #else # define __LZO_INFOSTR_OSNAME LZO_INFO_OS #endif #if defined(__LZO_INFOSTR_LIBC) #elif defined(LZO_INFO_LIBC) # define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC #else # define __LZO_INFOSTR_LIBC "" #endif #if defined(__LZO_INFOSTR_CCVER) #elif defined(LZO_INFO_CCVER) # define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER #else # define __LZO_INFOSTR_CCVER "" #endif #define LZO_INFO_STRING \ LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER #endif /* already included */ /* vim:set ts=4 et: */ ht-2.0.22/minilzo/lzoconf.h0000644000175000001440000003341211006065547012440 00000000000000/* lzoconf.h -- configuration for the LZO real-time data compression library This file is part of the LZO real-time data compression library. Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer All Rights Reserved. The LZO library is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. The LZO library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the LZO library; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Markus F.X.J. Oberhumer http://www.oberhumer.com/opensource/lzo/ */ #ifndef __LZOCONF_H_INCLUDED #define __LZOCONF_H_INCLUDED #define LZO_VERSION 0x2030 #define LZO_VERSION_STRING "2.03" #define LZO_VERSION_DATE "Apr 30 2008" /* internal Autoconf configuration file - only used when building LZO */ #if defined(LZO_HAVE_CONFIG_H) # include #endif #include #include /*********************************************************************** // LZO requires a conforming ************************************************************************/ #if !defined(CHAR_BIT) || (CHAR_BIT != 8) # error "invalid CHAR_BIT" #endif #if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) # error "check your compiler installation" #endif #if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1) # error "your limits.h macros are broken" #endif /* get OS and architecture defines */ #ifndef __LZODEFS_H_INCLUDED #include "lzodefs.h" #endif #ifdef __cplusplus extern "C" { #endif /*********************************************************************** // some core defines ************************************************************************/ #if !defined(LZO_UINT32_C) # if (UINT_MAX < LZO_0xffffffffL) # define LZO_UINT32_C(c) c ## UL # else # define LZO_UINT32_C(c) ((c) + 0U) # endif #endif /* memory checkers */ #if !defined(__LZO_CHECKER) # if defined(__BOUNDS_CHECKING_ON) # define __LZO_CHECKER 1 # elif defined(__CHECKER__) # define __LZO_CHECKER 1 # elif defined(__INSURE__) # define __LZO_CHECKER 1 # elif defined(__PURIFY__) # define __LZO_CHECKER 1 # endif #endif /*********************************************************************** // integral and pointer types ************************************************************************/ /* lzo_uint should match size_t */ #if !defined(LZO_UINT_MAX) # if defined(LZO_ABI_LLP64) /* WIN64 */ # if defined(LZO_OS_WIN64) typedef unsigned __int64 lzo_uint; typedef __int64 lzo_int; # else typedef unsigned long long lzo_uint; typedef long long lzo_int; # endif # define LZO_UINT_MAX 0xffffffffffffffffull # define LZO_INT_MAX 9223372036854775807LL # define LZO_INT_MIN (-1LL - LZO_INT_MAX) # elif defined(LZO_ABI_IP32L64) /* MIPS R5900 */ typedef unsigned int lzo_uint; typedef int lzo_int; # define LZO_UINT_MAX UINT_MAX # define LZO_INT_MAX INT_MAX # define LZO_INT_MIN INT_MIN # elif (ULONG_MAX >= LZO_0xffffffffL) typedef unsigned long lzo_uint; typedef long lzo_int; # define LZO_UINT_MAX ULONG_MAX # define LZO_INT_MAX LONG_MAX # define LZO_INT_MIN LONG_MIN # else # error "lzo_uint" # endif #endif /* Integral types with 32 bits or more. */ #if !defined(LZO_UINT32_MAX) # if (UINT_MAX >= LZO_0xffffffffL) typedef unsigned int lzo_uint32; typedef int lzo_int32; # define LZO_UINT32_MAX UINT_MAX # define LZO_INT32_MAX INT_MAX # define LZO_INT32_MIN INT_MIN # elif (ULONG_MAX >= LZO_0xffffffffL) typedef unsigned long lzo_uint32; typedef long lzo_int32; # define LZO_UINT32_MAX ULONG_MAX # define LZO_INT32_MAX LONG_MAX # define LZO_INT32_MIN LONG_MIN # else # error "lzo_uint32" # endif #endif /* The larger type of lzo_uint and lzo_uint32. */ #if (LZO_UINT_MAX >= LZO_UINT32_MAX) # define lzo_xint lzo_uint #else # define lzo_xint lzo_uint32 #endif /* Memory model that allows to access memory at offsets of lzo_uint. */ #if !defined(__LZO_MMODEL) # if (LZO_UINT_MAX <= UINT_MAX) # define __LZO_MMODEL # elif defined(LZO_HAVE_MM_HUGE_PTR) # define __LZO_MMODEL_HUGE 1 # define __LZO_MMODEL __huge # else # define __LZO_MMODEL # endif #endif /* no typedef here because of const-pointer issues */ #define lzo_bytep unsigned char __LZO_MMODEL * #define lzo_charp char __LZO_MMODEL * #define lzo_voidp void __LZO_MMODEL * #define lzo_shortp short __LZO_MMODEL * #define lzo_ushortp unsigned short __LZO_MMODEL * #define lzo_uint32p lzo_uint32 __LZO_MMODEL * #define lzo_int32p lzo_int32 __LZO_MMODEL * #define lzo_uintp lzo_uint __LZO_MMODEL * #define lzo_intp lzo_int __LZO_MMODEL * #define lzo_xintp lzo_xint __LZO_MMODEL * #define lzo_voidpp lzo_voidp __LZO_MMODEL * #define lzo_bytepp lzo_bytep __LZO_MMODEL * /* deprecated - use `lzo_bytep' instead of `lzo_byte *' */ #define lzo_byte unsigned char __LZO_MMODEL typedef int lzo_bool; /*********************************************************************** // function types ************************************************************************/ /* name mangling */ #if !defined(__LZO_EXTERN_C) # ifdef __cplusplus # define __LZO_EXTERN_C extern "C" # else # define __LZO_EXTERN_C extern # endif #endif /* calling convention */ #if !defined(__LZO_CDECL) # define __LZO_CDECL __lzo_cdecl #endif /* DLL export information */ #if !defined(__LZO_EXPORT1) # define __LZO_EXPORT1 #endif #if !defined(__LZO_EXPORT2) # define __LZO_EXPORT2 #endif /* __cdecl calling convention for public C and assembly functions */ #if !defined(LZO_PUBLIC) # define LZO_PUBLIC(_rettype) __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL #endif #if !defined(LZO_EXTERN) # define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype) #endif #if !defined(LZO_PRIVATE) # define LZO_PRIVATE(_rettype) static _rettype __LZO_CDECL #endif /* function types */ typedef int (__LZO_CDECL *lzo_compress_t) ( const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem ); typedef int (__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem ); typedef int (__LZO_CDECL *lzo_optimize_t) ( lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem ); typedef int (__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem, const lzo_bytep dict, lzo_uint dict_len ); typedef int (__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint src_len, lzo_bytep dst, lzo_uintp dst_len, lzo_voidp wrkmem, const lzo_bytep dict, lzo_uint dict_len ); /* Callback interface. Currently only the progress indicator ("nprogress") * is used, but this may change in a future release. */ struct lzo_callback_t; typedef struct lzo_callback_t lzo_callback_t; #define lzo_callback_p lzo_callback_t __LZO_MMODEL * /* malloc & free function types */ typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t) (lzo_callback_p self, lzo_uint items, lzo_uint size); typedef void (__LZO_CDECL *lzo_free_func_t) (lzo_callback_p self, lzo_voidp ptr); /* a progress indicator callback function */ typedef void (__LZO_CDECL *lzo_progress_func_t) (lzo_callback_p, lzo_uint, lzo_uint, int); struct lzo_callback_t { /* custom allocators (set to 0 to disable) */ lzo_alloc_func_t nalloc; /* [not used right now] */ lzo_free_func_t nfree; /* [not used right now] */ /* a progress indicator callback function (set to 0 to disable) */ lzo_progress_func_t nprogress; /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress * callbacks points back to this struct, so you are free to store * some extra info in the following variables. */ lzo_voidp user1; lzo_xint user2; lzo_xint user3; }; /*********************************************************************** // error codes and prototypes ************************************************************************/ /* Error codes for the compression/decompression functions. Negative * values are errors, positive values will be used for special but * normal events. */ #define LZO_E_OK 0 #define LZO_E_ERROR (-1) #define LZO_E_OUT_OF_MEMORY (-2) /* [not used right now] */ #define LZO_E_NOT_COMPRESSIBLE (-3) /* [not used right now] */ #define LZO_E_INPUT_OVERRUN (-4) #define LZO_E_OUTPUT_OVERRUN (-5) #define LZO_E_LOOKBEHIND_OVERRUN (-6) #define LZO_E_EOF_NOT_FOUND (-7) #define LZO_E_INPUT_NOT_CONSUMED (-8) #define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ #ifndef lzo_sizeof_dict_t # define lzo_sizeof_dict_t ((unsigned)sizeof(lzo_bytep)) #endif /* lzo_init() should be the first function you call. * Check the return code ! * * lzo_init() is a macro to allow checking that the library and the * compiler's view of various types are consistent. */ #define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ (int)sizeof(lzo_callback_t)) LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int); /* version functions (useful for shared libraries) */ LZO_EXTERN(unsigned) lzo_version(void); LZO_EXTERN(const char *) lzo_version_string(void); LZO_EXTERN(const char *) lzo_version_date(void); LZO_EXTERN(const lzo_charp) _lzo_version_string(void); LZO_EXTERN(const lzo_charp) _lzo_version_date(void); /* string functions */ LZO_EXTERN(int) lzo_memcmp(const lzo_voidp _s1, const lzo_voidp _s2, lzo_uint _len); LZO_EXTERN(lzo_voidp) lzo_memcpy(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len); LZO_EXTERN(lzo_voidp) lzo_memmove(lzo_voidp _dest, const lzo_voidp _src, lzo_uint _len); LZO_EXTERN(lzo_voidp) lzo_memset(lzo_voidp _s, int _c, lzo_uint _len); /* checksum functions */ LZO_EXTERN(lzo_uint32) lzo_adler32(lzo_uint32 _adler, const lzo_bytep _buf, lzo_uint _len); LZO_EXTERN(lzo_uint32) lzo_crc32(lzo_uint32 _c, const lzo_bytep _buf, lzo_uint _len); LZO_EXTERN(const lzo_uint32p) lzo_get_crc32_table(void); /* misc. */ LZO_EXTERN(int) _lzo_config_check(void); typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; typedef union { void *vp; lzo_bytep bp; lzo_uint32 u32; long l; } lzo_align_t; /* align a char pointer on a boundary that is a multiple of `size' */ LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp _ptr, lzo_uint _size); #define LZO_PTR_ALIGN_UP(_ptr,_size) \ ((_ptr) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(_ptr),(lzo_uint)(_size))) /*********************************************************************** // deprecated macros - only for backward compatibility with LZO v1.xx ************************************************************************/ #if defined(LZO_CFG_COMPAT) #define __LZOCONF_H 1 #if defined(LZO_ARCH_I086) # define __LZO_i386 1 #elif defined(LZO_ARCH_I386) # define __LZO_i386 1 #endif #if defined(LZO_OS_DOS16) # define __LZO_DOS 1 # define __LZO_DOS16 1 #elif defined(LZO_OS_DOS32) # define __LZO_DOS 1 #elif defined(LZO_OS_WIN16) # define __LZO_WIN 1 # define __LZO_WIN16 1 #elif defined(LZO_OS_WIN32) # define __LZO_WIN 1 #endif #define __LZO_CMODEL #define __LZO_DMODEL #define __LZO_ENTRY __LZO_CDECL #define LZO_EXTERN_CDECL LZO_EXTERN #define LZO_ALIGN LZO_PTR_ALIGN_UP #define lzo_compress_asm_t lzo_compress_t #define lzo_decompress_asm_t lzo_decompress_t #endif /* LZO_CFG_COMPAT */ #ifdef __cplusplus } /* extern "C" */ #endif #endif /* already included */ /* vim:set ts=4 et: */ ht-2.0.22/minilzo/Makefile.am0000644000175000017500000000052411724770100012646 00000000000000AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/asm \ -I$(top_srcdir)/io/@IO_DIR@ -I$(top_srcdir)/io \ -I$(top_srcdir)/output AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_LIBRARIES = liblzo.a liblzo_a_SOURCES = lzoconf.h lzodefs.h minilzo.c minilzo.h ht-2.0.22/minilzo/Makefile.in0000644000175000017500000003102412127657374012675 00000000000000# Makefile.in generated by automake 1.10.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = minilzo DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru liblzo_a_AR = $(AR) $(ARFLAGS) liblzo_a_LIBADD = am_liblzo_a_OBJECTS = minilzo.$(OBJEXT) liblzo_a_OBJECTS = $(am_liblzo_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(liblzo_a_SOURCES) DIST_SOURCES = $(liblzo_a_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ HT_LDFLAGS = @HT_LDFLAGS@ HT_LIBS = @HT_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IO_DIR = @IO_DIR@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ LZO_LIBS = @LZO_LIBS@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ curses_CPPFLAGS = @curses_CPPFLAGS@ curses_LIBS = @curses_LIBS@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ ncurses_config = @ncurses_config@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/asm \ -I$(top_srcdir)/io/@IO_DIR@ -I$(top_srcdir)/io \ -I$(top_srcdir)/output AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_LIBRARIES = liblzo.a liblzo_a_SOURCES = lzoconf.h lzodefs.h minilzo.c minilzo.h all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign minilzo/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign minilzo/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) liblzo.a: $(liblzo_a_OBJECTS) $(liblzo_a_DEPENDENCIES) -rm -f liblzo.a $(liblzo_a_AR) liblzo.a $(liblzo_a_OBJECTS) $(liblzo_a_LIBADD) $(RANLIB) liblzo.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/minilzo.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ht-2.0.22/htidle.h0000644000175000001440000000166510615341620010555 00000000000000/* * HT Editor * htidle.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTIDLE_H__ #define __HTIDLE_H__ #include "data.h" void register_idle_object(Object *o); void unregister_idle_object(Object *o); void do_idle(); /* * INIT */ bool init_idle(); /* * DONE */ void done_idle(); #endif ht-2.0.22/classimg.h0000644000175000001440000000230710615341616011105 00000000000000/* * HT Editor * classimg.h * * Copyright (C) 2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __CLASSIMG_H__ #define __CLASSIMG_H__ #include "class.h" #include "formats.h" #include "htanaly.h" extern format_viewer_if htclassimage_if; /* * CLASS ht_class_aviewer */ class ht_class_aviewer: public ht_aviewer { public: ht_class_shared_data *class_shared; File *file; void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Analyser *Analy, ht_class_shared_data *class_shared); virtual void setAnalyser(Analyser *a); }; #endif /* !__HTCLASSIMG_H__ */ ht-2.0.22/httext.cc0000644000175000017500000001553112127651420010765 00000000000000/* * HT Editor * httext.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "htsearch.h" #include "httext.h" #include "stream.h" #include ht_view *httext_init(Bounds *b, File *file, ht_format_group *group) { /* no httext for file > 5 MiB */ if (file->getSize() > 5*1024*1024) { return NULL; } ht_text_viewer2 *v=new ht_text_viewer2(); v->init(b, TEXT_DESC, 0/*VC_EDIT | VC_GOTO | VC_SEARCH | VC_BLOCKOP | VC_TRUNCATE*/, file, group); v->search_caps|=SEARCHMODE_BIN | SEARCHMODE_EVALSTR; ht_text_sub *t=new ht_text_sub(); t->init(file, 0x0, file->getSize()); v->insertsub(t); return v; } format_viewer_if httext_if = { httext_init, 0 }; /* * CLASS ht_text_viewer2 */ /*bool ht_text_viewer2::offset_to_pos(FileOfs ofs, viewer_pos *pos) { pos->u.sub = first_sub; pos->u.line_id.id1 = ofs; pos->u.line_id.id2 = 0; pos->u.tag_idx = 0; pos->u.tag_group = 0; return true; } bool ht_text_viewer2::pos_to_offset(viewer_pos pos, FileOfs *ofs) { *ofs = pos.u.line_id.id1; return true; }*/ void ht_text_viewer2::handlemsg(htmsg *msg) { switch (msg->msg) { case msg_keypressed: switch (msg->data1.integer) { case K_Left: { // FIXME: send cmd_bla when available htmsg m; m.msg = msg_keypressed; m.type = mt_empty; m.data1.integer = K_Control_Left; sendmsg(&m); clearmsg(msg); return; } case K_Right: { // FIXME: send cmd_bla when available htmsg m; m.msg = msg_keypressed; m.type = mt_empty; m.data1.integer = K_Control_Right; sendmsg(&m); clearmsg(msg); return; } } break; } return ht_uformat_viewer::handlemsg(msg); } /* * CLASS ht_text_sub */ /* FIXME: put it somewhere else..., why ain't this a POSIX function ? */ const void *ht_memrchr(const void *string, int ch, size_t num) { while (num--) { if (((const char*)string)[num]==ch) return ((const char*)string)+num; } return NULL; } #define TEXT_SUB_READSIZE 256 #define TEXT_SUB_MAX_LINELEN 512 #define TEXT_SUB_MAX_LINEENDLEN 2 #define TEXT_SUB_TABSIZE 5 byte ht_text_sub_line[TEXT_SUB_MAX_LINELEN]; void ht_text_sub::init(File *file, FileOfs offset, int size) { ht_linear_sub::init(file, offset, size); } void ht_text_sub::done() { ht_linear_sub::done(); } bool ht_text_sub::convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id) { clear_line_id(line_id); line_id->id1 = offset; prev_line_id(line_id, 1); return true; } bool ht_text_sub::convert_id_to_ofs(const LINE_ID line_id, FileOfs *offset) { return false; } uint ht_text_sub::find_linelen_backwd(byte *buf, uint maxbuflen, FileOfs ofs, int *le_len) { uint readlen=(maxbuflen>TEXT_SUB_READSIZE) ? TEXT_SUB_READSIZE : maxbuflen; uint oreadlen=readlen; FileOfs oofs=ofs; byte *bufp; uint s; uint len=0; uint lineends=0; if (le_len) *le_len=0; do { if (ofs==fofs) break; if (readlen>ofs) readlen=ofs; if (ofs-readlenseek(ofs); /* make sure current and next read overlap to guarantee proper lineend-matching */ if (readlen==oreadlen) ofs+=TEXT_SUB_MAX_LINEENDLEN-1; else if (ofs+readlen+TEXT_SUB_MAX_LINEENDLEN-1<=oofs) readlen+=TEXT_SUB_MAX_LINEENDLEN-1; s=file->read(buf, readlen); int l; bufp=match_lineend_backwd(buf, s, &l); if (bufp) { lineends++; if (lineends==1) { bufp=match_lineend_backwd(buf, bufp-buf, &l); if (bufp) lineends++; } if (lineends==2) { len+=buf+s-bufp-1; if (len>TEXT_SUB_MAX_LINELEN) { len=TEXT_SUB_MAX_LINELEN; break; } if (le_len) *le_len=l; break; } } len+=s; if (len>TEXT_SUB_MAX_LINELEN) { len=TEXT_SUB_MAX_LINELEN; break; } } while (s); return len; } uint ht_text_sub::find_linelen_forwd(byte *buf, uint maxbuflen, FileOfs ofs, int *le_len) { uint readlen=(maxbuflen>TEXT_SUB_READSIZE) ? TEXT_SUB_READSIZE : maxbuflen; byte *bufp; uint s; uint len = 0; if (le_len) *le_len = 0; do { file->seek(ofs); s = file->read(buf, readlen); int l; bufp = match_lineend_forwd(buf, s, &l); if (bufp) { len += bufp-buf+l; if (le_len) *le_len = l; break; } if (s != readlen) { len += s; break; } /* make sure current and next read overlap to guarantee proper lineend-matching */ if (s > (TEXT_SUB_MAX_LINEENDLEN-1)) { len += s-(TEXT_SUB_MAX_LINEENDLEN-1); } ofs += s-(TEXT_SUB_MAX_LINEENDLEN-1); } while (s == readlen); if (len > TEXT_SUB_MAX_LINELEN) { len = TEXT_SUB_MAX_LINELEN; if (le_len) *le_len = 0; } return len; } void ht_text_sub::first_line_id(LINE_ID *line_id) { clear_line_id(line_id); line_id->id1 = 0; } bool ht_text_sub::getline(char *line, int maxlen, const LINE_ID line_id) { byte *bufp = (byte*)line; FileOfs ofs = line_id.id1; int ll; uint l = find_linelen_forwd(ht_text_sub_line, sizeof ht_text_sub_line, ofs, &ll); if (l) { l -= ll; if (l > 255) l = 255; file->seek(ofs); l = file->read(line, l); while (l--) { if (*bufp=='\e' || *bufp==0) *bufp = '.'; bufp++; } *bufp = 0; return true; } return false; } void ht_text_sub::last_line_id(LINE_ID *line_id) { clear_line_id(line_id); FileOfs ofs = fofs+fsize; uint l = find_linelen_backwd(ht_text_sub_line, sizeof ht_text_sub_line, ofs, NULL); line_id->id1 = ofs-l; } byte *ht_text_sub::match_lineend_forwd(byte *buf, uint buflen, int *le_len) { byte *result=NULL; byte *n=(byte*)memchr(buf, '\n', buflen); if (n) { if ((n>buf) && (n[-1] == '\r')) { *le_len=2; result=n-1; } else { *le_len=1; result=n; } } return result; } byte *ht_text_sub::match_lineend_backwd(byte *buf, uint buflen, int *le_len) { byte *result=NULL; byte *n=(byte*)ht_memrchr(buf, '\n', buflen); if (n) { if ((n>buf) && (n[-1] == '\r')) { *le_len=2; result=n-1; } else { *le_len=1; result=n; } } return result; } int ht_text_sub::next_line_id(LINE_ID *line_id, int n) { FileOfs ofs = line_id->id1; int r=0; while (n--) { uint l=find_linelen_forwd(ht_text_sub_line, sizeof ht_text_sub_line, ofs, NULL); ofs+=l; if (!l) break; r++; } line_id->id1 = ofs; return r; } int ht_text_sub::prev_line_id(LINE_ID *line_id, int n) { FileOfs ofs = line_id->id1; int r=0; while (n--) { uint l=find_linelen_backwd(ht_text_sub_line, sizeof ht_text_sub_line, ofs, NULL); ofs-=l; if (!l) break; r++; } line_id->id1 = ofs; return r; } ht-2.0.22/htpefhd.cc0000644000175000001440000001433710771304342011067 00000000000000/* * HT Editor * htpefhd.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "pefstruc.h" #include "atom.h" #include "htpef.h" #include "htpefhd.h" #include "httag.h" #include "formats.h" #include "snprintf.h" static ht_mask_ptable pef_header[]= { {"tag1", STATICTAG_EDIT_BYTE("00000000")" " STATICTAG_EDIT_BYTE("00000001")" " STATICTAG_EDIT_BYTE("00000002")" " STATICTAG_EDIT_BYTE("00000003")" = " STATICTAG_EDIT_CHAR("00000000") STATICTAG_EDIT_CHAR("00000001") STATICTAG_EDIT_CHAR("00000002") STATICTAG_EDIT_CHAR("00000003")}, {"tag2", STATICTAG_EDIT_BYTE("00000004")" " STATICTAG_EDIT_BYTE("00000005")" " STATICTAG_EDIT_BYTE("00000006")" " STATICTAG_EDIT_BYTE("00000007")" = " STATICTAG_EDIT_CHAR("00000004") STATICTAG_EDIT_CHAR("00000005") STATICTAG_EDIT_CHAR("00000006") STATICTAG_EDIT_CHAR("00000007")}, {"architecture", STATICTAG_EDIT_DWORD_BE("00000008")" = " STATICTAG_EDIT_CHAR("00000008") STATICTAG_EDIT_CHAR("00000009") STATICTAG_EDIT_CHAR("0000000a") STATICTAG_EDIT_CHAR("0000000b")" " STATICTAG_DESC_DWORD_BE("00000008", ATOM_PEF_ARCH_STR)}, {"format version", STATICTAG_EDIT_DWORD_BE("0000000c")}, {"timestamp", STATICTAG_EDIT_DWORD_BE("00000010")}, {"oldDefVersion", STATICTAG_EDIT_DWORD_BE("00000014")}, {"oldImpVersion", STATICTAG_EDIT_DWORD_BE("00000018")}, {"currentVersion", STATICTAG_EDIT_DWORD_BE("0000001c")}, {"sectionCount", STATICTAG_EDIT_WORD_BE("00000020")}, {"instSectionCount", STATICTAG_EDIT_WORD_BE("00000022")}, {"reserved", STATICTAG_EDIT_DWORD_BE("00000024")}, {0, 0} }; static ht_mask_ptable pef_sectionheader[]= { {"nameofs", STATICTAG_EDIT_DWORD_BE("00000000")}, {"default address", STATICTAG_EDIT_DWORD_BE("00000004")}, {"total size", STATICTAG_EDIT_DWORD_BE("00000008")}, {"unpacked size", STATICTAG_EDIT_DWORD_BE("0000000c")}, {"packed size", STATICTAG_EDIT_DWORD_BE("00000010")}, {"container offset", STATICTAG_EDIT_DWORD_BE("00000014")}, {"section kind", STATICTAG_EDIT_BYTE("00000018")" "STATICTAG_DESC_BYTE("00000018", ATOM_PEF_SECTION_KIND_STR)}, {"share kind", STATICTAG_EDIT_BYTE("00000019")" "STATICTAG_DESC_BYTE("00000019", ATOM_PEF_SHARE_KIND_STR)}, {"alignment", STATICTAG_EDIT_BYTE("0000001a")}, {"reserved", STATICTAG_EDIT_BYTE("0000001b")}, {0, 0} }; static int_hash pef_arch[] = { {0x70777063, "PowerPC"}, {0x6d36386b, "M68K"}, {0, 0} }; static int_hash pef_sectionKind[] = { {PEF_SK_Code, "code"}, {PEF_SK_UnpackedData, "unpacked data"}, {PEF_SK_PatternInitData,"pattern-initialized data"}, {PEF_SK_ConstData, "const data"}, {PEF_SK_Loader, "loader"}, {PEF_SK_Debug, "debug?"}, {PEF_SK_ExecutableData, "code/data"}, {PEF_SK_Exception, "exception?"}, {PEF_SK_Traceback, "traceback?"}, {0, 0} }; static int_hash pef_shareKind[] = { {PEF_SHK_ProcessShare, "process share"}, {PEF_SHK_GlobalShare, "global share"}, {PEF_SHK_ProtectedShare, "protected share"}, {0, 0} }; static ht_mask_ptable pef_loader_info_header[]= { {"main section", STATICTAG_EDIT_DWORD_BE("00000000")}, {"main offset", STATICTAG_EDIT_DWORD_BE("00000004")}, {"init section", STATICTAG_EDIT_DWORD_BE("00000008")}, {"init offset", STATICTAG_EDIT_DWORD_BE("0000000c")}, {"term section", STATICTAG_EDIT_DWORD_BE("00000010")}, {"term offset", STATICTAG_EDIT_DWORD_BE("00000014")}, {"imported library count", STATICTAG_EDIT_DWORD_BE("00000018")}, {"total imported symbol count", STATICTAG_EDIT_DWORD_BE("0000001c")}, {"reloc section count", STATICTAG_EDIT_DWORD_BE("00000020")}, {"reloc section offset", STATICTAG_EDIT_DWORD_BE("00000024")}, {"load strings offset", STATICTAG_EDIT_DWORD_BE("00000028")}, {"export hash offset", STATICTAG_EDIT_DWORD_BE("0000002c")}, {"export hash table power", STATICTAG_EDIT_DWORD_BE("00000030")}, {"exported symbol count", STATICTAG_EDIT_DWORD_BE("00000034")}, {0, 0} }; /*static ht_mask_ptable pef_loader_reloc_header[]= { {""}, {0, 0} };*/ ht_view *htpefheader_init(Bounds *b, File *file, ht_format_group *group) { ht_pef_shared_data *pef_shared = (ht_pef_shared_data *)group->get_shared_data(); ht_uformat_viewer *v = new ht_uformat_viewer(); v->init(b, DESC_PEF_HEADER, VC_EDIT, file, group); ht_mask_sub *m = new ht_mask_sub(); m->init(file, 0); char info[128]; ht_snprintf(info, sizeof info, "* PEF header at offset %08qx", pef_shared->header_ofs); registerAtom(ATOM_PEF_ARCH, pef_arch); registerAtom(ATOM_PEF_SHARE_KIND, pef_shareKind); registerAtom(ATOM_PEF_SECTION_KIND, pef_sectionKind); m->add_mask(info); m->add_staticmask_ptable(pef_header, pef_shared->header_ofs, true); v->insertsub(m); for (int i=0; i < pef_shared->contHeader.sectionCount; i++) { m = new ht_mask_sub(); m->init(file, 1); ht_snprintf(info, sizeof info, "Section %d", i); m->add_staticmask_ptable(pef_sectionheader, pef_shared->header_ofs+sizeof(pef_shared->contHeader) +i*sizeof(PEF_SECTION_HEADER), true); ht_collapsable_sub *cs = new ht_collapsable_sub(); cs->init(file, m, 1, info, 1); v->insertsub(cs); } if (pef_shared->loader_info_header_ofs) { m = new ht_mask_sub(); m->init(file, 1); ht_snprintf(info, sizeof info, "Loader header at offset %08qx", pef_shared->loader_info_header_ofs); m->add_staticmask_ptable(pef_loader_info_header, pef_shared->loader_info_header_ofs, true); ht_collapsable_sub *cs = new ht_collapsable_sub(); cs->init(file, m, 1, info, 1); v->insertsub(cs); /* relocation headers */ // pef_shared->loader_info_header_ofs + sizeof pef_shared->loader_info_header // + pef_shared->loader_info_header.importedLibraryCount*sizeof(PEF_ImportedLibrary) } return v; } format_viewer_if htpefheader_if = { htpefheader_init, 0 }; ht-2.0.22/htprocess.cc0000644000175000001440000000247710615345251011462 00000000000000/* * HT Editor * process.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "htprocess.h" #include "htctrl.h" #include "htdialog.h" #include "htiobox.h" #include "keyb.h" bool execute_process(process_func pp, Object *context) { Bounds b; get_std_progress_indicator_metrics(&b); ht_progress_indicator pi; pi.init(&b, "ESC to cancel"); bool cancelled=false; bool p=true; while (p) { p = pp(context, pi.text); if (keyb_keypressed()) { if (keyb_getkey() == K_Escape) { cancelled = true; break; } } pi.sendmsg(msg_draw, 0); screen->show(); } pi.done(); return !cancelled; } void execute_process_bg(process_func pp, Object *context) { /* FIXME: nyi */ } ht-2.0.22/AUTHORS0000644000175000001440000000025710115332305010172 00000000000000 Authors ========= Stefan Weyergraf Sebastian Biallas (sb@biallas.net) Contributions made by: Stanley Gambarin (Java class files) ht-2.0.22/cstream.cc0000644000175000001440000000742610615341616011106 00000000000000/* * HT Editor * cstream.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "cstream.h" #include "htdebug.h" #include "except.h" #include "endianess.h" # ifdef USE_MINILZO # include "minilzo/minilzo.h" # elif HAVE_LZO_LZO1X_H # include # elif HAVE_LZO1X_H # include # endif #include "tools.h" #include CompressedStream::CompressedStream(Stream *stream, bool own_stream) : StreamLayer(stream, own_stream) { if ((stream->getAccessMode() & (IOAM_READ | IOAM_WRITE)) == (IOAM_READ | IOAM_WRITE)) { // ht_compressed_stream cant be used for read and write access simultaneously assert(0); } bufferpos = 0; buffersize = COMPRESSED_STREAM_DEFAULT_GRANULARITY; buffer = ht_malloc(buffersize); } CompressedStream::~CompressedStream() { if (getAccessMode() & IOAM_WRITE) { flush_compressed(); } free(buffer); } void CompressedStream::flush_compressed() { if (bufferpos) { byte cbuf[bufferpos + bufferpos / 64 + 16 + 3]; byte workbuf[LZO1X_1_MEM_COMPRESS]; lzo_uint cbuf_len; byte n[4]; memset(workbuf, 0, sizeof workbuf); lzo1x_1_compress(buffer, bufferpos, cbuf, &cbuf_len, workbuf); createForeignInt(n, bufferpos, 4, big_endian); mStream->writex(n, 4); createForeignInt(n, cbuf_len, 4, big_endian); mStream->writex(n, 4); mStream->writex(cbuf, cbuf_len); bufferpos = 0; } } void CompressedStream::flush_uncompressed() { if (bufferpos == 0) { free(buffer); buffer = NULL; uint cbuf_len; uint uncompressed_len; byte n[4]; mStream->readx(n, 4); uncompressed_len = createHostInt(n, 4, big_endian); mStream->readx(n, 4); cbuf_len = createHostInt(n, 4, big_endian); if (!uncompressed_len || uncompressed_len > COMPRESSED_STREAM_DEFAULT_GRANULARITY || !cbuf_len || cbuf_len > 2*COMPRESSED_STREAM_DEFAULT_GRANULARITY) throw IOException(EIO); buffer = ht_malloc(uncompressed_len); byte cbuf[cbuf_len]; mStream->readx(cbuf, cbuf_len); lzo_uint dummy = uncompressed_len; lzo1x_decompress_safe(cbuf, cbuf_len, buffer, &dummy, NULL); if (dummy != uncompressed_len) throw IOException(EIO); buffersize = uncompressed_len; bufferpos = uncompressed_len; } } uint CompressedStream::read(void *aBuf, uint size) { uint ssize = size; byte *buf = (byte *)aBuf; while (size >= bufferpos) { memcpy(buf, buffer+buffersize-bufferpos, bufferpos); buf += bufferpos; size -= bufferpos; bufferpos = 0; if (size) { try { flush_uncompressed(); } catch (const EOFException &) { return ssize - size; } } else break; } if (size) { memcpy(buf, buffer+buffersize-bufferpos, size); bufferpos -= size; } return ssize; } uint CompressedStream::write(const void *aBuf, uint size) { uint ssize = size; const byte *buf = (const byte *)aBuf; while (bufferpos+size >= buffersize) { memcpy(buffer+bufferpos, buf, buffersize-bufferpos); size -= buffersize-bufferpos; buf += buffersize-bufferpos; bufferpos = buffersize; if (size) { try { flush_compressed(); } catch (const EOFException &) { return ssize - size; } } else break; } if (size) { memcpy(buffer+bufferpos, buf, size); bufferpos += size; } return ssize; } ht-2.0.22/mfile.h0000644000175000001440000001654210615341624010404 00000000000000/* * HT Editor * mfile.h * * Copyright (C) 1999-2003 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __MFILE_H__ #define __MFILE_H__ #include "stream.h" /* * File areas */ class FileArea: public Object { public: FileOfs start; FileOfs size; FileArea(FileOfs start, FileOfs size); /* extends Object */ virtual int compareTo(const Object *obj) const; }; class ModifiedFileArea: public FileArea { public: byte *buf; ModifiedFileArea(FileOfs start, FileOfs size); virtual ~ModifiedFileArea(); /* extends Object */ virtual ObjectID getObjectID() const; }; class CopiedFileArea: public FileArea { public: FileOfs src_start; CopiedFileArea(FileOfs start, FileOfs size, FileOfs src_start); /* extends Object */ virtual ObjectID getObjectID() const; }; /** * File modification layer. * This is a file modification layer. Ie. a file-layer that keeps track * of all modifications made to it, without forwarding (or "flushing") them to * the underlying (possibly physical) file. * This is invisible however to the user of this object as all modifications are * reflected back when retrieving information through the File interface. * "Flushing" (ie. applying the modifications) must be done explicitly through * a call to fcntl(FCNTL_MODS_FLUSH). * * This object is (esp. for big files) much more memory- and time-efficient * compared to an "all-in-memory"- or even a "modpages-in-memory"-approach: * * "all-in-memory" approach
* ========================
* This can be achieved using the MemoryFile object (with little modification). * The whole underlying File is read once on creation of this object and * then kept in memory until destruction. * Modifications received through the File interface are instantly applied to the * this "in-memory image". * * Performance analysis (performance grades are relative to the probability of the event): * - read() and write() cause a single call to 'memcpy'. optimal performance. * - truncate() and extend() cause a single call to 'realloc'. good performance. * - insert() and cut() cause a single call to 'memmove'. bad performance. * - memory consumption is constantly high. not memory-efficient. * This approach is naive and very easy to implement, which is why: * This is a very common approach for text- and hex-editors (although * it is VERY BAD for huge files).

* * "modpages-in-memory" approach
* =============================
* This approach divides the underlying File into seamless blocks of * equal size. These blocks are called "pages". Two kinds of pages exist: * modified and unmodified pages. * Right after construction, all pages are unmodified. (We may use a tree * that contains only modified pages. So this tree is empty right after * construction). * If a write-(or read-)operation spans multiple pages, it is treated as * multiple discrete write-(or read-)operations not spanning multiple pages. * Whenever an attempt is made to write() to a page, it is made sure * that this page is modified. If it is not modified, "page-size" bytes of * memory are allocated and filled with the corresponding bytes from the * underlying file. The write is then performed in memory. * read()s are served from modified pages if possible. * extend() and truncate() are treated like writes with zeros. * But they must create new pages and/or change the size of the last page * and realloc(). * insert() and cut() have "naive" implementations, which * translates them into a combination of extend()/read()/write() and * read()/write()/truncate(), respectively. * * Performance analysis (performance grades are relative to the probability of the event): * - read() and write() cause little trouble. good performance. * - truncate() and extend() cause little trouble. good performance. * - insert() and cut() cause big trouble. bad performance. * - memory consumption is high only for insert()/extend(). kind-of memory-efficient. * This approach is easy to implement. It has been used extensively used * in HT 0.7.x and its predecessors.

* * "modareas-in-memory" approach
* =============================
* This is the approach used by a FileModificator. This is meant * to be a more progressive approach compared to the above. * As is well known from complexity-theory (and a programmer's all-day * work) you can often save memory by wasting some more (CPU-)time and * vice-versa. * As pointed out in both analyses above the insert() and cut() * operations cause these approaches to comsume very much memory (about as much * as the file's size !). * We will combine these two statements into a new approach: * It's derived from the "modpages-in-memory" approach, with some exceptions: * - "seamless blocks of equal size" become "seamless, dynamically sized blocks". * We will call them areas. * - due to their dynamic size, areas also have dynamic start offsets. * * Taking the notions from "modpages-in-memory" we have then also: * "modified and unmodified areas". * But we will now call the unmodified areas "copied areas". * (And both copied and modified areas must to registered in a tree). * insert() and cut() can now be implemented by simple * operations on the areas. Memory consumption drops drastically on huge * files (as compared to all other methods). * This approach is hard to implement (the code written is complex). * It will be used in (at least) HT 2.x.x . */ class FileModificator: public FileLayer { protected: AVLTree mods; FileOfs newsize; FileOfs pos; int mcount; int inv_mcount; bool cut1(ObjHandle h, FileOfs rstart, FileOfs size); ObjHandle findArea(FileOfs o); void flushMods(); void invalidateMods(); bool isModified() const; bool isModifiedByte(FileOfs o); void makeAreaModified(ObjHandle h, FileOfs rstart, FileOfs size); void read1(FileArea *a, FileOfs rstart, byte *buf, uint count); void write1(FileArea *a, FileOfs rstart, const byte *buf, uint count); public: FileModificator(File *file, bool own_file); /* */ void checkSanity(); void debug(); /* */ /* extends FileLayer */ virtual FileOfs copyAllTo(Stream *stream); virtual FileOfs copyTo(Stream *stream, FileOfs count); virtual void cut(FileOfs size); virtual void extend(FileOfs newsize); virtual String & getDesc(String &result) const; virtual FileOfs getSize() const; virtual uint read(void *buf, uint size); virtual void seek(FileOfs offset); virtual FileOfs tell() const; virtual void truncate(FileOfs newsize); virtual int vcntl(uint cmd, va_list vargs); virtual uint write(const void *buf, uint size); virtual void insert(const void *buf, FileOfs size); }; #endif /* __MFILE_H__ */ ht-2.0.22/htneobj.h0000644000175000001440000000152710206756710010740 00000000000000/* * HT Editor * htneobj.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTNEOBJ_H__ #define __HTNEOBJ_H__ #include "formats.h" extern format_viewer_if htnesegments_if; #endif /* !__HTNEIMG_H__ */ ht-2.0.22/htpehead.h0000644000175000001440000000211510615341623011060 00000000000000/* * HT Editor * htpehead.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTPEHEAD_H__ #define __HTPEHEAD_H__ #include "formats.h" extern format_viewer_if htpeheader_if; /* * CLASS ht_pe_header_viewer */ class ht_pe_header_viewer: public ht_uformat_viewer { public: void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *group); /* overwritten */ virtual bool ref_sel(LINE_ID *id); }; #endif /* !__HTPEHEAD_H__ */ ht-2.0.22/formats.cc0000644000175000001440000000245010615341616011113 00000000000000/* * HT Editor * formats.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "formats.h" #include "htdebug.h" #include "class.h" #include "hthex.h" #include "httext.h" #include "htdisasm.h" #include "htfinfo.h" #include "htelf.h" #include "htcoff.h" #include "htle.h" #include "htmacho.h" #include "htmz.h" #include "htne.h" #include "htpe.h" #include "htpef.h" #include "htflt.h" #include "htxbe.h" #include "htxex.h" format_viewer_if *format_viewer_ifs[] = { &hthex_if, &httext_if, &htdisasm_if, &htfinfo_if, &htelf_if, &htmz_if, &htcls_if, &htcoff_if, &htpe_if, &htne_if, &htle_if, &htmacho_if, &htflt_if, &htxbe_if, &htxex_if, &htpef_if, NULL }; ht-2.0.22/htpefimp.h0000644000175000001440000000344010615341623011114 00000000000000/* * HT Editor * htpefimp.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTPEFIMP_H__ #define __HTPEFIMP_H__ #include "htdialog.h" #include "formats.h" extern format_viewer_if htpefimports_if; /* * class ht_pef_import_library */ class ht_pef_import_library: public Object { public: char *name; ht_pef_import_library(char *name); ~ht_pef_import_library(); }; /* * class ht_pef_import_function */ class ht_pef_import_function: public Object { public: uint libidx; int num; char *name; uint sym_class; ht_pef_import_function(uint libidx, int num, const char *name, uint sym_class); ~ht_pef_import_function(); }; struct ht_pef_import { Container *funcs; Container *libs; }; /* * CLASS ht_pef_import_viewer */ class ht_pef_import_viewer: public ht_itext_listbox { protected: ht_format_group *format_group; bool grouplib; uint sortby; /* new */ void dosort(); public: void init(Bounds *b, const char *desc, ht_format_group *fg); virtual void done(); /* overwritten */ virtual void handlemsg(htmsg *msg); virtual bool select_entry(void *entry); /* new */ const char *func(uint i, bool execute); }; #endif /* !__HTPEFIMP_H__ */ ht-2.0.22/hteval.cc0000644000175000001440000002224311222061127010714 00000000000000/* * HT Editor * hteval.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "atom.h" #include "htctrl.h" #include "endianess.h" #include "hthist.h" #include "htiobox.h" #include "htpal.h" #include "strtools.h" #include "str.h" #include "snprintf.h" #include "syntax.h" #include "textedit.h" #include "textfile.h" extern "C" { #include "evalx.h" } static eval_func_handler real_func_handler; static eval_symbol_handler real_symbol_handler; static bool have_last_result; static eval_scalar last_result; static bool symbol_eval(eval_scalar *r, char *symbol) { if (strcmp(symbol, "_") == 0) { if (have_last_result) { scalar_clone(r, &last_result); return true; } else { set_eval_error("no previous result..."); return false; } } return real_symbol_handler ? real_symbol_handler(r, symbol) : false; } static bool func_eval(eval_scalar *r, char *name, eval_scalarlist *params) { eval_func myfuncs[] = { {"_", 0, {SCALAR_ANY}, "last result"}, {NULL}, }; if (std_eval_func_handler(r, name, params, myfuncs)) return true; return real_func_handler ? real_func_handler(r, name, params) : false; } /* * eval help */ #define FH_HEAD 1 #define FH_DESC 2 // FIXME: disfunctional... class ht_help_lexer: public ht_syntax_lexer { public: /* overwritten */ virtual vcp getcolor_syntax(uint pal_index) { return VCP(VC_BLUE, VC_TRANSPARENT); } virtual lexer_state getinitstate() { return FH_HEAD; } virtual lexer_token geterrortoken() { return 3; } virtual const char *getname() { return "bla"; } virtual lexer_token gettoken(void *buf, uint buflen, text_pos p, bool start_of_line, lexer_state *ret_state, uint *ret_len) { *ret_len = buflen; lexer_token last = *ret_state; if (start_of_line && buflen == 0) { *ret_state = FH_HEAD; } else { *ret_state = FH_DESC; } return buflen ? last : 0; } virtual vcp gettoken_color(lexer_token t) { switch (t) { case FH_HEAD: return VCP(VC_LIGHT(VC_WHITE), VC_TRANSPARENT); case FH_DESC: return VCP(VC_BLACK, VC_TRANSPARENT); } return VCP(VC_RED, VC_TRANSPARENT); } }; static void dialog_fhelp(File *f) { ht_help_lexer *l = new ht_help_lexer(); l->init(); ht_ltextfile *t = new ht_ltextfile(f, true, NULL); Bounds b, c; app->getbounds(&c); b = c; b.w = 70; b.h = 19; b.x = (c.w - b.w) / 2, b.y = (c.h - b.h) / 2; c = b; ht_dialog dialog; dialog.init(&b, "eval() - functions", FS_KILLER | FS_TITLE | FS_MOVE | FS_RESIZE); b.x = 0; b.y = 0; b.w -= 2; b.h -= 2; ht_text_viewer *v = new ht_text_viewer(); v->init(&b, true, t, NULL); v->set_lexer(l, true); dialog.insert(v); b = c; b.x = b.w-2; b.y = 0; b.w = 1; b.h-=2; ht_scrollbar *hs=new ht_scrollbar(); hs->init(&b, &dialog.pal, true); dialog.setvscrollbar(hs); dialog.setpalette(palkey_generic_cyan); dialog.run(0); dialog.done(); } void dialog_eval_help(eval_func_handler func_handler, eval_symbol_handler symbol_handler, void *context) { real_func_handler = func_handler; real_symbol_handler = symbol_handler; eval_scalar res; if (eval(&res, "help()", func_eval, symbol_eval, context)) { eval_str s; scalar_context_str(&res, &s); scalar_destroy(&res); ConstMemMapFile *f = new ConstMemMapFile(s.value, s.len); dialog_fhelp(f); string_destroy(&s); } } /* * */ static int sprint_base2(char *x, uint32 value, bool leading_zeros) { char *ix = x; bool draw = leading_zeros; for (int i=0; i<32; i++) { bool v = value & (1<<(32-i-1)); if (v) draw = true; if (draw) *x++ = v ? '1' : '0'; } *x = 0; return x-ix; } static int sprint_base2_0(char *x, uint32 value, int zeros) { char *ix = x; char vi = 0; uint32 m = 0x80000000; while (zeros < 32) {m >>= 1; zeros++;} do { if (value & m) { while (vi--) *(x++)='0'; vi = 0; *x = '1'; x++; } else { vi++; } m >>= 1; } while (m); if (!value) *(x++)='0'; *x = 0; return x-ix; } static void nicify(char *dest, const char *src, int d) { *dest = *src; int l = strlen(src); if (!l) return; dest++; src++; while (l--) { if ((l%d==0) && (l>1)) { *dest='\''; dest++; } *dest++ = *src++; } *dest=0; } static void do_eval(ht_strinputfield *s, ht_statictext *t, const char *b, eval_func_handler func_handler, eval_symbol_handler symbol_handler, void *context) { eval_scalar r; String x; real_func_handler = func_handler; real_symbol_handler = symbol_handler; if (eval(&r, b, func_eval, symbol_eval, context)) { switch (r.type) { case SCALAR_INT: { char buf1[1024]; char buf2[1024]; ht_snprintf(buf1, sizeof buf1, "%qx", r.scalar.integer.value); nicify(buf2, buf1, 4); x.assignFormat("64bit integer:\nhex %s\n", buf2); ht_snprintf(buf1, sizeof buf1, "%qu", r.scalar.integer.value); nicify(buf2, buf1, 3); x.appendFormat("dec %s\n", buf2); if ((sint64)r.scalar.integer.value < 0) { ht_snprintf(buf1, sizeof buf1, "%qd", r.scalar.integer.value); nicify(buf2, buf1+1, 3); x.appendFormat("sdec -%s\n", buf2); } ht_snprintf(buf1, sizeof buf1, "%qo", r.scalar.integer.value); nicify(buf2, buf1, 3); x.appendFormat("oct %s\n", buf2); uint32 l = r.scalar.integer.value; ht_snprintf(buf1, sizeof buf1, "%032b", l); nicify(buf2, buf1, 8); x.appendFormat("binlo %s\n", buf2); if (r.scalar.integer.value >> 32) { l = r.scalar.integer.value >> 32; ht_snprintf(buf1, sizeof buf1, "%032b", l); nicify(buf2, buf1, 8); x.appendFormat("binhi %s\n", buf2); } byte bb[4]; /* big-endian string */ x += "string \""; createForeignInt(bb, r.scalar.integer.value, 4, big_endian); x.append(bb, 4); x += "\" 32bit big-endian (e.g. network)\n"; /* little-endian string */ x += "string \""; createForeignInt(bb, r.scalar.integer.value, 4, little_endian); x.append(bb, 4); x += "\" 32bit little-endian (e.g. x86)\n"; break; } case SCALAR_STR: { char buf1[1024]; /* c-escaped */ x = "string:\nc-escaped \""; x.append((byte*)buf1, escape_special(buf1, sizeof buf1, r.scalar.str.value, r.scalar.str.len, NULL, true)); /* raw */ x += "'\nraw '"; x.append((byte*)r.scalar.str.value, r.scalar.str.len); x += "'\n"; break; } case SCALAR_FLOAT: { char buf1[1024]; sprintf(buf1, "val %.20f\nnorm %.20e", r.scalar.floatnum.value, r.scalar.floatnum.value); // FIXME: endianess/hardware format float ff = ((float)r.scalar.floatnum.value); uint32 f; memcpy(&f, &ff, 4); x += "\n-- IEEE-754, 32 bit --"; x.appendFormat("\nhex %08x\nbin ", f); x.append((byte*)buf1, sprint_base2(buf1, f, true)); x.appendFormat("\nsplit %c1.", (f>>31) ? '-' : '+'); x.append((byte*)buf1, sprint_base2_0(buf1, f&((1<<23)-1), 23)); x.appendFormat("b * 2^%d", ((f>>23)&255)-127); break; } default: x = "?"; } if (have_last_result) scalar_destroy(&last_result); scalar_clone(&last_result, &r); have_last_result = true; scalar_destroy(&r); } else { const char *str="?"; int pos=0; get_eval_error(&str, &pos); s->isetcursor(pos); x.assignFormat("error at pos %d: %s", pos+1, str); } String in; in.assign('\0'); x.translate(in, " "); t->settext(x.contentChar()); } #define BUTTON_HELP 100 void eval_dialog(eval_func_handler func_handler, eval_symbol_handler symbol_handler, void *context) { Bounds b, c; app->getbounds(&c); b.w=70; b.h=17; b.x=(c.w-b.w)/2; b.y=(c.h-b.h)/2; ht_dialog *d=new ht_dialog(); c=b; const char *hint="type integer, float or string expression to evaluate"; d->init(&b, "evaluate", FS_TITLE | FS_MOVE | FS_RESIZE); List *ehist = (List*)getAtomValue(HISTATOM_EVAL_EXPR); /* input line */ b.assign(1, 1, c.w-14, 1); ht_strinputfield *s = new ht_strinputfield(); s->init(&b, 255, ehist); d->insert(s); /* help button */ ht_button *bhelp = new ht_button(); b.assign(c.w-12, 1, 10, 2); bhelp->init(&b, "~Functions", BUTTON_HELP); d->insert(bhelp); /* result text */ b.assign(1, 3, c.w-4, c.h-5); ht_statictext *t = new ht_statictext(); t->init(&b, hint, align_left); t->growmode = MK_GM(GMH_LEFT, GMV_FIT); d->insert(t); int button; while ((button = d->run(false)) != button_cancel) { switch (button) { case button_ok: { ht_strinputfield_data str; char b[1024]; ViewDataBuf vdb(s, &str, sizeof str); if (str.textlen) { bin2str(b, str.text, str.textlen); insert_history_entry(ehist, b, 0); do_eval(s, t, b, func_handler, symbol_handler, context); } else { t->settext(hint); } break; } case BUTTON_HELP: dialog_eval_help(func_handler, symbol_handler, context); break; } } d->done(); delete d; } ht-2.0.22/str.cc0000644000175000001440000003701711010140021010230 00000000000000/* * HT Editor * str.cc * * Copyright (C) 2002 Stefan Weyergraf (stefan@weyergraf.de) * Copyright (C) 2002, 2003 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include "except.h" #include "htdebug.h" #include "snprintf.h" #include "str.h" #include "stream.h" #include "strtools.h" #include "tools.h" #ifdef HAVE_HT_OBJECTS #include "atom.h" #endif extern "C" { #include "regex.h" } /* * CLASS String */ /** * creates empty string */ String::String() { mContent = NULL; realloc(0); } /** * create string from char * */ String::String(const char *s) { mContent = NULL; assign(s); } /** * copy constructor */ String::String(const String *s) { mContent = NULL; assign(s); } /** * copy constructor */ String::String(const String &s) { assert(&s != this); mContent = NULL; assign(s); } /** * creates string from array |s| size |aLength| */ String::String(const byte *s, int aLength) { mContent = NULL; assign(s, aLength); } /** * creates string with |count| times |c| */ String::String(char c, int count) { mContent = NULL; assign(c, count); } String::~String() { free(mContent); } /** * (re-)assigns string to |s| */ void String::assign(const String *s) { realloc(s->mLength); memcpy(mContent, s->mContent, mLength); } /** * (re-)assigns string to |s| */ void String::assign(const String &s) { realloc(s.mLength); memcpy(mContent, s.mContent, mLength); } /** * (re-)assigns string to char * |s| */ void String::assign(const char *s) { int slen = s ? strlen(s) : 0; realloc(slen); memcpy(mContent, s, mLength); } /** * (re-)assigns string to array |s| length |aLength| */ void String::assign(const byte *s, int aLength) { realloc(aLength); memcpy(mContent, s, mLength); } /** * (re-)assigns string to |count| times |c| */ void String::assign(char c, int count) { realloc(count); memset(mContent, c, count); } /** * (re-)assigns string via ht_snprintf */ void String::assignFormat(const char *s, ...) { char buf[1024]; va_list vargs; va_start(vargs, s); ht_vsnprintf(buf, sizeof buf, s, vargs); va_end(vargs); assign(buf); } /** * appends |s| to the end */ void String::append(const String &s) { if (s.mLength) { int oldLength = mLength; realloc(mLength + s.mLength); memcpy(&mContent[oldLength], s.mContent, s.mLength); } } void String::append(const char *s) { if (s && *s) { int oldLength = mLength; int slen = strlen(s); realloc(mLength + slen); memcpy(&mContent[oldLength], s, slen); } } void String::appendChar(char c) { realloc(mLength+1); mContent[mLength-1] = c; } void String::append(const byte *s, int aLength) { if (aLength <= 0) return; int oldLength = mLength; realloc(mLength + aLength); memcpy(&mContent[oldLength], s, aLength); } /** * (re-)append to string via ht_snprintf */ void String::appendFormat(const char *s, ...) { char buf[1024]; va_list vargs; va_start(vargs, s); ht_vsnprintf(buf, sizeof buf, s, vargs); va_end(vargs); append(buf); } /** * prepends |s| to the front */ void String::prepend(const String &s) { if (s.mLength) { int oldLength = mLength; realloc(mLength + s.mLength); memmove(&mContent[s.mLength], &mContent[0], oldLength); memcpy(&mContent[0], s.mContent, s.mLength); } } /** * Empties string. */ void String::clear() { realloc(0); } String *String::clone() const { return new String(mContent, mLength); } /** * compares to characters. * used in compareTo() and findXXX() (and therefore replace()) * @returns 0 for equality, negative number if |c1c2| */ int String::compareChar(char c1, char c2) const { if (c1 < c2) return -1; if (c1 > c2) return 1; return 0; } int String::compare(const char *s) const { if (!mLength) { return (s) ? -1: 0; } if (!s) { return 1; } int l = mLength; for (int i=0; i < l; i++) { if (!*s) return 1; int r = compareChar(mContent[i], s[i]); if (r) return r; } if (s[l]) return -1; return 0; } int String::compare(const String &s) const { if (!mContent) { return (s.mContent) ? -1: 0; } if (!s.mContent) { return 1; } int l = MIN(mLength, s.mLength); for (int i=0; igetObjectID()); return compare(*((String *)o)); } uint String::countChar(char c) const { int i = 0; uint n = 0; while (i < mLength) { if (compareChar(mContent[i], c) == 0) n++; i++; } return n; } /** * Crops the string to contain a maximum of |aNewLength| characters. */ void String::crop(int aNewLength) { if ((aNewLength >= 0) && (aNewLength < mLength)) realloc(aNewLength); } /** * Deletes |aLength| characters at |pos| */ void String::del(int pos, int aLength) { if (pos < 0) { aLength += pos; pos = 0; } if (aLength <= 0 || pos >= mLength) return; if (pos+aLength >= mLength) aLength = mLength-pos; if (!aLength) return; if (pos + aLength < mLength) { memmove(&mContent[pos], &mContent[pos+aLength], mLength-aLength-pos); } realloc(mLength-aLength); } /** * Escapes certains characters in a c-style manner (all characters < 0x20). * @param aSpecialChars characters that need a \ * @param bit7 hex encode (\x..) characters >127 */ void String::escape(const char *aSpecialChars, bool bit7) { if (!mLength) return; String copy(this); realloc(mLength*4); realloc(escape_special((char*)mContent, mLength+1, copy.mContent, copy.mLength, aSpecialChars, bit7)); } /** * Search forwards for |c| in string * @param c character to search for * @param start first character position to look for * @returns position of character or number < 0 if not found */ int String::findCharFwd(char c, int start, int ith_match) const { if (!mLength) return -1; if (start >= mLength) return -1; if (start < 0) start = 0; for (int i=start; i < mLength; i++) { if (compareChar(mContent[i], c) == 0) { if (ith_match <= 1) return i; ith_match--; } } return -1; } /** * Search backwards for |c| in string * @param c character to search for * @param start first character position to look for * @returns position of character or number < 0 if not found */ int String::findCharBwd(char c, int start, int ith_match) const { if (!mLength) return -1; if (start >= mLength) return -1; if (start < 0) start = mLength-1; for (int i=start; i>=0; i--) { if (compareChar(mContent[i], c) == 0) { if (ith_match <= 1) return i; ith_match--; } } return -1; } /** * Search forwards for |s| in string * @param s string to search for * @param start first character position to look for * @returns position of character or number < 0 if not found */ int String::findStringFwd(const String &s, int start, int ith_match) const { if (start < 0) start = 0; if (!mLength || !s.mLength || (start+s.mLength > mLength)) return -1; for (int i=start; (i+s.mLength <= mLength); i++) { for (int j=i; (j>=0) && (j+s.mLength <= mLength) && (j-i < s.mLength); j++) { if (compareChar(mContent[j], s.mContent[j-i])) goto notfound; if (ith_match <= 0) return i; ith_match--; } if (ith_match <= 1) return i; ith_match--; notfound:; } return -1; } /** * Search backwards for |s| in string * @param s string to search for * @param start first character position to look for * @returns position of character or number < 0 if not found */ int String::findStringBwd(const String &s, int start, int ith_match) const { assert("not yet implemented" && 0); if (!mLength) return -1; return -1; } /** * Assign s, destroy s */ void String::grab(String &s) { free(mContent); mLength = s.mLength; mContent = s.mContent; s.mLength = 0; s.mContent = NULL; s.realloc(0); } /** * Get the content of the String. * The original String gets destroyed. * It's up to you to free the content. */ byte *String::grabContent() { byte *res = mContent; mContent = NULL; return res; } char *String::grabContentChar() { char *res = (char*)mContent; mContent = NULL; return res; } /** * inserts |s| at postion |pos| in string. */ void String::insert(const String &s, int pos) { if (pos > mLength || pos < 0) throw MsgException("index out of bounds"); if (!s.mLength) return; realloc(mLength+s.mLength); if (mLength-s.mLength-pos > 0) memmove(&mContent[pos+s.mLength], &mContent[pos], mLength-s.mLength-pos); memmove(&mContent[pos], s.mContent, s.mLength); } bool String::leftSplit(char chr, String &initial, String &rem) const { int pivot = findCharFwd(chr); if (pivot < 0) { initial = *this; rem.clear(); return false; } subString(0, pivot, initial); subString(pivot+1, length(), rem); return true; } void String::load(ObjectStream &s) { #if 0 mContent = NULL; GET_INT32D(s, mLength); realloc(mLength); GET_BINARY(s, mContent, mLength); #else GET_LSTRING(s, mContent, mLength); realloc(mLength); #endif } ObjectID String::getObjectID() const { return OBJID_STRING; } void String::realloc(int aNewSize) { mLength = aNewSize; mContent = (byte*)::realloc(mContent, mLength+1); if (!mContent) throw std::bad_alloc(); mContent[mLength] = 0; /* if (mContent) { if (aNewSize) { mContent = (byte*)::realloc(mContent, aNewSize); } else { free(mContent); mContent = NULL; } } else { if (aNewSize) { mContent = (byte*)::malloc(aNewSize); } } mLength = aNewSize;*/ } #define MAX_REGEX_MATCHES 32 bool String::regexMatch(const String &aRegEx, Container *resultStrings) const { const char *re = aRegEx.toString(); bool result = false; regex_t rx; int r = regcomp(&rx, re, REG_EXTENDED | ((compareChar('A','a')==0) ? REG_ICASE : 0)); if (r) throw MsgException("EINVAL"); regmatch_t pmatch[MAX_REGEX_MATCHES]; if (regexec(&rx, (char*)mContent, MAX_REGEX_MATCHES, pmatch, 0) != 0) return false; if (resultStrings) { for (int i=1; iinsert(s); } } delete re; return result; } /** * replaces all occurences of |what| in string with |with| * @param what searchstring * @param with replacement * @returns number of replacements */ int String::replace(String &what, String &with) { int p = findStringFwd(what); int whatlen = what.length(); int withlen = with.length(); int numRepl = 0; while (p >= 0) { if (whatlen == withlen) { // replace in situ memmove(&mContent[p], with.mContent, withlen); } else { del(p, whatlen); insert(with, p); } numRepl++; p = findStringFwd(what, p+withlen); } return numRepl; } bool String::rightSplit(char chr, String &initial, String &rem) const { int pivot = findCharBwd(chr); if (pivot < 0) { initial = *this; rem.clear(); return false; } subString(0, pivot, initial); subString(pivot+1, length(), rem); return true; } /** * assigns result to the substring with * |aLength| characters starting at |aStart|. * @param result will hold the result * @param aStart position of first character in new string * @param aLength number of characters to copy * @returns number of characters copied */ int String::subString(int aStart, int aLength, String &result) const { if (aLength <= 0 || aStart >= mLength) { result.clear(); return 0; } if (aStart+aLength >= mLength) aLength = mLength-aStart; result.assign(&mContent[aStart], aLength); return aLength; } void String::store(ObjectStream &s) const { #if 0 PUT_INT32D(s, mLength); s.putCommentf("%y", this); PUT_BINARY(s, mContent, mLength); #else PUT_LSTRING(s, mContent, mLength); #endif } /** * */ void String::transformCase(StringCase c) { if (c==stringCaseCaps) { } else { for (int i=0; iescape
. * Note that output isnt defined if string wasnt escaped before. */ void String::unescape() { String copy(this); realloc(unescape_special(mContent, mLength, (char*)copy.mContent)); } String &String::operator +=(char c) { realloc(mLength+1); mContent[mLength-1] = c; return *this; } /* * global */ String operator +(const String &s1, const String &s2) { String temp = String(s1); temp.append(s2); return temp; } String operator +(const char *s1, const String &s2) { String temp = String(s1); temp.append(s2); return temp; } /* * CLASS IString */ IString::IString() { } IString *IString::clone() const { IString *r = new IString(); *r = *this; return r; } int IString::compareChar(char c1, char c2) const { c1 = tolower(c1); c2 = tolower(c2); return String::compareChar(c1, c2); } ObjectID IString::getObjectID() const { return OBJID_ISTRING; } ht-2.0.22/htmachoimg.h0000644000175000001440000000231310615341620011413 00000000000000/* * HT Editor * htmachoimg.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTMACHOIMG_H__ #define __HTMACHOIMG_H__ #include "htanaly.h" #include "htmacho.h" #include "formats.h" extern format_viewer_if htmachoimage_if; /* * CLASS ht_macho_aviewer */ class ht_macho_aviewer: public ht_aviewer { public: ht_macho_shared_data *macho_shared; void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Analyser *Analyser, ht_macho_shared_data *macho_shared); virtual void setAnalyser(Analyser *a); }; #endif /* !__HTMACHOIMG_H__ */ ht-2.0.22/httag.cc0000644000175000017500000011246411724770012010560 00000000000000/* * HT Editor * httag.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "htdebug.h" #include "strtools.h" #include "httag.h" #include "tools.h" #include #include #include /**/ // these 3 functions are evil. but they are only used in statictag_to_tag(). // they should go sometime... static uint32 hexb(const char *s) { byte b=*(byte*)s; b -= '0'; if (b > 9) b -= 'a'-'0'-10; byte c = *(byte*)(s+1); c -= '0'; if (c > 9) c -= 'a'-'0'-10; return (b << 4) + c; } static uint32 hexw(const char *s) { return (hexb(s)<<8) | hexb(s+2); } static uint32 hexd(const char *s) { return (hexw(s)<<16) | hexw(s+4); } // static TAGSTRING *tag_error(TAGSTRING *buf, int maxlen) { while (maxlen-- > 0) { *buf++ = 0; } return buf; } TAGSTRING *tag_make_sel(TAGSTRING *buf, int maxlen, const char *string) { return tag_make_ref(buf, maxlen, 0, 0, 0, 0, string); } TAGSTRING *tag_make_ref_len(TAGSTRING *buf, int maxlen, uint32 id128_1, uint32 id128_2, uint32 id128_3, uint32 id128_4, const char *string, int strlen) { if (maxlen <= (signed)sizeof (ht_tag_sel)) return tag_error(buf, maxlen); if (maxlen <= (signed)sizeof (ht_tag_sel)+strlen) { strlen = maxlen - sizeof (ht_tag_sel) - 1; } ht_tag_sel tag; tag.escape = '\e'; tag.magic = HT_TAG_SEL; tag.id128_1 = id128_1; tag.id128_2 = id128_2; tag.id128_3 = id128_3; tag.id128_4 = id128_4; tag.strlen = strlen; tag.flush(buf); memcpy(buf + sizeof(tag), string, strlen); return buf + sizeof(tag) + strlen; } TAGSTRING *tag_make_ref(TAGSTRING *buf, int maxlen, uint32 id128_1, uint32 id128_2, uint32 id128_3, uint32 id128_4, const char *string) { return tag_make_ref_len(buf, maxlen, id128_1, id128_2, id128_3, id128_4, string, strlen(string)); } TAGSTRING *tag_make_flags(TAGSTRING *buf, int maxlen, uint32 id, FileOfs ofs) { if (maxlen <= (signed)sizeof (ht_tag_flags)) return tag_error(buf, maxlen); ht_tag_flags tag; tag.escape = '\e'; tag.magic = HT_TAG_FLAGS; tag.offset = ofs; tag.id = id; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_group(TAGSTRING *buf, int maxlen) { if (maxlen <= (signed)sizeof (ht_tag_group)) return tag_error(buf, maxlen); ht_tag_group tag; tag.escape = '\e'; tag.magic = HT_TAG_GROUP; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_color(TAGSTRING *buf, int maxlen, uint32 color) { if (maxlen <= (signed)sizeof (ht_tag_color)) return tag_error(buf, maxlen); ht_tag_color tag; tag.escape = '\e'; tag.magic = HT_TAG_COLOR; tag.color = color; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_default_color(TAGSTRING *buf, int maxlen) { if (maxlen <= (signed)sizeof (ht_tag_color)) return tag_error(buf, maxlen); ht_tag_color tag; tag.escape = '\e'; tag.magic = HT_TAG_COLOR; tag.color = 0xffffffffU; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_edit_byte(TAGSTRING *buf, int maxlen, FileOfs ofs) { if (maxlen <= (signed)sizeof (ht_tag_edit_byte)) return tag_error(buf, maxlen); ht_tag_edit_byte tag; tag.escape = '\e'; tag.magic = HT_TAG_EDIT_BYTE; tag.offset = ofs; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_edit_word(TAGSTRING *buf, int maxlen, FileOfs ofs, tag_endian e) { if (maxlen <= (signed)sizeof (ht_tag_edit_word_generic)) return tag_error(buf, maxlen); ht_tag_edit_word_generic tag; tag.escape = '\e'; byte m = 0xff; switch (e) { case tag_endian_big: m = HT_TAG_EDIT_WORD_BE; break; case tag_endian_little: m = HT_TAG_EDIT_WORD_LE; break; case tag_endian_var: m = HT_TAG_EDIT_WORD_VE; break; } tag.magic = m; tag.offset = ofs; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_edit_dword(TAGSTRING *buf, int maxlen, FileOfs ofs, tag_endian e) { if (maxlen <= (signed)sizeof (ht_tag_edit_dword_generic)) return tag_error(buf, maxlen); ht_tag_edit_dword_generic tag; tag.escape = '\e'; byte m = 0xff; switch (e) { case tag_endian_big: m = HT_TAG_EDIT_DWORD_BE; break; case tag_endian_little: m = HT_TAG_EDIT_DWORD_LE; break; case tag_endian_var: m = HT_TAG_EDIT_DWORD_VE; break; } tag.magic = m; tag.offset = ofs; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_edit_qword(TAGSTRING *buf, int maxlen, FileOfs ofs, tag_endian e) { if (maxlen <= (signed)sizeof (ht_tag_edit_qword_generic)) return tag_error(buf, maxlen); ht_tag_edit_qword_generic tag; tag.escape = '\e'; byte m = 0xff; switch (e) { case tag_endian_big: m = HT_TAG_EDIT_QWORD_BE; break; case tag_endian_little: m = HT_TAG_EDIT_QWORD_LE; break; case tag_endian_var: m = HT_TAG_EDIT_QWORD_VE; break; } tag.magic = m; tag.offset = ofs; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_edit_time(TAGSTRING *buf, int maxlen, FileOfs ofs, tag_endian e) { if (maxlen <= (signed)sizeof (ht_tag_edit_time)) return tag_error(buf, maxlen); ht_tag_edit_time tag; tag.escape = '\e'; byte m = 0xff; switch (e) { case tag_endian_big: m = HT_TAG_EDIT_TIME_BE; break; case tag_endian_little: m = HT_TAG_EDIT_TIME_LE; break; case tag_endian_var: m = HT_TAG_EDIT_TIME_VE; break; } tag.magic = m; tag.offset = ofs; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_edit_char(TAGSTRING *buf, int maxlen, FileOfs ofs) { if (maxlen <= (signed)sizeof (ht_tag_edit_char)) return tag_error(buf, maxlen); ht_tag_edit_char tag; tag.escape = '\e'; tag.magic = HT_TAG_EDIT_CHAR; tag.offset = ofs; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_edit_bit(TAGSTRING *buf, int maxlen, FileOfs ofs, int bitidx) { if (maxlen <= (signed)sizeof (ht_tag_edit_bit)) return tag_error(buf, maxlen); ht_tag_edit_bit tag; tag.escape = '\e'; tag.magic = HT_TAG_EDIT_BIT; tag.offset = ofs; tag.bitidx = bitidx; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_edit_selvis(TAGSTRING *buf, int maxlen, FileOfs offset, char ch) { if (maxlen <= (signed)sizeof (ht_tag_edit_selvis)) return tag_error(buf, maxlen); ht_tag_edit_selvis tag; tag.escape = '\e'; tag.magic = HT_TAG_EDIT_SELVIS; tag.offset = offset; tag.ch = ch; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_desc_byte(TAGSTRING *buf, int maxlen, FileOfs ofs32, uint32 id32) { if (maxlen <= (signed)sizeof (ht_tag_desc_byte)) return tag_error(buf, maxlen); ht_tag_desc_byte tag; tag.escape = '\e'; tag.magic = HT_TAG_DESC_BYTE; tag.offset = ofs32; tag.id = id32; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_desc_word(TAGSTRING *buf, int maxlen, FileOfs ofs32, uint32 id32, tag_endian e) { if (maxlen <= (signed)sizeof (ht_tag_desc_word_generic)) return tag_error(buf, maxlen); ht_tag_desc_word_generic tag; tag.escape = '\e'; byte m = 0xff; switch (e) { case tag_endian_big: m = HT_TAG_DESC_WORD_BE; break; case tag_endian_little: m = HT_TAG_DESC_WORD_LE; break; case tag_endian_var: m = HT_TAG_DESC_WORD_VE; break; } tag.magic = m; tag.offset = ofs32; tag.id = id32; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_desc_dword(TAGSTRING *buf, int maxlen, FileOfs ofs32, uint32 id32, tag_endian e) { if (maxlen <= (signed)sizeof (ht_tag_desc_dword_generic)) return tag_error(buf, maxlen); ht_tag_desc_dword_generic tag; tag.escape = '\e'; byte m = 0xff; switch (e) { case tag_endian_big: m = HT_TAG_DESC_DWORD_BE; break; case tag_endian_little: m = HT_TAG_DESC_DWORD_LE; break; case tag_endian_var: m = HT_TAG_DESC_DWORD_VE; break; } tag.magic = m; tag.offset = ofs32; tag.id = id32; tag.flush(buf); return buf + sizeof(tag); } TAGSTRING *tag_make_desc_qword(TAGSTRING *buf, int maxlen, FileOfs ofs32, uint32 id32, tag_endian e) { if (maxlen <= (signed)sizeof (ht_tag_desc_qword_generic)) return tag_error(buf, maxlen); ht_tag_desc_qword_generic tag; tag.escape = '\e'; byte m = 0xff; switch (e) { case tag_endian_big: m = HT_TAG_DESC_QWORD_BE; break; case tag_endian_little: m = HT_TAG_DESC_QWORD_LE; break; case tag_endian_var: m = HT_TAG_DESC_QWORD_VE; break; } tag.magic = m; tag.offset = ofs32; tag.id = id32; tag.flush(buf); return buf + sizeof(tag); } /**/ void statictag_to_tag(const char *statictag_str, TAGSTRING *tag_str, int maxlen, uint64 relocation, bool std_bigendian) { if (maxlen < 1) return; if (maxlen == 1) { *tag_str = 0; return; } FileOfs ofs = 0; ID id; TAGSTRING *tag_str_end = tag_str + maxlen - 1; while (*statictag_str) { if (*statictag_str == '\e') { switch ((byte)*(statictag_str+1)) { case HT_STATICTAG_EDIT_BYTE: ofs = hexd(statictag_str+2); tag_str = tag_make_edit_byte(tag_str, tag_str_end-tag_str, ofs+relocation); statictag_str += 2+8; break; case HT_STATICTAG_EDIT_WORD_LE: ofs = hexd(statictag_str+2); tag_str = tag_make_edit_word(tag_str, tag_str_end-tag_str, ofs+relocation, tag_endian_little); statictag_str += 2+8; break; case HT_STATICTAG_EDIT_DWORD_LE: ofs = hexd(statictag_str+2); tag_str = tag_make_edit_dword(tag_str, tag_str_end-tag_str, ofs+relocation, tag_endian_little); statictag_str += 2+8; break; case HT_STATICTAG_EDIT_QWORD_LE: ofs = hexd(statictag_str+2); tag_str = tag_make_edit_qword(tag_str, tag_str_end-tag_str, ofs+relocation, tag_endian_little); statictag_str += 2+8; break; case HT_STATICTAG_EDIT_WORD_BE: ofs = hexd(statictag_str+2); tag_str = tag_make_edit_word(tag_str, tag_str_end-tag_str, ofs+relocation, tag_endian_big); statictag_str += 2+8; break; case HT_STATICTAG_EDIT_DWORD_BE: ofs = hexd(statictag_str+2); tag_str = tag_make_edit_dword(tag_str, tag_str_end-tag_str, ofs+relocation, tag_endian_big); statictag_str += 2+8; break; case HT_STATICTAG_EDIT_QWORD_BE: ofs = hexd(statictag_str+2); tag_str = tag_make_edit_qword(tag_str, tag_str_end-tag_str, ofs+relocation, tag_endian_big); statictag_str += 2+8; break; case HT_STATICTAG_EDIT_WORD_VE: ofs = hexd(statictag_str+2); tag_str = tag_make_edit_word(tag_str, tag_str_end-tag_str, ofs+relocation, std_bigendian ? tag_endian_big : tag_endian_little); statictag_str += 2+8; break; case HT_STATICTAG_EDIT_DWORD_VE: ofs = hexd(statictag_str+2); tag_str = tag_make_edit_dword(tag_str, tag_str_end-tag_str, ofs+relocation, std_bigendian ? tag_endian_big : tag_endian_little); statictag_str += 2+8; break; case HT_STATICTAG_EDIT_QWORD_VE: ofs = hexd(statictag_str+2); tag_str = tag_make_edit_qword(tag_str, tag_str_end-tag_str, ofs+relocation, std_bigendian ? tag_endian_big : tag_endian_little); statictag_str += 2+8; break; case HT_STATICTAG_EDIT_TIME_LE: ofs = hexd(statictag_str+2); tag_str = tag_make_edit_time(tag_str, tag_str_end-tag_str, ofs+relocation, tag_endian_little); statictag_str += 2+8; break; case HT_STATICTAG_EDIT_TIME_BE: ofs = hexd(statictag_str+2); tag_str = tag_make_edit_time(tag_str, tag_str_end-tag_str, ofs+relocation, tag_endian_big); statictag_str += 2+8; break; case HT_STATICTAG_EDIT_TIME_VE: ofs = hexd(statictag_str+2); tag_str = tag_make_edit_time(tag_str, tag_str_end-tag_str, ofs+relocation, std_bigendian ? tag_endian_big : tag_endian_little); statictag_str += 2+8; break; case HT_STATICTAG_EDIT_CHAR: ofs = hexd(statictag_str+2); tag_str = tag_make_edit_char(tag_str, tag_str_end-tag_str, ofs+relocation); statictag_str += 2+8; break; case HT_STATICTAG_EDIT_BIT: { ofs = hexd(statictag_str+2); int bitidx = hexb(statictag_str+2+8); tag_str = tag_make_edit_bit(tag_str, tag_str_end-tag_str, ofs+relocation, bitidx); statictag_str += 2+8+2; break; } case HT_STATICTAG_EDIT_SELVIS: { ofs = hexd(statictag_str+2); char ch = hexb(statictag_str+2+8); tag_str = tag_make_edit_selvis(tag_str, tag_str_end-tag_str, ofs+relocation, ch); statictag_str += 2+8+2; break; } case HT_STATICTAG_DESC_BYTE: ofs = hexd(statictag_str+2); id = hexd(statictag_str+2+8); tag_str = tag_make_desc_byte(tag_str, tag_str_end-tag_str, ofs+relocation, id); statictag_str += 2+8+8; break; case HT_STATICTAG_DESC_WORD_LE: ofs = hexd(statictag_str+2); id = hexd(statictag_str+2+8); tag_str = tag_make_desc_word(tag_str, tag_str_end-tag_str, ofs+relocation, id, tag_endian_little); statictag_str += 2+8+8; break; case HT_STATICTAG_DESC_DWORD_LE: ofs = hexd(statictag_str+2); id = hexd(statictag_str+2+8); tag_str = tag_make_desc_dword(tag_str, tag_str_end-tag_str, ofs+relocation, id, tag_endian_little); statictag_str += 2+8+8; break; case HT_STATICTAG_DESC_QWORD_LE: ofs = hexd(statictag_str+2); id = hexd(statictag_str+2+8); tag_str = tag_make_desc_qword(tag_str, tag_str_end-tag_str, ofs+relocation, id, tag_endian_little); statictag_str += 2+8+8; break; case HT_STATICTAG_DESC_WORD_BE: ofs = hexd(statictag_str+2); id = hexd(statictag_str+2+8); tag_str = tag_make_desc_word(tag_str, tag_str_end-tag_str, ofs+relocation, id, tag_endian_big); statictag_str += 2+8+8; break; case HT_STATICTAG_DESC_DWORD_BE: ofs = hexd(statictag_str+2); id = hexd(statictag_str+2+8); tag_str = tag_make_desc_dword(tag_str, tag_str_end-tag_str, ofs+relocation, id, tag_endian_big); statictag_str += 2+8+8; break; case HT_STATICTAG_DESC_QWORD_BE: ofs = hexd(statictag_str+2); id = hexd(statictag_str+2+8); tag_str = tag_make_desc_qword(tag_str, tag_str_end-tag_str, ofs+relocation, id, tag_endian_big); statictag_str += 2+8+8; break; case HT_STATICTAG_DESC_WORD_VE: ofs = hexd(statictag_str+2); id = hexd(statictag_str+2+8); tag_str = tag_make_desc_word(tag_str, tag_str_end-tag_str, ofs+relocation, id, std_bigendian ? tag_endian_big : tag_endian_little); statictag_str += 2+8+8; break; case HT_STATICTAG_DESC_DWORD_VE: ofs = hexd(statictag_str+2); id = hexd(statictag_str+2+8); tag_str = tag_make_desc_dword(tag_str, tag_str_end-tag_str, ofs+relocation, id, std_bigendian ? tag_endian_big : tag_endian_little); statictag_str += 2+8+8; break; case HT_STATICTAG_DESC_QWORD_VE: ofs = hexd(statictag_str+2); id = hexd(statictag_str+2+8); tag_str = tag_make_desc_qword(tag_str, tag_str_end-tag_str, ofs+relocation, id, std_bigendian ? tag_endian_big : tag_endian_little); statictag_str += 2+8+8; break; case HT_STATICTAG_SEL: { uint32 id_1 = hexd(statictag_str+2); uint32 id_2 = hexd(statictag_str+2+8); uint32 id_3 = hexd(statictag_str+2+16); uint32 id_4 = hexd(statictag_str+2+24); byte len = hexb(statictag_str+2+8+8+8+8); tag_str = tag_make_ref_len(tag_str, tag_str_end-tag_str, id_1, id_2, id_3, id_4, statictag_str+2+8+8+8+8+2, len); statictag_str += 2+8+8+8+8+2+len; break; } case HT_STATICTAG_FLAGS: { ofs = hexd(statictag_str+2); id = hexd(statictag_str+2+8); tag_str = tag_make_flags(tag_str, tag_str_end-tag_str, id, ofs+relocation); statictag_str += 2+8+8; break; } case HT_STATICTAG_GROUP: tag_str = tag_make_group(tag_str, tag_str_end-tag_str); statictag_str += 2; break; case HT_STATICTAG_COLOR: { byte color = hexb(statictag_str+2); tag_str = tag_make_color(tag_str, tag_str_end-tag_str, color); statictag_str += 2+2; break; } default: HT_ERROR("error in statictag string!"); } } else { if (tag_str < tag_str_end) { *tag_str++ = *statictag_str; } statictag_str++; } } *tag_str = 0; } const TAGSTRING *tag_findnext(const TAGSTRING *tagstring) { return strchr(tagstring, '\e'); } int tag_get_len(const TAGSTRING *tagstring) { assert(tagstring && tagstring[0] == '\e'); switch (tagstring[1]) { case HT_TAG_EDIT_BYTE: return HT_TAG_EDIT_BYTE_LEN; case HT_TAG_EDIT_WORD_LE: return HT_TAG_EDIT_WORD_LE_LEN; case HT_TAG_EDIT_DWORD_LE: return HT_TAG_EDIT_DWORD_LE_LEN; case HT_TAG_EDIT_QWORD_LE: return HT_TAG_EDIT_QWORD_LE_LEN; case HT_TAG_EDIT_WORD_BE: return HT_TAG_EDIT_WORD_BE_LEN; case HT_TAG_EDIT_DWORD_BE: return HT_TAG_EDIT_DWORD_BE_LEN; case HT_TAG_EDIT_QWORD_BE: return HT_TAG_EDIT_QWORD_BE_LEN; case HT_TAG_EDIT_WORD_VE: return HT_TAG_EDIT_WORD_VE_LEN; case HT_TAG_EDIT_DWORD_VE: return HT_TAG_EDIT_DWORD_VE_LEN; case HT_TAG_EDIT_QWORD_VE: return HT_TAG_EDIT_QWORD_VE_LEN; case HT_TAG_EDIT_TIME_LE: return HT_TAG_EDIT_TIME_LE_LEN; case HT_TAG_EDIT_TIME_BE: return HT_TAG_EDIT_TIME_BE_LEN; case HT_TAG_EDIT_TIME_VE: return HT_TAG_EDIT_TIME_VE_LEN; case HT_TAG_EDIT_CHAR: return HT_TAG_EDIT_CHAR_LEN; case HT_TAG_EDIT_BIT: return HT_TAG_EDIT_BIT_LEN; case HT_TAG_EDIT_SELVIS: return HT_TAG_EDIT_SELVIS_LEN; case HT_TAG_SEL: return HT_TAG_SEL_LEN(((ht_tag_sel*)tagstring)->strlen); case HT_TAG_FLAGS: return HT_TAG_FLAGS_LEN; case HT_TAG_COLOR: return HT_TAG_COLOR_LEN; case HT_TAG_GROUP: return HT_TAG_GROUP_LEN; case HT_TAG_DESC_BYTE: return HT_TAG_DESC_BYTE_LEN; case HT_TAG_DESC_WORD_LE: return HT_TAG_DESC_WORD_LE_LEN; case HT_TAG_DESC_DWORD_LE: return HT_TAG_DESC_DWORD_LE_LEN; case HT_TAG_DESC_QWORD_LE: return HT_TAG_DESC_QWORD_LE_LEN; case HT_TAG_DESC_WORD_BE: return HT_TAG_DESC_WORD_BE_LEN; case HT_TAG_DESC_DWORD_BE: return HT_TAG_DESC_DWORD_BE_LEN; case HT_TAG_DESC_QWORD_BE: return HT_TAG_DESC_QWORD_BE_LEN; case HT_TAG_DESC_WORD_VE: return HT_TAG_DESC_WORD_VE_LEN; case HT_TAG_DESC_DWORD_VE: return HT_TAG_DESC_DWORD_VE_LEN; case HT_TAG_DESC_QWORD_VE: return HT_TAG_DESC_QWORD_VE_LEN; } assert(0); return -1; } int tag_get_vlen(const TAGSTRING *tagstring) { assert(tagstring && tagstring[0] == '\e'); switch (tagstring[1]) { case HT_TAG_EDIT_BYTE: return HT_TAG_EDIT_BYTE_VLEN; case HT_TAG_EDIT_WORD_LE: return HT_TAG_EDIT_WORD_LE_VLEN; case HT_TAG_EDIT_DWORD_LE: return HT_TAG_EDIT_DWORD_LE_VLEN; case HT_TAG_EDIT_QWORD_LE: return HT_TAG_EDIT_QWORD_LE_VLEN; case HT_TAG_EDIT_WORD_BE: return HT_TAG_EDIT_WORD_BE_VLEN; case HT_TAG_EDIT_DWORD_BE: return HT_TAG_EDIT_DWORD_BE_VLEN; case HT_TAG_EDIT_QWORD_BE: return HT_TAG_EDIT_QWORD_BE_VLEN; case HT_TAG_EDIT_WORD_VE: return HT_TAG_EDIT_WORD_VE_VLEN; case HT_TAG_EDIT_DWORD_VE: return HT_TAG_EDIT_DWORD_VE_VLEN; case HT_TAG_EDIT_QWORD_VE: return HT_TAG_EDIT_QWORD_VE_VLEN; case HT_TAG_EDIT_TIME_LE: return HT_TAG_EDIT_TIME_LE_VLEN; case HT_TAG_EDIT_TIME_BE: return HT_TAG_EDIT_TIME_BE_VLEN; case HT_TAG_EDIT_TIME_VE: return HT_TAG_EDIT_TIME_VE_VLEN; case HT_TAG_EDIT_CHAR: return HT_TAG_EDIT_CHAR_VLEN; case HT_TAG_EDIT_BIT: return HT_TAG_EDIT_BIT_VLEN; case HT_TAG_EDIT_SELVIS: return HT_TAG_EDIT_SELVIS_VLEN; case HT_TAG_SEL: return HT_TAG_SEL_VLEN(((ht_tag_sel*)tagstring)->strlen); default: return 0; } } static int time_mp[14] = {0,1,3,4,6,7,9,10,12,13,15,16,17,18}; int tag_get_micropos(const TAGSTRING *tagstring, int i) { switch (tagstring[1]) { case HT_TAG_EDIT_BYTE: case HT_TAG_EDIT_WORD_LE: case HT_TAG_EDIT_DWORD_LE: case HT_TAG_EDIT_QWORD_LE: case HT_TAG_EDIT_WORD_BE: case HT_TAG_EDIT_DWORD_BE: case HT_TAG_EDIT_QWORD_BE: case HT_TAG_EDIT_WORD_VE: case HT_TAG_EDIT_DWORD_VE: case HT_TAG_EDIT_QWORD_VE: case HT_TAG_EDIT_CHAR: case HT_TAG_EDIT_BIT: return i; case HT_TAG_EDIT_TIME_LE: case HT_TAG_EDIT_TIME_BE: case HT_TAG_EDIT_TIME_VE: return time_mp[i]; } // assert(0); return -1; } int tag_get_microsize(const TAGSTRING *tagstring) { switch (tagstring[1]) { case HT_TAG_EDIT_BYTE: return HT_TAG_EDIT_BYTE_VLEN; case HT_TAG_EDIT_WORD_LE: return HT_TAG_EDIT_WORD_LE_VLEN; case HT_TAG_EDIT_DWORD_LE: return HT_TAG_EDIT_DWORD_LE_VLEN; case HT_TAG_EDIT_QWORD_LE: return HT_TAG_EDIT_QWORD_LE_VLEN; case HT_TAG_EDIT_WORD_BE: return HT_TAG_EDIT_WORD_BE_VLEN; case HT_TAG_EDIT_DWORD_BE: return HT_TAG_EDIT_DWORD_BE_VLEN; case HT_TAG_EDIT_QWORD_BE: return HT_TAG_EDIT_QWORD_BE_VLEN; case HT_TAG_EDIT_WORD_VE: return HT_TAG_EDIT_WORD_VE_VLEN; case HT_TAG_EDIT_DWORD_VE: return HT_TAG_EDIT_DWORD_VE_VLEN; case HT_TAG_EDIT_QWORD_VE: return HT_TAG_EDIT_QWORD_VE_VLEN; case HT_TAG_EDIT_TIME_LE: case HT_TAG_EDIT_TIME_BE: case HT_TAG_EDIT_TIME_VE: return 14; case HT_TAG_EDIT_CHAR: return HT_TAG_EDIT_CHAR_VLEN; case HT_TAG_EDIT_BIT: return HT_TAG_EDIT_BIT_VLEN; default: return 1; } } int tag_get_size(const TAGSTRING *tagstring) { switch (tagstring[1]) { case HT_TAG_EDIT_BYTE: return HT_TAG_EDIT_BYTE_SIZE; case HT_TAG_EDIT_WORD_LE: return HT_TAG_EDIT_WORD_LE_SIZE; case HT_TAG_EDIT_DWORD_LE: return HT_TAG_EDIT_DWORD_LE_SIZE; case HT_TAG_EDIT_QWORD_LE: return HT_TAG_EDIT_QWORD_LE_SIZE; case HT_TAG_EDIT_WORD_BE: return HT_TAG_EDIT_WORD_BE_SIZE; case HT_TAG_EDIT_DWORD_BE: return HT_TAG_EDIT_DWORD_BE_SIZE; case HT_TAG_EDIT_QWORD_BE: return HT_TAG_EDIT_QWORD_BE_SIZE; case HT_TAG_EDIT_WORD_VE: return HT_TAG_EDIT_WORD_VE_SIZE; case HT_TAG_EDIT_DWORD_VE: return HT_TAG_EDIT_DWORD_VE_SIZE; case HT_TAG_EDIT_QWORD_VE: return HT_TAG_EDIT_QWORD_VE_SIZE; case HT_TAG_EDIT_TIME_LE: return HT_TAG_EDIT_TIME_LE_SIZE; case HT_TAG_EDIT_TIME_BE: return HT_TAG_EDIT_TIME_BE_SIZE; case HT_TAG_EDIT_TIME_VE: return HT_TAG_EDIT_TIME_VE_SIZE; case HT_TAG_EDIT_CHAR: return HT_TAG_EDIT_CHAR_SIZE; case HT_TAG_EDIT_BIT: return HT_TAG_EDIT_BIT_SIZE; default: return 0; } } FileOfs tag_get_offset(const TAGSTRING *tagstring) { switch (tagstring[1]) { case HT_TAG_EDIT_BYTE: return ht_tag_edit_byte(tagstring).offset; case HT_TAG_EDIT_WORD_LE: case HT_TAG_EDIT_WORD_BE: case HT_TAG_EDIT_WORD_VE: return ht_tag_edit_word_generic(tagstring).offset; case HT_TAG_EDIT_DWORD_LE: case HT_TAG_EDIT_DWORD_BE: case HT_TAG_EDIT_DWORD_VE: return ht_tag_edit_dword_generic(tagstring).offset; case HT_TAG_EDIT_QWORD_LE: case HT_TAG_EDIT_QWORD_BE: case HT_TAG_EDIT_QWORD_VE: return ht_tag_edit_qword_generic(tagstring).offset; case HT_TAG_EDIT_TIME_LE: case HT_TAG_EDIT_TIME_BE: case HT_TAG_EDIT_TIME_VE: return ht_tag_edit_time(tagstring).offset; case HT_TAG_EDIT_CHAR: return ht_tag_edit_char(tagstring).offset; case HT_TAG_EDIT_BIT: return ht_tag_edit_bit(tagstring).offset; case HT_TAG_EDIT_SELVIS: return ht_tag_edit_selvis(tagstring).offset; case HT_TAG_DESC_BYTE: return ht_tag_desc_byte(tagstring).offset; case HT_TAG_DESC_WORD_LE: case HT_TAG_DESC_WORD_BE: case HT_TAG_DESC_WORD_VE: return ht_tag_desc_word_generic(tagstring).offset; case HT_TAG_DESC_DWORD_LE: case HT_TAG_DESC_DWORD_BE: case HT_TAG_DESC_DWORD_VE: return ht_tag_desc_dword_generic(tagstring).offset; case HT_TAG_DESC_QWORD_LE: case HT_TAG_DESC_QWORD_BE: case HT_TAG_DESC_QWORD_VE: return ht_tag_desc_qword_generic(tagstring).offset; case HT_TAG_FLAGS: return ht_tag_flags(tagstring).offset; } assert(0); return 0; } void tag_get_id(const TAGSTRING *tagstring, uint32 *id128_1, uint32 *id128_2, uint32 *id128_3, uint32 *id128_4) { if (tagstring[1] != HT_TAG_SEL) return; ht_tag_sel tag(tagstring); *id128_1 = tag.id128_1; *id128_2 = tag.id128_2; *id128_3 = tag.id128_3; *id128_4 = tag.id128_4; } TAGSTRING *tag_get_seltext(const TAGSTRING *tagstring) { return (TAGSTRING *)(tagstring + sizeof(ht_tag_sel)); } int tag_get_seltextlen(const TAGSTRING *tagstring) { if (tagstring[1] != HT_TAG_SEL) return -1; return ht_tag_sel(tagstring).strlen; } vcp tag_get_color(const TAGSTRING *tagstring) { return ht_tag_color(tagstring).color; } bool tag_get_desc_id(const TAGSTRING *tagstring, uint32 *id) { switch (tagstring[1]) { case HT_TAG_DESC_BYTE: *id = ht_tag_desc_byte(tagstring).id; return true; case HT_TAG_DESC_WORD_LE: case HT_TAG_DESC_WORD_BE: case HT_TAG_DESC_WORD_VE: *id = ht_tag_desc_word_generic(tagstring).id; return true; case HT_TAG_DESC_DWORD_LE: case HT_TAG_DESC_DWORD_BE: case HT_TAG_DESC_DWORD_VE: *id = ht_tag_desc_dword_generic(tagstring).id; return true; case HT_TAG_DESC_QWORD_LE: case HT_TAG_DESC_QWORD_BE: case HT_TAG_DESC_QWORD_VE: *id = ht_tag_desc_qword_generic(tagstring).id; return true; } return false; } void tag_set_offset(TAGSTRING *tagstring, FileOfs offset) { switch (tagstring[1]) { case HT_TAG_EDIT_BYTE: { ht_tag_edit_byte tag(tagstring); tag.offset = offset; tag.flush(tagstring); break; } case HT_TAG_EDIT_WORD_LE: case HT_TAG_EDIT_WORD_BE: case HT_TAG_EDIT_WORD_VE: { ht_tag_edit_word_generic tag(tagstring); tag.offset = offset; tag.flush(tagstring); break; } case HT_TAG_EDIT_DWORD_LE: case HT_TAG_EDIT_DWORD_BE: case HT_TAG_EDIT_DWORD_VE: { ht_tag_edit_dword_generic tag(tagstring); tag.offset = offset; tag.flush(tagstring); break; } case HT_TAG_EDIT_QWORD_LE: case HT_TAG_EDIT_QWORD_BE: case HT_TAG_EDIT_QWORD_VE: { ht_tag_edit_qword_generic tag(tagstring); tag.offset = offset; tag.flush(tagstring); break; } case HT_TAG_EDIT_TIME_LE: case HT_TAG_EDIT_TIME_BE: case HT_TAG_EDIT_TIME_VE: { ht_tag_edit_time tag(tagstring); tag.offset = offset; tag.flush(tagstring); break; } case HT_TAG_EDIT_CHAR: { ht_tag_edit_char tag(tagstring); tag.offset = offset; tag.flush(tagstring); break; } case HT_TAG_EDIT_BIT: { ht_tag_edit_bit tag(tagstring); tag.offset = offset; tag.flush(tagstring); break; } } } bool tag_is_editable(const TAGSTRING *tagstring) { switch (tagstring[1]) { case HT_TAG_EDIT_BYTE: case HT_TAG_EDIT_WORD_LE: case HT_TAG_EDIT_DWORD_LE: case HT_TAG_EDIT_QWORD_LE: case HT_TAG_EDIT_WORD_BE: case HT_TAG_EDIT_DWORD_BE: case HT_TAG_EDIT_QWORD_BE: case HT_TAG_EDIT_WORD_VE: case HT_TAG_EDIT_DWORD_VE: case HT_TAG_EDIT_QWORD_VE: case HT_TAG_EDIT_TIME_LE: case HT_TAG_EDIT_TIME_BE: case HT_TAG_EDIT_TIME_VE: case HT_TAG_EDIT_CHAR: case HT_TAG_EDIT_BIT: return true; default: return false; } assert(0); return false; } void tag_strcat(TAGSTRING *dest, int maxlen, const TAGSTRING *src) { int l = tag_strlen(dest); tag_strcpy(dest+l, maxlen-l, src); } void tag_strcpy(TAGSTRING *dest, int maxlen, const TAGSTRING *src) { if (maxlen > 0) { maxlen--; while (*src && maxlen) { if (*src == '\e') { int l = tag_get_len(src); if (l > maxlen) { tag_error(dest, maxlen); return; } else { memcpy(dest, src, l); dest += l; src += l; maxlen -= l; } } else { *dest++ = *src++; maxlen--; } } *dest = 0; } } TAGSTRING *tag_strdup(const TAGSTRING *tagstring) { if (!tagstring) return NULL; int l = tag_strlen(tagstring); TAGSTRING *s = ht_malloc(l + 1); memcpy(s, tagstring, l); s[l] = 0; return s; } int tag_strlen(const TAGSTRING *tagstring) { int c = 0, r; while (*tagstring) { if (tagstring[0] == '\e') { r = tag_get_len(tagstring); } else { r = 1; } tagstring += r; c += r; } return c; } int tag_strvlen(const TAGSTRING *tagstring) { int c=0, r, v; while (*tagstring) { if (tagstring[0] == '\e') { r = tag_get_len(tagstring); v = tag_get_vlen(tagstring); } else { r = 1; v = 1; } tagstring += r; c += v; } return c; } int tag_count_selectable_tags_in_group(const TAGSTRING *tagstring, int group) { int c = 0; tagstring = tag_get_group(tagstring, group); while ((tagstring = tag_findnext(tagstring))) { switch (tagstring[1]) { case HT_TAG_EDIT_BYTE: c++; tagstring += HT_TAG_EDIT_BYTE_LEN; break; case HT_TAG_EDIT_WORD_LE: c++; tagstring += HT_TAG_EDIT_WORD_LE_LEN; break; case HT_TAG_EDIT_DWORD_LE: c++; tagstring += HT_TAG_EDIT_DWORD_LE_LEN; break; case HT_TAG_EDIT_QWORD_LE: c++; tagstring += HT_TAG_EDIT_QWORD_LE_LEN; break; case HT_TAG_EDIT_WORD_BE: c++; tagstring += HT_TAG_EDIT_WORD_BE_LEN; break; case HT_TAG_EDIT_DWORD_BE: c++; tagstring += HT_TAG_EDIT_DWORD_BE_LEN; break; case HT_TAG_EDIT_QWORD_BE: c++; tagstring += HT_TAG_EDIT_QWORD_BE_LEN; break; case HT_TAG_EDIT_WORD_VE: c++; tagstring += HT_TAG_EDIT_WORD_VE_LEN; break; case HT_TAG_EDIT_DWORD_VE: c++; tagstring += HT_TAG_EDIT_DWORD_VE_LEN; break; case HT_TAG_EDIT_QWORD_VE: c++; tagstring += HT_TAG_EDIT_QWORD_VE_LEN; break; case HT_TAG_EDIT_TIME_LE: c++; tagstring += HT_TAG_EDIT_TIME_LE_LEN; break; case HT_TAG_EDIT_TIME_BE: c++; tagstring += HT_TAG_EDIT_TIME_BE_LEN; break; case HT_TAG_EDIT_TIME_VE: c++; tagstring += HT_TAG_EDIT_TIME_VE_LEN; break; case HT_TAG_EDIT_CHAR: c++; tagstring += HT_TAG_EDIT_CHAR_LEN; break; case HT_TAG_EDIT_BIT: c++; tagstring += HT_TAG_EDIT_BIT_LEN; break; case HT_TAG_SEL: c++; tagstring += HT_TAG_SEL_LEN(((ht_tag_sel*)tagstring)->strlen); break; case HT_TAG_FLAGS: c++; tagstring += HT_TAG_FLAGS_LEN; break; case HT_TAG_GROUP: return c; case HT_TAG_DESC_BYTE: c++; tagstring += HT_TAG_DESC_BYTE_LEN; break; case HT_TAG_DESC_WORD_LE: c++; tagstring += HT_TAG_DESC_WORD_LE_LEN; break; case HT_TAG_DESC_DWORD_LE: c++; tagstring += HT_TAG_DESC_DWORD_LE_LEN; break; case HT_TAG_DESC_QWORD_LE: c++; tagstring += HT_TAG_DESC_QWORD_LE_LEN; break; case HT_TAG_DESC_WORD_BE: c++; tagstring += HT_TAG_DESC_WORD_BE_LEN; break; case HT_TAG_DESC_DWORD_BE: c++; tagstring += HT_TAG_DESC_DWORD_BE_LEN; break; case HT_TAG_DESC_QWORD_BE: c++; tagstring += HT_TAG_DESC_QWORD_BE_LEN; break; case HT_TAG_DESC_WORD_VE: c++; tagstring += HT_TAG_DESC_WORD_VE_LEN; break; case HT_TAG_DESC_DWORD_VE: c++; tagstring += HT_TAG_DESC_DWORD_VE_LEN; break; case HT_TAG_DESC_QWORD_VE: c++; tagstring += HT_TAG_DESC_QWORD_VE_LEN; break; default: tagstring += tag_get_len(tagstring); break; } } return c; } int tag_count_selectable_tags(const TAGSTRING *tagstring) { int c=0; while ((tagstring=tag_findnext(tagstring))) { switch (tagstring[1]) { case HT_TAG_EDIT_BYTE: c++; tagstring+=HT_TAG_EDIT_BYTE_LEN; break; case HT_TAG_EDIT_WORD_LE: c++; tagstring+=HT_TAG_EDIT_WORD_LE_LEN; break; case HT_TAG_EDIT_DWORD_LE: c++; tagstring+=HT_TAG_EDIT_DWORD_LE_LEN; break; case HT_TAG_EDIT_QWORD_LE: c++; tagstring+=HT_TAG_EDIT_QWORD_LE_LEN; break; case HT_TAG_EDIT_WORD_BE: c++; tagstring+=HT_TAG_EDIT_WORD_BE_LEN; break; case HT_TAG_EDIT_DWORD_BE: c++; tagstring+=HT_TAG_EDIT_DWORD_BE_LEN; break; case HT_TAG_EDIT_QWORD_BE: c++; tagstring+=HT_TAG_EDIT_QWORD_BE_LEN; break; case HT_TAG_EDIT_WORD_VE: c++; tagstring+=HT_TAG_EDIT_WORD_VE_LEN; break; case HT_TAG_EDIT_DWORD_VE: c++; tagstring+=HT_TAG_EDIT_DWORD_VE_LEN; break; case HT_TAG_EDIT_QWORD_VE: c++; tagstring+=HT_TAG_EDIT_QWORD_VE_LEN; break; case HT_TAG_EDIT_TIME_LE: c++; tagstring+=HT_TAG_EDIT_TIME_LE_LEN; break; case HT_TAG_EDIT_TIME_BE: c++; tagstring+=HT_TAG_EDIT_TIME_BE_LEN; break; case HT_TAG_EDIT_TIME_VE: c++; tagstring+=HT_TAG_EDIT_TIME_VE_LEN; break; case HT_TAG_EDIT_CHAR: c++; tagstring+=HT_TAG_EDIT_CHAR_LEN; break; case HT_TAG_EDIT_BIT: c++; tagstring+=HT_TAG_EDIT_BIT_LEN; break; case HT_TAG_SEL: c++; tagstring+=HT_TAG_SEL_LEN(((ht_tag_sel*)tagstring)->strlen); break; case HT_TAG_FLAGS: c++; tagstring+=HT_TAG_FLAGS_LEN; break; case HT_TAG_DESC_BYTE: c++; tagstring+=HT_TAG_DESC_BYTE_LEN; break; case HT_TAG_DESC_WORD_LE: c++; tagstring+=HT_TAG_DESC_WORD_LE_LEN; break; case HT_TAG_DESC_DWORD_LE: c++; tagstring+=HT_TAG_DESC_DWORD_LE_LEN; break; case HT_TAG_DESC_QWORD_LE: c++; tagstring+=HT_TAG_DESC_QWORD_LE_LEN; break; case HT_TAG_DESC_WORD_BE: c++; tagstring+=HT_TAG_DESC_WORD_BE_LEN; break; case HT_TAG_DESC_DWORD_BE: c++; tagstring+=HT_TAG_DESC_DWORD_BE_LEN; break; case HT_TAG_DESC_QWORD_BE: c++; tagstring+=HT_TAG_DESC_QWORD_BE_LEN; break; case HT_TAG_DESC_WORD_VE: c++; tagstring+=HT_TAG_DESC_WORD_VE_LEN; break; case HT_TAG_DESC_DWORD_VE: c++; tagstring+=HT_TAG_DESC_DWORD_VE_LEN; break; case HT_TAG_DESC_QWORD_VE: c++; tagstring+=HT_TAG_DESC_QWORD_VE_LEN; break; default: tagstring+=tag_get_len(tagstring); break; } } return c; } int tag_count_groups(const TAGSTRING *tagstring) { int c = 1; while ((tagstring = tag_findnext(tagstring))) { if (tagstring[1] == HT_TAG_GROUP) { c++; tagstring += HT_TAG_GROUP_LEN; } else { tagstring += tag_get_len(tagstring); } } return c; } TAGSTRING *tag_get_selectable_tag(const TAGSTRING *tagstring, int n, int group) { const TAGSTRING *r = NULL; if (group > 0) tagstring = tag_get_group(tagstring, group); n++; while (n && (tagstring = tag_findnext(tagstring))) { switch (tagstring[1]) { case HT_TAG_EDIT_BYTE: n--; r=tagstring; tagstring+=HT_TAG_EDIT_BYTE_LEN; break; case HT_TAG_EDIT_WORD_LE: n--; r=tagstring; tagstring+=HT_TAG_EDIT_WORD_LE_LEN; break; case HT_TAG_EDIT_DWORD_LE: n--; r=tagstring; tagstring+=HT_TAG_EDIT_DWORD_LE_LEN; break; case HT_TAG_EDIT_QWORD_LE: n--; r=tagstring; tagstring+=HT_TAG_EDIT_QWORD_LE_LEN; break; case HT_TAG_EDIT_WORD_BE: n--; r=tagstring; tagstring+=HT_TAG_EDIT_WORD_BE_LEN; break; case HT_TAG_EDIT_DWORD_BE: n--; r=tagstring; tagstring+=HT_TAG_EDIT_DWORD_BE_LEN; break; case HT_TAG_EDIT_QWORD_BE: n--; r=tagstring; tagstring+=HT_TAG_EDIT_QWORD_BE_LEN; break; case HT_TAG_EDIT_WORD_VE: n--; r=tagstring; tagstring+=HT_TAG_EDIT_WORD_VE_LEN; break; case HT_TAG_EDIT_DWORD_VE: n--; r=tagstring; tagstring+=HT_TAG_EDIT_DWORD_VE_LEN; break; case HT_TAG_EDIT_QWORD_VE: n--; r=tagstring; tagstring+=HT_TAG_EDIT_QWORD_VE_LEN; break; case HT_TAG_EDIT_TIME_LE: n--; r=tagstring; tagstring+=HT_TAG_EDIT_TIME_LE_LEN; break; case HT_TAG_EDIT_TIME_BE: n--; r=tagstring; tagstring+=HT_TAG_EDIT_TIME_BE_LEN; break; case HT_TAG_EDIT_TIME_VE: n--; r=tagstring; tagstring+=HT_TAG_EDIT_TIME_VE_LEN; break; case HT_TAG_EDIT_CHAR: n--; r=tagstring; tagstring+=HT_TAG_EDIT_CHAR_LEN; break; case HT_TAG_EDIT_BIT: n--; r=tagstring; tagstring+=HT_TAG_EDIT_BIT_LEN; break; case HT_TAG_SEL: n--; r=tagstring; tagstring+=HT_TAG_SEL_LEN(((ht_tag_sel*)tagstring)->strlen); break; case HT_TAG_FLAGS: n--; r=tagstring; tagstring+=HT_TAG_FLAGS_LEN; break; case HT_TAG_GROUP: if (group!=-1) return (char*)r; tagstring+=HT_TAG_GROUP_LEN; break; case HT_TAG_DESC_BYTE: n--; r=tagstring; tagstring+=HT_TAG_DESC_BYTE_LEN; break; case HT_TAG_DESC_WORD_LE: n--; r=tagstring; tagstring+=HT_TAG_DESC_WORD_LE_LEN; break; case HT_TAG_DESC_DWORD_LE: n--; r=tagstring; tagstring+=HT_TAG_DESC_DWORD_LE_LEN; break; case HT_TAG_DESC_QWORD_LE: n--; r=tagstring; tagstring+=HT_TAG_DESC_QWORD_LE_LEN; break; case HT_TAG_DESC_WORD_BE: n--; r=tagstring; tagstring+=HT_TAG_DESC_WORD_BE_LEN; break; case HT_TAG_DESC_DWORD_BE: n--; r=tagstring; tagstring+=HT_TAG_DESC_DWORD_BE_LEN; break; case HT_TAG_DESC_QWORD_BE: n--; r=tagstring; tagstring+=HT_TAG_DESC_QWORD_BE_LEN; break; case HT_TAG_DESC_WORD_VE: n--; r=tagstring; tagstring+=HT_TAG_DESC_WORD_VE_LEN; break; case HT_TAG_DESC_DWORD_VE: n--; r=tagstring; tagstring+=HT_TAG_DESC_DWORD_VE_LEN; break; case HT_TAG_DESC_QWORD_VE: n--; r=tagstring; tagstring+=HT_TAG_DESC_QWORD_VE_LEN; break; default: tagstring+=tag_get_len(tagstring); break; } } return (n == 0) ? (char*)r : NULL; } TAGSTRING *tag_get_group(const TAGSTRING *tagstring, int group) { const TAGSTRING *r=tagstring; while ((group) && (tagstring=tag_findnext(tagstring))) { switch (tagstring[1]) { case HT_TAG_GROUP: group--; tagstring+=HT_TAG_GROUP_LEN; r=tagstring; break; default: tagstring+=tag_get_len(tagstring); break; } } return (TAGSTRING *)r; } int tag_get_class(const TAGSTRING *tagstring) { switch (tagstring[1]) { case HT_TAG_EDIT_BYTE: case HT_TAG_EDIT_WORD_LE: case HT_TAG_EDIT_DWORD_LE: case HT_TAG_EDIT_QWORD_LE: case HT_TAG_EDIT_WORD_BE: case HT_TAG_EDIT_DWORD_BE: case HT_TAG_EDIT_QWORD_BE: case HT_TAG_EDIT_WORD_VE: case HT_TAG_EDIT_DWORD_VE: case HT_TAG_EDIT_QWORD_VE: case HT_TAG_EDIT_TIME_LE: case HT_TAG_EDIT_TIME_BE: case HT_TAG_EDIT_TIME_VE: case HT_TAG_EDIT_CHAR: case HT_TAG_EDIT_BIT: return tag_class_edit; case HT_TAG_SEL: case HT_TAG_FLAGS: case HT_TAG_DESC_BYTE: case HT_TAG_DESC_WORD_LE: case HT_TAG_DESC_DWORD_LE: case HT_TAG_DESC_QWORD_LE: case HT_TAG_DESC_WORD_BE: case HT_TAG_DESC_DWORD_BE: case HT_TAG_DESC_QWORD_BE: case HT_TAG_DESC_WORD_VE: case HT_TAG_DESC_DWORD_VE: case HT_TAG_DESC_QWORD_VE: return tag_class_sel; default: return tag_class_no; } } char *tag_striptags(char *dest, const TAGSTRING *src) { if (!dest) return NULL; if (!src) { *dest = 0; return dest; } char *d = dest; while (*src) { if (src[0]=='\e') { switch (src[1]) { case HT_TAG_SEL: { src += sizeof (ht_tag_sel); break; } default: src += tag_get_len(src); } } else { *dest = *src; dest++; src++; } } *dest = 0; return d; } ht-2.0.22/htflt.h0000644000175000001440000000273710615341616010433 00000000000000/* * HT Editor * htflt.h * * Copyright (C) 2003 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTFLT_H__ #define __HTFLT_H__ #include "fltstruc.h" #include "formats.h" #include "endianess.h" #include "htformat.h" #include "relfile.h" #define DESC_FLT "flat - binary format" #define DESC_FLT_HEADER "flat/header" #define DESC_FLT_IMAGE "flat/image" extern format_viewer_if htflt_if; typedef uint32 FLTAddress; struct ht_flt_shared_data { FileOfs header_ofs; flat_hdr header; FLTAddress code_start; FLTAddress code_end; FLTAddress data_start; FLTAddress data_end; FLTAddress bss_start; FLTAddress bss_end; }; /* * CLASS ht_flt */ class ht_flt: public ht_format_group { public: void init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs); virtual void done(); }; #endif /* !__HTELF_H__ */ ht-2.0.22/regex.h0000644000175000001440000004404107507606014010420 00000000000000/* Definitions for data structures and routines for the regular expression library, version 0.12. Copyright (C) 1985, 89, 90, 91, 92, 93, 95 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __REGEXP_LIBRARY_H__ #define __REGEXP_LIBRARY_H__ /* POSIX says that must be included (by the caller) before . */ #if !defined (_POSIX_C_SOURCE) && !defined (_POSIX_SOURCE) && defined (VMS) /* VMS doesn't have `size_t' in , even though POSIX says it should be there. */ #include #endif /* The following bits are used to determine the regexp syntax we recognize. The set/not-set meanings are chosen so that Emacs syntax remains the value 0. The bits are given in alphabetical order, and the definitions shifted by one from the previous bit; thus, when we add or remove a bit, only one other definition need change. */ typedef unsigned reg_syntax_t; /* If this bit is not set, then \ inside a bracket expression is literal. If set, then such a \ quotes the following character. */ #define RE_BACKSLASH_ESCAPE_IN_LISTS (1) /* If this bit is not set, then + and ? are operators, and \+ and \? are literals. If set, then \+ and \? are operators and + and ? are literals. */ #define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1) /* If this bit is set, then character classes are supported. They are: [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. If not set, then character classes are not supported. */ #define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1) /* If this bit is set, then ^ and $ are always anchors (outside bracket expressions, of course). If this bit is not set, then it depends: ^ is an anchor if it is at the beginning of a regular expression or after an open-group or an alternation operator; $ is an anchor if it is at the end of a regular expression, or before a close-group or an alternation operator. This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because POSIX draft 11.2 says that * etc. in leading positions is undefined. We already implemented a previous draft which made those constructs invalid, though, so we haven't changed the code back. */ #define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1) /* If this bit is set, then special characters are always special regardless of where they are in the pattern. If this bit is not set, then special characters are special only in some contexts; otherwise they are ordinary. Specifically, * + ? and intervals are only special when not after the beginning, open-group, or alternation operator. */ #define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1) /* If this bit is set, then *, +, ?, and { cannot be first in an re or immediately after an alternation or begin-group operator. */ #define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1) /* If this bit is set, then . matches newline. If not set, then it doesn't. */ #define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1) /* If this bit is set, then . doesn't match NUL. If not set, then it does. */ #define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1) /* If this bit is set, nonmatching lists [^...] do not match newline. If not set, they do. */ #define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1) /* If this bit is set, either \{...\} or {...} defines an interval, depending on RE_NO_BK_BRACES. If not set, \{, \}, {, and } are literals. */ #define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1) /* If this bit is set, +, ? and | aren't recognized as operators. If not set, they are. */ #define RE_LIMITED_OPS (RE_INTERVALS << 1) /* If this bit is set, newline is an alternation operator. If not set, newline is literal. */ #define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1) /* If this bit is set, then `{...}' defines an interval, and \{ and \} are literals. If not set, then `\{...\}' defines an interval. */ #define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1) /* If this bit is set, (...) defines a group, and \( and \) are literals. If not set, \(...\) defines a group, and ( and ) are literals. */ #define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1) /* If this bit is set, then \ matches . If not set, then \ is a back-reference. */ #define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1) /* If this bit is set, then | is an alternation operator, and \| is literal. If not set, then \| is an alternation operator, and | is literal. */ #define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1) /* If this bit is set, then an ending range point collating higher than the starting range point, as in [z-a], is invalid. If not set, then when ending range point collates higher than the starting range point, the range is ignored. */ #define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1) /* If this bit is set, then an unmatched ) is ordinary. If not set, then an unmatched ) is invalid. */ #define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1) /* If this bit is set, succeed as soon as we match the whole pattern, without further backtracking. */ #define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1) /* This global variable defines the particular regexp syntax to use (for some interfaces). When a regexp is compiled, the syntax used is stored in the pattern buffer, so changing this does not affect already-compiled regexps. */ extern reg_syntax_t re_syntax_options; /* Define combinations of the above bits for the standard possibilities. (The [[[ comments delimit what gets put into the Texinfo file, so don't delete them!) */ /* [[[begin syntaxes]]] */ #define RE_SYNTAX_EMACS 0 #define RE_SYNTAX_AWK \ (RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DOT_NOT_NULL \ | RE_NO_BK_PARENS | RE_NO_BK_REFS \ | RE_NO_BK_VBAR | RE_NO_EMPTY_RANGES \ | RE_UNMATCHED_RIGHT_PAREN_ORD) #define RE_SYNTAX_POSIX_AWK \ (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS) #define RE_SYNTAX_GREP \ (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ | RE_NEWLINE_ALT) #define RE_SYNTAX_EGREP \ (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ | RE_NO_BK_VBAR) #define RE_SYNTAX_POSIX_EGREP \ (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES) /* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ #define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC #define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC /* Syntax bits common to both basic and extended POSIX regex syntax. */ #define _RE_SYNTAX_POSIX_COMMON \ (RE_CHAR_CLASSES | RE_DOT_NEWLINE | RE_DOT_NOT_NULL \ | RE_INTERVALS | RE_NO_EMPTY_RANGES) #define RE_SYNTAX_POSIX_BASIC \ (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM) /* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes RE_LIMITED_OPS, i.e., \? \+ \| are not recognized. Actually, this isn't minimal, since other operators, such as \`, aren't disabled. */ #define RE_SYNTAX_POSIX_MINIMAL_BASIC \ (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS) #define RE_SYNTAX_POSIX_EXTENDED \ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INDEP_OPS | RE_NO_BK_BRACES \ | RE_NO_BK_PARENS | RE_NO_BK_VBAR \ | RE_UNMATCHED_RIGHT_PAREN_ORD) /* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INVALID_OPS replaces RE_CONTEXT_INDEP_OPS and RE_NO_BK_REFS is added. */ #define RE_SYNTAX_POSIX_MINIMAL_EXTENDED \ (_RE_SYNTAX_POSIX_COMMON | RE_CONTEXT_INDEP_ANCHORS \ | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES \ | RE_NO_BK_PARENS | RE_NO_BK_REFS \ | RE_NO_BK_VBAR | RE_UNMATCHED_RIGHT_PAREN_ORD) /* [[[end syntaxes]]] */ /* Maximum number of duplicates an interval can allow. Some systems (erroneously) define this in other header files, but we want our value, so remove any previous define. */ #ifdef RE_DUP_MAX #undef RE_DUP_MAX #endif #define RE_DUP_MAX ((1 << 15) - 1) /* POSIX `cflags' bits (i.e., information for `regcomp'). */ /* If this bit is set, then use extended regular expression syntax. If not set, then use basic regular expression syntax. */ #define REG_EXTENDED 1 /* If this bit is set, then ignore case when matching. If not set, then case is significant. */ #define REG_ICASE (REG_EXTENDED << 1) /* If this bit is set, then anchors do not match at newline characters in the string. If not set, then anchors do match at newlines. */ #define REG_NEWLINE (REG_ICASE << 1) /* If this bit is set, then report only success or fail in regexec. If not set, then returns differ between not matching and errors. */ #define REG_NOSUB (REG_NEWLINE << 1) /* POSIX `eflags' bits (i.e., information for regexec). */ /* If this bit is set, then the beginning-of-line operator doesn't match the beginning of the string (presumably because it's not the beginning of a line). If not set, then the beginning-of-line operator does match the beginning of the string. */ #define REG_NOTBOL 1 /* Like REG_NOTBOL, except for the end-of-line. */ #define REG_NOTEOL (1 << 1) /* If any error codes are removed, changed, or added, update the `re_error_msg' table in regex.c. */ typedef enum { REG_NOERROR = 0, /* Success. */ REG_NOMATCH, /* Didn't find a match (for regexec). */ /* POSIX regcomp return error codes. (In the order listed in the standard.) */ REG_BADPAT, /* Invalid pattern. */ REG_ECOLLATE, /* Not implemented. */ REG_ECTYPE, /* Invalid character class name. */ REG_EESCAPE, /* Trailing backslash. */ REG_ESUBREG, /* Invalid back reference. */ REG_EBRACK, /* Unmatched left bracket. */ REG_EPAREN, /* Parenthesis imbalance. */ REG_EBRACE, /* Unmatched \{. */ REG_BADBR, /* Invalid contents of \{\}. */ REG_ERANGE, /* Invalid range end. */ REG_ESPACE, /* Ran out of memory. */ REG_BADRPT, /* No preceding re for repetition op. */ /* Error codes we've added. */ REG_EEND, /* Premature end. */ REG_ESIZE, /* Compiled pattern bigger than 2^16 bytes. */ REG_ERPAREN /* Unmatched ) or \); not returned from regcomp. */ } reg_errcode_t; /* This data structure represents a compiled pattern. Before calling the pattern compiler, the fields `buffer', `allocated', `fastmap', `translate', and `no_sub' can be set. After the pattern has been compiled, the `re_nsub' field is available. All other fields are private to the regex routines. */ struct re_pattern_buffer { /* [[[begin pattern_buffer]]] */ /* Space that holds the compiled pattern. It is declared as `unsigned char *' because its elements are sometimes used as array indexes. */ unsigned char *buffer; /* Number of bytes to which `buffer' points. */ unsigned long allocated; /* Number of bytes actually used in `buffer'. */ unsigned long used; /* Syntax setting with which the pattern was compiled. */ reg_syntax_t syntax; /* Pointer to a fastmap, if any, otherwise zero. re_search uses the fastmap, if there is one, to skip over impossible starting points for matches. */ char *fastmap; /* Either a translate table to apply to all characters before comparing them, or zero for no translation. The translation is applied to a pattern when it is compiled and to a string when it is matched. */ char *translate; /* Number of subexpressions found by the compiler. */ size_t re_nsub; /* Zero if this pattern cannot match the empty string, one else. Well, in truth it's used only in `re_search_2', to see whether or not we should use the fastmap, so we don't set this absolutely perfectly; see `re_compile_fastmap' (the `duplicate' case). */ unsigned can_be_null : 1; /* If REGS_UNALLOCATED, allocate space in the `regs' structure for `max (RE_NREGS, re_nsub + 1)' groups. If REGS_REALLOCATE, reallocate space if necessary. If REGS_FIXED, use what's there. */ #define REGS_UNALLOCATED 0 #define REGS_REALLOCATE 1 #define REGS_FIXED 2 unsigned regs_allocated : 2; /* Set to zero when `regex_compile' compiles a pattern; set to one by `re_compile_fastmap' if it updates the fastmap. */ unsigned fastmap_accurate : 1; /* If set, `re_match_2' does not return information about subexpressions. */ unsigned no_sub : 1; /* If set, a beginning-of-line anchor doesn't match at the beginning of the string. */ unsigned not_bol : 1; /* Similarly for an end-of-line anchor. */ unsigned not_eol : 1; /* If true, an anchor at a newline matches. */ unsigned newline_anchor : 1; /* [[[end pattern_buffer]]] */ }; typedef struct re_pattern_buffer regex_t; /* Type for byte offsets within the string. POSIX mandates this. */ typedef int regoff_t; /* This is the structure we store register match data in. See regex.texinfo for a full description of what registers match. */ struct re_registers { unsigned num_regs; regoff_t *start; regoff_t *end; }; /* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer, `re_match_2' returns information about at least this many registers the first time a `regs' structure is passed. */ #ifndef RE_NREGS #define RE_NREGS 30 #endif /* POSIX specification for registers. Aside from the different names than `re_registers', POSIX uses an array of structures, instead of a structure of arrays. */ typedef struct { regoff_t rm_so; /* Byte offset from string's start to substring's start. */ regoff_t rm_eo; /* Byte offset from string's start to substring's end. */ } regmatch_t; /* Declarations for routines. */ /* To avoid duplicating every routine declaration -- once with a prototype (if we are ANSI), and once without (if we aren't) -- we use the following macro to declare argument types. This unfortunately clutters up the declarations a bit, but I think it's worth it. */ #if __STDC__ #define _RE_ARGS(args) args #else /* not __STDC__ */ #define _RE_ARGS(args) () #endif /* not __STDC__ */ /* Sets the current default syntax to SYNTAX, and return the old syntax. You can also simply assign to the `re_syntax_options' variable. */ extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax)); /* Compile the regular expression PATTERN, with length LENGTH and syntax given by the global `re_syntax_options', into the buffer BUFFER. Return NULL if successful, and an error string if not. */ extern const char *re_compile_pattern _RE_ARGS ((const char *pattern, int length, struct re_pattern_buffer *buffer)); /* Compile a fastmap for the compiled pattern in BUFFER; used to accelerate searches. Return 0 if successful and -2 if was an internal error. */ extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer)); /* Search in the string STRING (with length LENGTH) for the pattern compiled into BUFFER. Start searching at position START, for RANGE characters. Return the starting position of the match, -1 for no match, or -2 for an internal error. Also return register information in REGS (if REGS and BUFFER->no_sub are nonzero). */ extern int re_search _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, int length, int start, int range, struct re_registers *regs)); /* Like `re_search', but search in the concatenation of STRING1 and STRING2. Also, stop searching at index START + STOP. */ extern int re_search_2 _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, int length1, const char *string2, int length2, int start, int range, struct re_registers *regs, int stop)); /* Like `re_search', but return how many characters in STRING the regexp in BUFFER matched, starting at position START. */ extern int re_match _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string, int length, int start, struct re_registers *regs)); /* Relates to `re_match' as `re_search_2' relates to `re_search'. */ extern int re_match_2 _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1, int length1, const char *string2, int length2, int start, struct re_registers *regs, int stop)); /* Set REGS to hold NUM_REGS registers, storing them in STARTS and ENDS. Subsequent matches using BUFFER and REGS will use this memory for recording register information. STARTS and ENDS must be allocated with malloc, and must each be at least `NUM_REGS * sizeof (regoff_t)' bytes long. If NUM_REGS == 0, then subsequent matches should allocate their own register data. Unless this function is called, the first search or match using PATTERN_BUFFER will allocate its own register data, without freeing the old data. */ extern void re_set_registers _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs, unsigned num_regs, regoff_t *starts, regoff_t *ends)); #ifdef _REGEX_RE_COMP /* 4.2 bsd compatibility. */ extern char *re_comp _RE_ARGS ((const char *)); extern int re_exec _RE_ARGS ((const char *)); #endif /* POSIX compatibility. */ extern int regcomp _RE_ARGS ((regex_t *preg, const char *pattern, int cflags)); extern int regexec _RE_ARGS ((const regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags)); extern size_t regerror _RE_ARGS ((int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)); extern void regfree _RE_ARGS ((regex_t *preg)); #endif /* not __REGEXP_LIBRARY_H__ */ /* Local variables: make-backup-files: t version-control: t trim-versions-without-asking: nil End: */ ht-2.0.22/htdoc.c0000644000175000001440000023563112156423375010414 00000000000000/* generated by bin2c from ./doc/hthelp.info */ char htinfo[15375] = { 'T', 'h', 'i', 's', ' ', 'i', 's', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', 'p', 'r', 'o', 'd', 'u', 'c', 'e', 'd', ' ', 'b', 'y', ' ', 'm', 'a', 'k', 'e', 'i', 'n', 'f', 'o', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', ' ', '5', '.', '1', ' ', 'f', 'r', 'o', 'm', ' ', 'h', 't', '.', 't', 'e', 'x', 'i', '.', 0x0a,0x0a,'S', 'T', 'A', 'R', 'T', '-', 'I', 'N', 'F', 'O', '-', 'D', 'I', 'R', '-', 'E', 'N', 'T', 'R', 'Y', 0x0a,'*', ' ', 'h', 't', ':', ' ', '(', 'h', 't', '.', 'i', 'n', 'f', 'o', ')', '.', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'H', 'T', ' ', 'E', 'd', 'i', 't', 'o', 'r', '.', 0x0a,'E', 'N', 'D', '-', 'I', 'N', 'F', 'O', '-', 'D', 'I', 'R', '-', 'E', 'N', 'T', 'R', 'Y', 0x0a,0x0a,' ', ' ', ' ', 'T', 'h', 'i', 's', ' ', 'f', 'i', 'l', 'e', ' ', 'd', 'o', 'c', 'u', 'm', 'e', 'n', 't', 's', ' ', 't', 'h', 'e', ' ', 'H', 'T', ' ', 'E', 'd', 'i', 't', 'o', 'r', '.', 0x0a,0x0a,' ', ' ', ' ', 'C', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', '(', 'C', ')', ' ', '1', '9', '9', '9', '-', '2', '0', '1', '3', ' ', 'T', 'h', 'e', ' ', 'H', 'T', ' ', 'a', 'u', 't', 'h', 'o', 'r', 's', '.', 0x0a, '*', 'N', 'o', 't', 'e', ' ', 'T', 'h', 'e', ' ', 'H', 'T', ' ', 'A', 'u', 't', 'h', 'o', 'r', 's', ':', ' ', 'A', 'u', 't', 'h', 'o', 'r', 's', ',', ' ', 'f', 'o', 'r', ' ', 'a', ' ', 'l', 'i', 's', 't', ' ', 'o', 'f', ' ', 't', 'h', 'e', ' ', 'c', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', 'h', 'o', 'l', 'd', 'e', 'r', 's', '.', 0x0a,0x0a,' ', ' ', ' ', 'P', 'e', 'r', 'm', 'i', 's', 's', 'i', 'o', 'n', ' ', 'i', 's', ' ', 'g', 'r', 'a', 'n', 't', 'e', 'd', ' ', 't', 'o', ' ', 'm', 'a', 'k', 'e', ' ', 'a', 'n', 'd', ' ', 'd', 'i', 's', 't', 'r', 'i', 'b', 'u', 't', 'e', ' ', 'v', 'e', 'r', 'b', 'a', 't', 'i', 'm', ' ', 'c', 'o', 'p', 'i', 'e', 's', ' ', 'o', 'f', ' ', 't', 'h', 'i', 's', 0x0a,'m', 'a', 'n', 'u', 'a', 'l', ' ', 'p', 'r', 'o', 'v', 'i', 'd', 'e', 'd', ' ', 't', 'h', 'e', ' ', 'c', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', 'n', 'o', 't', 'i', 'c', 'e', ' ', 'a', 'n', 'd', ' ', 't', 'h', 'i', 's', ' ', 'p', 'e', 'r', 'm', 'i', 's', 's', 'i', 'o', 'n', ' ', 'n', 'o', 't', 'i', 'c', 'e', ' ', 'a', 'r', 'e', 0x0a,'p', 'r', 'e', 's', 'e', 'r', 'v', 'e', 'd', ' ', 'o', 'n', ' ', 'a', 'l', 'l', ' ', 'c', 'o', 'p', 'i', 'e', 's', '.', 0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,' ', ' ', ' ', 'T', 'r', 'a', 'd', 'e', 'm', 'a', 'r', 'k', 's', ' ', 'a', 'r', 'e', ' ', 't', 'h', 'e', ' ', 'p', 'r', 'o', 'p', 'e', 'r', 't', 'y', ' ', 'o', 'f', ' ', 't', 'h', 'e', 'i', 'r', ' ', 'r', 'e', 's', 'p', 'e', 'c', 't', 'i', 'v', 'e', ' ', 'o', 'w', 'n', 'e', 'r', 's', ',', ' ', 'w', 'h', 'i', 'c', 'h', ' ', 'm', 'a', 'y', ' ', 'b', 'e', 0x0a,'r', 'e', 'g', 'i', 's', 't', 'e', 'r', 'e', 'd', ' ', 'i', 'n', ' ', 'c', 'e', 'r', 't', 'a', 'i', 'n', ' ', 'j', 'u', 'r', 'i', 's', 'd', 'i', 'c', 't', 'i', 'o', 'n', 's', '.', 0x0a,0x0a,0x1f,0x0a,'F', 'i', 'l', 'e', ':', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', ' ', 'N', 'o', 'd', 'e', ':', ' ', 'T', 'o', 'p', ',', ' ', ' ', 'P', 'r', 'e', 'v', ':', ' ', '(', 'd', 'i', 'r', ')', ',', ' ', ' ', 'U', 'p', ':', ' ', '(', 'd', 'i', 'r', ')', 0x0a,0x0a, 'H', 'T', ' ', 'E', 'd', 'i', 't', 'o', 'r', 0x0a,'=', '=', '=', '=', '=', '=', '=', '=', '=', 0x0a,0x0a,'T', 'h', 'i', 's', ' ', 'i', 's', ' ', 'H', 'T', ' ', '2', '.', '0', '.', '2', '2', ';', ' ', 'H', 'a', 'v', 'e', ' ', 'f', 'u', 'n', '.', '.', '.', 0x0a,0x0a,'*', ' ', 'M', 'e', 'n', 'u', ':', 0x0a,0x0a,'*', ' ', 'A', 'b', 'o', 'u', 't', ':', ':', 0x0a, '*', ' ', 'K', 'e', 'y', ' ', 'b', 'i', 'n', 'd', 'i', 'n', 'g', 's', ':', ':', 0x0a,'*', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', ':', ':', 0x0a,'*', ' ', 'A', 'u', 't', 'h', 'o', 'r', 's', ':', ':', 0x0a,'*', ' ', 'W', 'h', 'e', 'r', 'e', ' ', 't', 'o', ' ', 'd', 'o', 'w', 'n', 'l', 'o', 'a', 'd', '?', ':', ':', 0x0a,0x0a,0x1f,0x0a,'F', 'i', 'l', 'e', ':', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', ' ', 'N', 'o', 'd', 'e', ':', ' ', 'A', 'b', 'o', 'u', 't', ',', ' ', ' ', 'P', 'r', 'e', 'v', ':', ' ', 'T', 'o', 'p', ',', ' ', ' ', 'U', 'p', ':', ' ', 'T', 'o', 'p', 0x0a,0x0a,'A', 'b', 'o', 'u', 't', 0x0a,'=', '=', '=', '=', '=', 0x0a,0x0a, 'T', 'h', 'i', 's', ' ', 'p', 'r', 'o', 'g', 'r', 'a', 'm', ' ', 'i', 's', ' ', 'a', ' ', 'f', 'i', 'l', 'e', ' ', 'v', 'i', 'e', 'w', 'e', 'r', ',', ' ', 'e', 'd', 'i', 't', 'o', 'r', ' ', 'a', 'n', 'd', ' ', 'a', 'n', 'a', 'l', 'y', 'z', 'e', 'r', ' ', 'f', 'o', 'r', ' ', 't', 'e', 'x', 't', ',', ' ', 'b', 'i', 'n', 'a', 'r', 'y', ',', ' ', 'a', 'n', 'd', 0x0a,'(', 'e', 's', 'p', 'e', 'c', 'i', 'a', 'l', 'l', 'y', ')', ' ', 'e', 'x', 'e', 'c', 'u', 't', 'a', 'b', 'l', 'e', ' ', 'f', 'i', 'l', 'e', 's', '.', 0x0a, 0x0a,' ', ' ', ' ', ' ', ' ', 'T', 'h', 'i', 's', ' ', 'p', 'r', 'o', 'g', 'r', 'a', 'm', ' ', 'i', 's', ' ', 'f', 'r', 'e', 'e', ' ', 's', 'o', 'f', 't', 'w', 'a', 'r', 'e', ';', ' ', 'y', 'o', 'u', ' ', 'c', 'a', 'n', ' ', 'r', 'e', 'd', 'i', 's', 't', 'r', 'i', 'b', 'u', 't', 'e', ' ', 'i', 't', ' ', 'a', 'n', 'd', '/', 'o', 'r', 0x0a,' ', ' ', ' ', ' ', ' ', 'm', 'o', 'd', 'i', 'f', 'y', ' ', 'i', 't', ' ', 'u', 'n', 'd', 'e', 'r', ' ', 't', 'h', 'e', ' ', 't', 'e', 'r', 'm', 's', ' ', 'o', 'f', ' ', 't', 'h', 'e', ' ', 'G', 'N', 'U', ' ', 'G', 'e', 'n', 'e', 'r', 'a', 'l', ' ', 'P', 'u', 'b', 'l', 'i', 'c', ' ', 'L', 'i', 'c', 'e', 'n', 's', 'e', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', 0x0a,' ', ' ', ' ', ' ', ' ', '2', ' ', 'a', 's', ' ', 'p', 'u', 'b', 'l', 'i', 's', 'h', 'e', 'd', ' ', 'b', 'y', ' ', 't', 'h', 'e', ' ', 'F', 'r', 'e', 'e', ' ', 'S', 'o', 'f', 't', 'w', 'a', 'r', 'e', ' ', 'F', 'o', 'u', 'n', 'd', 'a', 't', 'i', 'o', 'n', '.', 0x0a,0x0a,' ', ' ', ' ', ' ', ' ', 'T', 'h', 'i', 's', ' ', 'p', 'r', 'o', 'g', 'r', 'a', 'm', ' ', 'i', 's', ' ', 'd', 'i', 's', 't', 'r', 'i', 'b', 'u', 't', 'e', 'd', ' ', 'i', 'n', ' ', 't', 'h', 'e', ' ', 'h', 'o', 'p', 'e', ' ', 't', 'h', 'a', 't', ' ', 'i', 't', ' ', 'w', 'i', 'l', 'l', ' ', 'b', 'e', ' ', 'u', 's', 'e', 'f', 'u', 'l', ',', ' ', 'b', 'u', 't', 0x0a,' ', ' ', ' ', ' ', ' ', 'W', 'I', 'T', 'H', 'O', 'U', 'T', ' ', 'A', 'N', 'Y', ' ', 'W', 'A', 'R', 'R', 'A', 'N', 'T', 'Y', ';', ' ', 'w', 'i', 't', 'h', 'o', 'u', 't', ' ', 'e', 'v', 'e', 'n', ' ', 't', 'h', 'e', ' ', 'i', 'm', 'p', 'l', 'i', 'e', 'd', ' ', 'w', 'a', 'r', 'r', 'a', 'n', 't', 'y', ' ', 'o', 'f', 0x0a,' ', ' ', ' ', ' ', ' ', 'M', 'E', 'R', 'C', 'H', 'A', 'N', 'T', 'A', 'B', 'I', 'L', 'I', 'T', 'Y', ' ', 'o', 'r', ' ', 'F', 'I', 'T', 'N', 'E', 'S', 'S', ' ', 'F', 'O', 'R', ' ', 'A', ' ', 'P', 'A', 'R', 'T', 'I', 'C', 'U', 'L', 'A', 'R', ' ', 'P', 'U', 'R', 'P', 'O', 'S', 'E', '.', ' ', 'S', 'e', 'e', ' ', 't', 'h', 'e', ' ', 'G', 'N', 'U', 0x0a,' ', ' ', ' ', ' ', ' ', 'G', 'e', 'n', 'e', 'r', 'a', 'l', ' ', 'P', 'u', 'b', 'l', 'i', 'c', ' ', 'L', 'i', 'c', 'e', 'n', 's', 'e', ' ', 'f', 'o', 'r', ' ', 'm', 'o', 'r', 'e', ' ', 'd', 'e', 't', 'a', 'i', 'l', 's', '.', 0x0a, 0x0a,' ', ' ', ' ', ' ', ' ', 'Y', 'o', 'u', ' ', 's', 'h', 'o', 'u', 'l', 'd', ' ', 'h', 'a', 'v', 'e', ' ', 'r', 'e', 'c', 'e', 'i', 'v', 'e', 'd', ' ', 'a', ' ', 'c', 'o', 'p', 'y', ' ', 'o', 'f', ' ', 't', 'h', 'e', ' ', 'G', 'N', 'U', ' ', 'G', 'e', 'n', 'e', 'r', 'a', 'l', ' ', 'P', 'u', 'b', 'l', 'i', 'c', ' ', 'L', 'i', 'c', 'e', 'n', 's', 'e', 0x0a, ' ', ' ', ' ', ' ', ' ', 'a', 'l', 'o', 'n', 'g', ' ', 'w', 'i', 't', 'h', ' ', 't', 'h', 'i', 's', ' ', 'p', 'r', 'o', 'g', 'r', 'a', 'm', ';', ' ', 'i', 'f', ' ', 'n', 'o', 't', ',', ' ', 'w', 'r', 'i', 't', 'e', ' ', 't', 'o', ' ', 't', 'h', 'e', ' ', 'F', 'r', 'e', 'e', ' ', 'S', 'o', 'f', 't', 'w', 'a', 'r', 'e', 0x0a,' ', ' ', ' ', ' ', ' ', 'F', 'o', 'u', 'n', 'd', 'a', 't', 'i', 'o', 'n', ',', ' ', 'I', 'n', 'c', '.', ',', ' ', '5', '1', ' ', 'F', 'r', 'a', 'n', 'k', 'l', 'i', 'n', ' ', 'S', 't', 'r', 'e', 'e', 't', ',', ' ', 'F', 'i', 'f', 't', 'h', ' ', 'F', 'l', 'o', 'o', 'r', ',', ' ', 'B', 'o', 's', 't', 'o', 'n', ',', ' ', 'M', 'A', 0x0a,' ', ' ', ' ', ' ', ' ', '0', '2', '1', '1', '0', '-', '1', '3', '0', '1', ' ', 'U', 'S', 'A', '.', 0x0a,0x0a,0x1f,0x0a,'F', 'i', 'l', 'e', ':', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', ' ', 'N', 'o', 'd', 'e', ':', ' ', 'K', 'e', 'y', ' ', 'b', 'i', 'n', 'd', 'i', 'n', 'g', 's', ',', ' ', ' ', 'P', 'r', 'e', 'v', ':', ' ', 'T', 'o', 'p', ',', ' ', ' ', 'U', 'p', ':', ' ', 'T', 'o', 'p', 0x0a,0x0a,'K', 'e', 'y', ' ', 'b', 'i', 'n', 'd', 'i', 'n', 'g', 's', 0x0a,'=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', 0x0a,0x0a,' ', ' ', ' ', '*', ' ', 'G', 'e', 'n', 'e', 'r', 'a', 'l', ' ', 'k', 'e', 'y', ' ', 'b', 'i', 'n', 'd', 'i', 'n', 'g', 's', 0x0a,0x0a, ' ', ' ', ' ', ' ', ' ', 'R', 'e', 't', 'u', 'r', 'n', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'f', 'o', 'l', 'l', 'o', 'w', ' ', 'l', 'i', 'n', 'k', ' ', '(', 'i', 'f', ' ', 'a', 'p', 'p', 'l', 'i', 'c', 'a', 'b', 'l', 'e', ')', 0x0a,' ', ' ', ' ', ' ', ' ', 'B', 'a', 'c', 'k', 's', 'p', 'a', 'c', 'e', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'u', 'n', 'd', 'o', ' ', '"', 'f', 'o', 'l', 'l', 'o', 'w', ' ', 'l', 'i', 'n', 'k', '"', 0x0a,' ', ' ', ' ', ' ', ' ', 'S', 'p', 'a', 'c', 'e', '/', 'F', '6', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'c', 'h', 'o', 'o', 's', 'e', ' ', 'v', 'i', 'e', 'w', ' ', 'm', 'o', 'd', 'e', 0x0a, ' ', ' ', ' ', ' ', ' ', 'A', 'l', 't', '+', '[', '1', '-', '9', ']', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 's', 'e', 'l', 'e', 'c', 't', ' ', 'w', 'i', 'n', 'd', 'o', 'w', 0x0a,' ', ' ', ' ', ' ', ' ', 'A', 'l', 't', '+', '0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 's', 'e', 'l', 'e', 'c', 't', ' ', 'w', 'i', 'n', 'd', 'o', 'w', ' ', 'l', 'i', 's', 't', 0x0a,' ', ' ', ' ', ' ', ' ', 'C', 't', 'r', 'l', '+', 'L', 'e', 'f', 't', '/', 'R', 'i', 'g', 'h', 't', ' ', ' ', ' ', ' ', 's', 'c', 'r', 'o', 'l', 'l', ' ', 'l', 'e', 'f', 't', '/', 'r', 'i', 'g', 'h', 't', 0x0a,' ', ' ', ' ', ' ', ' ', 'C', 'u', 'r', 's', 'o', 'r', ' ', 'k', 'e', 'y', 's', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'm', 'o', 'v', 'e', ' ', 'a', 'r', 'o', 'u', 'n', 'd', 0x0a,' ', ' ', ' ', ' ', ' ', 'P', 'a', 'g', 'e', ' ', 'U', 'p', '/', 'D', 'o', 'w', 'n', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'n', 'e', 'x', 't', '/', 'p', 'r', 'e', 'v', ' ', 'p', 'a', 'g', 'e', 0x0a,' ', ' ', ' ', ' ', ' ', 'A', 'l', 't', '+', 'S', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 't', 'o', 'g', 'g', 'l', 'e', ' ', 's', 'e', 'l', 'e', 'c', 't', 0x0a,' ', ' ', ' ', ' ', ' ', 'C', 't', 'r', 'l', '+', 'I', 'n', 's', '/', 'A', 'l', 't', '+', 'C', ' ', ' ', ' ', ' ', ' ', 'c', 'o', 'p', 'y', 0x0a,' ', ' ', ' ', ' ', ' ', 'S', 'h', 'i', 'f', 't', '+', 'I', 'n', 's', '/', 'A', 'l', 't', '+', 'V', ' ', ' ', ' ', ' ', 'i', 'n', 's', 'e', 'r', 't', 0x0a, ' ', ' ', ' ', ' ', ' ', 'C', 't', 'r', 'l', '+', 'D', 'e', 'l', '/', 'A', 'l', 't', '+', 'D', ' ', ' ', ' ', ' ', ' ', 'd', 'e', 'l', 'e', 't', 'e', 0x0a,' ', ' ', ' ', ' ', ' ', 'S', 'h', 'i', 'f', 't', '+', 'D', 'e', 'l', '/', 'A', 'l', 't', '+', 'X', ' ', ' ', ' ', ' ', 'c', 'u', 't', 0x0a,0x0a,' ', ' ', ' ', '*', ' ', 'W', 'i', 'n', 'd', 'o', 'w', ' ', 'k', 'e', 'y', ' ', 'b', 'i', 'n', 'd', 'i', 'n', 'g', 's', 0x0a,0x0a,' ', ' ', ' ', ' ', ' ', 'A', 'l', 't', '+', 'F', '3', '/', 'C', 't', 'r', 'l', '+', 'W', ' ', ' ', ' ', ' ', ' ', ' ', 'c', 'l', 'o', 's', 'e', ' ', 'w', 'i', 'n', 'd', 'o', 'w', 0x0a,' ', ' ', ' ', ' ', ' ', 'C', 't', 'r', 'l', '+', 'F', '5', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'r', 'e', 's', 'i', 'z', 'e', '/', 'm', 'o', 'v', 'e', ' ', 'm', 'o', 'd', 'e', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '(', 'i', 'n', ' ', 'r', 'e', 's', 'i', 'z', 'e', '/', 'm', 'o', 'v', 'e', ' ', 'm', 'o', 'd', 'e', ' ', 'o', 'n', 'l', 'y', ':', ')', 0x0a, ' ', ' ', ' ', ' ', ' ', 'S', 'p', 'a', 'c', 'e', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 't', 'o', 'g', 'g', 'l', 'e', ' ', 'r', 'e', 's', 'i', 'z', 'e', '/', 'm', 'o', 'v', 'e', ' ', 'm', 'o', 'd', 'e', 0x0a, ' ', ' ', ' ', ' ', ' ', 'C', 'u', 'r', 's', 'o', 'r', ' ', 'k', 'e', 'y', 's', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'r', 'e', 's', 'i', 'z', 'e', '/', 'm', 'o', 'v', 'e', ' ', 'w', 'i', 'n', 'd', 'o', 'w', 0x0a,' ', ' ', ' ', ' ', ' ', 'E', 's', 'c', 'a', 'p', 'e', '/', 'R', 'e', 't', 'u', 'r', 'n', '/', 'C', 't', 'r', 'l', '+', 'F', '5', 'l', 'e', 'a', 'v', 'e', ' ', 'r', 'e', 's', 'i', 'z', 'e', '/', 'm', 'o', 'v', 'e', ' ', 'm', 'o', 'd', 'e', 0x0a,0x0a,' ', ' ', ' ', '*', ' ', 'A', 'n', 'a', 'l', 'y', 's', 'e', 'r', ' ', 'k', 'e', 'y', ' ', 'b', 'i', 'n', 'd', 'i', 'n', 'g', 's', 0x0a, 0x0a,' ', ' ', ' ', ' ', ' ', 'c', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'c', 'o', 'n', 't', 'i', 'n', 'u', 'e', ' ', 'c', 'o', 'd', 'e', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'i', 's', ' ', 'a', 't', ' ', 'c', 'u', 'r', 's', 'o', 'r', 0x0a,' ', ' ', ' ', ' ', ' ', 'f', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'f', 'o', 'l', 'l', 'o', 'w', ' ', 'd', 'w', 'o', 'r', 'd', ' ', 'p', 't', 'r', ' ', 'a', 't', ' ', 'a', 'd', 'd', 'r', 'e', 's', 's', 0x0a,' ', ' ', ' ', ' ', ' ', 'n', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'n', 'a', 'm', 'e', ' ', 'c', 'u', 'r', 'r', 'e', 'n', 't', ' ', 'a', 'd', 'd', 'r', 'e', 's', 's', ' ', '(', 'e', 'm', 'p', 't', 'y', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', 't', 'o', ' ', 'd', 'e', 'l', 'e', 't', 'e', ')', 0x0a,' ', ' ', ' ', ' ', ' ', 'x', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 's', 'h', 'o', 'w', ' ', 'x', 'r', 'e', 'f', 's', ' ', '(', 's', 'e', 'a', 'r', 'c', 'h', ' ', 'f', 'o', 'r', ' ', 'x', 'r', 'e', 'f', 's', ')', 0x0a,' ', ' ', ' ', ' ', ' ', '#', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'e', 'd', 'i', 't', ' ', 'c', 'o', 'm', 'm', 'e', 'n', 't', 's', 0x0a, ' ', ' ', ' ', ' ', ' ', 's', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'd', 'e', 'f', 'i', 'n', 'e', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', 0x0a, ' ', ' ', ' ', ' ', ' ', 'i', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'd', 'e', 'f', 'i', 'n', 'e', ' ', 'a', 'n', ' ', 'i', 'n', 't', 'e', 'g', 'e', 'r', ' ', '(', '3', '2', 'b', 'i', 't', ')', 0x0a,' ', ' ', ' ', ' ', ' ', 'h', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'd', 'e', 'f', 'i', 'n', 'e', ' ', 'a', ' ', 'h', 'a', 'l', 'f', 'w', 'o', 'r', 'd', ' ', '(', '1', '6', 'b', 'i', 't', ')', 0x0a,' ', ' ', ' ', ' ', ' ', 'b', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'd', 'e', 'f', 'i', 'n', 'e', ' ', 'a', ' ', 'b', 'y', 't', 'e', ' ', '(', '8', 'b', 'i', 't', ')', 0x0a,' ', ' ', ' ', ' ', ' ', 'C', 't', 'r', 'l', '+', 'A', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'c', 'a', 'l', 'l', ' ', 'a', 's', 's', 'e', 'm', 'b', 'l', 'e', 'r', 0x0a, ' ', ' ', ' ', ' ', ' ', 'C', 't', 'r', 'l', '+', 'F', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'g', 'o', 't', 'o', ' ', 's', 't', 'a', 'r', 't', ' ', 'o', 'f', ' ', 'c', 'u', 'r', 'r', 'e', 'n', 't', ' ', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '(', 'i', 'n', 'd', 'i', 'c', 'a', 't', 'e', 'd', ' ', 'i', 'n', ' ', 't', 'h', 'e', ' ', '2', 'n', 'd', ' ', 'l', 'i', 'n', 'e', ')', 0x0a,' ', ' ', ' ', ' ', ' ', 'C', 't', 'r', 'l', '+', 'L', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'g', 'o', 't', 'o', ' ', 'p', 'r', 'e', 'v', 'i', 'o', 'u', 's', ' ', 'l', 'a', 'b', 'e', 'l', 0x0a,' ', ' ', ' ', ' ', ' ', 'C', 't', 'r', 'l', '+', 'T', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 's', 'h', 'o', 'w', ' ', 'r', 'e', 'c', 'u', 'r', 's', 'i', 'v', 'e', ' ', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', ' ', 'r', 'e', 'f', 'e', 'r', 'e', 'n', 'c', 'e', 's', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x0a,0x0a,0x0a,'N', 'o', 't', 'e', ':', ' ', 'S', 'o', 'm', 'e', ' ', 'k', 'e', 'y', 's', ' ', 'd', 'o', 'n', '\'','t', ' ', 'w', 'o', 'r', 'k', ' ', 'i', 'n', ' ', 'H', 'T', '-', 'p', 'o', 's', 'i', 'x', '.', ' ', ' ', 'T', 'r', 'y', ' ', 'u', 's', 'i', 'n', 'g', ' ', 'E', 's', 'c', 'a', 'p', 'e', ' ', 'i', 'n', 's', 't', 'e', 'a', 'd', ' ', 'o', 'f', 0x0a,'C', 'o', 'n', 't', 'r', 'o', 'l', ' ', 'o', 'r', ' ', 's', 'o', 'm', 'e', 't', 'h', 'i', 'n', 'g', '.', '.', '.', 0x0a,0x0a,0x1f,0x0a,'F', 'i', 'l', 'e', ':', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', ' ', 'N', 'o', 'd', 'e', ':', ' ', 'A', 'u', 't', 'h', 'o', 'r', 's', ',', ' ', ' ', 'P', 'r', 'e', 'v', ':', ' ', 'T', 'o', 'p', ',', ' ', ' ', 'U', 'p', ':', ' ', 'T', 'o', 'p', 0x0a,0x0a,'A', 'u', 't', 'h', 'o', 'r', 's', 0x0a,'=', '=', '=', '=', '=', '=', '=', 0x0a,0x0a,' ', ' ', ' ', '*', ' ', 'S', 't', 'e', 'f', 'a', 'n', ' ', 'W', 'e', 'y', 'e', 'r', 'g', 'r', 'a', 'f', 0x0a,0x0a,' ', ' ', ' ', '*', ' ', 'S', 'e', 'b', 'a', 's', 't', 'i', 'a', 'n', ' ', 'B', 'i', 'a', 'l', 'l', 'a', 's', ' ', '<', 's', 'b', '@', 'b', 'i', 'a', 'l', 'l', 'a', 's', '.', 'n', 'e', 't', '>', 0x0a,0x0a,0x1f, 0x0a,'F', 'i', 'l', 'e', ':', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', ' ', 'N', 'o', 'd', 'e', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', ',', ' ', ' ', 'P', 'r', 'e', 'v', ':', ' ', 'T', 'o', 'p', ',', ' ', ' ', 'U', 'p', ':', ' ', 'T', 'o', 'p', 0x0a,0x0a,'F', 'e', 'a', 't', 'u', 'r', 'e', 's', 0x0a,'=', '=', '=', '=', '=', '=', '=', '=', 0x0a,0x0a,'H', 'T', ' ', 'c', 'o', 'n', 't', 'a', 'i', 'n', 's', ' ', 's', 'o', 'm', 'e', ' ', 'v', 'e', 'r', 'y', ' ', 'a', 'd', 'v', 'a', 'n', 'c', 'e', 'd', ' ', 'a', 'n', 'd', ' ', 'u', 's', 'e', 'f', 'u', 'l', ' ', 'f', 'e', 'a', 't', 'u', 'r', 'e', 's', ',', ' ', 'w', 'h', 'i', 'c', 'h', ' ', 'y', 'o', 'u', ' ', 's', 'h', 'o', 'u', 'l', 'd', 0x0a,'c', 'a', 'r', 'e', 'f', 'u', 'l', 'l', 'y', ' ', 'i', 'n', 's', 'p', 'e', 'c', 't', ':', 0x0a,0x0a,'*', ' ', 'M', 'e', 'n', 'u', ':', 0x0a,0x0a, '*', ' ', 'G', 'e', 'n', 'e', 'r', 'a', 'l', ' ', 'f', 'e', 'a', 't', 'u', 'r', 'e', 's', ':', ':', 0x0a,'*', ' ', 'C', 'o', 'n', 'f', 'i', 'g', 'u', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'f', 'i', 'l', 'e', 's', ':', ':', 0x0a,'*', ' ', 'C', 'l', 'i', 'p', 'b', 'o', 'a', 'r', 'd', ':', ':', 0x0a,'*', ' ', 'G', 'l', 'o', 'b', 'a', 'l', ' ', 'h', 'i', 's', 't', 'o', 'r', 'y', ':', ':', 0x0a,'*', ' ', 'E', 'x', 'p', 'r', 'e', 's', 's', 'i', 'o', 'n', ' ', 'e', 'v', 'a', 'l', 'u', 'a', 't', 'i', 'o', 'n', ':', ':', 0x0a, '*', ' ', 'B', 'l', 'o', 'c', 'k', ' ', 'o', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', 's', ':', ':', 0x0a,'*', ' ', 'S', 'e', 'a', 'r', 'c', 'h', ' ', 'a', 'n', 'd', ' ', 'i', 't', 's', ' ', 'd', 'i', 'f', 'f', 'e', 'r', 'e', 'n', 't', ' ', 'm', 'o', 'd', 'e', 's', ':', ':', 0x0a, '*', ' ', 'C', 'o', 'm', 'm', 'a', 'n', 'd', ' ', 'l', 'i', 'n', 'e', ' ', 'o', 'p', 't', 'i', 'o', 'n', 's', ':', ':', 0x0a,0x0a,0x1f,0x0a,'F', 'i', 'l', 'e', ':', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', ' ', 'N', 'o', 'd', 'e', ':', ' ', 'G', 'e', 'n', 'e', 'r', 'a', 'l', ' ', 'f', 'e', 'a', 't', 'u', 'r', 'e', 's', ',', ' ', ' ', 'P', 'r', 'e', 'v', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', ',', ' ', ' ', 'U', 'p', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', 0x0a,0x0a, 'G', 'e', 'n', 'e', 'r', 'a', 'l', ' ', 'f', 'e', 'a', 't', 'u', 'r', 'e', 's', 0x0a,'=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', 0x0a,0x0a,' ', ' ', '1', '.', ' ', 'S', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd', ' ', 'f', 'i', 'l', 'e', ' ', 'f', 'o', 'r', 'm', 'a', 't', 's', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', 'c', 'o', 'm', 'm', 'o', 'n', ' ', 'o', 'b', 'j', 'e', 'c', 't', ' ', 'f', 'i', 'l', 'e', ' ', 'f', 'o', 'r', 'm', 'a', 't', ' ', '(', 'C', 'O', 'F', 'F', '/', 'X', 'C', 'O', 'F', 'F', '3', '2', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'h', 'e', 'a', 'd', 'e', 'r', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'i', 'm', 'a', 'g', 'e', ' ', 'w', 'i', 't', 'h', ' ', 'c', 'o', 'd', 'e', '/', 'd', 'a', 't', 'a', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'e', 'r', ' ', '(', 'x', '8', '6', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', 'e', 'x', 'e', 'c', 'u', 't', 'a', 'b', 'l', 'e', ' ', 'a', 'n', 'd', ' ', 'l', 'i', 'n', 'k', 'a', 'b', 'l', 'e', ' ', 'f', 'o', 'r', 'm', 'a', 't', ' ', '(', 'E', 'L', 'F', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'h', 'e', 'a', 'd', 'e', 'r', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 's', 'e', 'c', 't', 'i', 'o', 'n', ' ', 'h', 'e', 'a', 'd', 'e', 'r', 's', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'p', 'r', 'o', 'g', 'r', 'a', 'm', ' ', 'h', 'e', 'a', 'd', 'e', 'r', 's', 0x0a, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 's', 'y', 'm', 'b', 'o', 'l', ' ', 't', 'a', 'b', 'l', 'e', 's', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'i', 'm', 'a', 'g', 'e', ' ', 'w', 'i', 't', 'h', ' ', 'c', 'o', 'd', 'e', '/', 'd', 'a', 't', 'a', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'e', 'r', ' ', '(', 'x', '8', '6', ',', ' ', 'A', 'M', 'D', '6', '4', ',', ' ', 'I', 'A', '-', '6', '4', ',', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'A', 'l', 'p', 'h', 'a', ',', ' ', 'P', 'o', 'w', 'e', 'r', 'P', 'C', ',', ' ', 'A', 'R', 'M', ')', ' ', 'a', 'n', 'd', ' ', 'r', 'e', 'l', 'o', 'c', 'a', 't', 'i', 'o', 'n', 's', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', 'l', 'i', 'n', 'e', 'a', 'r', ' ', 'e', 'x', 'e', 'c', 'u', 't', 'a', 'b', 'l', 'e', 's', ' ', '(', 'L', 'E', ')', 0x0a, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'h', 'e', 'a', 'd', 'e', 'r', 0x0a, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'V', 'x', 'D', ' ', 'd', 'e', 's', 'c', 'r', 'i', 'p', 't', 'o', 'r', 0x0a, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'o', 'b', 'j', 'e', 'c', 't', ' ', 't', 'a', 'b', 'l', 'e', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'p', 'a', 'g', 'e', ' ', 't', 'a', 'b', 'l', 'e', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'i', 'm', 'a', 'g', 'e', ' ', 'w', 'i', 't', 'h', ' ', 'c', 'o', 'd', 'e', '/', 'd', 'a', 't', 'a', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'e', 'r', ' ', '(', 'x', '8', '6', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'a', 'u', 't', 'o', '-', 'r', 'e', 'l', 'o', 'c', 'a', 't', 'i', 'o', 'n', ' ', 'l', 'a', 'y', 'e', 'r', ' ', '(', 'o', 'n', 'l', 'y', ' ', 'i', 'n', 't', 'e', 'r', 'n', 'a', 'l', ' ', 'r', 'e', 'f', 's', ' ', 'f', 'o', 'r', ' ', 'n', 'o', 'w', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', 's', 't', 'a', 'n', 'd', 'a', 'r', 'd', ' ', 'd', 'o', 's', ' ', 'e', 'x', 'e', 'c', 'u', 't', 'a', 'b', 'l', 'e', 's', ' ', '(', 'M', 'Z', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'h', 'e', 'a', 'd', 'e', 'r', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'r', 'e', 'l', 'o', 'c', 'a', 't', 'i', 'o', 'n', 's', 0x0a, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'i', 'm', 'a', 'g', 'e', ' ', '(', 'd', 'i', 's', 'a', 's', 's', 'e', 'm', 'b', 'l', 'y', ' ', 'o', 'n', 'l', 'y', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', 'n', 'e', 'w', ' ', 'e', 'x', 'e', 'c', 'u', 't', 'a', 'b', 'l', 'e', 's', ' ', '(', 'N', 'E', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'h', 'e', 'a', 'd', 'e', 'r', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 's', 'e', 'g', 'm', 'e', 'n', 't', 's', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'n', 'a', 'm', 'e', 's', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'e', 'n', 't', 'r', 'y', 'p', 'o', 'i', 'n', 't', 's', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'i', 'm', 'a', 'g', 'e', ' ', 'w', 'i', 't', 'h', ' ', 'c', 'o', 'd', 'e', '/', 'd', 'a', 't', 'a', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'e', 'r', ' ', '(', 'x', '8', '6', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'a', 'u', 't', 'o', '-', 'r', 'e', 'l', 'o', 'c', 'a', 't', 'i', 'o', 'n', ' ', 'l', 'a', 'y', 'e', 'r', ' ', '(', 'p', 'r', 'e', 't', 't', 'y', ' ', 'c', 'o', 'm', 'p', 'l', 'e', 't', 'e', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', 'p', 'o', 'r', 't', 'a', 'b', 'l', 'e', ' ', 'e', 'x', 'e', 'c', 'u', 't', 'a', 'b', 'l', 'e', 's', ' ', '(', 'P', 'E', '3', '2', ',', ' ', 'P', 'E', '6', '4', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'h', 'e', 'a', 'd', 'e', 'r', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'i', 'm', 'p', 'o', 'r', 't', ' ', 's', 'e', 'c', 't', 'i', 'o', 'n', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'd', 'e', 'l', 'a', 'y', '-', 'i', 'm', 'p', 'o', 'r', 't', ' ', 's', 'e', 'c', 't', 'i', 'o', 'n', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'e', 'x', 'p', 'o', 'r', 't', ' ', 's', 'e', 'c', 't', 'i', 'o', 'n', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e', 's', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'i', 'm', 'a', 'g', 'e', ' ', 'w', 'i', 't', 'h', ' ', 'c', 'o', 'd', 'e', '/', 'd', 'a', 't', 'a', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'e', 'r', ' ', '(', 'x', '8', '6', ',', ' ', 'A', 'M', 'D', '6', '4', ',', ' ', 'P', 'o', 'w', 'e', 'r', 'P', 'C', ',', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'I', 'A', '-', '6', '4', ',', ' ', 'A', 'l', 'p', 'h', 'a', ',', ' ', 'A', 'R', 'M', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'p', 'r', 'e', 'l', 'i', 'm', 'i', 'n', 'a', 'r', 'y', ' ', 's', 'u', 'p', 'p', 'o', 'r', 't', ' ', 'f', 'o', 'r', ' ', '.', 'n', 'e', 't', ' ', 'e', 'x', 'e', 'c', 'u', 't', 'a', 'b', 'l', 'e', 's', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', 'j', 'a', 'v', 'a', ' ', 'c', 'l', 'a', 's', 's', ' ', 'f', 'i', 'l', 'e', 's', ' ', '(', 'C', 'L', 'A', 'S', 'S', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'h', 'e', 'a', 'd', 'e', 'r', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'i', 'm', 'a', 'g', 'e', ' ', 'w', 'i', 't', 'h', ' ', 'c', 'o', 'd', 'e', '/', 'd', 'a', 't', 'a', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'e', 'r', ' ', '(', 'j', 'a', 'v', 'a', ' ', 'b', 'y', 't', 'e', 'c', 'o', 'd', 'e', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'd', 'i', 's', 'a', 's', 's', 'e', 'm', 'b', 'l', 'e', 'r', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', 'M', 'a', 'c', 'h', ' ', 'e', 'x', 'e', '/', 'l', 'i', 'n', 'k', ' ', 'f', 'o', 'r', 'm', 'a', 't', ' ', '(', 'M', 'a', 'c', 'h', 'O', ')', 0x0a, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'h', 'e', 'a', 'd', 'e', 'r', 0x0a, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'i', 'm', 'a', 'g', 'e', ' ', 'w', 'i', 't', 'h', ' ', 'c', 'o', 'd', 'e', '/', 'd', 'a', 't', 'a', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'e', 'r', ' ', '(', 'x', '8', '6', ',', ' ', 'A', 'M', 'D', '6', '4', ',', ' ', 'P', 'o', 'w', 'e', 'r', 'P', 'C', ',', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'A', 'R', 'M', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', 'X', '-', 'B', 'o', 'x', ' ', 'e', 'x', 'e', 'c', 'u', 't', 'a', 'b', 'l', 'e', ' ', '(', 'X', 'B', 'E', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'h', 'e', 'a', 'd', 'e', 'r', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'i', 'm', 'p', 'o', 'r', 't', 's', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'i', 'm', 'a', 'g', 'e', ' ', 'w', 'i', 't', 'h', ' ', 'c', 'o', 'd', 'e', '/', 'd', 'a', 't', 'a', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'e', 'r', ' ', '(', 'x', '8', '6', ')', 0x0a, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', 'F', 'l', 'a', 't', ' ', '(', 'F', 'L', 'T', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'h', 'e', 'a', 'd', 'e', 'r', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'i', 'm', 'a', 'g', 'e', ' ', 'w', 'i', 't', 'h', ' ', 'd', 'a', 't', 'a', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'e', 'r', ' ', '(', 'n', 'o', ' ', 'd', 'i', 's', 'a', 's', 's', 'e', 'm', 'b', 'l', 'e', 'r', ' ', 'y', 'e', 't', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', 'P', 'o', 'w', 'e', 'r', 'P', 'C', ' ', 'e', 'x', 'e', 'c', 'u', 't', 'a', 'b', 'l', 'e', ' ', 'f', 'o', 'r', 'm', 'a', 't', ' ', '(', 'P', 'E', 'F', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'h', 'e', 'a', 'd', 'e', 'r', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'i', 'm', 'p', 'o', 'r', 't', 's', ' ', '-', ' ', 'i', 'm', 'a', 'g', 'e', ' ', 'w', 'i', 't', 'h', ' ', 'c', 'o', 'd', 'e', '/', 'd', 'a', 't', 'a', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'e', 'r', ' ', '(', 'P', 'o', 'w', 'e', 'r', 'P', 'C', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '*', ' ', 'S', 't', 'i', 'l', 'l', ' ', 's', 'o', 'm', 'e', ' ', 't', 'o', ' ', 'b', 'e', ' ', 'i', 'm', 'p', 'l', 'e', 'm', 'e', 'n', 't', 'e', 'd', ' ', '(', 'M', '$', '-', 'O', 'B', 'J', ',', ' ', 'A', 'R', 'C', 'H', ',', ' ', 'L', 'X', ')', 0x0a,' ', ' ', '2', '.', ' ', 'C', 'o', 'd', 'e', ' ', '&', ' ', 'D', 'a', 't', 'a', ' ', 'A', 'n', 'a', 'l', 'y', 's', 'e', 'r', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'f', 'i', 'n', 'd', 's', ' ', 'b', 'r', 'a', 'n', 'c', 'h', ' ', 's', 'o', 'u', 'r', 'c', 'e', 's', ' ', 'a', 'n', 'd', ' ', 'd', 'e', 's', 't', 'i', 'n', 'a', 't', 'i', 'o', 'n', 's', ' ', 'r', 'e', 'c', 'u', 'r', 's', 'i', 'v', 'e', 'l', 'y', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'f', 'i', 'n', 'd', 's', ' ', 'p', 'r', 'o', 'c', 'e', 'd', 'u', 'r', 'e', ' ', 'e', 'n', 't', 'r', 'i', 'e', 's', 0x0a, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'c', 'r', 'e', 'a', 't', 'e', 's', ' ', 'l', 'a', 'b', 'e', 'l', 's', ' ', 'b', 'a', 's', 'e', 'd', ' ', 'o', 'n', ' ', 't', 'h', 'i', 's', ' ', 'i', 'n', 'f', 'o', 'r', 'm', 'a', 't', 'i', 'o', 'n', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'c', 'r', 'e', 'a', 't', 'e', 's', ' ', 'x', 'r', 'e', 'f', ' ', 'i', 'n', 'f', 'o', 'r', 'm', 'a', 't', 'i', 'o', 'n', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'a', 'l', 'l', 'o', 'w', 's', ' ', 't', 'o', ' ', 'i', 'n', 't', 'e', 'r', 'a', 'c', 't', 'i', 'v', 'e', 'l', 'y', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'e', ' ', 'u', 'n', 'e', 'x', 'p', 'l', 'o', 'r', 'e', 'd', ' ', 'c', 'o', 'd', 'e', ' ', '(', 'p', 'r', 'e', 's', 's', ' ', '\'','c', '\'', ')', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'a', 'l', 'l', 'o', 'w', 's', ' ', 't', 'o', ' ', 'c', 'r', 'e', 'a', 't', 'e', '/', 'r', 'e', 'n', 'a', 'm', 'e', '/', 'd', 'e', 'l', 'e', 't', 'e', ' ', 'l', 'a', 'b', 'e', 'l', 's', ' ', '(', 'p', 'r', 'e', 's', 's', ' ', '\'','n', '\'',')', 0x0a, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'a', 'l', 'l', 'o', 'w', 's', ' ', 't', 'o', ' ', 'c', 'r', 'e', 'a', 't', 'e', '/', 'e', 'd', 'i', 't', ' ', 'c', 'o', 'm', 'm', 'e', 'n', 't', 's', ' ', '(', 'p', 'r', 'e', 's', 's', ' ', '\'','#', '\'',')', 0x0a,' ', ' ', '3', '.', ' ', 'T', 'a', 'r', 'g', 'e', 't', ' ', 's', 'y', 's', 't', 'e', 'm', 's', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'D', 'J', 'G', 'P', 'P', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'G', 'N', 'U', '/', 'L', 'i', 'n', 'u', 'x', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'F', 'r', 'e', 'e', 'B', 'S', 'D', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', ' ', 'W', 'i', 'n', '3', '2', 0x0a,0x0a,0x1f,0x0a,'F', 'i', 'l', 'e', ':', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', ' ', 'N', 'o', 'd', 'e', ':', ' ', 'C', 'o', 'n', 'f', 'i', 'g', 'u', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'f', 'i', 'l', 'e', 's', ',', ' ', ' ', 'P', 'r', 'e', 'v', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', ',', ' ', ' ', 'U', 'p', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', 0x0a,0x0a,'C', 'o', 'n', 'f', 'i', 'g', 'u', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'f', 'i', 'l', 'e', 's', 0x0a,'=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', 0x0a,0x0a,'G', 'l', 'o', 'b', 'a', 'l', ' ', 'c', 'o', 'n', 'f', 'i', 'g', 'u', 'r', 'a', 't', 'i', 'o', 'n', 0x0a,'-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', 0x0a,0x0a,'H', 'T', ' ', 'a', 'u', 't', 'o', 'm', 'a', 't', 'i', 'c', 'a', 'l', 'l', 'y', ' ', 'c', 'r', 'e', 'a', 't', 'e', 's', ' ', 'a', ' ', 'f', 'i', 'l', 'e', ' ', 't', 'o', ' ', 's', 't', 'o', 'r', 'e', ' ', 'i', 't', 's', ' ', 'c', 'o', 'n', 'f', 'i', 'g', 'u', 'r', 'a', 't', 'i', 'o', 'n', '.', ' ', ' ', 'I', 't', ' ', 'i', 's', 0x0a,'c', 'a', 'l', 'l', 'e', 'd', ' ', '\'','~', '/', '.', 'h', 't', 'c', 'f', 'g', '2', '\'',' ', 'o', 'n', ' ', 'U', 'n', 'i', 'c', 'e', 's', ' ', 'a', 'n', 'd', ' ', '\'','h', 't', '.', 'c', 'f', 'g', '2', '\'',' ', '(', 'w', 'h', 'e', 'r', 'e', ' ', 'h', 't', '.', 'e', 'x', 'e', ' ', 'r', 'e', 's', 'i', 'd', 'e', 's', ')', ' ', 'o', 'n', 0x0a,'W', 'i', 'n', 'd', 'o', 'w', 's', '.', ' ', ' ', 'M', 'o', 'r', 'e', ' ', 's', 'p', 'e', 'c', 'i', 'f', 'i', 'c', 'a', 'l', 'l', 'y', ' ', 'i', 't', ' ', 'c', 'o', 'n', 't', 'a', 'i', 'n', 's', ' ', 'H', 'T', '\'','s', ' ', 'r', 'e', 'g', 'i', 's', 't', 'r', 'y', ' ', 'a', 'n', 'd', ' ', 't', 'h', 'e', ' ', '*', 'N', 'o', 't', 'e', 0x0a,'G', 'l', 'o', 'b', 'a', 'l', ' ', 'h', 'i', 's', 't', 'o', 'r', 'y', ':', ':', '.', 0x0a,0x0a,'P', 'e', 'r', ' ', 'f', 'i', 'l', 'e', ' ', 'c', 'o', 'n', 'f', 'i', 'g', 'u', 'r', 'a', 't', 'i', 'o', 'n', 0x0a,'-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', 0x0a,0x0a,'T', 'h', 'e', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'e', 'r', ' ', '(', 'f', 'o', 'r', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'a', 'b', 'l', 'e', ' ', 'f', 'i', 'l', 'e', 's', ')', ' ', 'w', 'i', 'l', 'l', ' ', 'b', 'e', ' ', 's', 't', 'o', 'r', 'e', 'd', ' ', 'i', 'n', ' ', 'a', 'n', ' ', 'e', 'x', 't', 'r', 'a', ' ', 'f', 'i', 'l', 'e', 0x0a,'c', 'a', 'l', 'l', 'e', 'd', ' ', '\'','F', 'I', 'L', 'E', 'N', 'A', 'M', 'E', '.', 'h', 't', 'c', 'f', 'g', '\'', ',', ' ', 'w', 'h', 'e', 'r', 'e', ' ', 'F', 'I', 'L', 'E', 'N', 'A', 'M', 'E', ' ', 'i', 's', ' ', 't', 'h', 'e', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'e', 'd', ' ', 'f', 'i', 'l', 'e', '.', ' ', ' ', 'T', 'h', 'i', 's', ' ', 'f', 'i', 'l', 'e', 0x0a,'c', 'o', 'n', 't', 'a', 'i', 'n', 's', ' ', 'a', 'l', 'l', ' ', 'i', 'n', 'f', 'o', 'r', 'm', 'a', 't', 'i', 'o', 'n', ' ', 't', 'o', ' ', 'r', 'e', 's', 't', 'o', 'r', 'e', ' ', 't', 'h', 'e', ' ', 'c', 'o', 'm', 'p', 'l', 'e', 't', 'e', ' ', 's', 't', 'a', 't', 'e', ' ', 'o', 'f', ' ', 't', 'h', 'e', ' ', 'a', 'n', 'a', 'l', 'y', 's', 'e', 'r', '.', 0x0a,0x0a,0x1f,0x0a,'F', 'i', 'l', 'e', ':', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', ' ', 'N', 'o', 'd', 'e', ':', ' ', 'C', 'l', 'i', 'p', 'b', 'o', 'a', 'r', 'd', ',', ' ', ' ', 'P', 'r', 'e', 'v', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', ',', ' ', ' ', 'U', 'p', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', 0x0a,0x0a,'C', 'l', 'i', 'p', 'b', 'o', 'a', 'r', 'd', 0x0a,'=', '=', '=', '=', '=', '=', '=', '=', '=', 0x0a,0x0a,'A', 'l', 'l', ' ', 'o', 'p', 'e', 'n', ' ', 'f', 'i', 'l', 'e', 's', ' ', 'a', 'n', 'd', ' ', 'd', 'i', 'a', 'l', 'o', 'g', 's', ' ', 'u', 's', 'e', ' ', 't', 'h', 'e', ' ', 'c', 'o', 'm', 'm', 'o', 'n', ' ', 'c', 'l', 'i', 'p', 'b', 'o', 'a', 'r', 'd', ',', ' ', 'w', 'h', 'e', 'r', 'e', ' ', 'a', 'l', 'l', ' ', 'c', 'o', 'p', 'i', 'e', 'd', 0x0a,'a', 'n', 'd', ' ', 'c', 'u', 't', ' ', 't', 'e', 'x', 't', ' ', 'o', 'r', ' ', 'b', 'i', 'n', 'a', 'r', 'y', ' ', 'd', 'a', 't', 'a', ' ', 'i', 's', ' ', 's', 't', 'o', 'r', 'e', 'd', '.', ' ', ' ', 'C', 'l', 'i', 'p', 'b', 'o', 'a', 'r', 'd', ' ', 'o', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', 's', ' ', 'a', 'r', 'e', 0x0a,'n', 'o', 'r', 'm', 'a', 'l', 'l', 'y', ' ', 'b', 'i', 'n', 'a', 'r', 'y', ' ', 's', 'a', 'f', 'e', ',', ' ', 't', 'h', 'a', 't', ' ', 'm', 'e', 'a', 'n', 's', ' ', 'y', 'o', 'u', ' ', 'c', 'a', 'n', ' ', 'c', 'o', 'p', 'y', ' ', 's', 'o', 'm', 'e', ' ', 'b', 'i', 'n', 'a', 'r', 'y', ' ', 'd', 'a', 't', 'a', ' ', 'o', 'u', 't', ' ', 'o', 'f', ' ', 'a', 0x0a,'f', 'i', 'l', 'e', ' ', 'a', 'n', 'd', ' ', 'p', 'a', 's', 't', 'e', ' ', 'i', 't', ' ', 'i', 'n', 't', 'o', ' ', 'a', 'n', ' ', 'i', 'n', 'p', 'u', 't', ' ', 'l', 'i', 'n', 'e', '.', ' ', ' ', 'E', 'x', 'c', 'e', 'p', 't', 'i', 'o', 'n', 's', ' ', 'a', 'r', 'e', ' ', 'o', 'n', 'l', 'y', ' ', 't', 'h', 'e', ' ', '\\','0', 0x0a, 'c', 'h', 'a', 'r', 'a', 'c', 't', 'e', 'r', ' ', '(', 'b', 'i', 'n', 'a', 'r', 'y', ' ', 'n', 'u', 'l', 'l', ')', ',', ' ', 'i', 't', ' ', 'w', 'i', 'l', 'l', ' ', 'b', 'e', ' ', 'c', 'o', 'n', 'v', 'e', 'r', 't', 'e', 'd', ' ', 't', 'o', ' ', 'a', ' ', 's', 'p', 'a', 'c', 'e', ' ', 'i', 'n', ' ', 'p', 'l', 'a', 'c', 'e', 's', ' ', 'w', 'h', 'e', 'r', 'e', 0x0a,'i', 't', ' ', 'w', 'o', 'u', 'l', 'd', ' ', 'n', 'o', 't', ' ', 'm', 'a', 'k', 'e', ' ', 's', 'e', 'n', 's', 'e', ' ', '(', 'e', '.', 'g', '.', ' ', ' ', 'f', 'i', 'l', 'e', ' ', 'o', 'p', 'e', 'n', ')', '.', 0x0a,0x0a,' ', ' ', ' ', 'A', 'l', 't', 'h', 'o', 'u', 'g', 'h', ' ', 't', 'h', 'e', ' ', 'c', 'l', 'i', 'p', 'b', 'o', 'a', 'r', 'd', ' ', 'w', 'o', 'n', '\'','t', ' ', 'b', 'e', ' ', 's', 'a', 'v', 'e', 'd', ' ', 'b', 'e', 't', 'w', 'e', 'e', 'n', ' ', 'd', 'i', 'f', 'f', 'e', 'r', 'e', 'n', 't', ' ', 'H', 'T', ' ', 's', 'e', 's', 's', 'i', 'o', 'n', 's', 0x0a,'(', 'i', 'e', '.', ' ', ' ', 'y', 'o', 'u', ' ', 'w', 'i', 'l', 'l', ' ', 'l', 'o', 'o', 's', 'e', ' ', 'i', 't', ' ', 'w', 'h', 'e', 'n', ' ', 'e', 'x', 'i', 't', 'i', 'n', 'g', ' ', 'H', 'T', ')', ',', ' ', 'y', 'o', 'u', ' ', 'c', 'a', 'n', ' ', 'e', 'i', 't', 'h', 'e', 'r', ' ', 's', 'a', 'v', 'e', ' ', 'a', 'n', 'd', ' ', 'l', 'o', 'a', 'd', 0x0a,'i', 't', ' ', 'o', 'r', ' ', 'p', 'a', 'r', 't', ' ', 'o', 'f', ' ', 'i', 't', ' ', 'm', 'a', 'n', 'u', 'a', 'l', 'l', 'y', ' ', '(', 'v', 'i', 'a', ' ', 'E', 'd', 'i', 't', '-', '>', 'p', 'a', 's', 't', 'e', ' ', 'i', 'n', 't', 'o', '/', 'c', 'o', 'p', 'y', ' ', 'f', 'r', 'o', 'm', ' ', 'f', 'i', 'l', 'e', ')', ' ', 'o', 'r', ' ', 'r', 'e', 'l', 'y', 0x0a,'o', 'n', ' ', 't', 'h', 'e', ' ', 'i', 'n', 'p', 'u', 't', ' ', 'l', 'i', 'n', 'e', 's', '\'',' ', '*', 'N', 'o', 't', 'e', ' ', 'h', 'i', 's', 't', 'o', 'r', 'y', ':', ' ', 'G', 'l', 'o', 'b', 'a', 'l', ' ', 'h', 'i', 's', 't', 'o', 'r', 'y', ',', ' ', 'w', 'h', 'i', 'c', 'h', ' ', 'i', 's', ' ', 's', 't', 'o', 'r', 'e', 'd', ' ', 'a', 'n', 'd', 0x0a,'r', 'e', 't', 'r', 'i', 'e', 'v', 'e', 'd', ' ', 'f', 'r', 'o', 'm', ' ', 't', 'h', 'e', ' ', 'c', 'o', 'n', 'f', 'i', 'g', ' ', 'f', 'i', 'l', 'e', ' ', 'a', 'u', 't', 'o', 'm', 'a', 't', 'i', 'c', 'a', 'l', 'l', 'y', '.', 0x0a, 0x0a,0x1f,0x0a,'F', 'i', 'l', 'e', ':', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', ' ', 'N', 'o', 'd', 'e', ':', ' ', 'G', 'l', 'o', 'b', 'a', 'l', ' ', 'h', 'i', 's', 't', 'o', 'r', 'y', ',', ' ', ' ', 'P', 'r', 'e', 'v', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', ',', ' ', ' ', 'U', 'p', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', 0x0a,0x0a,'G', 'l', 'o', 'b', 'a', 'l', ' ', 'h', 'i', 's', 't', 'o', 'r', 'y', 0x0a,'=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', 0x0a,0x0a,'H', 'T', 's', ' ', 'h', 'i', 's', 't', 'o', 'r', 'y', ' ', 's', 'y', 's', 't', 'e', 'm', ' ', 'i', 's', ' ', 'g', 'l', 'o', 'b', 'a', 'l', ',', ' ', 'w', 'h', 'i', 'c', 'h', ' ', 'm', 'e', 'a', 'n', 's', ' ', 't', 'h', 'a', 't', ' ', 'y', 'o', 'u', ' ', 'c', 'a', 'n', ' ', 'u', 's', 'e', ' ', 'i', 't', ' ', 'f', 'o', 'r', ' ', 'a', 'l', 'l', 0x0a,'o', 'p', 'e', 'n', ' ', 'f', 'i', 'l', 'e', 's', '.', ' ', ' ', 'H', 'i', 's', 't', 'o', 'r', 'i', 'e', 's', ' ', 'a', 'r', 'e', ' ', 'a', 'l', 's', 'o', ' ', 'g', 'r', 'o', 'u', 'p', 'e', 'd', ' ', 'b', 'y', ' ', 't', 'h', 'e', 'i', 'r', ' ', 'c', 'o', 'n', 't', 'e', 'x', 't', '.', ' ', ' ', 'I', '.', 'e', '.', 0x0a,'f', 'i', 'l', 'e', '-', 'r', 'e', 'l', 'a', 't', 'e', 'd', ' ', 'a', 'n', 'd', ' ', 'r', 'e', 'g', 'e', 'x', '-', 's', 'e', 'a', 'r', 'c', 'h', '-', 'r', 'e', 'l', 'a', 't', 'e', 'd', ' ', 'd', 'i', 'a', 'l', 'o', 'g', 's', ' ', 'h', 'a', 'v', 'e', ' ', 't', 'h', 'e', 'i', 'r', ' ', 'o', 'w', 'n', ' ', 'h', 'i', 's', 't', 'o', 'r', 'y', 0x0a,'(', 'w', 'h', 'o', ' ', 'w', 'o', 'u', 'l', 'd', ' ', 'w', 'a', 'n', 't', ' ', 't', 'o', ' ', 'o', 'p', 'e', 'n', ' ', '"', '[', '0', '-', '9', ']', '[', '0', '-', '9', 'a', '-', 'z', ']', '+', '"', ' ', 'a', 'n', 'y', 'w', 'a', 'y', '?', ')', '.', 0x0a,0x0a,' ', ' ', ' ', 'H', 'i', 's', 't', 'o', 'r', 'y', ' ', 'e', 'n', 't', 'r', 'i', 'e', 's', ' ', 'a', 'r', 'e', ' ', 's', 't', 'o', 'r', 'e', 'd', ' ', 'w', 'i', 't', 'h', 'i', 'n', ' ', 't', 'h', 'e', ' ', '*', 'N', 'o', 't', 'e', ' ', 'C', 'o', 'n', 'f', 'i', 'g', 'u', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'f', 'i', 'l', 'e', 's', ':', ':', ',', ' ', 's', 'o', 0x0a,'t', 'h', 'e', 'y', ' ', 'c', 'a', 'n', ' ', 'b', 'e', ' ', 'r', 'e', 'u', 's', 'e', 'd', ' ', 'w', 'h', 'e', 'n', ' ', 'y', 'o', 'u', ' ', 'r', 'e', 'l', 'a', 'u', 'n', 'c', 'h', '.', 0x0a,0x0a,' ', ' ', ' ', 'Y', 'o', 'u', ' ', 'c', 'a', 'n', ' ', 'd', 'e', 'l', 'e', 't', 'e', ' ', 'a', ' ', 'h', 'i', 's', 't', 'o', 'r', 'y', ' ', 'e', 'n', 't', 'r', 'y', ' ', 'b', 'y', ' ', 'p', 'r', 'e', 's', 's', 'i', 'n', 'g', ' ', 'D', 'E', 'L', ' ', 'i', 'n', 's', 'i', 'd', 'e', ' ', 't', 'h', 'e', ' ', 'h', 'i', 's', 't', 'o', 'r', 'y', 0x0a, 'p', 'o', 'p', 'u', 'p', '.', 0x0a,0x0a, 0x1f,0x0a,'F', 'i', 'l', 'e', ':', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', ' ', 'N', 'o', 'd', 'e', ':', ' ', 'E', 'x', 'p', 'r', 'e', 's', 's', 'i', 'o', 'n', ' ', 'e', 'v', 'a', 'l', 'u', 'a', 't', 'i', 'o', 'n', ',', ' ', ' ', 'P', 'r', 'e', 'v', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', ',', ' ', ' ', 'U', 'p', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', 0x0a,0x0a,'E', 'x', 'p', 'r', 'e', 's', 's', 'i', 'o', 'n', ' ', 'e', 'v', 'a', 'l', 'u', 'a', 't', 'i', 'o', 'n', 0x0a,'=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', 0x0a,0x0a, 'H', 'T', ' ', 'c', 'o', 'n', 't', 'a', 'i', 'n', 's', ' ', 'a', ' ', 'v', 'e', 'r', 'y', ' ', 'p', 'o', 'w', 'e', 'r', 'f', 'u', 'l', ' ', 'e', 'x', 'p', 'r', 'e', 's', 's', 'i', 'o', 'n', ' ', 'e', 'v', 'a', 'l', 'u', 'a', 't', 'o', 'r', ' ', 'w', 'h', 'i', 'c', 'h', ' ', 'i', 's', ' ', 'u', 's', 'e', 'd', ' ', 'i', 'n', ' ', 'a', 'l', 'l', 0x0a,'d', 'i', 'a', 'l', 'o', 'g', 's', ' ', 'w', 'h', 'e', 'r', 'e', ' ', 'e', 'x', 'p', 'r', 'e', 's', 's', 'i', 'o', 'n', 's', ' ', 'a', 'r', 'e', ' ', 'e', 'x', 'p', 'e', 'c', 't', 'e', 'd', '.', ' ', ' ', 'T', 'h', 'e', 's', 'e', ' ', 'a', 'r', 'e', ' ', 'm', 'a', 'i', 'n', 'l', 'y', 0x0a, 'b', 'l', 'o', 'c', 'k', 'o', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', ',', ' ', 'g', 'o', 't', 'o', ',', ' ', 's', 'e', 'a', 'r', 'c', 'h', ' ', 'a', 'n', 'd', ' ', 'o', 'f', ' ', 'c', 'o', 'u', 'r', 's', 'e', ' ', 'e', 'v', 'a', 'l', 'u', 'a', 't', 'e', ' ', 'i', 't', 's', 'e', 'l', 'f', 0x0a,'(', 'E', 'd', 'i', 't', '-', '>', 'E', 'v', 'a', 'l', 'u', 'a', 't', 'e', ')', '.', 0x0a,0x0a,' ', ' ', ' ', 'Y', 'o', 'u', ' ', 'c', 'a', 'n', ' ', 'u', 's', 'e', ' ', 'a', 'l', 'l', ' ', 's', 't', 'a', 'n', 'd', 'a', 'r', 'd', ' ', 'm', 'a', 't', 'h', ' ', 'o', 'p', 'e', 'r', 'a', 't', 'o', 'r', 's', ' ', '(', '+', ' ', '-', ' ', '/', ' ', '*', ' ', '%', ' ', '*', '*', ')', ',', ' ', 'l', 'o', 'g', 'i', 'c', 'a', 'l', 0x0a,'o', 'p', 'e', 'r', 'a', 't', 'o', 'r', 's', ' ', '(', '!', ' ', ' ', '&', '&', ' ', '|', '|', ' ', '^', '^', ')', ',', ' ', 'r', 'e', 'l', 'a', 't', 'i', 'o', 'n', 'a', 'l', ' ', 'o', 'p', 'e', 'r', 'a', 't', 'o', 'r', 's', ' ', '(', '=', '=', ' ', '!', '=', ' ', '<', ' ', '>', ' ', '<', '=', ' ', '>', '=', ')', ',', ' ', 'b', 'i', 't', 0x0a,'o', 'p', 'e', 'r', 'a', 't', 'o', 'r', 's', ' ', '(', '~', ' ', '&', ' ', '|', ' ', '^', ')', ',', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', 'o', 'p', 'e', 'r', 'a', 't', 'o', 'r', 's', ' ', '(', '.', ' ', ' ', 'f', 'o', 'r', ' ', 'c', 'o', 'n', 'c', 'a', 't', 'e', 'n', 'a', 't', 'i', 'o', 'n', ')', ',', 0x0a,'p', 'a', 'r', 'e', 'n', 't', 'h', 'e', 's', 'i', 's', ',', ' ', 't', 'h', 'e', ' ', 't', 'e', 'r', 'n', 'a', 'r', 'y', ' ', 'o', 'p', 'e', 'r', 'a', 't', 'o', 'r', ' ', '(', 'a', '?', 'b', ':', 'c', ')', ',', ' ', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 's', ' ', 'a', 'n', 'd', ' ', 's', 'y', 'm', 'b', 'o', 'l', 's', ' ', '(', 'b', 'o', 't', 'h', 0x0a,'d', 'e', 'p', 'e', 'n', 'd', 'i', 'n', 'g', ' ', 'o', 'n', ' ', 'c', 'o', 'n', 't', 'e', 'x', 't', ')', '.', 0x0a,0x0a,' ', ' ', ' ', 'T', 'h', 'e', ' ', 'e', 'v', 'a', 'l', 'u', 'a', 't', 'o', 'r', ' ', 'u', 's', 'e', 's', ' ', 'i', 'n', 't', 'e', 'g', 'e', 'r', ',', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', 'a', 'n', 'd', ' ', 'f', 'l', 'o', 'a', 't', ' ', 't', 'y', 'p', 'e', 's', ' ', 'd', 'e', 'p', 'e', 'n', 'd', 'i', 'n', 'g', ' ', 'o', 'n', 0x0a,'c', 'o', 'n', 't', 'e', 'x', 't', '.', ' ', ' ', 'Y', 'o', 'u', ' ', 'c', 'a', 'n', ' ', 'a', 'l', 'w', 'a', 'y', 's', ' ', 'c', 'o', 'n', 'v', 'e', 'r', 't', ' ', 'a', ' ', 'r', 'e', 's', 'u', 'l', 't', ' ', 'v', 'i', 'a', ' ', 't', 'h', 'e', ' ', '\'','i', 'n', 't', '(', ')', '\'',',', ' ', '\'','s', 't', 'r', 'i', 'n', 'g', '(', ')', '\'',0x0a,'a', 'n', 'd', ' ', '\'','f', 'l', 'o', 'a', 't', '(', ')', '\'',' ', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 's', ' ', 't', 'o', ' ', 'a', 'p', 'p', 'r', 'o', 'p', 'r', 'i', 'a', 't', 'e', ' ', 't', 'y', 'p', 'e', '.', ' ', ' ', 'T', 'r', 'y', ' ', 'E', 'd', 'i', 't', '-', '>', 'E', 'v', 'a', 'l', 'u', 'a', 't', 'e', ' ', 't', 'o', ' ', 's', 'e', 'e', 0x0a,'h', 'o', 'w', ' ', 'i', 't', ' ', 'w', 'o', 'r', 'k', 's', '.', '.', '.', 0x0a,0x0a,'F', 'u', 'n', 'c', 't', 'i', 'o', 'n', 's', ' ', 'a', 'n', 'd', ' ', 's', 'y', 'm', 'b', 'o', 'l', 's', 0x0a,'-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', 0x0a,0x0a,'Y', 'o', 'u', ' ', 'c', 'a', 'n', ' ', 'a', 'l', 'w', 'a', 'y', 's', ' ', 'u', 's', 'e', ' ', 't', 'h', 'e', ' ', 's', 't', 'a', 'n', 'd', 'a', 'r', 'd', ' ', 'b', 'u', 'i', 'l', 't', '-', 'i', 'n', ' ', 'm', 'a', 't', 'h', ' ', '(', '\'','r', 'o', 'u', 'n', 'd', '\'', ',', ' ', '\'','s', 'i', 'n', '\'',',', ' ', '\'','r', 'a', 'n', 'd', 'o', 'm', '\'',',', 0x0a,'e', 't', 'c', '.', ')', ' ', ' ', 'a', 'n', 'd', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', '(', '\'','s', 't', 'r', 'c', 'm', 'p', '\'',',', ' ', '\'','s', 't', 'r', 'c', 'h', 'r', '\'', ',', ' ', '\'','s', 'p', 'r', 'i', 'n', 't', 'f', '\'',',', ' ', 'e', 't', 'c', '.', ')', ' ', ' ', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 's', ',', ' ', 't', 'h', 'e', 'y', 0x0a,'w', 'o', 'r', 'k', ' ', 'm', 'o', 'r', 'e', ' ', 'o', 'r', ' ', 'l', 'e', 's', 's', ' ', 'l', 'i', 'k', 'e', ' ', 't', 'h', 'e', ' ', 'c', 'o', 'r', 'r', 'e', 's', 'p', 'o', 'n', 'd', 'i', 'n', 'g', ' ', 'C', ' ', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 's', ' ', '(', 'a', 'c', 't', 'u', 'a', 'l', 'l', 'y', ' ', 't', 'h', 'e', 'y', ' ', 'A', 'R', 'E', 0x0a,'m', 'o', 'r', 'e', ' ', 'o', 'r', ' ', 'l', 'e', 's', 's', ' ', 'w', 'r', 'a', 'p', 'p', 'e', 'r', 's', ' ', 'f', 'o', 'r', ' ', 't', 'h', 'e', 'm', ')', ';', ' ', 's', 'e', 'e', ' ', '\'','e', 'v', 'a', 'l', '/', 'e', 'v', 'a', 'l', '.', 'y', '\'',' ', 'f', 'o', 'r', ' ', 'd', 'e', 't', 'a', 'i', 'l', 's', ' ', '(', 's', 'o', 'r', 'r', 'y', 0x0a,'b', 'u', 't', ' ', 'a', ' ', 'd', 'e', 't', 'a', 'i', 'l', 'e', 'd', ' ', 'h', 'e', 'l', 'p', ' ', 'w', 'o', 'u', 'l', 'd', ' ', 'g', 'e', 't', ' ', 'o', 'u', 't', 'd', 'a', 't', 'e', 'd', ' ', 'r', 'a', 't', 'h', 'e', 'r', ' ', 's', 'o', 'o', 'n', ')', '.', 0x0a,0x0a, ' ', ' ', ' ', 'T', 'h', 'e', ' ', 's', 'y', 'm', 'b', 'o', 'l', ' ', '_', ' ', 'a', 'l', 'w', 'a', 'y', 's', ' ', 'r', 'e', 'f', 'e', 'r', 's', ' ', 't', 'o', ' ', 't', 'h', 'e', ' ', 'l', 'a', 's', 't', ' ', 'r', 'e', 's', 'u', 'l', 't', '.', ' ', ' ', 'I', 'f', ' ', 'y', 'o', 'u', ' ', 'a', 'r', 'e', ' ', 'i', 'n', ' ', 'a', ' ', 'h', 'e', 'x', 0x0a,'b', 'u', 'f', 'f', 'e', 'r', ',', ' ', 't', 'h', 'e', ' ', 'v', 'a', 'r', 'i', 'a', 'b', 'l', 'e', ' ', '\'','f', 'i', 'r', 's', 't', '\'',' ', 'c', 'o', 'n', 't', 'a', 'i', 'n', 's', ' ', 't', 'h', 'e', ' ', 'o', 'f', 'f', 's', 'e', 't', ' ', 'o', 'f', ' ', 't', 'h', 'e', ' ', 'f', 'i', 'r', 's', 't', ' ', 'b', 'y', 't', 'e', ' ', 'a', 'n', 'd', 0x0a,'t', 'h', 'e', ' ', 'v', 'a', 'r', 'i', 'a', 'b', 'l', 'e', ' ', '\'','l', 'a', 's', 't', '\'',' ', 'c', 'o', 'n', 't', 'a', 'i', 'n', 's', ' ', 't', 'h', 'e', ' ', 'o', 'f', 'f', 's', 'e', 't', ' ', 'o', 'f', ' ', 't', 'h', 'e', ' ', 'l', 'a', 's', 't', ' ', 'b', 'y', 't', 'e', '.', ' ', ' ', 'T', 'h', 'i', 's', ' ', 'i', 's', 0x0a,'u', 's', 'e', 'f', 'u', 'l', ',', ' ', 'f', 'o', 'r', ' ', 'i', 'n', 's', 't', 'a', 'c', 'e', ',', ' ', 'i', 'f', ' ', 'y', 'o', 'u', ' ', 'w', 'a', 'n', 't', ' ', 't', 'o', ' ', 'j', 'u', 'm', 'p', ' ', 't', 'o', ' ', 't', 'h', 'e', ' ', 'l', 'a', 's', 't', ' ', 'b', 'y', 't', 'e', ' ', 'o', 'f', ' ', 'a', ' ', 'f', 'i', 'l', 'e', '.', 0x0a,0x0a,' ', ' ', ' ', 'I', 'f', ' ', 'y', 'o', 'u', ' ', 'a', 'r', 'e', ' ', 'i', 'n', ' ', 'a', ' ', 'h', 'e', 'x', ' ', 'b', 'u', 'f', 'f', 'e', 'r', ',', ' ', 't', 'h', 'e', ' ', 'v', 'a', 'r', 'i', 'a', 'b', 'l', 'e', ' ', '\'','f', 'i', 'r', 's', 't', '\'',' ', 'c', 'o', 'n', 't', 'a', 'i', 'n', 's', ' ', 't', 'h', 'e', ' ', 'o', 'f', 'f', 's', 'e', 't', 0x0a,'o', 'f', ' ', 't', 'h', 'e', ' ', 'f', 'i', 'r', 's', 't', ' ', 'b', 'y', 't', 'e', ' ', 'a', 'n', 'd', ' ', 't', 'h', 'e', ' ', 'v', 'a', 'r', 'i', 'a', 'b', 'l', 'e', ' ', '\'','l', 'a', 's', 't', '\'', ' ', 'c', 'o', 'n', 't', 'a', 'i', 'n', 's', ' ', 't', 'h', 'e', ' ', 'o', 'f', 'f', 's', 'e', 't', ' ', 'o', 'f', ' ', 't', 'h', 'e', 0x0a,'l', 'a', 's', 't', ' ', 'b', 'y', 't', 'e', '.', ' ', ' ', 'T', 'h', 'i', 's', ' ', 'i', 's', ' ', 'u', 's', 'e', 'f', 'u', 'l', ',', ' ', 'f', 'o', 'r', ' ', 'i', 'n', 's', 't', 'a', 'n', 'c', 'e', ',', ' ', 'i', 'f', ' ', 'y', 'o', 'u', ' ', 'w', 'a', 'n', 't', ' ', 't', 'o', ' ', 'j', 'u', 'm', 'p', ' ', 't', 'o', ' ', 't', 'h', 'e', 0x0a,'l', 'a', 's', 't', ' ', 'b', 'y', 't', 'e', ' ', 'o', 'f', ' ', 'a', ' ', 'f', 'i', 'l', 'e', '.', 0x0a,0x0a,' ', ' ', ' ', 'W', 'h', 'e', 'n', ' ', 'u', 's', 'i', 'n', 'g', ' ', '*', 'N', 'o', 't', 'e', ' ', 'B', 'l', 'o', 'c', 'k', ' ', 'o', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', 's', ':', ':', ',', ' ', 'o', 'r', ' ', 's', 'e', 'a', 'r', 'c', 'h', 'i', 'n', 'g', ' ', 'y', 'o', 'u', ' ', 'h', 'a', 'v', 'e', ' ', 's', 'o', 'm', 'e', 0x0a,'c', 'o', 'n', 't', 'e', 'x', 't', ' ', 'd', 'e', 'p', 'e', 'n', 'd', 'i', 'n', 'g', ' ', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 's', ' ', 'a', 'n', 'd', ' ', 's', 'y', 'm', 'b', 'o', 'l', 's', ';', ' ', 's', 'e', 'e', ' ', 't', 'h', 'e', 's', 'e', ' ', 's', 'e', 'c', 't', 'i', 'o', 'n', 's', ' ', 'f', 'o', 'r', 0x0a,'e', 'x', 'p', 'l', 'a', 'n', 'a', 't', 'i', 'o', 'n', '.', 0x0a,0x0a, 0x1f,0x0a,'F', 'i', 'l', 'e', ':', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', ' ', 'N', 'o', 'd', 'e', ':', ' ', 'B', 'l', 'o', 'c', 'k', ' ', 'o', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', 's', ',', ' ', ' ', 'P', 'r', 'e', 'v', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', ',', ' ', ' ', 'U', 'p', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', 0x0a,0x0a,'B', 'l', 'o', 'c', 'k', ' ', 'o', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', 's', 0x0a,'=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', 0x0a, 0x0a,'B', 'l', 'o', 'c', 'k', ' ', 'o', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', ' ', '(', 'B', 'l', 'o', 'c', 'k', 'o', 'p', ')', ' ', 'i', 's', ' ', 'a', ' ', 'v', 'e', 'r', 'y', ' ', 'p', 'o', 'w', 'e', 'r', 'f', 'u', 'l', ' ', 't', 'o', 'o', 'l', ' ', 't', 'o', ' ', 'p', 'e', 'r', 'f', 'o', 'r', 'm', 0x0a,'m', 'o', 'd', 'i', 'f', 'i', 'c', 'a', 't', 'i', 'o', 'n', 's', ' ', 'o', 'n', ' ', 'b', 'i', 'n', 'a', 'r', 'y', ' ', 'f', 'i', 'l', 'e', 's', '.', ' ', ' ', 'I', 't', ' ', 'i', 's', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e', ' ', 'i', 'n', ' ', 'h', 'e', 'x', ' ', 'v', 'i', 'e', 'w', 'e', 'r', ' ', 'o', 'n', 'l', 'y', '.', 0x0a,0x0a,' ', ' ', ' ', 'B', 'l', 'o', 'c', 'k', 'o', 'p', ' ', 't', 'a', 'k', 'e', 's', ' ', 'f', 'o', 'u', 'r', ' ', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', 's', ':', ' ', 'S', 'T', 'A', 'R', 'T', ',', ' ', 'E', 'N', 'D', ',', ' ', 'M', 'O', 'D', 'E', ' ', 'a', 'n', 'd', ' ', 'E', 'X', 'P', 'R', 'E', 'S', 'S', 'I', 'O', 'N', '.', 0x0a,'B', 'l', 'o', 'c', 'k', 'o', 'p', ' ', 'w', 'o', 'r', 'k', 's', ' ', 'a', 's', ' ', 'f', 'o', 'l', 'l', 'o', 'w', 's', ':', 0x0a, 0x0a,' ', ' ', ' ', '*', ' ', 'S', 'T', 'A', 'R', 'T', ':', ' ', 'S', 't', 'a', 'r', 't', ' ', 'a', 't', ' ', 't', 'h', 'e', ' ', 'o', 'f', 'f', 's', 'e', 't', ' ', 's', 'p', 'e', 'c', 'i', 'f', 'i', 'e', 'd', ' ', 'b', 'y', ' ', 'S', 'T', 'A', 'R', 'T', 0x0a,' ', ' ', ' ', '*', ' ', 'R', 'E', 'P', 'E', 'A', 'T', ':', ' ', 'E', 'v', 'a', 'l', 'u', 'a', 't', 'e', ' ', 'E', 'X', 'P', 'R', 'E', 'S', 'S', 'I', 'O', 'N', ' ', 'a', 'n', 'd', ' ', 's', 't', 'o', 'r', 'e', ' ', 'n', ' ', 'b', 'y', 't', 'e', 's', ' ', '(', '1', ' ', '-', ' ', 'b', 'y', 't', 'e', ',', ' ', '2', ' ', '-', ' ', 'w', 'o', 'r', 'd', ',', 0x0a,' ', ' ', ' ', ' ', ' ', '4', ' ', '-', ' ', 'd', 'w', 'o', 'r', 'd', ',', ' ', 'v', 'a', 'r', 'i', 'a', 'b', 'l', 'e', ' ', '-', ' ', 's', 't', 'r', 'i', 'n', 'g', ')', ' ', 'a', 't', ' ', 't', 'h', 'e', ' ', 'c', 'u', 'r', 'r', 'e', 'n', 't', ' ', 'o', 'f', 'f', 's', 'e', 't', '.', ' ', ' ', 'I', 'n', 'c', 'r', 'e', 'm', 'e', 'n', 't', 0x0a,' ', ' ', ' ', ' ', ' ', 'c', 'u', 'r', 'r', 'e', 'n', 't', ' ', 'o', 'f', 'f', 's', 'e', 't', ' ', 'b', 'y', ' ', 'n', '.', ' ', ' ', 'S', 't', 'o', 'p', ' ', 'i', 'f', ' ', 'E', 'N', 'D', ' ', 'h', 'a', 's', ' ', 'b', 'e', 'e', 'n', ' ', 'r', 'e', 'a', 'c', 'h', 'e', 'd', '.', 0x0a,0x0a,'S', 'p', 'e', 'c', 'i', 'a', 'l', ' ', 'v', 'a', 'r', 'i', 'a', 'b', 'l', 'e', 's', '/', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 's', ' ', 't', 'h', 'a', 't', ' ', 'c', 'a', 'n', ' ', 'b', 'e', ' ', 'u', 's', 'e', 'd', ' ', 'i', 'n', ' ', 'E', 'X', 'P', 'R', 'E', 'S', 'S', 'I', 'O', 'N', ':', 0x0a,0x0a, '\'','r', 'e', 'a', 'd', 'b', 'y', 't', 'e', '(', 'o', 'f', 's', ')', '\'',0x0a, ' ', ' ', ' ', ' ', ' ', 'r', 'e', 'a', 'd', ' ', 'a', ' ', 'b', 'y', 't', 'e', ' ', 'f', 'r', 'o', 'm', ' ', 'o', 'f', 'f', 's', 'e', 't', ' ', 'O', 'F', 'S', ',', ' ', 'r', 'e', 't', 'u', 'r', 'n', 's', ' ', 'a', ' ', 'n', 'u', 'm', 'b', 'e', 'r', 0x0a,'\'','r', 'e', 'a', 'd', 's', 't', 'r', 'i', 'n', 'g', '(', 'o', 'f', 's', ',', ' ', 's', 'i', 'z', 'e', ')', '\'',0x0a,' ', ' ', ' ', ' ', ' ', 'r', 'e', 'a', 'd', ' ', 'S', 'I', 'Z', 'E', ' ', 'b', 'y', 't', 'e', 's', ' ', 'f', 'r', 'o', 'm', ' ', 'o', 'f', 'f', 's', 'e', 't', ' ', 'O', 'F', 'S', ',', ' ', 'r', 'e', 't', 'u', 'r', 'n', 's', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', 0x0a,'\'','i', '\'',0x0a,' ', ' ', ' ', ' ', ' ', 'c', 'o', 'n', 't', 'a', 'i', 'n', 's', ' ', 't', 'h', 'e', ' ', 'i', 't', 'e', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'c', 'o', 'u', 'n', 't', '/', 'i', 'n', 'd', 'e', 'x', ' ', 's', 't', 'a', 'r', 't', 'i', 'n', 'g', ' ', 'w', 'i', 't', 'h', ' ', '0', 0x0a,0x0a,0x1f, 0x0a,'F', 'i', 'l', 'e', ':', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', ' ', 'N', 'o', 'd', 'e', ':', ' ', 'S', 'e', 'a', 'r', 'c', 'h', ' ', 'a', 'n', 'd', ' ', 'i', 't', 's', ' ', 'd', 'i', 'f', 'f', 'e', 'r', 'e', 'n', 't', ' ', 'm', 'o', 'd', 'e', 's', ',', ' ', ' ', 'P', 'r', 'e', 'v', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', ',', ' ', ' ', 'U', 'p', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', 0x0a,0x0a,'S', 'e', 'a', 'r', 'c', 'h', ' ', 'a', 'n', 'd', ' ', 'i', 't', 's', ' ', 'd', 'i', 'f', 'f', 'e', 'r', 'e', 'n', 't', ' ', 'm', 'o', 'd', 'e', 's', 0x0a,'=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', 0x0a,0x0a,'T', 'h', 'e', ' ', 's', 'e', 'a', 'r', 'c', 'h', ' ', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', ' ', 'i', 's', ' ', 'o', 'n', 'e', ' ', 'o', 'f', ' ', 't', 'h', 'e', ' ', 'm', 'o', 's', 't', ' ', 'a', 'd', 'v', 'a', 'n', 'c', 'e', 'd', ' ', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 's', ' ', 'o', 'f', ' ', 'H', 'T', '.', ' ', 'I', 't', ' ', 'i', 's', 0x0a,'i', 'n', 'v', 'o', 'k', 'e', 'd', ' ', 't', 'h', 'r', 'o', 'u', 'g', 'h', ' ', 'F', '7', ',', ' ', 'S', 'h', 'i', 'f', 't', '-', 'F', '7', ' ', 'c', 'o', 'n', 't', 'i', 'n', 'u', 'e', 's', ' ', 'a', ' ', 's', 'e', 'a', 'r', 'c', 'h', ' ', 'f', 'r', 'o', 'm', ' ', 'c', 'u', 'r', 's', 'o', 'r', '.', ' ', ' ', 'D', 'e', 'p', 'e', 'n', 'd', 'i', 'n', 'g', 0x0a,'o', 'n', ' ', 'c', 'o', 'n', 't', 'e', 'x', 't', ' ', '(', 'i', 'e', '.', ' ', ' ', 'f', 'i', 'l', 'e', ' ', 't', 'y', 'p', 'e', ' ', 'a', 'n', 'd', ' ', 'm', 'o', 'd', 'e', ')', ' ', 't', 'h', 'e', ' ', 'f', 'o', 'l', 'l', 'o', 'w', 'i', 'n', 'g', ' ', 'm', 'o', 'd', 'e', 's', ' ', 'a', 'r', 'e', ' ', 'e', 'n', 'a', 'b', 'l', 'e', 'd', ':', 0x0a,0x0a, 'b', 'i', 'n', ':', ' ', 'A', 'S', 'C', 'I', 'I', ' ', '/', ' ', 'H', 'e', 'x', 0x0a,'-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', 0x0a,0x0a,'E', 'n', 't', 'e', 'r', ' ', 'a', 'n', ' ', 'e', 'x', 'a', 'c', 't', ' ', 's', 'e', 'a', 'r', 'c', 'h', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', 'e', 'i', 't', 'h', 'e', 'r', ' ', 'v', 'i', 'a', ' ', 'a', 's', 'c', 'i', 'i', ' ', 'c', 'h', 'a', 'r', 'a', 'c', 't', 'e', 'r', 's', ' ', 'o', 'r', ' ', 'v', 'i', 'a', 0x0a,'h', 'e', 'x', 'a', 'd', 'e', 'c', 'i', 'm', 'a', 'l', ' ', 'i', 'n', 't', 'e', 'r', 'p', 'r', 'e', 't', 'a', 't', 'i', 'o', 'n', '.', ' ', ' ', 'T', 'h', 'i', 's', ' ', 'i', 's', ' ', 't', 'h', 'e', ' ', 'f', 'a', 's', 't', 'e', 's', 't', ' ', 's', 'e', 'a', 'r', 'c', 'h', ' ', 'm', 'o', 'd', 'e', '.', ' ', ' ', 'Y', 'o', 'u', ' ', 'm', 'a', 'y', 0x0a,'s', 'p', 'e', 'c', 'i', 'f', 'y', ' ', 'a', ' ', 'c', 'a', 's', 'e', '-', 'i', 'n', 's', 'e', 'n', 's', 'i', 't', 'i', 'v', 'e', ' ', 's', 'e', 'a', 'r', 'c', 'h', '.', 0x0a,0x0a,'b', 'i', 'n', ':', ' ', 'e', 'v', 'a', 'l', ' ', 's', 't', 'r', 0x0a,'-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', 0x0a,0x0a,'E', 'n', 't', 'e', 'r', ' ', 'a', 'n', ' ', 'e', 'x', 'p', 'r', 'e', 's', 's', 'i', 'o', 'n', ',', ' ', 'i', 't', ' ', 'w', 'i', 'l', 'l', ' ', 'b', 'e', ' ', 'e', 'v', 'a', 'l', 'u', 'a', 't', 'e', 'd', ' ', 'O', 'N', 'C', 'E', ' ', '(', 'd', 'i', 'f', 'f', 'e', 'r', 'e', 'n', 'c', 'e', ' ', 't', 'o', ' ', 't', 'h', 'e', ' ', '4', 't', 'h', 0x0a,'m', 'o', 'd', 'e', ')', ',', ' ', 'a', 'n', 'd', ' ', 'H', 'T', ' ', 'w', 'i', 'l', 'l', ' ', 't', 'h', 'e', 'n', ' ', 's', 'e', 'a', 'r', 'c', 'h', ' ', 'f', 'o', 'r', ' ', 't', 'h', 'e', ' ', 'r', 'e', 's', 'u', 'l', 't', '-', 's', 't', 'r', 'i', 'n', 'g', '.', ' ', ' ', 'T', 'h', 'i', 's', ' ', 'i', 's', ' ', 'p', 'r', 'e', 't', 't', 'y', 0x0a,'u', 's', 'e', 'f', 'u', 'l', ' ', 'w', 'h', 'e', 'n', ' ', 's', 'e', 'a', 'r', 'c', 'h', 'i', 'n', 'g', ' ', 'f', 'o', 'r', ' ', 'i', 'n', 't', 'e', 'r', 'm', 'i', 'x', 'e', 'd', ' ', 't', 'e', 'x', 't', ' ', 'a', 'n', 'd', ' ', 'c', 'o', 'n', 't', 'r', 'o', 'l', '-', 'c', 'h', 'a', 'r', 's', '/', 'b', 'i', 'n', 'a', 'r', 'y', ',', ' ', 'e', '.', 'g', '.', 0x0a, '\'','"', 'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd', '\\','n', '\\', '0', '"', '\'',0x0a,0x0a,'d', 'i', 's', 'p', 'l', 'a', 'y', ':', ' ', 'r', 'e', 'g', 'e', 'x', 0x0a,'-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', 0x0a,0x0a,'A', 's', ' ', 't', 'h', 'e', ' ', 'p', 'r', 'e', 'f', 'i', 'x', ' ', 'i', 'n', 'd', 'i', 'c', 'a', 't', 'e', 's', ',', ' ', 't', 'h', 'i', 's', ' ', 's', 'e', 'a', 'r', 'c', 'h', ' ', 'd', 'o', 'e', 's', 'n', '\'','t', ' ', 's', 'e', 'a', 'r', 'c', 'h', ' ', 'i', 'n', ' ', 't', 'h', 'e', ' ', 'b', 'i', 'n', 'a', 'r', 'y', ' ', 'f', 'i', 'l', 'e', 0x0a,'b', 'u', 't', ' ', 'i', 'n', ' ', 't', 'h', 'e', ' ', 'd', 'i', 's', 'p', 'l', 'a', 'y', ' ', 'o', 'n', ' ', 's', 'c', 'r', 'e', 'e', 'n', '.', ' ', ' ', 'H', 'T', ' ', 's', 'e', 'a', 'r', 'c', 'h', 'e', 's', ' ', 'f', 'o', 'r', ' ', 'a', ' ', 'r', 'e', 'g', 'u', 'l', 'a', 'r', ' ', 'e', 'x', 'p', 'r', 'e', 's', 's', 'i', 'o', 'n', ' ', 's', 'o', 0x0a,'t', 'h', 'i', 's', ' ', 'c', 'a', 'n', ' ', 'b', 'e', ' ', 'v', 'e', 'r', 'y', ' ', 'p', 'o', 'w', 'e', 'r', 'f', 'u', 'l', ',', ' ', 'e', '.', 'g', '.', ' ', ' ', 'i', 'n', ' ', 'P', 'E', '/', 'I', 'm', 'a', 'g', 'e', ' ', 'y', 'o', 'u', ' ', 'c', 'a', 'n', ' ', 's', 'e', 'a', 'r', 'c', 'h', ' ', 'f', 'o', 'r', 0x0a,'\'','(', 'a', 'd', 'd', '|', 's', 'u', 'b', ')', '.', '+', '?', ',', '\\',' ', '[', '7', '8', ']', '$', '\'', '.', ' ', ' ', 'T', 'h', 'i', 's', ' ', 'w', 'i', 'l', 'l', ' ', 'f', 'i', 'n', 'd', ' ', 'a', 'l', 'l', ' ', 'a', 'd', 'd', ' ', 'o', 'r', ' ', 's', 'u', 'b', ' ', 'i', 'n', 's', 't', 'r', 'u', 'c', 't', 'i', 'o', 'n', 's', ' ', 'w', 'i', 't', 'h', 0x0a,'s', 'e', 'c', 'o', 'n', 'd', ' ', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', ' ', '7', ' ', 'o', 'r', ' ', '8', '.', 0x0a,0x0a,'e', 'x', 'p', 'r', ' ', 'n', 'o', 'n', 'z', 'e', 'r', 'o', 0x0a,'-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', 0x0a,0x0a, 'T', 'h', 'i', 's', ' ', 'i', 's', ' ', 't', 'h', 'e', ' ', 's', 'l', 'o', 'w', 'e', 's', 't', ' ', 'b', 'u', 't', ' ', 'a', 'l', 's', 'o', ' ', 'm', 'o', 's', 't', ' ', 'a', 'd', 'v', 'a', 'n', 'c', 'e', 'd', ' ', 's', 'e', 'a', 'r', 'c', 'h', ' ', 'm', 'o', 'd', 'e', '.', ' ', ' ', 'E', 'n', 't', 'e', 'r', ' ', 'a', 'n', 0x0a,'e', 'x', 'p', 'r', 'e', 's', 's', 'i', 'o', 'n', ' ', 'a', 'n', 'd', ' ', 't', 'h', 'e', ' ', 's', 'e', 'a', 'r', 'c', 'h', ' ', 's', 't', 'o', 'p', 's', ' ', 'i', 'f', ' ', 't', 'h', 'i', 's', ' ', 'e', 'x', 'p', 'r', 'e', 's', 's', 'i', 'o', 'n', ' ', 'e', 'v', 'a', 'l', 'u', 'a', 't', 'e', 's', ' ', 't', 'o', ' ', 'n', 'o', 'n', '-', 'z', 'e', 'r', 'o', 0x0a,'(', 'i', 't', ' ', 'w', 'i', 'l', 'l', ' ', 'b', 'e', ' ', 'e', 'v', 'a', 'l', 'u', 'a', 't', 'e', 'd', ' ', 'o', 'n', ' ', 'e', 'v', 'e', 'r', 'y', ' ', 'b', 'y', 't', 'e', ')', '.', ' ', ' ', 'I', 'n', ' ', 't', 'h', 'i', 's', ' ', 'm', 'o', 'd', 'e', ' ', 't', 'h', 'e', 'r', 'e', ' ', 'a', 'r', 'e', ' ', 't', 'w', 'o', 0x0a,'p', 'r', 'e', 'd', 'e', 'f', 'i', 'n', 'e', 'd', ' ', 's', 'y', 'm', 'b', 'o', 'l', 's', ' ', 'a', 'n', 'd', ' ', 's', 'o', 'm', 'e', ' ', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 's', ':', ' ', 'I', ' ', 'i', 's', ' ', 'a', 'l', 'w', 'a', 'y', 's', ' ', 't', 'h', 'e', ' ', 'n', 'u', 'm', 'b', 'e', 'r', ' ', 'o', 'f', ' ', 'c', 'u', 'r', 'r', 'e', 'n', 't', 0x0a,'i', 't', 'e', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'a', 'n', 'd', ' ', 'O', ' ', 's', 't', 'a', 'n', 'd', 's', ' ', 'f', 'o', 'r', ' ', 't', 'h', 'e', ' ', 'c', 'u', 'r', 'r', 'e', 'n', 't', ' ', 'o', 'f', 'f', 's', 'e', 't', ' ', 'i', 'n', ' ', 'f', 'i', 'l', 'e', '.', ' ', ' ', 'W', 'i', 't', 'h', ' ', 't', 'h', 'e', 0x0a,'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 's', ' ', '\'','r', 'e', 'a', 'd', 'b', 'y', 't', 'e', '(', 'o', 'f', 's', ')', '\'', ' ', 'a', 'n', 'd', ' ', '\'','r', 'e', 'a', 'd', 's', 't', 'r', 'i', 'n', 'g', '(', 'o', 'f', 's', ',', ' ', 's', 'i', 'z', 'e', ')', '\'',' ', 'y', 'o', 'u', ' ', 'a', 'c', 'c', 'e', 's', 's', ' ', 't', 'h', 'e', 0x0a,'f', 'i', 'l', 'e', '\'','s', ' ', 'c', 'o', 'n', 't', 'e', 'n', 't', '.', 0x0a,0x0a,' ', ' ', ' ', 'I', 't', '\'','s', ' ', 'e', 'a', 's', 'i', 'e', 'r', ' ', 't', 'o', ' ', 'u', 'n', 'd', 'e', 'r', 's', 't', 'a', 'n', 'd', ' ', 't', 'h', 'i', 's', ' ', 'w', 'i', 't', 'h', ' ', 'e', 'x', 'a', 'm', 'p', 'l', 'e', 's', ':', 0x0a,0x0a,' ', ' ', '1', '.', ' ', 'S', 'e', 'a', 'r', 'c', 'h', 'i', 'n', 'g', ' ', 'f', 'o', 'r', ' ', 'p', 'a', 't', 't', 'e', 'r', 'n', 's', ':', 0x0a,0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', 'a', '.', ' ', 'E', 'n', 't', 'e', 'r', ' ', '\'','r', 'e', 'a', 'd', 'b', 'y', 't', 'e', '(', 'o', ')', ' ', '=', '=', ' ', 'r', 'e', 'a', 'd', 'b', 'y', 't', 'e', '(', 'o', '+', '1', ')', '\'',0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'T', 'h', 'i', 's', ' ', 'w', 'i', 'l', 'l', ' ', 's', 'e', 'a', 'r', 'c', 'h', ' ', 'f', 'o', 'r', ' ', 't', 'w', 'o', ' ', 'e', 'q', 'u', 'a', 'l', ' ', 'b', 'y', 't', 'e', 's', ' ', '(', '"', 'A', 'A', '"', ',', ' ', '"', '5', '5', '"', ',', ' ', '"', '!', '!', '"', ',', ' ', 'e', 't', 'c', '.', ')', '.', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', 'b', '.', ' ', 'E', 'n', 't', 'e', 'r', ' ', '\'','(', 'r', 'e', 'a', 'd', 'b', 'y', 't', 'e', '(', 'o', ')', ' ', '=', '=', ' ', 'r', 'e', 'a', 'd', 'b', 'y', 't', 'e', '(', 'o', '+', '1', ')', '-', '1', ')', ' ', '&', '&', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '(', 'r', 'e', 'a', 'd', 'b', 'y', 't', 'e', '(', 'o', ')', '=', '=', 'r', 'e', 'a', 'd', 'b', 'y', 't', 'e', '(', 'o', '+', '2', ')', '-', '2', ')', '\'',0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'T', 'h', 'i', 's', ' ', 'w', 'i', 'l', 'l', ' ', 's', 'e', 'a', 'r', 'c', 'h', ' ', 'f', 'o', 'r', ' ', 't', 'h', 'r', 'e', 'e', ' ', 'a', 's', 'c', 'e', 'n', 'd', 'i', 'n', 'g', ' ', 'b', 'y', 't', 'e', 's', ' ', '(', '"', 'A', 'B', 'C', '"', ',', ' ', '"', '1', '2', '3', '"', ',', 0x0a, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'e', 't', 'c', ')', '.', 0x0a, 0x0a,' ', ' ', '2', '.', ' ', 'S', 'e', 'a', 'r', 'c', 'h', ' ', 'w', 'i', 't', 'h', ' ', 's', 'p', 'e', 'c', 'i', 'a', 'l', ' ', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', 's', ':', 0x0a,0x0a,' ', ' ', ' ', ' ', ' ', 'W', 'i', 't', 'h', ' ', 'H', 'T', ' ', 'y', 'o', 'u', ' ', 'c', 'a', 'n', ' ', 'e', 'a', 's', 'i', 'l', 'y', ' ', 'd', 'e', 't', 'e', 'c', 't', ' ', 't', 'h', 'e', ' ', 'R', 'S', 'A', ' ', 'k', 'e', 'y', ' ', 'i', 'n', ' ', 't', 'h', 'e', ' ', '\'','A', 'D', 'V', 'A', 'P', 'I', '3', '2', '.', 'D', 'L', 'L', '\'',':', 0x0a,' ', ' ', ' ', ' ', ' ', 'S', 'e', 'a', 'r', 'c', 'h', ' ', 'f', 'o', 'r', ' ', '\'','e', 'n', 't', 'r', 'o', 'p', 'y', '(', 'r', 'e', 'a', 'd', 's', 't', 'r', 'i', 'n', 'g', '(', 'o', ',', ' ', '6', '4', ')', ')', ' ', '>', ' ', '8', '2', '\'',' ', 'i', 'n', ' ', 'e', 'x', 'p', 'r', '!', '=', '0', ' ', 'm', 'o', 'd', 'e', ',', ' ', 'a', 'n', 'd', 0x0a,' ', ' ', ' ', ' ', ' ', 'y', 'o', 'u', ' ', 'w', 'i', 'l', 'l', ' ', 'f', 'i', 'n', 'd', ' ', 'i', 't', ' ', 'v', 'e', 'r', 'y', ' ', 'q', 'u', 'i', 'c', 'k', 'l', 'y', '.', ' ', ' ', 'H', 'o', 'w', ' ', 'd', 'o', 'e', 's', ' ', 'i', 't', ' ', 'w', 'o', 'r', 'k', '?', ' ', ' ', '\'','r', 'e', 'a', 'd', 's', 't', 'r', 'i', 'n', 'g', '(', 'o', ',', 0x0a,' ', ' ', ' ', ' ', ' ', '6', '4', ')', '\'',' ', 'r', 'e', 'a', 'd', 's', ' ', 'a', ' ', '6', '4', ' ', 'b', 'y', 't', 'e', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', 'f', 'r', 'o', 'm', ' ', 'c', 'u', 'r', 'r', 'e', 'n', 't', ' ', 'o', 'f', 'f', 's', 'e', 't', ' ', 'a', 'n', 'd', ' ', 'e', 'n', 't', 'r', 'o', 'p', 'y', 0x0a,' ', ' ', ' ', ' ', ' ', 'c', 'a', 'l', 'c', 'u', 'l', 'a', 't', 'e', 's', ' ', 't', 'h', 'e', ' ', 'e', 'n', 't', 'r', 'o', 'p', 'y', ' ', '(', '"', 'r', 'a', 'n', 'd', 'o', 'm', 'n', 'e', 's', 's', '"', ')', ' ', 'o', 'f', ' ', 'a', ' ', 's', 't', 'r', 'i', 'n', 'g', ' ', '(', 'r', 'e', 's', 'u', 'l', 't', ' ', 'i', 's', 0x0a,' ', ' ', ' ', ' ', ' ', '0', '.', '.', '1', '0', '0', ')', '.', ' ', ' ', 'S', 'o', ' ', 't', 'h', 'e', ' ', 's', 'e', 'a', 'r', 'c', 'h', ' ', 's', 't', 'o', 'p', 's', ' ', 'i', 'f', ' ', 'a', ' ', 'e', 'n', 't', 'r', 'o', 'p', 'y', ' ', 'g', 'r', 'e', 'a', 't', 'e', 'r', ' ', 't', 'h', 'a', 'n', ' ', '8', '2', '%', 0x0a,' ', ' ', ' ', ' ', ' ', '(', 'g', 'u', 'e', 's', 's', 'e', 'd', ' ', 'v', 'a', 'l', 'u', 'e', ')', ' ', 'i', 's', ' ', 'e', 'n', 'c', 'o', 'u', 'n', 't', 'e', 'r', 'e', 'd', ',', ' ', 'w', 'h', 'i', 'c', 'h', ' ', 'n', 'o', 'r', 'm', 'a', 'l', 'l', 'y', ' ', 'i', 'n', 'd', 'i', 'c', 'a', 't', 'e', 's', ' ', 'p', 'a', 'c', 'k', 'e', 'd', ' ', 'o', 'r', 0x0a,' ', ' ', ' ', ' ', ' ', 'e', 'n', 'c', 'r', 'y', 't', 'e', 'd', ' ', 'd', 'a', 't', 'a', '.', 0x0a,0x0a,' ', ' ', ' ', ' ', ' ', 'N', 'o', 't', 'e', ':', ' ', 't', 'h', 'e', ' ', '\'','e', 'n', 't', 'r', 'o', 'p', 'y', '(', ')', '\'',' ', 'f', 'u', 'n', 'c', 't', 'i', 'o', 'n', ' ', 'i', 's', ' ', 'n', 'o', 't', ' ', 't', 'h', 'e', ' ', 'b', 'e', 's', 't', ' ', 'o', 'f', ' ', 'i', 't', 's', ' ', 'k', 'i', 'n', 'd', ',', ' ', 'i', 'f', ' ', 'y', 'o', 'u', 0x0a,' ', ' ', ' ', ' ', ' ', 'k', 'n', 'o', 'w', ' ', 'o', 'f', ' ', 'a', ' ', 'b', 'e', 't', 't', 'e', 'r', ' ', 'o', 'n', 'e', ' ', 'p', 'l', 'e', 'a', 's', 'e', ' ', 'l', 'e', 't', ' ', 'u', 's', ' ', 'k', 'n', 'o', 'w', '!', 0x0a,0x0a,0x1f,0x0a,'F', 'i', 'l', 'e', ':', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', ' ', 'N', 'o', 'd', 'e', ':', ' ', 'C', 'o', 'm', 'm', 'a', 'n', 'd', ' ', 'l', 'i', 'n', 'e', ' ', 'o', 'p', 't', 'i', 'o', 'n', 's', ',', ' ', ' ', 'P', 'r', 'e', 'v', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', ',', ' ', ' ', 'U', 'p', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', 0x0a,0x0a,'C', 'o', 'm', 'm', 'a', 'n', 'd', ' ', 'l', 'i', 'n', 'e', ' ', 'o', 'p', 't', 'i', 'o', 'n', 's', 0x0a,'=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', 0x0a,0x0a,'\'', '-', '-', '\'',' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 't', 'r', 'e', 'a', 't', ' ', 'a', 'l', 'l', ' ', 'a', 'd', 'd', 'i', 't', 'i', 'o', 'n', 'a', 'l', ' ', 'p', 'a', 'r', 'a', 'm', 'e', 't', 'e', 'r', 's', ' ', 'a', 's', ' ', 'f', 'i', 'l', 'e', ' ', 'n', 'a', 'm', 'e', 's', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x0a,'\'','-', 'v', '\'', ' ', ' ', ' ', ' ', '\'','-', '-', 'v', 'e', 'r', 's', 'i', 'o', 'n', '\'',' ', ' ', ' ', ' ', 's', 'h', 'o', 'w', ' ', 'v', 'e', 'r', 's', 'i', 'o', 'n', ' ', 'a', 'n', 'd', ' ', 'c', 'o', 'p', 'y', 'r', 'i', 'g', 'h', 't', ' ', 'o', 'n', ' ', 'c', 'o', 'n', 's', 'o', 'l', 'e', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x0a,'\'','-', 'h', '\'',' ', ' ', ' ', ' ', '\'','-', '-', 'h', 'e', 'l', 'p', '\'',' ', ' ', ' ', ' ', ' ', ' ', ' ', 's', 'h', 'o', 'w', ' ', 'h', 'e', 'l', 'p', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x0a,'\'','-', 't', '\'',' ', ' ', ' ', ' ', '\'','-', '-', 't', 'e', 'x', 't', '\'',' ', ' ', ' ', ' ', ' ', ' ', ' ', 'l', 'o', 'a', 'd', ' ', 'f', 'i', 'l', 'e', '(', 's', ')', ' ', 'i', 'n', ' ', 't', 'e', 'x', 't', ' ', 'e', 'd', 'i', 't', 'o', 'r', ' ', 'm', 'o', 'd', 'e', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x0a,'\'','-', 'b', '\'',' ', ' ', ' ', ' ', '\'','-', '-', 'b', 'i', 'n', '\'',' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'l', 'o', 'a', 'd', ' ', 'f', 'i', 'l', 'e', '(', 's', ')', ' ', 'i', 'n', ' ', 'h', 'e', 'x', ' ', 'e', 'd', 'i', 't', 'o', 'r', ' ', 'm', 'o', 'd', 'e', 0x0a,' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 0x0a,'\'','-', 'a', '\'',' ', ' ', ' ', ' ', '\'','-', '-', 'a', 'u', 't', 'o', '\'',' ', ' ', ' ', ' ', ' ', ' ', ' ', 't', 'r', 'y', ' ', 't', 'o', ' ', 'g', 'u', 'e', 's', 's', ' ', 'f', 'i', 'l', 'e', ' ', 't', 'y', 'p', 'e', 0x0a,0x0a, 0x1f,0x0a,'F', 'i', 'l', 'e', ':', ' ', 'h', 't', 'h', 'e', 'l', 'p', '.', 'i', 'n', 'f', 'o', ',', ' ', ' ', 'N', 'o', 'd', 'e', ':', ' ', 'W', 'h', 'e', 'r', 'e', ' ', 't', 'o', ' ', 'd', 'o', 'w', 'n', 'l', 'o', 'a', 'd', '?', ',', ' ', ' ', 'P', 'r', 'e', 'v', ':', ' ', 'T', 'o', 'p', ',', ' ', ' ', 'U', 'p', ':', ' ', 'T', 'o', 'p', 0x0a,0x0a,'W', 'h', 'e', 'r', 'e', ' ', 't', 'o', ' ', 'd', 'o', 'w', 'n', 'l', 'o', 'a', 'd', '?', 0x0a,'=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', '=', 0x0a,0x0a,'T', 'h', 'e', ' ', 'H', 'T', ' ', 'h', 'o', 'm', 'e', 'p', 'a', 'g', 'e', ' ', 'i', 's', ' ', 'l', 'o', 'c', 'a', 't', 'e', 'd', ' ', 'a', 't', ' ', '<', 'h', 't', 't', 'p', ':', '/', '/', 'h', 't', 'e', '.', 's', 'o', 'u', 'r', 'c', 'e', 'f', 'o', 'r', 'g', 'e', '.', 'n', 'e', 't', '>', 0x0a, 0x0a,'D', 'o', 'w', 'n', 'l', 'o', 'a', 'd', 's', ' ', 'a', 'r', 'e', ' ', 'a', 'v', 'a', 'i', 'l', 'a', 'b', 'l', 'e', ' ', 'f', 'r', 'o', 'm', ' ', 't', 'h', 'e', ' ', '\'','d', 'o', 'w', 'n', 'l', 'o', 'a', 'd', '\'',' ', 's', 'e', 'c', 't', 'i', 'o', 'n', '.', ' ', ' ', 'P', 'l', 'e', 'a', 's', 'e', ' ', 'a', 'l', 's', 'o', ' ', 't', 'a', 'k', 'e', ' ', 'a', 0x0a,'l', 'o', 'o', 'k', ' ', 'a', 't', ' ', '<', 'h', 't', 't', 'p', ':', '/', '/', 's', 'o', 'u', 'r', 'c', 'e', 'f', 'o', 'r', 'g', 'e', '.', 'n', 'e', 't', '/', 'p', 'r', 'o', 'j', 'e', 'c', 't', 's', '/', 'h', 't', 'e', '>', 0x0a, 0x0a,0x0a,0x1f,0x0a,'T', 'a', 'g', ' ', 'T', 'a', 'b', 'l', 'e', ':', 0x0a,'N', 'o', 'd', 'e', ':', ' ', 'T', 'o', 'p', 0x7f,'5', '8', '1', 0x0a,'N', 'o', 'd', 'e', ':', ' ', 'A', 'b', 'o', 'u', 't', 0x7f,'7', '7', '8', 0x0a,'N', 'o', 'd', 'e', ':', ' ', 'K', 'e', 'y', ' ', 'b', 'i', 'n', 'd', 'i', 'n', 'g', 's', 0x7f, '1', '6', '2', '6', 0x0a,'N', 'o', 'd', 'e', ':', ' ', 'A', 'u', 't', 'h', 'o', 'r', 's', 0x7f,'3', '3', '8', '7', 0x0a, 'N', 'o', 'd', 'e', ':', ' ', 'F', 'e', 'a', 't', 'u', 'r', 'e', 's', 0x7f,'3', '5', '2', '7', 0x0a,'N', 'o', 'd', 'e', ':', ' ', 'G', 'e', 'n', 'e', 'r', 'a', 'l', ' ', 'f', 'e', 'a', 't', 'u', 'r', 'e', 's', 0x7f,'3', '8', '9', '0', 0x0a, 'N', 'o', 'd', 'e', ':', ' ', 'C', 'o', 'n', 'f', 'i', 'g', 'u', 'r', 'a', 't', 'i', 'o', 'n', ' ', 'f', 'i', 'l', 'e', 's', 0x7f,'6', '6', '9', '0', 0x0a,'N', 'o', 'd', 'e', ':', ' ', 'C', 'l', 'i', 'p', 'b', 'o', 'a', 'r', 'd', 0x7f,'7', '3', '3', '9', 0x0a,'N', 'o', 'd', 'e', ':', ' ', 'G', 'l', 'o', 'b', 'a', 'l', ' ', 'h', 'i', 's', 't', 'o', 'r', 'y', 0x7f,'8', '1', '5', '3', 0x0a,'N', 'o', 'd', 'e', ':', ' ', 'E', 'x', 'p', 'r', 'e', 's', 's', 'i', 'o', 'n', ' ', 'e', 'v', 'a', 'l', 'u', 'a', 't', 'i', 'o', 'n', 0x7f,'8', '7', '0', '4', 0x0a,'N', 'o', 'd', 'e', ':', ' ', 'B', 'l', 'o', 'c', 'k', ' ', 'o', 'p', 'e', 'r', 'a', 't', 'i', 'o', 'n', 's', 0x7f,'1', '0', '6', '0', '0', 0x0a,'N', 'o', 'd', 'e', ':', ' ', 'S', 'e', 'a', 'r', 'c', 'h', ' ', 'a', 'n', 'd', ' ', 'i', 't', 's', ' ', 'd', 'i', 'f', 'f', 'e', 'r', 'e', 'n', 't', ' ', 'm', 'o', 'd', 'e', 's', 0x7f,'1', '1', '4', '5', '5', 0x0a,'N', 'o', 'd', 'e', ':', ' ', 'C', 'o', 'm', 'm', 'a', 'n', 'd', ' ', 'l', 'i', 'n', 'e', ' ', 'o', 'p', 't', 'i', 'o', 'n', 's', 0x7f,'1', '4', '1', '2', '2', 0x0a, 'N', 'o', 'd', 'e', ':', ' ', 'W', 'h', 'e', 'r', 'e', ' ', 't', 'o', ' ', 'd', 'o', 'w', 'n', 'l', 'o', 'a', 'd', '?', 0x7f,'1', '4', '6', '8', '8', 0x0a,0x1f, 0x0a,'E', 'n', 'd', ' ', 'T', 'a', 'g', ' ', 'T', 'a', 'b', 'l', 'e', 0x0a }; ht-2.0.22/htpeimg.cc0000644000175000001440000001402711011644507011074 00000000000000/* * HT Editor * htpeimg.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "log.h" #include "formats.h" #include "htnewexe.h" #include "htpal.h" #include "htpeimg.h" #include "strtools.h" #include "pe_analy.h" #include "pestruct.h" #include "snprintf.h" static ht_view *htpeimage_init(Bounds *b, File *file, ht_format_group *group) { ht_pe_shared_data *pe_shared=(ht_pe_shared_data *)group->get_shared_data(); if (pe_shared->opt_magic!=COFF_OPTMAGIC_PE32 && pe_shared->opt_magic!=COFF_OPTMAGIC_PE64) return 0; bool pe32 = (pe_shared->opt_magic==COFF_OPTMAGIC_PE32); String fn; LOG("%y: PE: loading image (starting analyser)...", &file->getFilename(fn)); PEAnalyser *p = new PEAnalyser(); p->init(pe_shared, file); Bounds c=*b; ht_group *g=new ht_group(); g->init(&c, VO_RESIZE, DESC_PE_IMAGE"-g"); AnalyInfoline *head; c.y+=2; c.h-=2; ht_pe_aviewer *v=new ht_pe_aviewer(); v->init(&c, DESC_PE_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, p, pe_shared); c.y-=2; c.h=2; head=new AnalyInfoline(); head->init(&c, v, ANALY_STATUS_DEFAULT); v->attachInfoline(head); /* search for lowest/highest */ RVA l=(RVA)-1, h=0; COFF_SECTION_HEADER *s=pe_shared->sections.sections; for (uint i=0; isections.section_count; i++) { if (s->data_address < l) l = s->data_address; if ((s->data_address + s->data_size > h) && s->data_size) h = s->data_address + s->data_size - 1; s++; } /**/ Address *low; Address *high; if (pe32) { l += pe_shared->pe32.header_nt.image_base; h += pe_shared->pe32.header_nt.image_base; low = p->createAddress32(l); high = p->createAddress32(h); } else { low = p->createAddress64(l + pe_shared->pe64.header_nt.image_base); high = p->createAddress64(h + pe_shared->pe64.header_nt.image_base); } ht_analy_sub *analy=new ht_analy_sub(); analy->init(file, v, p, low, high); delete low; delete high; v->analy_sub = analy; v->insertsub(analy); v->sendmsg(msg_complete_init, 0); Address *tmpaddr; if (pe32) { tmpaddr = p->createAddress32(pe_shared->pe32.header.entrypoint_address + pe_shared->pe32.header_nt.image_base); } else { tmpaddr = p->createAddress64(pe_shared->pe64.header.entrypoint_address + pe_shared->pe64.header_nt.image_base); } v->gotoAddress(tmpaddr, NULL); delete tmpaddr; g->insert(head); g->insert(v); g->setpalette(palkey_generic_window_default); pe_shared->v_image=v; return g; } format_viewer_if htpeimage_if = { htpeimage_init, 0 }; static int pe_viewer_func_rva(eval_scalar *result, eval_int *i) { ht_pe_aviewer *aviewer = (ht_pe_aviewer*)eval_get_context(); RVA rva = i->value; viewer_pos p; FileOfs ofs; if (pe_rva_to_ofs(&aviewer->pe_shared->sections, rva, &ofs) && aviewer->offset_to_pos(ofs, &p)) { Address *a; int b; aviewer->convertViewerPosToAddress(p, &a); a->putIntoArray((byte*)&b); delete a; scalar_create_int_c(result, b); return 1; } else { set_eval_error("invalid file offset or no corresponding RVA for '0%xh'", rva); } return 0; } static int pe_viewer_func_section_int(eval_scalar *result, eval_int *q) { ht_pe_aviewer *aviewer = (ht_pe_aviewer*)eval_get_context(); uint64 i = q->value - 1; if (i >= 0 && i < aviewer->pe_shared->sections.section_count) { viewer_pos p; FileOfs ofs; if (pe_rva_to_ofs(&aviewer->pe_shared->sections, aviewer->pe_shared->sections.sections[i].data_address, &ofs) && aviewer->offset_to_pos(ofs, &p)) { Address *a; uint64 b; aviewer->convertViewerPosToAddress(p, &a); a->putIntoUInt64(b); delete a; scalar_create_int_q(result, b); return 1; } else { // set_eval_error("invalid file offset or no corresponding RVA for '0%xh'", rva); } } else { set_eval_error("no section number %qd", q->value); } return 0; } static int pe_viewer_func_section_str(eval_scalar *result, eval_str *str) { ht_pe_aviewer *aviewer = (ht_pe_aviewer*)eval_get_context(); int section; char str2[COFF_SIZEOF_SHORT_NAME+1]; memset(str2, 0, COFF_SIZEOF_SHORT_NAME+1); memcpy(str2, str->value, MIN(str->len, COFF_SIZEOF_SHORT_NAME)); if (pe_section_name_to_section(&aviewer->pe_shared->sections, str2, §ion)) { eval_scalar i; scalar_create_int_c(&i, section+1); return pe_viewer_func_section_int(result, &i.scalar.integer); } return 0; } static int pe_viewer_func_section(eval_scalar *result, eval_scalar *q) { if (q->type == SCALAR_STR) return pe_viewer_func_section_str(result, &q->scalar.str); else { eval_int i; scalar_context_int(q, &i); return pe_viewer_func_section_int(result, &i); } } /* * CLASS ht_pe_aviewer */ void ht_pe_aviewer::init(Bounds *b, const char *desc, int caps, File *File, ht_format_group *format_group, Analyser *Analy, ht_pe_shared_data *PE_shared) { ht_aviewer::init(b, desc, caps, File, format_group, Analy); pe_shared = PE_shared; } bool ht_pe_aviewer::func_handler(eval_scalar *result, char *name, eval_scalarlist *params) { eval_func myfuncs[] = { {"rva", (void*)&pe_viewer_func_rva, {SCALAR_INT}, "returns address of rva"}, {"section", (void*)&pe_viewer_func_section, {SCALAR_ANY}, "returns address of section named param1 if param1 is a string\n" "returns address of section with index param1 otherwise"}, {NULL} }; if (std_eval_func_handler(result, name, params, myfuncs)) return true; return ht_aviewer::func_handler(result, name, params); } void ht_pe_aviewer::setAnalyser(Analyser *a) { ((PEAnalyser *)a)->reinit(pe_shared, file); analy = a; analy_sub->setAnalyser(a); } ht-2.0.22/cmds.h0000644000175000001440000000661010615341616010232 00000000000000/* * HT Editor * cmds.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __CMDS_H__ #define __CMDS_H__ #include "io/types.h" #define CMD uint32 #define msg_command 0x80000000 #define HT_COMMAND(c) (msg_command+(c)) #define cmd_quit HT_COMMAND(100) #define cmd_about HT_COMMAND(101) #define cmd_file_open HT_COMMAND(102) #define cmd_file_new HT_COMMAND(103) #define cmd_file_save HT_COMMAND(104) #define cmd_file_saveas HT_COMMAND(105) #define cmd_file_exec_cmd HT_COMMAND(106) #define cmd_edit_cut HT_COMMAND(120) #define cmd_edit_delete HT_COMMAND(121) #define cmd_edit_copy HT_COMMAND(122) #define cmd_edit_paste HT_COMMAND(123) #define cmd_edit_show_clipboard HT_COMMAND(124) #define cmd_edit_clear_clipboard HT_COMMAND(125) #define cmd_edit_copy_from_file HT_COMMAND(126) #define cmd_edit_paste_into_file HT_COMMAND(127) #define cmd_edit_copy_native HT_COMMAND(128) #define cmd_edit_paste_native HT_COMMAND(129) #define cmd_window_resizemove HT_COMMAND(140) #define cmd_window_switch_resizemove HT_COMMAND(141) #define cmd_window_close HT_COMMAND(142) #define cmd_window_tile_vertical HT_COMMAND(143) #define cmd_window_tile_horizontal HT_COMMAND(144) #define cmd_project_open HT_COMMAND(160) #define cmd_project_close HT_COMMAND(161) #define cmd_project_add_item HT_COMMAND(162) #define cmd_project_remove_item HT_COMMAND(163) #define cmd_project_edit_item HT_COMMAND(164) #define cmd_popup_dialog_eval HT_COMMAND(180) #define cmd_popup_dialog_view_list HT_COMMAND(181) #define cmd_popup_dialog_window_list HT_COMMAND(182) #define cmd_popup_window_log HT_COMMAND(183) #define cmd_popup_window_help HT_COMMAND(184) #define cmd_popup_window_options HT_COMMAND(185) #define cmd_popup_window_project HT_COMMAND(186) #define cmd_popup_dialog_info_loader HT_COMMAND(187) #define cmd_vstate_restore HT_COMMAND(190) #define cmd_analyser_save HT_COMMAND(200) /* * htanaly 500- 999 */ /* * htformat 1000- 1499 */ #define cmd_view_mode HT_COMMAND(1000) #define cmd_edit_mode HT_COMMAND(1001) #define cmd_view_mode_i HT_COMMAND(1002) #define cmd_edit_mode_i HT_COMMAND(1003) #define cmd_file_goto HT_COMMAND(1004) #define cmd_file_search HT_COMMAND(1005) #define cmd_file_replace HT_COMMAND(1006) #define cmd_file_blockop HT_COMMAND(1007) #define cmd_file_resize HT_COMMAND(1008) #define cmd_file_truncate HT_COMMAND(1009) #define cmd_file_extend HT_COMMAND(1010) /* * hex 1500 - 1999 */ #define cmd_hex_entropy HT_COMMAND(1500) #define cmd_hex_display_bytes HT_COMMAND(1501) #define cmd_hex_display_disp HT_COMMAND(1502) /* * disasm 2000 - 2499 */ #define cmd_disasm_call_assembler HT_COMMAND(2000) #define cmd_disasm_toggle1632 HT_COMMAND(2001) #endif /* __CMDS_H__ */ ht-2.0.22/htxbehead.cc0000644000175000001440000004725610615341624011410 00000000000000/* * HT Editor * htxbehead.cc * * Copyright (C) 2003 Stefan Esser * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "formats.h" #include "htapp.h" #include "atom.h" #include "htcoff.h" #include "htctrl.h" #include "endianess.h" #include "hthex.h" #include "htiobox.h" #include "htnewexe.h" #include "htxbe.h" #include "htxbehead.h" #include "httag.h" #include "strtools.h" #include "snprintf.h" #include "xbestruct.h" #include static ht_mask_ptable xbemagic[] = { {"magic", STATICTAG_EDIT_CHAR("00000000")STATICTAG_EDIT_CHAR("00000001")STATICTAG_EDIT_CHAR("00000002")STATICTAG_EDIT_CHAR("00000003")}, {0, 0} }; static ht_tag_flags_s xbe_init_flags[] = { {-1, "XBE - initialisation flags"}, {0, "[00] Mount Utility Drive"}, {1, "[01] Format Utility Drive"}, {2, "[02] Limit to 64MB"}, {3, "[03] Dont setup harddisk"}, {0, 0} }; static ht_mask_ptable xbeimageheader[] = { {"base address", STATICTAG_EDIT_DWORD_LE("00000104")}, {"size of headers", STATICTAG_EDIT_DWORD_LE("00000108")}, {"size of image", STATICTAG_EDIT_DWORD_LE("0000010c")}, {"size of imageheader", STATICTAG_EDIT_DWORD_LE("00000110")}, {"timestamp", STATICTAG_EDIT_DWORD_LE("00000114")}, {"certificate address", STATICTAG_EDIT_DWORD_LE("00000118")}, {"number of sections", STATICTAG_EDIT_DWORD_LE("0000011c")}, {"section header address", STATICTAG_EDIT_DWORD_LE("00000120")}, {"initialisation flags", STATICTAG_EDIT_DWORD_LE("00000124")" "STATICTAG_FLAGS("00000124", ATOM_XBE_INIT_FLAGS_STR)}, {"entry point", STATICTAG_EDIT_DWORD_LE("00000128")}, {"TLS address", STATICTAG_EDIT_DWORD_LE("0000012c")}, {"PE stack commit", STATICTAG_EDIT_DWORD_LE("00000130")}, {"PE heap reserve", STATICTAG_EDIT_DWORD_LE("00000134")}, {"PE heap commit", STATICTAG_EDIT_DWORD_LE("00000138")}, {"PE base address", STATICTAG_EDIT_DWORD_LE("0000013c")}, {"PE size of image", STATICTAG_EDIT_DWORD_LE("00000140")}, {"PE checksum", STATICTAG_EDIT_DWORD_LE("00000144")}, {"PE timestamp", STATICTAG_EDIT_DWORD_LE("00000148")}, {"debug pathname address", STATICTAG_EDIT_DWORD_LE("0000014c")}, {"debug filename address", STATICTAG_EDIT_DWORD_LE("00000150")}, {"debug unicode filename address", STATICTAG_EDIT_DWORD_LE("00000154")}, {"kernel image thunk address", STATICTAG_EDIT_DWORD_LE("00000158")}, {"non-kernel import directoy address", STATICTAG_EDIT_DWORD_LE("0000015c")}, {"number of library versions", STATICTAG_EDIT_DWORD_LE("00000160")}, {"library versions address", STATICTAG_EDIT_DWORD_LE("00000164")}, {"kernel library version", STATICTAG_EDIT_DWORD_LE("00000168")}, {"xapi library version", STATICTAG_EDIT_DWORD_LE("0000016c")}, {"logo bitmap address", STATICTAG_EDIT_DWORD_LE("00000170")}, {"logo bitmap size", STATICTAG_EDIT_DWORD_LE("00000174")}, {0, 0} }; static ht_tag_flags_s xbe_media_flags[] = { {-1, "XBE - allowed media flags"}, {0, "[00] Harddisk"}, {1, "[01] DVD X2"}, {2, "[02] DVD CD"}, {3, "[03] CD"}, {4, "[04] DVD-5 RO"}, {5, "[05] DVD-9 RO"}, {6, "[06] DVD-5 RW"}, {7, "[07] DVD-9 RW"}, {8, "[08] Dongle"}, {9, "[09] Mediaboard"}, {30, "[30] Nonsecure Harddisk"}, {31, "[31] Nonsecure Mode"}, {0, 0} }; static ht_tag_flags_s xbe_region_codes[] = { { -1, "XBE - game region codes"}, { 0, "[00] USA"}, { 1, "[01] Japan"}, { 2, "[02] Rest of World"}, { 31, "[31] Manufacturing" }, {0, 0} }; static ht_mask_ptable xbecertificate[] = { {"certificate size", STATICTAG_EDIT_DWORD_LE("00000000")}, {"timestamp", STATICTAG_EDIT_DWORD_LE("00000004")}, {"title id", STATICTAG_EDIT_DWORD_LE("00000008")}, {"alternate title ids", STATICTAG_EDIT_DWORD_LE("0000005c") " " STATICTAG_EDIT_DWORD_LE("00000060") " " STATICTAG_EDIT_DWORD_LE("00000064")}, {"", STATICTAG_EDIT_DWORD_LE("00000068") " " STATICTAG_EDIT_DWORD_LE("0000006c") " " STATICTAG_EDIT_DWORD_LE("00000070")}, {"", STATICTAG_EDIT_DWORD_LE("00000074") " " STATICTAG_EDIT_DWORD_LE("00000078") " " STATICTAG_EDIT_DWORD_LE("0000007c")}, {"", STATICTAG_EDIT_DWORD_LE("00000080") " " STATICTAG_EDIT_DWORD_LE("00000084") " " STATICTAG_EDIT_DWORD_LE("00000088")}, {"", STATICTAG_EDIT_DWORD_LE("0000008c") " " STATICTAG_EDIT_DWORD_LE("00000090") " " STATICTAG_EDIT_DWORD_LE("00000094")}, {"", STATICTAG_EDIT_DWORD_LE("00000098")}, {"allowed media", STATICTAG_EDIT_DWORD_LE("0000009c")" ("STATICTAG_FLAGS("0000009c", ATOM_XBE_MEDIA_FLAGS_STR)")"}, {"game region", STATICTAG_EDIT_DWORD_LE("000000a0")" ("STATICTAG_FLAGS("000000a0", ATOM_XBE_REGION_STR)")"}, {"game ratings", STATICTAG_EDIT_DWORD_LE("000000a4")}, {"disk number", STATICTAG_EDIT_DWORD_LE("000000a8")}, {"version", STATICTAG_EDIT_DWORD_LE("000000ac")}, {"lan key", STATICTAG_EDIT_BYTE("000000b0") STATICTAG_EDIT_BYTE("000000b1") STATICTAG_EDIT_BYTE("000000b2") STATICTAG_EDIT_BYTE("000000b3") STATICTAG_EDIT_BYTE("000000b4") STATICTAG_EDIT_BYTE("000000b5") STATICTAG_EDIT_BYTE("000000b6") STATICTAG_EDIT_BYTE("000000b7") STATICTAG_EDIT_BYTE("000000b8") STATICTAG_EDIT_BYTE("000000b9") STATICTAG_EDIT_BYTE("000000ba") STATICTAG_EDIT_BYTE("000000bb") STATICTAG_EDIT_BYTE("000000bc") STATICTAG_EDIT_BYTE("000000bd") STATICTAG_EDIT_BYTE("000000be") STATICTAG_EDIT_BYTE("000000bf")}, {"signature key", STATICTAG_EDIT_BYTE("000000c0") STATICTAG_EDIT_BYTE("000000c1") STATICTAG_EDIT_BYTE("000000c2") STATICTAG_EDIT_BYTE("000000c3") STATICTAG_EDIT_BYTE("000000c4") STATICTAG_EDIT_BYTE("000000c5") STATICTAG_EDIT_BYTE("000000c6") STATICTAG_EDIT_BYTE("000000c7") STATICTAG_EDIT_BYTE("000000c8") STATICTAG_EDIT_BYTE("000000c9") STATICTAG_EDIT_BYTE("000000ca") STATICTAG_EDIT_BYTE("000000cb") STATICTAG_EDIT_BYTE("000000cc") STATICTAG_EDIT_BYTE("000000cd") STATICTAG_EDIT_BYTE("000000ce") STATICTAG_EDIT_BYTE("000000cf")}, {"alternate signature keys", STATICTAG_EDIT_BYTE("000000d0") STATICTAG_EDIT_BYTE("000000d1") STATICTAG_EDIT_BYTE("000000d2") STATICTAG_EDIT_BYTE("000000d3") STATICTAG_EDIT_BYTE("000000d4") STATICTAG_EDIT_BYTE("000000d5") STATICTAG_EDIT_BYTE("000000d6") STATICTAG_EDIT_BYTE("000000d7") STATICTAG_EDIT_BYTE("000000d8") STATICTAG_EDIT_BYTE("000000d9") STATICTAG_EDIT_BYTE("000000da") STATICTAG_EDIT_BYTE("000000db") STATICTAG_EDIT_BYTE("000000dc") STATICTAG_EDIT_BYTE("000000dd") STATICTAG_EDIT_BYTE("000000de") STATICTAG_EDIT_BYTE("000000df")}, {"", STATICTAG_EDIT_BYTE("000000e0") STATICTAG_EDIT_BYTE("000000e1") STATICTAG_EDIT_BYTE("000000e2") STATICTAG_EDIT_BYTE("000000e3") STATICTAG_EDIT_BYTE("000000e4") STATICTAG_EDIT_BYTE("000000e5") STATICTAG_EDIT_BYTE("000000e6") STATICTAG_EDIT_BYTE("000000e7") STATICTAG_EDIT_BYTE("000000e8") STATICTAG_EDIT_BYTE("000000e9") STATICTAG_EDIT_BYTE("000000ea") STATICTAG_EDIT_BYTE("000000eb") STATICTAG_EDIT_BYTE("000000ec") STATICTAG_EDIT_BYTE("000000ed") STATICTAG_EDIT_BYTE("000000ee") STATICTAG_EDIT_BYTE("000000ef")}, {"", STATICTAG_EDIT_BYTE("000000f0") STATICTAG_EDIT_BYTE("000000f1") STATICTAG_EDIT_BYTE("000000f2") STATICTAG_EDIT_BYTE("000000f3") STATICTAG_EDIT_BYTE("000000f4") STATICTAG_EDIT_BYTE("000000f5") STATICTAG_EDIT_BYTE("000000f6") STATICTAG_EDIT_BYTE("000000f7") STATICTAG_EDIT_BYTE("000000f8") STATICTAG_EDIT_BYTE("000000f9") STATICTAG_EDIT_BYTE("000000fa") STATICTAG_EDIT_BYTE("000000fb") STATICTAG_EDIT_BYTE("000000fc") STATICTAG_EDIT_BYTE("000000fd") STATICTAG_EDIT_BYTE("000000fe") STATICTAG_EDIT_BYTE("000000ff")}, {"", STATICTAG_EDIT_BYTE("00000100") STATICTAG_EDIT_BYTE("00000101") STATICTAG_EDIT_BYTE("00000102") STATICTAG_EDIT_BYTE("00000103") STATICTAG_EDIT_BYTE("00000104") STATICTAG_EDIT_BYTE("00000105") STATICTAG_EDIT_BYTE("00000106") STATICTAG_EDIT_BYTE("00000107") STATICTAG_EDIT_BYTE("00000108") STATICTAG_EDIT_BYTE("00000109") STATICTAG_EDIT_BYTE("0000010a") STATICTAG_EDIT_BYTE("0000010b") STATICTAG_EDIT_BYTE("0000010c") STATICTAG_EDIT_BYTE("0000010d") STATICTAG_EDIT_BYTE("0000010e") STATICTAG_EDIT_BYTE("0000010f")}, {"", STATICTAG_EDIT_BYTE("00000110") STATICTAG_EDIT_BYTE("00000111") STATICTAG_EDIT_BYTE("00000112") STATICTAG_EDIT_BYTE("00000113") STATICTAG_EDIT_BYTE("00000114") STATICTAG_EDIT_BYTE("00000115") STATICTAG_EDIT_BYTE("00000116") STATICTAG_EDIT_BYTE("00000117") STATICTAG_EDIT_BYTE("00000118") STATICTAG_EDIT_BYTE("00000119") STATICTAG_EDIT_BYTE("0000011a") STATICTAG_EDIT_BYTE("0000011b") STATICTAG_EDIT_BYTE("0000011c") STATICTAG_EDIT_BYTE("0000011d") STATICTAG_EDIT_BYTE("0000011e") STATICTAG_EDIT_BYTE("0000011f")}, {"", STATICTAG_EDIT_BYTE("00000120") STATICTAG_EDIT_BYTE("00000121") STATICTAG_EDIT_BYTE("00000122") STATICTAG_EDIT_BYTE("00000123") STATICTAG_EDIT_BYTE("00000124") STATICTAG_EDIT_BYTE("00000125") STATICTAG_EDIT_BYTE("00000126") STATICTAG_EDIT_BYTE("00000127") STATICTAG_EDIT_BYTE("00000128") STATICTAG_EDIT_BYTE("00000129") STATICTAG_EDIT_BYTE("0000012a") STATICTAG_EDIT_BYTE("0000012b") STATICTAG_EDIT_BYTE("0000012c") STATICTAG_EDIT_BYTE("0000012d") STATICTAG_EDIT_BYTE("0000012e") STATICTAG_EDIT_BYTE("0000012f")}, {"", STATICTAG_EDIT_BYTE("00000130") STATICTAG_EDIT_BYTE("00000131") STATICTAG_EDIT_BYTE("00000132") STATICTAG_EDIT_BYTE("00000133") STATICTAG_EDIT_BYTE("00000134") STATICTAG_EDIT_BYTE("00000135") STATICTAG_EDIT_BYTE("00000136") STATICTAG_EDIT_BYTE("00000137") STATICTAG_EDIT_BYTE("00000138") STATICTAG_EDIT_BYTE("00000139") STATICTAG_EDIT_BYTE("0000013a") STATICTAG_EDIT_BYTE("0000013b") STATICTAG_EDIT_BYTE("0000013c") STATICTAG_EDIT_BYTE("0000013d") STATICTAG_EDIT_BYTE("0000013e") STATICTAG_EDIT_BYTE("0000013f")}, {"", STATICTAG_EDIT_BYTE("00000140") STATICTAG_EDIT_BYTE("00000141") STATICTAG_EDIT_BYTE("00000142") STATICTAG_EDIT_BYTE("00000143") STATICTAG_EDIT_BYTE("00000144") STATICTAG_EDIT_BYTE("00000145") STATICTAG_EDIT_BYTE("00000146") STATICTAG_EDIT_BYTE("00000147") STATICTAG_EDIT_BYTE("00000148") STATICTAG_EDIT_BYTE("00000149") STATICTAG_EDIT_BYTE("0000014a") STATICTAG_EDIT_BYTE("0000014b") STATICTAG_EDIT_BYTE("0000014c") STATICTAG_EDIT_BYTE("0000014d") STATICTAG_EDIT_BYTE("0000014e") STATICTAG_EDIT_BYTE("0000014f")}, {"", STATICTAG_EDIT_BYTE("00000150") STATICTAG_EDIT_BYTE("00000151") STATICTAG_EDIT_BYTE("00000152") STATICTAG_EDIT_BYTE("00000153") STATICTAG_EDIT_BYTE("00000154") STATICTAG_EDIT_BYTE("00000155") STATICTAG_EDIT_BYTE("00000156") STATICTAG_EDIT_BYTE("00000157") STATICTAG_EDIT_BYTE("00000158") STATICTAG_EDIT_BYTE("00000159") STATICTAG_EDIT_BYTE("0000015a") STATICTAG_EDIT_BYTE("0000015b") STATICTAG_EDIT_BYTE("0000015c") STATICTAG_EDIT_BYTE("0000015d") STATICTAG_EDIT_BYTE("0000015e") STATICTAG_EDIT_BYTE("0000015f")}, {"", STATICTAG_EDIT_BYTE("00000160") STATICTAG_EDIT_BYTE("00000161") STATICTAG_EDIT_BYTE("00000162") STATICTAG_EDIT_BYTE("00000163") STATICTAG_EDIT_BYTE("00000164") STATICTAG_EDIT_BYTE("00000165") STATICTAG_EDIT_BYTE("00000166") STATICTAG_EDIT_BYTE("00000167") STATICTAG_EDIT_BYTE("00000168") STATICTAG_EDIT_BYTE("00000169") STATICTAG_EDIT_BYTE("0000016a") STATICTAG_EDIT_BYTE("0000016b") STATICTAG_EDIT_BYTE("0000016c") STATICTAG_EDIT_BYTE("0000016d") STATICTAG_EDIT_BYTE("0000016e") STATICTAG_EDIT_BYTE("0000016f")}, {"", STATICTAG_EDIT_BYTE("00000170") STATICTAG_EDIT_BYTE("00000171") STATICTAG_EDIT_BYTE("00000172") STATICTAG_EDIT_BYTE("00000173") STATICTAG_EDIT_BYTE("00000174") STATICTAG_EDIT_BYTE("00000175") STATICTAG_EDIT_BYTE("00000176") STATICTAG_EDIT_BYTE("00000177") STATICTAG_EDIT_BYTE("00000178") STATICTAG_EDIT_BYTE("00000179") STATICTAG_EDIT_BYTE("0000017a") STATICTAG_EDIT_BYTE("0000017b") STATICTAG_EDIT_BYTE("0000017c") STATICTAG_EDIT_BYTE("0000017d") STATICTAG_EDIT_BYTE("0000017e") STATICTAG_EDIT_BYTE("0000017f")}, {"", STATICTAG_EDIT_BYTE("00000180") STATICTAG_EDIT_BYTE("00000181") STATICTAG_EDIT_BYTE("00000182") STATICTAG_EDIT_BYTE("00000183") STATICTAG_EDIT_BYTE("00000184") STATICTAG_EDIT_BYTE("00000185") STATICTAG_EDIT_BYTE("00000186") STATICTAG_EDIT_BYTE("00000187") STATICTAG_EDIT_BYTE("00000188") STATICTAG_EDIT_BYTE("00000189") STATICTAG_EDIT_BYTE("0000018a") STATICTAG_EDIT_BYTE("0000018b") STATICTAG_EDIT_BYTE("0000018c") STATICTAG_EDIT_BYTE("0000018d") STATICTAG_EDIT_BYTE("0000018e") STATICTAG_EDIT_BYTE("0000018f")}, {"", STATICTAG_EDIT_BYTE("00000190") STATICTAG_EDIT_BYTE("00000191") STATICTAG_EDIT_BYTE("00000192") STATICTAG_EDIT_BYTE("00000193") STATICTAG_EDIT_BYTE("00000194") STATICTAG_EDIT_BYTE("00000195") STATICTAG_EDIT_BYTE("00000196") STATICTAG_EDIT_BYTE("00000197") STATICTAG_EDIT_BYTE("00000198") STATICTAG_EDIT_BYTE("00000199") STATICTAG_EDIT_BYTE("0000019a") STATICTAG_EDIT_BYTE("0000019b") STATICTAG_EDIT_BYTE("0000019c") STATICTAG_EDIT_BYTE("0000019d") STATICTAG_EDIT_BYTE("0000019e") STATICTAG_EDIT_BYTE("0000019")}, {"", STATICTAG_EDIT_BYTE("000001a0") STATICTAG_EDIT_BYTE("000001a1") STATICTAG_EDIT_BYTE("000001a2") STATICTAG_EDIT_BYTE("000001a3") STATICTAG_EDIT_BYTE("000001a4") STATICTAG_EDIT_BYTE("000001a5") STATICTAG_EDIT_BYTE("000001a6") STATICTAG_EDIT_BYTE("000001a7") STATICTAG_EDIT_BYTE("000001a8") STATICTAG_EDIT_BYTE("000001a9") STATICTAG_EDIT_BYTE("000001aa") STATICTAG_EDIT_BYTE("000001ab") STATICTAG_EDIT_BYTE("000001ac") STATICTAG_EDIT_BYTE("000001ad") STATICTAG_EDIT_BYTE("000001ae") STATICTAG_EDIT_BYTE("000001af")}, {"", STATICTAG_EDIT_BYTE("000001b0") STATICTAG_EDIT_BYTE("000001b1") STATICTAG_EDIT_BYTE("000001b2") STATICTAG_EDIT_BYTE("000001b3") STATICTAG_EDIT_BYTE("000001b4") STATICTAG_EDIT_BYTE("000001b5") STATICTAG_EDIT_BYTE("000001b6") STATICTAG_EDIT_BYTE("000001b7") STATICTAG_EDIT_BYTE("000001b8") STATICTAG_EDIT_BYTE("000001b9") STATICTAG_EDIT_BYTE("000001ba") STATICTAG_EDIT_BYTE("000001bb") STATICTAG_EDIT_BYTE("000001bc") STATICTAG_EDIT_BYTE("000001bd") STATICTAG_EDIT_BYTE("000001be") STATICTAG_EDIT_BYTE("000001bf")}, {"", STATICTAG_EDIT_BYTE("000001c0") STATICTAG_EDIT_BYTE("000001c1") STATICTAG_EDIT_BYTE("000001c2") STATICTAG_EDIT_BYTE("000001c3") STATICTAG_EDIT_BYTE("000001c4") STATICTAG_EDIT_BYTE("000001c5") STATICTAG_EDIT_BYTE("000001c6") STATICTAG_EDIT_BYTE("000001c7") STATICTAG_EDIT_BYTE("000001c8") STATICTAG_EDIT_BYTE("000001c9") STATICTAG_EDIT_BYTE("000001ca") STATICTAG_EDIT_BYTE("000001cb") STATICTAG_EDIT_BYTE("000001cc") STATICTAG_EDIT_BYTE("000001cd") STATICTAG_EDIT_BYTE("000001ce") STATICTAG_EDIT_BYTE("000001cf")}, {0, 0} }; static ht_tag_flags_s xbe_section_flags[] = { {-1, "XBE - section flags"}, {0, "[00] Writeable"}, {1, "[01] Preload"}, {2, "[02] Executable"}, {3, "[03] Inserted File"}, {4, "[04] Head Page Read Only"}, {5, "[05] Tail Page Read Only"}, {0, 0} }; static ht_mask_ptable xbesectionheader[] = { {"section flags", STATICTAG_EDIT_DWORD_LE("00000000")" "STATICTAG_FLAGS("00000000", ATOM_XBE_SECTION_FLAGS_STR)}, {"virtual address", STATICTAG_EDIT_DWORD_LE("00000004")}, {"virtual size", STATICTAG_EDIT_DWORD_LE("00000008")}, {"raw address", STATICTAG_EDIT_DWORD_LE("0000000c")}, {"raw size", STATICTAG_EDIT_DWORD_LE("00000010")}, {"section name address", STATICTAG_EDIT_DWORD_LE("00000014")}, {"section name reference counter", STATICTAG_EDIT_DWORD_LE("00000018")}, {"head shared page reference counter address", STATICTAG_EDIT_DWORD_LE("0000001c")}, {"tail shared page reference counter address", STATICTAG_EDIT_DWORD_LE("00000020")}, {0, 0} }; static ht_tag_flags_s xbe_library_flags[] = { {-1, "XBE - library flags"}, {15, "[15] Debug Build"}, {0, 0} }; static ht_mask_ptable xbelibraryversion[] = { {"library name", STATICTAG_EDIT_CHAR("00000000")STATICTAG_EDIT_CHAR("00000001")STATICTAG_EDIT_CHAR("00000002")STATICTAG_EDIT_CHAR("00000003")STATICTAG_EDIT_CHAR("00000004")STATICTAG_EDIT_CHAR("00000005")STATICTAG_EDIT_CHAR("00000006")STATICTAG_EDIT_CHAR("00000007")}, {"major version", STATICTAG_EDIT_WORD_LE("00000008")}, {"minor version", STATICTAG_EDIT_WORD_LE("0000000a")}, {"build version", STATICTAG_EDIT_WORD_LE("0000000c")}, {"library flags", STATICTAG_EDIT_WORD_LE("0000000e")" "STATICTAG_FLAGS("0000000a", ATOM_XBE_LIBRARY_FLAGS_STR)}, {0, 0} }; static ht_view *htxbeheader_init(Bounds *b, File *file, ht_format_group *group) { ht_xbe_shared_data *xbe_shared=(ht_xbe_shared_data *)group->get_shared_data(); ht_xbe_header_viewer *v = new ht_xbe_header_viewer(); v->init(b, DESC_XBE_HEADER, VC_EDIT | VC_SEARCH, file, group); registerAtom(ATOM_XBE_INIT_FLAGS, xbe_init_flags); registerAtom(ATOM_XBE_SECTION_FLAGS, xbe_section_flags); registerAtom(ATOM_XBE_MEDIA_FLAGS, xbe_media_flags); registerAtom(ATOM_XBE_REGION, xbe_region_codes); registerAtom(ATOM_XBE_LIBRARY_FLAGS, xbe_library_flags); ht_mask_sub *s; ht_collapsable_sub *cs; s = new ht_mask_sub(); s->init(file, 0); char info[128]; ht_snprintf(info, sizeof info, "* XBE header"); s->add_mask(info); v->insertsub(s); /* FIXME: */ bool xbe_bigendian = false; s = new ht_mask_sub(); s->init(file, 1); s->add_staticmask_ptable(xbemagic, 0x0, xbe_bigendian); /* image header */ s->add_staticmask_ptable(xbeimageheader, 0x0, xbe_bigendian); cs = new ht_collapsable_sub(); cs->init(file, s, 1, "image header", 1); v->insertsub(cs); /* image header */ s = new ht_mask_sub(); s->init(file, 2); s->add_staticmask_ptable(xbecertificate, xbe_shared->header.certificate_address-xbe_shared->header.base_address, xbe_bigendian); cs = new ht_collapsable_sub(); cs->init(file, s, 1, "certificate", 1); v->insertsub(cs); /* library versions */ for (uint i=0; i < xbe_shared->header.number_of_library_versions; i++) { s = new ht_mask_sub(); s->init(file, 50+i); s->add_staticmask_ptable(xbelibraryversion, xbe_shared->header.library_versions_address-xbe_shared->header.base_address+i*sizeof *xbe_shared->libraries, xbe_bigendian); char t[256]; ht_snprintf(t, sizeof t, "library %d: %-9s %d.%d.%d", i, &xbe_shared->libraries[i].library_name, xbe_shared->libraries[i].major_version, xbe_shared->libraries[i].minor_version, xbe_shared->libraries[i].build_version); cs=new ht_collapsable_sub(); cs->init(file, s, 1, t, 1); v->insertsub(cs); } /* section headers */ for (uint i=0; isections.number_of_sections; i++) { const char *name; // uint ofs; s=new ht_mask_sub(); s->init(file, 100+i); s->add_staticmask_ptable(xbesectionheader, xbe_shared->header.section_header_address-xbe_shared->header.base_address+i*sizeof *xbe_shared->sections.sections, xbe_bigendian); if (xbe_shared->sections.sections[i].section_name_address) { name = (char *)xbe_shared->sections.sections[i].section_name_address; } else { name = ""; } char t[256]; ht_snprintf(t, sizeof t, "section header %d: %s - rva %08x vsize %08x", i, name, xbe_shared->sections.sections[i].virtual_address, xbe_shared->sections.sections[i].virtual_size); cs=new ht_collapsable_sub(); cs->init(file, s, 1, t, 1); v->insertsub(cs); } return v; } format_viewer_if htxbeheader_if = { htxbeheader_init, 0 }; /* * CLASS ht_pe_header_viewer */ void ht_xbe_header_viewer::init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *group) { ht_uformat_viewer::init(b, desc, caps, file, group); VIEW_DEBUG_NAME("ht_xbe_header_viewer"); } /* static ht_format_viewer *find_hex_viewer(ht_group *group) { // FIXME: God forgive us... ht_group *vr_group=group; while (strcmp(vr_group->desc, VIEWERGROUP_NAME)) vr_group=vr_group->group; ht_view *c=vr_group->getfirstchild(); while (c) { if (c->desc && (strcmp(c->desc, DESC_HEX)==0)) { return (ht_format_viewer*)c; } c=c->next; } return NULL; } */ bool ht_xbe_header_viewer::ref_sel(LINE_ID *id) { return true; } ht-2.0.22/htapp.h0000644000175000001440000002045211245514241010414 00000000000000/* * HT Editor * htapp.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTAPP_H__ #define __HTAPP_H__ #include "htctrl.h" #include "htdialog.h" #include "htformat.h" // file open modes #define FOM_AUTO 0 #define FOM_BIN 1 #define FOM_TEXT 2 // #define VIEWERGROUP_NAME "viewergroup" /* * CLASS ht_status */ #define STATUS_DEFAULT_FORMAT "%a %L %t %d" #define STATUS_ESCAPE '%' #define STATUS_ANALY_ACTIVE 'a' #define STATUS_ANALY_LINES 'L' #define STATUS_TIME 't' #define STATUS_DATE 'd' #define STATUS_WORKBUFLEN 80 /* * CLASS ht_status */ class ht_status: public ht_view { protected: int idle_count; char *format; char workbuf[STATUS_WORKBUFLEN]; int clear_len; int analy_ani; public: void init(Bounds *b); virtual void done(); virtual void draw(); virtual void handlemsg(htmsg *msg); virtual bool idle(); virtual void getminbounds(int *width, int *height); private: void render(); virtual const char *defaultpalette(); }; /* * CLASS ht_keyline */ class ht_keyline: public ht_view { public: void init(Bounds *b); virtual void done(); /* overwritten */ virtual void draw(); virtual const char *defaultpalette(); virtual void getminbounds(int *width, int *height); }; /* * CLASS ht_desktop */ class ht_desktop: public ht_view { public: void init(Bounds *b); /* overwritten */ virtual void draw(); virtual const char *defaultpalette(); }; /* * CLASS ht_logviewer */ class ht_log_msg: public Object { public: vcp color; char *msg; ht_log_msg(vcp Color, char *Msg); ~ht_log_msg(); }; typedef unsigned int LogColor; class ht_log: public Array { protected: uint maxlinecount; void deletefirstline(); void insertline(LogColor c, char *line); public: ht_log(); /* new */ void log(LogColor c, char *line); }; class ht_logviewer: public ht_viewer { private: ht_log *lines; bool own_lines; int ofs, xofs; ht_window *window; /* new */ int cursor_up(int n); int cursor_down(int n); bool get_vscrollbar_pos(int *pstart, int *psize); void update(); public: void init(Bounds *b, ht_window *window, ht_log *log, bool own_log); virtual void done(); /* overwritten */ virtual void draw(); virtual void handlemsg(htmsg *msg); }; /* * CLASS ht_vstate_history_entry */ class ht_vstate_history_entry: public Object { public: Object *data; ht_view *view; ht_vstate_history_entry(Object *data, ht_view *view); ~ht_vstate_history_entry(); }; /* * CLASS ht_file_window */ class ht_file_window: public ht_window { protected: Array vstate_history; int vstate_history_pos; void add_vstate_history(ht_vstate_history_entry *e); public: File *file; ht_file_window(); void init(Bounds *b, const char *desc, uint framestyle, uint number, File *file); virtual void done(); /* overwritten */ virtual void handlemsg(htmsg *msg); }; /* * CLASS ht_project */ class ht_project: public AVLTree { protected: char *filename; public: explicit ht_project(const char *filename); ht_project(BuildCtorArg &a): AVLTree(a) {}; virtual ~ht_project(); /* overwritten */ virtual void load(ObjectStream &s); virtual ObjectID getObjectID() const; virtual void store(ObjectStream &s) const; /* new */ const char *get_filename(); }; /* * CLASS ht_project_item */ class ht_project_item: public Object { protected: char *filename; char *path; public: ht_project_item(const char *filename, const char *path); ht_project_item(BuildCtorArg &a): Object(a) {}; virtual ~ht_project_item(); /* overwritten */ virtual void load(ObjectStream &s); virtual ObjectID getObjectID() const; virtual void store(ObjectStream &s) const; virtual int compareTo(const Object *) const; /* new */ const char *get_filename() const; const char *get_path() const; }; /* * CLASS ht_project_listbox */ class ht_project_listbox: public ht_listbox { protected: ht_project *project; uint colwidths[4]; public: void init(Bounds *b, ht_project *project); virtual int calcCount(); virtual void draw(); virtual void * getFirst(); virtual void * getLast(); virtual void * getNext(void *entry); virtual void * getPrev(void *entry); virtual const char *getStr(int col, void *entry); virtual void handlemsg(htmsg *msg); virtual int numColumns(); virtual void * quickfind(const char *s); virtual char * quickfindCompletition(const char *s); virtual bool selectEntry(void *entry); /* new */ const char *func(uint i, bool execute); void set_project(ht_project *project); }; /* * CLASS ht_project_window */ class ht_project_window: public ht_window { protected: ht_project **project; ht_project_listbox *plb; char wtitle[128]; public: void init(Bounds *b, const char *desc, uint framestyle, uint number, ht_project **project); virtual void done(); /* overwritten */ virtual void handlemsg(htmsg *msg); }; /* * CLASS ht_app_window_entry */ #define AWT_LOG 0 #define AWT_CLIPBOARD 1 #define AWT_HELP 2 #define AWT_FILE 3 #define AWT_OFM 4 #define AWT_PROJECT 5 #define AWT_TERM 6 class ht_app_window_entry: public Object { public: uint type; ht_window *window; bool minimized; uint number; bool isfile; FileLayer *layer; ht_app_window_entry(ht_window *window, uint number, uint type, bool minimized, bool isfile, FileLayer *layer); virtual int compareTo(const Object *) const; }; /* * CLASS ht_app */ class ht_app: public ht_dialog { protected: Container *windows; Container *syntax_lexers; ht_keyline *keyline; ht_desktop *desktop; ht_group *battlefield; bool exit_program; /* new */ ht_window *create_window_file_bin(Bounds *b, FileLayer *file, const char *title, bool isfile); ht_window *create_window_file_text(Bounds *b, FileLayer *file, const char *title, bool isfile); bool accept_close_all_windows(); uint find_free_window_number(); uint get_window_number(ht_window *window); ObjHandle get_window_listindex(ht_window *window); void get_stdbounds_file(Bounds *b); void get_stdbounds_tool(Bounds *b); int popup_view_list_dump(ht_view *view, ht_text_listbox *listbox, List *structure, int depth, int *currenti, ht_view *currentv); /* overwritten */ virtual const char *defaultpalette(); virtual const char *defaultpaletteclass(); public: ht_view *menu; ht_app() {}; ht_app(BuildCtorArg &a): ht_dialog(a) {}; void insert_window(ht_window *window, uint type, bool minimized, bool isfile, FileLayer *layer); void init(Bounds *b); virtual void done(); /* overwritten */ virtual void draw(); virtual bool focus(ht_view *view); virtual const char *func(uint i, bool execute); virtual void handlemsg(htmsg *msg); virtual void load(ObjectStream &f); virtual ObjectID getObjectID() const; virtual int run(bool modal); virtual void store(ObjectStream &f) const; /* new */ ht_window *create_window_clipboard(); ht_window *create_window_file(const char *filename, uint mode, bool allow_duplicates); ht_window *create_window_file_bin(const char *filename, bool allow_duplicates); ht_window *create_window_file_text(const char *filename, bool allow_duplicates); ht_window *create_window_help(const char *file, const char *node); ht_window *create_window_log(); ht_window *create_window_ofm(const char *url1, const char *url2); ht_window *create_window_project(); ht_window *create_window_term(const char *cmd); void delete_window(ht_window *window); ht_window *get_window_by_filename(const char *filename); ht_window *get_window_by_number(uint number); ht_window *get_window_by_type(uint type); ht_view *popup_view_list(const char *dialog_title); ht_window *popup_window_list(const char *dialog_title); void project_opencreate(const char *filename); void tile(bool vertical); void modal_resize(); }; extern ht_log *loglines; /* * INIT */ bool init_app(); /* * DONE */ void done_app(); #endif /* __HTAPP_H__ */ ht-2.0.22/formats.h0000644000175000001440000000201010615341616010745 00000000000000/* * HT Editor * formats.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __FORMATS_H__ #define __FORMATS_H__ struct format_viewer_if; #include "stream.h" #include "htformat.h" struct format_viewer_if { ht_view *(*init)(Bounds *b, File *file, ht_format_group *group); void (*done)(ht_view *view); }; extern format_viewer_if *format_viewer_ifs[]; #endif /* !__FORMATS_H__ */ ht-2.0.22/vxd.h0000644000175000001440000000206210615341625010102 00000000000000/* * HT Editor * vxd.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __VXD_H_ #define __VXD_H_ struct vxd_service_desc { int key; const char *name; }; struct vxd_t { const char *name; vxd_service_desc *services; }; struct vxd_desc { int key; vxd_t vxd; }; extern vxd_desc vxds[]; vxd_t *find_vxd(vxd_desc *table, int key); const char *find_vxd_service(vxd_service_desc *table, int key); #endif /* __VXD_H_ */ ht-2.0.22/htflt.cc0000644000175000001440000000503410615341616010562 00000000000000/* * HT Editor * htelf.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "log.h" #include "htflt.h" #include "htflthd.h" #include "htfltimg.h" #include "endianess.h" #include "stream.h" #include "tools.h" #include "fltstruc.h" #include static format_viewer_if *htflt_ifs[] = { &htfltheader_if, &htfltimage_if, 0 }; static ht_view *htflt_init(Bounds *b, File *file, ht_format_group *format_group) { byte ident[4]; file->seek(0); file->read(&ident, sizeof ident); if ((ident[0]!=FLTMAG0) || (ident[1]!=FLTMAG1) || (ident[2]!=FLTMAG2) || (ident[3]!=FLTMAG3) ) return 0; ht_flt *g=new ht_flt(); g->init(b, file, htflt_ifs, format_group, 0); return g; } format_viewer_if htflt_if = { htflt_init, 0 }; /* * CLASS ht_flt */ void ht_flt::init(Bounds *b, File *f, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs) { ht_format_group::init(b, VO_SELECTABLE | VO_BROWSABLE | VO_RESIZE, DESC_FLT, f, false, true, 0, format_group); VIEW_DEBUG_NAME("ht_flt"); String fn; file->getFilename(fn); LOG("%y: FLAT: found header at %08qx", &fn, header_ofs); ht_flt_shared_data *flt_shared = ht_malloc(sizeof (ht_flt_shared_data)); shared_data = flt_shared; flt_shared->header_ofs = header_ofs; /* read header */ file->seek(header_ofs); file->read(&flt_shared->header, sizeof flt_shared->header); createHostStruct(&flt_shared->header, FLAT_HEADER_struct, big_endian); flt_shared->code_start = sizeof flt_shared->header; flt_shared->code_end = flt_shared->header.data_start; flt_shared->data_start = flt_shared->header.data_start; flt_shared->data_end = flt_shared->header.data_end; flt_shared->bss_start = flt_shared->header.data_end; flt_shared->bss_end = flt_shared->header.bss_end; /* init ifs */ ht_format_group::init_ifs(ifs); } void ht_flt::done() { ht_format_group::done(); ht_flt_shared_data *flt_shared=(ht_flt_shared_data *)shared_data; free(flt_shared); } ht-2.0.22/htelf.cc0000644000175000017500000005354611724431703010561 00000000000000/* * HT Editor * htelf.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "elfstruc.h" #include "log.h" #include "htelf.h" #include "htelfhd.h" #include "htelfshs.h" #include "htelfphs.h" #include "htelfsym.h" #include "htelfrel.h" #include "htelfimg.h" #include "endianess.h" #include "except.h" #include "htiobox.h" #include "stream.h" #include "tools.h" #include "elfstruc.h" #include static format_viewer_if *htelf_ifs[] = { &htelfheader_if, &htelfsectionheaders_if, &htelfprogramheaders_if, &htelfimage_if, 0 }; static ht_view *htelf_init(Bounds *b, File *file, ht_format_group *format_group) { FileOfs header_ofs = 0; ELF_HEADER header; // read header try { file->seek(header_ofs); file->readx(&header, sizeof header); } catch (...) { return NULL; } // check for magic if ((header.e_ident[ELF_EI_MAG0]!=ELFMAG0) || (header.e_ident[ELF_EI_MAG1]!=ELFMAG1) || (header.e_ident[ELF_EI_MAG2]!=ELFMAG2) || (header.e_ident[ELF_EI_MAG3]!=ELFMAG3)) return NULL; switch (header.e_ident[ELF_EI_DATA]) { case ELFDATA2LSB: case ELFDATA2MSB: break; default: LOG_EX(LOG_WARN, "File seems to be ELF. But byte-order" " (ELF_EI_DATA) 0x%02x is unsupported. (byte at offset=0x%qx)", header.e_ident[ELF_EI_DATA], header_ofs+5); return NULL; } switch (header.e_ident[ELF_EI_CLASS]) { case ELFCLASS32: case ELFCLASS64: break; default: LOG_EX(LOG_WARN, "File seems to be ELF. But class-value" " (ELF_EI_CLASS) 0x%02x is unsupported. (byte at offset=0x%qx)", header.e_ident[ELF_EI_CLASS], header_ofs+4); return NULL; } try { ht_elf *g = new ht_elf(); g->init(b, file, htelf_ifs, format_group, header_ofs); return g; } catch (const Exception &x) { errorbox("error while reading ELF: %y", &x); return NULL; } } format_viewer_if htelf_if = { htelf_init, 0 }; /**/ int FakeAddr::compareTo(const Object *keyb) const { FakeAddr *b = (FakeAddr*)keyb; if (secidx == b->secidx) return symidx - b->symidx; return secidx - b->secidx; } bool isValidELFSectionIdx(ht_elf_shared_data *elf_shared, int idx) { return idx > 0 && (uint)idx < elf_shared->sheaders.count; } /* * CLASS ht_elf */ void ht_elf::init(Bounds *b, File *f, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs) { ht_format_group::init(b, VO_SELECTABLE | VO_BROWSABLE | VO_RESIZE, DESC_ELF, f, false, true, 0, format_group); VIEW_DEBUG_NAME("ht_elf"); String fn; LOG("%y: ELF: found header at 0x%08qx", &file->getFilename(fn), header_ofs); ht_elf_shared_data *elf_shared = ht_malloc(sizeof(ht_elf_shared_data)); shared_data = elf_shared; elf_shared->header_ofs = header_ofs; elf_shared->shnames = NULL; elf_shared->symtables = 0; elf_shared->reloctables = 0; elf_shared->v_image = NULL; elf_shared->shrelocs = NULL; elf_shared->fake_undefined_shidx = 0; elf_shared->undefined2fakeaddr = NULL; /* read header */ file->seek(header_ofs); file->readx(&elf_shared->ident, sizeof elf_shared->ident); switch (elf_shared->ident.e_ident[ELF_EI_DATA]) { case ELFDATA2LSB: elf_shared->byte_order = little_endian; break; case ELFDATA2MSB: elf_shared->byte_order = big_endian; break; } switch (elf_shared->ident.e_ident[ELF_EI_CLASS]) { case ELFCLASS32: { file->readx(&elf_shared->header32, sizeof elf_shared->header32); createHostStruct(&elf_shared->header32, ELF_HEADER32_struct, elf_shared->byte_order); /* read section headers */ elf_shared->sheaders.count = elf_shared->header32.e_shnum; if (!elf_shared->sheaders.count) { elf_shared->sheaders.sheaders32 = NULL; } else { elf_shared->sheaders.sheaders32 = ht_malloc(elf_shared->sheaders.count * sizeof *elf_shared->sheaders.sheaders32); file->seek(header_ofs + elf_shared->header32.e_shoff); file->readx(elf_shared->sheaders.sheaders32, elf_shared->sheaders.count*sizeof *elf_shared->sheaders.sheaders32); for (uint i=0; i < elf_shared->sheaders.count; i++) { ELF_SECTION_HEADER32 a = elf_shared->sheaders.sheaders32[i]; createHostStruct(elf_shared->sheaders.sheaders32+i, ELF_SECTION_HEADER32_struct, elf_shared->byte_order); } } /* read program headers */ elf_shared->pheaders.count = elf_shared->header32.e_phnum; // if (!elf_shared->pheaders.count) throw MsgException("Zero count in program section headers"); if (!elf_shared->pheaders.count) { elf_shared->pheaders.pheaders32 = NULL; } else { elf_shared->pheaders.pheaders32 = ht_malloc(elf_shared->pheaders.count*sizeof *elf_shared->pheaders.pheaders32); file->seek(header_ofs + elf_shared->header32.e_phoff); file->readx(elf_shared->pheaders.pheaders32, elf_shared->pheaders.count*sizeof *elf_shared->pheaders.pheaders32); for (uint i=0; i < elf_shared->pheaders.count; i++) { createHostStruct(elf_shared->pheaders.pheaders32+i, ELF_PROGRAM_HEADER32_struct, elf_shared->byte_order); } // if file is relocatable, relocate it if (elf_shared->header32.e_type == ELF_ET_REL) { /* create a fake section for undefined symbols */ try { fake_undefined_symbols32(); } catch (const Exception &x) { errorbox("error while faking undefined ELF symbols: %y", &x); } /* create streamfile layer for relocations */ try { auto_relocate32(); } catch (const Exception &x) { errorbox("error while auto-relocating ELF symbols: %y", &x); } } } break; } case ELFCLASS64: { file->readx(&elf_shared->header64, sizeof elf_shared->header64); createHostStruct(&elf_shared->header64, ELF_HEADER64_struct, elf_shared->byte_order); /* read section headers */ elf_shared->sheaders.count=elf_shared->header64.e_shnum; if (!elf_shared->sheaders.count) throw MsgException("Zero count for section headers"); elf_shared->sheaders.sheaders64 = ht_malloc(elf_shared->sheaders.count*sizeof *elf_shared->sheaders.sheaders64); file->seek(header_ofs + elf_shared->header64.e_shoff); file->readx(elf_shared->sheaders.sheaders64, elf_shared->sheaders.count*sizeof *elf_shared->sheaders.sheaders64); for (uint i=0; i < elf_shared->sheaders.count; i++) { ELF_SECTION_HEADER64 a = elf_shared->sheaders.sheaders64[i]; createHostStruct(elf_shared->sheaders.sheaders64+i, ELF_SECTION_HEADER64_struct, elf_shared->byte_order); } /* read program headers */ elf_shared->pheaders.count = elf_shared->header64.e_phnum; // if (!elf_shared->pheaders.count) throw MsgException("Zero count in program section headers"); if (!elf_shared->pheaders.count) { elf_shared->pheaders.pheaders64 = NULL; } else { elf_shared->pheaders.pheaders64 = ht_malloc(elf_shared->pheaders.count*sizeof *elf_shared->pheaders.pheaders64); /* FIXME: 64-bit */ file->seek(header_ofs + elf_shared->header64.e_phoff); file->readx(elf_shared->pheaders.pheaders64, elf_shared->pheaders.count*sizeof *elf_shared->pheaders.pheaders64); for (uint i=0; ipheaders.count; i++) { createHostStruct(elf_shared->pheaders.pheaders64+i, ELF_PROGRAM_HEADER64_struct, elf_shared->byte_order); } /* create a fake section for undefined symbols */ //fake_undefined_symbols(); /* create streamfile layer for relocations */ //auto_relocate(); } break; } } /* init ifs */ ht_format_group::init_ifs(ifs); while (init_if(&htelfsymboltable_if)) elf_shared->symtables++; while (init_if(&htelfreloctable_if)) elf_shared->reloctables++; } void ht_elf::done() { ht_format_group::done(); ht_elf_shared_data *elf_shared=(ht_elf_shared_data *)shared_data; if (elf_shared->shnames) { for (uint i=0; i < elf_shared->sheaders.count; i++) free(elf_shared->shnames[i]); free(elf_shared->shnames); } free(elf_shared->shrelocs); switch (elf_shared->ident.e_ident[ELF_EI_CLASS]) { case ELFCLASS32: free(elf_shared->sheaders.sheaders32); free(elf_shared->pheaders.pheaders32); break; case ELFCLASS64: free(elf_shared->sheaders.sheaders64); free(elf_shared->pheaders.pheaders64); break; } delete elf_shared->undefined2fakeaddr; free(elf_shared); } uint ht_elf::find_reloc_section_for(uint si) { ht_elf_shared_data *elf_shared=(ht_elf_shared_data *)shared_data; ELF_SECTION_HEADER32 *s=elf_shared->sheaders.sheaders32; for (uint i=0; i < elf_shared->sheaders.count; i++) { if ((s->sh_type == ELF_SHT_REL || s->sh_type == ELF_SHT_RELA) && s->sh_info == si) { return i; } s++; } return 0; } #define INVENT_BASE 0x100000 #define INVENT_STEPPING 0x100000 #define INVENT_LIMIT 0xffffffff static elf32_addr elf32_invent_address(uint si, ELF_SECTION_HEADER32 *s, uint scount, elf32_addr base = INVENT_BASE) { elf32_addr a = base; assert(s[si].sh_addr == 0); while (a < INVENT_LIMIT - s[si].sh_size) { bool ok = true; for (uint i=0; i < scount; i++) { if (a >= s[i].sh_addr && a < s[i].sh_addr+s[i].sh_size) { ok = false; break; } } if (ok) return a; a += INVENT_STEPPING; } return 0; } void ht_elf::relocate_section(ht_reloc_file *f, uint si, uint rsi, elf32_addr a) { // relocate section si (using section rsi) to address a ht_elf_shared_data *elf_shared=(ht_elf_shared_data *)shared_data; ELF_SECTION_HEADER32 *s=elf_shared->sheaders.sheaders32; FileOfs relh = s[rsi].sh_offset; uint symtabidx = s[rsi].sh_link; if (!isValidELFSectionIdx(elf_shared, symtabidx)) throw MsgfException("invalid symbol table index %d", symtabidx); FileOfs symh = elf_shared->sheaders.sheaders32[symtabidx].sh_offset; if (s[rsi].sh_type != ELF_SHT_REL) throw MsgfException( "invalid section type for section %d (expecting %d)", rsi, ELF_SHT_REL); uint relnum = s[rsi].sh_size / sizeof (ELF_REL32); for (uint i=0; i < relnum; i++) { // read ELF_REL32 ELF_REL32 r; file->seek(relh + i * sizeof r); file->readx(&r, sizeof r); createHostStruct(&r, ELF_REL32_struct, elf_shared->byte_order); // read ELF_SYMBOL32 uint symbolidx = ELF32_R_SYM(r.r_info); ELF_SYMBOL32 sym; file->seek(symh+symbolidx*sizeof (ELF_SYMBOL32)); file->read(&sym, sizeof sym); createHostStruct(&sym, ELF_SYMBOL32_struct, elf_shared->byte_order); // calc reloc vals uint32 A = 0; uint32 P = r.r_offset+s[si].sh_addr; uint32 S; if ((sym.st_shndx > 0) && (sym.st_shndx < elf_shared->sheaders.count)) { S = sym.st_value + elf_shared->shrelocs[sym.st_shndx].relocAddr; } else if (elf_shared->fake_undefined_shidx >= 0) { FakeAddr s(symtabidx, symbolidx, 0); FakeAddr *fa = (FakeAddr *) elf_shared->undefined2fakeaddr->get( elf_shared->undefined2fakeaddr->find(&s)); if (fa) { S = fa->addr; } else continue; } else { // skip this one // FIXME: nyi continue; } Object *z = new ht_elf32_reloc_entry(ELF32_R_TYPE(r.r_info), A, P, S); f->insert_reloc(r.r_offset+s[si].sh_offset, z); } } #define FAKE_SECTION_BASEADDR 0x4acc0000 /* "resolve" undefined references by creating fake section and fake addresses */ void ht_elf::fake_undefined_symbols32() { ht_elf_shared_data *elf_shared=(ht_elf_shared_data *)shared_data; // create a fake section elf_shared->fake_undefined_shidx = elf_shared->sheaders.count; elf_shared->sheaders.count++; elf_shared->sheaders.sheaders32 = (ELF_SECTION_HEADER32*) realloc(elf_shared->sheaders.sheaders32, sizeof (ELF_SECTION_HEADER32)* elf_shared->sheaders.count); ELF_SECTION_HEADER32 *s = elf_shared->sheaders.sheaders32; s[elf_shared->fake_undefined_shidx].sh_name = 0; s[elf_shared->fake_undefined_shidx].sh_type = ELF_SHT_NOBITS; s[elf_shared->fake_undefined_shidx].sh_flags = ELF_SHF_WRITE | ELF_SHF_ALLOC; s[elf_shared->fake_undefined_shidx].sh_addr = 0; s[elf_shared->fake_undefined_shidx].sh_offset = 0; s[elf_shared->fake_undefined_shidx].sh_size = 0; // filled in below s[elf_shared->fake_undefined_shidx].sh_link = 0; s[elf_shared->fake_undefined_shidx].sh_info = 0; s[elf_shared->fake_undefined_shidx].sh_addralign = 0; s[elf_shared->fake_undefined_shidx].sh_entsize = 0; elf32_addr a = elf32_invent_address(elf_shared->fake_undefined_shidx, s, elf_shared->sheaders.count, FAKE_SECTION_BASEADDR); s[elf_shared->fake_undefined_shidx].sh_addr = a; LOG("fake section %d", elf_shared->fake_undefined_shidx); // allocate fake addresses elf_shared->undefined2fakeaddr = new AVLTree(true); uint32 nextFakeAddr = FAKE_SECTION_BASEADDR; for (uint secidx = 0; secidx < elf_shared->sheaders.count; secidx++) { if (elf_shared->sheaders.sheaders32[secidx].sh_type == ELF_SHT_SYMTAB) { FileOfs symh = elf_shared->sheaders.sheaders32[secidx].sh_offset; uint symnum = elf_shared->sheaders.sheaders32[secidx].sh_size / sizeof (ELF_SYMBOL32); for (uint symidx = 1; symidx < symnum; symidx++) { ELF_SYMBOL32 sym; file->seek(symh+symidx*sizeof (ELF_SYMBOL32)); file->read(&sym, sizeof sym); createHostStruct(&sym, ELF_SYMBOL32_struct, elf_shared->byte_order); if (sym.st_shndx == ELF_SHN_UNDEF) { elf_shared->undefined2fakeaddr->insert( new FakeAddr(secidx, symidx, nextFakeAddr) ); nextFakeAddr += 4; } } } } elf_shared->fake_undefined_size = nextFakeAddr-FAKE_SECTION_BASEADDR; s[elf_shared->fake_undefined_shidx].sh_size = elf_shared->fake_undefined_size; } void ht_elf::auto_relocate32() { ht_elf32_reloc_file *rf = new ht_elf32_reloc_file(file, false, (ht_elf_shared_data*)shared_data); bool reloc_needed = false; ht_elf_shared_data *elf_shared=(ht_elf_shared_data *)shared_data; ELF_SECTION_HEADER32 *s=elf_shared->sheaders.sheaders32; if (!elf_shared->sheaders.count) { String fn; LOG("%y: ELF: segment header count is zero", &file->getFilename(fn)); } else { elf_shared->shrelocs = ht_malloc(elf_shared->sheaders.count * sizeof (ht_elf_reloc_section32)); } /* relocate sections */ for (uint i=0; i < elf_shared->sheaders.count; i++) { elf_shared->shrelocs[i].relocAddr = 0; if ((s[i].sh_type == ELF_SHT_PROGBITS) && (s[i].sh_addr == 0)) { uint j = find_reloc_section_for(i); if (j) { elf32_addr a = elf32_invent_address(i, s, elf_shared->sheaders.count); if (a) { reloc_needed = true; // update section header entry s[i].sh_addr = a; elf_shared->shrelocs[i].relocAddr = a; elf_shared->shrelocs[i].relocShIdx = j; } } } } /* apply relocations to section descriptors */ for (uint i=0; i < elf_shared->sheaders.count; i++) { if (elf_shared->shrelocs[i].relocAddr) { //LOG("section %d to %08x", i, elf_shared->shrelocs[i].relocAddr); try { relocate_section(rf, i, elf_shared->shrelocs[i].relocShIdx, elf_shared->shrelocs[i].relocAddr); } catch (const Exception &x) { LOG("error while relocating section %d: %y", i, &x); } } } if (reloc_needed) { rf->finalize(); own_file = true; file = rf; String fn; LOG("%y: ELF: relocation layer enabled (invented relocation addresses)", &file->getFilename(fn)); } else { free(elf_shared->shrelocs); elf_shared->shrelocs = NULL; delete rf; } } bool ht_elf::loc_enum_next(ht_format_loc *loc) { ht_elf_shared_data *sh = (ht_elf_shared_data*)shared_data; if (loc_enum) { loc->name = "elf"; loc->start = sh->header_ofs; loc->length = file->getSize() - loc->start; /* FIXME: ENOTOK */ loc_enum = false; return true; } return false; } void ht_elf::loc_enum_start() { loc_enum = true; } /* * address conversion routines */ bool elf_phys_and_mem_section(elf_section_header *sh, uint elfclass) { switch (elfclass) { case ELFCLASS32: { ELF_SECTION_HEADER32 *s = &sh->sheaders32; return s->sh_type == ELF_SHT_PROGBITS && s->sh_addr; } case ELFCLASS64: { ELF_SECTION_HEADER64 *s = &sh->sheaders64; return s->sh_type==ELF_SHT_PROGBITS && s->sh_addr; } } return false; } bool elf_valid_section(elf_section_header *sh, uint elfclass) { switch (elfclass) { case ELFCLASS32: { ELF_SECTION_HEADER32 *s = &sh->sheaders32; return (s->sh_type==ELF_SHT_PROGBITS || s->sh_type==ELF_SHT_NOBITS) && s->sh_addr; } case ELFCLASS64: { ELF_SECTION_HEADER64 *s = &sh->sheaders64; return (s->sh_type==ELF_SHT_PROGBITS || s->sh_type==ELF_SHT_NOBITS) && s->sh_addr; } } return false; } bool elf_addr_to_ofs(elf_section_headers *section_headers, uint elfclass, ELFAddress addr, FileOfs *ofs) { switch (elfclass) { case ELFCLASS32: { ELF_SECTION_HEADER32 *s = section_headers->sheaders32; for (uint i=0; i < section_headers->count; i++) { if ((elf_phys_and_mem_section((elf_section_header*)s, elfclass)) && (addr.a32 >= s->sh_addr) && (addr.a32 < s->sh_addr+s->sh_size)) { *ofs = addr.a32 - s->sh_addr + s->sh_offset; return true; } s++; } break; } case ELFCLASS64: { ELF_SECTION_HEADER64 *s = section_headers->sheaders64; for (uint i=0; i < section_headers->count; i++) { if ((elf_phys_and_mem_section((elf_section_header*)s, elfclass)) && addr.a64 >= s->sh_addr && (addr.a64 < s->sh_addr + s->sh_size)) { *ofs = addr.a64 - s->sh_addr + s->sh_offset; return true; } s++; } break; } } return false; } bool elf_addr_to_section(elf_section_headers *section_headers, uint elfclass, ELFAddress addr, int *section) { switch (elfclass) { case ELFCLASS32: { ELF_SECTION_HEADER32 *s = section_headers->sheaders32; for (uint i = 0; i < section_headers->count; i++) { if ((elf_valid_section((elf_section_header*)s, elfclass)) && (addr.a32 >= s->sh_addr) && (addr.a32 < s->sh_addr + s->sh_size)) { *section = i; return true; } s++; } break; } case ELFCLASS64: { ELF_SECTION_HEADER64 *s = section_headers->sheaders64; for (uint i = 0; i < section_headers->count; i++) { if ((elf_valid_section((elf_section_header*)s, elfclass)) && addr.a64 >= s->sh_addr && (addr.a64 < s->sh_addr + s->sh_size)) { *section = i; return true; } s++; } break; } } return false; } bool elf_addr_is_valid(elf_section_headers *section_headers, uint elfclass, ELFAddress addr) { switch (elfclass) { case ELFCLASS32: { ELF_SECTION_HEADER32 *s = section_headers->sheaders32; for (uint i=0; icount; i++) { if ((elf_valid_section((elf_section_header*)s, elfclass)) && (addr.a32 >= s->sh_addr) && (addr.a32 < s->sh_addr + s->sh_size)) { return true; } s++; } break; } case ELFCLASS64: { ELF_SECTION_HEADER64 *s = section_headers->sheaders64; for (uint i=0; icount; i++) { if ((elf_valid_section((elf_section_header*)s, elfclass)) && addr.a64 >= s->sh_addr && (addr.a64 < s->sh_addr + s->sh_size)) { return true; } s++; } break; } } return false; } bool elf_addr_is_physical(elf_section_headers *section_headers, uint elfclass, ELFAddress addr) { return false; } /* * offset conversion routines */ bool elf_ofs_to_addr(elf_section_headers *section_headers, uint elfclass, FileOfs ofs, ELFAddress *addr) { switch (elfclass) { case ELFCLASS32: { ELF_SECTION_HEADER32 *s = section_headers->sheaders32; for (uint i = 0; i < section_headers->count; i++) { if ((elf_phys_and_mem_section((elf_section_header*)s, elfclass)) && (ofs >= s->sh_offset) && (ofssh_offset+s->sh_size)) { addr->a32 = ofs - s->sh_offset + s->sh_addr; return true; } s++; } break; } case ELFCLASS64: { ELF_SECTION_HEADER64 *s = section_headers->sheaders64; uint64 qofs = ofs; for (uint i = 0; i < section_headers->count; i++) { if ((elf_phys_and_mem_section((elf_section_header*)s, elfclass)) && qofs >= s->sh_offset && (qofs < s->sh_offset + s->sh_size)) { addr->a64 = qofs - s->sh_offset + s->sh_addr; return true; } s++; } break; } } return false; } bool elf_ofs_to_section(elf_section_headers *section_headers, uint elfclass, uint32 ofs, int *section) { switch (elfclass) { case ELFCLASS32: { ELF_SECTION_HEADER32 *s=section_headers->sheaders32; for (uint i=0; icount; i++) { if ((elf_valid_section((elf_section_header*)s, elfclass)) && (ofs >= s->sh_offset) && (ofssh_offset+s->sh_size)) { *section = i; return true; } s++; } break; } case ELFCLASS64: { ELF_SECTION_HEADER64 *s = section_headers->sheaders64; uint64 qofs = ofs; for (uint i=0; i < section_headers->count; i++) { if ((elf_valid_section((elf_section_header*)s, elfclass)) && qofs >= s->sh_offset && (qofs < s->sh_offset + s->sh_size)) { *section = i; return true; } s++; } break; } } return false; } bool elf_ofs_to_addr_and_section(elf_section_headers *section_headers, uint elfclass, uint32 ofs, ELFAddress *addr, int *section) { return false; } /* * ht_elf32_reloc_entry */ //ht_elf32_reloc_entry::ht_elf32_reloc_entry(uint symtabidx, elf32_addr addr, uint t, uint symbolidx, elf32_addr addend, ht_elf_shared_data *data, File *file) ht_elf32_reloc_entry::ht_elf32_reloc_entry(uint t, uint32 A, uint32 P, uint32 S) { type = t; switch (type) { case ELF_R_386_32: relocs.r_32 = S+A; break; case ELF_R_386_PC32: relocs.r_pc32 = S+A-P; break; } } /* * ht_elf32_reloc_file */ ht_elf32_reloc_file::ht_elf32_reloc_file(File *s, bool os, ht_elf_shared_data *d) : ht_reloc_file(s, os), data(d) { } void ht_elf32_reloc_file::reloc_apply(Object *reloc, byte *buf) { ht_elf32_reloc_entry *e=(ht_elf32_reloc_entry*)reloc; switch (e->type) { case ELF_R_386_32: { uint32 v = createHostInt(buf, 4, data->byte_order); v += e->relocs.r_32; createForeignInt(buf, v, 4, data->byte_order); break; } case ELF_R_386_PC32: { uint32 v = createHostInt(buf, 4, data->byte_order); v += e->relocs.r_pc32; createForeignInt(buf, v, 4, data->byte_order); break; } } } bool ht_elf32_reloc_file::reloc_unapply(Object *reloc, byte *data) { return false; // ht_elf32_reloc_entry *e=(ht_elf32_reloc_entry*)reloc; } ht-2.0.22/tools/0000755000175000017500000000000012156433676010366 500000000000000ht-2.0.22/tools/Makefile.am0000644000175000017500000000026111724770100012323 00000000000000AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_PROGRAMS = bin2c bin2c_LDADD = bin2c_SOURCES = bin2c.c ht-2.0.22/tools/bin2c.c0000644000175000001440000000751510244710550011434 00000000000000/* * bin2c.c * * Copyright (C) 2001, 2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include // needed for dirent.h on Darwin #include /* for NAME_MAX */ #include #include #include #ifndef NAME_MAX #define NAME_MAX 255 #endif #define OPT_FORCE_HEX 1 int options = 0; #define ERROR(s...) { printf("error: " s); puts("\n"); exit(1); } static void char2cchar(char *buf, char c) { if ((!(options & OPT_FORCE_HEX)) && ((c>=32) && (c<='~'))) { if (c=='\'') { strcpy(buf, "'\\''"); } else if (c=='\\') { strcpy(buf, "'\\\\'"); } else { sprintf(buf, "'%c'", (unsigned char)c); } } else { sprintf(buf, "0x%02x", (unsigned char)c); } } #define BUFSIZE 1024 #define CHARS_PER_LINE 8 static void bin2c_table(int size, FILE *in, FILE *out) { char buf[BUFSIZE]; size_t s = sizeof buf; int i, j=0; char elem[16]; while ((s = fread(buf, 1, s, in))) { for (i = 0; i < s; i++) { int elemlen; if (i % CHARS_PER_LINE == 0) { fputs("\t", out); } char2cchar(elem, buf[i]); elemlen = strlen(elem); fputs(elem, out); if (j+1 < size) { int k; fputs(",", out); for (k=0; k<4-elemlen; k++) fputs(" ", out); if ((j+1) % CHARS_PER_LINE == 0) { fputs("\n", out); } } else { fputs("\n", out); } j++; } } } static void bin2c(char *name, int size, FILE *in, FILE *out, char *inname) { fprintf(out, "/* generated by bin2c from %s */\n\n", inname); fprintf(out, "char %s[%d] = {\n", name, size); bin2c_table(size, in, out); fputs("};\n", out); } static void bin2h(char *name, int size, FILE *out, char *outname) { char q[NAME_MAX]; int i, l; strcpy(q, outname); l=strlen(q); for (i=0; i='a') && (q[i]<='z')) { q[i]+='A'-'a'; } if (((q[i]<'A') || (q[i]>'Z')) && ((q[i]<'0') || (q[i]>'9'))) { q[i]='_'; } } fprintf(out, "#ifndef __%s\n", q); fprintf(out, "#define __%s\n\n", q); fputs("extern\n#ifdef __cplusplus\n\"C\"\n#endif\n", out); fprintf(out, "char %s[%d];\n", name, size); fprintf(out, "\n#endif /* __%s */\n", q); } static void syntax(char *name) { printf("syntax: %s [-Ndataname] infile c-outfile [h-outfile]\n", name); exit(1); } int main(int argc, char *argv[]) { int l; FILE *in=NULL, *out=NULL, *outh=NULL; char *inname, *outname, *outhname; char *name="bindata"; int x=1; char n[NAME_MAX]; if (argc > 1 && strncmp(argv[1], "-N", 2) == 0) { name = argv[1]+2; x++; } if (argc >= x + 1) { inname = argv[x]; } else { syntax(argv[0]); } in=fopen(inname, "rb"); if (!in) ERROR("can't open input file: %s", inname); if (argc >= x+2) { outname = argv[x+1]; if (argc >= x+3) { outhname = argv[x+2]; } else { int k = strlen(outname); strcpy(n, outname); if (k > 2 && strncmp(argv[x+1]+k-2, ".c", 2) == 0) { strcpy(n+k-2, ".h"); } else { strcpy(n+k, ".h"); } outhname = n; } outh = fopen(outhname, "wb"); if (!outh) ERROR("can't open .h output file: %s", outhname); } else { ERROR("no output file"); } out = fopen(outname, "wb"); if (!out) ERROR("can't open .c output file: %s", outname); fseek(in, 0, SEEK_END); l = ftell(in); fseek(in, 0, SEEK_SET); bin2c(name, l, in, out, inname); bin2h(name, l, outh, outhname); return 0; } ht-2.0.22/tools/Makefile.in0000644000175000017500000003042212127657374012355 00000000000000# Makefile.in generated by automake 1.10.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ noinst_PROGRAMS = bin2c$(EXEEXT) subdir = tools DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = PROGRAMS = $(noinst_PROGRAMS) am_bin2c_OBJECTS = bin2c.$(OBJEXT) bin2c_OBJECTS = $(am_bin2c_OBJECTS) bin2c_DEPENDENCIES = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(bin2c_SOURCES) DIST_SOURCES = $(bin2c_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ HT_LDFLAGS = @HT_LDFLAGS@ HT_LIBS = @HT_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IO_DIR = @IO_DIR@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ LZO_LIBS = @LZO_LIBS@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ curses_CPPFLAGS = @curses_CPPFLAGS@ curses_LIBS = @curses_LIBS@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ ncurses_config = @ncurses_config@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} bin2c_LDADD = bin2c_SOURCES = bin2c.c all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tools/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign tools/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstPROGRAMS: -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) bin2c$(EXEEXT): $(bin2c_OBJECTS) $(bin2c_DEPENDENCIES) @rm -f bin2c$(EXEEXT) $(LINK) $(bin2c_OBJECTS) $(bin2c_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bin2c.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-noinstPROGRAMS mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-noinstPROGRAMS ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ht-2.0.22/htleent.cc0000644000175000001440000000677110620177260011113 00000000000000/* * HT Editor * htleent.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "atom.h" #include "htnewexe.h" #include "htle.h" #include "htlehead.h" #include "httag.h" #include "formats.h" #include "snprintf.h" #include "lestruct.h" /* entry bundle */ static ht_tag_flags_s le_entry_bundle_flags[] = { {-1, "LE - entrypoint bundle flags"}, {0, "[00] valid"}, {1, "[01] 32bit (16bit otherwise)"}, {0, 0} }; static ht_mask_ptable le_entry_bundle_header[]= { {"number of entries", STATICTAG_EDIT_BYTE("00000000")}, {"bundle flags", STATICTAG_EDIT_BYTE("00000001")" "STATICTAG_FLAGS("00000001", ATOM_LE_ENTRY_BUNDLE_FLAGS_STR)}, {"object index", STATICTAG_EDIT_WORD_LE("00000002")}, {0,0} }; /* entry */ static ht_tag_flags_s le_entry_flags[] = { {-1, "LE - entrypoint flags"}, {0, "[00] exported"}, {1, "[01] uses shared segment"}, {0, 0} }; static ht_mask_ptable le_entry16[]= { {"flags", STATICTAG_EDIT_BYTE("00000000")" "STATICTAG_FLAGS("00000000", ATOM_LE_ENTRY_FLAGS_STR)}, {"offset", STATICTAG_EDIT_WORD_LE("00000001")}, {0, 0} }; static ht_mask_ptable le_entry32[]= { {"flags", STATICTAG_EDIT_BYTE("00000000")" "STATICTAG_FLAGS("00000000", ATOM_LE_ENTRY_FLAGS_STR)}, {"offset", STATICTAG_EDIT_DWORD_LE("00000001")}, {0, 0} }; static ht_view *htleentrypoints_init(Bounds *b, File *file, ht_format_group *group) { ht_le_shared_data *le_shared=(ht_le_shared_data *)group->get_shared_data(); int h=le_shared->hdr_ofs; ht_uformat_viewer *v=new ht_uformat_viewer(); v->init(b, DESC_LE_ENTRYPOINTS, VC_EDIT | VC_SEARCH, file, group); ht_mask_sub *m=new ht_mask_sub(); m->init(file, 0); registerAtom(ATOM_LE_ENTRY_FLAGS, le_entry_flags); registerAtom(ATOM_LE_ENTRY_BUNDLE_FLAGS, le_entry_bundle_flags); char info[128]; ht_snprintf(info, sizeof info, "* LE entry header at offset 0x%08qx", h+le_shared->hdr.enttab); /* FIXME: false */ bool le_bigendian = false; m->add_mask(info); m->add_staticmask_ptable(le_entry_bundle_header, h+le_shared->hdr.enttab, le_bigendian); v->insertsub(m); FileOfs o=h+le_shared->hdr.enttab; while (1) { char t[32]; LE_ENTRYPOINT_BUNDLE hdr; hdr.entry_count=0; file->seek(o); o+=file->read(&hdr, sizeof hdr); if (!hdr.entry_count) break; const char *flags_str; if (hdr.flags & LE_ENTRYPOINT_BUNDLE_32BIT) { flags_str="32-bit"; } else { flags_str="16-bit"; } for (int i=0; iinit(file, i); if (hdr.flags & LE_ENTRYPOINT_BUNDLE_32BIT) { m->add_staticmask_ptable(le_entry32, o, le_bigendian); o+=1+4; } else { m->add_staticmask_ptable(le_entry16, o, le_bigendian); o+=1+2; } ht_snprintf(t, sizeof t, "--- entry %d (%s) ---", i+1, flags_str); ht_collapsable_sub *cs=new ht_collapsable_sub(); cs->init(file, m, 1, t, 1); v->insertsub(cs); } } return v; } format_viewer_if htleentrypoints_if = { htleentrypoints_init, 0 }; ht-2.0.22/INSTALL0000644000175000001440000000135007542374650010171 00000000000000 Installing HT =============== (1) a. This creates by default the development (debug) version of HT (-g -O0): ./configure b. If you want a final (release) version (-O2 -fomit-frame-pointer) do the following instead: ./configure --enable-release c. if you want to build with profiling information (-pg -g) add '--enable-profiling' (2) compile and link HT: make (3) (optionally) install HT: make install (4) run HT: ht or ./ht Note: The package 'tex4ht' comes with a program called /usr/bin/ht which conflicts with this program's name... In order to use both programs properly you should rename one of them. (for example: mv /usr/local/bin/ht /usr/local/bin/ht.alt) ht-2.0.22/Makefile.in0000644000175000017500000011370012127657374011216 00000000000000# Makefile.in generated by automake 1.10.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = ht$(EXEEXT) @ENABLE_INCLUDED_LZO_TRUE@am__append_1 = minilzo @ENABLE_INCLUDED_LZO_TRUE@am__append_2 = minilzo/liblzo.a subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ TODO config.guess config.sub depcomp install-sh missing ylwrap ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = am__installdirs = "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_ht_OBJECTS = atom.$(OBJEXT) except.$(OBJEXT) data.$(OBJEXT) \ str.$(OBJEXT) strtools.$(OBJEXT) endianess.$(OBJEXT) \ htdoc.$(OBJEXT) blockop.$(OBJEXT) cstream.$(OBJEXT) \ formats.$(OBJEXT) htanaly.$(OBJEXT) htapp.$(OBJEXT) \ htcfg.$(OBJEXT) htclipboard.$(OBJEXT) htcoff.$(OBJEXT) \ htcoffhd.$(OBJEXT) htctrl.$(OBJEXT) htdebug.$(OBJEXT) \ htdialog.$(OBJEXT) htelf.$(OBJEXT) htelfhd.$(OBJEXT) \ htelfimg.$(OBJEXT) htelfphs.$(OBJEXT) htelfshs.$(OBJEXT) \ htelfsym.$(OBJEXT) htelfrel.$(OBJEXT) htfinfo.$(OBJEXT) \ htformat.$(OBJEXT) hthex.$(OBJEXT) hthist.$(OBJEXT) \ htidle.$(OBJEXT) htiobox.$(OBJEXT) htle.$(OBJEXT) \ htleent.$(OBJEXT) htlehead.$(OBJEXT) htleimg.$(OBJEXT) \ htleobj.$(OBJEXT) htlepage.$(OBJEXT) htmenu.$(OBJEXT) \ htmz.$(OBJEXT) htmzhead.$(OBJEXT) htmzimg.$(OBJEXT) \ htmzrel.$(OBJEXT) htne.$(OBJEXT) htneent.$(OBJEXT) \ htnehead.$(OBJEXT) htnenms.$(OBJEXT) htneobj.$(OBJEXT) \ htnewexe.$(OBJEXT) htobj.$(OBJEXT) htpal.$(OBJEXT) \ htpe.$(OBJEXT) htpedimp.$(OBJEXT) htpeexp.$(OBJEXT) \ htpehead.$(OBJEXT) htpeimg.$(OBJEXT) htpeimp.$(OBJEXT) \ htperes.$(OBJEXT) htreg.$(OBJEXT) htsearch.$(OBJEXT) \ httag.$(OBJEXT) httree.$(OBJEXT) main.$(OBJEXT) \ store.$(OBJEXT) stream.$(OBJEXT) tools.$(OBJEXT) vxd.$(OBJEXT) \ vxdserv.$(OBJEXT) cplus-dem.$(OBJEXT) regex.$(OBJEXT) \ syntax.$(OBJEXT) textfile.$(OBJEXT) textedit.$(OBJEXT) \ classread.$(OBJEXT) classview.$(OBJEXT) httext.$(OBJEXT) \ hteval.$(OBJEXT) relfile.$(OBJEXT) htprocess.$(OBJEXT) \ mfile.$(OBJEXT) elfstruc.$(OBJEXT) pestruct.$(OBJEXT) \ coff_s.$(OBJEXT) mzstruct.$(OBJEXT) defreg.$(OBJEXT) \ htdisasm.$(OBJEXT) htcoffimg.$(OBJEXT) nestruct.$(OBJEXT) \ htneimg.$(OBJEXT) htneimp.$(OBJEXT) cmds.$(OBJEXT) \ snprintf.$(OBJEXT) htpeil.$(OBJEXT) ilstruct.$(OBJEXT) \ log.$(OBJEXT) classimg.$(OBJEXT) vfs.$(OBJEXT) \ vfsview.$(OBJEXT) htlevxd.$(OBJEXT) lestruct.$(OBJEXT) \ htmacho.$(OBJEXT) htmachohd.$(OBJEXT) machostruc.$(OBJEXT) \ htmachoimg.$(OBJEXT) fltstruc.$(OBJEXT) htflt.$(OBJEXT) \ htflthd.$(OBJEXT) htfltimg.$(OBJEXT) xbestruct.$(OBJEXT) \ htxbehead.$(OBJEXT) htxbe.$(OBJEXT) htxbeimg.$(OBJEXT) \ htxbeimp.$(OBJEXT) pefstruc.$(OBJEXT) htpef.$(OBJEXT) \ htpefhd.$(OBJEXT) htpefimg.$(OBJEXT) htpefimp.$(OBJEXT) \ htxex.$(OBJEXT) htxexhead.$(OBJEXT) xexstruct.$(OBJEXT) \ cp-demangle.$(OBJEXT) htxeximg.$(OBJEXT) ht_OBJECTS = $(am_ht_OBJECTS) am__DEPENDENCIES_1 = ht_DEPENDENCIES = $(ANALYSER_DIR)/libanalyser.a $(ASM_DIR)/libasm.a \ $(INFO_DIR)/libinfo.a $(IO_DIR)/libhtio.a \ $(OUTPUT_DIR)/liboutput.a $(COMIO_DIR)/libcomio.a \ $(EVAL_DIR)/libhteval.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) $(am__append_2) ht_LINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(ht_LDFLAGS) $(LDFLAGS) \ -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(ht_SOURCES) DIST_SOURCES = $(ht_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive ETAGS = etags CTAGS = ctags DIST_SUBDIRS = tools analyser asm doc info io output eval minilzo DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ { test ! -d $(distdir) \ || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr $(distdir); }; } DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ HT_LDFLAGS = @HT_LDFLAGS@ HT_LIBS = @HT_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IO_DIR = io/@IO_DIR@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ LZO_LIBS = @LZO_LIBS@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ curses_CPPFLAGS = @curses_CPPFLAGS@ curses_LIBS = @curses_LIBS@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ ncurses_config = @ncurses_config@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = ${my_CPPFLAGS} -I$(srcdir)/$(ANALYSER_DIR) \ -I$(srcdir)/$(ASM_DIR) -I$(srcdir)/$(INFO_DIR) \ -I$(srcdir)/$(IO_DIR) -I$(srcdir)/$(COMIO_DIR) \ -I$(srcdir)/$(OUTPUT_DIR) -I$(srcdir)/$(EVAL_DIR) -I$(srcdir) AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} ANALYSER_DIR = analyser ASM_DIR = asm INFO_DIR = info COMIO_DIR = io OUTPUT_DIR = output EVAL_DIR = eval #SRT_DIR = srt EXTRA_DIST = TODO ChangeLog README KNOWNBUGS INSTALL COPYING AUTHORS SUBDIRS = tools analyser asm doc info io output eval $(am__append_1) ht_LDADD = $(ANALYSER_DIR)/libanalyser.a $(ASM_DIR)/libasm.a \ $(INFO_DIR)/libinfo.a $(IO_DIR)/libhtio.a \ $(OUTPUT_DIR)/liboutput.a $(COMIO_DIR)/libcomio.a \ $(EVAL_DIR)/libhteval.a ${HT_LIBS} ${LZO_LIBS} ${curses_LIBS} \ $(am__append_2) ht_LDFLAGS = ${HT_LDFLAGS} ht_SOURCES = atom.cc atom.h except.cc except.h data.cc data.h \ str.cc str.h strtools.cc strtools.h endianess.h endianess.cc \ htdoc.c htdoc.h blockop.cc blockop.h coff_s.h \ config.h cstream.cc cstream.h demangle.h elfstruc.h \ formats.cc formats.h htanaly.cc htanaly.h htapp.cc \ htapp.h htcfg.cc htcfg.h htclipboard.cc htclipboard.h \ htcoff.cc htcoff.h htcoffhd.cc htcoffhd.h htctrl.cc htctrl.h \ htdebug.cc htdebug.h htdialog.cc htdialog.h htelf.cc htelf.h htelfhd.cc \ htelfhd.h htelfimg.cc htelfimg.h htelfphs.cc htelfphs.h htelfshs.cc htelfshs.h \ htelfsym.cc htelfsym.h htelfrel.cc htelfrel.h htfinfo.cc htfinfo.h htformat.cc \ htformat.h hthex.cc hthex.h hthist.cc hthist.h htidle.cc \ htidle.h htinfo.h htiobox.cc htiobox.h htle.cc htle.h htleent.cc \ htleent.h htlehead.cc htlehead.h htleimg.cc htleimg.h htleobj.cc htleobj.h \ htlepage.cc htlepage.h htmenu.cc htmenu.h htmz.cc htmz.h \ htmzhead.cc htmzhead.h htmzimg.cc htmzimg.h htmzrel.cc htmzrel.h htne.cc \ htne.h htneent.cc htneent.h htnehead.cc htnehead.h htnenms.cc htnenms.h \ htneobj.cc htneobj.h htnewexe.cc htnewexe.h htobj.cc htobj.h htpal.cc \ htpal.h htpe.cc htpe.h htpedimp.cc htpedimp.h htpeexp.cc htpeexp.h \ htpehead.cc htpehead.h htpeimg.cc htpeimg.h htpeimp.cc htpeimp.h htperes.cc \ htperes.h htreg.cc htreg.h htsearch.cc htsearch.h \ httag.cc httag.h httree.cc \ httree.h lestruct.h main.cc mzstruct.h nestruct.h pestruct.h \ store.cc store.h stream.cc stream.h tools.cc tools.h vxd.cc vxd.h \ vxdserv.cc vxdserv.h cplus-dem.c demangle.h regex.c regex.h \ syntax.cc syntax.h textfile.cc textfile.h textedit.cc textedit.h \ classread.cc classview.cc class.h httext.cc httext.h hteval.cc hteval.h \ relfile.cc relfile.h htprocess.cc htprocess.h mfile.cc mfile.h elfstruc.cc \ pestruct.cc coff_s.cc mzstruct.cc defreg.h defreg.c htdisasm.cc htdisasm.h \ htcoffimg.cc htcoffimg.h nestruct.cc htneimg.cc htneimg.h htneimp.cc htneimp.h \ cmds.cc cmds.h snprintf.cc snprintf.h htpeil.cc htpeil.h \ ilstruct.cc ilstruct.h log.cc log.h classimg.cc classimg.h \ vfs.cc vfs.h vfsview.cc vfsview.h htlevxd.cc htlevxd.h lestruct.cc \ htmacho.cc htmacho.h htmachohd.cc htmachohd.h machostruc.cc machostruc.h \ htmachoimg.cc htmachoimg.h fltstruc.h fltstruc.cc htflt.cc htflt.h htflthd.cc \ htflthd.h htfltimg.cc htfltimg.h xbestruct.cc xbestruct.h htxbehead.cc \ htxbehead.h htxbe.cc htxbe.h htxbeimg.cc htxbeimg.h htxbeimp.cc htxbeimp.h \ pefstruc.cc pefstruc.h htpef.cc htpef.h htpefhd.cc htpefhd.h htpefimg.cc htpefimg.h \ htpefimp.cc htpefimp.h htxex.cc htxex.h htxexhead.cc htxexhead.h xexstruct.cc \ cp-demangle.c cp-demangle.h xexstruct.h htxeximg.cc htxeximg.h safe-ctype.h all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .c .cc .o .obj am--refresh: @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ cd $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) cd $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) config.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: $(am__configure_deps) cd $(top_srcdir) && $(AUTOHEADER) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) ht$(EXEEXT): $(ht_OBJECTS) $(ht_DEPENDENCIES) @rm -f ht$(EXEEXT) $(ht_LINK) $(ht_OBJECTS) $(ht_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atom.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/blockop.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/classimg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/classread.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/classview.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmds.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff_s.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cp-demangle.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cplus-dem.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cstream.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/data.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/defreg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elfstruc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/endianess.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/except.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fltstruc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/formats.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htanaly.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htapp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htcfg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htclipboard.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htcoff.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htcoffhd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htcoffimg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htctrl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htdebug.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htdialog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htdisasm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htdoc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htelf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htelfhd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htelfimg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htelfphs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htelfrel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htelfshs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htelfsym.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hteval.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htfinfo.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htflt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htflthd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htfltimg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htformat.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hthex.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hthist.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htidle.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htiobox.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htle.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htleent.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htlehead.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htleimg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htleobj.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htlepage.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htlevxd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htmacho.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htmachohd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htmachoimg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htmenu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htmz.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htmzhead.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htmzimg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htmzrel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htne.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htneent.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htnehead.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htneimg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htneimp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htnenms.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htneobj.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htnewexe.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htobj.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htpal.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htpe.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htpedimp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htpeexp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htpef.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htpefhd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htpefimg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htpefimp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htpehead.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htpeil.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htpeimg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htpeimp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htperes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htprocess.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htreg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htsearch.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httag.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httext.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httree.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htxbe.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htxbehead.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htxbeimg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htxbeimp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htxex.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htxexhead.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htxeximg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ilstruct.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lestruct.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/machostruc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mzstruct.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nestruct.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pefstruc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pestruct.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/relfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/snprintf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/store.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stream.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtools.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/syntax.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/textedit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/textfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tools.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vfs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vfsview.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vxd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vxdserv.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbestruct.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xexstruct.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) $(am__remove_distdir) test -d $(distdir) || mkdir $(distdir) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ distdir=`$(am__cd) $(distdir) && pwd`; \ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$top_distdir" \ distdir="$$distdir/$$subdir" \ am__remove_distdir=: \ am__skip_length_check=: \ distdir) \ || exit 1; \ fi; \ done -find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r $(distdir) dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && cd $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @cd $(distuninstallcheck_dir) \ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile $(PROGRAMS) config.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) install-am \ install-strip .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-binPROGRAMS \ clean-generic ctags ctags-recursive dist dist-all dist-bzip2 \ dist-gzip dist-lzma dist-shar dist-tarZ dist-zip distcheck \ distclean distclean-compile distclean-generic distclean-hdr \ distclean-tags distcleancheck distdir distuninstallcheck dvi \ dvi-am html html-am info info-am install install-am \ install-binPROGRAMS install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ ps ps-am tags tags-recursive uninstall uninstall-am \ uninstall-binPROGRAMS dist2: distdir $(AMTAR) chof - $(distdir) | BZIP2=$(BZIP2_ENV) bzip2 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-all2: dist2 htdoc.c htdoc.h: $(srcdir)/doc/hthelp.info tools/bin2c tools/bin2c -Nhtinfo $(srcdir)/doc/hthelp.info htdoc.c htdoc.h # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ht-2.0.22/htperes.cc0000644000175000001440000002106110634114571011110 00000000000000/* * HT Editor * htperes.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "formats.h" #include "htapp.h" #include "htctrl.h" #include "htdialog.h" #include "endianess.h" #include "hthex.h" #include "htiobox.h" #include "keyb.h" #include "htnewexe.h" #include "htobj.h" #include "htpe.h" #include "htperes.h" #include "strtools.h" #include "httree.h" #include "log.h" #include "pestruct.h" #include "stream.h" #include "snprintf.h" #include static int_hash restypes[] = { {0x0001, "cursors"}, {0x0002, "bitmaps"}, {0x0003, "icons"}, {0x0004, "menus"}, {0x0005, "dialogs"}, {0x0006, "string tables"}, {0x0007, "font directories"}, {0x0008, "fonts"}, {0x0009, "accelerators"}, {0x000a, "custom resource data"}, {0x000b, "message tables"}, {0x000c, "group cursors"}, {0x000e, "group icons"}, {0x0010, "version information"}, {0x0011, "dialog includes"}, {0x0013, "pnp"}, {0x0014, "vxd"}, {0x0015, "animated cursors"}, { 0 } }; static int_hash languages[] = { {7, "german"}, {9, "english"}, {10, "spanish"}, {12, "french"}, {16, "italian"}, { 0 } }; class ht_pe_resource_leaf: public Object { public: uint32 offset; uint32 size; }; static File *peresource_file; static FileOfs peresource_dir_ofs; static ht_static_treeview *peresource_tree; static char peresource_string[128]; static pe_section_headers *peresource_section_headers; static void read_resource_dir(void *node, int ofs, int level) { if (level>2) return; /* no deep recursions please (for currupted resource directories) */ PE_RESOURCE_DIRECTORY dir; // get directory peresource_file->seek(peresource_dir_ofs+ofs); if (peresource_file->read(&dir, sizeof dir) != (sizeof dir)) return; createHostStruct(&dir, PE_RESOURCE_DIRECTORY_struct, little_endian); // get entries PE_RESOURCE_DIRECTORY_ENTRY entry; for (int i=0; iseek(peresource_dir_ofs+ofs+sizeof dir+i*8); peresource_file->read(&entry, sizeof entry); createHostStruct(&entry, PE_RESOURCE_DIRECTORY_ENTRY_struct, little_endian); if (entry.offset_to_directory & 0x80000000) { bool hasname = entry.name & 0x80000000; PE_RESOURCE_DIRECTORY subdir; peresource_file->seek(peresource_dir_ofs + (entry.offset_to_directory & 0x7fffffff)); peresource_file->read(&subdir, sizeof subdir); createHostStruct(&subdir, PE_RESOURCE_DIRECTORY_struct, little_endian); if (hasname) { peresource_file->seek(peresource_dir_ofs + (entry.name & 0x7fffffff)); char *name = peresource_file->readstrw(); ht_snprintf(peresource_string, sizeof peresource_string, "%s [%d]", name, subdir.name_count+subdir.id_count); free(name); } else { const char *s = (!level) ? matchhash(entry.name & 0xffff, restypes) : NULL; if (s) { ht_snprintf(peresource_string, sizeof peresource_string, "ID %04x, %s [%d]", entry.name & 0xffff, s, subdir.name_count+subdir.id_count); } else { ht_snprintf(peresource_string, sizeof peresource_string, "ID %04x [%d]", entry.name & 0xffff, subdir.name_count+subdir.id_count); } } void *n = peresource_tree->add_child(node, peresource_string); read_resource_dir(n, entry.offset_to_directory & 0x7fffffff, level+1); } else { char *rm = peresource_string; char *rm_end = rm + sizeof peresource_string; const char *s = matchhash((char)entry.name, languages); if (s) { rm += ht_snprintf(rm, rm_end-rm, "resource, %s (%04x) ", s, entry.name & 0xffff); } else { rm += ht_snprintf(rm, rm_end-rm, "resource, unknown language (%04x) ", entry.name & 0xffff); } PE_RESOURCE_DATA_ENTRY data; peresource_file->seek(peresource_dir_ofs+entry.offset_to_directory); peresource_file->read(&data, sizeof data); createHostStruct(&data, PE_RESOURCE_DATA_ENTRY_struct, little_endian); ht_pe_resource_leaf *xdata = NULL; FileOfs dofs=0; if (pe_rva_to_ofs(peresource_section_headers, data.offset_to_data, &dofs)) { xdata = new ht_pe_resource_leaf(); xdata->offset = dofs; xdata->size = data.size; rm += ht_snprintf(rm, rm_end-rm, "offset %08qx", dofs); } else { rm += ht_snprintf(rm, rm_end-rm, "offset? (rva %08x, corrupt)", data.offset_to_data); } ht_snprintf(rm, rm_end-rm, " size %08x", data.size); peresource_tree->add_child(node, peresource_string, xdata); } } } static ht_view *htperesources_init(Bounds *b, File *file, ht_format_group *group) { ht_pe_shared_data *pe_shared=(ht_pe_shared_data *)group->get_shared_data(); if (pe_shared->opt_magic!=COFF_OPTMAGIC_PE32 && pe_shared->opt_magic!=COFF_OPTMAGIC_PE64) return NULL; bool pe32 = (pe_shared->opt_magic==COFF_OPTMAGIC_PE32); uint32 sec_rva, sec_size; if (pe32) { sec_rva = pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_RESOURCE].address; sec_size = pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_RESOURCE].size; } else { sec_rva = pe_shared->pe64.header_nt.directory[PE_DIRECTORY_ENTRY_RESOURCE].address; sec_size = pe_shared->pe64.header_nt.directory[PE_DIRECTORY_ENTRY_RESOURCE].size; } if (!sec_rva || !sec_size) return NULL; ht_pe_resource_viewer *t=new ht_pe_resource_viewer(); t->init(b, DESC_PE_RESOURCES); void *root; String fn; /* get resource directory offset */ /* 1. get resource directory rva */ FileOfs iofs; uint32 irva; if (pe32) { irva=pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_RESOURCE].address; // uint32 isize=pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_RESOURCE].size; } else { irva=pe_shared->pe64.header_nt.directory[PE_DIRECTORY_ENTRY_RESOURCE].address; } /* 2. transform it into an offset */ if (!pe_rva_to_ofs(&pe_shared->sections, irva, &iofs)) goto pe_read_error; LOG("%y: PE: reading resource directory at offset 0x%08qx, rva %08x", &file->getFilename(fn), iofs, irva); peresource_file = file; peresource_dir_ofs = iofs; peresource_tree = t; peresource_section_headers = &pe_shared->sections; root=t->add_child(0, "pe resources"); read_resource_dir(root, 0, 0); t->adjust(root, true); t->update(); pe_shared->v_resources = t; return t; pe_read_error: errorbox("%y: PE resource directory seems to be corrupted.", &file->getFilename(fn)); t->done(); delete t; return NULL; } format_viewer_if htperesources_if = { htperesources_init, 0 }; /* * CLASS ht_pe_resource_viewer */ void ht_pe_resource_viewer::init(Bounds *b, const char *desc) { ht_static_treeview::init(b, desc); VIEW_DEBUG_NAME("ht_pe_resource_viewer"); } void ht_pe_resource_viewer::done() { ht_static_treeview::done(); } void ht_pe_resource_viewer::handlemsg(htmsg *msg) { switch (msg->msg) { case msg_vstate_restore: vstate_restore((Object*)msg->data1.ptr); clearmsg(msg); return; } ht_static_treeview::handlemsg(msg); } void ht_pe_resource_viewer::select_node(void *node) { static_node *s=(static_node*)node; if (s->data) { ht_group *vr_group=group; while (strcmp(vr_group->desc, VIEWERGROUP_NAME)) vr_group=vr_group->group; ht_view *c=vr_group->getfirstchild(); ht_format_viewer *hexv = NULL; while (c) { if (c->desc && (strcmp(c->desc, DESC_HEX)==0)) { hexv=(ht_format_viewer*)c; break; } c=c->next; } if (hexv) { vstate_save(); hexv->goto_offset(((ht_pe_resource_leaf*)s->data)->offset, false); hexv->pselect_set(((ht_pe_resource_leaf*)s->data)->offset, ((ht_pe_resource_leaf*)s->data)->offset+((ht_pe_resource_leaf*)s->data)->size); app->focus(hexv); } } } class ht_pe_resource_viewer_vstate: public Object { public: void *node; }; Object *ht_pe_resource_viewer::vstate_create() { ht_pe_resource_viewer_vstate *v = new ht_pe_resource_viewer_vstate(); v->node = get_cursor_node(); return v; } bool ht_pe_resource_viewer::vstate_save() { Object *vs = vstate_create(); if (vs) { htmsg m; m.msg = msg_vstate_save; m.type = mt_empty; m.data1.ptr = vs; m.data2.ptr = this; app->sendmsg(&m); return true; } return false; } void ht_pe_resource_viewer::vstate_restore(Object *d) { ht_pe_resource_viewer_vstate *v = new ht_pe_resource_viewer_vstate(); goto_node(v->node); } ht-2.0.22/htidle.cc0000644000175000001440000000301310615341620010700 00000000000000/* * HT Editor * htidle.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "data.h" #include "htdebug.h" #include "htidle.h" #include "keyb.h" #include "sys.h" static List *idle_objs; void register_idle_object(Object *o) { idle_objs->insert(o); } void unregister_idle_object(Object *o) { int c = idle_objs->count(); for (int i=0; i < c; i++) if ((*idle_objs)[i] == o) { idle_objs->remove(idle_objs->findByIdx(i)); } } void do_idle() { static int cur_idle = 0; static bool any_idles = 0; int c = idle_objs->count(); if (c) { if (cur_idle >= c) { cur_idle = 0; if (!any_idles) sys_suspend(); any_idles = 0; } Object *i = (*idle_objs)[cur_idle]; assert(i); any_idles |= i->idle(); cur_idle++; } else { sys_suspend(); } } /* * INIT */ bool init_idle() { idle_objs = new Array(false); return true; } /* * DONE */ void done_idle() { delete idle_objs; } ht-2.0.22/htpe.cc0000644000175000001440000002226211011644507010377 00000000000000/* * HT Editor * htpe.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "log.h" #include "endianess.h" #include "htnewexe.h" #include "htpe.h" #include "htpehead.h" #include "htpeexp.h" #include "htpeil.h" #include "htpeimp.h" #include "htpedimp.h" #include "htpeimg.h" #include "htperes.h" #include "stream.h" #include "tools.h" #include #include static format_viewer_if *htpe_ifs[] = { &htpeheader_if, &htpeexports_if, &htpeimports_if, &htpedelayimports_if, &htperesources_if, &htpeil_if, &htpeimage_if, 0 }; static ht_view *htpe_init(Bounds *b, File *file, ht_format_group *format_group) { byte pemagic[4]; FileOfs h = get_newexe_header_ofs(file); file->seek(h); ; if (file->read(pemagic, 4) != 4 || pemagic[0] != PE_MAGIC0 || pemagic[1] != PE_MAGIC1 || pemagic[2] != PE_MAGIC2 || pemagic[3] != PE_MAGIC3) return 0; ht_pe *g = new ht_pe(); g->init(b, file, htpe_ifs, format_group, h); return g; } format_viewer_if htpe_if = { htpe_init, 0 }; /* * CLASS ht_pe */ void ht_pe::init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs) { ht_format_group::init(b, VO_BROWSABLE | VO_SELECTABLE | VO_RESIZE, DESC_PE, file, false, true, 0, format_group); VIEW_DEBUG_NAME("ht_pe"); String fn; LOG("%y: PE: found header at 0x%08qx", &file->getFilename(fn), header_ofs); ht_pe_shared_data *pe_shared = ht_malloc(sizeof (ht_pe_shared_data)); shared_data = pe_shared; pe_shared->header_ofs = header_ofs; pe_shared->exports.funcs = new Array(true); pe_shared->dimports.funcs = new Array(true); pe_shared->dimports.libs = new Array(true); pe_shared->imports.funcs = new Array(true); pe_shared->imports.libs = new Array(true); pe_shared->il = NULL; pe_shared->v_image = NULL; pe_shared->v_dimports = NULL; pe_shared->v_imports = NULL; pe_shared->v_exports = NULL; pe_shared->v_resources = NULL; pe_shared->v_header = NULL; /* read header */ file->seek(header_ofs+4); file->readx(&pe_shared->coffheader, sizeof pe_shared->coffheader); createHostStruct(&pe_shared->coffheader, COFF_HEADER_struct, little_endian); file->readx(&pe_shared->opt_magic, sizeof pe_shared->opt_magic); pe_shared->opt_magic = createHostInt(&pe_shared->opt_magic, sizeof pe_shared->opt_magic, little_endian); file->seek(header_ofs+4+sizeof pe_shared->coffheader); switch (pe_shared->opt_magic) { case COFF_OPTMAGIC_PE32: file->readx(&pe_shared->pe32.header, sizeof pe_shared->pe32.header); createHostStruct(&pe_shared->pe32.header, COFF_OPTIONAL_HEADER32_struct, little_endian); file->readx(&pe_shared->pe32.header_nt, sizeof pe_shared->pe32.header_nt); createHostStruct(&pe_shared->pe32.header_nt, PE_OPTIONAL_HEADER32_NT_struct, little_endian); for (uint i=0; ipe32.header_nt.directory[i], PE_DATA_DIRECTORY_struct, little_endian); } break; case COFF_OPTMAGIC_PE64: file->readx(&pe_shared->pe64.header, sizeof pe_shared->pe64.header); createHostStruct(&pe_shared->pe64.header, COFF_OPTIONAL_HEADER64_struct, little_endian); file->readx(&pe_shared->pe64.header_nt, sizeof pe_shared->pe64.header_nt); createHostStruct(&pe_shared->pe64.header_nt, PE_OPTIONAL_HEADER64_NT_struct, little_endian); for (uint i=0; ipe64.header_nt.directory[i], PE_DATA_DIRECTORY_struct, little_endian); } break; } /* read section headers */ int os=pe_shared->coffheader.optional_header_size; pe_shared->sections.section_count=pe_shared->coffheader.section_count; file->seek(header_ofs+os+sizeof(COFF_HEADER)+4/*magic*/); pe_shared->sections.sections = ht_malloc(pe_shared->sections.section_count * sizeof *pe_shared->sections.sections); file->readx(pe_shared->sections.sections, pe_shared->sections.section_count*sizeof *pe_shared->sections.sections); for (uint i=0; isections.section_count; i++) { createHostStruct(&pe_shared->sections.sections[i], COFF_SECTION_HEADER_struct, little_endian); /* * To make those uninitialized/initialized flags * correct we guess a little * if (pe_shared->sections.sections[i].data_size && pe_shared->sections.sections[i].data_offset) { pe_shared->sections.sections[i].characteristics |= ; pe_shared->sections.sections[i].characteristics ~= ; } else { pe_shared->sections.sections[i].characteristics |= ; pe_shared->sections.sections[i].characteristics ~= ; }*/ } shared_data = pe_shared; ht_format_group::init_ifs(ifs); } void ht_pe::done() { ht_format_group::done(); ht_pe_shared_data *pe_shared = (ht_pe_shared_data*)shared_data; delete pe_shared->exports.funcs; delete pe_shared->dimports.funcs; delete pe_shared->dimports.libs; delete pe_shared->imports.funcs; delete pe_shared->imports.libs; free(pe_shared->sections.sections); free(shared_data); } void ht_pe::loc_enum_start() { /* ht_pe_shared_data *sh=(ht_pe_shared_data*)shared_data; if (sh->opt_magic==COFF_OPTMAGIC_PE32) { loc_enum=1; } else { loc_enum=0; } */ } bool ht_pe::loc_enum_next(ht_format_loc *loc) { #if 0 ht_pe_shared_data *sh=(ht_pe_shared_data*)shared_data; if (loc_enum) { loc->name="pe"; loc->start=sh->header_ofs; // calc pe size uint l=sizeof (COFF_HEADER) + sh->coffheader.optional_header_size; // go through directories for (uint i=0; i<16; i++) { FileOfs o; if (pe_rva_to_ofs(&sh->sections, sh->pe32.header_nt.directory[i].address, &o)) { uint k=o+sh->pe32.header_nt.directory[i].size-sh->header_ofs; l=MAX(k, l); } } // go through sections for (uint i=0; isections.section_count; i++) { uint k=sh->sections.sections[i].data_offset+sh->sections.sections[i].data_size-sh->header_ofs; l=MAX(k, l); } loc->length=l; loc_enum=0; return true; } return false; #endif return false; } /* * rva conversion routines */ bool pe_rva_to_ofs(pe_section_headers *section_headers, RVA rva, FileOfs *ofs) { COFF_SECTION_HEADER *s=section_headers->sections; for (uint i=0; isection_count; i++) { if ((rva>=s->data_address) && (rvadata_address+s->data_size)) { *ofs=rva-s->data_address+s->data_offset; return true; } s++; } return false; } bool pe_rva_to_section(pe_section_headers *section_headers, RVA rva, int *section) { COFF_SECTION_HEADER *s=section_headers->sections; for (uint i=0; isection_count; i++) { if ((rva>=s->data_address) && (rvadata_address+MAX(s->data_size, s->data_vsize))) { *section=i; return true; } s++; } return false; } bool pe_rva_is_valid(pe_section_headers *section_headers, RVA rva) { COFF_SECTION_HEADER *s=section_headers->sections; for (uint i=0; isection_count; i++) { if ((rva>=s->data_address) && (rvadata_address+MAX(s->data_size, s->data_vsize))) { return true; } s++; } return false; } bool pe_rva_is_physical(pe_section_headers *section_headers, RVA rva) { COFF_SECTION_HEADER *s=section_headers->sections; for (uint i=0; isection_count; i++) { if ((rva>=s->data_address) && (rvadata_address+s->data_size)) { return true; } s++; } return false; } /* * ofs conversion routines */ bool pe_ofs_to_rva(pe_section_headers *section_headers, FileOfs ofs, RVA *rva) { COFF_SECTION_HEADER *s=section_headers->sections; for (uint i=0; isection_count; i++) { if ((ofs>=s->data_offset) && (ofsdata_offset+s->data_size)) { *rva=ofs-s->data_offset+s->data_address; return true; } s++; } return false; } bool pe_ofs_to_section(pe_section_headers *section_headers, FileOfs ofs, int *section) { COFF_SECTION_HEADER *s=section_headers->sections; for (uint i=0; isection_count; i++) { if ((ofs>=s->data_offset) && (ofsdata_offset+s->data_size)) { *section=i; return true; } s++; } return false; } bool pe_ofs_to_rva_and_section(pe_section_headers *section_headers, FileOfs ofs, RVA *rva, int *section) { bool r = pe_ofs_to_rva(section_headers, ofs, rva); if (r) { r = pe_ofs_to_section(section_headers, ofs, section); } return r; } bool pe_ofs_is_valid(pe_section_headers *section_headers, FileOfs ofs) { RVA rva; return pe_ofs_to_rva(section_headers, ofs, &rva); } /* * */ bool pe_section_name_to_section(pe_section_headers *section_headers, const char *name, int *section) { COFF_SECTION_HEADER *s = section_headers->sections; int slen = strlen(name); slen = MIN(slen, COFF_SIZEOF_SHORT_NAME); for (uint i=0; i < section_headers->section_count; i++) { if (ht_strncmp(name, (char*)&s->name, slen) == 0) { *section = i; return true; } s++; } return false; } ht-2.0.22/relfile.cc0000644000175000001440000001077010615341624011065 00000000000000/* * HT Editor * relfile.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "htdebug.h" #include "relfile.h" #include "tools.h" #define MAX_RELOC_ITEM_LEN 8 /* * ht_reloc_file */ ht_reloc_file::ht_reloc_file(File *s, bool os) : FileLayer(s, os) { relocs = new AVLTree(true); enabled = true; } ht_reloc_file::~ht_reloc_file() { delete relocs; } void ht_reloc_file::finalize() { // relocs->set_compare_keys(compare_keys_uint); } int ht_reloc_file::vcntl(uint cmd, va_list vargs) { switch (cmd) { case FCNTL_GET_RELOC: { bool *e = va_arg(vargs, bool*); *e = enabled; return 0; } case FCNTL_SET_RELOC: { enabled = (bool)(va_arg(vargs, int)); return 0; } } return FileLayer::vcntl(cmd, vargs); } void ht_reloc_file::insert_reloc(FileOfs o, Object *reloc) { relocs->insert(new KeyValue(new UInt64(o), reloc)); } uint ht_reloc_file::read(void *buf, uint size) { FileOfs o = tell(); /* read fine data. */ uint ret = FileLayer::read(buf, size); uint c = ret; if (enabled) { ObjHandle oh; if ((MAX_RELOC_ITEM_LEN+1) <= o) { KeyValue kv(new UInt64(o - (MAX_RELOC_ITEM_LEN+1)), NULL); oh = relocs->findG(&kv); } else { oh = relocs->findFirst(); } /* enum through 'relocs' - the tree that contains all our * dear relocations - starting some bytes before the current * (stream) offset to get all the relocation items that may * intersect with our fine read data. */ while (oh != invObjHandle) { KeyValue *kv = (KeyValue *)relocs->get(oh); UInt64 *k = (UInt64 *)kv->mKey; /* buffer to apply relocation to */ byte b[MAX_RELOC_ITEM_LEN]; /* stop if the item is "behind" the area this function * should work on. */ if (k->value >= o+c) break; /* if relocation item intersects with the beginning of * this read, copy buf to b+s */ uint s = (k->value < o) ? o - k->value : 0; /* if relocation item intersects with the end of * this read, copy buf+e to b */ uint e = (k->value > o) ? k->value - o : 0; /* complicated calculation to get the size of the * intended intersection (=: mm) of the read and b. */ uint l = (k->value + sizeof b > o+c) ? k->value + sizeof b - o - c : 0; uint mm = MIN(sizeof b - l, sizeof b - s); /* probably cleaner to clear it all before we start * because if the read is smaller then the reloc item * we'd have some undefined bytes in b. */ memset(b, 0, sizeof b); /* never memmove beyond Bounds of b. (maybe you didn't call finalize()?) */ assert(mm+s <= sizeof b); /* move read data to b as good as we can. */ memmove(b+s, ((byte*)buf)+e, mm); /* apply complete relocation item. */ reloc_apply(kv->mValue, b); /* overwrite read with relocated/read data as good as we can. */ memcpy(((byte*)buf)+e, b+s, mm); oh = relocs->findG(kv); } } return ret; } uint ht_reloc_file::write(const void *buf, uint size) { /* documentation: see read(). */ FileOfs o; if (enabled) { o = tell(); uint c = size; ObjHandle oh; if ((MAX_RELOC_ITEM_LEN+1) <= o) { KeyValue kv(new UInt64(o - (MAX_RELOC_ITEM_LEN+1)), NULL); oh = relocs->findG(&kv); } else { oh = relocs->findFirst(); } while (oh != invObjHandle) { KeyValue *kv = (KeyValue *)relocs->get(oh); UInt64 *k = (UInt64 *)kv->mKey; byte b[MAX_RELOC_ITEM_LEN]; if (k->value >= o+c) break; uint s = (k->value < o) ? o - k->value : 0; uint e = (k->value > o) ? k->value - o : 0; uint l = (k->value+sizeof b > o+c) ? k->value + sizeof b - o - c : 0; memset(b, 0, sizeof b); uint mm = MIN(sizeof b - l, sizeof b - s); assert(mm+s <= sizeof b); memmove(b+s, ((byte*)buf)+e, mm); // FIXME: return here ??? if (!reloc_unapply(kv->mValue, b)) /*return 0*/; // FIXME: violation of function declaration "const void *buf" memcpy(((byte*)buf)+e, b+s, mm); oh = relocs->findG(kv); } } return FileLayer::write(buf, size); } ht-2.0.22/xexstruct.h0000755000175000001440000000642510615345252011364 00000000000000/* * HT Editor * xexstruct.h * * Copyright (C) 2006 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __XEXSTRUCT_H_ #define __XEXSTRUCT_H_ #include "io/types.h" #include "tools.h" typedef unsigned int RVA; #define XEX_MAGIC_LENGTH 4 #define XEX_MAGIC0 'X' #define XEX_MAGIC1 'E' #define XEX_MAGIC2 'X' #define XEX_MAGIC3 '2' struct XEX_IMAGE_HEADER { byte magic_id[XEX_MAGIC_LENGTH]; uint32 flags; uint32 size; uint32 res; uint32 file_header_offset; uint32 number_of_sections; } PACKED; #define XEX_HEADER_FIELD_MODULES 0x0002ff #define XEX_HEADER_FIELD_LOADERINFO 0x0003ff #define XEX_HEADER_FIELD_FILENAME 0x0080ff #define XEX_HEADER_FIELD_LOADBASE 0x010001 #define XEX_HEADER_FIELD_ENTRY 0x010100 #define XEX_HEADER_FIELD_BASE 0x010201 #define XEX_HEADER_FIELD_IMPORT 0x0103ff #define XEX_HEADER_FIELD_IDS 0x018002 #define XEX_HEADER_FIELD_ORIG_FILENAME 0x0183ff #define XEX_HEADER_FIELD_RESMAP2 0x0200ff #define XEX_HEADER_FIELD_UNK0 0x020104 // 80078884 #define XEX_HEADER_FIELD_STACK_SIZE 0x020200 // 800788bc #define XEX_HEADER_FIELD_CACHE_INFO 0x020301 #define XEX_HEADER_FIELD_MEDIAINFO 0x040006 #define XEX_HEADER_FIELD_LAN_KEY 0x040404 #define XEX_HEADER_FIELD_IMPORT_UNK 0xe10402 #define XEX_MEDIA_HD 0x00000001 #define XEX_MEDIA_DVD_X2 0x00000002 #define XEX_MEDIA_DVD_CD 0x00000004 #define XEX_MEDIA_DVD_5 0x00000008 #define XEX_MEDIA_DVD_9 0x00000010 #define XEX_MEDIA_FLASH 0x00000020 #define XEX_MEDIA_MEMORY_UNIT 0x00000080 #define XEX_MEDIA_MASS_STORAGE 0x00000100 #define XEX_MEDIA_SMB 0x00000200 #define XEX_MEDIA_RAM 0x00000400 #define XEX_MEDIA_INSECURE 0x01000000 #define XEX_MEDIA_SAVE_GAME 0x02000000 #define XEX_MEDIA_LOCAL 0x04000000 #define XEX_MEDIA_LIVE 0x08000000 #define XEX_MEDIA_XBOX 0x10000000 struct XEX_IMAGE_HEADER_INFO_ENTRY { union { struct { byte res; byte classe; byte type; byte size; } b; uint32 type PACKED; } PACKED; uint32 value; } PACKED; enum { XEX_LOADER_NONE = 0, XEX_LOADER_RAW = 1, XEX_LOADER_COMPRESSED = 2, }; struct XEX_LOADER_INFO_HEADER { uint16 crypted; uint16 type; } PACKED; struct XEX_RAW_LOADER_ENTRY { uint32 raw; uint32 pad; } PACKED; struct XEX_FILE_HEADER { uint32 hdr_size; uint32 image_size; uint8 key[256]; uint32 unk1; uint32 image_flags; uint32 load_address; uint8 hash1[20]; uint32 unk2; uint8 hash2[20]; uint8 unk3[16]; uint8 loader_key[16]; uint32 unk4; uint8 hash3[20]; uint32 region; uint32 media_mask; uint32 pages; } PACKED; extern byte XEX_IMAGE_HEADER_struct[]; extern byte XEX_IMAGE_HEADER_INFO_ENTRY_struct[]; extern byte XEX_LOADER_INFO_HEADER_struct[]; extern byte XEX_RAW_LOADER_ENTRY_struct[]; extern byte XEX_FILE_HEADER_struct[]; #endif ht-2.0.22/TODO0000644000175000001440000001435710240664655007637 00000000000000 HT TODO ========= +sepps - implement ht_static_treeview::goto_node() at all - exports/dimports in PE32+ broken - ht_listbox should have column align (left, right, center) - strz escape problems e.g. ffffffff -> " " - segments - multiple disassemblers - address: different display types (ie rva) - next unexplored - out_addr *analyser_output::get_addr(ADDR Addr) no cur_out_addr==NULL test - htanaly.cc: menu ifs not used properly (for keys...) - analy_x86: AnalyX86Disassembler::createAddress() fix it. - analy.cc: pushAddress(x,y) leaks x if !isValidCodeAddr(x) - analy.cc: analyser file storage: thresholds are stored after data structures which they are used for. > 80c20 dd 0x4c000024 ;; 00080c20 rfid > 823e4 dd 0x7d708120 ;; 000823e4 mtcrf 0x08,r11 +dunno - update help - listbox-search - qword *, /, %: better impl... - FILEOFS 64+ bits - (HT_1_0) freeze/stabilize config file formats / APIs - int ht_ne_entrypoint_viewer::ref_sel(LINE_ID *id) - 1”1 will eval to 1 - [x86 asm] 'jmp 1+2' doenst work but 'mov [1+2], ax' ?? - store.cc:60: getObject quits with invalid config file - disasm (esp. x86) switch 16/32 correctly - classread/view.cc - rename to match PE/ELF/LE,etc.'s structure - shared data not freed - segmented addresses + eval() - [start, end) or [start, end] in - Areas - ht_analy::lowest/highest address - document commandline options in help +steves - get rid of bnstr()!!! - ./configure should not fail if it can't find lex/flex (and probably other including but not limited to yacc) - eval: no signed division (there should be an operator s/ with "-7 s/ 7 == -1") - x86asm: "test eax, [2342343]" should yield "test [2342343], eax" ("test" ist symmetric) same with "xchg" - eval: "-2+1.0" vs. "2+1.0" (difficult) - option to open a file without attempting to parse 'special information' - i.e. to edit it as pure hex. - mov eax, [eax+ebp] vs. mov eax, [ebp+eax] - blockop should support multiple endianesses (currently only big-endian) - eval: int(-1.0) results in 0xffffffff instead of 0xffffffffffffffff - eval: int("-1") does not work - eval should warn if number too big/cannot parse - eval whatis(whatis("whatis")), what is? - create ht.cfg in "home dir", implementation+interface sys_get_home_dir() - disabling "-pipe" on generic-POSIX systems doesn't seem to work - input_date_time() - open... new option: preserve mtime - htsys.h move to .., implement sys_pstat_fd(pstat_t *s, int fd) - eval text_viewer - LE binary search does not work - Resources in VxDs (like in PE) - IPC-djgpp: recognize gui progs and close window !? - httext line wrapping, ctrl+page_down ?! - new instead of malloc - terminal.cc: terminal line buffering ?! - textviewer: vi-mania: '/' searches, 'n' continues - vfsview: xtime tag modified to display seconds. keep this ? - LE: fix file offset chaos (but howto ?) - "class Process" in process.cc: replacing/improving *_process see messy code htsearch: replace_bin_process (c->'s) - (HT_0_9) features configurable - (HT_0_9) directory structure - move source files (especially object system) into separate directories, solve name problems - (HT_0_9) data2/string2/stream2/store2/debug2 - homogenous/heterogenous lists - save on readonly/locked file - stream::set_layered suspicious - use exceptions - (HT_0_9) the next big changes (htvision rewrites) - rewrite menus, disable menu-entries (and multiple context menus ?) - handlemsg should not have to handle keypressed. new concepts needed - texteditor as dialog-widget should have attachable scrollbar - menus should save last cursor position - use exceptions and get rid of globalerror (cause its ugly) - cleanup msg interface - auto-documentation (e.g. keys) - syntax.cc:bool match_sorted_stringtable(char *s, UINT slen, char **strings, UINT strings_count): better use bsearch() (ANSI, POSIX) - texteditor as dialog-widget should have attachable scrollbar - open file: wildcards - search - search should prefill start/end ofs from selection (if applicable) - search with invalid start/end offset - menus should save last cursor position - int ht_disasm_sub::prev_line_id(LINE_ID *line_id, int n), bah - getbounds rel coords - disable buttons (disable menu-entries, disable messages) - file manager - file browser - vfs based on ht_listbox - copy, etc. ?! - vfs ..._viewer to get config_changed - elf/pe/etc.-section ref tree optimizationdfgjl - KEY_RESIZE - textedit/file - +get_size,extend,truncate +overwrite -use_getline - highlighter speed !! - bug with getline's pofs ?! - long lines - unindent() - match pair highlight - undo::gettext() should (be able to) use text_editor::snprint_ppos(...) - input separators configurable (right now only creates UNIX-style files) - search backwards - more history entries: replace e.g. - improve edit_time/dialog ?! - auto-documentation (e.g. keys) - portability - compile on sun solaris (curses problems (only?) on cf.sf.net) - compile on MacOS X (curses.h, but no ACS_*) - detect format length (ne,le,elf) - LE: use byte/word order (no examples) - pe/elf relocations ? - make ht_group_sub work correctly - color invert & underlined attribute and transparent chars, codepages ? && abstract (e.g. transparent) chars (io/*) - x86 (dis)assembler - options (ambigous & + floats) + beautify (enums) - "short"/"large" branches - OBJECT_ID vs HT_ATOM ? - object notification (e.g. insertion into groups (c overview), dialog-elements content modified ) - file structure overview - uformat+k_shift_*: use select_mode_* - *::duplicate(); --> *::clone(); - use better c/c++ (s/most dwords/UINT/, s/int/bool/where needed, more enums, templates, exceptions) - better coff-detection - multiple bit tag (extend bit tag ?) - execute_dialog_modal + window move/resize - taginfo-window - clipboard: limit size somehow - smart window positioning (don't hide cursor) - split up htobj.cc and htdialog.cc into smaller files - extended search (continue as idle w/result window) - CHAR-TAGs must also be editable as hex - full support of: pe, le, lx, mz, ne, elf, a archives, pure/dj coff, m$ object files, etc.. - exe-packer support (at least notification) - fix FIXMEs - remove memory leaks +discussion - queuemsg in ht_view ?! - searchmode bin/regex: rewrite regex ? - "Ctrl-X" vs. "Ctrl+X" - only frames have desc, rest view_debug_name ht-2.0.22/endianess.cc0000755000175000001440000001172011011644507011410 00000000000000/* * HT Editor * endianess.cc * * Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "htdebug.h" #include "endianess.h" #include "io/types.h" void createForeignInt(void *buf, int i, int size, Endianess to_endianess) { uint8 *b = (uint8*)buf; switch (size) { case 1: b[0] = i; break; case 2: switch (to_endianess) { case big_endian: b[0] = i>>8; b[1] = i; break; case little_endian: b[0] = i; b[1] = i>>8; break; } break; case 4: switch (to_endianess) { case big_endian: b[0] = i>>24; b[1] = i>>16; b[2] = i>>8; b[3] = i; break; case little_endian: b[0] = i; b[1] = i>>8; b[2] = i>>16; b[3] = i>>24; break; } break; default: ASSERT(0); } } int createHostInt(const void *buf, int size, Endianess from_endianess) { uint8 *b = (uint8*)buf; switch (size) { case 1: return b[0]; case 2: switch (from_endianess) { case big_endian: return (b[0]<<8) | b[1]; case little_endian: return (b[1]<<8) | b[0]; } break; case 4: switch (from_endianess) { case big_endian: return (b[0]<<24) | (b[1]<<16) | (b[2]<<8) | b[3]; case little_endian: return (b[3]<<24) | (b[2]<<16) | (b[1]<<8) | b[0]; } break; } ASSERT(0); return 0; } void createForeignInt64(void *buf, uint64 i, int size, Endianess to_endianess) { if (size <= 4) { return createForeignInt(buf, i, size, to_endianess); } uint8 *b = (uint8*)buf; uint32 hi = i >> 32; uint32 lo = i; switch (to_endianess) { case big_endian: b[0] = hi>>24; b[1] = hi>>16; b[2] = hi>>8; b[3] = hi; b[4] = lo>>24; b[5] = lo>>16; b[6] = lo>>8; b[7] = lo; break; case little_endian: b[0] = lo; b[1] = lo>>8; b[2] = lo>>16; b[3] = lo>>24; b[4] = hi; b[5] = hi>>8; b[6] = hi>>16; b[7] = hi>>24; break; default: ASSERT(0); } } uint64 createHostInt64(const void *buf, int size, Endianess from_endianess) { if (size <= 4) { return createHostInt(buf, size, from_endianess); } uint8 *b = (uint8*)buf; uint64 q; switch (from_endianess) { case big_endian: q = uint64(b[0])<<56 | uint64(b[1])<<48 | uint64(b[2])<<40 | uint64(b[3])<<32 | uint64(b[4])<<24 | uint64(b[5])<<16 | uint64(b[6])<<8 | uint64(b[7]); break; case little_endian: q = uint64(b[7])<<56 | uint64(b[6])<<48 | uint64(b[5])<<40 | uint64(b[4])<<32 | uint64(b[3])<<24 | uint64(b[2])<<16 | uint64(b[1])<<8 | uint64(b[0]); break; default: ASSERT(0); } return q; } void createHostStruct(void *buf, const uint8 *table, Endianess from_endianess) { uint8 *buf2 = (uint8*)buf; while (*table) { int table2 = *table & ~STRUCT_ENDIAN_HOST; if (*table & STRUCT_ENDIAN_HOST) { switch (table2) { case STRUCT_ENDIAN_8: { uint8 a = createHostInt(buf2, STRUCT_ENDIAN_8, from_endianess); memcpy(buf2, &a, STRUCT_ENDIAN_8); break; } case STRUCT_ENDIAN_16: { uint16 a = createHostInt(buf2, STRUCT_ENDIAN_16, from_endianess); memcpy(buf2, &a, STRUCT_ENDIAN_16); break; } case STRUCT_ENDIAN_32: { uint32 a = createHostInt(buf2, STRUCT_ENDIAN_32, from_endianess); memcpy(buf2, &a, STRUCT_ENDIAN_32); break; } case STRUCT_ENDIAN_64: { uint64 q = createHostInt64(buf2, STRUCT_ENDIAN_64, from_endianess); memcpy(buf2, &q, STRUCT_ENDIAN_64); break; } default: ASSERT(0); } } buf2 += table2; table++; } } void createHostStructx(void *buf, uint bufsize, const uint8 *table, Endianess from_endianess) { uint8 *buf2 = (uint8*)buf; while (*table) { if (bufsize) ASSERT((uint)(buf2 - (uint8*)buf) < bufsize); int table2 = *table & ~STRUCT_ENDIAN_HOST; if (*table & STRUCT_ENDIAN_HOST) { switch (table2) { case STRUCT_ENDIAN_8: { uint8 a = createHostInt(buf2, STRUCT_ENDIAN_8, from_endianess); memcpy(buf2, &a, STRUCT_ENDIAN_8); break; } case STRUCT_ENDIAN_16: { uint16 a = createHostInt(buf2, STRUCT_ENDIAN_16, from_endianess); memcpy(buf2, &a, STRUCT_ENDIAN_16); break; } case STRUCT_ENDIAN_32: { uint32 a = createHostInt(buf2, STRUCT_ENDIAN_32, from_endianess); memcpy(buf2, &a, STRUCT_ENDIAN_32); break; } case STRUCT_ENDIAN_64: { uint64 q = createHostInt64(buf2, STRUCT_ENDIAN_64, from_endianess); memcpy(buf2, &q, STRUCT_ENDIAN_64); break; } default: ASSERT(0); } } buf2 += table2; table++; } if (bufsize) ASSERT((uint)(buf2 - (uint8*)buf) == bufsize); } ht-2.0.22/htmacho.cc0000644000175000001440000002332211302044257011057 00000000000000/* * HT Editor * htmacho.cc * * Copyright (C) 2003 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "elfstruc.h" #include "log.h" #include "htmacho.h" #include "htmachohd.h" #include "htmachoimg.h" #include "endianess.h" #include "stream.h" #include "tools.h" #include "machostruc.h" #include static format_viewer_if *htmacho_ifs[] = { &htmachoheader_if, &htmachoimage_if, 0 }; static ht_view *htmacho_init(Bounds *b, File *file, ht_format_group *format_group) { byte magic[4]; file->seek(0); file->read(&magic, sizeof magic); if (memcmp(magic, "\xfe\xed\xfa\xce", 4) == 0) { ht_macho *g = new ht_macho(); g->init(b, file, htmacho_ifs, format_group, 0, big_endian, false); return g; } else if (memcmp(magic, "\xfe\xed\xfa\xcf", 4) == 0) { ht_macho *g = new ht_macho(); g->init(b, file, htmacho_ifs, format_group, 0, big_endian, true); return g; } else if (memcmp(magic, "\xce\xfa\xed\xfe", 4) == 0) { ht_macho *g = new ht_macho(); g->init(b, file, htmacho_ifs, format_group, 0, little_endian, false); return g; } else if (memcmp(magic, "\xcf\xfa\xed\xfe", 4) == 0) { ht_macho *g = new ht_macho(); g->init(b, file, htmacho_ifs, format_group, 0, little_endian, true); return g; } return NULL; } format_viewer_if htmacho_if = { htmacho_init, 0 }; /* * CLASS ht_macho */ void ht_macho::init(Bounds *b, File *f, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs, Endianess image_endianess, bool _64) { ht_format_group::init(b, VO_SELECTABLE | VO_BROWSABLE | VO_RESIZE, DESC_MACHO, f, false, true, 0, format_group); VIEW_DEBUG_NAME("ht_macho"); String fn; file->getFilename(fn); LOG("%y: Mach-O: found header at %08qx", &fn, header_ofs); ht_macho_shared_data *macho_shared = ht_malloc(sizeof(ht_macho_shared_data)); shared_data = macho_shared; macho_shared->image_endianess = image_endianess; macho_shared->_64 = _64; macho_shared->header_ofs = header_ofs; macho_shared->cmds.count = 0; macho_shared->cmds.cmds = NULL; FileOfs ofs; file->seek(header_ofs); if (_64) { file->read(&macho_shared->header64, sizeof macho_shared->header64); createHostStruct(&macho_shared->header64, MACHO_HEADER_64_struct, image_endianess); ofs = header_ofs + sizeof macho_shared->header64; } else { file->read(&macho_shared->header, sizeof macho_shared->header); createHostStruct(&macho_shared->header, MACHO_HEADER_struct, image_endianess); ofs = header_ofs + sizeof macho_shared->header; } /* read commands */ uint nsections = 0; macho_shared->cmds.cmds = ht_malloc(sizeof (MACHO_COMMAND_U*) * macho_shared->header.ncmds); macho_shared->cmds.count = 0; for (uint i=0; i < macho_shared->header.ncmds; i++) { MACHO_COMMAND cmd; file->seek(ofs); file->read(&cmd, sizeof cmd); createHostStruct(&cmd, MACHO_COMMAND_struct, image_endianess); if (cmd.cmdsize > 1024*1024) break; macho_shared->cmds.cmds[i] = ht_malloc(cmd.cmdsize); file->seek(ofs); if (file->read(macho_shared->cmds.cmds[i], cmd.cmdsize) != cmd.cmdsize) { LOG_EX(LOG_ERROR, "%y: Mach-O: error processing command idx %d " "(read error %d bytes from %08qx)", &fn, i, cmd.cmdsize, ofs); free(macho_shared->cmds.cmds[i]); break; } switch (cmd.cmd) { case LC_SEGMENT: createHostStruct(macho_shared->cmds.cmds[i], MACHO_SEGMENT_COMMAND_struct, image_endianess); // already count sections (needed for reading sections, see below) nsections += macho_shared->cmds.cmds[i]->segment.nsects; break; case LC_SEGMENT_64: createHostStruct(macho_shared->cmds.cmds[i], MACHO_SEGMENT_64_COMMAND_struct, image_endianess); // already count sections (needed for reading sections, see below) nsections += macho_shared->cmds.cmds[i]->segment_64.nsects; break; case LC_SYMTAB: createHostStruct(macho_shared->cmds.cmds[i], MACHO_SYMTAB_COMMAND_struct, image_endianess); break; case LC_THREAD: case LC_UNIXTHREAD: { MACHO_THREAD_COMMAND *c = (MACHO_THREAD_COMMAND*)macho_shared->cmds.cmds[i]; createHostStruct(macho_shared->cmds.cmds[i], MACHO_THREAD_COMMAND_struct, image_endianess); switch (macho_shared->header.cputype) { case MACHO_CPU_TYPE_ARM: switch (c->flavor) { case FLAVOR_ARM_THREAD_STATE: createHostStruct(&c->state, MACHO_ARM_THREAD_STATE_struct, image_endianess); break; } break; case MACHO_CPU_TYPE_I386: switch (c->flavor) { case -1: createHostStruct(&c->state, MACHO_I386_THREAD_STATE_struct, image_endianess); break; } break; case MACHO_CPU_TYPE_X86_64: switch (c->flavor) { case FLAVOR_X86_64_THREAD_STATE: createHostStruct(&c->state, MACHO_X86_64_THREAD_STATE_struct, image_endianess); break; } break; case MACHO_CPU_TYPE_POWERPC: switch (c->flavor) { case FLAVOR_PPC_THREAD_STATE: createHostStruct(&c->state, MACHO_PPC_THREAD_STATE_struct, image_endianess); break; } break; case MACHO_CPU_TYPE_POWERPC64: switch (c->flavor) { case FLAVOR_PPC_64_THREAD_STATE: createHostStruct(&c->state, MACHO_PPC_64_THREAD_STATE_struct, image_endianess); break; } break; } break; } default: createHostStruct(macho_shared->cmds.cmds[i], MACHO_COMMAND_struct, image_endianess); } ofs += cmd.cmdsize; macho_shared->cmds.count++; } /* read sections */ if (_64) { ofs = header_ofs + sizeof macho_shared->header64; } else { ofs = header_ofs + sizeof macho_shared->header; } macho_shared->section_count = nsections; macho_shared->sections = ht_malloc(sizeof (MACHO_SECTION_U) * macho_shared->section_count); uint sec = 0; for (uint i=0; i < macho_shared->cmds.count; i++) { if (macho_shared->cmds.cmds[i]->cmd.cmd == LC_SEGMENT) { FileOfs sofs = ofs + sizeof (MACHO_SEGMENT_COMMAND); file->seek(sofs); for (uint j=0; j < macho_shared->cmds.cmds[i]->segment.nsects; j++) { macho_shared->sections[sec]._64 = false; file->read(&macho_shared->sections[sec].s, sizeof (MACHO_SECTION)); createHostStruct(&macho_shared->sections[sec].s, MACHO_SECTION_struct, image_endianess); sec++; } } else if (macho_shared->cmds.cmds[i]->cmd.cmd == LC_SEGMENT_64) { FileOfs sofs = ofs + sizeof (MACHO_SEGMENT_64_COMMAND); file->seek(sofs); for (uint j=0; j < macho_shared->cmds.cmds[i]->segment_64.nsects; j++) { macho_shared->sections[sec]._64 = true; file->read(&macho_shared->sections[sec].s64, sizeof (MACHO_SECTION_64)); createHostStruct(&macho_shared->sections[sec].s64, MACHO_SECTION_64_struct, image_endianess); sec++; } } ofs += macho_shared->cmds.cmds[i]->cmd.cmdsize; } /* init ifs */ ht_format_group::init_ifs(ifs); } /* * address conversion routines */ bool macho_phys_and_mem_section(MACHO_SECTION_U *s) { return true; } bool macho_valid_section(MACHO_SECTION_U *s) { return true; } bool macho_addr_to_ofs(MACHO_SECTION_U *s, uint section_count, MACHOAddress addr, FileOfs *ofs) { for (uint i=0; i < section_count; i++) { if (macho_phys_and_mem_section(s)) { if (s->_64) { if (addr >= s->s64.vmaddr && addr < s->s64.vmaddr + s->s64.vmsize) { *ofs = addr - s->s64.vmaddr + s->s64.fileoff; return true; } } else { if (addr >= s->s.vmaddr && addr < s->s.vmaddr + s->s.vmsize) { *ofs = addr - s->s.vmaddr + s->s.fileoff; return true; } } } s++; } return false; } bool macho_addr_to_section(MACHO_SECTION_U *s, uint section_count, MACHOAddress addr, int *section) { for (uint i=0; i < section_count; i++) { if (s->_64) { if (macho_valid_section(s) && addr >= s->s64.vmaddr && addr < s->s64.vmaddr + s->s64.vmsize) { *section = i; return true; } } else { if (macho_valid_section(s) && addr >= s->s.vmaddr && addr < s->s.vmaddr + s->s.vmsize) { *section = i; return true; } } s++; } return false; } bool macho_addr_is_valid(MACHO_SECTION_U *s, uint section_count, MACHOAddress addr) { for (uint i=0; i < section_count; i++) { if (s->_64) { if (macho_valid_section(s) && addr >= s->s64.vmaddr && addr < s->s64.vmaddr + s->s64.vmsize) { return true; } } else { if (macho_valid_section(s) && addr >= s->s.vmaddr && addr < s->s.vmaddr + s->s.vmsize) { return true; } } s++; } return false; } /* * offset conversion routines */ bool macho_ofs_to_addr(MACHO_SECTION_U *s, uint section_count, FileOfs ofs, MACHOAddress *addr) { for (uint i=0; i < section_count; i++) { if (s->_64) { if (macho_phys_and_mem_section(s) && ofs >= s->s64.fileoff && ofs < s->s64.fileoff+s->s64.vmsize) { *addr = ofs - s->s64.fileoff + s->s64.vmaddr; return true; } } else { if (macho_phys_and_mem_section(s) && ofs >= s->s.fileoff && ofs < s->s.fileoff+s->s.vmsize) { *addr = ofs - s->s.fileoff + s->s.vmaddr; return true; } } s++; } return false; } bool macho_ofs_to_section(MACHO_SECTION_U *s, uint section_count, FileOfs ofs, int *section) { for (uint i=0; i < section_count; i++) { if (s->_64) { if (macho_valid_section(s) && ofs >= s->s64.fileoff && ofs < s->s64.fileoff+s->s64.vmsize) { *section = i; return true; } } else { if (macho_valid_section(s) && ofs >= s->s.fileoff && ofs < s->s.fileoff+s->s.vmsize) { *section = i; return true; } } s++; } return false; } ht-2.0.22/hthist.h0000644000175000001440000000370510615341620010604 00000000000000/* * HT Editor * hthist.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef HTHIST_H #define HTHIST_H #include "htobj.h" #include "store.h" #include "tools.h" /* * histories */ #define HISTATOM_GOTO MAGIC32("HIS\x80") #define HISTATOM_FILE MAGIC32("HIS\x81") #define HISTATOM_SEARCH_BIN MAGIC32("HIS\x82") #define HISTATOM_SEARCH_EVALSTR MAGIC32("HIS\x83") #define HISTATOM_SEARCH_VREGEX MAGIC32("HIS\x84") #define HISTATOM_SEARCH_EXPR MAGIC32("HIS\x85") #define HISTATOM_ASSEMBLER MAGIC32("HIS\x86") #define HISTATOM_NAME_ADDR MAGIC32("HIS\x87") #define HISTATOM_EVAL_EXPR MAGIC32("HIS\x88") /* * CLASS ht_history_entry */ class ht_history_entry: public Object { public: char *desc; ObjectStreamBin *data; MemoryFile *datafile; ht_history_entry(char *str=0, ObjectStreamBin *data = NULL, MemoryFile *datafile = NULL); ht_history_entry(BuildCtorArg &a): Object(a) {}; ~ht_history_entry(); /* overwritten */ virtual int compareTo(const Object *) const; virtual void load(ObjectStream &s); virtual void store(ObjectStream &s) const; virtual ObjectID getObjectID() const; }; bool insert_history_entry(List *history, char *name, ht_view *view); void store_history(ObjectStream &s); bool load_history(ObjectStream &s); /* * INIT */ bool init_hist(); /* * DONE */ void done_hist(); #endif /* HTHIST_H */ ht-2.0.22/httree.h0000644000175000017500000000622012127651420010575 00000000000000/* * HT Editor * httree.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef HT_TREE #define HT_TREE #include "data.h" #include "htobj.h" #include "io/types.h" struct ht_treeview_data { DDECL_PTR(void, selected); }; class ht_treeview: public ht_view { public: int delta_x, delta_y; int maxsize_x, maxsize_y; int foc; void *selected; void init(Bounds *b, const char *desc); virtual void done(); virtual void adjust(void *node, bool expand) = 0; int create_graph(AbstractChar *s, void *node, int level, int lines, int width, int endwidth, const AbstractChar *Chars); void collapse_all(void *node); virtual int count_children(void *node); virtual void draw(); void draw_r(void *node, int level, int *pos, uint32 lines); void expand_all(void *node); virtual void *get_child(void *node, int i) = 0; virtual void getdata(ObjectStream &s); virtual int get_graph(AbstractChar *s, void *node, int level, int lines); virtual void *get_next_node(void *node) = 0; void *get_node(int i); void *get_node_r(void *node, int *i); virtual void *get_prev_node(void *node) = 0; virtual void *get_root() = 0; virtual char *get_text(void *node) = 0; virtual void handlemsg(htmsg *msg); virtual bool has_children(void *node) = 0; virtual void has_focused(int i); virtual bool is_expanded(void *node) = 0; virtual bool is_selected(int i); void scroll_to(int x, int y); virtual void select_node(void *node); // stub virtual void setdata(ObjectStream &s); void set_limit(int x, int y); void update(); void update_r(void *node, int level, int *pos, int *x); private: void adjust_focus(int Focus); }; struct static_node { static_node *next, *prev, *child; char *text; bool expanded; Object *data; }; class ht_static_treeview: public ht_treeview { public: static_node *root; void init(Bounds *b, const char *desc); virtual void done(); void *add_child(void *node, const char *text, Object *Data=NULL); void *add_node(static_node **node, const char *text, Object *Data=NULL); virtual void adjust(void *node, bool expand); static_node *create_node(const char *text, static_node *prev, Object *Data=NULL); virtual void *get_child(void *node, int i); virtual void *get_next_node(void *node); virtual void *get_prev_node(void *node); virtual void *get_root(); virtual char *get_text(void *node); virtual bool has_children(void *node); virtual bool is_expanded(void *node); virtual void select_node(void *node); /* new */ void *get_cursor_node(); void goto_node(void *node); }; #endif ht-2.0.22/configure.in0000644000175000017500000001576712127657370011474 00000000000000dnl Process this file with autoconf to produce a configure script. AC_INIT(ht,[2.0.22],[https://sourceforge.net/tracker/?group_id=1066]) AC_PREREQ(2.59) dnl Check the system. AC_CANONICAL_SYSTEM AC_ARG_ENABLE(x11-textmode, [ --enable-x11-textmode build with x11 textmode support [default=yes]],,enable_x11_textmode="yes") AC_ARG_ENABLE(maintainermode, [ --enable-maintainermode minimise autodetection for package mantainers [default=no]],,enable_maintainermode="no") AC_ARG_ENABLE(release, [ --enable-release make a release build [default=yes]],,enable_release="yes") AC_ARG_ENABLE(profiling, [ --enable-profiling make a profile build [default=no]],,enable_profiling="no") # Certain flags that shall always be present even if user does make CFLAGS="" my_CPPFLAGS="-DNOMACROS" my_CFLAGS="-Wall -fsigned-char" my_CXXFLAGS="-Wall -Woverloaded-virtual -Wnon-virtual-dtor -fsigned-char" if test "x$enable_maintainermode" = "xno"; then if test "x$enable_release" = "xyes"; then default_user_CFLAGS="-O3 -Wall -fomit-frame-pointer" else default_user_CFLAGS="-ggdb3 -O0 -Wall" fi if test "x$enable_profiling" = "xyes"; then default_user_CFLAGS="$default_user_CFLAGS -pg -g" fi fi CFLAGS="$default_user_CFLAGS" CXXFLAGS="$default_user_CFLAGS" AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_HEADERS([config.h]) dnl Check OS specifica NEED_CURSES=0 HAVE_PIPE=0 HT_X11BASE="-L/usr/X11/lib -L/usr/X11R6/lib" case "$target_os" in linux*) IO_DIR=posix echo "*** LINUX, building POSIX version. we need (n)curses." 1>&2 NEED_CURSES=1 HAVE_PIPE=1 HT_LIBS="$HT_LIBS -lm" my_CPPFLAGS="$my_CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" ;; *freebsd*) IO_DIR=posix echo "*** FREEBSD, building native FreeBSD version. we need (n)curses." 1>&2 NEED_CURSES=1 HAVE_PIPE=1 my_CPPFLAGS="$my_CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" ;; *openbsd*) IO_DIR=posix echo "*** OpenBSD, building native OpenBSD version. we need (n)curses." 1>&2 NEED_CURSES=1 HAVE_PIPE=1 HT_X11BASE="-L${X11BASE}/lib" my_CPPFLAGS="$my_CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" ;; cygwin*) IO_DIR=win32 echo "*** CYGWIN, building native Win32 version (no cygwin.dll)" 1>&2 my_CFLAGS="$my_CFLAGS -mno-cygwin" NEED_CURSES=0 HAVE_PIPE=1 ;; mingw32*) IO_DIR=win32 echo "*** MINGW32, building native Win32 version" 1>&2 HT_LDFLAGS="$HT_LDFLAGS -static-libgcc -static-libstdc++" NEED_CURSES=0 HAVE_PIPE=1 ;; *) echo "configure: warning: $target_os: unknown target OS, assuming POSIX-compatible..." 1>&2 IO_DIR=posix echo "*** POSIX-generic, we need (n)curses, '-pipe' disabled for safety" 1>&2 NEED_CURSES=1 HAVE_PIPE=0 my_CPPFLAGS="$my_CPPFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" ;; esac if test "x$HAVE_PIPE" = "x1"; then my_CFLAGS="$my_CFLAGS -pipe"; fi AC_DEFINE_UNQUOTED(SYSTEM_OSAPI_SPECIFIC_TYPES_HDR, "io/$IO_DIR/types.h", [Location of io/$IO_DIR/types.h]) AM_CONDITIONAL(USE_POSIX_DIR, test x$IO_DIR = xposix) AM_CONDITIONAL(USE_DJGPP_DIR, test x$IO_DIR = xdjgpp) AM_CONDITIONAL(USE_WIN32_DIR, test x$IO_DIR = xwin32) dnl Checks for programs. AC_PROG_RANLIB AC_PATH_PROGS(MAKE, gmake make, :) AC_PROG_MAKE_SET AC_PROG_CC AC_PROG_CPP AC_PROG_CXX AC_PROG_YACC AM_PROG_LEX AC_PATH_PROG(AR, ar) AC_PATH_PROG(AR, gar) if test "x$AR" = "x"; then AC_MSG_ERROR([*** 'ar' and 'gar' missing, please install one of them or fix your \$PATH ***]) fi if test "x$enable_maintainermode" = "xno"; then if test "${GXX}" = yes; then gxx_version=`${CXX} -v 2>&1 | grep "^.*g.. version" | \\ sed -e 's/^.*g.. version *//'` case ${gxx_version} in 1.*|2.*|3.*|4.0|4.1|4.2|4.3) ;; *) dnl my_CXXFLAGS="$my_CXXFLAGS -march=native" dnl my_CFLAGS="$my_CFLAGS -march=native" ;; esac fi fi dnl Checks for libraries. minilzo_enabled=no AC_ARG_WITH(included-lzo, AS_HELP_STRING([--with-included-lzo], [use included minilzo]), minilzo_enabled=$withval, minilzo_enabled=no) AC_MSG_CHECKING([whether to use the included lzo compression library]) AC_MSG_RESULT($minilzo_enabled) LZO_LIBS= if test "$minilzo_enabled" != "yes"; then AC_CHECK_LIB(lzo2, lzo1x_1_compress, LZO_LIBS=-llzo2) if test "$LZO_LIBS" = ""; then AC_CHECK_LIB(lzo, lzo1x_1_compress, LZO_LIBS=-llzo, [ minilzo_enabled=yes AC_MSG_WARN( *** *** Could not find liblzo or liblzo2. Will use the included minilzo. ) ]) fi fi AC_SUBST(LZO_LIBS) if test "$LZO_LIBS" = "-llzo"; then AC_CHECK_HEADERS(lzo1x.h) elif test "$LZO_LIBS" = "-llzo2"; then AC_CHECK_HEADERS(lzo/lzo1x.h) fi if test "$minilzo_enabled" = "yes"; then AC_DEFINE(USE_MINILZO, 1, [whether to use the included minilzo]) fi AM_CONDITIONAL(USE_LZO, test "$use_lzo" = "yes") AM_CONDITIONAL(ENABLE_INCLUDED_LZO, test "$minilzo_enabled" = "yes") HAVE_X11=0 if test "x$enable_x11_textmode" = "xyes"; then TEMP_LDFLAGS=$LDFLAGS LDFLAGS="$HT_LDFLAGS $HT_X11BASE" AC_CHECK_LIB(X11, XOpenDisplay, HAVE_X11=1) LDFLAGS=$TEMP_LDFLAGS if test "x$HAVE_X11" = "x1"; then AC_DEFINE(HAVE_TEXTMODE_X11, 1, [This system has Xlib support and we shall use it]) HT_LIBS="$HT_LIBS -lX11" HT_LDFLAGS="$HT_LDFLAGS $HT_X11BASE" fi fi dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([stdlib.h]) AC_CHECK_HEADERS([string.h]) AC_CHECK_HEADERS([stdint.h]) dnl AC_CONFIG_HEADER(config.h) CURSES_LIB= if test "x$NEED_CURSES" = "x1"; then AC_CHECK_PROGS([ncurses_config], [ncursesw6-config ncursesw5-config ncurses6-config ncurses5-config]) if test "x$ncurses_config" != "x"; then curses_CPPFLAGS="$($ncurses_config --cflags)" curses_LIBS="$($ncurses_config --libs)" AC_DEFINE([CURSES_HDR], [], [This system provides ncurses.h]) else AC_SEARCH_LIBS([initscr], [ncursesw ncurses curses], [curses_LIBS="$LIBS"; LIBS=""]) AC_CHECK_HEADERS([curses.h], [AC_DEFINE([CURSES_HDR], [], [This system provides curses.h])]) AC_CHECK_HEADERS([ncurses.h], [AC_DEFINE([CURSES_HDR], [], [This system provides ncurses.h])]) fi if test "x$curses_LIBS" = "x"; then AC_MSG_ERROR([*** (n)curses.h needed ***]) fi AC_SUBST([curses_CPPFLAGS]) AC_SUBST([curses_LIBS]) fi dnl Makefile vars. AC_SUBST(IO_DIR) AC_SUBST(HT_LDFLAGS) AC_SUBST(HT_LIBS) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_CHECK_SIZEOF(char, 1) AC_CHECK_SIZEOF(short, 2) AC_CHECK_SIZEOF(int, 4) AC_CHECK_SIZEOF(long int, 4) dnl Checks for library functions. AC_CHECK_FUNCS(asinh acosh atanh) AC_OUTPUT([ Makefile analyser/Makefile asm/Makefile doc/Makefile eval/Makefile info/Makefile io/Makefile io/posix/Makefile io/djgpp/Makefile io/win32/Makefile minilzo/Makefile output/Makefile tools/Makefile ]) echo 1>&2 echo "$0 successful." 1>&2 echo 1>&2 echo "=====================" 1>&2 echo "Configuration summary" 1>&2 echo "=====================" 1>&2 echo 1>&2 if test "x$HAVE_X11" = "x1"; then echo "X11 textmode support available: yes" 1>&2 else echo "X11 textmode support available: no" 1>&2 fi echo "enable profiling: $enable_profiling" 1>&2 echo "make a release build: $enable_release" 1>&2 echo "using included minilzo: $minilzo_enabled" 1>&2 ht-2.0.22/cstream.h0000644000175000001440000000247110615341616010743 00000000000000/* * HT Editor * cstream.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __CSTREAM_H__ #define __CSTREAM_H__ #include "io/types.h" #include "stream.h" /* * NEVER use ht_compressed_stream for both reading and writing! */ #define COMPRESSED_STREAM_DEFAULT_GRANULARITY 10240 class CompressedStream: public StreamLayer { protected: byte *buffer; uint buffersize; uint bufferpos; public: CompressedStream(Stream *stream, bool own_stream); virtual ~CompressedStream(); /* overwritten */ virtual uint read(void *buf, uint size); virtual uint write(const void *buf, uint size); protected: void flush_compressed(); void flush_uncompressed(); }; #endif ht-2.0.22/htmzimg.cc0000644000175000001440000000403210615341620011110 00000000000000/* * HT Editor * htmzimg.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "htdisasm.h" #include "htmz.h" #include "htmzimg.h" #include "htpal.h" #include "strtools.h" #include "htformat.h" #include "formats.h" #include "snprintf.h" #include "x86asm.h" #include "x86dis.h" static ht_view *htmzimage_init(Bounds *b, File *file, ht_format_group *group) { ht_mz_shared_data *mz_shared=(ht_mz_shared_data *)group->get_shared_data(); x86asm *assembler=new x86asm(X86_OPSIZE16, X86_ADDRSIZE16); x86dis *disassembler=new x86dis(X86_OPSIZE16, X86_ADDRSIZE16); FileOfs o = mz_shared->header.header_size*16; ht_disasm_viewer *v=new ht_disasm_viewer(); v->init(b, DESC_MZ_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, assembler, disassembler, 1); ht_mask_sub *m=new ht_mask_sub(); m->init(file, 0); char info[128]; ht_snprintf(info, sizeof info, "* MZ image at offset 0x%08qx", o); m->add_mask(info); v->insertsub(m); ht_disasm_sub *d=new ht_disasm_sub(); d->init(file, o, (mz_shared->header.sizep-1)*512+ mz_shared->header.sizelp, disassembler, false, X86DIS_STYLE_OPTIMIZE_ADDR); v->insertsub(d); v->sendmsg(msg_complete_init, 0); viewer_pos p; v->clear_viewer_pos(&p); p.u.sub = d; p.u.tag_idx = 0; if (d->convert_ofs_to_id(o+mz_shared->header.cs*16+ mz_shared->header.ip, &p.u.line_id)) { v->goto_pos(p, false); } return v; } format_viewer_if htmzimage_if = { htmzimage_init, 0 }; ht-2.0.22/htreg.cc0000644000175000017500000012553012127651417010565 00000000000000/* * HT Editor * htreg.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "defreg.h" #include "atom.h" #include "htctrl.h" #include "htdialog.h" #include "htiobox.h" #include "htpal.h" #include "htreg.h" #include "log.h" #include "snprintf.h" #include "store.h" #include "tools.h" ht_registry *registry; #define ATOM_HT_REGISTRY MAGIC32("REG\x00") #define ATOM_HT_REGISTRY_NODE MAGIC32("REG\x01") #define ATOM_HT_REGISTRY_DATA_STREE MAGIC32("REG\x02") #define ATOM_HT_REGISTRY_DATA_DWORD MAGIC32("REG\x03") #define ATOM_HT_REGISTRY_DATA_RAW MAGIC32("REG\x04") #define ATOM_HT_REGISTRY_DATA_STRING MAGIC32("REG\x05") #define ATOM_HT_REGISTRY_NODE_TYPE_DESC MAGIC32("REG\x10") #define ATOM_HT_CREATE_EMPTY_SUBDIR MAGIC32("REG\x20") #define ATOM_HT_CREATE_EMPTY_SYMLINK MAGIC32("REG\x21") #define ATOM_HT_CREATE_EMPTY_DWORD MAGIC32("REG\x22") #define ATOM_HT_CREATE_EMPTY_STRING MAGIC32("REG\x23") #define ATOM_HT_CREATE_EMPTY_RAW MAGIC32("REG\x24") #define GENERATE_NEW_REGISTRY 0 /* * CLASS ht_registry_data */ bool ht_registry_data::editdialog(const char *keyname) { return false; } void ht_registry_data::strvalue(char *buf32bytes) { strcpy(buf32bytes, ""); } /* * CLASS ht_registry_data_stree */ ht_registry_data_stree::ht_registry_data_stree(AVLTree *t) { tree = t; } ht_registry_data_stree::~ht_registry_data_stree() { delete tree; } void ht_registry_data_stree::load(ObjectStream &f) { GET_OBJECT(f, tree); } ObjectID ht_registry_data_stree::getObjectID() const { return ATOM_HT_REGISTRY_DATA_STREE; } void ht_registry_data_stree::store(ObjectStream &f) const { PUT_OBJECT(f, tree); } void ht_registry_data_stree::strvalue(char *buf32bytes) { *buf32bytes = 0; } /* * CLASS ht_registry_data_dword */ ht_registry_data_dword::ht_registry_data_dword(uint32 v) { value = v; } bool ht_registry_data_dword::editdialog(const char *keyname) { // FIXME: use eval instead of strtol char result[32]; ht_snprintf(result, sizeof result, "%d", value); if (inputbox("edit dword", "number", result, sizeof result, 0)==button_ok) { char *r; int i = (int)strtol(result, &r, 10); if (*r == 0) { value = i; return true; } } return false; } void ht_registry_data_dword::load(ObjectStream &f) { GET_INT32X(f, value); } ObjectID ht_registry_data_dword::getObjectID() const { return ATOM_HT_REGISTRY_DATA_DWORD; } void ht_registry_data_dword::store(ObjectStream &f) const { PUT_INT32X(f, value); } void ht_registry_data_dword::strvalue(char *buf32bytes) { ht_snprintf(buf32bytes, 32, "%d", value); } /* * CLASS ht_registry_data_raw */ ht_registry_data_raw::ht_registry_data_raw(const void *v, uint s) { size = s; if (size) { value = malloc(s); memcpy(value, v, s); } else { value = 0; } } ht_registry_data_raw::~ht_registry_data_raw() { free(value); } bool ht_registry_data_raw::editdialog(const char *keyname) { bool r = false; Bounds b; b.w = 50; b.h = 15; b.x = (screen->w-b.w)/2; b.y = (screen->h-b.h)/2; ht_dialog *d = new ht_dialog(); d->init(&b, "edit data_raw", FS_TITLE | FS_KILLER); if (d->run(false)) { r = true; } d->done(); delete d; return r; } void ht_registry_data_raw::load(ObjectStream &f) { GET_INT32D(f, size); GET_BINARY(f, value, size); } ObjectID ht_registry_data_raw::getObjectID() const { return ATOM_HT_REGISTRY_DATA_RAW; } void ht_registry_data_raw::store(ObjectStream &f) const { PUT_INT32D(f, size); PUT_BINARY(f, value, size); } void ht_registry_data_raw::strvalue(char *buf32bytes) { strcpy(buf32bytes, "raw"); } /* * CLASS ht_registry_data_string */ ht_registry_data_string::ht_registry_data_string(const char *s) { value = ht_strdup(s); } ht_registry_data_string::~ht_registry_data_string() { free(value); } bool ht_registry_data_string::editdialog(const char *keyname) { char res[256]; ht_strlcpy(res, value, sizeof res); if (inputbox("edit string", "string", res, sizeof res, 0)) { free(value); value = strdup(res); return true; } return false; } void ht_registry_data_string::load(ObjectStream &f) { GET_STRING(f, value); } ObjectID ht_registry_data_string::getObjectID() const { return ATOM_HT_REGISTRY_DATA_STRING; } void ht_registry_data_string::store(ObjectStream &f) const { PUT_STRING(f, value); } void ht_registry_data_string::strvalue(char *buf32bytes) { ht_strlcpy(buf32bytes, value, 32); } /* * CLASS ht_registry_node */ ht_registry_node::ht_registry_node(ht_registry_node_type aType, const char *aName, ht_registry_data *aData) { type = aType; name = ht_strdup(aName); data = aData; } ht_registry_node::~ht_registry_node() { if (data) { data->done(); delete data; } free(name); } int ht_registry_node::compareTo(const Object *o) const { return strcmp(name, ((ht_registry_node*)o)->name); } void ht_registry_node::load(ObjectStream &f) { GET_INT32X(f, type); GET_STRING(f, name); GET_OBJECT(f, data); } void ht_registry_node::store(ObjectStream &f) const { PUT_INT32X(f, type); PUT_STRING(f, name); PUT_OBJECT(f, data); } ObjectID ht_registry_node::getObjectID() const { return ATOM_HT_REGISTRY_NODE; } /* * create_empty_* */ ht_registry_data *create_empty_symlink() { return new ht_registry_data_string(""); } ht_registry_data *create_empty_dword() { return new ht_registry_data_dword(0); } ht_registry_data *create_empty_string() { return new ht_registry_data_string(""); } ht_registry_data *create_empty_raw() { return new ht_registry_data_raw(NULL, 0); } /* * CLASS ht_registry */ ht_registry_node_type_desc::ht_registry_node_type_desc(ht_registry_node_type aType, const char *aName, create_empty_registry_data_func c) { type = aType; name = ht_strdup(aName); create_empty_registry_data = c; } ht_registry_node_type_desc::~ht_registry_node_type_desc() { free(name); } int ht_registry_node_type_desc::compareTo(const Object *d) const { return strcmp(name, ((ht_registry_node_type_desc*)d)->name); } void ht_registry_node_type_desc::load(ObjectStream &f) { GET_INT32D(f, type); GET_STRING(f, name); uint atom; GET_INT32X(f, atom); void *p = getAtomValue(atom); create_empty_registry_data=(create_empty_registry_data_func)p; } ObjectID ht_registry_node_type_desc::getObjectID() const { return ATOM_HT_REGISTRY_NODE_TYPE_DESC; } void ht_registry_node_type_desc::store(ObjectStream &f) const { PUT_INT32D(f, type); PUT_STRING(f, name); uint atom = getAtomId((void*)create_empty_registry_data); PUT_INT32X(f, atom); } ht_registry_data *create_empty_palette_entry(); void ht_registry::init() { #if GENERATE_NEW_REGISTRY // build registry root AVLTree *s = new AVLTree(true); root = new ht_registry_node(RNT_SUBDIR, "/", new ht_registry_data_stree(s)); AVLTree *config = new AVLTree(true); AVLTree *palette = new AVLTree(true); s->insert(new ht_registry_node(RNT_SUBDIR, "config", new ht_registry_data_stree(config))); s->insert(new ht_registry_node(RNT_SUBDIR, "palette", new ht_registry_data_stree(palette))); AVLTree *config_misc = new AVLTree(true); AVLTree *config_editor = new AVLTree(true); config->insert(new ht_registry_node(RNT_SUBDIR, "misc", new ht_registry_data_stree(config_misc))); config_misc->insert(new ht_registry_node(RNT_DWORD, "config format", new ht_registry_data_dword(2))); config_misc->insert(new ht_registry_node(RNT_STRING, "statusline", new ht_registry_data_string("%a %L %t %d"))); config_misc->insert(new ht_registry_node(RNT_STRING, "vfs display format", new ht_registry_data_string("type,name:20+,|,desc,|,bsize,|,perm,|,rmtime"))); config->insert(new ht_registry_node(RNT_SUBDIR, "editor", new ht_registry_data_stree(config_editor))); config_editor->insert(new ht_registry_node(RNT_STRING, "EOF", new ht_registry_data_string(""))); config_editor->insert(new ht_registry_node(RNT_STRING, "EOL", new ht_registry_data_string("."))); config_editor->insert(new ht_registry_node(RNT_DWORD, "auto indent", new ht_registry_data_dword(1))); config_editor->insert(new ht_registry_node(RNT_DWORD, "scroll offset", new ht_registry_data_dword(3))); config_editor->insert(new ht_registry_node(RNT_DWORD, "tab size", new ht_registry_data_dword(8))); AVLTree *palette_analyser = new AVLTree(true); AVLTree *palette_generic = new AVLTree(true); AVLTree *palette_syntax = new AVLTree(true); AVLTree *palette_tags = new AVLTree(true); palette->insert(new ht_registry_node(RNT_SUBDIR, "analyser", new ht_registry_data_stree(palette_analyser))); AVLTree *analyser_default = new AVLTree(true); palette_analyser->insert(new ht_registry_node(RNT_SUBDIR, "default", new ht_registry_data_stree(analyser_default))); analyser_default->insert(new ht_registry_node(256, "default", new palette_entry(0, 33288))); analyser_default->insert(new ht_registry_node(256, "comment", new palette_entry(0, 1800))); analyser_default->insert(new ht_registry_node(256, "label", new palette_entry(0, 34312))); analyser_default->insert(new ht_registry_node(256, "number", new palette_entry(0, 776))); analyser_default->insert(new ht_registry_node(256, "string", new palette_entry(0, 33800))); analyser_default->insert(new ht_registry_node(256, "symbol-character", new palette_entry(0, 33544))); palette->insert(new ht_registry_node(RNT_SUBDIR, "generic", new ht_registry_data_stree(palette_generic))); AVLTree *palette_generic_black = new AVLTree(true); AVLTree *palette_generic_blue = new AVLTree(true); AVLTree *palette_generic_cyan = new AVLTree(true); AVLTree *palette_generic_gray = new AVLTree(true); AVLTree *palette_generic_gray2 = new AVLTree(true); palette_generic->insert(new ht_registry_node(RNT_SYMLINK, "desktop", new ht_registry_data_string("black"))); palette_generic->insert(new ht_registry_node(RNT_SYMLINK, "dialog", new ht_registry_data_string("gray"))); palette_generic->insert(new ht_registry_node(RNT_SYMLINK, "help", new ht_registry_data_string("cyan"))); palette_generic->insert(new ht_registry_node(RNT_SYMLINK, "keyline", new ht_registry_data_string("black"))); palette_generic->insert(new ht_registry_node(RNT_SYMLINK, "menu", new ht_registry_data_string("gray2"))); palette_generic->insert(new ht_registry_node(RNT_SYMLINK, "special", new ht_registry_data_string("cyan"))); palette_generic->insert(new ht_registry_node(RNT_SYMLINK, "window", new ht_registry_data_string("blue"))); palette_generic->insert(new ht_registry_node(RNT_SUBDIR, "black", new ht_registry_data_stree(palette_generic_black))); palette_generic->insert(new ht_registry_node(RNT_SUBDIR, "blue", new ht_registry_data_stree(palette_generic_blue))); palette_generic->insert(new ht_registry_node(RNT_SUBDIR, "cyan", new ht_registry_data_stree(palette_generic_cyan))); palette_generic->insert(new ht_registry_node(RNT_SUBDIR, "gray", new ht_registry_data_stree(palette_generic_gray))); palette_generic->insert(new ht_registry_node(RNT_SUBDIR, "gray2", new ht_registry_data_stree(palette_generic_gray2))); // black palette_generic_black->insert(new ht_registry_node(256, "body", new palette_entry(0, 1792))); palette_generic_black->insert(new ht_registry_node(256, "text focused", new palette_entry(0, 3))); palette_generic_black->insert(new ht_registry_node(256, "text unfocused", new palette_entry(0, 8))); palette_generic_black->insert(new ht_registry_node(256, "text shortcut", new palette_entry(0, 1792))); palette_generic_black->insert(new ht_registry_node(256, "text shortcut selected", new palette_entry(0, 34312))); palette_generic_black->insert(new ht_registry_node(256, "text selected", new palette_entry(0, 0))); palette_generic_black->insert(new ht_registry_node(256, "text disabled", new palette_entry(0, 1795))); palette_generic_black->insert(new ht_registry_node(256, "frame focused", new palette_entry(0, 1800))); palette_generic_black->insert(new ht_registry_node(256, "frame unfocused", new palette_entry(0, 1800))); palette_generic_black->insert(new ht_registry_node(256, "frame move-resize", new palette_entry(0, 33288))); palette_generic_black->insert(new ht_registry_node(256, "frame killer", new palette_entry(0, 520))); palette_generic_black->insert(new ht_registry_node(256, "scrollbar", new palette_entry(0, 7))); palette_generic_black->insert(new ht_registry_node(256, "input focused", new palette_entry(0, 34561))); palette_generic_black->insert(new ht_registry_node(256, "input unfocused", new palette_entry(0, 34561))); palette_generic_black->insert(new ht_registry_node(256, "input selected", new palette_entry(0, 34562))); palette_generic_black->insert(new ht_registry_node(256, "input clip-chars", new palette_entry(0, 33281))); palette_generic_black->insert(new ht_registry_node(256, "button focused", new palette_entry(0, 34562))); palette_generic_black->insert(new ht_registry_node(256, "button unfocused", new palette_entry(0, 2))); palette_generic_black->insert(new ht_registry_node(256, "button shadow", new palette_entry(0, 8))); palette_generic_black->insert(new ht_registry_node(256, "button shortcut", new palette_entry(0, 0))); palette_generic_black->insert(new ht_registry_node(256, "list focused & selected", new palette_entry(0, 34561))); palette_generic_black->insert(new ht_registry_node(256, "list focused & unselected", new palette_entry(0, 1792))); palette_generic_black->insert(new ht_registry_node(256, "list unfocused & selected", new palette_entry(0, 34560))); palette_generic_black->insert(new ht_registry_node(256, "list unfocused & unselected", new palette_entry(0, 0))); palette_generic_black->insert(new ht_registry_node(256, "cluster focused", new palette_entry(0, 34563))); palette_generic_black->insert(new ht_registry_node(256, "cluster unfocused", new palette_entry(0, 3))); palette_generic_black->insert(new ht_registry_node(256, "cluster shortcut", new palette_entry(0, 34307))); // blue palette_generic_blue->insert(new ht_registry_node(256, "body", new palette_entry(0, 769))); palette_generic_blue->insert(new ht_registry_node(256, "text focused", new palette_entry(0, 34305))); palette_generic_blue->insert(new ht_registry_node(256, "text unfocused", new palette_entry(0, 34561))); palette_generic_blue->insert(new ht_registry_node(256, "text shortcut", new palette_entry(0, 1))); palette_generic_blue->insert(new ht_registry_node(256, "text shortcut selected", new palette_entry(0, 1))); palette_generic_blue->insert(new ht_registry_node(256, "text selected", new palette_entry(0, 257))); palette_generic_blue->insert(new ht_registry_node(256, "text disabled", new palette_entry(0, 34305))); palette_generic_blue->insert(new ht_registry_node(256, "frame focused", new palette_entry(0, 34568))); palette_generic_blue->insert(new ht_registry_node(256, "frame unfocused", new palette_entry(0, 1800))); palette_generic_blue->insert(new ht_registry_node(256, "frame move-resize", new palette_entry(0, 33288))); palette_generic_blue->insert(new ht_registry_node(256, "frame killer", new palette_entry(0, 33288))); palette_generic_blue->insert(new ht_registry_node(256, "scrollbar", new palette_entry(0, 259))); palette_generic_blue->insert(new ht_registry_node(256, "input focused", new palette_entry(0, 34561))); palette_generic_blue->insert(new ht_registry_node(256, "input unfocused", new palette_entry(0, 34561))); palette_generic_blue->insert(new ht_registry_node(256, "input selected", new palette_entry(0, 33031))); palette_generic_blue->insert(new ht_registry_node(256, "input clip-chars", new palette_entry(0, 33281))); palette_generic_blue->insert(new ht_registry_node(256, "button focused", new palette_entry(0, 34562))); palette_generic_blue->insert(new ht_registry_node(256, "button unfocused", new palette_entry(0, 2))); palette_generic_blue->insert(new ht_registry_node(256, "button shadow", new palette_entry(0, 8))); palette_generic_blue->insert(new ht_registry_node(256, "button shortcut", new palette_entry(0, 34312))); palette_generic_blue->insert(new ht_registry_node(256, "list focused & selected", new palette_entry(0, 34563))); palette_generic_blue->insert(new ht_registry_node(256, "list focused & unselected", new palette_entry(0, 769))); palette_generic_blue->insert(new ht_registry_node(256, "list unfocused & selected", new palette_entry(0, 3))); palette_generic_blue->insert(new ht_registry_node(256, "list unfocused & unselected", new palette_entry(0, 769))); palette_generic_blue->insert(new ht_registry_node(256, "cluster focused", new palette_entry(0, 34563))); palette_generic_blue->insert(new ht_registry_node(256, "cluster unfocused", new palette_entry(0, 0))); palette_generic_blue->insert(new ht_registry_node(256, "cluster shortcut", new palette_entry(0, 0))); // cyan palette_generic_cyan->insert(new ht_registry_node(256, "body", new palette_entry(0, 3))); palette_generic_cyan->insert(new ht_registry_node(256, "text focused", new palette_entry(0, 8))); palette_generic_cyan->insert(new ht_registry_node(256, "text unfocused", new palette_entry(0, 8))); palette_generic_cyan->insert(new ht_registry_node(256, "text shortcut", new palette_entry(0, 34312))); palette_generic_cyan->insert(new ht_registry_node(256, "text shortcut selected", new palette_entry(0, 34305))); palette_generic_cyan->insert(new ht_registry_node(256, "text selected", new palette_entry(0, 8))); palette_generic_cyan->insert(new ht_registry_node(256, "text disabled", new palette_entry(0, 1792))); palette_generic_cyan->insert(new ht_registry_node(256, "frame focused", new palette_entry(0, 34568))); palette_generic_cyan->insert(new ht_registry_node(256, "frame unfocused", new palette_entry(0, 8))); palette_generic_cyan->insert(new ht_registry_node(256, "frame move-resize", new palette_entry(0, 33288))); palette_generic_cyan->insert(new ht_registry_node(256, "frame killer", new palette_entry(0, 33288))); palette_generic_cyan->insert(new ht_registry_node(256, "scrollbar", new palette_entry(0, 769))); palette_generic_cyan->insert(new ht_registry_node(256, "input focused", new palette_entry(0, 34561))); palette_generic_cyan->insert(new ht_registry_node(256, "input unfocused", new palette_entry(0, 34561))); palette_generic_cyan->insert(new ht_registry_node(256, "input selected", new palette_entry(0, 34562))); palette_generic_cyan->insert(new ht_registry_node(256, "input clip-chars", new palette_entry(0, 33281))); palette_generic_cyan->insert(new ht_registry_node(256, "button focused", new palette_entry(0, 34562))); palette_generic_cyan->insert(new ht_registry_node(256, "button unfocused", new palette_entry(0, 2))); palette_generic_cyan->insert(new ht_registry_node(256, "button shadow", new palette_entry(0, 8))); palette_generic_cyan->insert(new ht_registry_node(256, "button shortcut", new palette_entry(0, 34312))); palette_generic_cyan->insert(new ht_registry_node(256, "list focused & selected", new palette_entry(0, 34561))); palette_generic_cyan->insert(new ht_registry_node(256, "list focused & unselected", new palette_entry(0, 3))); palette_generic_cyan->insert(new ht_registry_node(256, "list unfocused & selected", new palette_entry(0, 34563))); palette_generic_cyan->insert(new ht_registry_node(256, "list unfocused & unselected", new palette_entry(0, 3))); palette_generic_cyan->insert(new ht_registry_node(256, "cluster focused", new palette_entry(0, 34563))); palette_generic_cyan->insert(new ht_registry_node(256, "cluster unfocused", new palette_entry(0, 3))); palette_generic_cyan->insert(new ht_registry_node(256, "cluster shortcut", new palette_entry(0, 34307))); // gray palette_generic_gray->insert(new ht_registry_node(256, "body", new palette_entry(0, 7))); palette_generic_gray->insert(new ht_registry_node(256, "text focused", new palette_entry(0, 34568))); palette_generic_gray->insert(new ht_registry_node(256, "text unfocused", new palette_entry(0, 8))); palette_generic_gray->insert(new ht_registry_node(256, "text shortcut", new palette_entry(0, 34312))); palette_generic_gray->insert(new ht_registry_node(256, "text shortcut selected", new palette_entry(0, 34312))); palette_generic_gray->insert(new ht_registry_node(256, "text selected", new palette_entry(0, 34561))); palette_generic_gray->insert(new ht_registry_node(256, "text disabled", new palette_entry(0, 32776))); palette_generic_gray->insert(new ht_registry_node(256, "frame focused", new palette_entry(0, 34568))); palette_generic_gray->insert(new ht_registry_node(256, "frame unfocused", new palette_entry(0, 8))); palette_generic_gray->insert(new ht_registry_node(256, "frame move-resize", new palette_entry(0, 33288))); palette_generic_gray->insert(new ht_registry_node(256, "frame killer", new palette_entry(0, 33288))); palette_generic_gray->insert(new ht_registry_node(256, "scrollbar", new palette_entry(0, 769))); palette_generic_gray->insert(new ht_registry_node(256, "input focused", new palette_entry(0, 34561))); palette_generic_gray->insert(new ht_registry_node(256, "input unfocused", new palette_entry(0, 34561))); palette_generic_gray->insert(new ht_registry_node(256, "input selected", new palette_entry(0, 34562))); palette_generic_gray->insert(new ht_registry_node(256, "input clip-chars", new palette_entry(0, 33281))); palette_generic_gray->insert(new ht_registry_node(256, "button focused", new palette_entry(0, 34562))); palette_generic_gray->insert(new ht_registry_node(256, "button unfocused", new palette_entry(0, 2))); palette_generic_gray->insert(new ht_registry_node(256, "button shadow", new palette_entry(0, 8))); palette_generic_gray->insert(new ht_registry_node(256, "button shortcut", new palette_entry(0, 34312))); palette_generic_gray->insert(new ht_registry_node(256, "list focused & selected", new palette_entry(0, 34562))); palette_generic_gray->insert(new ht_registry_node(256, "list focused & unselected", new palette_entry(0, 3))); palette_generic_gray->insert(new ht_registry_node(256, "list unfocused & selected", new palette_entry(0, 34563))); palette_generic_gray->insert(new ht_registry_node(256, "list unfocused & unselected", new palette_entry(0, 3))); palette_generic_gray->insert(new ht_registry_node(256, "cluster focused", new palette_entry(0, 34563))); palette_generic_gray->insert(new ht_registry_node(256, "cluster unfocused", new palette_entry(0, 3))); palette_generic_gray->insert(new ht_registry_node(256, "cluster shortcut", new palette_entry(0, 34307))); // gray2 palette_generic_gray2->insert(new ht_registry_node(256, "body", new palette_entry(0, 7))); palette_generic_gray2->insert(new ht_registry_node(256, "text focused", new palette_entry(0, 8))); palette_generic_gray2->insert(new ht_registry_node(256, "text unfocused", new palette_entry(0, 8))); palette_generic_gray2->insert(new ht_registry_node(256, "text shortcut", new palette_entry(0, 1032))); palette_generic_gray2->insert(new ht_registry_node(256, "text shortcut selected", new palette_entry(0, 1032))); palette_generic_gray2->insert(new ht_registry_node(256, "text selected", new palette_entry(0, 2))); palette_generic_gray2->insert(new ht_registry_node(256, "text disabled", new palette_entry(0, 1792))); palette_generic_gray2->insert(new ht_registry_node(256, "frame focused", new palette_entry(0, 8))); palette_generic_gray2->insert(new ht_registry_node(256, "frame unfocused", new palette_entry(0, 8))); palette_generic_gray2->insert(new ht_registry_node(256, "frame move-resize", new palette_entry(0, 33288))); palette_generic_gray2->insert(new ht_registry_node(256, "frame killer", new palette_entry(0, 33288))); palette_generic_gray2->insert(new ht_registry_node(256, "scrollbar", new palette_entry(0, 8))); palette_generic_gray2->insert(new ht_registry_node(256, "input focused", new palette_entry(0, 34561))); palette_generic_gray2->insert(new ht_registry_node(256, "input unfocused", new palette_entry(0, 34561))); palette_generic_gray2->insert(new ht_registry_node(256, "input selected", new palette_entry(0, 34562))); palette_generic_gray2->insert(new ht_registry_node(256, "input clip-chars", new palette_entry(0, 33281))); palette_generic_gray2->insert(new ht_registry_node(256, "button focused", new palette_entry(0, 34562))); palette_generic_gray2->insert(new ht_registry_node(256, "button unfocused", new palette_entry(0, 2))); palette_generic_gray2->insert(new ht_registry_node(256, "button shadow", new palette_entry(0, 8))); palette_generic_gray2->insert(new ht_registry_node(256, "button shortcut", new palette_entry(0, 34312))); palette_generic_gray2->insert(new ht_registry_node(256, "list focused & selected", new palette_entry(0, 34562))); palette_generic_gray2->insert(new ht_registry_node(256, "list focused & unselected", new palette_entry(0, 3))); palette_generic_gray2->insert(new ht_registry_node(256, "list unfocused & selected", new palette_entry(0, 34563))); palette_generic_gray2->insert(new ht_registry_node(256, "list unfocused & unselected", new palette_entry(0, 3))); palette_generic_gray2->insert(new ht_registry_node(256, "cluster focused", new palette_entry(0, 34563))); palette_generic_gray2->insert(new ht_registry_node(256, "cluster unfocused", new palette_entry(0, 3))); palette_generic_gray2->insert(new ht_registry_node(256, "cluster shortcut", new palette_entry(0, 0))); palette->insert(new ht_registry_node(RNT_SUBDIR, "syntax", new ht_registry_data_stree(palette_syntax))); AVLTree *c = new AVLTree(true); palette_syntax->insert(new ht_registry_node(RNT_SUBDIR, "c", new ht_registry_data_stree(c))); AVLTree *default1 = new AVLTree(true); c->insert(new ht_registry_node(RNT_SUBDIR, "default", new ht_registry_data_stree(default1))); default1->insert(new ht_registry_node(256, "whitespace", new palette_entry(0, 34312))); default1->insert(new ht_registry_node(256, "comment", new palette_entry(0, 1800))); default1->insert(new ht_registry_node(256, "identifier", new palette_entry(0, 34312))); default1->insert(new ht_registry_node(256, "reserved", new palette_entry(0, 34568))); default1->insert(new ht_registry_node(256, "integer number", new palette_entry(0, 34056))); default1->insert(new ht_registry_node(256, "float number", new palette_entry(0, 33032))); default1->insert(new ht_registry_node(256, "string", new palette_entry(0, 33544))); default1->insert(new ht_registry_node(256, "character", new palette_entry(0, 33544))); default1->insert(new ht_registry_node(256, "symbol", new palette_entry(0, 34568))); default1->insert(new ht_registry_node(256, "preprocess", new palette_entry(0, 33288))); default1->insert(new ht_registry_node(256, "meta", new palette_entry(0, 33032))); palette->insert(new ht_registry_node(RNT_SUBDIR, "tags", new ht_registry_data_stree(palette_tags))); AVLTree *tag_default = new AVLTree(true); palette_tags->insert(new ht_registry_node(RNT_SUBDIR, "default", new ht_registry_data_stree(tag_default))); tag_default->insert(new ht_registry_node(256, "edit-tag cursor select", new palette_entry(0, 34564))); tag_default->insert(new ht_registry_node(256, "edit-tag cursor edit", new palette_entry(0, 34564))); tag_default->insert(new ht_registry_node(256, "edit-tag cursor unfocused", new palette_entry(0, 34568))); tag_default->insert(new ht_registry_node(256, "edit-tag selected", new palette_entry(0, 32775))); tag_default->insert(new ht_registry_node(256, "edit-tag modified", new palette_entry(0, 33800))); tag_default->insert(new ht_registry_node(256, "edit-tag", new palette_entry(0, 1800))); tag_default->insert(new ht_registry_node(256, "sel-tag cursor focused", new palette_entry(0, 34563))); tag_default->insert(new ht_registry_node(256, "sel-tag cursor unfocused", new palette_entry(0, 3))); tag_default->insert(new ht_registry_node(256, "sel-tag", new palette_entry(0, 34568))); // build node_types tree node_types = new AVLTree(true); struct bla { const char *identifier; ht_registry_node_type type; create_empty_registry_data_func create_empty_registry_data; }; bla b[]= { {"subdir", RNT_SUBDIR, NULL}, {"symlink", RNT_SYMLINK, create_empty_symlink}, {"dword", RNT_DWORD, create_empty_dword}, {"string", RNT_STRING, create_empty_string}, {"raw", RNT_RAW, create_empty_raw}, }; for (uint i=0; iinsert(d); } ht_registry_node_type_desc *d=new ht_registry_node_type_desc( 256, "palette", create_empty_palette_entry); node_types->insert(d); #endif } void ht_registry::done() { delete node_types; delete root; } int ht_registry::create_node(const char *key, ht_registry_node_type type) { const char *name; ht_registry_node *m; if (!splitfind(key, &name, &m)) return EINVAL; if (!valid_nodename(name)) return EINVAL; ht_registry_node_type_desc *d = get_node_type_desc(type, NULL); if (d && d->create_empty_registry_data) { ht_registry_node t(0, name, NULL); if (((ht_registry_data_stree*)m->data)->tree->find(&t) != invObjHandle) return EEXIST; ht_registry_data *data = d->create_empty_registry_data(); ht_registry_node *n=new ht_registry_node(type, name, data); ((ht_registry_data_stree*)m->data)->tree->insert(n); return 0; } return ENOSYS; } int ht_registry::create_subdir(const char *key) { const char *name; ht_registry_node *m; if (!splitfind(key, &name, &m)) return EINVAL; if (!valid_nodename(name)) return EINVAL; AVLTree *s=new AVLTree(true); ht_registry_node *n=new ht_registry_node(RNT_SUBDIR, name, new ht_registry_data_stree(s)); bool ins; ((ht_registry_data_stree*)m->data)->tree->findOrInsert(n, ins); if (!ins) { delete n; return EEXIST; } return 0; } int ht_registry::delete_node(const char *key) { Container *dir; ht_registry_node *n = find_entry_i(&dir, key, false); if (!n) return ENOENT; const char *s = strrchr(key, '/'); if (s) s++; else s=key; ht_registry_node ss(0, s, NULL); return dir->delObj(&ss) ? 0 : ENOENT; } void ht_registry::debug_dump() { #if 0 // FILE *f=fopen("", ""); debug_dump_i(stderr, ((ht_registry_data_stree*)root->data)->tree, 0); // fclose(f); #endif } void ht_registry::debug_dump_i(FILE *f, Container *t, int ident) { #if 0 ht_data_string *key=NULL; ht_registry_node *n; while ((key=(ht_data_string*)t->enum_next((ht_data**)&n, key))) { for (int i=0; ivalue); switch (n->type) { case RNT_DWORD: fprintf(f, "= (uint32) %08d (%08x)\n", ((ht_data_dword*)n->data)->value, ((ht_data_dword*)n->data)->value); break; case RNT_STRING: fprintf(f, "= (string) \"%s\"\n", ((ht_data_string*)n->data)->value); break; case RNT_SYMLINK: fprintf(f, "=> \"%s\"\n", ((ht_data_string*)n->data)->value); break; case RNT_SUBDIR: fprintf(f, "{\n"); debug_dump_i(f, ((ht_registry_data_stree*)n->data)->tree, ident+1); for (int i=0; itype); if (!name) name = "?"; fprintf(f, "= ('%s'=%d)\n", name, n->type); break; } } } #endif } ht_registry_node *ht_registry::enum_next(const char *dir, ht_registry_node *prevkey) { rec_depth = 0; ht_registry_node *n = find_entry_i(NULL, dir, true); if (n) { if (n->type != RNT_SUBDIR) return NULL; Container *t = ((ht_registry_data_stree*)n->data)->tree; if (prevkey) { return (ht_registry_node *)t->get(t->findG(prevkey)); } else { return (ht_registry_node *)t->get(t->findFirst()); } } return NULL; } ht_registry_node *ht_registry::enum_prev(const char *dir, ht_registry_node *prevkey) { rec_depth = 0; ht_registry_node *n = find_entry_i(NULL, dir, true); if (n) { if (n->type != RNT_SUBDIR) return NULL; Container *t = ((ht_registry_data_stree*)n->data)->tree; if (prevkey) { return (ht_registry_node *)t->get(t->findL(prevkey)); } else { return (ht_registry_node *)t->get(t->findLast()); } } return NULL; } bool ht_registry::find_any_entry(const char *key, ht_registry_node **node) { rec_depth = 0; ht_registry_node *n = find_entry_i(NULL, key, true); if (n) { *node = n; return true; } return false; } bool ht_registry::find_data_entry(const char *key, ht_registry_node **node, bool follow_symlinks, Container **rdir) { ht_registry_node *n = find_entry_i(rdir, key, follow_symlinks); if (n) { if (n->type == RNT_SUBDIR) return false; *node = n; return true; } return false; } ht_registry_node *ht_registry::find_entry_i(Container **rdir, const char *key, bool follow_symlinks) { ht_registry_node *dir = root; const char *s; if (key[0]=='/') key++; while (1) { s = strchr(key, '/'); if (s) { String t((const byte *)key, s - key); dir = find_entry_get_subdir(((ht_registry_data_stree*)dir->data)->tree, t.contentChar()); if (!dir) break; key = s+1; } else { ht_registry_node *n; if (*key==0) { n = dir; } else { n = find_entry_get_data(((ht_registry_data_stree*)dir->data)->tree, key, follow_symlinks); } if (rdir) *rdir=((ht_registry_data_stree*)dir->data)->tree; return n; } } return NULL; } ht_registry_node *ht_registry::find_entry_get_node(Container *dir, const char *nodename) { if (nodename) { ht_registry_node t(0, nodename, NULL); ht_registry_node *n=(ht_registry_node*)dir->get(dir->find(&t)); return n; } return NULL; } ht_registry_node *ht_registry::find_entry_get_subdir(Container *dir, const char *nodename) { ht_registry_node *n=find_entry_get_node(dir, nodename); start: if (!n) return 0; switch (n->type) { case RNT_SYMLINK: { rec_depth++; if (rec_depth > MAX_SYMLINK_REC_DEPTH) return 0; char *sl=((ht_registry_data_string*)n->data)->value; if (sl[0] == '/') { n = find_entry_i(NULL, sl, true); goto start; } else { return find_entry_get_subdir(dir, sl); } } case RNT_SUBDIR: return n; } return 0; } ht_registry_node *ht_registry::find_entry_get_data(Container *dir, const char *nodename, bool follow_symlinks) { ht_registry_node *n = find_entry_get_node(dir, nodename); start: if (!n) return NULL; if (follow_symlinks && n->type == RNT_SYMLINK) { rec_depth++; if (rec_depth > MAX_SYMLINK_REC_DEPTH) return NULL; char *sl = ((ht_registry_data_string*)n->data)->value; if (sl[0] == '/') { n = find_entry_i(NULL, sl, true); goto start; } else { return find_entry_get_data(dir, sl, follow_symlinks); } } return n; } ht_registry_node_type ht_registry::have_node_type(const char *identifier, create_empty_registry_data_func create_empty_registry_data) { ht_registry_node_type t=lookup_node_type(identifier); if (!t) t=register_node_type(identifier, create_empty_registry_data); return t; } void ht_registry::load(ObjectStream &f) { GET_OBJECT(f, node_types); GET_OBJECT(f, root); } ht_registry_node_type_desc *ht_registry::get_node_type_desc(ht_registry_node_type t, const char **identifier) { ht_registry_node_type_desc *data = NULL; firstThat(ht_registry_node_type_desc, data, *node_types, t == data->type); if (data && identifier) *identifier = data->name; return data; } ht_registry_node_type ht_registry::lookup_node_type(const char *identifier) { ht_registry_node_type_desc s(0, identifier, NULL); ht_registry_node_type_desc *d=(ht_registry_node_type_desc*)node_types->get(node_types->find(&s)); return d ? d->type : 0; } ObjectID ht_registry::getObjectID() const { return ATOM_HT_REGISTRY; } ht_registry_node_type ht_registry::register_node_type(const char *identifier, create_empty_registry_data_func create_empty_registry_data) { // ht_registry_node_type t = RNT_USER; ht_registry_node_type t = 0; ht_registry_node_type_desc *nt = NULL; do { t++; firstThat(ht_registry_node_type_desc, nt, *node_types, t == nt->type); } while (nt != NULL); ht_registry_node_type_desc *v = new ht_registry_node_type_desc(t, identifier, create_empty_registry_data); if (node_types->find(v) != invObjHandle) { delete v; return RNT_INVALID; } else { node_types->insert(v); return t; } } int ht_registry::set_dword(const char *key, uint32 d) { return set_node(key, RNT_DWORD, new ht_registry_data_dword(d)); } int ht_registry::set_raw(const char *key, const void *data, uint size) { return set_node(key, RNT_RAW, new ht_registry_data_raw(data, size)); } int ht_registry::set_node(const char *key, ht_registry_node_type type, ht_registry_data *data) { ht_registry_node *n = find_entry_i(NULL, key, false); if (!n) return ENOENT; if (n->type == type) { if (n->data) { n->data->done(); delete n->data; } n->data = data; return 0; } return EPERM; } int ht_registry::set_string(const char *key, const char *string) { return set_node(key, RNT_STRING, new ht_registry_data_string(string)); } int ht_registry::set_symlink(const char *key, const char *dest) { return set_node(key, RNT_SYMLINK, new ht_registry_data_string(dest)); } bool ht_registry::splitfind(const char *key, const char **name, ht_registry_node **node) { char dir[256]; /* FIXME: possible buffer overflow */ const char *n = strrchr(key, '/'); if (n) { ht_strlcpy(dir, key, n-key+1); n++; } else { dir[0]=0; n=key; } ht_registry_node *m = find_entry_i(NULL, dir, true); if (!m) return 0; if (m->type != RNT_SUBDIR) return 0; *node = m; *name = n; return 1; } void ht_registry::store(ObjectStream &f) const { PUT_OBJECT(f, node_types); PUT_OBJECT(f, root); } unsigned char valid_nodename_chars[256/8]= { /* 00, 08, 10, 18 */ 0, 0, 0, 0, /* 20, 28, 30, 38 */ /* space '-' 0-9 '&' ':' '.' */ BITMAP(1, 0, 0, 0, 0, 0, 1, 0), BITMAP(0, 0, 0, 0, 0, 1, 1, 0), BITMAP(1, 1, 1, 1, 1, 1, 1, 1), BITMAP(1, 1, 1, 0, 0, 0, 0, 0), /* 40, 48, 50, 58 */ /* A-Z '_' */ BITMAP(0, 1, 1, 1, 1, 1, 1, 1), BITMAP(1, 1, 1, 1, 1, 1, 1, 1), BITMAP(1, 1, 1, 1, 1, 1, 1, 1), BITMAP(1, 1, 1, 0, 0, 0, 0, 1), /* 60, 68, 70, 78 */ /* a-z */ BITMAP(0, 1, 1, 1, 1, 1, 1, 1), BITMAP(1, 1, 1, 1, 1, 1, 1, 1), BITMAP(1, 1, 1, 1, 1, 1, 1, 1), BITMAP(1, 1, 1, 0, 0, 0, 0, 0), /* 80, 88, 90, 98 */ 0, 0, 0, 0, /* a0, a8, b0, b8 */ 0, 0, 0, 0, /* c0, c8, d0, d8 */ 0, 0, 0, 0, /* e0, e8, f0, f8 */ 0, 0, 0, 0 }; unsigned char valid_nodename_chars_first[256/8]= { /* 00, 08, 10, 18 */ 0, 0, 0, 0, /* 20, 28, 30, 38 */ /* '.' '-' 0-9 */ BITMAP(0, 0, 0, 0, 0, 0, 1, 0), BITMAP(0, 0, 0, 0, 0, 1, 1, 0), BITMAP(1, 1, 1, 1, 1, 1, 1, 1), BITMAP(1, 1, 0, 0, 0, 0, 0, 0), /* 40, 48, 50, 58 */ /* A-Z '_' */ BITMAP(0, 1, 1, 1, 1, 1, 1, 1), BITMAP(1, 1, 1, 1, 1, 1, 1, 1), BITMAP(1, 1, 1, 1, 1, 1, 1, 1), BITMAP(1, 1, 1, 0, 0, 0, 0, 1), /* 60, 68, 70, 78 */ /* a-z */ BITMAP(0, 1, 1, 1, 1, 1, 1, 1), BITMAP(1, 1, 1, 1, 1, 1, 1, 1), BITMAP(1, 1, 1, 1, 1, 1, 1, 1), BITMAP(1, 1, 1, 0, 0, 0, 0, 0), /* 80, 88, 90, 98 */ 0, 0, 0, 0, /* a0, a8, b0, b8 */ 0, 0, 0, 0, /* c0, c8, d0, d8 */ 0, 0, 0, 0, /* e0, e8, f0, f8 */ 0, 0, 0, 0 }; static bool valid_char(unsigned char *bitmap, char c) { int o=c/8; int p=c%8; return BITBIT(bitmap[o], p); } bool ht_registry::valid_nodename(const char *nodename) { if ((strcmp(nodename, "..")==0) || (strcmp(nodename, ".")==0)) { return false; } if (!valid_char(valid_nodename_chars_first, *nodename)) return false; nodename++; while (*nodename) { if (!valid_char(valid_nodename_chars, *nodename)) return false; nodename++; } return true; } uint32 get_config_dword(const char *ident, uint32 def) { String e; e = "/config/"; e.append(ident); ht_registry_node *n; Container *dir; if (registry->find_data_entry(e.contentChar(), &n, true, &dir)) { if (n->type == RNT_DWORD) { ht_registry_data_dword *s = (ht_registry_data_dword *)n->data; return s->value; } else { const char *q = "?"; registry->get_node_type_desc(n->type, &q); LOG_EX(LOG_ERROR, "registry key '%y' not of type %s, but: %s", &e, "dword", q); } } else { String f(ident); String dirname, filename; f.rightSplit('/', dirname, filename); dir->insert(new ht_registry_node(RNT_DWORD, filename.contentChar(), new ht_registry_data_dword(def))); LOG_EX(LOG_ERROR, "registry key '%y' not found", &e); } return def; } char *get_config_string(const char *ident) { String e; e = "/config/"; e.append(ident); ht_registry_node *n; if (registry->find_data_entry(e.contentChar(), &n, true)) { if (n->type == RNT_STRING) { ht_registry_data_string *s = (ht_registry_data_string *)n->data; return ht_strdup(s->value); } else { const char *q = "?"; registry->get_node_type_desc(n->type, &q); LOG_EX(LOG_ERROR, "registry key '%y' not of type %s, but: %s", &e, "string", q); } } else LOG_EX(LOG_ERROR, "registry key '%y' not found", &e); return NULL; } BUILDER(ATOM_HT_REGISTRY, ht_registry, Object); BUILDER(ATOM_HT_REGISTRY_NODE, ht_registry_node, Object); BUILDER(ATOM_HT_REGISTRY_DATA_STREE, ht_registry_data_stree, ht_registry_data); BUILDER(ATOM_HT_REGISTRY_DATA_DWORD, ht_registry_data_dword, ht_registry_data); BUILDER(ATOM_HT_REGISTRY_DATA_RAW, ht_registry_data_raw, ht_registry_data); BUILDER(ATOM_HT_REGISTRY_DATA_STRING, ht_registry_data_string, ht_registry_data); BUILDER(ATOM_HT_REGISTRY_NODE_TYPE_DESC, ht_registry_node_type_desc, Object); /* * INIT */ #include "cstream.h" bool init_registry() { REGISTER(ATOM_HT_REGISTRY, ht_registry); REGISTER(ATOM_HT_REGISTRY_NODE, ht_registry_node); REGISTER(ATOM_HT_REGISTRY_DATA_STREE, ht_registry_data_stree); REGISTER(ATOM_HT_REGISTRY_DATA_DWORD, ht_registry_data_dword); REGISTER(ATOM_HT_REGISTRY_DATA_RAW, ht_registry_data_raw); REGISTER(ATOM_HT_REGISTRY_DATA_STRING, ht_registry_data_string); REGISTER(ATOM_HT_REGISTRY_NODE_TYPE_DESC, ht_registry_node_type_desc); // registerAtom(ATOM_HT_CREATE_EMPTY_SUBDIR, (void*)); registerAtom(ATOM_HT_CREATE_EMPTY_SYMLINK, (void*)create_empty_symlink); registerAtom(ATOM_HT_CREATE_EMPTY_DWORD, (void*)create_empty_dword); registerAtom(ATOM_HT_CREATE_EMPTY_STRING, (void*)create_empty_string); registerAtom(ATOM_HT_CREATE_EMPTY_RAW, (void*)create_empty_raw); /* * load default registry */ #if ! GENERATE_NEW_REGISTRY ConstMemMapFile f(default_reg, sizeof default_reg); CompressedStream c(&f, false); ObjectStreamBin o(&c, false); GET_OBJECT(o, registry); #else registry = new ht_registry; registry->init(); LocalFile f("ht.reg", IOAM_WRITE, FOM_CREATE); CompressedStream c(&f, false); ObjectStreamBin o(&c, false); PUT_OBJECT(o, registry); #endif return true; } /* * DONE */ void done_registry() { UNREGISTER(ATOM_HT_REGISTRY, ht_registry); UNREGISTER(ATOM_HT_REGISTRY_NODE, ht_registry_node); UNREGISTER(ATOM_HT_REGISTRY_DATA_STREE, ht_registry_data_stree); UNREGISTER(ATOM_HT_REGISTRY_DATA_DWORD, ht_registry_data_dword); UNREGISTER(ATOM_HT_REGISTRY_DATA_RAW, ht_registry_data_raw); UNREGISTER(ATOM_HT_REGISTRY_DATA_STRING, ht_registry_data_string); UNREGISTER(ATOM_HT_REGISTRY_NODE_TYPE_DESC, ht_registry_node_type_desc); // unregisterAtom(ATOM_HT_CREATE_EMPTY_SUBDIR); unregisterAtom(ATOM_HT_CREATE_EMPTY_SYMLINK); unregisterAtom(ATOM_HT_CREATE_EMPTY_DWORD); unregisterAtom(ATOM_HT_CREATE_EMPTY_STRING); unregisterAtom(ATOM_HT_CREATE_EMPTY_RAW); registry->done(); delete registry; } ht-2.0.22/snprintf.h0000644000175000001440000000242510615341624011146 00000000000000/* * HT Editor * snprintf.h * * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __SNPRINTF_H__ #define __SNPRINTF_H__ #include #include #include int ht_asprintf(char **ptr, const char *format, ...); int ht_vasprintf(char **ptr, const char *format, va_list ap); int ht_snprintf(char *str, size_t count, const char *fmt, ...); int ht_vsnprintf(char *str, size_t count, const char *fmt, va_list args); int ht_fprintf(FILE *file, const char *fmt, ...); int ht_vfprintf(FILE *file, const char *fmt, va_list args); int ht_printf(const char *fmt, ...); int ht_vprintf(const char *fmt, va_list args); #endif ht-2.0.22/analyser/0000755000175000017500000000000012156433676011044 500000000000000ht-2.0.22/analyser/macho_analy.h0000644000175000001440000000402610655731110013370 00000000000000/* * HT Editor * macho_analy.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef macho_analy_h #define macho_analy_h #include "analy.h" #include "htmacho.h" //test #include "machostruc.h" class MachoAnalyser: public Analyser { public: ht_macho_shared_data *macho_shared; File *file; Area *validarea; MachoAnalyser() {}; MachoAnalyser(BuildCtorArg&a): Analyser(a) {}; void init(ht_macho_shared_data *macho_shared, File *File); void load(ObjectStream &f); virtual void done(); virtual ObjectID getObjectID() const; virtual void beginAnalysis(); virtual uint bufPtr(Address *Addr, byte *buf, int size); bool convertAddressToMACHOAddress(Address *addr, MACHOAddress *r); virtual Address *createAddress(); Address *createAddress32(uint32 addr); Address *createAddress64(uint64 addr); virtual Assembler *createAssembler(); virtual String & getName(String &res); virtual const char *getType(); virtual void initCodeAnalyser(); virtual void initUnasm(); virtual void log(const char *msg); virtual Address *nextValid(Address *Addr); virtual void store(ObjectStream &f) const; virtual int queryConfig(int mode); virtual bool validAddress(Address *Addr, tsectype action); virtual Address *fileofsToAddress(FileOfs fileofs); virtual FileOfs addressToFileofs(Address *Addr); virtual const char *getSegmentNameByAddress(Address *Addr); }; #endif ht-2.0.22/analyser/coff_analy.h0000644000175000001440000000366410615342710013225 00000000000000/* * HT Editor * coff_analy.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef coff_analy_h #define coff_analy_h #include "analy.h" #include "htcoff.h" class CoffAnalyser: public Analyser { public: ht_coff_shared_data *coff_shared; File *file; Area *validarea; CoffAnalyser() {}; CoffAnalyser(BuildCtorArg&a): Analyser(a) {}; void init(ht_coff_shared_data *Coff_shared, File *File); void load(ObjectStream &f); virtual void done(); virtual ObjectID getObjectID() const; virtual void beginAnalysis(); virtual uint bufPtr(Address *Addr, byte *buf, int size); bool convertAddressToRVA(Address *addr, RVA *r); virtual Address *createAddress(); Address *createAddress32(uint32 addr); virtual Assembler *createAssembler(); virtual String & getName(String &res); virtual const char *getSegmentNameByAddress(Address *Addr); virtual const char *getType(); virtual void initCodeAnalyser(); virtual void initUnasm(); virtual void log(const char *msg); virtual Address *nextValid(Address *Addr); virtual void store(ObjectStream &f) const; virtual int queryConfig(int mode); virtual Address *fileofsToAddress(FileOfs fileofs); virtual FileOfs addressToFileofs(Address *Addr); virtual bool validAddress(Address *Addr, tsectype action); }; #endif ht-2.0.22/analyser/ne_analy.cc0000644000175000001440000002713510615342710013047 00000000000000/* * HT Editor * ne_analy.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "analy.h" #include "analy_alpha.h" #include "analy_names.h" #include "analy_register.h" #include "analy_x86.h" #include "ne_analy.h" #include "htctrl.h" #include "htdebug.h" #include "endianess.h" #include "htiobox.h" #include "htne.h" #include "htneent.h" #include "strtools.h" #include "nestruct.h" #include "snprintf.h" #include "x86asm.h" /* * */ NEAnalyser::NEAnalyser() { } void NEAnalyser::init(ht_ne_shared_data *NE_shared, File *File) { ne_shared = NE_shared; file = File; validarea = new Area(); validarea->init(); Analyser::init(); ///////////// setLocationTreeOptimizeThreshold(100); setSymbolTreeOptimizeThreshold(100); } /* * */ void NEAnalyser::load(ObjectStream &f) { /* ht_pe_shared_data *pe_shared; ht_stream *file; area *validarea; */ GET_OBJECT(f, validarea); Analyser::load(f); } /* * */ void NEAnalyser::done() { validarea->done(); delete validarea; Analyser::done(); } /* * */ void NEAnalyser::beginAnalysis() { char buffer[1024]; /* * entrypoint */ Address *entry = createAddress1616(NE_ADDR_SEG(ne_shared->hdr.csip), NE_ADDR_OFS(ne_shared->hdr.csip)); if (ne_shared->hdr.flags & NE_FLAGS_SELFLOAD) { // bound as family app (needs loader) struct bla { NEAddress a; const char *b; const char *c; }; bla blabla[] = { { NE_MAKE_ADDR(0x0001, 0x0004), "loader_ptr_1", "loader_entry_1"}, { NE_MAKE_ADDR(0x0001, 0x0008), "loader_ptr_2", "loader_entry_2"}, { NE_MAKE_ADDR(0x0001, 0x0018), "loader_ptr_3", "loader_entry_3"}, { 0, 0, 0 }, }; bla *blla = blabla; while (blla->b) { Address *bllaa = createAddress1616(NE_ADDR_SEG(blla->a), NE_ADDR_OFS(blla->a)); addComment(bllaa, 0, ""); assignSymbol(bllaa, blla->b, label_data); data->setIntAddressType(bllaa, dst_idword, 4); NEAddress addr; byte buf[4]; if (validAddress(bllaa, scinitialized) && bufPtr(bllaa, buf, 4)==4) { ht_snprintf(buffer, sizeof buffer, "; pointer to %s", blla->c); addComment(bllaa, 0, buffer); addr = createHostInt(buf, 4, little_endian); Address *a = createAddress1616(NE_ADDR_SEG(addr), NE_ADDR_OFS(addr)); addComment(a, 0, ""); assignSymbol(a, blla->c, label_func); pushAddress(a, a); delete a; } blla++; delete bllaa; } } else { pushAddress(entry, entry); } /* * give all sections a descriptive comment: */ NE_SEGMENT *s = ne_shared->segments.segments; for (uint i = 0; i < ne_shared->segments.segment_count; i++) { Address *secaddr = createAddress1616(NE_ADDR_SEG(NE_get_seg_addr(ne_shared, i)), NE_ADDR_OFS(NE_get_seg_addr(ne_shared, i))); uint epsize = MIN(NE_get_seg_vsize(ne_shared, i), NE_get_seg_psize(ne_shared, i)); uint evsize = MAX(NE_get_seg_vsize(ne_shared, i), NE_get_seg_psize(ne_shared, i)); ht_snprintf(buffer, sizeof buffer, "; section %d <%s>", i+1, getSegmentNameByAddress(secaddr)); addComment(secaddr, 0, ""); addComment(secaddr, 0, ";******************************************************************"); addComment(secaddr, 0, buffer); ht_snprintf(buffer, sizeof buffer, "; virtual address %08x virtual size %08x", NE_get_seg_addr(ne_shared, i), evsize); addComment(secaddr, 0, buffer); uint32 ofs = NE_get_seg_ofs(ne_shared, i); ht_snprintf(buffer, sizeof buffer, "; file offset %08x file size %08x", ofs, epsize); addComment(secaddr, 0, buffer); addComment(secaddr, 0, ";******************************************************************"); // mark end of sections sprintf(buffer, "; end of section <%s>", getSegmentNameByAddress(secaddr)); Address *secend_addr = secaddr->clone(); secend_addr->add(evsize); newLocation(secend_addr)->flags |= AF_FUNCTION_END; addComment(secend_addr, 0, ""); addComment(secend_addr, 0, ";******************************************************************"); addComment(secend_addr, 0, buffer); addComment(secend_addr, 0, ";******************************************************************"); validarea->add(secaddr, secend_addr); Address *seciniaddr = secaddr->clone(); seciniaddr->add(epsize); if (validAddress(secaddr, scinitialized) && validAddress(seciniaddr, scinitialized)) { initialized->add(secaddr, seciniaddr); } delete secaddr; delete secend_addr; delete seciniaddr; s++; } // entrypoints int entrypoint_count = ne_shared->entrypoints->count(); int *entropy = random_permutation(entrypoint_count); for (int i = 0; i < entrypoint_count; i++) { ht_ne_entrypoint *f = (ht_ne_entrypoint*) (*ne_shared->entrypoints)[entropy[i]]; if (f) { Address *address = createAddress1616(f->seg, f->offset); if (validAddress(address, scvalid)) { char *label; if (f->name) { ht_snprintf(buffer, sizeof buffer, "; exported function %s, ordinal %04x", f->name, f->ordinal); } else { ht_snprintf(buffer, sizeof buffer, "; unnamed exported function, ordinal %04x", f->ordinal); } label = export_func_name(f->name, f->ordinal); addComment(address, 0, ""); addComment(address, 0, ";********************************************************"); addComment(address, 0, buffer); addComment(address, 0, ";********************************************************"); pushAddress(address, address); assignSymbol(address, label, label_func); free(label); } delete address; } } if (entropy) free(entropy); // imports if (ne_shared->imports) { FileOfs h = ne_shared->hdr_ofs + ne_shared->hdr.imptab; foreach (ne_import_rec, imp, *ne_shared->imports, { char *name = NULL; char *mod = (imp->module-1 < ne_shared->modnames_count) ? ne_shared->modnames[imp->module-1] : (char*)"invalid!"; if (imp->byname) { file->seek(h + imp->name_ofs); name = file->readstrp(); } char *label = import_func_name(mod, name, imp->byname ? 0 : imp->ord); if (name) free(name); Address *addr = createAddress1616(ne_shared->fake_segment + 1, imp->addr); addComment(addr, 0, ""); assignSymbol(addr, label, label_func); data->setIntAddressType(addr, dst_ibyte, 1); free(label); delete addr; }); } /* virtual Object *enum_next(ht_data **value, Object *prevkey); int import_count = ne_shared->imports.funcs->count(); for (int i=0; iimports.funcs->get(*(entropy+i)); ht_pe_import_library *d=(ht_pe_import_library *)pe_shared->imports.libs->get(f->libidx); char *label; label = import_func_name(d->name, (f->byname) ? f->name.name : NULL, f->ordinal); addComment(f->address, 0, ""); assignSymbol(f->address, label, label_func); data->set_int_addr_type(f->address, dst_idword, 4); free(label); }*/ addComment(entry, 0, ""); addComment(entry, 0, ";****************************"); if (ne_shared->hdr.flags & NE_FLAGS_NOTAPROCESS) { addComment(entry, 0, "; library entry point"); } else { addComment(entry, 0, "; program entry point"); } addComment(entry, 0, ";****************************"); if (validCodeAddress(entry)) { assignSymbol(entry, "entrypoint", label_func); } else { assignSymbol(entry, "entrypoint", label_data); } setLocationTreeOptimizeThreshold(1000); setSymbolTreeOptimizeThreshold(1000); delete entry; Analyser::beginAnalysis(); } /* * */ ObjectID NEAnalyser::getObjectID() const { return ATOM_NE_ANALYSER; } /* * */ uint NEAnalyser::bufPtr(Address *Addr, byte *buf, int size) { FileOfs ofs = addressToFileofs(Addr); /* if (ofs == INVALID_FILE_OFS) { int as=1; }*/ assert(ofs != INVALID_FILE_OFS); file->seek(ofs); return file->read(buf, size); } bool NEAnalyser::convertAddressToNEAddress(Address *addr, NEAddress *r) { if (addr->getObjectID()==ATOM_ADDRESS_X86_1616) { *r = NE_MAKE_ADDR(((AddressX86_1616*)addr)->seg, ((AddressX86_1616*)addr)->addr); return true; } else { return false; } } Address *NEAnalyser::createAddress() { return new AddressX86_1616(0, 0); } Address *NEAnalyser::createAddress1616(uint16 seg, uint16 ofs) { return new AddressX86_1616(seg, ofs); } /* * */ Assembler *NEAnalyser::createAssembler() { /* FIXME: 16/32 */ Assembler *a = new x86asm(X86_OPSIZE16, X86_ADDRSIZE16); a->init(); return a; } /* * */ FileOfs NEAnalyser::addressToFileofs(Address *Addr) { if (validAddress(Addr, scinitialized)) { FileOfs ofs; NEAddress na; if (!convertAddressToNEAddress(Addr, &na)) return INVALID_FILE_OFS; if (!NE_addr_to_ofs(ne_shared, na, &ofs)) { return INVALID_FILE_OFS; } return ofs; } else { return INVALID_FILE_OFS; } } /* * */ const char *NEAnalyser::getSegmentNameByAddress(Address *Addr) { static char segmentname[16]; int i; NEAddress na; if (!convertAddressToNEAddress(Addr, &na)) return NULL; if (!NE_addr_to_segment(ne_shared, na, &i)) return NULL; if (i == (int)ne_shared->fake_segment) { strcpy(segmentname, "faked names"); } else { sprintf(segmentname, "seg%d", i+1); } return segmentname; } /* * */ String &NEAnalyser::getName(String &res) { return file->getDesc(res); } /* * */ const char *NEAnalyser::getType() { return "NE/Analyser"; } /* * */ void NEAnalyser::initCodeAnalyser() { Analyser::initCodeAnalyser(); } /* * */ void NEAnalyser::initUnasm() { DPRINTF("ne_analy: "); DPRINTF("initing analy_x86_disassembler\n"); analy_disasm = new AnalyX86Disassembler(); ((AnalyX86Disassembler*)analy_disasm)->init(this, ANALYX86DISASSEMBLER_FLAGS_16BIT | ANALYX86DISASSEMBLER_FLAGS_SEGMENTED); } /* * */ void NEAnalyser::log(const char *msg) { /* * log() creates to much traffic so dont log * perhaps we reactivate this later * */ /* LOG(msg);*/ } /* * */ Address *NEAnalyser::nextValid(Address *Addr) { return (Address *)validarea->findNext(Addr); } /* * */ void NEAnalyser::store(ObjectStream &st) const { PUT_OBJECT(st, validarea); Analyser::store(st); } /* * */ int NEAnalyser::queryConfig(int mode) { switch (mode) { case Q_DO_ANALYSIS: case Q_ENGAGE_CODE_ANALYSER: case Q_ENGAGE_DATA_ANALYSER: return true; default: return 0; } } /* * */ Address *NEAnalyser::fileofsToAddress(FileOfs fileofs) { NEAddress a; if (NE_ofs_to_addr(ne_shared, fileofs, &a)) { return createAddress1616(NE_ADDR_SEG(a), NE_ADDR_OFS(a)); } else { return new InvalidAddress(); } } /* * */ bool NEAnalyser::validAddress(Address *Addr, tsectype action) { ne_segment_headers *segments = &ne_shared->segments; int sec; NEAddress na; if (!convertAddressToNEAddress(Addr, &na)) return false; if (!NE_addr_to_segment(ne_shared, na, &sec)) return false; NE_SEGMENT *s = segments->segments + sec; switch (action) { case scvalid: return true; case scread: return !(s->flags & NE_READONLY) || (s->flags & NE_DATA); case scwrite: return !(s->flags & NE_READONLY) && (s->flags & NE_DATA); case screadwrite: return !(s->flags & NE_READONLY) && (s->flags & NE_DATA); case sccode: return (!(s->flags & NE_DATA)) && NE_addr_is_physical(ne_shared, na); case scinitialized: return NE_addr_is_physical(ne_shared, na); } return false; } ht-2.0.22/analyser/macho_analy.cc0000644000175000017500000003105611715242037013540 00000000000000/* * HT Editor * macho_analy.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "analy.h" #include "analy_names.h" #include "analy_arm.h" #include "analy_ppc.h" #include "analy_register.h" #include "analy_x86.h" #include "macho_analy.h" #include "htctrl.h" #include "htdebug.h" #include "htiobox.h" #include "htmacho.h" #include "strtools.h" #include "pestruct.h" #include "snprintf.h" #include "x86asm.h" extern "C" { #include "demangle.h" } #include #include #include /* * */ void MachoAnalyser::init(ht_macho_shared_data *Macho_shared, File *File) { macho_shared = Macho_shared; file = File; validarea = new Area(); validarea->init(); Analyser::init(); } void MachoAnalyser::beginAnalysis() { setLocationTreeOptimizeThreshold(100); setSymbolTreeOptimizeThreshold(100); /* * entrypoints */ uint entrypoint_count = 0; MACHO_COMMAND_U **pp = macho_shared->cmds.cmds; for (uint i=0; i < macho_shared->cmds.count; i++) { if ((*pp)->cmd.cmd == LC_UNIXTHREAD || (*pp)->cmd.cmd == LC_THREAD) { MACHO_THREAD_COMMAND *s = (MACHO_THREAD_COMMAND*)*pp; uint64 e = 0; switch (macho_shared->header.cputype) { case MACHO_CPU_TYPE_ARM: e = s->state.state_arm.pc; break; case MACHO_CPU_TYPE_POWERPC: e = s->state.state_ppc.srr[0]; break; case MACHO_CPU_TYPE_I386: e = s->state.state_i386.eip; break; case MACHO_CPU_TYPE_X86_64: e = s->state.state_x86_64.rip; case MACHO_CPU_TYPE_POWERPC64: e = s->state.state_ppc64.srr[0]; break; default: assert(0); } char desc[128]; Address *entry; if (macho_shared->_64) { entry = createAddress64(e); } else { entry = createAddress32(e); } sprintf(desc, "entrypoint%d", entrypoint_count++); pushAddress(entry, entry); assignSymbol(entry, desc, label_func); addComment(entry, 0, ""); addComment(entry, 0, ";****************************"); addComment(entry, 0, "; thread entrypoint"); addComment(entry, 0, ";****************************"); delete entry; } pp++; } /* * give all sections a descriptive comment: */ char blub[100]; pp = macho_shared->cmds.cmds; for (uint i=0; i < macho_shared->cmds.count; i++) { if ((*pp)->cmd.cmd == LC_SEGMENT) { MACHO_SEGMENT_COMMAND *s = (MACHO_SEGMENT_COMMAND*)*pp; Address *secaddr; secaddr = createAddress32(s->vmaddr); if (validAddress(secaddr, scvalid)) { ht_snprintf(blub, sizeof blub, "; section %d <%s>", i+1, getSegmentNameByAddress(secaddr)); addComment(secaddr, 0, ""); addComment(secaddr, 0, ";******************************************************************"); addComment(secaddr, 0, blub); ht_snprintf(blub, sizeof blub, "; virtual address %08x virtual size %08x", s->vmaddr, s->vmsize); addComment(secaddr, 0, blub); ht_snprintf(blub, sizeof blub, "; file offset %08x file size %08x", s->fileoff, s->filesize); addComment(secaddr, 0, blub); addComment(secaddr, 0, ";******************************************************************"); ht_snprintf(blub, sizeof blub, "; end of section <%s>", getSegmentNameByAddress(secaddr)); Address *secend_addr = secaddr->clone(); secend_addr->add(s->vmsize); newLocation(secend_addr)->flags |= AF_FUNCTION_END; addComment(secend_addr, 0, ""); addComment(secend_addr, 0, ";******************************************************************"); addComment(secend_addr, 0, blub); addComment(secend_addr, 0, ";******************************************************************"); // validarea->add(secaddr, secend_addr); delete secend_addr; } delete secaddr; } pp++; } /* symbols */ pp = macho_shared->cmds.cmds; for (uint i=0; i < macho_shared->cmds.count; i++) { if ((*pp)->cmd.cmd == LC_SYMTAB) { MACHO_SYMTAB_COMMAND *s = (MACHO_SYMTAB_COMMAND*)*pp; int *entropy = random_permutation(s->nsyms); for (uint j=0; j < s->nsyms; j++) { Address *address = NULL; char *label = NULL; if (macho_shared->_64) { file->seek(s->symoff + entropy[j]*sizeof (MACHO_SYMTAB_NLIST_64)); MACHO_SYMTAB_NLIST_64 nlist; if (file->read(&nlist, sizeof nlist) != sizeof nlist) break; createHostStruct(&nlist, MACHO_SYMTAB_NLIST_64_struct, macho_shared->image_endianess); if (nlist.strx && (nlist.type & MACHO_SYMBOL_N_TYPE) == MACHO_SYMBOL_TYPE_N_SECT) { file->seek(s->stroff + nlist.strx); label = file->fgetstrz(); address = createAddress64(nlist.value); } } else { file->seek(s->symoff + entropy[j]*sizeof (MACHO_SYMTAB_NLIST)); MACHO_SYMTAB_NLIST nlist; if (file->read(&nlist, sizeof nlist) != sizeof nlist) break; createHostStruct(&nlist, MACHO_SYMTAB_NLIST_struct, macho_shared->image_endianess); if (nlist.strx && (nlist.type & MACHO_SYMBOL_N_TYPE) == MACHO_SYMBOL_TYPE_N_SECT) { file->seek(s->stroff + nlist.strx); label = file->fgetstrz(); address = createAddress32(nlist.value); } } if (address && validAddress(address, scvalid)) { char macho_buffer[1024]; char *demangled = cplus_demangle(label, DMGL_PARAMS | DMGL_ANSI); if (!demangled) demangled = cplus_demangle_v3(label, DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES); if (!demangled && label[0]) demangled = cplus_demangle_v3(label+1, DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES); make_valid_name(label, label); ht_snprintf(macho_buffer, sizeof macho_buffer, "; function %s", (demangled) ? demangled : label); free(demangled); addComment(address, 0, ""); addComment(address, 0, ";********************************************************"); addComment(address, 0, macho_buffer); addComment(address, 0, ";********************************************************"); pushAddress(address, address); assignSymbol(address, label, label_func); } delete address; free(label); } free(entropy); } pp++; } setLocationTreeOptimizeThreshold(1000); setSymbolTreeOptimizeThreshold(1000); Analyser::beginAnalysis(); } /* * */ void MachoAnalyser::load(ObjectStream &f) { GET_OBJECT(f, validarea); Analyser::load(f); } /* * */ void MachoAnalyser::done() { validarea->done(); delete validarea; Analyser::done(); } ObjectID MachoAnalyser::getObjectID() const { return ATOM_MACHO_ANALYSER; } /* * */ uint MachoAnalyser::bufPtr(Address *Addr, byte *buf, int size) { FileOfs ofs = addressToFileofs(Addr); assert(ofs != INVALID_FILE_OFS); file->seek(ofs); return file->read(buf, size); } bool MachoAnalyser::convertAddressToMACHOAddress(Address *addr, MACHOAddress *r) { if (addr->getObjectID() == ATOM_ADDRESS_FLAT_64) { *r = ((AddressFlat64*)addr)->addr; return true; } else if (addr->getObjectID() == ATOM_ADDRESS_FLAT_32) { *r = ((AddressFlat32*)addr)->addr; return true; } else if (addr->getObjectID() == ATOM_ADDRESS_X86_FLAT_32) { *r = ((AddressX86Flat32*)addr)->addr; return true; } return false; } Address *MachoAnalyser::createAddress() { if (macho_shared->header.cputype == MACHO_CPU_TYPE_I386) { return new AddressX86Flat32(); } else { if (macho_shared->_64) { return new AddressFlat64(); } else { return new AddressFlat32(); } } } Address *MachoAnalyser::createAddress32(uint32 addr) { switch (macho_shared->header.cputype) { case MACHO_CPU_TYPE_I386: return new AddressX86Flat32(addr); case MACHO_CPU_TYPE_ARM: case MACHO_CPU_TYPE_POWERPC: default: return new AddressFlat32(addr); } } Address *MachoAnalyser::createAddress64(uint64 addr) { return new AddressFlat64(addr); } /* * */ Assembler *MachoAnalyser::createAssembler() { switch (macho_shared->header.cputype) { case MACHO_CPU_TYPE_I386: { Assembler *a = new x86asm(X86_OPSIZE32, X86_ADDRSIZE32); a->init(); return a; } case MACHO_CPU_TYPE_X86_64: { Assembler *a = new x86_64asm(); a->init(); return a; } } return NULL; } /* * */ FileOfs MachoAnalyser::addressToFileofs(Address *Addr) { if (validAddress(Addr, scinitialized)) { FileOfs ofs; MACHOAddress ea; if (!convertAddressToMACHOAddress(Addr, &ea)) return INVALID_FILE_OFS; if (!macho_addr_to_ofs(macho_shared->sections, macho_shared->section_count, ea, &ofs)) return INVALID_FILE_OFS; return ofs; } else { return INVALID_FILE_OFS; } } /* * */ const char *MachoAnalyser::getSegmentNameByAddress(Address *Addr) { static char macho_sectionname[33]; int i; MACHOAddress ea; if (!convertAddressToMACHOAddress(Addr, &ea)) return NULL; if (!macho_addr_to_section(macho_shared->sections, macho_shared->section_count, ea, &i)) return NULL; if (macho_shared->sections[i]._64) { ht_strlcpy(macho_sectionname, (char*)macho_shared->sections[i].s.sectname, sizeof macho_sectionname); } else { ht_strlcpy(macho_sectionname, (char*)macho_shared->sections[i].s64.sectname, sizeof macho_sectionname); } return macho_sectionname; } /* * */ String &MachoAnalyser::getName(String &res) { return file->getDesc(res); } /* * */ const char *MachoAnalyser::getType() { return "Mach-O/Analyser"; } /* * */ void MachoAnalyser::initCodeAnalyser() { Analyser::initCodeAnalyser(); } /* * */ void MachoAnalyser::initUnasm() { uint machine = macho_shared->header.cputype; bool macho64 = macho_shared->_64; switch (machine) { case MACHO_CPU_TYPE_I386: analy_disasm = new AnalyX86Disassembler(); ((AnalyX86Disassembler*)analy_disasm)->init(this, macho64 ? ANALYX86DISASSEMBLER_FLAGS_FLAT64 : 0); break; case MACHO_CPU_TYPE_X86_64: if (macho64) { analy_disasm = new AnalyX86Disassembler(); ((AnalyX86Disassembler*)analy_disasm)->init(this, ANALYX86DISASSEMBLER_FLAGS_AMD64 | ANALYX86DISASSEMBLER_FLAGS_FLAT64); } else { errorbox("x86_64 cant be used in a 32-Bit Mach-O."); } break; case MACHO_CPU_TYPE_POWERPC: case MACHO_CPU_TYPE_POWERPC64: analy_disasm = new AnalyPPCDisassembler(); ((AnalyPPCDisassembler*)analy_disasm)->init(this, macho64 ? ANALY_PPC_64 : ANALY_PPC_32); break; case MACHO_CPU_TYPE_ARM: analy_disasm = new AnalyArmDisassembler(); ((AnalyArmDisassembler*)analy_disasm)->init(this); break; default: warnbox("No disassembler for unknown machine type %04x!", machine); } } /* * */ void MachoAnalyser::log(const char *msg) { /* * log() does to much traffic so dont log * perhaps we reactivate this later * */ /* LOG(msg);*/ } /* * */ Address *MachoAnalyser::nextValid(Address *Addr) { return (Address *)validarea->findNext(Addr); } /* * */ void MachoAnalyser::store(ObjectStream &f) const { PUT_OBJECT(f, validarea); Analyser::store(f); } /* * */ int MachoAnalyser::queryConfig(int mode) { switch (mode) { case Q_DO_ANALYSIS: case Q_ENGAGE_CODE_ANALYSER: case Q_ENGAGE_DATA_ANALYSER: return true; default: return 0; } } /* * */ Address *MachoAnalyser::fileofsToAddress(FileOfs fileofs) { MACHOAddress ea; if (macho_ofs_to_addr(macho_shared->sections, macho_shared->section_count, fileofs, &ea)) { if (macho_shared->_64) { return createAddress64(ea); } else { return createAddress32(ea); } } else { return new InvalidAddress(); } } /* * */ bool MachoAnalyser::validAddress(Address *Addr, tsectype action) { int sec; MACHOAddress ea; if (!convertAddressToMACHOAddress(Addr, &ea)) return false; if (!macho_addr_to_section(macho_shared->sections, macho_shared->section_count, ea, &sec)) return false; MACHO_SECTION_U &s = macho_shared->sections[sec]; uint32 flags; if (s._64) { flags = s.s64.flags; } else { flags = s.s.flags; } switch (action) { case scvalid: return true; case scread: return true; case scwrite: case screadwrite: { bool writable = (flags & MACHO_SECTION_TYPE) != MACHO_S_CSTRING_LITERALS && (flags & MACHO_SECTION_TYPE) != MACHO_S_4BYTE_LITERALS && (flags & MACHO_SECTION_TYPE) != MACHO_S_8BYTE_LITERALS ; return writable; } case sccode: return (flags & MACHO_SECTION_TYPE) == MACHO_S_REGULAR || (flags & MACHO_S_ATTR_PURE_INSTRUCTIONS) || (flags & MACHO_S_ATTR_SOME_INSTRUCTIONS); case scinitialized: return (flags & MACHO_SECTION_TYPE) != MACHO_S_ZEROFILL; } return false; } ht-2.0.22/analyser/analy.h0000644000175000001440000003255410615342706012235 00000000000000/* * HT Editor * analy.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef analy_h #define analy_h #include "asm.h" #include "data.h" #include "code_analy.h" #include "data_analy.h" #include "stddata.h" extern int num_ops_parsed; class Analyser; #define ADDRESS_STRING_FORMAT_COMPACT 0 #define ADDRESS_STRING_FORMAT_LEADING_WHITESPACE 1 #define ADDRESS_STRING_FORMAT_LEADING_ZEROS 2 #define ADDRESS_STRING_FORMAT_RESERVED 3 #define ADDRESS_STRING_FORMAT_HEX_CAPS 4 #define ADDRESS_STRING_FORMAT_ADD_0X 8 #define ADDRESS_STRING_FORMAT_ADD_H 16 class Address: public Object { public: Address() {}; Address(BuildCtorArg&a): Object(a) {}; virtual bool add(int offset) = 0; virtual int byteSize() = 0; virtual Address * clone() const = 0; virtual int compareDelinear(Address *to); virtual bool difference(int &result, Address *to) = 0; virtual void getFromArray(const byte *array) = 0; virtual void getFromCPUAddress(CPU_ADDR *ca) = 0; virtual bool getFromUInt64(uint64 u) = 0; virtual bool isValid(); virtual int parseString(const char *s, int length, Analyser *a) = 0; virtual void putIntoArray(byte *array) const = 0; virtual void putIntoCPUAddress(CPU_ADDR *ca) const = 0; virtual bool putIntoUInt64(uint64 &u) const = 0; virtual int stringify(char *s, int max_length, int format) const = 0; virtual int stringSize() const = 0; virtual int toString(char *buf, int buflen) const; }; class InvalidAddress: public Address { public: InvalidAddress() {}; InvalidAddress(BuildCtorArg&a): Address(a) {}; virtual bool add(int offset); virtual int byteSize(); virtual int compareTo(const Object *obj) const; virtual bool difference(int &result, Address *to); virtual InvalidAddress *clone() const; virtual void getFromArray(const byte *array); virtual void getFromCPUAddress(CPU_ADDR *ca); virtual bool getFromUInt64(uint64 u); virtual bool isValid(); virtual ObjectID getObjectID() const; virtual int parseString(const char *s, int length, Analyser *a); virtual void putIntoArray(byte *array) const; virtual void putIntoCPUAddress(CPU_ADDR *ca) const; virtual bool putIntoUInt64(uint64 &u) const; virtual int stringify(char *s, int max_length, int format) const; virtual int stringSize() const; }; /* * This address type will be used by most analysers, so we define it here. */ class AddressFlat32: public Address { public: uint32 addr; AddressFlat32(BuildCtorArg&a): Address(a) {}; AddressFlat32(uint32 a=0): addr(a) {}; virtual bool add(int offset); virtual int byteSize(); virtual AddressFlat32 * clone() const; virtual int compareTo(const Object *obj) const; virtual int compareDelinear(Address *to); virtual void getFromArray(const byte *array); virtual void getFromCPUAddress(CPU_ADDR *ca); virtual bool getFromUInt64(uint64 u); virtual bool difference(int &result, Address *to); virtual void load(ObjectStream &s); virtual ObjectID getObjectID() const; virtual int parseString(const char *s, int length, Analyser *a); virtual void putIntoArray(byte *array) const; virtual void putIntoCPUAddress(CPU_ADDR *ca) const; virtual bool putIntoUInt64(uint64 &u) const; virtual void store(ObjectStream &s) const; virtual int stringify(char *s, int max_length, int format) const; virtual int stringSize() const; }; class AddressFlat64: public Address { public: uint64 addr; AddressFlat64(BuildCtorArg&a): Address(a) {}; AddressFlat64(uint64 a=0): addr(a) {}; virtual bool add(int offset); virtual int byteSize(); virtual int compareTo(const Object *obj) const; virtual int compareDelinear(Address *to); virtual void getFromArray(const byte *array); virtual void getFromCPUAddress(CPU_ADDR *ca); virtual bool getFromUInt64(uint64 u); virtual bool difference(int &result, Address *to); virtual AddressFlat64 * clone() const; virtual void load(ObjectStream &s); virtual ObjectID getObjectID() const; virtual int parseString(const char *s, int length, Analyser *a); virtual void putIntoArray(byte *array) const; virtual void putIntoCPUAddress(CPU_ADDR *ca) const; virtual bool putIntoUInt64(uint64 &u) const; virtual void store(ObjectStream &s) const; virtual int stringify(char *s, int max_length, int format) const; virtual int stringSize() const; }; #define ANALY_SEGMENT_CAP_WRITE 1 #define ANALY_SEGMENT_CAP_INITIALIZED 2 // other caps can be defined locally class Segment: public Object { Address *start, *end; char *name; int caps; Segment(const char *n, Address *s, Address *e, int c, int address_size); virtual bool containsAddress(Address *addr) = 0; virtual String & getName(String &res); virtual int getAddressSize(); virtual int getCapability(int cap); }; /* * these are the different possibilities of a branch * to support further processors other types can be added */ enum branch_enum_t { br_nobranch, // straight exec. flow br_jump, br_return, br_call, br_jXX }; /* * internal opcodes are interchanged in this format */ #define OPCODE dis_insn /* * */ class AnalyDisassembler: public Object { public: Analyser *analy; Disassembler *disasm; AnalyDisassembler(); AnalyDisassembler(BuildCtorArg &a): Object(a) {}; void init(Analyser *A); virtual Address * branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine) = 0; virtual void examineOpcode(OPCODE *opcode) = 0; virtual void initDisasm(); virtual branch_enum_t isBranch(OPCODE *opcode) = 0; }; /***************************************************************************/ enum xref_enum_t { xrefread, xrefwrite, xrefoffset, xrefjump, xrefcall, xrefijump, xreficall }; class AddrXRef: public Object { public: Address *addr; xref_enum_t type; AddrXRef(Address *a, xref_enum_t aType = xrefread); AddrXRef(BuildCtorArg&a): Object(a) {}; virtual ~AddrXRef(); virtual void load(ObjectStream &s); virtual ObjectID getObjectID() const; virtual void store(ObjectStream &s) const; virtual int compareTo(const Object *) const; }; class CommentList: public Array { public: CommentList(); void appendPreComment(const char *s); void appendPreComment(int special); void appendPostComment(const char *s); void appendPostComment(int special); const char * getName(uint i); }; struct Symbol; struct Location { // the address Address *addr; // this is a tree structure (key is addr) Location *left, *right; // attached label Symbol *label; // attached xrefs Container *xrefs; // attached comments CommentList *comments; // for data types taddr_type type; // the function the address belongs to (if applicable) Location *thisfunc; // some flags int flags; }; /* * taddr.flags: */ #define AF_DELETED 1 #define AF_FUNCTION_SET 2 #define AF_FUNCTION_END 4 enum tsectype { scvalid, scread, scwrite, screadwrite, sccode, scinitialized }; enum taccesstype { acread, acwrite, acoffset }; struct taccess { bool indexed; int size; taccesstype type; }; enum labeltype { label_unknown = 0, label_func, label_loc, label_data }; struct Symbol { labeltype type; Location * location; char * name; Symbol *left, *right; }; class AddressQueueItem: public Object { public: Address *addr; Address *func; AddressQueueItem(BuildCtorArg&a): Object(a) {}; AddressQueueItem(Address *Addr, Address *Func); ~AddressQueueItem(); virtual void load(ObjectStream &s); virtual ObjectID getObjectID() const; virtual void store(ObjectStream &s) const; }; class CodeAnalyser; class DataAnalyser; class Analyser: public Object { public: Address * addr; Address * invalid_addr; Queue * addr_queue; int ops_parsed; // for continuing bool active; Address *next_explored, *first_explored, *last_explored; bool next_address_is_invalid; Area * explored; Area * initialized; Location * locations; CodeAnalyser * code; DataAnalyser * data; AnalyDisassembler * analy_disasm; Disassembler * disasm; Symbol * symbols; int location_threshold, symbol_threshold; int cur_addr_ops, cur_label_ops; // for threshold int max_opcode_length; Location *cur_func; mutable bool dirty; int symbol_count; int location_count; Analyser() {}; Analyser(BuildCtorArg&a): Object(a) {}; void init(); virtual void load(ObjectStream &s); virtual void done(); bool addAddressSymbol(Address *Addr, const char *Prefix, labeltype type, Location *infunc=NULL); void addComment(Address *Addr, int line, const char *c); bool addSymbol(Address *Addr, const char *label, labeltype type, Location *infunc=NULL); virtual FileOfs addressToFileofs(Address *Addr) = 0; bool addXRef(Address *from, Address *to, xref_enum_t action); void assignComment(Address *Addr, int line, const char *c); bool assignSymbol(Address *Addr, const char *label, labeltype type, Location *infunc=NULL); void assignXRef(Address *from, Address *to, xref_enum_t action); virtual void beginAnalysis(); virtual uint bufPtr(Address *Addr, byte *buf, int size) = 0; bool continueAnalysis(); void continueAnalysisAt(Address *Addr); virtual Address * createAddress() = 0; void dataAccess(Address *Addr, taccess access); void deleteLocation(Address *Addr); void deleteSymbol(Address *Addr); bool deleteXRef(Address *from, Address *to); void disableSymbol(Symbol *label); void doBranch(branch_enum_t branch, OPCODE *opcode, int len); void engageCodeanalyser(); Location * enumLocations(Address *Addr); Location * enumLocationsReverse(Address *Addr); Symbol * enumSymbolsByName(const char *at); Symbol * enumSymbolsByNameReverse(const char *at); Symbol * enumSymbols(Symbol *sym); Symbol * enumSymbolsReverse(Symbol *sym); virtual taddr_typetype examineData(Address *Addr); void finish(); void freeLocation(Location *loc); void freeLocations(Location *locs); void freeComments(Location *loc); void freeSymbol(Symbol *sym); void freeSymbols(Symbol *syms); Location * getLocationByAddress(Address *Addr); Location * getLocationContextByAddress(Address *Addr); int getLocationCount() const; Location * getFunctionByAddress(Address *Addr); Location * getPreviousSymbolByAddress(Address *Addr); virtual const char * getSegmentNameByAddress(Address *Addr); Symbol * getSymbolByAddress(Address *Addr); Symbol * getSymbolByName(const char *label); const char * getSymbolNameByLocation(Location *loc); int getSymbolCount() const; bool gotoAddress(Address *Addr, Address *func); virtual void initCodeAnalyser(); virtual void initDataAnalyser(); virtual void initUnasm() = 0; virtual void log(const char *s); // stub virtual CPU_ADDR mapAddr(Address *Addr); // stub Location * newLocation(Address *Addr); Location * newLocation(Location *&locs, Address *Addr); Symbol * newSymbol(const char *label, Location *loc, labeltype type, Location *infunc); Symbol * newSymbol(Symbol *&syms, const char *label, Location *loc, labeltype type); virtual Address * nextValid(Address *Addr) = 0; void optimizeLocationTree(); void optimizeSymbolTree(); bool popAddress(Address **Addr, Address **func); void pushAddress(Address *Addr, Address *func); virtual int queryConfig(int mode); // stub void setActive(bool mode); void setLocationFunction(Location *a, Location *func); void setLocationTreeOptimizeThreshold(int threshold); void setDisasm(Disassembler *d); void setSymbolTreeOptimizeThreshold(int threshold); virtual void store(ObjectStream &s) const; virtual bool validAddress(Address *addr, tsectype action) = 0; bool validCodeAddress(Address *addr); bool validReadAddress(Address *addr); bool validWriteAddress(Address *addr); // interface only (there's no internal use) int mode; virtual Assembler * createAssembler(); virtual Address * fileofsToAddress(FileOfs fileofs); CommentList * getComments(Address *Addr); const char * getDisasmStr(Address *Addr, int &length); const char * getDisasmStrFormatted(Address *Addr); int getDisplayMode(); virtual String & getName(String &res); virtual const char * getType(); Container * getXRefs(Address *Addr); bool isDirty(); void makeDirty(); void setDisplayMode(int enable, int disable); void toggleDisplayMode(int toggle); }; /* display modes */ #define ANALY_SHOW_ADDRESS 1 #define ANALY_SHOW_COMMENTS 2 #define ANALY_SHOW_LABELS 4 #define ANALY_SHOW_XREFS 8 #define ANALY_SHOW_BYTES 16 #define ANALY_EDIT_BYTES 32 #define ANALY_TRANSLATE_SYMBOLS 64 #define ANALY_COLLAPSE_XREFS 128 /* queryConfig() constants */ #define Q_DO_ANALYSIS 1 #define Q_ENGAGE_CODE_ANALYSER 2 #define Q_ENGAGE_DATA_ANALYSER 3 /* interesting constants */ #define INVALID_FILE_OFS ((FileOfs)-1) /* analyser system constants */ #define MAX_OPS_PER_CONTINUE 10 extern int global_analyser_address_string_format; #endif ht-2.0.22/analyser/stddata.h0000644000175000001440000000273010636023333012541 00000000000000/* * HT Editor * stddata.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef STDDATA_H #define STDDATA_H #include "data.h" struct area_s { area_s *left, *right; Object *start, *end; }; class Area: public Object { public: area_s *a; Area() {}; Area(BuildCtorArg &a): Object(a) {}; void init(); virtual void load(ObjectStream &s); virtual void done(); virtual ObjectID getObjectID() const; virtual Area * clone() const; void add(Object *Start, Object *End); bool contains(Object *V); area_s *getArea(Object *at); Object *findNext(Object *From); Object *findPrev(Object *From); void freeRecursive(area_s *p); virtual void store(ObjectStream &s) const; #ifdef DEBUG_FIXNEW void dump(); #endif }; #define ATOM_AREA MAGIC32("AREA") bool init_stddata(); void done_stddata(); #endif ht-2.0.22/analyser/class_analy.h0000644000175000001440000000352610636023333013412 00000000000000/* * HT Editor * class_analy.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef class_analy_h #define class_analy_h #include "analy.h" #include "class.h" class ClassAnalyser: public Analyser { public: ht_class_shared_data *class_shared; File *file; ClassAnalyser() {}; ClassAnalyser(BuildCtorArg&a): Analyser(a) {}; void init(ht_class_shared_data *Class_shared, File *File); virtual ObjectID getObjectID() const; virtual void beginAnalysis(); virtual uint bufPtr(Address *Addr, byte *buf, int size); virtual Address *createAddress(); Address *createAddress32(ClassAddress addr); virtual Assembler *createAssembler(); virtual String & getName(String &res); virtual const char *getType(); virtual void initCodeAnalyser(); virtual void initUnasm(); virtual void log(const char *msg); virtual Address *nextValid(Address *Addr); virtual int queryConfig(int mode); virtual bool validAddress(Address *Addr, tsectype action); virtual Address *fileofsToAddress(FileOfs fileofs); virtual FileOfs addressToFileofs(Address *Addr); virtual const char *getSegmentNameByAddress(Address *Addr); void reinit(ht_class_shared_data *class_shared, File *file); }; #endif ht-2.0.22/analyser/code_analy.h0000644000175000001440000000224510615342707013222 00000000000000/* * HT Editor * code_analy.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef CODE_ANALY_H #define CODE_ANALY_H #include "data.h" #include "stream.h" #include "analy.h" class Analyser; class CodeAnalyser: public Object { public: Analyser *a; CodeAnalyser(); CodeAnalyser(BuildCtorArg&a): Object(a) {}; void init(Analyser *A); virtual void load(ObjectStream &s); virtual void done(); virtual ObjectID getObjectID() const; virtual void store(ObjectStream &s) const; }; #endif ht-2.0.22/analyser/le_analy.cc0000644000175000001440000003322310615342710013040 00000000000000/* * HT Editor * le_analy.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "analy.h" #include "analy_alpha.h" #include "analy_names.h" #include "analy_register.h" #include "analy_x86.h" #include "htanaly.h" // FIXME: for ht_aviewer, to call gotoAddress(entrypoint) #include "le_analy.h" #include "htctrl.h" #include "htdebug.h" #include "endianess.h" #include "htiobox.h" #include "htle.h" #include "strtools.h" #include "nestruct.h" #include "snprintf.h" #include "x86asm.h" /* * */ void LEAnalyser::init(ht_le_shared_data *LE_shared, File *File) { le_shared = LE_shared; file = File; validarea = new Area(); validarea->init(); Analyser::init(); ///////////// setLocationTreeOptimizeThreshold(100); setSymbolTreeOptimizeThreshold(100); } /* * */ void LEAnalyser::load(ObjectStream &f) { /* ht_pe_shared_data *pe_shared; ht_stream *file; area *validarea; */ GET_OBJECT(f, validarea); Analyser::load(f); } /* * */ void LEAnalyser::done() { validarea->done(); delete validarea; Analyser::done(); } /* * */ void LEAnalyser::beginAnalysis() { // char buffer[1024]; /* * entrypoint */ LEAddress a; Address *control = NULL; Address *v86control = NULL; Address *pmcontrol = NULL; if (le_shared->is_vxd) { LEAddress addr; int temp; addr = le_shared->vxd_desc.v86_ctrl_ofs; if (LE_addr_to_segment(le_shared, addr, &temp)) { a = LE_MAKE_ADDR(le_shared, LE_ADDR_SEG(le_shared, addr), LE_ADDR_OFS(le_shared, addr)); v86control = createAddressFlat32(a); le_shared->best_entrypoint = a; } addr = le_shared->vxd_desc.pm_ctrl_ofs; if (LE_addr_to_segment(le_shared, addr, &temp)) { a = LE_MAKE_ADDR(le_shared, LE_ADDR_SEG(le_shared, addr), LE_ADDR_OFS(le_shared, addr)); pmcontrol = createAddressFlat32(a); le_shared->best_entrypoint = a; } addr = le_shared->vxd_desc.ctrl_ofs; if (LE_addr_to_segment(le_shared, addr, &temp)) { a = LE_MAKE_ADDR(le_shared, LE_ADDR_SEG(le_shared, addr), LE_ADDR_OFS(le_shared, addr)); control = createAddressFlat32(a); le_shared->best_entrypoint = a; } } Address *entry = NULL; if (le_shared->hdr.startobj != 0) { a = LE_MAKE_ADDR(le_shared, le_shared->hdr.startobj-1, le_shared->hdr.eip); le_shared->best_entrypoint = a; entry = createAddressFlat32(a); } if (v86control) pushAddress(v86control, v86control); if (pmcontrol) pushAddress(pmcontrol, pmcontrol); if (control) pushAddress(control, control); if (entry) pushAddress(entry, entry); /* * give all sections a descriptive comment: */ LE_OBJECT *s = le_shared->objmap.header; char blub[100]; for (uint i = 0; i < le_shared->objmap.count; i++) { LEAddress la = LE_get_seg_addr(le_shared, i); Address *secaddr = createAddressFlat32(la); // uint psize = LE_get_seg_psize(le_shared, i); uint vsize = LE_get_seg_vsize(le_shared, i); sprintf(blub, "; section %d <%s> USE%d", i+1, getSegmentNameByAddress(secaddr), (le_shared->objmap.header[i].flags & LE_OBJECT_FLAG_USE32) ? 32 : 16); addComment(secaddr, 0, ""); addComment(secaddr, 0, ";******************************************************************"); addComment(secaddr, 0, blub); sprintf(blub, "; virtual address %08x virtual size %08x", LE_get_seg_addr(le_shared, i), vsize); addComment(secaddr, 0, blub); /* sprintf(blub, "; file offset %08x file size %08x", psize); addComment(secaddr, 0, blub);*/ addComment(secaddr, 0, ";******************************************************************"); // mark end of sections sprintf(blub, "; end of section <%s>", getSegmentNameByAddress(secaddr)); Address *secend_addr = secaddr->clone(); secend_addr->add(vsize); newLocation(secend_addr)->flags |= AF_FUNCTION_END; addComment(secend_addr, 0, ""); addComment(secend_addr, 0, ";******************************************************************"); addComment(secend_addr, 0, blub); addComment(secend_addr, 0, ";******************************************************************"); validarea->add(secaddr, secend_addr); Address *seciniaddr = secaddr->clone(); seciniaddr->add(vsize-1); if (validAddress(secaddr, scinitialized) && validAddress(seciniaddr, scinitialized)) { initialized->add(secaddr, seciniaddr); } delete secaddr; delete secend_addr; delete seciniaddr; s++; } // entrypoints /* int entrypoint_count = le_shared->entrypoints->count(); int *entropy = random_permutation(entrypoint_count); for (int i=0; ientrypoints->get(*(entropy+i)); if (f) { Address *address = createAddress1616(f->seg, f->offset); if (validAddress(address, scvalid)) { char *label; if (f->name) { sprintf(buffer, "; exported function %s, ordinal %04x", f->name, f->ordinal); } else { sprintf(buffer, "; unnamed exported function, ordinal %04x", f->ordinal); } label = export_func_name(f->name, f->ordinal); addComment(address, 0, ""); addComment(address, 0, ";********************************************************"); addComment(address, 0, buffer); addComment(address, 0, ";********************************************************"); pushAddress(address, address); assignSymbol(address, label, label_func); free(label); } delete address; } } if (entropy) free(entropy); */ // imports /* if (le_shared->imports) { ht_tree *t = le_shared->imports; Object *v; ne_import_rec *imp = NULL; FileOfs h = le_shared->hdr_ofs + le_shared->hdr.imptab; while ((imp = (ne_import_rec*)t->enum_next(&v, imp))) { char *name = NULL; char *mod = (imp->module-1 < le_shared->modnames_count) ? le_shared->modnames[imp->module-1] : (char*)"invalid!"; if (imp->byname) { file->seek(h+imp->name_ofs); name = getstrp(file); } char *label = import_func_name(mod, name, imp->byname ? 0 : imp->ord); if (name) free(name); Address *addr = createAddress1616(le_shared->fake_segment+1, imp->addr); addComment(addr, 0, ""); assignSymbol(addr, label, label_func); data->setIntAddressType(addr, dst_ibyte, 1); free(label); delete addr; } } */ /* virtual Object *enum_next(ht_data **value, Object *prevkey); int import_count = le_shared->imports.funcs->count(); for (int i=0; iimports.funcs->get(*(entropy+i)); ht_pe_import_library *d=(ht_pe_import_library *)pe_shared->imports.libs->get(f->libidx); char *label; label = import_func_name(d->name, (f->byname) ? f->name.name : NULL, f->ordinal); addComment(f->address, 0, ""); assignSymbol(f->address, label, label_func); data->set_int_addr_type(f->address, dst_idword, 4); free(label); }*/ if (le_shared->is_vxd) { if (v86control) { addComment(v86control, 0, ""); addComment(v86control, 0, ";****************************"); addComment(v86control, 0, "; VxD V86-control procedure"); addComment(v86control, 0, ";****************************"); assignSymbol(v86control, "VxD_v86_control", label_func); } if (pmcontrol) { addComment(pmcontrol, 0, ""); addComment(pmcontrol, 0, ";****************************"); addComment(pmcontrol, 0, "; VxD PM-control procedure"); addComment(pmcontrol, 0, ";****************************"); assignSymbol(pmcontrol, "VxD_pm_control", label_func); } if (control) { addComment(control, 0, ""); addComment(control, 0, ";****************************"); addComment(control, 0, "; VxD control procedure"); addComment(control, 0, ";****************************"); assignSymbol(control, "VxD_control", label_func); } } if (entry) { addComment(entry, 0, ""); addComment(entry, 0, ";****************************"); addComment(entry, 0, "; program entry point"); addComment(entry, 0, ";****************************"); if (validCodeAddress(entry)) { assignSymbol(entry, "entrypoint", label_func); } else { assignSymbol(entry, "entrypoint", label_data); } } setLocationTreeOptimizeThreshold(1000); setSymbolTreeOptimizeThreshold(1000); delete entry; if (le_shared->best_entrypoint != LE_ADDR_INVALID) { Address *tmpaddr = createAddressFlat32(le_shared->best_entrypoint); ((ht_aviewer*)le_shared->v_image)->gotoAddress(tmpaddr, NULL); delete tmpaddr; } Analyser::beginAnalysis(); } /* * */ ObjectID LEAnalyser::getObjectID() const { return ATOM_LE_ANALYSER; } /* * */ FileOfs LEAnalyser::addressToFileofs(Address *Addr) { if (validAddress(Addr, scinitialized)) { FileOfs ofs; LEAddress na; if (!convertAddressToLEAddress(Addr, &na)) return INVALID_FILE_OFS; if (!LE_addr_to_ofs(le_shared, na, &ofs)) { return INVALID_FILE_OFS; } return ofs; /* uint m; FileOfs oo; if (!le_shared->linear_file->map_ofs(ofs, &oo, &m)) { le_shared->linear_file->map_ofs(ofs, &oo, &m); return INVALID_FILE_OFS; } return oo;*/ } else { return INVALID_FILE_OFS; } } FileOfs LEAnalyser::addressToRealFileofs(Address *Addr) { if (validAddress(Addr, scinitialized)) { FileOfs ofs; LEAddress na; if (!convertAddressToLEAddress(Addr, &na)) return INVALID_FILE_OFS; if (!LE_addr_to_ofs(le_shared, na, &ofs)) { return INVALID_FILE_OFS; } FileOfs m; FileOfs oo; if (!le_shared->linear_file->map_ofs(ofs, &oo, &m)) { return INVALID_FILE_OFS; } return oo; } else { return INVALID_FILE_OFS; } } /* * */ uint LEAnalyser::bufPtr(Address *Addr, byte *buf, int size) { FileOfs ofs = addressToFileofs(Addr); /* if (ofs == INVALID_FILE_OFS) { ht_printf("%y", Addr); int as=1; }*/ assert(ofs != INVALID_FILE_OFS); file->seek(ofs); return file->read(buf, size); } bool LEAnalyser::convertAddressToLEAddress(Address *addr, LEAddress *r) { if (addr->getObjectID()==ATOM_ADDRESS_X86_FLAT_32) { // *r = LE_MAKE_ADDR(le_shared, ((AddressX86Flat32*)addr)->seg, ((AddressX86_1632*)addr)->addr); *r = ((AddressX86Flat32*)addr)->addr; return true; } else { return false; } } Address *LEAnalyser::createAddress() { return new AddressX86Flat32(0); } Address *LEAnalyser::createAddressFlat32(uint32 ofs) { return new AddressX86Flat32(ofs); } /* * */ Assembler *LEAnalyser::createAssembler() { /* FIXME: 16/32 */ Assembler *a = new x86asm(X86_OPSIZE32, X86_ADDRSIZE32); a->init(); return a; } /* * */ const char *LEAnalyser::getSegmentNameByAddress(Address *Addr) { static char segmentname[16]; int i; LEAddress na; if (!convertAddressToLEAddress(Addr, &na)) return NULL; if (!LE_addr_to_segment(le_shared, na, &i)) return NULL; // LEAddress temp; /* bool init = LE_addr_to_ofs(le_shared, na, &temp); if (!init) return NULL;*/ /* if (i == (int)le_shared->fake_segment) { strcpy(segmentname, "faked names"); } else {*/ sprintf(segmentname, "seg%d", i+1); // } return segmentname; } /* * */ String &LEAnalyser::getName(String &res) { return file->getDesc(res); } /* * */ const char *LEAnalyser::getType() { return "LE/Analyser"; } /* * */ void LEAnalyser::initCodeAnalyser() { Analyser::initCodeAnalyser(); } /* * */ void LEAnalyser::initUnasm() { DPRINTF("le_analy: "); DPRINTF("initing analy_x86_disassembler\n"); analy_disasm = new AnalyX86Disassembler(); ((AnalyX86Disassembler*)analy_disasm)->init(this, le_shared->is_vxd ? ANALYX86DISASSEMBLER_FLAGS_VXD_X86DIS : 0); } /* * */ void LEAnalyser::log(const char *msg) { /* * log() creates to much traffic so dont log * perhaps we reactivate this later * */ /* LOG(msg);*/ } /* * */ Address *LEAnalyser::nextValid(Address *Addr) { return (Address *)validarea->findNext(Addr); } /* * */ void LEAnalyser::store(ObjectStream &st) const { PUT_OBJECT(st, validarea); Analyser::store(st); } /* * */ int LEAnalyser::queryConfig(int mode) { switch (mode) { case Q_DO_ANALYSIS: case Q_ENGAGE_CODE_ANALYSER: case Q_ENGAGE_DATA_ANALYSER: return true; default: return 0; } } /* * */ Address *LEAnalyser::fileofsToAddress(FileOfs fileofs) { LEAddress a; if (LE_ofs_to_addr(le_shared, fileofs, &a)) { return createAddressFlat32(a); } else { return new InvalidAddress(); } } /* * */ /* FIXME: fileofs chaos */ Address *LEAnalyser::realFileofsToAddress(FileOfs fileofs) { LEAddress a; uint lofs; if (le_shared->linear_file->unmap_ofs(fileofs, &lofs) && LE_ofs_to_addr(le_shared, lofs, &a)) { return createAddressFlat32(a); } else { return new InvalidAddress(); } } /* * */ bool LEAnalyser::validAddress(Address *Addr, tsectype action) { ht_le_objmap *objects = &le_shared->objmap; int sec; LEAddress na; if (!convertAddressToLEAddress(Addr, &na)) return false; if (!LE_addr_to_segment(le_shared, na, &sec)) return false; FileOfs temp; bool init = LE_addr_to_ofs(le_shared, na, &temp); LE_OBJECT *s = objects->header + sec; switch (action) { case scvalid: return true; case scread: return (s->flags & LE_OBJECT_FLAG_READABLE); case scwrite: return (s->flags & LE_OBJECT_FLAG_WRITEABLE); case screadwrite: return (s->flags & LE_OBJECT_FLAG_READABLE) && (s->flags & LE_OBJECT_FLAG_WRITEABLE); case sccode: return (s->flags & LE_OBJECT_FLAG_EXECUTABLE) && init; case scinitialized: return init; } return false; } ht-2.0.22/analyser/xex_analy.cc0000644000175000001440000001541210615342776013260 00000000000000/* * HT Editor * xex_analy.cc * * Copyright (C) 2006 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "analy.h" #include "analy_names.h" #include "analy_register.h" #include "analy_ppc.h" #include "htctrl.h" #include "htdebug.h" #include "htiobox.h" #include "htxex.h" #include "strtools.h" #include "xex_analy.h" #include "xexstruct.h" #include "snprintf.h" void XEXAnalyser::init(ht_xex_shared_data *XEX_shared, File *File) { xex_shared = XEX_shared; file = File; validarea = new Area(); validarea->init(); Analyser::init(); } /* * */ void XEXAnalyser::load(ObjectStream &f) { GET_OBJECT(f, validarea); Analyser::load(f); } /* * */ void XEXAnalyser::done() { validarea->done(); delete validarea; Analyser::done(); } /* * */ void XEXAnalyser::beginAnalysis() { char buffer[1024]; Address *entry = createAddress32(xex_shared->entrypoint); pushAddress(entry, entry); int lib_count=xex_shared->imports.lib_count; for (int i=0; i < lib_count; i++) { XexImportLib *lib = xex_shared->imports.libs + i; for (int j = 0; j < lib->func_count; j++) { XexImportFunc *func = lib->funcs + j; uint32 ord = func->ord; if (ord & 0xff000000) { int libidx = (ord & 0x00ff0000) >> 16; ord &= 0x7fff; if (libidx != i) { continue; } char s[200]; ht_snprintf(s, sizeof s, "wrapper_import_%s_%d", lib->name, ord); Address *faddr = createAddress32(func->patch); addComment(faddr, 0, ""); assignSymbol(faddr, s, label_func); delete faddr; faddr = createAddress32(func->patch+12); Address *faddr2 = createAddress32(func->ia); addXRef(faddr2, faddr, xrefijump); delete faddr; delete faddr2; // printf("xref 0x%08x -> 0x%08x\n", ia, imports[i].func[j].patch + 12); } else { char s[200]; ord &= 0x7fff; ht_snprintf(s, sizeof s, "import_%s_%d", lib->name, ord); Address *faddr = createAddress32(func->patch); addComment(faddr, 0, ""); assignSymbol(faddr, s, label_func); data->setIntAddressType(faddr, dst_idword, 4); delete faddr; // printf("function_ptr 0x%08x name '%s'\n", imports[i].func[j].patch, s); } } } #if 0 int dimport_count=xex_shared->dimports.funcs->count(); entropy = random_permutation(dimport_count); for (int i=0; idimports.funcs)[entropy[i]]; ht_pe_import_library *d=(ht_pe_import_library *)(*xex_shared->dimports.libs)[f->libidx]; if (f->byname) { ht_snprintf(buffer, sizeof buffer, "; delay import function loader for %s, ordinal %04x", f->name.name, f->ordinal); } else { ht_snprintf(buffer, sizeof buffer, "; delay import function loader for ordinal %04x", f->ordinal); } char *label; label = import_func_name(d->name, f->byname ? f->name.name : NULL, f->ordinal); Address *faddr; if (pe32) { faddr = createAddress32(f->address); } else { faddr = createAddress64(f->address); } addComment(faddr, 0, ""); addComment(faddr, 0, ";********************************************************"); addComment(faddr, 0, buffer); addComment(faddr, 0, ";********************************************************"); assignSymbol(faddr, label, label_func); free(label); delete faddr; } if (entropy) free(entropy); #endif addComment(entry, 0, ""); addComment(entry, 0, ";****************************"); addComment(entry, 0, "; program entry point"); addComment(entry, 0, ";****************************"); assignSymbol(entry, "entrypoint", label_func); setLocationTreeOptimizeThreshold(1000); setSymbolTreeOptimizeThreshold(1000); delete entry; Analyser::beginAnalysis(); } /* * */ ObjectID XEXAnalyser::getObjectID() const { return ATOM_XEX_ANALYSER; } /* * */ uint XEXAnalyser::bufPtr(Address *Addr, byte *buf, int size) { FileOfs ofs = addressToFileofs(Addr); /* if (ofs == INVALID_FILE_OFS) { int as=0; }*/ assert(ofs != INVALID_FILE_OFS); file->seek(ofs); return file->read(buf, size); } bool XEXAnalyser::convertAddressToRVA(Address *addr, RVA *r) { ObjectID oid = addr->getObjectID(); if (oid == ATOM_ADDRESS_FLAT_32) { *r = ((AddressFlat32*)addr)->addr - xex_shared->image_base; return true; } return false; } /* * */ Address *XEXAnalyser::createAddress32(uint32 addr) { return new AddressFlat32(addr); } Address *XEXAnalyser::createAddress() { return new AddressFlat32(); } /* * */ FileOfs XEXAnalyser::addressToFileofs(Address *Addr) { if (validAddress(Addr, scinitialized)) { FileOfs ofs; RVA r; if (!convertAddressToRVA(Addr, &r)) return INVALID_FILE_OFS; if (!xex_rva_to_ofs(xex_shared, r, ofs)) return INVALID_FILE_OFS; return ofs; } else { return INVALID_FILE_OFS; } } /* * */ const char *XEXAnalyser::getSegmentNameByAddress(Address *Addr) { return ""; } /* * */ String &XEXAnalyser::getName(String &s) { return file->getDesc(s); } /* * */ const char *XEXAnalyser::getType() { return "XEX/Analyser"; } /* * */ void XEXAnalyser::initUnasm() { analy_disasm = new AnalyPPCDisassembler(); ((AnalyPPCDisassembler*)analy_disasm)->init(this, ANALY_PPC_32); } /* * */ Address *XEXAnalyser::nextValid(Address *Addr) { return (Address *)validarea->findNext(Addr); } /* * */ void XEXAnalyser::store(ObjectStream &st) const { PUT_OBJECT(st, validarea); Analyser::store(st); } /* * */ Address *XEXAnalyser::fileofsToAddress(FileOfs fileofs) { RVA r; if (xex_ofs_to_rva(xex_shared, fileofs, r)) { return createAddress32(r + xex_shared->image_base); } else { return new InvalidAddress(); } } /* * */ bool XEXAnalyser::validAddress(Address *Addr, tsectype action) { // e_section_headers *sections=&xex_shared->sections; int sec; RVA r; FileOfs ofs; if (!convertAddressToRVA(Addr, &r)) return false; // if (!pe_rva_to_section(sections, r, &sec)) return false; if (!xex_rva_to_ofs(xex_shared, r, ofs)) return false; uint32 flags = xex_get_rva_flags(xex_shared, r); switch (action) { case scvalid: case scinitialized: case scread: return true; return true; case scwrite: case screadwrite: return !(flags & 1); case sccode: return !(flags & 2); } return true; } ht-2.0.22/analyser/analyinfo.h0000644000175000001440000000205110206756711013077 00000000000000/* * HT Editor * analyinfo.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ANALYINFO_H #define ANALYINFO_H #define htanalyser_name "ht-analyser" #define htanalyser_copyright "(c) 1999-2002 "htanalyser_author" ("htanalyser_mail")" #define htanalyser_loadtitle htanalyser_name" "htanalyser_copyright #define htanalyser_author "Sebastian Biallas" #define htanalyser_mail "sb@biallas.net" #endif ht-2.0.22/analyser/flt_analy.h0000644000175000001440000000377410615342710013077 00000000000000/* * HT Editor * flt_analy.h * * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef flt_analy_h #define flt_analy_h #include "analy.h" #include "htflt.h" //test #include "fltstruc.h" class FLTAnalyser: public Analyser { public: ht_flt_shared_data *flt_shared; File *file; Area *validarea; FLTAnalyser() {}; FLTAnalyser(BuildCtorArg&a): Analyser(a) {}; void init(ht_flt_shared_data *flt_shared, File *File); void load(ObjectStream &f); virtual void done(); virtual ObjectID getObjectID() const; virtual void beginAnalysis(); virtual uint bufPtr(Address *Addr, byte *buf, int size); bool convertAddressToFLTAddress(Address *addr, FLTAddress *r); virtual Address *createAddress(); Address *createAddress32(uint32 addr); Address *createAddress64(uint64 addr); virtual Assembler *createAssembler(); virtual String & getName(String &res); virtual const char *getType(); virtual void initCodeAnalyser(); virtual void initUnasm(); virtual void log(const char *msg); virtual Address *nextValid(Address *Addr); virtual void store(ObjectStream &f) const; virtual int queryConfig(int mode); virtual bool validAddress(Address *Addr, tsectype action); virtual Address *fileofsToAddress(FileOfs fileofs); virtual FileOfs addressToFileofs(Address *Addr); virtual const char *getSegmentNameByAddress(Address *Addr); }; #endif ht-2.0.22/analyser/analy_register.cc0000644000175000001440000001257010615342707014274 00000000000000/* * HT Editor * analy_register.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "analy_register.h" #include "analy_alpha.h" #include "analy_java.h" #include "analy_ia64.h" #include "analy_il.h" #include "analy_ppc.h" #include "analy_x86.h" #include "analy_arm.h" #include "class_analy.h" #include "code_analy.h" #include "coff_analy.h" #include "data_analy.h" #include "elf_analy.h" #include "flt_analy.h" #include "ne_analy.h" #include "pe_analy.h" #include "le_analy.h" #include "macho_analy.h" #include "xbe_analy.h" #include "pef_analy.h" #include "xex_analy.h" #include "atom.h" BUILDER(ATOM_ANALY_ALPHA, AnalyAlphaDisassembler, AnalyDisassembler) BUILDER(ATOM_ANALY_X86, AnalyX86Disassembler, AnalyDisassembler) BUILDER(ATOM_ANALY_IA64, AnalyIA64Disassembler, AnalyDisassembler) BUILDER(ATOM_ANALY_IL, AnalyILDisassembler, AnalyDisassembler) BUILDER(ATOM_ANALY_JAVA, AnalyJavaDisassembler, AnalyDisassembler) BUILDER(ATOM_ANALY_PPC, AnalyPPCDisassembler, AnalyDisassembler) BUILDER(ATOM_ANALY_ARM, AnalyArmDisassembler, AnalyDisassembler) BUILDER(ATOM_CODE_ANALYSER, CodeAnalyser, Object) BUILDER(ATOM_DATA_ANALYSER, DataAnalyser, Object) BUILDER(ATOM_ADDR_QUEUE_ITEM, AddressQueueItem, Object) BUILDER(ATOM_ADDR_XREF, AddrXRef, Object) BUILDER(ATOM_PE_ANALYSER, PEAnalyser, Analyser) BUILDER(ATOM_ELF_ANALYSER, ElfAnalyser, Analyser) BUILDER(ATOM_COFF_ANALYSER, CoffAnalyser, Analyser) BUILDER(ATOM_NE_ANALYSER, NEAnalyser, Analyser) BUILDER(ATOM_CLASS_ANALYSER, ClassAnalyser, Analyser) BUILDER(ATOM_LE_ANALYSER, LEAnalyser, Analyser) BUILDER(ATOM_MACHO_ANALYSER, MachoAnalyser, Analyser) BUILDER(ATOM_FLT_ANALYSER, FLTAnalyser, Analyser) BUILDER(ATOM_XBE_ANALYSER, XBEAnalyser, Analyser) BUILDER(ATOM_PEF_ANALYSER, PEFAnalyser, Analyser) BUILDER(ATOM_XEX_ANALYSER, XEXAnalyser, Analyser) BUILDER(ATOM_ADDRESS_INVALID, InvalidAddress, Address) BUILDER(ATOM_ADDRESS_FLAT_32, AddressFlat32, Address) BUILDER(ATOM_ADDRESS_FLAT_64, AddressFlat64, Address) BUILDER(ATOM_ADDRESS_X86_FLAT_32, AddressX86Flat32, Address) BUILDER(ATOM_ADDRESS_X86_1616, AddressX86_1616, Address) BUILDER(ATOM_ADDRESS_X86_1632, AddressX86_1632, Address) bool init_analyser() { REGISTER(ATOM_ANALY_ALPHA, AnalyAlphaDisassembler) REGISTER(ATOM_ANALY_X86, AnalyX86Disassembler) REGISTER(ATOM_ANALY_IA64, AnalyIA64Disassembler) REGISTER(ATOM_ANALY_IL, AnalyILDisassembler) REGISTER(ATOM_ANALY_JAVA, AnalyJavaDisassembler) REGISTER(ATOM_ANALY_PPC, AnalyPPCDisassembler) REGISTER(ATOM_ANALY_ARM, AnalyArmDisassembler) REGISTER(ATOM_CODE_ANALYSER, CodeAnalyser) REGISTER(ATOM_DATA_ANALYSER, DataAnalyser) REGISTER(ATOM_ADDR_QUEUE_ITEM, AddressQueueItem) REGISTER(ATOM_ADDR_XREF, AddrXRef) REGISTER(ATOM_PE_ANALYSER, PEAnalyser) REGISTER(ATOM_ELF_ANALYSER, ElfAnalyser) REGISTER(ATOM_COFF_ANALYSER, CoffAnalyser) REGISTER(ATOM_NE_ANALYSER, NEAnalyser) REGISTER(ATOM_CLASS_ANALYSER, ClassAnalyser) REGISTER(ATOM_LE_ANALYSER, LEAnalyser) REGISTER(ATOM_MACHO_ANALYSER, MachoAnalyser) REGISTER(ATOM_FLT_ANALYSER, FLTAnalyser) REGISTER(ATOM_XBE_ANALYSER, XBEAnalyser) REGISTER(ATOM_PEF_ANALYSER, PEFAnalyser) REGISTER(ATOM_XEX_ANALYSER, XEXAnalyser) REGISTER(ATOM_ADDRESS_INVALID, InvalidAddress) REGISTER(ATOM_ADDRESS_FLAT_32, AddressFlat32) REGISTER(ATOM_ADDRESS_FLAT_64, AddressFlat64) REGISTER(ATOM_ADDRESS_X86_FLAT_32, AddressX86Flat32) REGISTER(ATOM_ADDRESS_X86_1616, AddressX86_1616) REGISTER(ATOM_ADDRESS_X86_1632, AddressX86_1632) return true; } void done_analyser() { UNREGISTER(ATOM_ANALY_ALPHA, AnalyAlphaDisassembler) UNREGISTER(ATOM_ANALY_X86, AnalyX86Disassembler) UNREGISTER(ATOM_ANALY_IA64, AnalyIA64Disassembler) UNREGISTER(ATOM_ANALY_IL, AnalyILDisassembler) UNREGISTER(ATOM_ANALY_JAVA, AnalyJavaDisassembler) UNREGISTER(ATOM_ANALY_PPC, AnalyPPCDisassembler) UNREGISTER(ATOM_ANALY_ARM, AnalyArmDisassembler) UNREGISTER(ATOM_CODE_ANALYSER, CodeAnalyser) UNREGISTER(ATOM_DATA_ANALYSER, DataAnalyser) UNREGISTER(ATOM_ADDR_QUEUE_ITEM, AddressQueueItem) UNREGISTER(ATOM_ADDR_XREF, AddrXRef) UNREGISTER(ATOM_PE_ANALYSER, PEAnalyser) UNREGISTER(ATOM_ELF_ANALYSER, ElfAnalyser) UNREGISTER(ATOM_COFF_ANALYSER, CoffAnalyser) UNREGISTER(ATOM_NE_ANALYSER, NEAnalyser) UNREGISTER(ATOM_CLASS_ANALYSER, ClassAnalyser) UNREGISTER(ATOM_LE_ANALYSER, LEAnalyser) UNREGISTER(ATOM_MACHO_ANALYSER, MachoAnalyser) UNREGISTER(ATOM_FLT_ANALYSER, FLTAnalyser) UNREGISTER(ATOM_XBE_ANALYSER, XBEAnalyser) UNREGISTER(ATOM_PEF_ANALYSER, PEFAnalyser) UNREGISTER(ATOM_XEX_ANALYSER, XEXAnalyser) UNREGISTER(ATOM_ADDRESS_INVALID, InvalidAddress) UNREGISTER(ATOM_ADDRESS_FLAT_32, AddressFlat32) UNREGISTER(ATOM_ADDRESS_FLAT_64, AddressFlat64) UNREGISTER(ATOM_ADDRESS_X86_FLAT_32, AddressX86Flat32) UNREGISTER(ATOM_ADDRESS_X86_1616, AddressX86_1616) UNREGISTER(ATOM_ADDRESS_X86_1632, AddressX86_1632) } ht-2.0.22/analyser/code_analy.cc0000644000175000001440000000231610615342707013357 00000000000000/* * HT Editor * code_analy.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include #include #include #include #include "analy.h" #include "analy_register.h" #include "language.h" #include "code_analy.h" #include "htdebug.h" CodeAnalyser::CodeAnalyser() { } void CodeAnalyser::init(Analyser *A) { } void CodeAnalyser::load(ObjectStream &f) { } void CodeAnalyser::done() { } ObjectID CodeAnalyser::getObjectID() const { return ATOM_CODE_ANALYSER; } void CodeAnalyser::store(ObjectStream &f) const { } ht-2.0.22/analyser/analy_java.h0000644000175000001440000000244510615342707013233 00000000000000/* * HT Editor * analy_java.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ANALY_JAVA_H #define ANALY_JAVA_H #include "analy.h" #include "javadis.h" class AnalyJavaDisassembler: public AnalyDisassembler { public: AnalyJavaDisassembler() {}; AnalyJavaDisassembler(BuildCtorArg&a): AnalyDisassembler(a) {}; void init(Analyser *A, java_token_func token_func, void *context); virtual ObjectID getObjectID() const; virtual Address *branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine); virtual void examineOpcode(OPCODE *opcode); virtual branch_enum_t isBranch(OPCODE *opcode); }; #endif /* ANALY_JAVA_H */ ht-2.0.22/analyser/analy_alpha.cc0000644000175000001440000000505612156426226013537 00000000000000/* * HT Editor * analy_alpha.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "analy_alpha.h" #include "analy_register.h" #include "alphadis.h" #include "htiobox.h" #include "snprintf.h" /* * */ AnalyAlphaDisassembler::AnalyAlphaDisassembler() { } void AnalyAlphaDisassembler::init(Analyser *A) { disasm = new Alphadis(); AnalyDisassembler::init(A); } /* * */ void AnalyAlphaDisassembler::load(ObjectStream &f) { return AnalyDisassembler::load(f); } /* * */ void AnalyAlphaDisassembler::done() { AnalyDisassembler::done(); } ObjectID AnalyAlphaDisassembler::getObjectID() const { return ATOM_ANALY_ALPHA; } /* * */ Address *AnalyAlphaDisassembler::branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine) { Address *a = createAddress(((alphadis_insn *)opcode)->address); if (examine && analy->validAddress(a, scvalid)) { return a; } delete a; return new InvalidAddress(); } Address *AnalyAlphaDisassembler::createAddress(uint64 offset) { return new AddressFlat64(offset); } /* * */ void AnalyAlphaDisassembler::examineOpcode(OPCODE *opcode) { } /* * */ branch_enum_t AnalyAlphaDisassembler::isBranch(OPCODE *opcode) { // FIXME: needs work!! alphadis_insn *alpha_insn = (alphadis_insn *) opcode; if (alpha_insn->valid) { switch ((alpha_insn->table+alpha_insn->code)->type) { case ALPHA_GROUP_BRA: if (alpha_insn->table == alpha_instr_tbl) { switch (alpha_insn->code) { case 0x30: return br_jump; case 0x34: return br_call; default: if (alpha_insn->code > 0x30) return br_jXX; } } return br_nobranch; case ALPHA_GROUP_JMP: { switch (alpha_insn->code) { case 0: case 3: case 1: return br_call; case 2: return br_return; } } } } return br_nobranch; } /* * */ void AnalyAlphaDisassembler::store(ObjectStream &f) const { AnalyDisassembler::store(f); } ht-2.0.22/analyser/ne_analy.h0000644000175000001440000000370010615342710012701 00000000000000/* * HT Editor * ne_analy.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ne_analy_h #define ne_analy_h #include "analy.h" #include "htne.h" class NEAnalyser: public Analyser { public: ht_ne_shared_data *ne_shared; File *file; Area *validarea; NEAnalyser(); NEAnalyser(BuildCtorArg&a): Analyser(a){}; void init(ht_ne_shared_data *ne_shared, File *file); void load(ObjectStream &f); virtual void done(); virtual ObjectID getObjectID() const; virtual void beginAnalysis(); virtual uint bufPtr(Address *Addr, byte *buf, int size); bool convertAddressToNEAddress(Address *addr, NEAddress *r); virtual Address *createAddress(); Address *createAddress1616(uint16 seg, uint16 ofs); virtual Assembler *createAssembler(); virtual String & getName(String &res); virtual const char *getType(); virtual void initCodeAnalyser(); virtual void initUnasm(); virtual void log(const char *msg); virtual Address *nextValid(Address *Addr); virtual void store(ObjectStream &f) const; virtual int queryConfig(int mode); virtual Address *fileofsToAddress(FileOfs fileofs); virtual const char *getSegmentNameByAddress(Address *Addr); virtual FileOfs addressToFileofs(Address *Addr); virtual bool validAddress(Address *Addr, tsectype action); }; #endif /* ne_analy_h */ ht-2.0.22/analyser/le_analy.h0000644000175000001440000000405310615342710012701 00000000000000/* * HT Editor * le_analy.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef le_analy_h #define le_analy_h #include "analy.h" #include "htle.h" class LEAnalyser: public Analyser { public: ht_le_shared_data *le_shared; File *file; Area *validarea; LEAnalyser() {}; LEAnalyser(BuildCtorArg&a): Analyser(a) {}; void init(ht_le_shared_data *le_shared, File *file); void load(ObjectStream &f); virtual void done(); virtual ObjectID getObjectID() const; virtual void beginAnalysis(); virtual uint bufPtr(Address *Addr, byte *buf, int size); bool convertAddressToLEAddress(Address *addr, LEAddress *r); virtual Address *createAddress(); Address *createAddressFlat32(uint32 ofs); virtual Assembler *createAssembler(); virtual String & getName(String &res); virtual const char *getType(); virtual void initCodeAnalyser(); virtual void initUnasm(); virtual void log(const char *msg); virtual Address *nextValid(Address *Addr); virtual void store(ObjectStream &f) const; virtual int queryConfig(int mode); virtual Address *fileofsToAddress(FileOfs fileofs); virtual const char *getSegmentNameByAddress(Address *Addr); virtual FileOfs addressToFileofs(Address *Addr); virtual bool validAddress(Address *Addr, tsectype action); virtual Address * realFileofsToAddress(FileOfs fileofs); virtual FileOfs addressToRealFileofs(Address *Addr); }; #endif /* le_analy_h */ ht-2.0.22/analyser/analy_x86.h0000644000175000001440000001102310655731110012721 00000000000000/* * HT Editor * analy_x86.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ANALY_X86_H #define ANALY_X86_H #include "analy.h" class AddressX86Flat32: public Address { public: uint32 addr; AddressX86Flat32(BuildCtorArg&a): Address(a) {}; AddressX86Flat32(uint32 a=0): addr(a) {}; virtual bool add(int offset); virtual int byteSize(); virtual int compareTo(const Object *obj) const; virtual int compareDelinear(Address *to); virtual bool difference(int &result, Address *to); virtual AddressX86Flat32 *clone() const; virtual void getFromArray(const byte *array); virtual void getFromCPUAddress(CPU_ADDR *ca); virtual bool getFromUInt64(uint64 u); virtual void load(ObjectStream &s); virtual ObjectID getObjectID() const; virtual int parseString(const char *s, int length, Analyser *a); virtual void putIntoArray(byte *array) const; virtual void putIntoCPUAddress(CPU_ADDR *ca) const; virtual bool putIntoUInt64(uint64 &u) const; virtual void store(ObjectStream &s) const; virtual int stringify(char *s, int max_length, int format) const; virtual int stringSize() const; }; class AddressX86_1616: public Address { public: uint16 seg; uint16 addr; public: AddressX86_1616(BuildCtorArg&a): Address(a) {}; AddressX86_1616(uint16 seg=0, uint16 addr=0); virtual bool add(int offset); virtual int byteSize(); virtual int compareTo(const Object *obj) const; virtual int compareDelinear(Address *to); virtual bool difference(int &result, Address *to); virtual AddressX86_1616 *clone() const; virtual void getFromArray(const byte *array); virtual void getFromCPUAddress(CPU_ADDR *ca); virtual bool getFromUInt64(uint64 u); virtual void load(ObjectStream &s); virtual ObjectID getObjectID() const; virtual int parseString(const char *s, int length, Analyser *a); virtual void putIntoArray(byte *array) const; virtual void putIntoCPUAddress(CPU_ADDR *ca) const; virtual bool putIntoUInt64(uint64 &u) const; virtual void store(ObjectStream &s) const; virtual int stringify(char *s, int max_length, int format) const; virtual int stringSize() const; }; class AddressX86_1632: public Address { public: uint16 seg; uint32 addr; public: AddressX86_1632(BuildCtorArg&a): Address(a) {}; AddressX86_1632(uint16 seg=0, uint32 addr=0); virtual bool add(int offset); virtual int byteSize(); virtual int compareTo(const Object *obj) const; virtual int compareDelinear(Address *obj); virtual bool difference(int &result, Address *to); virtual AddressX86_1632 *clone() const; virtual void getFromArray(const byte *array); virtual void getFromCPUAddress(CPU_ADDR *ca); virtual bool getFromUInt64(uint64 u); virtual void load(ObjectStream &s); virtual ObjectID getObjectID() const; virtual int parseString(const char *s, int length, Analyser *a); virtual void putIntoArray(byte *array) const; virtual void putIntoCPUAddress(CPU_ADDR *ca) const; virtual bool putIntoUInt64(uint64 &u) const; virtual void store(ObjectStream &s) const; virtual int stringify(char *s, int max_length, int format) const; virtual int stringSize() const; }; #define ANALYX86DISASSEMBLER_FLAGS_16BIT 1 #define ANALYX86DISASSEMBLER_FLAGS_SEGMENTED 2 #define ANALYX86DISASSEMBLER_FLAGS_FLAT64 4 #define ANALYX86DISASSEMBLER_FLAGS_VXD_X86DIS 8 #define ANALYX86DISASSEMBLER_FLAGS_AMD64 16 class AnalyX86Disassembler: public AnalyDisassembler { protected: void createUnasm(); public: int flags; AnalyX86Disassembler() {}; AnalyX86Disassembler(BuildCtorArg&a): AnalyDisassembler(a) {}; void init(Analyser *A, int flags); void load(ObjectStream &f); virtual ObjectID getObjectID() const; virtual Address *branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine); Address *createAddress(uint16 segment, uint64 offset); uint16 getSegment(Address *addr); virtual void examineOpcode(OPCODE *opcode); virtual branch_enum_t isBranch(OPCODE *opcode); virtual void store(ObjectStream &f) const; }; #endif ht-2.0.22/analyser/analy.cc0000644000175000017500000012751011724770012012371 00000000000000/* * HT Editor * analy.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "analy.h" #include "analy_names.h" #include "analy_register.h" #include "code_analy.h" #include "data_analy.h" #include "io/types.h" #include "atom.h" #include "except.h" #include "htctrl.h" #include "htdebug.h" #include "strtools.h" #include "language.h" #include "snprintf.h" #include "tools.h" #define DPRINTF(msg...) //#undef DPRINTF //#define DPRINTF(msg...) {global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS;char buf[1024]; ht_snprintf(buf, sizeof buf, ##msg); fprintf(stdout, buf);} int global_analyser_address_string_format = ADDRESS_STRING_FORMAT_COMPACT; int Address::compareDelinear(Address *obj) { return compareTo(obj); } bool Address::isValid() { return true; } int Address::toString(char *s, int maxlen) const { return stringify(s, maxlen, global_analyser_address_string_format); } bool InvalidAddress::add(int offset) { return false; } int InvalidAddress::byteSize() { return 0; } int InvalidAddress::compareTo(const Object *obj) const { return 0; } void InvalidAddress::putIntoCPUAddress(CPU_ADDR *ca) const { } bool InvalidAddress::difference(int &result, Address *to) { return false; } InvalidAddress *InvalidAddress::clone() const { return new InvalidAddress(*this); } void InvalidAddress::getFromArray(const byte *array) { } void InvalidAddress::getFromCPUAddress(CPU_ADDR *ca) { } bool InvalidAddress::getFromUInt64(uint64 u) { return false; } bool InvalidAddress::isValid() { return false; } int InvalidAddress::parseString(const char *s, int length, Analyser *a) { return 0; } ObjectID InvalidAddress::getObjectID() const { return ATOM_ADDRESS_INVALID; } void InvalidAddress::putIntoArray(byte *array) const { } bool InvalidAddress::putIntoUInt64(uint64 &u) const { return false; } int InvalidAddress::stringify(char *s, int max_length, int format) const { return ht_snprintf(s, max_length, "*INVALID"); } int InvalidAddress::stringSize() const { return 8; } /* * */ bool AddressFlat32::add(int offset) { // check for overflow if ((int)offset < 0) { if (addr+offset > addr) return false; } else { if (addr+offset < addr) return false; } addr+=offset; return true; } int AddressFlat32::byteSize() { return 4; } int AddressFlat32::compareTo(const Object *obj) const { assert(getObjectID() == obj->getObjectID()); if (addr > ((AddressFlat32 *)obj)->addr) return 1; if (addr < ((AddressFlat32 *)obj)->addr) return -1; return 0; } int AddressFlat32::compareDelinear(Address *to) { assert(getObjectID() == to->getObjectID()); uint32 da = delinearize(addr); uint32 db = delinearize(((AddressFlat32 *)to)->addr); if (da > db) return 1; if (da < db) return -1; return 0; } bool AddressFlat32::difference(int &result, Address *to) { if (getObjectID() == to->getObjectID()) { result = addr - ((AddressFlat32 *)to)->addr; return true; } else { return false; } } AddressFlat32 *AddressFlat32::clone() const { return new AddressFlat32(*this); } void AddressFlat32::getFromArray(const byte *array) { memcpy(&addr, array, sizeof(addr)); } void AddressFlat32::getFromCPUAddress(CPU_ADDR *ca) { addr = ca->addr32.offset; } bool AddressFlat32::getFromUInt64(uint64 u) { if (u <= 0xffffffff) { addr = u; return true; } else { return false; } } void AddressFlat32::load(ObjectStream &st) { GET_INT32X(st, addr); } ObjectID AddressFlat32::getObjectID() const { return ATOM_ADDRESS_FLAT_32; } int AddressFlat32::parseString(const char *s, int length, Analyser *a) { return false; } void AddressFlat32::putIntoArray(byte *array) const { memcpy(array, &addr, sizeof(addr)); } void AddressFlat32::putIntoCPUAddress(CPU_ADDR *ca) const { ca->addr32.offset = addr; } bool AddressFlat32::putIntoUInt64(uint64 &u) const { u = addr; return true; } void AddressFlat32::store(ObjectStream &st) const { PUT_INT32X(st, addr); } int AddressFlat32::stringify(char *s, int max_length, int format) const { const char *formats[] = { "%s%x%s", "%s%8x%s", "%s%08x%s", "", "%s%X%s", "%s%8X%s", "%s%08X%s", "", }; return ht_snprintf(s, max_length, formats[format&7], (format & ADDRESS_STRING_FORMAT_ADD_0X) ? "0x":"", addr, (format & ADDRESS_STRING_FORMAT_ADD_H) ? "h":""); } int AddressFlat32::stringSize() const { return 8; } /* * */ bool AddressFlat64::add(int offset) { // check for overflow // FIXME: XXXXXXXXXXXXX addr += sint64(offset); return true; } int AddressFlat64::byteSize() { return 8; } int AddressFlat64::compareTo(const Object *obj) const { assert(getObjectID() == obj->getObjectID()); if (addr > ((AddressFlat64 *)obj)->addr) return 1; if (addr < ((AddressFlat64 *)obj)->addr) return -1; return 0; } int AddressFlat64::compareDelinear(Address *to) { assert(getObjectID() == to->getObjectID()); uint64 da1, da2; da1 = delinearize64(addr); da2 = delinearize64(((AddressFlat64 *)to)->addr); if (da1 > da2) return 1; if (da1 < da2) return -1; return 0; } bool AddressFlat64::difference(int &result, Address *to) { if (getObjectID() == to->getObjectID()) { uint64 res = addr - ((AddressFlat64 *)to)->addr; uint32 rh = res >> 32; if (!rh || rh == 0xffffffff) { result = res; return true; } } return false; } AddressFlat64 *AddressFlat64::clone() const { return new AddressFlat64(*this); } void AddressFlat64::getFromArray(const byte *array) { memcpy(&addr, array, sizeof(addr)); } void AddressFlat64::getFromCPUAddress(CPU_ADDR *ca) { addr = ca->flat64.addr; } bool AddressFlat64::getFromUInt64(uint64 u) { addr = u; return true; } void AddressFlat64::load(ObjectStream &st) { GET_INT64X(st, addr); } ObjectID AddressFlat64::getObjectID() const { return ATOM_ADDRESS_FLAT_64; } int AddressFlat64::parseString(const char *s, int length, Analyser *a) { return false; } void AddressFlat64::putIntoArray(byte *array) const { memcpy(array, &addr, sizeof(addr)); } void AddressFlat64::putIntoCPUAddress(CPU_ADDR *ca) const { ca->flat64.addr = addr; } bool AddressFlat64::putIntoUInt64(uint64 &u) const { u = addr; return true; } void AddressFlat64::store(ObjectStream &st) const { PUT_INT64X(st, addr); } int AddressFlat64::stringify(char *s, int max_length, int format) const { const char *formats[] = { "%s%qx%s", "%s%16qx%s", "%s%016qx%s", "", "%s%qx%s", "%s%16qx%s", "%s%016qx%s", "", }; return ht_snprintf(s, max_length, formats[format&7], (format & ADDRESS_STRING_FORMAT_ADD_0X) ? "0x":"", addr, (format & ADDRESS_STRING_FORMAT_ADD_H) ? "h":""); } int AddressFlat64::stringSize() const { return 16; } /* * */ AddrXRef::AddrXRef(Address *a, xref_enum_t Type) { addr = a->clone(); type = Type; } AddrXRef::~AddrXRef() { delete addr; } void AddrXRef::load(ObjectStream &f) { GET_OBJECT(f, addr); type = (xref_enum_t)GETX_INTX(f, 1, "type"); } ObjectID AddrXRef::getObjectID() const { return ATOM_ADDR_XREF; } void AddrXRef::store(ObjectStream &f) const { PUT_OBJECT(f, addr); PUT_INTX(f, type, 1); } int AddrXRef::compareTo(const Object *o) const { Address *a = ((AddrXRef*)o)->addr; return addr->compareTo(a); } /* * */ AddressQueueItem::AddressQueueItem(Address *aAddr, Address *aFunc) { addr = aAddr->clone(); func = aFunc->clone(); } AddressQueueItem::~AddressQueueItem() { delete addr; delete func; } ObjectID AddressQueueItem::getObjectID() const { return ATOM_ADDR_QUEUE_ITEM; } void AddressQueueItem::load(ObjectStream &f) { GET_OBJECT(f, addr); GET_OBJECT(f, func); } void AddressQueueItem::store(ObjectStream &f) const { PUT_OBJECT(f, addr); PUT_OBJECT(f, func); } /* * */ CommentList::CommentList() : Array(true) { } void CommentList::appendPreComment(const char *s) { insert(new String(s)); } void CommentList::appendPostComment(const char *s) { insert(new String(s)); } void CommentList::appendPreComment(int special) { insert(new UInt(special)); } void CommentList::appendPostComment(int special) { insert(new UInt(special+0x10000000)); } const char *CommentList::getName(uint i) { Object *d = get(findByIdx(i)); // return d ? ((d->getObjectID()==OBJID_UINT) ? comment_lookup(((UInt*)d)->value): return d ? ((String*)d)->contentChar() : NULL; } /* * */ void Analyser::init() { active = false; dirty = false; next_address_is_invalid = false; addr = new InvalidAddress(); invalid_addr = new InvalidAddress(); addr_queue = new Queue(true); locations = NULL; symbols = NULL; symbol_count = location_count = 0; cur_addr_ops = cur_label_ops = 1; setLocationTreeOptimizeThreshold(1000); setSymbolTreeOptimizeThreshold(1000); cur_func = NULL; ops_parsed = 0; next_explored = new InvalidAddress(); first_explored = new InvalidAddress(); last_explored = new InvalidAddress(); explored = new Area(); explored->init(); initialized = new Area(); initialized->init(); initCodeAnalyser(); initDataAnalyser(); disasm = NULL; analy_disasm = NULL; max_opcode_length = 1; initUnasm(); mode = ANALY_TRANSLATE_SYMBOLS; } static void loadlocations(ObjectStream &st, Location *&loc, int l, int r) { if (l > r) { loc = NULL; return; } int m = (l+r)/2; loc = new Location; loadlocations(st, loc->left, l, m-1); loc->addr = GETX_OBJECT(st , "addr"); // xrefs loc->xrefs = GETX_OBJECT(st, "xrefs"); // comments loc->comments = GETX_OBJECT(st, "comments"); analyser_get_addrtype(st, &loc->type); // must be resolved later (thisfunc is of type Location not Address) Address *a = GETX_OBJECT(st, "func"); loc->thisfunc = (Location *)a; loc->flags = GETX_INT(st, 1, "flags"); loc->label = NULL; loadlocations(st, loc->right, m+1, r); } static void loadsymbols(Analyser *analy, ObjectStream &st, Symbol *&symbol, int l, int r) { if (l > r) { symbol = NULL; return; } int m = (l+r)/2; symbol = new Symbol; loadsymbols(analy, st, symbol->left, l, m-1); Address *a = GETX_OBJECT(st, "addr"); (symbol->location = analy->newLocation(a))->label = symbol; delete a; symbol->name = st.getString("name"); symbol->type = (labeltype)GETX_INT(st, 1, "type"); loadsymbols(analy, st, symbol->right, m+1, r); } static void resolveaddrs(Analyser *a, Location *loc) { if (loc) { resolveaddrs(a, loc->left); Address *tmp = (Address*)loc->thisfunc; if (tmp->isValid()) { loc->thisfunc = a->getLocationByAddress(tmp); } else { loc->thisfunc = NULL; } delete tmp; resolveaddrs(a, loc->right); } } /* * */ void Analyser::load(ObjectStream &st) { cur_addr_ops = 0; cur_label_ops = 0; GET_OBJECT(st, addr); invalid_addr = new InvalidAddress(); GET_OBJECT(st, addr_queue); GET_INT32D(st, ops_parsed); GET_BOOL(st, active); if (active) { some_analyser_active++; } next_address_is_invalid = false; GET_OBJECT(st, next_explored); GET_OBJECT(st, first_explored); GET_OBJECT(st, last_explored); GET_INT32X(st, mode); GET_OBJECT(st, explored); GET_OBJECT(st, initialized); cur_addr_ops = cur_label_ops = 1; setLocationTreeOptimizeThreshold(1000); setSymbolTreeOptimizeThreshold(1000); GET_INT32D(st, location_count); loadlocations(st, locations, 0, location_count-1); resolveaddrs(this, locations); GET_INT32D(st, symbol_count); loadsymbols(this, st, symbols, 0, symbol_count-1); GET_OBJECT(st, analy_disasm); GET_OBJECT(st, disasm); if (analy_disasm) { analy_disasm->analy = this; analy_disasm->disasm = disasm; } GET_OBJECT(st, code); GET_OBJECT(st, data); if (data) { data->analy = this; } GET_INT32D(st, location_threshold); GET_INT32D(st, symbol_threshold); GET_INT32D(st, max_opcode_length); Address *curfuncaddr = GETX_OBJECT(st, "cur_func"); if (curfuncaddr) { cur_func = newLocation(curfuncaddr); delete curfuncaddr; } else { cur_func = NULL; } dirty = false; } /* * */ void Analyser::done() { setActive(false); freeLocations(locations); freeSymbols(symbols); delete addr_queue; if (explored) { explored->done(); delete explored; } if (initialized) { initialized->done(); delete initialized; } if (code) { code->done(); delete code; } if (data) { data->done(); delete data; } if (disasm) { disasm->done(); delete disasm; } if (analy_disasm) { analy_disasm->done(); delete analy_disasm; } delete addr; delete invalid_addr; delete next_explored; delete first_explored; delete last_explored; } /* * addAddressSymbol will never overwrite an existing label (like addlabel) */ bool Analyser::addAddressSymbol(Address *address, const char *prefix, labeltype type, Location *infunc) { if (!validAddress(address, scvalid)) return false; char symbol[1024]; global_analyser_address_string_format = ADDRESS_STRING_FORMAT_COMPACT; ht_snprintf(symbol, sizeof symbol, "%s_%y", prefix, address); if (addSymbol(address, symbol, type, infunc)) { return true; } else { return false; } } /* * */ void Analyser::addComment(Address *Addr, int line, const char *c) { // line 0 meens append (at the moment assume append every time ;-)) // if (!validaddr(Addr, scvalid)) return; Location *a = newLocation(Addr); CommentList *com = a->comments; if (!com) { com = new CommentList(); com->init(); a->comments = com; } com->appendPreComment(c); DPRINTF("#(%y) comment `%s'\n", Addr, c); } /* * addlabel: create label if there isnt one * fail if label exist on another address * */ bool Analyser::addSymbol(Address *Addr, const char *label, labeltype type, Location *infunc) { if (!validAddress(Addr, scvalid)) return false; Location *a = newLocation(Addr); if (!a->label) { Symbol *l = newSymbol(label, a, type, infunc); if (l->location->addr->compareTo(Addr) != 0) { // this label already exists at a different address return false; } a->label = l; if (a->type.type == dt_unknown || a->type.type == dt_unknown_data) { if (type == label_func && !validCodeAddress(Addr)) { type = label_unknown; } switch (type) { case label_unknown: break; case label_func: data->setCodeAddressType(a, dst_function); break; case label_loc: data->setCodeAddressType(a, dst_location); break; case label_data: data->setAddressType(a, dt_unknown_data, 0, 0); break; } } return true; } else { // adress already has a label return false; } } /* * */ bool Analyser::addXRef(Address *from, Address *to, xref_enum_t action) { if (!validAddress(from, scvalid) || !validAddress(to, scvalid)) return false; Location *a = newLocation(from); Container *x = a->xrefs; if (x) { AddrXRef tmp(to); if (x->find(&tmp)) return false; } else { x = new AVLTree(true); a->xrefs = x; } x->insert(new AddrXRef(to, action)); DPRINTF("xref %y->%y\n", from, to); return true; } /* * */ void Analyser::assignComment(Address *Addr, int line, const char *c) { /* not really implemented */ addComment(Addr, line, c); } /* * */ bool Analyser::assignSymbol(Address *Addr, const char *label, labeltype type, Location *infunc) { if (!validAddress(Addr, scvalid)) return false; Location *a = newLocation(Addr); Symbol *l = newSymbol(label, a, type, infunc); if (l->location->addr->compareTo(Addr) != 0) { // label already exists at a different address return false; } if (l->location->type.type == dt_unknown) { if (type == label_func && !validCodeAddress(Addr)) { type = label_unknown; } switch (type) { case label_unknown: break; case label_func: data->setCodeAddressType(a, dst_function); break; case label_loc: data->setCodeAddressType(a, dst_location); break; case label_data: data->setAddressType(a, dt_unknown_data, 0, 0); break; } } if (a->label) { // overwrite if (a->label != l) { // label has to be renamed disableSymbol(a->label); a->label = l; } } else { a->label = l; } return true; } /* * */ void Analyser::assignXRef(Address *from, Address *to, xref_enum_t action) { if (!validAddress(from, scvalid) || !validAddress(to, scvalid)) return; Location *a = newLocation(from); Container *x = a->xrefs; if (x) { AddrXRef *xref; AddrXRef tmp(to); if ((xref = (AddrXRef*)x->get(x->find(&tmp)))) { // update xref xref->type = action; DPRINTF("xref %y->%y updated\n", from, to); return; } } else { x = new AVLTree(true); a->xrefs = x; } x->insert(new AddrXRef(to, action)); DPRINTF("xref %y->%y\n", from, to); } /* * */ void Analyser::beginAnalysis() { if (queryConfig(Q_DO_ANALYSIS)) { DPRINTF("################################\nAnalysis started.\n"); if (analy_disasm && disasm) { ops_parsed = 0; if (gotoAddress(invalid_addr, invalid_addr)) setActive(true); } else { DPRINTF("Analysis can't be started. No disassembler available."); } } } /* * */ bool Analyser::continueAnalysis() { byte buf[32]; OPCODE *instr; int len; branch_enum_t branch; assert((uint)max_opcode_length <= sizeof buf); if (!active) return false; do { int diff; // char tbuf[100]; // char tbuf2[100]; // addr->stringify(tbuf, 100, 0); /* if (strcmp(tbuf, "200970ec") == 0) { int as=0; }*/ // printf("*** %s ***\n", tbuf); if ((addr->difference(diff, next_explored) && (diff >= 0)) || !validCodeAddress(addr)) { if (!gotoAddress(addr, invalid_addr)) { finish(); return false; } } int bz = bufPtr(addr, buf, max_opcode_length); instr = disasm->decode(buf, bz, mapAddr(addr)); instr = disasm->duplicateInsn(instr); ops_parsed++; num_ops_parsed++; len = disasm->getSize(instr); last_explored->add(len); do { DPRINTF("opcode @%y [func: %y]: %s\n", addr, (cur_func) ? cur_func->addr : invalid_addr, disasm->str(instr, 0)); if (disasm->validInsn(instr)) { branch = analy_disasm->isBranch(instr); if (branch != br_nobranch) { doBranch(branch, instr, len); } else { analy_disasm->examineOpcode(instr); } } else { DPRINTF("invalid opcode @%y\n", addr); // log("invalid opcode at address %y\n", addr); if (!addr->add(len)) { delete addr; addr = new InvalidAddress(); } else { newLocation(addr)->flags |= AF_FUNCTION_END; next_address_is_invalid = true; } } } while (disasm->selectNext(instr)); if (next_address_is_invalid || !addr->add(len)) { gotoAddress(invalid_addr, invalid_addr); next_address_is_invalid = false; } free(instr); } while ((ops_parsed % MAX_OPS_PER_CONTINUE) !=0); return true; } /* * */ void Analyser::continueAnalysisAt(Address *Addr) { if (!validAddress(Addr, sccode)) return; if (queryConfig(Q_DO_ANALYSIS)) { DPRINTF("continueing analysis at %y\n", Addr); if (active || disasm) { data->setCodeAddressType(Addr, dst_function); pushAddress(Addr, Addr); } if (!active) { if (disasm) { Analyser::beginAnalysis(); } else { DPRINTF("couldn't start analysis: no disasm available\n"); } } } } /* * should return a new instance of an apropriate assembler */ Assembler *Analyser::createAssembler() { return NULL; } /* * */ void Analyser::dataAccess(Address *Addr, taccess access) { if (!validAddress(Addr, scvalid)) { char msg[100]; global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; ht_snprintf(msg, sizeof msg, "access of invalid addr %y at addr %y", Addr, addr); log(msg); return; } DPRINTF("dataaccess of %y\n", Addr); // string test byte buffer[1024]; if (validAddress(Addr, scinitialized)) { uint bz = bufPtr(Addr, buffer, sizeof buffer); if (bz > 2) { analy_string *str = string_test(buffer, bz); if (str) { char string1[128], string2[128]; str->render_string(string2, sizeof string2); ht_snprintf(string1, sizeof string1, "%s_%s", str->name(), string2); make_valid_name(string2, string1); if (addAddressSymbol(Addr, string2, label_data)) { addComment(Addr, 0, ""); } data->setArrayAddressType(Addr, dst_string, str->length()); str->done(); delete str; return; } } } if (validCodeAddress(Addr) && access.type == acoffset) { if (addAddressSymbol(Addr, LPRFX_OFS, label_func)) { addComment(Addr, 0, ""); } Location *a = getLocationByAddress(Addr); assert(a); // test if Addr points to code if ((a->type.type == dt_unknown) || (a->type.type == dt_code)) { // test if Addr points to valid code (test not yet complete) byte buf[16]; int bz = bufPtr(Addr, buf, sizeof(buf)); OPCODE *instr = disasm->decode(buf, MIN(bz, max_opcode_length), mapAddr(Addr)); if (disasm->validInsn(instr)) { data->setCodeAddressType(Addr, dst_cunknown); pushAddress(Addr, Addr); } } } else { if (access.type != acoffset) { switch (access.size) { case 1: data->setIntAddressType(Addr, dst_ibyte, 1); break; case 2: data->setIntAddressType(Addr, dst_iword, 2); break; case 4: data->setIntAddressType(Addr, dst_idword, 4); break; } } if (validAddress(Addr, scinitialized)) { addAddressSymbol(Addr, LPRFX_DTA, label_data); } else { addAddressSymbol(Addr, LPRFX_DTU, label_data); } } } /* * disables address, frees misc */ void Analyser::deleteLocation(Address *Addr) { Location *a = getLocationByAddress(Addr); if (a) { disableSymbol(a->label); a->label = NULL; a->flags |= AF_DELETED; location_count--; } } /* * disables label of an address and unassigns address' label */ void Analyser::deleteSymbol(Address *Addr) { Location *a = getLocationByAddress(Addr); if (a) { disableSymbol(a->label); a->label = NULL; symbol_count--; } } /* * */ bool Analyser::deleteXRef(Address *from, Address *to) { if (!validAddress(from, scvalid) || !validAddress(to, scvalid)) return false; Location *a = getLocationByAddress(from); if (!a) return false; Container *x = a->xrefs; if (!x) return false; DPRINTF("deleted xref %y->%y\n", from, to); AddrXRef tmp(to); return x->delObj(&tmp); } /* * an disabled label will be overwritten as soon as possible, * and never be returned nor saved. * performed this way to preserve the labeltrees structure * */ void Analyser::disableSymbol(Symbol *label) { if (label) { label->location = NULL; } } /* * */ void Analyser::doBranch(branch_enum_t branch, OPCODE *opcode, int len) { Address *branch_addr = analy_disasm->branchAddr(opcode, branch, true); if (branch != br_return) { if (!validCodeAddress(branch_addr)) { char msg[100]; global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS; ht_snprintf(msg, sizeof msg, "branch to invalid addr %y from addr %y", branch_addr, addr); log(msg); } } /* if (branch != brcall) { taddr *a = new_addr(addr+len); if (!a->comments) { add_comment(a->addr, 0, ""); } }*/ Address *next_addr = addr->clone(); if (!next_addr->add(len)) { delete next_addr; next_addr = new InvalidAddress(); } switch (branch) { case br_jump: if (next_addr->isValid()) newLocation(next_addr)->flags |= AF_FUNCTION_END; addXRef(branch_addr, addr, xrefjump); if (addAddressSymbol(branch_addr, LPRFX_LOC, label_loc, cur_func)) { addComment(branch_addr, 0, ""); } // gotoAddress(branch_addr, invalid_addr); pushAddress(branch_addr, invalid_addr); next_address_is_invalid = true; break; case br_return: if (next_addr->isValid()) newLocation(next_addr)->flags |= AF_FUNCTION_END; next_address_is_invalid = true; break; case br_call: { addXRef(branch_addr, addr, xrefcall); bool special_func = false; const char *lprfx = LPRFX_SUB; if (!getSymbolByAddress(branch_addr) && validCodeAddress(branch_addr)) { // should be in code_analy byte buf[16]; int bz = bufPtr(branch_addr, buf, sizeof(buf)); OPCODE *instr = disasm->decode(buf, MIN(bz, max_opcode_length), mapAddr(branch_addr)); branch_enum_t bt = analy_disasm->isBranch(instr); if (bt == br_return) { lprfx = LPRFX_STUB; } else if (bt == br_jump) { char buf[1024], label[1024]; Address *wrap_addr = analy_disasm->branchAddr(instr, bt, false); if (validAddress(wrap_addr, scvalid)) { Symbol *l = getSymbolByAddress(wrap_addr); addComment(branch_addr, 0, ""); addComment(branch_addr, 0, ";----------------------------------------------"); global_analyser_address_string_format = ADDRESS_STRING_FORMAT_COMPACT; if (l && l->name) { ht_snprintf(buf, sizeof buf, "%s %s", "; W R A P P E R for", l->name); ht_snprintf(label, sizeof label, "%s_%s_%y", LPRFX_WRAP, l->name, branch_addr); } else { ht_snprintf(buf, sizeof buf, "%s %s %y", "; W R A P P E R for", "address", wrap_addr); ht_snprintf(label, sizeof label, "%s_%y_%y", LPRFX_WRAP, wrap_addr, branch_addr); } addComment(branch_addr, 0, buf); addComment(branch_addr, 0, ";----------------------------------------------"); addSymbol(branch_addr, label, label_func); special_func = true; } delete wrap_addr; } } if (!special_func && addAddressSymbol(branch_addr, lprfx, label_func)) { addComment(branch_addr, 0, ""); addComment(branch_addr, 0, ";-----------------------"); addComment(branch_addr, 0, "; S U B R O U T I N E"); addComment(branch_addr, 0, ";-----------------------"); if (branch_addr->compareTo(cur_func->addr) == 0) { addComment(branch_addr, 0, "; (recursive)"); } } // pushAddress(next_addr, cur_func->addr); // gotoAddress(branch_addr, branch_addr); pushAddress(branch_addr, branch_addr); break; } case br_jXX: addXRef(branch_addr, addr, xrefjump); if (addAddressSymbol(branch_addr, LPRFX_LOC, label_loc, cur_func)) { addComment(branch_addr, 0, ""); } // pushAddress(next_addr, cur_func->addr); // gotoAddress(branch_addr, invalid_addr); pushAddress(branch_addr, invalid_addr); break; default:{} // stupid but neccessary } delete next_addr; delete branch_addr; } /* * */ void Analyser::engageCodeanalyser() { if (queryConfig(Q_ENGAGE_CODE_ANALYSER)) { DPRINTF("starting code analyser.\n"); } } static void analyserenum_addrs(Location *locs, Address *at, Location *&loc) { if ((at->compareTo(locs->addr) < 0) || !at->isValid()) { loc = locs; if (locs->left) analyserenum_addrs(locs->left, at, loc); } else /*if (at >= locs->addr)*/ { if (locs->right) analyserenum_addrs(locs->right, at, loc); } } /* * */ Location *Analyser::enumLocations(Address *Addr) { Location *result = NULL; if (locations) analyserenum_addrs(locations, Addr, result); while (result && (result->flags & AF_DELETED)) { Address *a = result->addr; result = NULL; analyserenum_addrs(locations, a, result); } return result; } static void analyserenum_addrs_back(Location *locs, Address *at, Location *&loc) { if (at->compareTo(locs->addr) <= 0) { if (locs->left) analyserenum_addrs_back(locs->left, at, loc); } else /*if (at > locs->addr)*/ { loc = locs; if (locs->right) analyserenum_addrs_back(locs->right, at, loc); } } /* * */ Location *Analyser::enumLocationsReverse(Address *Addr) { Location *result = NULL; if (locations) analyserenum_addrs_back(locations, Addr, result); while ((result) && (result->flags & AF_DELETED)) { Address *a = result->addr; result = NULL; analyserenum_addrs_back(locations, a, result); } return result; } static void analyserenum_labels(Symbol *labels, const char *at, Symbol *&label) { int i = strcmp(at, labels->name); if (i < 0) { label = labels; if (labels->left) analyserenum_labels(labels->left, at, label); } else /*if (i >= 0)*/ { if (labels->right) analyserenum_labels(labels->right, at, label); } } /* * returns the (alphanumerically) next label to "at" * or the first if "at" is NULL * returns NULL if there is no preceding label * */ Symbol *Analyser::enumSymbolsByName(const char *at) { Symbol *result = NULL; if (!at) at=""; if (symbols) analyserenum_labels(symbols, at, result); // label with !addr mustnt be returned while ((result) && (!result->location)) { char *name = result->name; result = NULL; analyserenum_labels(symbols, name, result); } return result; } static void analyserenum_labels_back(Symbol *labels, const char *at, Symbol *&label) { int i = strcmp(at, labels->name); if (i <= 0) { if (labels->left) analyserenum_labels_back(labels->left, at, label); } else /*if (i >= 0)*/ { label = labels; if (labels->right) analyserenum_labels_back(labels->right, at, label); } } /* * */ Symbol *Analyser::enumSymbolsByNameReverse(const char *at) { Symbol *result = NULL; // FIXME: if (!at) at="\xff\xff\xff"; if (symbols) analyserenum_labels_back(symbols, at, result); // labels with !addr mustnt be returned while ((result) && (!result->location)) { char *name = result->name; result = NULL; analyserenum_labels_back(symbols, name, result); } return result; } Symbol *Analyser::enumSymbols(Symbol *sym) { if (sym) { return enumSymbolsByName(sym->name); } else { return enumSymbolsByName(NULL); } } Symbol *Analyser::enumSymbolsReverse(Symbol *sym) { if (sym) { return enumSymbolsByNameReverse(sym->name); } else { return enumSymbolsByNameReverse(NULL); } } /* * */ taddr_typetype Analyser::examineData(Address *Addr) { if ((validReadAddress(Addr)) && (validAddress(Addr, scinitialized))) { DPRINTF("examinating data @%y:\n", Addr); } else return dt_unknown; return dt_unknown; } /* * */ static Location *analyserfindaddr(Location *locs, Address *Addr) { if (locs) { if (Addr->compareTo(locs->addr) < 0) return analyserfindaddr(locs->left, Addr); if (Addr->compareTo(locs->addr) > 0) return analyserfindaddr(locs->right, Addr); return (locs->flags & AF_DELETED) ? NULL : locs; } return NULL; } /* * */ Location *Analyser::getLocationByAddress(Address *Addr) { return analyserfindaddr(locations, Addr); } /* * finds the address Addr belongs to (if address has size > 1) */ Location *Analyser::getLocationContextByAddress(Address *Addr) { Location *res = enumLocationsReverse(Addr); if (res && res->type.type != dt_unknown) { Address *resaddr = res->addr->clone(); resaddr->add(res->type.length); if (resaddr->compareTo(Addr) > 0) { delete resaddr; return res; } delete resaddr; } return NULL; } /* * finds the function the Addr belongs to (if possible/applicable). */ Location *Analyser::getFunctionByAddress(Address *Addr) { Location *loc = getLocationByAddress(Addr); if (!loc) loc = enumLocationsReverse(Addr); while (loc && !(loc->flags & AF_FUNCTION_SET)) { if (loc->flags & AF_FUNCTION_END) return NULL; loc = enumLocationsReverse(loc->addr); } return loc ? loc->thisfunc : NULL; } /* * searches back to the last location */ Location *Analyser::getPreviousSymbolByAddress(Address *Addr) { Location *loc = getLocationByAddress(Addr); if (!loc) loc = enumLocationsReverse(Addr); while (loc && !loc->label) { if (loc->flags & AF_FUNCTION_END) return NULL; loc = enumLocationsReverse(loc->addr); } return loc ? loc : NULL; } /* * */ static Symbol *analyserfindlabel(Symbol *labels, const char *label) { if (labels) { int i = strcmp(label, labels->name); if (i < 0) return analyserfindlabel(labels->left, label); if (i > 0) return analyserfindlabel(labels->right, label); return labels->location ? labels : NULL; } return NULL; } /* * */ Symbol *Analyser::getSymbolByName(const char *label) { return analyserfindlabel(symbols, label); } const char *Analyser::getSymbolNameByLocation(Location *loc) { return loc ? (loc->label ? loc->label->name : NULL): NULL; } /** * converts |FileOfs fileofs| to |Address| */ Address *Analyser::fileofsToAddress(FileOfs fileaddr) { // abstract / stub return new InvalidAddress(); } /** * called once every time the analyser has nothing more to do. */ void Analyser::finish() { DPRINTF("the analyser finished (for now).\n"); cur_func = NULL; delete addr; addr = new InvalidAddress(); setActive(false); } /* * */ void Analyser::freeLocation(Location *loc) { if (loc) { // label will be freed separatly delete loc->xrefs; freeComments(loc); delete loc->addr; delete loc; } } /* * */ void Analyser::freeLocations(Location *addrs) { if (addrs) { freeLocations(addrs->left); freeLocations(addrs->right); freeLocation(addrs); } } /* * */ void Analyser::freeComments(Location *aAddr) { delete aAddr->comments; aAddr->comments = NULL; } /* * */ void Analyser::freeSymbol(Symbol *label) { if (label) { free(label->name); delete label; } } /* * */ void Analyser::freeSymbols(Symbol *labels) { if (labels) { freeSymbols(labels->left); freeSymbols(labels->right); freeSymbol(labels); } } /* * */ CommentList *Analyser::getComments(Address *Addr) { Location *a = getLocationByAddress(Addr); if (a) { return a->comments; } return NULL; } static char *analy_addr_sym_func2(CPU_ADDR Addr, int *symstrlen, void *analy) { Address *a = ((Analyser*)analy)->createAddress(); a->getFromCPUAddress(&Addr); Location *loc = ((Analyser*)analy)->getLocationByAddress(a); delete a; if (loc && loc->label) { if (symstrlen) *symstrlen = strlen(loc->label->name); return loc->label->name; } return NULL; } /* * */ const char *Analyser::getDisasmStr(Address *Addr, int &length) { if (validAddress(Addr, scinitialized)) { if (disasm) { addr_sym_func = NULL; byte buf[16]; int bz = bufPtr(Addr, buf, sizeof(buf)); OPCODE *o = disasm->decode(buf, MIN(bz, max_opcode_length), mapAddr(Addr)); length = disasm->getSize(o); return disasm->strf(o, DIS_STYLE_HEX_NOZEROPAD+DIS_STYLE_HEX_ASMSTYLE, DISASM_STRF_SMALL_FORMAT); } else { return ""; } } else { return ""; } } /* * */ const char *Analyser::getDisasmStrFormatted(Address *Addr) { if (disasm) { addr_sym_func_context = this; addr_sym_func = &analy_addr_sym_func2; byte buf[16]; int bz = bufPtr(Addr, buf, sizeof(buf)); OPCODE *o=disasm->decode(buf, MIN(bz, max_opcode_length), mapAddr(Addr)); const char *res = disasm->strf(o, DIS_STYLE_HEX_NOZEROPAD+DIS_STYLE_HEX_ASMSTYLE, DISASM_STRF_SMALL_FORMAT); addr_sym_func_context = NULL; addr_sym_func = NULL; return res; } else { return ""; } } /* * */ int Analyser::getDisplayMode() { return mode; } static void analysergetlocationcount(Location *addr, int *c) { if (addr) { analysergetlocationcount(addr->left, c); if (!(addr->flags & AF_DELETED)) (*c)++; analysergetlocationcount(addr->right, c); } } /* * */ int Analyser::getLocationCount() const { int c=0; analysergetlocationcount(locations, &c); return c; } /* * */ String & Analyser::getName(String &res) { return res = "generic"; } static void analysergetsymbolcount(Symbol *l, int *c) { if (l) { analysergetsymbolcount(l->left, c); if (l->location) (*c)++; analysergetsymbolcount(l->right, c); } } /* * */ int Analyser::getSymbolCount() const { int c=0; analysergetsymbolcount(symbols, &c); return c; } /* * */ const char *Analyser::getSegmentNameByAddress(Address *Addr) { return NULL; } /* * */ Symbol *Analyser::getSymbolByAddress(Address *Addr) { Location *a = getLocationByAddress(Addr); return (a) ? a->label : NULL; } /* * */ const char *Analyser::getType() { return "generic"; } /* * */ Container *Analyser::getXRefs(Address *Addr) { Location *a = getLocationByAddress(Addr); if (!a) return NULL; return a->xrefs; } /* * */ bool Analyser::gotoAddress(Address *aAddr, Address *func) { DPRINTF("goto(%y, %y)\n", aAddr, func); int diff; if (first_explored->difference(diff, last_explored) && diff < 0) { DPRINTF("explored->add(%y - %y)\n", first_explored, last_explored); explored->add(first_explored, last_explored); } delete first_explored; delete last_explored; delete next_explored; func = func->clone(); if (!validCodeAddress(aAddr) || explored->contains(aAddr)) { DPRINTF("Address: %y Valid: %d Explored: %d\n", addr, validCodeAddress(addr), explored->contains(addr)); do { delete addr; delete func; if (!popAddress(&addr, &func)) { first_explored = new InvalidAddress(); last_explored = new InvalidAddress(); next_explored = new InvalidAddress(); addr = new InvalidAddress(); return false; } DPRINTF("pop %y (Valid: %d Explored: %d)\n", addr, validCodeAddress(addr), explored->contains(addr)); } while ((explored->contains(addr)) || (!validCodeAddress(addr))); } else { if (addr != aAddr) { delete addr; addr = aAddr->clone(); } } if (func->isValid()) { cur_func = newLocation(func); setLocationFunction(cur_func, cur_func); } delete func; next_explored = (Address *)explored->findNext(addr); if (!next_explored) { next_explored = new InvalidAddress(); } else { next_explored = next_explored->clone(); } first_explored = addr->clone(); last_explored = addr->clone(); return true; } /* * */ void Analyser::initCodeAnalyser() { code = new CodeAnalyser(); code->init(this); } /* * */ void Analyser::initDataAnalyser() { data = new DataAnalyser(); data->init(this); } /* * */ bool Analyser::isDirty() { return dirty; } /* * */ void Analyser::log(const char *s) { // stub } /* * */ void Analyser::makeDirty() { dirty = true; } /* * */ CPU_ADDR Analyser::mapAddr(Address *aAddr) { /* * this function should map the independent address Addr to a * processor dependent * e.g. .23423 --> 00234324 (or something like this) * it is only used for relativ calls/jumps */ CPU_ADDR a; aAddr->putIntoCPUAddress(&a); return a; } Location *Analyser::newLocation(Location *&locs, Address *aAddr) { if (locs) { if (aAddr->compareTo(locs->addr) < 0) return newLocation(locs->left, aAddr); if (aAddr->compareTo(locs->addr) > 0) return newLocation(locs->right, aAddr); } else { locs = new Location; memset(locs, 0, sizeof *locs); locs->addr = aAddr->clone(); location_count++; } locs->flags &= ~AF_DELETED; return locs; } /* * */ Location *Analyser::newLocation(Address *Addr) { /* if (!(cur_addr_ops--)) { optimizeLocationTree(); }*/ return newLocation(locations, Addr); } Symbol *Analyser::newSymbol(Symbol *&labels, const char *label, Location *loc, labeltype type) { if (labels) { int i = strcmp(label, labels->name); if (i < 0) return newSymbol(labels->left, label, loc, type); if (i > 0) return newSymbol(labels->right, label, loc, type); if (!labels->location) { labels->location = loc; if (type != label_unknown) labels->type = type; } } else { labels = new Symbol; labels->name = ht_strdup(label); labels->location = loc; labels->type = type; labels->left = NULL; labels->right = NULL; symbol_count++; } return labels; } /* * */ Symbol *Analyser::newSymbol(const char *label, Location *loc, labeltype type, Location *infunc) { /* if (!(cur_label_ops--)) { optimizeSymbolTree(); }*/ Symbol *result = newSymbol(symbols, label, loc, type); if ((result) && (result->location==loc) && (infunc)) setLocationFunction(loc, infunc); return result; } /* * optimizes(=balances) addr tree */ void Analyser::optimizeLocationTree() { cur_addr_ops = location_threshold; // implement me! } /* * see optimize_addr_tree() */ void Analyser::optimizeSymbolTree() { cur_label_ops = symbol_threshold; // implement me! } /* * */ bool Analyser::popAddress(Address **Addr, Address **func) { if (!addr_queue->isEmpty()) { AddressQueueItem *aqi = (AddressQueueItem *) addr_queue->deQueue(); *Addr = aqi->addr->clone(); *func = aqi->func->clone(); delete aqi; DPRINTF("addr %y (from sub %y) poped\n", *Addr, *func); return true; } else { DPRINTF("pop failed -> analyser obviously finished\n"); return false; } } /* * */ void Analyser::pushAddress(Address *Addr, Address *func) { if (validCodeAddress(Addr)) { if (!func->isValid()) { if (cur_func) { func = cur_func->addr; } } DPRINTF("addr %y (from func %y) pushed\n", Addr, func); AddressQueueItem *aqi = new AddressQueueItem(Addr, func); addr_queue->enQueue(aqi); } } /* * */ int Analyser::queryConfig(int mode) { switch (mode) { case Q_DO_ANALYSIS: case Q_ENGAGE_CODE_ANALYSER: case Q_ENGAGE_DATA_ANALYSER: return true; default: return 0; } } static void saveaddrs(ObjectStream &st, Location *addr) { if (addr) { saveaddrs(st, addr->left); if (!(addr->flags & AF_DELETED)) { PUTX_OBJECT(st, addr->addr, "addr"); PUTX_OBJECT(st, addr->xrefs, "xrefs"); PUTX_OBJECT(st, addr->comments, "comments"); analyser_put_addrtype(st, &addr->type); if (addr->thisfunc) { PUTX_OBJECT(st, addr->thisfunc->addr, "func"); } else { Address *invalid_addr = new InvalidAddress(); PUTX_OBJECT(st, invalid_addr, "func"); delete invalid_addr; } PUTX_INT8X(st, addr->flags, "flags"); } saveaddrs(st, addr->right); } } static void savelabels(ObjectStream &st, Symbol *label) { if (label) { savelabels(st, label->left); if (label->location) { // label isn't deleted PUTX_OBJECT(st, label->location->addr, "addr"); PUTX_STRING(st, label->name, "name"); int a = (int)label->type; PUTX_INTX(st, a, 1, "type"); } savelabels(st, label->right); } } /* * */ void Analyser::store(ObjectStream &st) const { PUT_OBJECT(st, addr); PUT_OBJECT(st, addr_queue); PUT_INT32D(st, ops_parsed); PUT_BOOL(st, active); PUT_OBJECT(st, next_explored); PUT_OBJECT(st, first_explored); PUT_OBJECT(st, last_explored); PUT_INT32X(st, mode); PUT_OBJECT(st, explored); PUT_OBJECT(st, initialized); st.putComment("locations"); PUTX_INT32D(st, getLocationCount(), "location_count"); saveaddrs(st, locations); st.putComment("symbols"); PUTX_INT32D(st, getSymbolCount(), "symbol_count"); savelabels(st, symbols); PUT_OBJECT(st, analy_disasm); PUT_OBJECT(st, disasm); PUT_OBJECT(st, code); PUT_OBJECT(st, data); PUT_INT32D(st, location_threshold); PUT_INT32D(st, symbol_threshold); PUT_INT32D(st, max_opcode_length); if (cur_func) { PUTX_OBJECT(st, cur_func->addr, "cur_func"); } else { PUTX_OBJECT(st, NULL, "cur_func"); } dirty = false; } /* * */ void Analyser::setActive(bool mode) { if (mode) { if (!active) { active = true; some_analyser_active++; } } else { if (active) { active = false; some_analyser_active--; } } } /* * */ void Analyser::setDisplayMode(int enable, int disable) { mode &= ~disable; mode |= enable; } /* * */ void Analyser::setLocationFunction(Location *a, Location *func) { if (a) { a->thisfunc = func; a->flags &= !AF_FUNCTION_END; a->flags |= AF_FUNCTION_SET; } } /* * */ void Analyser::setDisasm(Disassembler *d) { disasm = d; if (disasm) { int t; disasm->getOpcodeMetrics(t, max_opcode_length, t, t, t); } else { max_opcode_length = 1; } } /* * sets addr_threshold. after threshold addr_tree ops the tree will * be optimized */ void Analyser::setLocationTreeOptimizeThreshold(int threshold) { location_threshold = threshold; if (cur_addr_ops > location_threshold) cur_addr_ops = location_threshold; } /* * see set_addr_tree_optimize_threshold */ void Analyser::setSymbolTreeOptimizeThreshold(int threshold) { symbol_threshold = threshold; if (cur_label_ops > symbol_threshold) cur_label_ops = symbol_threshold; } /* * */ void Analyser::toggleDisplayMode(int toggle) { mode ^= toggle; } /* * */ bool Analyser::validCodeAddress(Address *Addr) { Location *a = getLocationByAddress(Addr); if (a) { if ((a->type.type != dt_code) && (a->type.type != dt_unknown)) return false; } return validAddress(Addr, sccode); } /* * */ bool Analyser::validReadAddress(Address *Addr) { return validAddress(Addr, scread); } /* * */ bool Analyser::validWriteAddress(Address *Addr) { return validAddress(Addr, scwrite); } /****************************************************************************/ AnalyDisassembler::AnalyDisassembler() { disasm = NULL; } /* * */ void AnalyDisassembler::init(Analyser *A) { analy = A; initDisasm(); } /* * */ void AnalyDisassembler::initDisasm() { if (analy) { analy->setDisasm(disasm); } } ht-2.0.22/analyser/flt_analy.cc0000644000175000001440000001575710615342710013241 00000000000000/* * HT Editor * flt_analy.cc * * Copyright (C) 1999-2003 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "analy.h" #include "analy_alpha.h" #include "analy_names.h" #include "analy_ia64.h" #include "analy_ppc.h" #include "analy_register.h" #include "analy_x86.h" #include "flt_analy.h" #include "htctrl.h" #include "htdebug.h" #include "htiobox.h" #include "htflt.h" #include "strtools.h" #include "pestruct.h" #include "snprintf.h" //#include "x86asm.h" #include #include #include /* * */ void FLTAnalyser::init(ht_flt_shared_data *Flt_shared, File *File) { flt_shared = Flt_shared; file = File; validarea = new Area(); validarea->init(); Analyser::init(); } void FLTAnalyser::beginAnalysis() { setLocationTreeOptimizeThreshold(100); setSymbolTreeOptimizeThreshold(100); /* * give all sections a descriptive comment: */ Address *secaddr; secaddr = createAddress32(flt_shared->code_start); if (validAddress(secaddr, scvalid)) { addComment(secaddr, 0, ""); addComment(secaddr, 0, ";******************************************************************"); addComment(secaddr, 0, "; start of code"); addComment(secaddr, 0, ";******************************************************************"); } delete secaddr; secaddr = createAddress32(flt_shared->data_start); if (validAddress(secaddr, scvalid)) { addComment(secaddr, 0, ""); addComment(secaddr, 0, ";******************************************************************"); addComment(secaddr, 0, "; start of data"); addComment(secaddr, 0, ";******************************************************************"); } delete secaddr; secaddr = createAddress32(flt_shared->bss_start); if (validAddress(secaddr, scvalid)) { addComment(secaddr, 0, ""); addComment(secaddr, 0, ";******************************************************************"); addComment(secaddr, 0, "; start of bss"); addComment(secaddr, 0, ";******************************************************************"); } delete secaddr; Address *secaddr1, *secaddr2; secaddr1 = createAddress32(flt_shared->code_start); secaddr2 = createAddress32(flt_shared->bss_end); validarea->add(secaddr1, secaddr2); delete secaddr1; delete secaddr2; /* * entrypoint */ Address *entry; entry = createAddress32(flt_shared->header.entry); pushAddress(entry, entry); assignSymbol(entry, "entrypoint", label_func); addComment(entry, 0, ""); addComment(entry, 0, ";****************************"); addComment(entry, 0, "; entrypoint"); addComment(entry, 0, ";****************************"); delete entry; setLocationTreeOptimizeThreshold(1000); setSymbolTreeOptimizeThreshold(1000); Analyser::beginAnalysis(); } /* * */ void FLTAnalyser::load(ObjectStream &f) { GET_OBJECT(f, validarea); Analyser::load(f); } /* * */ void FLTAnalyser::done() { validarea->done(); delete validarea; Analyser::done(); } ObjectID FLTAnalyser::getObjectID() const { return ATOM_FLT_ANALYSER; } /* * */ uint FLTAnalyser::bufPtr(Address *Addr, byte *buf, int size) { FileOfs ofs = addressToFileofs(Addr); /* if (ofs == INVALID_FILE_OFS) { int as = 1; }*/ assert(ofs != INVALID_FILE_OFS); file->seek(ofs); return file->read(buf, size); } bool FLTAnalyser::convertAddressToFLTAddress(Address *addr, FLTAddress *r) { if (addr->getObjectID()==ATOM_ADDRESS_FLAT_32) { *r = ((AddressFlat32*)addr)->addr; return true; } else { return false; } } Address *FLTAnalyser::createAddress() { return new AddressFlat32(); } Address *FLTAnalyser::createAddress32(uint32 addr) { return new AddressFlat32(addr); } /* * */ Assembler *FLTAnalyser::createAssembler() { return NULL; } /* * */ FileOfs FLTAnalyser::addressToFileofs(Address *Addr) { if (validAddress(Addr, scinitialized)) { FLTAddress ea; if (!convertAddressToFLTAddress(Addr, &ea)) return INVALID_FILE_OFS; return (FileOfs)ea; } else { return INVALID_FILE_OFS; } } /* * */ const char *FLTAnalyser::getSegmentNameByAddress(Address *Addr) { FLTAddress ea; if (!convertAddressToFLTAddress(Addr, &ea)) return NULL; if (ea >= flt_shared->code_start) { if (ea >= flt_shared->data_start) { if (ea >= flt_shared->bss_start) { if (ea >= flt_shared->bss_end) { return NULL; } return "bss"; } return "data"; } return "code"; } return NULL; } /* * */ String &FLTAnalyser::getName(String &res) { return file->getDesc(res); } /* * */ const char *FLTAnalyser::getType() { return "FLAT/Analyser"; } /* * */ void FLTAnalyser::initCodeAnalyser() { Analyser::initCodeAnalyser(); } /* * */ void FLTAnalyser::initUnasm() { DPRINTF("flt_analy: "); // DPRINTF("initing analy_ppc_disassembler\n"); analy_disasm = NULL; // ((AnalyPPCDisassembler*)analy_disasm)->init(this); } /* * */ void FLTAnalyser::log(const char *msg) { /* * log() does to much traffic so dont log * perhaps we reactivate this later * */ /* LOG(msg);*/ } /* * */ Address *FLTAnalyser::nextValid(Address *Addr) { return (Address *)validarea->findNext(Addr); } /* * */ void FLTAnalyser::store(ObjectStream &f) const { PUT_OBJECT(f, validarea); Analyser::store(f); } /* * */ int FLTAnalyser::queryConfig(int mode) { switch (mode) { case Q_DO_ANALYSIS: case Q_ENGAGE_CODE_ANALYSER: case Q_ENGAGE_DATA_ANALYSER: return true; default: return 0; } } /* * */ Address *FLTAnalyser::fileofsToAddress(FileOfs fileofs) { FLTAddress ea = (FLTAddress)fileofs; if (ea >= flt_shared->code_start && ea < flt_shared->data_end) { return createAddress32(ea); } else { return new InvalidAddress(); } } /* * */ bool FLTAnalyser::validAddress(Address *Addr, tsectype action) { FLTAddress ea; if (!convertAddressToFLTAddress(Addr, &ea)) return false; if (ea >= flt_shared->code_start) { if (ea >= flt_shared->data_start) { if (ea >= flt_shared->bss_start) { if (ea >= flt_shared->bss_end) { return false; } switch (action) { case scvalid: case scread: case scwrite: case screadwrite: return true; case sccode: case scinitialized: return false; } } switch (action) { case scvalid: case scread: case scwrite: case screadwrite: case scinitialized: return true; case sccode: return false; } } switch (action) { case scvalid: case scread: case scinitialized: return true; case scwrite: case screadwrite: case sccode: return false; } } return false; } ht-2.0.22/analyser/analy_register.h0000644000175000001440000000434210615342707014134 00000000000000/* * HT Editor * analy_register.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ANALY_REGISTER #define ANALY_REGISTER #include "tools.h" /* * AAS.: analyser disassembler */ #define ATOM_ANALY_ALPHA MAGIC32("AAS\x00") #define ATOM_ANALY_X86 MAGIC32("AAS\x01") #define ATOM_ANALY_IA64 MAGIC32("AAS\x02") #define ATOM_ANALY_IL MAGIC32("AAS\x03") #define ATOM_ANALY_JAVA MAGIC32("AAS\x04") #define ATOM_ANALY_PPC MAGIC32("AAS\x05") #define ATOM_ANALY_ARM MAGIC32("AAS\x06") /* * ANX.: analyser objects */ #define ATOM_CODE_ANALYSER MAGIC32("ANX\x00") #define ATOM_DATA_ANALYSER MAGIC32("ANX\x01") #define ATOM_ADDR_QUEUE_ITEM MAGIC32("ANX\x80") #define ATOM_ADDR_XREF MAGIC32("ANX\x81") /* * ANA.: analysers */ #define ATOM_PE_ANALYSER MAGIC32("ANA\x50") #define ATOM_ELF_ANALYSER MAGIC32("ANA\x51") #define ATOM_COFF_ANALYSER MAGIC32("ANA\x52") #define ATOM_NE_ANALYSER MAGIC32("ANA\x53") #define ATOM_CLASS_ANALYSER MAGIC32("ANA\x54") #define ATOM_LE_ANALYSER MAGIC32("ANA\x55") #define ATOM_MACHO_ANALYSER MAGIC32("ANA\x56") #define ATOM_FLT_ANALYSER MAGIC32("ANA\x57") #define ATOM_XBE_ANALYSER MAGIC32("ANA\x58") #define ATOM_PEF_ANALYSER MAGIC32("ANA\x59") #define ATOM_XEX_ANALYSER MAGIC32("ANA\x5a") /* * ADR.: addresses */ #define ATOM_ADDRESS_INVALID MAGIC32("ADR\x00") #define ATOM_ADDRESS_FLAT_32 MAGIC32("ADR\x01") #define ATOM_ADDRESS_FLAT_64 MAGIC32("ADR\x02") #define ATOM_ADDRESS_X86_FLAT_32 MAGIC32("ADR\x10") #define ATOM_ADDRESS_X86_1616 MAGIC32("ADR\x11") #define ATOM_ADDRESS_X86_1632 MAGIC32("ADR\x12") bool init_analyser(); void done_analyser(); #endif ht-2.0.22/analyser/analy_arm.cc0000644000175000001440000000363010615342774013230 00000000000000#include "analy_arm.h" #include "analy_register.h" #include "armdis.h" void AnalyArmDisassembler::init(Analyser *A) { disasm = new ArmDisassembler(); AnalyDisassembler::init(A); } ObjectID AnalyArmDisassembler::getObjectID() const { return ATOM_ANALY_ARM; } Address *AnalyArmDisassembler::branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine) { ArmDisInsn *insn = static_cast(opcode); if (insn->offset != ~0u) return new AddressFlat32(insn->offset); return new InvalidAddress(); } void AnalyArmDisassembler::examineOpcode(OPCODE *opcode) { ArmDisInsn *insn = static_cast(opcode); if (insn->offset == ~0u) return; if (insn->opstr[0] == 'b') return; AddressFlat32 addr(insn->offset); if (!analy->validAddress(&addr, scvalid)) return; analy->data->setIntAddressType(&addr, dst_idword, 4); analy->addXRef(&addr, analy->addr, xrefread); } branch_enum_t AnalyArmDisassembler::isBranch(OPCODE *opcode) { ArmDisInsn *dis_insn = static_cast(opcode); if (dis_insn->opstr[0] != 'b') { if (strstr(dis_insn->opstr, "pc, lr") != NULL) return dis_insn->iscond ? br_nobranch : br_return; if (strstr(dis_insn->opstr, "pc}") != NULL && dis_insn->opstr[0] == 'l') return dis_insn->iscond ? br_nobranch : br_return; if (strstr(dis_insn->opstr, " pc,") != NULL || strstr(dis_insn->opstr, "\tpc,") != NULL) return dis_insn->iscond ? br_jXX : br_jump; return br_nobranch; } if (dis_insn->opstr[1] <= ' ') return br_jump; if (dis_insn->opstr[1] == 'l' && !dis_insn->iscond) return br_call; if (dis_insn->opstr[1] == 'x' && !dis_insn->iscond) { if (strstr(dis_insn->opstr + 2, "lr") != NULL) return br_return; return br_jump; } return br_jXX; } ht-2.0.22/analyser/analy_ppc.h0000644000175000001440000000265310615342707013075 00000000000000/* * HT Editor * analy_ppc.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ANALY_PPC_H #define ANALY_PPC_H #include "analy.h" #include "ppcdis.h" #define ANALY_PPC_32 0 #define ANALY_PPC_64 1 class AnalyPPCDisassembler: public AnalyDisassembler { int mode; public: AnalyPPCDisassembler() {}; AnalyPPCDisassembler(BuildCtorArg&a): AnalyDisassembler(a) {}; void init(Analyser *A, int mode); virtual void done(); virtual ObjectID getObjectID() const; void load(ObjectStream &f); virtual Address *branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine); Address *createAddress(uint64 offset); virtual void examineOpcode(OPCODE *opcode); virtual branch_enum_t isBranch(OPCODE *opcode); virtual void store(ObjectStream &f) const; }; #endif ht-2.0.22/analyser/Makefile.am0000644000175000017500000000175411724770077013026 00000000000000AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/asm \ -I$(top_srcdir)/io/@IO_DIR@ -I$(top_srcdir)/io \ -I$(top_srcdir)/output -I$(top_srcdir)/eval AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_LIBRARIES = libanalyser.a libanalyser_a_SOURCES = analy.cc analy.h analy_alpha.cc analy_alpha.h \ analy_names.cc analy_names.h analy_x86.cc analy_x86.h analyinfo.h \ code_analy.cc code_analy.h data_analy.cc data_analy.h \ language.cc language.h pe_analy.cc pe_analy.h stddata.cc stddata.h \ elf_analy.cc elf_analy.h analy_register.cc analy_register.h \ coff_analy.cc coff_analy.h analy_java.cc analy_java.h \ class_analy.cc class_analy.h ne_analy.cc ne_analy.h \ analy_il.cc analy_il.h analy_ia64.cc analy_ia64.h le_analy.cc le_analy.h \ analy_ppc.cc analy_ppc.h macho_analy.cc macho_analy.h flt_analy.cc flt_analy.h \ xbe_analy.cc xbe_analy.h pef_analy.cc pef_analy.h analy_arm.cc analy_arm.h \ xex_analy.cc xex_analy.h ht-2.0.22/analyser/xbe_analy.h0000644000175000001440000000367210615342710013065 00000000000000/* * HT Editor * xbe_analy.h * * Copyright (C) 2003 Stefan Esser * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef xbe_analy_h #define xbe_analy_h #include "analy.h" #include "htxbe.h" class XBEAnalyser: public Analyser { public: ht_xbe_shared_data *xbe_shared; File *file; Area *validarea; XBEAnalyser() {}; XBEAnalyser(BuildCtorArg&a): Analyser(a) {}; void init(ht_xbe_shared_data *XBE_shared, File *File); void load(ObjectStream &f); virtual void done(); virtual ObjectID getObjectID() const; virtual void beginAnalysis(); virtual uint bufPtr(Address *Addr, byte *buf, int size); bool convertAddressToRVA(Address *addr, RVA *r); virtual Address *createAddress(); Address *createAddress32(uint32 addr); Address *createAddress64(uint64 high_addr); virtual Assembler *createAssembler(); virtual String & getName(String &res); virtual const char *getType(); virtual void initCodeAnalyser(); virtual void initUnasm(); virtual void log(const char *msg); virtual Address *nextValid(Address *Addr); virtual void store(ObjectStream &f) const; virtual int queryConfig(int mode); virtual bool validAddress(Address *Addr, tsectype action); virtual Address *fileofsToAddress(FileOfs fileofs); virtual FileOfs addressToFileofs(Address *Addr); virtual const char *getSegmentNameByAddress(Address *Addr); }; #endif ht-2.0.22/analyser/pe_analy.cc0000644000175000001440000004277110636023333013054 00000000000000/* * HT Editor * pe_analy.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "analy.h" #include "analy_alpha.h" #include "analy_ia64.h" #include "analy_il.h" #include "analy_names.h" #include "analy_register.h" #include "analy_ppc.h" #include "analy_x86.h" #include "analy_arm.h" #include "htctrl.h" #include "htdebug.h" #include "htiobox.h" #include "htpe.h" #include "strtools.h" #include "ilopc.h" #include "pe_analy.h" #include "pestruct.h" #include "snprintf.h" #include "x86asm.h" void PEAnalyser::init(ht_pe_shared_data *Pe_shared, File *File) { pe_shared = Pe_shared; file = File; validarea = new Area(); validarea->init(); Analyser::init(); } static char *string_func(uint32 ofs, void *context); static char *token_func(uint32 token, void *context); /* * */ void PEAnalyser::load(ObjectStream &f) { GET_OBJECT(f, validarea); Analyser::load(f); } /* * */ void PEAnalyser::done() { validarea->done(); delete validarea; Analyser::done(); } /* * */ void PEAnalyser::reinit(ht_pe_shared_data *Pe_shared, File *f) { pe_shared = Pe_shared; file = f; if (disasm->getObjectID() == ATOM_DISASM_IL) { ((ILDisassembler *)disasm)->initialize(string_func, token_func, pe_shared); } } /* * */ void PEAnalyser::beginAnalysis() { char buffer[1024]; setLocationTreeOptimizeThreshold(100); setSymbolTreeOptimizeThreshold(100); bool pe32 = (pe_shared->opt_magic == COFF_OPTMAGIC_PE32); /* * entrypoint */ Address *entry; if (pe32) { entry = createAddress32(pe_shared->pe32.header.entrypoint_address+pe_shared->pe32.header_nt.image_base); } else { entry = createAddress64(pe_shared->pe64.header.entrypoint_address+pe_shared->pe64.header_nt.image_base); } pushAddress(entry, entry); /* * give all sections a descriptive comment: */ /*struct PE_SECTION_HEADER { byte name[PE_SIZEOF_SHORT_NAME] __attribute__ ((packed)); uint32 data_vsize __attribute__ ((packed)); uint32 data_address __attribute__ ((packed)); uint32 data_size __attribute__ ((packed)); uint32 data_offset __attribute__ ((packed)); uint32 relocation_offset __attribute__ ((packed)); uint32 linenumber_offset __attribute__ ((packed)); uint16 relocation_count __attribute__ ((packed)); uint16 linenumber_count __attribute__ ((packed)); uint32 characteristics __attribute__ ((packed)); };*/ COFF_SECTION_HEADER *s=pe_shared->sections.sections; char blub[100]; for (uint i=0; isections.section_count; i++) { Address *secaddr; if (pe32) { secaddr = createAddress32(s->data_address + pe_shared->pe32.header_nt.image_base); } else { secaddr = createAddress64(s->data_address + pe_shared->pe64.header_nt.image_base); } ht_snprintf(blub, sizeof blub, "; section %d <%s>", i+1, getSegmentNameByAddress(secaddr)); addComment(secaddr, 0, ""); addComment(secaddr, 0, ";******************************************************************"); addComment(secaddr, 0, blub); ht_snprintf(blub, sizeof blub, "; virtual address %08x virtual size %08x", s->data_address, s->data_vsize); addComment(secaddr, 0, blub); ht_snprintf(blub, sizeof blub, "; file offset %08x file size %08x", s->data_offset, s->data_size); addComment(secaddr, 0, blub); addComment(secaddr, 0, ";******************************************************************"); // mark end of sections ht_snprintf(blub, sizeof blub, "; end of section <%s>", getSegmentNameByAddress(secaddr)); Address *secend_addr = secaddr->clone(); secend_addr->add(MAX(s->data_size, s->data_vsize)); newLocation(secend_addr)->flags |= AF_FUNCTION_END; addComment(secend_addr, 0, ""); addComment(secend_addr, 0, ";******************************************************************"); addComment(secend_addr, 0, blub); addComment(secend_addr, 0, ";******************************************************************"); validarea->add(secaddr, secend_addr); Address *seciniaddr = secaddr->clone(); seciniaddr->add(MIN(s->data_size, s->data_vsize)); if (validAddress(secaddr, scinitialized) && validAddress(seciniaddr, scinitialized)) { initialized->add(secaddr, seciniaddr); } s++; delete secaddr; delete secend_addr; delete seciniaddr; } // exports int export_count=pe_shared->exports.funcs->count(); int *entropy = random_permutation(export_count); for (int i=0; iexports.funcs)[entropy[i]]; Address *faddr; if (pe32) { faddr = createAddress32(f->address + pe_shared->pe32.header_nt.image_base); } else { faddr = createAddress64(f->address + pe_shared->pe64.header_nt.image_base); } if (validAddress(faddr, scvalid)) { char *label; if (f->byname) { ht_snprintf(buffer, sizeof buffer, "; exported function %s, ordinal %04x", f->name, f->ordinal); } else { ht_snprintf(buffer, sizeof buffer, "; unnamed exported function, ordinal %04x", f->ordinal); } label = export_func_name((f->byname) ? f->name : NULL, f->ordinal); addComment(faddr, 0, ""); addComment(faddr, 0, ";********************************************************"); addComment(faddr, 0, buffer); addComment(faddr, 0, ";********************************************************"); pushAddress(faddr, faddr); assignSymbol(faddr, label, label_func); free(label); } delete faddr; } if (entropy) free(entropy); int import_count=pe_shared->imports.funcs->count(); entropy = random_permutation(import_count); for (int i=0; iimports.funcs)[entropy[i]]; ht_pe_import_library *d = (ht_pe_import_library *)(*pe_shared->imports.libs)[f->libidx]; char *label; label = import_func_name(d->name, (f->byname) ? f->name.name : NULL, f->ordinal); Address *faddr; if (pe32) { faddr = createAddress32(f->address + pe_shared->pe32.header_nt.image_base); } else { faddr = createAddress64(f->address + pe_shared->pe64.header_nt.image_base); } addComment(faddr, 0, ""); if (!assignSymbol(faddr, label, label_func)) { // multiple import of a function (duplicate labelname) // -> mangle name a bit more addComment(faddr, 0, "; duplicate import"); ht_snprintf(buffer, sizeof buffer, "%s_%x", label, f->address); assignSymbol(faddr, buffer, label_func); } if (pe32) { data->setIntAddressType(faddr, dst_idword, 4); } else { data->setIntAddressType(faddr, dst_iqword, 8); } free(label); delete faddr; } if (entropy) free(entropy); int dimport_count=pe_shared->dimports.funcs->count(); entropy = random_permutation(dimport_count); for (int i=0; idimports.funcs)[entropy[i]]; ht_pe_import_library *d=(ht_pe_import_library *)(*pe_shared->dimports.libs)[f->libidx]; if (f->byname) { ht_snprintf(buffer, sizeof buffer, "; delay import function loader for %s, ordinal %04x", f->name.name, f->ordinal); } else { ht_snprintf(buffer, sizeof buffer, "; delay import function loader for ordinal %04x", f->ordinal); } char *label; label = import_func_name(d->name, f->byname ? f->name.name : NULL, f->ordinal); Address *faddr; if (pe32) { faddr = createAddress32(f->address); } else { faddr = createAddress64(f->address); } addComment(faddr, 0, ""); addComment(faddr, 0, ";********************************************************"); addComment(faddr, 0, buffer); addComment(faddr, 0, ";********************************************************"); assignSymbol(faddr, label, label_func); free(label); delete faddr; } if (entropy) free(entropy); addComment(entry, 0, ""); addComment(entry, 0, ";****************************"); if (pe_shared->coffheader.characteristics & COFF_DLL) { addComment(entry, 0, "; dll entry point"); } else { addComment(entry, 0, "; program entry point"); } addComment(entry, 0, ";****************************"); assignSymbol(entry, "entrypoint", label_func); setLocationTreeOptimizeThreshold(1000); setSymbolTreeOptimizeThreshold(1000); delete entry; Analyser::beginAnalysis(); } /* * */ ObjectID PEAnalyser::getObjectID() const { return ATOM_PE_ANALYSER; } /* * */ uint PEAnalyser::bufPtr(Address *Addr, byte *buf, int size) { FileOfs ofs = addressToFileofs(Addr); /* if (ofs == INVALID_FILE_OFS) { int as=0; }*/ assert(ofs != INVALID_FILE_OFS); file->seek(ofs); return file->read(buf, size); } bool PEAnalyser::convertAddressToRVA(Address *addr, RVA *r) { ObjectID oid = addr->getObjectID(); if (oid == ATOM_ADDRESS_FLAT_32) { *r = ((AddressFlat32*)addr)->addr - pe_shared->pe32.header_nt.image_base; return true; } else if (oid == ATOM_ADDRESS_X86_FLAT_32) { *r = ((AddressX86Flat32*)addr)->addr - pe_shared->pe32.header_nt.image_base; return true; } else if (oid == ATOM_ADDRESS_FLAT_64) { uint64 q = ((AddressFlat64*)addr)->addr - pe_shared->pe64.header_nt.image_base; if (q >> 32) return false; *r = q; return true; } return false; } /* * */ Address *PEAnalyser::createAddress32(uint32 addr) { switch (pe_shared->coffheader.machine) { case COFF_MACHINE_I386: case COFF_MACHINE_I486: case COFF_MACHINE_I586: return new AddressX86Flat32(addr); } // fallback to standard-addrs return new AddressFlat32(addr); } /* * */ Address *PEAnalyser::createAddress64(uint64 addr) { return new AddressFlat64(addr); } Address *PEAnalyser::createAddress() { switch (pe_shared->coffheader.machine) { case COFF_MACHINE_I386: case COFF_MACHINE_I486: case COFF_MACHINE_I586: if (pe_shared->opt_magic == COFF_OPTMAGIC_PE64) { return new AddressFlat64(); } else { return new AddressX86Flat32(); } } if (pe_shared->opt_magic == COFF_OPTMAGIC_PE64) { return new AddressFlat64(); } return new AddressFlat32(); } /* * */ Assembler *PEAnalyser::createAssembler() { Assembler *a = NULL; switch (pe_shared->coffheader.machine) { case COFF_MACHINE_I386: case COFF_MACHINE_I486: case COFF_MACHINE_I586: a = new x86asm(X86_OPSIZE32, X86_ADDRSIZE32); a->init(); return a; case COFF_MACHINE_AMD64: a = new x86_64asm(); a->init(); return a; } return a; } /* * */ FileOfs PEAnalyser::addressToFileofs(Address *Addr) { /* char tbuf[1024]; Addr->stringify(tbuf, 1024, 0); printf("ADDR=%s", tbuf);*/ if (validAddress(Addr, scinitialized)) { // printf(" v1\n"); FileOfs ofs; RVA r; if (!convertAddressToRVA(Addr, &r)) return INVALID_FILE_OFS; if (!pe_rva_to_ofs(&pe_shared->sections, r, &ofs)) return INVALID_FILE_OFS; return ofs; } else { // printf(" IV1\n"); return INVALID_FILE_OFS; } } /* * */ const char *PEAnalyser::getSegmentNameByAddress(Address *Addr) { static char sectionname[9]; pe_section_headers *sections=&pe_shared->sections; int i; RVA r; // Addr-=pe_shared->pe32.header_nt.image_base; if (!convertAddressToRVA(Addr, &r)) return NULL; pe_rva_to_section(sections, r, &i); COFF_SECTION_HEADER *s=sections->sections+i; if (!pe_rva_is_valid(sections, r)) return NULL; memcpy(sectionname, s->name, 8); sectionname[8] = 0; return sectionname; } /* * */ String &PEAnalyser::getName(String &s) { return file->getDesc(s); } /* * */ const char *PEAnalyser::getType() { return "PE/Analyser"; } /* * */ void PEAnalyser::initCodeAnalyser() { Analyser::initCodeAnalyser(); } static char *string_func(uint32 ofs, void *context) { char str[1024]; static char str2[1024]; ht_pe_shared_data *pe = (ht_pe_shared_data*)context; if (ofs < pe->il->string_pool_size) { uint32 length; uint32 o = ILunpackDword(length, (byte*)&pe->il->string_pool[ofs], 10); wide_char_to_multi_byte(str, (byte*)&pe->il->string_pool[ofs+o], length/2+1); escape_special_str(str2, sizeof str2, str, "\""); return str2; } else { return NULL; } } static char *token_func(uint32 token, void *context) { static char tokenstr[1024]; // ht_pe_shared_data *pe = (ht_pe_shared_data*)context; switch (token & IL_META_TOKEN_MASK) { case IL_META_TOKEN_TYPE_REF: case IL_META_TOKEN_TYPE_DEF: { sprintf(tokenstr, "typedef"); break; } case IL_META_TOKEN_FIELD_DEF: { sprintf(tokenstr, "fielddef"); break; } case IL_META_TOKEN_METHOD_DEF: { sprintf(tokenstr, "methoddef"); break; } case IL_META_TOKEN_MEMBER_REF: { sprintf(tokenstr, "memberref"); break; } case IL_META_TOKEN_TYPE_SPEC: { sprintf(tokenstr, "typespec"); break; } default: return NULL; } return tokenstr; } /* * */ void PEAnalyser::initUnasm() { bool pe64 = false; if (pe_shared->opt_magic == COFF_OPTMAGIC_PE64) { pe64 = true; } DPRINTF("pe_analy: "); if (pe_shared->il) { analy_disasm = new AnalyILDisassembler(); ((AnalyILDisassembler *)analy_disasm)->init(this, string_func, token_func, pe_shared); } else { switch (pe_shared->coffheader.machine) { case COFF_MACHINE_I386: // Intel 386 case COFF_MACHINE_I486: // Intel 486 case COFF_MACHINE_I586: // Intel 586 if (pe64) { errorbox("x86 cant be used in PE64 format."); } else { DPRINTF("initing analy_x86_disassembler\n"); analy_disasm = new AnalyX86Disassembler(); ((AnalyX86Disassembler *)analy_disasm)->init(this, 0); } break; case COFF_MACHINE_AMD64: if (!pe64) { errorbox("x86_64 cant be used in PE32 format."); } else { analy_disasm = new AnalyX86Disassembler(); ((AnalyX86Disassembler *)analy_disasm)->init(this, ANALYX86DISASSEMBLER_FLAGS_AMD64); } break; case COFF_MACHINE_R3000: // MIPS little-endian, 0x160 big-endian DPRINTF("no apropriate disassembler for MIPS\n"); warnbox("No disassembler for MIPS!"); break; case COFF_MACHINE_R4000: // MIPS little-endian DPRINTF("no apropriate disassembler for MIPS\n"); warnbox("No disassembler for MIPS!"); break; case COFF_MACHINE_R10000: // MIPS little-endian DPRINTF("no apropriate disassembler for MIPS\n"); warnbox("No disassembler for MIPS!"); break; case COFF_MACHINE_ALPHA: // Alpha_AXP DPRINTF("initing alpha_axp_disassembler\n"); analy_disasm = new AnalyAlphaDisassembler(); ((AnalyAlphaDisassembler *)analy_disasm)->init(this); break; case COFF_MACHINE_POWERPC_LE: // IBM PowerPC Little-Endian DPRINTF("no apropriate disassembler for POWER PC\n"); warnbox("No disassembler for little endian POWER PC!"); break; case COFF_MACHINE_POWERPC_BE: case COFF_MACHINE_POWERPC64_BE: analy_disasm = new AnalyPPCDisassembler(); ((AnalyPPCDisassembler*)analy_disasm)->init(this, pe64 ? ANALY_PPC_64 : ANALY_PPC_32); break; case COFF_MACHINE_IA64: if (!pe64) { errorbox("Intel IA64 cant be used in PE32 format."); } else { analy_disasm = new AnalyIA64Disassembler(); ((AnalyIA64Disassembler*)analy_disasm)->init(this); } break; case COFF_MACHINE_ARM: // ARM case COFF_MACHINE_THUMB: // Thumb DPRINTF("initing arm_disassembler\n"); analy_disasm = new AnalyArmDisassembler(); ((AnalyArmDisassembler *)analy_disasm)->init(this); break; case COFF_MACHINE_UNKNOWN: default: DPRINTF("no apropriate disassembler for machine %04x\n", pe_shared->coffheader.machine); warnbox("No disassembler for unknown machine type %04x!", pe_shared->coffheader.machine); } } } /* * */ void PEAnalyser::log(const char *msg) { /* * log() creates to much traffic so dont log * perhaps we reactivate this later * */ /* LOG(msg);*/ } /* * */ Address *PEAnalyser::nextValid(Address *Addr) { return (Address *)validarea->findNext(Addr); } /* * */ void PEAnalyser::store(ObjectStream &st) const { PUT_OBJECT(st, validarea); Analyser::store(st); } /* * */ int PEAnalyser::queryConfig(int mode) { switch (mode) { case Q_DO_ANALYSIS: case Q_ENGAGE_CODE_ANALYSER: case Q_ENGAGE_DATA_ANALYSER: return true; default: return 0; } } /* * */ Address *PEAnalyser::fileofsToAddress(FileOfs fileofs) { RVA r; if (pe_ofs_to_rva(&pe_shared->sections, fileofs, &r)) { if (pe_shared->opt_magic == COFF_OPTMAGIC_PE32) { return createAddress32(r + pe_shared->pe32.header_nt.image_base); } else { return createAddress64(r + pe_shared->pe64.header_nt.image_base); } } else { return new InvalidAddress(); } } /* * */ bool PEAnalyser::validAddress(Address *Addr, tsectype action) { pe_section_headers *sections=&pe_shared->sections; int sec; RVA r; if (!convertAddressToRVA(Addr, &r)) return false; if (!pe_rva_to_section(sections, r, &sec)) return false; COFF_SECTION_HEADER *s=sections->sections+sec; switch (action) { case scvalid: return true; case scread: return s->characteristics & COFF_SCN_MEM_READ; case scwrite: return s->characteristics & COFF_SCN_MEM_WRITE; case screadwrite: return s->characteristics & COFF_SCN_MEM_WRITE; case sccode: // FIXME: EXECUTE vs. CNT_CODE ? if (!pe_rva_is_physical(sections, r)) return false; return (s->characteristics & (COFF_SCN_MEM_EXECUTE | COFF_SCN_CNT_CODE)); case scinitialized: if (!pe_rva_is_physical(sections, r)) return false; return true; // !(s->characteristics & COFF_SCN_CNT_UNINITIALIZED_DATA); } return false; } ht-2.0.22/analyser/analy_alpha.h0000644000175000001440000000260112156425724013374 00000000000000/* * HT Editor * analy_alpha.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ANALY_ALPHA_H #define ANALY_ALPHA_H #include "analy.h" #include "alphadis.h" class AnalyAlphaDisassembler: public AnalyDisassembler { public: AnalyAlphaDisassembler(); AnalyAlphaDisassembler(BuildCtorArg &a): AnalyDisassembler(a) {}; void init(Analyser *A); void load(ObjectStream &f); virtual void done(); virtual ObjectID getObjectID() const; virtual Address *branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine); Address *createAddress(uint64 offset); virtual void examineOpcode(OPCODE *opcode); virtual branch_enum_t isBranch(OPCODE *opcode); virtual void store(ObjectStream &f) const; }; #endif ht-2.0.22/analyser/data_analy.h0000644000175000001440000000574510615342710013223 00000000000000/* * HT Editor * data_analy.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef DATA_ANALY_H #define DATA_ANALY_H #include "data.h" #include "analy.h" enum OP {op_read, op_write, op_offset}; /* * general type of an address */ enum taddr_typetype { dt_unknown = 0, dt_code, dt_unknown_data, dt_int, dt_float, dt_array }; enum taddr_code_subtype { dst_cunknown = 0, dst_location, dst_function }; enum taddr_int_subtype{ dst_iunknown = 0, dst_ibyte, dst_iword, dst_idword, dst_ipword, dst_iqword }; enum taddr_float_subtype { dst_funknown = 0, dst_fsingle, dst_fdouble, dst_fextended }; enum taddr_array_subtype { dst_aunknown = 0, dst_abyte, dst_aword, dst_adword, dst_apword, dst_aqword, dst_string, dst_unistring }; struct taddr_type { taddr_typetype type; union { byte subtype; taddr_code_subtype code_subtype; taddr_int_subtype int_subtype; taddr_float_subtype float_subtype; taddr_array_subtype array_subtype; }; union { int length; // ...? }; }; class Analyser; class Address; struct Location; class DataAnalyser: public Object { public: Analyser *analy; DataAnalyser(); DataAnalyser(BuildCtorArg&a): Object(a) {}; void init(Analyser *Analy); virtual void load(ObjectStream &s); virtual void done(); virtual ObjectID getObjectID() const; void access(Address *Addr, OP op, int size); void setAddressType(Address *Addr, taddr_typetype type, int subtype, int length); void setAddressType(Location *Addr, taddr_typetype type, int subtype, int length); void setCodeAddressType(Address *Addr, taddr_code_subtype subtype); void setCodeAddressType(Location *Addr, taddr_code_subtype subtype); void setIntAddressType(Address *Addr, taddr_int_subtype subtype, int length); void setIntAddressType(Location *Addr, taddr_int_subtype subtype, int length); void setFloatAddressType(Address *Addr, taddr_float_subtype subtype, int length); void setFloatAddressType(Location *Addr, taddr_float_subtype subtype, int length); void setArrayAddressType(Address *Addr, taddr_array_subtype subtype, int length); void setArrayAddressType(Location *Addr, taddr_array_subtype subtype, int length); virtual void store(ObjectStream &s) const; }; void analyser_put_addrtype(ObjectStream &s, const taddr_type *at); void analyser_get_addrtype(ObjectStream &s, taddr_type *at); #endif ht-2.0.22/analyser/pe_analy.h0000644000175000001440000000400610636023333012703 00000000000000/* * HT Editor * pe_analy.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef pe_analy_h #define pe_analy_h #include "analy.h" #include "htpe.h" class PEAnalyser: public Analyser { public: ht_pe_shared_data *pe_shared; File *file; Area *validarea; PEAnalyser() {}; PEAnalyser(BuildCtorArg&a): Analyser(a) {}; void init(ht_pe_shared_data *Pe_shared, File *file); void load(ObjectStream &f); void reinit(ht_pe_shared_data *Pe_shared, File *file); virtual void done(); virtual ObjectID getObjectID() const; virtual void beginAnalysis(); virtual uint bufPtr(Address *Addr, byte *buf, int size); bool convertAddressToRVA(Address *addr, RVA *r); virtual Address *createAddress(); Address *createAddress32(uint32 addr); Address *createAddress64(uint64 high_addr); virtual Assembler *createAssembler(); virtual String & getName(String &res); virtual const char *getType(); virtual void initCodeAnalyser(); virtual void initUnasm(); virtual void log(const char *msg); virtual Address *nextValid(Address *Addr); virtual void store(ObjectStream &f) const; virtual int queryConfig(int mode); virtual bool validAddress(Address *Addr, tsectype action); virtual Address *fileofsToAddress(FileOfs fileofs); virtual FileOfs addressToFileofs(Address *Addr); virtual const char *getSegmentNameByAddress(Address *Addr); }; #endif ht-2.0.22/analyser/analy_ia64.h0000644000175000001440000000242110615342706013046 00000000000000/* * HT Editor * analy_ia64.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ANALY_IA64_H #define ANALY_IA64_H #include "analy.h" #include "ia64dis.h" class AnalyIA64Disassembler: public AnalyDisassembler { public: AnalyIA64Disassembler() {}; AnalyIA64Disassembler(BuildCtorArg&a): AnalyDisassembler(a) {}; void init(Analyser *A); virtual ObjectID getObjectID() const; virtual Address *branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine); Address *createAddress(uint32 offset); virtual void examineOpcode(OPCODE *opcode); virtual branch_enum_t isBranch(OPCODE *opcode); }; #endif ht-2.0.22/analyser/analy_arm.h0000644000175000001440000000104210615342776013067 00000000000000#ifndef ANALY_ARM_20060408_H #define ANALY_ARM_20060408_H #include "analy.h" class AnalyArmDisassembler: public AnalyDisassembler { public: AnalyArmDisassembler() {} AnalyArmDisassembler(BuildCtorArg&a): AnalyDisassembler(a) {}; void init(Analyser *A); virtual ObjectID getObjectID() const; virtual Address * branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine); virtual void examineOpcode(OPCODE *opcode); virtual branch_enum_t isBranch(OPCODE *opcode); }; #endif ht-2.0.22/analyser/elf_analy.cc0000644000175000001440000005076712156420110013213 00000000000000/* * HT Editor * elf_analy.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "analy.h" #include "analy_alpha.h" #include "analy_names.h" #include "analy_ia64.h" #include "analy_ppc.h" #include "analy_register.h" #include "analy_x86.h" #include "analy_arm.h" #include "elf_analy.h" #include "htctrl.h" #include "htdebug.h" #include "htiobox.h" #include "htelf.h" #include "strtools.h" #include "pestruct.h" #include "snprintf.h" #include "x86asm.h" extern "C" { #include "demangle.h" } #include #include #include void ElfAnalyser::init(ht_elf_shared_data *Elf_shared, File *File) { elf_shared = Elf_shared; file = File; validarea = new Area(); validarea->init(); Analyser::init(); } void ElfAnalyser::beginAnalysis() { Address *entry = NULL; bool c32 = false; switch (elf_shared->ident.e_ident[ELF_EI_CLASS]) { case ELFCLASS32: { entry = createAddress32(elf_shared->header32.e_entry); c32 = true; break; } case ELFCLASS64: { entry = createAddress64(elf_shared->header64.e_entry); c32 = false; break; } } if (!validAddress(entry, scvalid)) { delete entry; entry = NULL; } setLocationTreeOptimizeThreshold(100); setSymbolTreeOptimizeThreshold(100); /* * give all sections a descriptive comment: */ ELF_SECTION_HEADER32 *s32=elf_shared->sheaders.sheaders32; ELF_SECTION_HEADER64 *s64=elf_shared->sheaders.sheaders64; char blub[100]; for (uint i=0; i < elf_shared->sheaders.count; i++) { Address *secaddr; if (c32) { // fprintf(stderr, "desc sec %d, %08x\n", i, s32->sh_addr); secaddr = createAddress32(s32->sh_addr); } else { secaddr = createAddress64(s64->sh_addr); } if (validAddress(secaddr, scvalid)) { // fprintf(stderr, "valid!\n"); ht_snprintf(blub, sizeof blub, "; section %d <%s>", i, getSegmentNameByAddress(secaddr)); addComment(secaddr, 0, ""); addComment(secaddr, 0, ";******************************************************************"); addComment(secaddr, 0, blub); if (c32) { ht_snprintf(blub, sizeof blub, "; virtual address %08x virtual size %08x", s32->sh_addr, s32->sh_size); } else { ht_snprintf(blub, sizeof blub, "; virtual address %08qx virtual size %08qx", s64->sh_addr, s64->sh_size); } addComment(secaddr, 0, blub); if (validAddress(secaddr, scinitialized)) { if (c32) { ht_snprintf(blub, sizeof blub, "; file offset %08x file size %08x", s32->sh_offset, s32->sh_size); } else { ht_snprintf(blub, sizeof blub, "; file offset %08qx file size %08qx", s64->sh_offset, s64->sh_size); } } else { ht_snprintf(blub, sizeof blub, "; section is not in file"); } addComment(secaddr, 0, blub); addComment(secaddr, 0, ";******************************************************************"); // mark end of sections ht_snprintf(blub, sizeof blub, "; end of section <%s>", getSegmentNameByAddress(secaddr)); Address *secend_addr = secaddr->clone(); if (c32) { secend_addr->add(s32->sh_size); } else { secend_addr->add(s64->sh_size); } newLocation(secend_addr)->flags |= AF_FUNCTION_END; addComment(secend_addr, 0, ""); addComment(secend_addr, 0, ";******************************************************************"); addComment(secend_addr, 0, blub); addComment(secend_addr, 0, ";******************************************************************"); validarea->add(secaddr, secend_addr); Address *seciniaddr = secaddr->clone(); seciniaddr->add(c32 ? s32->sh_size : s64->sh_size); if (validAddress(secaddr, scinitialized) && validAddress(seciniaddr, scinitialized)) { initialized->add(secaddr, seciniaddr); } delete seciniaddr; delete secend_addr; } delete secaddr; s32++; s64++; } /* symbols */ if (c32) { for (uint i=1; i < elf_shared->sheaders.count; i++) { if ((elf_shared->sheaders.sheaders32[i].sh_type==ELF_SHT_SYMTAB) || (elf_shared->sheaders.sheaders32[i].sh_type==ELF_SHT_DYNSYM)) { initInsertSymbols(i); } } initInsertFakeSymbols(); } else { for (uint i=1; i < elf_shared->sheaders.count; i++) { if ((elf_shared->sheaders.sheaders64[i].sh_type==ELF_SHT_SYMTAB) || (elf_shared->sheaders.sheaders64[i].sh_type==ELF_SHT_DYNSYM)) { initInsertSymbols(i); } } } /* * entrypoint */ if (entry) { pushAddress(entry, entry); assignSymbol(entry, "entrypoint", label_func); addComment(entry, 0, ""); addComment(entry, 0, ";****************************"); switch (c32 ? elf_shared->header32.e_type : elf_shared->header64.e_type) { case ELF_ET_DYN: addComment(entry, 0, "; dynamic executable entry point"); break; case ELF_ET_EXEC: addComment(entry, 0, "; executable entry point"); break; default: addComment(entry, 0, "; entry point"); } addComment(entry, 0, ";****************************"); delete entry; } setLocationTreeOptimizeThreshold(1000); setSymbolTreeOptimizeThreshold(1000); Analyser::beginAnalysis(); } /* * */ void ElfAnalyser::initInsertFakeSymbols() { if (!elf_shared->undefined2fakeaddr) return; foreach(FakeAddr, fa, *elf_shared->undefined2fakeaddr, { Address *address = createAddress32(fa->addr); FileOfs h = elf_shared->sheaders.sheaders32[fa->secidx].sh_offset; ELF_SYMBOL32 sym; file->seek(h + fa->symidx * sizeof (ELF_SYMBOL32)); file->readx(&sym, sizeof sym); createHostStruct(&sym, ELF_SYMBOL32_struct, elf_shared->byte_order); FileOfs sto = elf_shared->sheaders.sheaders32[ elf_shared->sheaders.sheaders32[fa->secidx].sh_link].sh_offset; file->seek(sto + sym.st_name); char *name = file->fgetstrz(); char buf[1024]; ht_snprintf(buf, sizeof buf, "undef_%s", name); free(name); make_valid_name(buf, buf); assignSymbol(address, buf, label_func); }) } void ElfAnalyser::initInsertSymbols(int shidx) { char elf_buffer[1024]; if (elf_shared->ident.e_ident[ELF_EI_CLASS] == ELFCLASS32) { FileOfs h = elf_shared->sheaders.sheaders32[shidx].sh_offset; FileOfs sto = elf_shared->sheaders.sheaders32[elf_shared->sheaders.sheaders32[shidx].sh_link].sh_offset; uint symnum = elf_shared->sheaders.sheaders32[shidx].sh_size / sizeof (ELF_SYMBOL32); int *entropy = random_permutation(symnum); for (uint i = 0; i < symnum; i++) { ELF_SYMBOL32 sym; if (entropy[i] == 0) continue; file->seek(h+entropy[i]*sizeof (ELF_SYMBOL32)); file->read(&sym, sizeof sym); createHostStruct(&sym, ELF_SYMBOL32_struct, elf_shared->byte_order); file->seek(sto+sym.st_name); char *name = file->fgetstrz(); if (!name) continue; switch (sym.st_shndx) { case ELF_SHN_UNDEF: break; case ELF_SHN_ABS: break; case ELF_SHN_COMMON: break; default: // sym.st_shndx break; } const char *bind; switch (ELF32_ST_BIND(sym.st_info)) { case ELF_STB_LOCAL: bind="local"; break; case ELF_STB_GLOBAL: bind="global"; break; case ELF_STB_WEAK: bind="weak"; break; default: bind="?"; break; } switch (ELF32_ST_TYPE(sym.st_info)) { case ELF_STT_NOTYPE: case ELF_STT_FUNC: { char *label = name; if (!getSymbolByName(label)) { elf32_addr sym_addr = sym.st_value; if (elf_shared->shrelocs && sym.st_shndx > 0 && sym.st_shndx < elf_shared->sheaders.count && elf_shared->shrelocs[sym.st_shndx].relocAddr) { sym_addr += elf_shared->shrelocs[sym.st_shndx].relocAddr; } Address *address = createAddress32(sym_addr); if (validAddress(address, scvalid)) { char *demangled = cplus_demangle(label, DMGL_PARAMS | DMGL_ANSI); if (!demangled) demangled = cplus_demangle_v3(label, DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES); make_valid_name(label, label); ht_snprintf(elf_buffer, sizeof elf_buffer, "; function %s (%s)", (demangled) ? demangled : label, bind); free(demangled); addComment(address, 0, ""); addComment(address, 0, ";********************************************************"); addComment(address, 0, elf_buffer); addComment(address, 0, ";********************************************************"); pushAddress(address, address); assignSymbol(address, label, label_func); } delete address; } break; } case ELF_STT_OBJECT: { char *label = name; if (!getSymbolByName(label)) { Address *address = createAddress32(sym.st_value); if (validAddress(address, scvalid)) { char *demangled = cplus_demangle(label, DMGL_PARAMS | DMGL_ANSI); make_valid_name(label, label); ht_snprintf(elf_buffer, sizeof elf_buffer, "; data object %s, size %d (%s)", (demangled) ? demangled : label, sym.st_size, bind); if (demangled) free(demangled); addComment(address, 0, ""); addComment(address, 0, ";********************************************************"); addComment(address, 0, elf_buffer); addComment(address, 0, ";********************************************************"); assignSymbol(address, label, label_data); } delete address; } break; } case ELF_STT_SECTION: case ELF_STT_FILE: break; } free(name); } if (entropy) free(entropy); } else { // FIXME: 64 bit FileOfs h = elf_shared->sheaders.sheaders64[shidx].sh_offset; FileOfs sto = elf_shared->sheaders.sheaders64[elf_shared->sheaders.sheaders64[shidx].sh_link].sh_offset; uint symnum = elf_shared->sheaders.sheaders64[shidx].sh_size / sizeof (ELF_SYMBOL64); int *entropy = random_permutation(symnum); for (uint i=0; iseek(h+entropy[i]*sizeof (ELF_SYMBOL64)); file->read(&sym, sizeof sym); createHostStruct(&sym, ELF_SYMBOL64_struct, elf_shared->byte_order); file->seek(sto+sym.st_name); char *name = file->fgetstrz(); if (!name) continue; switch (sym.st_shndx) { case ELF_SHN_UNDEF: break; case ELF_SHN_ABS: break; case ELF_SHN_COMMON: break; default: { // sym.st_shndx break; } } const char *bind; switch (ELF64_ST_BIND(sym.st_info)) { case ELF_STB_LOCAL: bind="local"; break; case ELF_STB_GLOBAL: bind="global"; break; case ELF_STB_WEAK: bind="weak"; break; default: bind="?"; break; } switch (ELF64_ST_TYPE(sym.st_info)) { case ELF_STT_NOTYPE: case ELF_STT_FUNC: { char *label = name; if (!getSymbolByName(label)) { Address *address = createAddress64(sym.st_value); if (validAddress(address, scvalid)) { char *demangled = cplus_demangle(label, DMGL_PARAMS | DMGL_ANSI); if (!demangled) demangled = cplus_demangle_v3(label, DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES); make_valid_name(label, label); ht_snprintf(elf_buffer, sizeof elf_buffer, "; function %s (%s)", (demangled) ? demangled : label, bind); if (demangled) free(demangled); addComment(address, 0, ""); addComment(address, 0, ";********************************************************"); addComment(address, 0, elf_buffer); addComment(address, 0, ";********************************************************"); pushAddress(address, address); assignSymbol(address, label, label_func); } delete address; } break; } case ELF_STT_OBJECT: { char *label = name; if (!getSymbolByName(label)) { Address *address = createAddress64(sym.st_value); char *demangled = cplus_demangle(label, DMGL_PARAMS | DMGL_ANSI); if (!demangled) demangled = cplus_demangle_v3(label, DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES); make_valid_name(label, label); ht_snprintf(elf_buffer, sizeof elf_buffer, "; data object %s, size %qd (%s)", (demangled) ? demangled : label, sym.st_size, bind); free(demangled); addComment(address, 0, ""); addComment(address, 0, ";********************************************************"); addComment(address, 0, elf_buffer); addComment(address, 0, ";********************************************************"); assignSymbol(address, label, label_data); delete address; } break; } case ELF_STT_SECTION: case ELF_STT_FILE: break; } free(name); } if (entropy) free(entropy); } } /* * */ void ElfAnalyser::load(ObjectStream &f) { GET_OBJECT(f, validarea); Analyser::load(f); } /* * */ void ElfAnalyser::done() { validarea->done(); delete validarea; Analyser::done(); } ObjectID ElfAnalyser::getObjectID() const { return ATOM_ELF_ANALYSER; } /* * */ uint ElfAnalyser::bufPtr(Address *Addr, byte *buf, int size) { FileOfs ofs = addressToFileofs(Addr); /* if (ofs == INVALID_FILE_OFS) { int as = 1; }*/ assert(ofs != INVALID_FILE_OFS); file->seek(ofs); return file->read(buf, size); } bool ElfAnalyser::convertAddressToELFAddress(Address *addr, ELFAddress *r) { if (addr->getObjectID()==ATOM_ADDRESS_FLAT_32) { r->a32 = ((AddressFlat32*)addr)->addr; return true; } else if (addr->getObjectID()==ATOM_ADDRESS_X86_FLAT_32) { r->a32 = ((AddressX86Flat32*)addr)->addr; return true; } else if (addr->getObjectID()==ATOM_ADDRESS_FLAT_64) { r->a64 = ((AddressFlat64*)addr)->addr; return true; } else { return false; } } Address *ElfAnalyser::createAddress() { switch (elf_shared->ident.e_ident[ELF_EI_CLASS]) { case ELFCLASS32: { switch (elf_shared->header32.e_machine) { case ELF_EM_386: return new AddressX86Flat32(); } return new AddressFlat32(); } case ELFCLASS64: { /* switch (elf_shared->header32.e_machine) { case ELF_EM_386: return new AddressX86Flat32(0); }*/ return new AddressFlat64(); } } return new AddressFlat32(); } Address *ElfAnalyser::createAddress32(uint32 addr) { switch (elf_shared->header32.e_machine) { case ELF_EM_386: return new AddressX86Flat32(addr); } return new AddressFlat32(addr); } Address *ElfAnalyser::createAddress64(uint64 addr) { return new AddressFlat64(addr); } /* * */ Assembler *ElfAnalyser::createAssembler() { switch (elf_shared->ident.e_ident[ELF_EI_CLASS]) { case ELFCLASS32: switch (elf_shared->header32.e_machine) { case ELF_EM_386: Assembler *a = new x86asm(X86_OPSIZE32, X86_ADDRSIZE32); a->init(); return a; } case ELFCLASS64: switch (elf_shared->header64.e_machine) { case ELF_EM_X86_64: Assembler *a = new x86_64asm(); a->init(); return a; } } return NULL; } /* * */ FileOfs ElfAnalyser::addressToFileofs(Address *Addr) { if (validAddress(Addr, scinitialized)) { FileOfs ofs; ELFAddress ea; if (!convertAddressToELFAddress(Addr, &ea)) return INVALID_FILE_OFS; if (!elf_addr_to_ofs(&elf_shared->sheaders, elf_shared->ident.e_ident[ELF_EI_CLASS], ea, &ofs)) return INVALID_FILE_OFS; return ofs; } else { return INVALID_FILE_OFS; } } /* * */ const char *ElfAnalyser::getSegmentNameByAddress(Address *Addr) { static char elf_sectionname[33]; elf_section_headers *sections=&elf_shared->sheaders; int i; ELFAddress ea; if (!convertAddressToELFAddress(Addr, &ea)) return NULL; if (!elf_addr_to_section(sections, elf_shared->ident.e_ident[ELF_EI_CLASS], ea, &i)) return NULL; if (i == elf_shared->fake_undefined_shidx) { strcpy(elf_sectionname, "$$HT_FAKE$$"); } else { ht_strlcpy(elf_sectionname, elf_shared->shnames[i], sizeof elf_sectionname); } return elf_sectionname; } /* * */ String &ElfAnalyser::getName(String &res) { return file->getDesc(res); } /* * */ const char *ElfAnalyser::getType() { return "ELF/Analyser"; } /* * */ void ElfAnalyser::initCodeAnalyser() { Analyser::initCodeAnalyser(); } /* * */ void ElfAnalyser::initUnasm() { DPRINTF("elf_analy: "); int machine = 0; bool elf64 = false; switch (elf_shared->ident.e_ident[ELF_EI_CLASS]) { case ELFCLASS32: machine = elf_shared->header32.e_machine; break; case ELFCLASS64: machine = elf_shared->header64.e_machine; elf64 = true; break; } switch (machine) { case ELF_EM_386: DPRINTF("initing analy_x86_disassembler\n"); analy_disasm = new AnalyX86Disassembler(); ((AnalyX86Disassembler*)analy_disasm)->init(this, elf64 ? ANALYX86DISASSEMBLER_FLAGS_FLAT64 : 0); break; case ELF_EM_X86_64: if (elf_shared->ident.e_ident[ELF_EI_CLASS] != ELFCLASS64) { errorbox("x86_64 can't be used in a 32-Bit ELF."); } else { analy_disasm = new AnalyX86Disassembler(); ((AnalyX86Disassembler*)analy_disasm)->init(this, ANALYX86DISASSEMBLER_FLAGS_AMD64 | ANALYX86DISASSEMBLER_FLAGS_FLAT64); } break; case ELF_EM_IA_64: // Intel ia64 if (elf_shared->ident.e_ident[ELF_EI_CLASS] != ELFCLASS64) { errorbox("Intel IA64 can't be used in a 32-Bit ELF."); } else { analy_disasm = new AnalyIA64Disassembler(); ((AnalyIA64Disassembler*)analy_disasm)->init(this); } break; case ELF_EM_PPC: // PowerPC if (elf_shared->ident.e_ident[ELF_EI_CLASS] != ELFCLASS32) { errorbox("PowerPC32 can't be used in a 64-Bit ELF."); } else { DPRINTF("initing analy_ppc_disassembler\n"); analy_disasm = new AnalyPPCDisassembler(); ((AnalyPPCDisassembler*)analy_disasm)->init(this, ANALY_PPC_32); } break; case ELF_EM_PPC64: // PowerPC64 if (elf_shared->ident.e_ident[ELF_EI_CLASS] != ELFCLASS64) { errorbox("PowerPC64 can't be used in a 32-Bit ELF."); } else { DPRINTF("initing analy_ppc_disassembler\n"); analy_disasm = new AnalyPPCDisassembler(); ((AnalyPPCDisassembler*)analy_disasm)->init(this, ANALY_PPC_64); } break; case ELF_EM_ARM: // Arm if (elf_shared->ident.e_ident[ELF_EI_CLASS] != ELFCLASS32) { errorbox("ARM can't be used in a 64-Bit ELF."); } else { DPRINTF("initing analy_arm_disassembler\n"); analy_disasm = new AnalyArmDisassembler(); ((AnalyArmDisassembler*)analy_disasm)->init(this); } break; case ELF_EM_ALPHA: if (elf_shared->ident.e_ident[ELF_EI_CLASS] != ELFCLASS64) { errorbox("Alpha can't be used in a 32-Bit ELF."); } else { DPRINTF("initing analy_alpha_disassembler\n"); analy_disasm = new AnalyAlphaDisassembler(); ((AnalyAlphaDisassembler*)analy_disasm)->init(this); } break; default: DPRINTF("no apropriate disassembler for machine %04x\n", machine); warnbox("No disassembler for unknown machine type %04x!", machine); } } /* * */ Address *ElfAnalyser::nextValid(Address *Addr) { return (Address *)validarea->findNext(Addr); } /* * */ void ElfAnalyser::store(ObjectStream &f) const { PUT_OBJECT(f, validarea); Analyser::store(f); } /* * */ int ElfAnalyser::queryConfig(int mode) { switch (mode) { case Q_DO_ANALYSIS: case Q_ENGAGE_CODE_ANALYSER: case Q_ENGAGE_DATA_ANALYSER: return true; default: return 0; } } /* * */ Address *ElfAnalyser::fileofsToAddress(FileOfs fileofs) { ELFAddress ea; if (elf_ofs_to_addr(&elf_shared->sheaders, elf_shared->ident.e_ident[ELF_EI_CLASS], fileofs, &ea)) { switch (elf_shared->ident.e_ident[ELF_EI_CLASS]) { case ELFCLASS32: return createAddress32(ea.a32); case ELFCLASS64: return createAddress64(ea.a64); } return new InvalidAddress(); } else { return new InvalidAddress(); } } /* * */ bool ElfAnalyser::validAddress(Address *Addr, tsectype action) { elf_section_headers *sections=&elf_shared->sheaders; int sec; byte cls = elf_shared->ident.e_ident[ELF_EI_CLASS]; ELFAddress ea; if (!convertAddressToELFAddress(Addr, &ea)) return false; if (!elf_addr_to_section(sections, cls, ea, &sec)) return false; switch (cls) { case ELFCLASS32: { ELF_SECTION_HEADER32 *s = sections->sheaders32 + sec; switch (action) { case scvalid: return true; case scread: return true; case scwrite: case screadwrite: return s->sh_flags & ELF_SHF_WRITE; case sccode: return (s->sh_flags & ELF_SHF_EXECINSTR) && (s->sh_type == ELF_SHT_PROGBITS); case scinitialized: return s->sh_type==ELF_SHT_PROGBITS; } return false; } case ELFCLASS64: { ELF_SECTION_HEADER64 *s = sections->sheaders64 + sec; switch (action) { case scvalid: return true; case scread: return true; case scwrite: case screadwrite: return s->sh_flags & ELF_SHF_WRITE; case sccode: return (s->sh_flags & ELF_SHF_EXECINSTR) && (s->sh_type == ELF_SHT_PROGBITS); case scinitialized: return s->sh_type==ELF_SHT_PROGBITS; } return false; } } return false; } ht-2.0.22/analyser/analy_ia64.cc0000644000175000001440000000537610615342706013220 00000000000000/* * HT Editor * analy_ia64.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "analy_ia64.h" #include "analy_register.h" #include "ia64dis.h" #include "htiobox.h" #include "snprintf.h" void AnalyIA64Disassembler::init(Analyser *A) { disasm = new IA64Disassembler(); AnalyDisassembler::init(A); } ObjectID AnalyIA64Disassembler::getObjectID() const { return ATOM_ANALY_IA64; } /* * */ Address *AnalyIA64Disassembler::branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine) { IA64DisInsn *dis_insn = (IA64DisInsn*)opcode; IA64SlotDisInsn *slot = &dis_insn->slot[dis_insn->selected]; for (int j=0; j<7; j++) { if (slot->op[j].type == IA64_OPERAND_ADDRESS) { Address *addr = new AddressFlat64(slot->op[j].imm); return addr; } } return new InvalidAddress(); } Address *AnalyIA64Disassembler::createAddress(uint32 offset) { return new AddressFlat32(offset); } /* * */ void AnalyIA64Disassembler::examineOpcode(OPCODE *opcode) { /* IA64DisInsn *dis_insn = (IA64DisInsn*)opcode; IA64SlotDisInsn *slot = &dis_insn->slot[dis_insn->selected]; for (int j=0; j<7; j++) { if (slot->op[j].type == IA64_OPERAND_ADDRESS) { Address *addr = new AddressFlat64(slot->op[j].imm); if (analy->validAddress(addr, scvalid)) { taccess access; xref_enum_t xref = xrefoffset; access.type = acoffset; access.indexed = false; analy->dataAccess(addr, access); analy->addXRef(addr, analy->addr, xref); } } }*/ } /* * */ branch_enum_t AnalyIA64Disassembler::isBranch(OPCODE *opcode) { IA64DisInsn *dis_insn = (IA64DisInsn *) opcode; IA64SlotDisInsn *slot = &dis_insn->slot[dis_insn->selected]; if (ht_strncmp(slot->opcode->name, "br.", 3)==0) { if (ht_strncmp(slot->opcode->name+3, "call", 4)==0) { return br_call; } else if (ht_strncmp(slot->opcode->name+3, "cond", 4)==0) { if (slot->qp) { return br_jXX; } else { return br_jump; } } else if (ht_strncmp(slot->opcode->name+3, "cloop", 5)==0) { return br_jXX; } else if (ht_strncmp(slot->opcode->name+3, "ret", 3)==0) { if (!slot->qp) return br_return; } } return br_nobranch; } ht-2.0.22/analyser/xex_analy.h0000644000175000001440000000351010615342776013116 00000000000000/* * HT Editor * xex_analy.h * * Copyright (C) 2006 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef xex_analy_h #define xex_analy_h #include "analy.h" #include "htxex.h" class XEXAnalyser: public Analyser { public: ht_xex_shared_data *xex_shared; File *file; Area *validarea; XEXAnalyser() {}; XEXAnalyser(BuildCtorArg&a): Analyser(a) {}; void init(ht_xex_shared_data *XEX_shared, File *File); void load(ObjectStream &f); void reinit(ht_xex_shared_data *XEX_shared, File *File); virtual void done(); virtual ObjectID getObjectID() const; virtual void beginAnalysis(); virtual uint bufPtr(Address *Addr, byte *buf, int size); bool convertAddressToRVA(Address *addr, RVA *r); virtual Address *createAddress(); Address *createAddress32(uint32 addr); virtual String & getName(String &res); virtual const char *getType(); virtual void initUnasm(); virtual Address *nextValid(Address *Addr); virtual void store(ObjectStream &f) const; virtual bool validAddress(Address *Addr, tsectype action); virtual Address *fileofsToAddress(FileOfs fileofs); virtual FileOfs addressToFileofs(Address *Addr); virtual const char *getSegmentNameByAddress(Address *Addr); }; #endif ht-2.0.22/analyser/analy_x86.cc0000644000175000017500000003410611724770012013074 00000000000000/* * HT Editor * analy_x86.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "analy_register.h" #include "analy_x86.h" #include "htdebug.h" #include "snprintf.h" #include "x86dis.h" bool AddressX86Flat32::add(int offset) { // check for overflow if ((int)offset < 0) { if (addr+offset > addr) return false; } else { if (addr+offset < addr) return false; } addr+=offset; return true; } int AddressX86Flat32::byteSize() { return 4; } int AddressX86Flat32::compareTo(const Object *obj) const { assert(getObjectID() == obj->getObjectID()); if (addr > ((AddressX86Flat32 *)obj)->addr) return 1; if (addr < ((AddressX86Flat32 *)obj)->addr) return -1; return 0; } int AddressX86Flat32::compareDelinear(Address *to) { assert(getObjectID() == to->getObjectID()); uint32 da = delinearize(addr); uint32 db = delinearize(((AddressFlat32 *)to)->addr); if (da > db) return 1; if (da < db) return -1; return 0; } bool AddressX86Flat32::difference(int &result, Address *to) { if (getObjectID() == to->getObjectID()) { result = addr-((AddressX86Flat32 *)to)->addr; return true; } else { return false; } } AddressX86Flat32 *AddressX86Flat32::clone() const { return new AddressX86Flat32(*this); } void AddressX86Flat32::getFromArray(const byte *array) { memcpy(&addr, array, sizeof(addr)); } void AddressX86Flat32::getFromCPUAddress(CPU_ADDR *ca) { addr = ca->addr32.offset; } bool AddressX86Flat32::getFromUInt64(uint64 u) { if (u <= 0xffffffff) { addr = u; return true; } else { return false; } } void AddressX86Flat32::load(ObjectStream &s) { GET_INT32X(s, addr); } ObjectID AddressX86Flat32::getObjectID() const { return ATOM_ADDRESS_X86_FLAT_32; } int AddressX86Flat32::parseString(const char *s, int length, Analyser *a) { return 0; } void AddressX86Flat32::putIntoArray(byte *array) const { memcpy(array, &addr, sizeof(addr)); } void AddressX86Flat32::putIntoCPUAddress(CPU_ADDR *ca) const { ca->addr32.offset = addr; } bool AddressX86Flat32::putIntoUInt64(uint64 &u) const { u = addr; return true; } void AddressX86Flat32::store(ObjectStream &s) const { PUT_INT32X(s, addr); } int AddressX86Flat32::stringify(char *s, int max_length, int format) const { const char *formats[] = { "%s%x%s", "%s%8x%s", "%s%08x%s", "", "%s%X%s", "%s%8X%s", "%s%08X%s", "", }; return ht_snprintf(s, max_length, formats[format&7], (format & ADDRESS_STRING_FORMAT_ADD_0X) ? "0x":"", addr, (format & ADDRESS_STRING_FORMAT_ADD_H) ? "h":""); } int AddressX86Flat32::stringSize() const { return 8; } AddressX86_1632::AddressX86_1632(uint16 Seg, uint32 Addr) { seg = Seg; addr = Addr; } bool AddressX86_1632::add(int offset) { // check for overflow if ((int)offset < 0) { if (addr+offset > addr) return false; } else { if (addr+offset < addr) return false; } addr+=offset; return true; } int AddressX86_1632::byteSize() { return 6; } int AddressX86_1632::compareTo(const Object *obj) const { assert(getObjectID() == obj->getObjectID()); if (seg > ((AddressX86_1632 *)obj)->seg) return 1; if (seg < ((AddressX86_1632 *)obj)->seg) return -1; if (addr > ((AddressX86_1632 *)obj)->addr) return 1; if (addr < ((AddressX86_1632 *)obj)->addr) return -1; return 0; } int AddressX86_1632::compareDelinear(Address *to) { assert(getObjectID() == to->getObjectID()); uint32 s1 = delinearize(seg); uint32 s2 = delinearize(((AddressX86_1632 *)to)->seg); if (s1 > s2) return 1; if (s1 < s2) return -1; uint32 a1 = delinearize(addr); uint32 a2 = delinearize(((AddressX86_1632 *)to)->addr); if (a1 > a2) return 1; if (a1 < a2) return -1; return 0; } bool AddressX86_1632::difference(int &result, Address *to) { if ((getObjectID() == to->getObjectID()) && (seg == ((AddressX86_1632 *)to)->seg)) { result = addr-((AddressX86_1632 *)to)->addr; return true; } else { return false; } } AddressX86_1632 *AddressX86_1632::clone() const { return new AddressX86_1632(*this); } void AddressX86_1632::getFromArray(const byte *array) { memcpy(&addr, array, sizeof(addr)); memcpy(&seg, array + sizeof(addr), sizeof(seg)); } void AddressX86_1632::getFromCPUAddress(CPU_ADDR *ca) { seg = ca->addr32.seg; addr = ca->addr32.offset; } bool AddressX86_1632::getFromUInt64(uint64 u) { return false; } void AddressX86_1632::load(ObjectStream &s) { GET_INT16X(s, seg); GET_INT16X(s, addr); } ObjectID AddressX86_1632::getObjectID() const { return ATOM_ADDRESS_X86_1632; } int AddressX86_1632::parseString(const char *s, int length, Analyser *a) { return 0; } void AddressX86_1632::putIntoArray(byte *array) const { memcpy(array, &addr, sizeof(addr)); memcpy(array + sizeof(addr), &seg, sizeof(seg)); } void AddressX86_1632::putIntoCPUAddress(CPU_ADDR *ca) const { ca->addr32.seg = seg; ca->addr32.offset = addr; } bool AddressX86_1632::putIntoUInt64(uint64 &u) const { return false; } void AddressX86_1632::store(ObjectStream &s) const { PUT_INT16X(s, seg); PUT_INT16X(s, addr); } int AddressX86_1632::stringify(char *s, int max_length, int format) const { const char *formats[] = { "%s%x%s:%s%x%s", "%s%4x%s:%s%08x%s", "%s%04x%s:%s%08x%s", "", "%s%X%s:%s%X%s", "%s%4X%s:%s%08X%s", "%s%04X%s:%s%08X%s", "", }; return ht_snprintf(s, max_length, formats[format&7], (format & ADDRESS_STRING_FORMAT_ADD_0X) ? "0x":"", seg, (format & ADDRESS_STRING_FORMAT_ADD_H) ? "h":"", (format & ADDRESS_STRING_FORMAT_ADD_0X) ? "0x":"", addr, (format & ADDRESS_STRING_FORMAT_ADD_H) ? "h":""); } int AddressX86_1632::stringSize() const { return 14; } /* * */ AddressX86_1616::AddressX86_1616(uint16 Seg, uint16 Addr) { seg = Seg; addr = Addr; } bool AddressX86_1616::add(int offset) { // check for overflow if ((int)offset < 0) { if (addr+offset > addr) return false; } else { if (addr+offset < addr) return false; } addr+=offset; return true; } int AddressX86_1616::byteSize() { return 4; } int AddressX86_1616::compareTo(const Object *obj) const { assert(getObjectID() == obj->getObjectID()); if (seg > ((AddressX86_1616 *)obj)->seg) return 1; if (seg < ((AddressX86_1616 *)obj)->seg) return -1; if (addr > ((AddressX86_1616 *)obj)->addr) return 1; if (addr < ((AddressX86_1616 *)obj)->addr) return -1; return 0; } int AddressX86_1616::compareDelinear(Address *to) { assert(getObjectID() == to->getObjectID()); uint32 s1 = delinearize(seg); uint32 s2 = delinearize(((AddressX86_1616 *)to)->seg); if (s1 > s2) return 1; if (s1 < s2) return -1; uint32 a1 = delinearize(addr); uint32 a2 = delinearize(((AddressX86_1616 *)to)->addr); if (a1 > a2) return 1; if (a1 < a2) return -1; return 0; } bool AddressX86_1616::difference(int &result, Address *to) { if ((getObjectID() == to->getObjectID()) && (seg == ((AddressX86_1616 *)to)->seg)) { result = (int)addr-(int)((AddressX86_1616 *)to)->addr; return true; } else { return false; } } AddressX86_1616 *AddressX86_1616::clone() const { return new AddressX86_1616(*this); } void AddressX86_1616::getFromArray(const byte *array) { memcpy(&addr, array, sizeof(addr)); memcpy(&seg, array + sizeof(addr), sizeof(seg)); } bool AddressX86_1616::getFromUInt64(uint64 u) { return false; } void AddressX86_1616::getFromCPUAddress(CPU_ADDR *ca) { seg = ca->addr32.seg; addr = ca->addr32.offset; } void AddressX86_1616::load(ObjectStream &s) { GET_INT16X(s, seg); GET_INT16X(s, addr); } ObjectID AddressX86_1616::getObjectID() const { return ATOM_ADDRESS_X86_1616; } int AddressX86_1616::parseString(const char *s, int length, Analyser *a) { return 0; } void AddressX86_1616::putIntoArray(byte *array) const { memcpy(array, &addr, sizeof(addr)); memcpy(array + sizeof(addr), &seg, sizeof(seg)); } void AddressX86_1616::putIntoCPUAddress(CPU_ADDR *ca) const { ca->addr32.seg = seg; ca->addr32.offset = addr; } bool AddressX86_1616::putIntoUInt64(uint64 &u) const { return false; } void AddressX86_1616::store(ObjectStream &s) const { PUT_INT16X(s, seg); PUT_INT16X(s, addr); } int AddressX86_1616::stringify(char *s, int max_length, int format) const { const char *formats[] = { "%s%x%s:%s%04x%s", "%s%4x%s:%s%04x%s", "%s%04x%s:%s%04x%s", "", "%s%X%s:%s%04X%s", "%s%4X%s:%s%04X%s", "%s%04X%s:%s%04X%s", "", }; return ht_snprintf(s, max_length, formats[format&7], (format & ADDRESS_STRING_FORMAT_ADD_0X) ? "0x":"", seg, (format & ADDRESS_STRING_FORMAT_ADD_H) ? "h":"", (format & ADDRESS_STRING_FORMAT_ADD_0X) ? "0x":"", addr, (format & ADDRESS_STRING_FORMAT_ADD_H) ? "h":""); } int AddressX86_1616::stringSize() const { return 9; } void AnalyX86Disassembler::init(Analyser *A, int f) { flags = f; createUnasm(); AnalyDisassembler::init(A); } /* * */ void AnalyX86Disassembler::load(ObjectStream &f) { GET_INT32X(f, flags); AnalyDisassembler::load(f); } /* * */ ObjectID AnalyX86Disassembler::getObjectID() const { return ATOM_ANALY_X86; } Address *AnalyX86Disassembler::createAddress(uint16 segment, uint64 offset) { if (flags & (ANALYX86DISASSEMBLER_FLAGS_FLAT64 | ANALYX86DISASSEMBLER_FLAGS_AMD64)) { return new AddressFlat64(offset); } else if (flags & ANALYX86DISASSEMBLER_FLAGS_SEGMENTED) { if (offset <= 0xffff) { return new AddressX86_1616(segment, offset); } else { // FIXME // return new AddressX86_1632(segment, offset); return new AddressX86_1616(segment, offset); } } else { return new AddressX86Flat32(offset); } } void AnalyX86Disassembler::createUnasm() { if (flags & ANALYX86DISASSEMBLER_FLAGS_AMD64) { disasm = new x86_64dis(); } else { if (flags & ANALYX86DISASSEMBLER_FLAGS_VXD_X86DIS) { if (flags & ANALYX86DISASSEMBLER_FLAGS_16BIT) { disasm = new x86dis_vxd(X86_OPSIZE16, X86_ADDRSIZE16); } else { disasm = new x86dis_vxd(X86_OPSIZE32, X86_ADDRSIZE32); } } else { if (flags & ANALYX86DISASSEMBLER_FLAGS_16BIT) { disasm = new x86dis(X86_OPSIZE16, X86_ADDRSIZE16); } else { disasm = new x86dis(X86_OPSIZE32, X86_ADDRSIZE32); } } } } uint16 AnalyX86Disassembler::getSegment(Address *addr) { if (addr->getObjectID() == ATOM_ADDRESS_X86_1616) { return ((AddressX86_1616*)addr)->seg; } else if (addr->getObjectID() == ATOM_ADDRESS_X86_1632) { return ((AddressX86_1632*)addr)->seg; } else { assert(0); return 0; } } /* * */ Address *AnalyX86Disassembler::branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine) { Address *addr; x86dis_insn *o = (x86dis_insn*)opcode; assert(o->op[1].type == X86_OPTYPE_EMPTY); switch (o->op[0].type) { case X86_OPTYPE_IMM: { uint16 seg = 0; if (flags & ANALYX86DISASSEMBLER_FLAGS_SEGMENTED) { seg = getSegment(analy->addr); } addr = createAddress(seg, o->op[0].imm); return addr; } case X86_OPTYPE_FARPTR: if (flags & ANALYX86DISASSEMBLER_FLAGS_SEGMENTED) { addr = createAddress(o->op[0].farptr.seg, o->op[0].farptr.offset); } else { break; } return addr; case X86_OPTYPE_MEM: { taccess access; addr = NULL; if (o->op[0].mem.hasdisp) { addr = createAddress(0, o->op[0].mem.disp); access.type = acread; access.indexed = (o->op[0].mem.base != X86_REG_NO) || (o->op[0].mem.index != X86_REG_NO); access.size = o->op[0].size; } else { break; } if (examine && analy->validAddress(addr, scvalid)) { analy->dataAccess(addr, access); xref_enum_t xref; switch (branchtype) { case br_jXX: case br_jump: xref = xrefijump; break; case br_call: xref = xreficall; break; default: {assert(0);} } analy->addXRef(addr, analy->addr, xref); } if (examine) { delete addr; break; } else { return addr; } } default: break; } return new InvalidAddress(); } /* * */ void AnalyX86Disassembler::examineOpcode(OPCODE *opcode) { x86dis_insn *o = (x86dis_insn*)opcode; for (int i = 0; i < 5; i++) { x86_insn_op *op = &o->op[i]; Address *addr = NULL; taccess access; xref_enum_t xref = xrefoffset; switch (op->type) { case X86_OPTYPE_IMM: access.type = acoffset; access.indexed = false; addr = createAddress(0, op->imm); break; case X86_OPTYPE_FARPTR: if (flags & ANALYX86DISASSEMBLER_FLAGS_SEGMENTED) { addr = createAddress(op->farptr.seg, op->farptr.offset); } access.type = acoffset; access.indexed = false; break; case X86_OPTYPE_MEM: if (op->mem.hasdisp) { addr = createAddress(0, op->mem.disp); access.type = acread; access.indexed = (op->mem.base != X86_REG_NO) || (op->mem.index != X86_REG_NO); access.size = op->size; if (strcmp(o->name, "cmp")==0 || strcmp(o->name, "test")==0 || strcmp(o->name, "push")==0) { xref = xrefread; } else { xref = (i==0) ? xrefwrite : xrefread; } } break; default: continue; } if (addr) { if (analy->validAddress(addr, scvalid)) { analy->dataAccess(addr, access); analy->addXRef(addr, analy->addr, xref); } delete addr; } } } /* * */ branch_enum_t AnalyX86Disassembler::isBranch(OPCODE *opcode) { x86dis_insn *o = (x86dis_insn*)opcode; const char *opcode_str = o->name; if (opcode_str[0] == '~') { opcode_str++; } if (opcode_str[0] == '|') { opcode_str++; } if (opcode_str[0]=='j') { if (opcode_str[1]=='m') return br_jump; else return br_jXX; } else if ((opcode_str[0]=='l') && (opcode_str[1]=='o') && (opcode_str[2]=='o')) { // loop opcode will be threated like a jXX return br_jXX; } else if ((opcode_str[0]=='c') && (opcode_str[1]=='a')) { return br_call; } else if ((opcode_str[0]=='r') && (opcode_str[1]=='e')) { return br_return; } else return br_nobranch; } /* * */ void AnalyX86Disassembler::store(ObjectStream &f) const { PUT_INT32X(f, flags); AnalyDisassembler::store(f); } ht-2.0.22/analyser/pef_analy.h0000644000175000001440000000403710615342710013055 00000000000000/* * HT Editor * pef_analy.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef pef_analy_h #define pef_analy_h #include "analy.h" #include "htpef.h" //test #include "pefstruc.h" class PEFAnalyser: public Analyser { public: ht_pef_shared_data *pef_shared; File *file; Area *validarea; PEFAnalyser(); PEFAnalyser(BuildCtorArg&a): Analyser(a) {}; void init(ht_pef_shared_data *pef_shared, File *File); void load(ObjectStream &f); virtual void done(); virtual ObjectID getObjectID() const; virtual void beginAnalysis(); virtual uint bufPtr(Address *Addr, byte *buf, int size); bool convertAddressToPEFAddress(Address *addr, PEFAddress *r); virtual Address *createAddress(); Address *createAddress32(uint32 addr); Address *createAddress64(uint64 addr); virtual Assembler *createAssembler(); virtual String & getName(String &res); virtual const char *getType(); virtual void initCodeAnalyser(); void initInsertSymbols(int shidx); virtual void initUnasm(); virtual void log(const char *msg); virtual Address *nextValid(Address *Addr); virtual void store(ObjectStream &f) const; virtual int queryConfig(int mode); virtual bool validAddress(Address *Addr, tsectype action); virtual Address *fileofsToAddress(FileOfs fileofs); virtual FileOfs addressToFileofs(Address *Addr); virtual const char *getSegmentNameByAddress(Address *Addr); }; #endif ht-2.0.22/analyser/coff_analy.cc0000644000175000001440000003126710615342710013363 00000000000000/* * HT Editor * coff_analy.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "analy.h" #include "analy_alpha.h" #include "analy_names.h" #include "analy_register.h" #include "analy_ppc.h" #include "analy_x86.h" #include "analy_arm.h" #include "coff_analy.h" #include "coff_s.h" #include "htctrl.h" #include "htdebug.h" #include "htiobox.h" #include "htcoff.h" #include "strtools.h" #include "snprintf.h" #include "x86asm.h" /* * */ void CoffAnalyser::init(ht_coff_shared_data *Coff_shared, File *File) { coff_shared = Coff_shared; file = File; validarea = new Area(); validarea->init(); Analyser::init(); ///////////// setLocationTreeOptimizeThreshold(100); setSymbolTreeOptimizeThreshold(100); } /* * */ void CoffAnalyser::load(ObjectStream &f) { /* ht_pe_shared_data *pe_shared; ht_stream *file; area *validarea; */ GET_OBJECT(f, validarea); Analyser::load(f); } /* * */ void CoffAnalyser::done() { validarea->done(); delete validarea; Analyser::done(); } /* * */ void CoffAnalyser::beginAnalysis() { // char buffer[1024]; /* * entrypoint */ Address *entry=createAddress32(coff_shared->coff32header.entrypoint_address); pushAddress(entry, entry); /* * give all sections a descriptive comment: */ /*struct PE_SECTION_HEADER { byte name[PE_SIZEOF_SHORT_NAME] __attribute__ ((packed)); uint32 data_vsize __attribute__ ((packed)); uint32 data_address __attribute__ ((packed)); uint32 data_size __attribute__ ((packed)); uint32 data_offset __attribute__ ((packed)); uint32 relocation_offset __attribute__ ((packed)); uint32 linenumber_offset __attribute__ ((packed)); uint16 relocation_count __attribute__ ((packed)); uint16 linenumber_count __attribute__ ((packed)); uint32 characteristics __attribute__ ((packed)); };*/ COFF_SECTION_HEADER *s=coff_shared->sections.sections; char blub[100]; for (uint i=0; isections.section_count; i++) { Address *secaddr = createAddress32(s->data_address); sprintf(blub, "; section %d <%s>", i+1, getSegmentNameByAddress(secaddr)); addComment(secaddr, 0, ""); addComment(secaddr, 0, ";******************************************************************"); addComment(secaddr, 0, blub); sprintf(blub, "; virtual address %08x size %08x", s->data_address, s->data_size); addComment(secaddr, 0, blub); sprintf(blub, "; file offset %08x", s->data_offset+coff_shared->hdr_ofs); addComment(secaddr, 0, blub); addComment(secaddr, 0, ";******************************************************************"); // mark end of sections sprintf(blub, "; end of section <%s>", getSegmentNameByAddress(secaddr)); Address *secend_addr = secaddr->clone(); secend_addr->add(MAX(s->data_size, s->data_vsize)); newLocation(secend_addr)->flags |= AF_FUNCTION_END; addComment(secend_addr, 0, ""); addComment(secend_addr, 0, ";******************************************************************"); addComment(secend_addr, 0, blub); addComment(secend_addr, 0, ";******************************************************************"); validarea->add(secaddr, secend_addr); Address *secini_addr = secaddr->clone(); secini_addr->add(MIN(s->data_size, s->data_vsize)); if (validAddress(secaddr, scinitialized) && validAddress(secini_addr, scinitialized)) { initialized->add(secaddr, secini_addr); } s++; delete secaddr; delete secend_addr; delete secini_addr; } // exports /* int export_count=coff_shared->exports.funcs->count(); int *entropy = random_permutation(export_count); for (int i=0; iexports.funcs->get(*(entropy+i)); if (valid_addr(f->address, scvalid)) { char *label; if (f->byname) { sprintf(buffer, "; exported function %s, ordinal %04x", f->name, f->ordinal); } else { sprintf(buffer, "; unnamed exported function, ordinal %04x", f->ordinal); } label = export_func_name((f->byname) ? f->name : NULL, f->ordinal); add_comment(f->address, 0, ""); add_comment(f->address, 0, ";********************************************************"); add_comment(f->address, 0, buffer); add_comment(f->address, 0, ";********************************************************"); push_addr(f->address, f->address); assign_label(f->address, label, label_func); free(label); } } if (entropy) free(entropy);*/ /* int import_count=pe_shared->imports.funcs->count(); entropy = random_permutation(import_count); for (int i=0; iimports.funcs->get(*(entropy+i)); ht_pe_import_library *d=(ht_pe_import_library *)pe_shared->imports.libs->get(f->libidx); char *label; label = import_func_name(d->name, (f->byname) ? f->name.name : NULL, f->ordinal); add_comment(f->address, 0, ""); assign_label(f->address, label, label_func); data->set_int_addr_type(f->address, dst_idword, 4); free(label); } if (entropy) free(entropy); int dimport_count=pe_shared->dimports.funcs->count(); entropy = random_permutation(dimport_count); for (int i=0; idimports.funcs->get(*(entropy+i)); ht_pe_import_library *d=(ht_pe_import_library *)pe_shared->dimports.libs->get(f->libidx); char *label; label = import_func_name(d->name, f->byname ? f->name.name : NULL, f->ordinal); add_comment(f->address, 0, ""); assign_label(f->address, label, label_func); // data->setintaddrtype(f->address, dstidword, 4); free(label); } if (entropy) free(entropy);*/ addComment(entry, 0, ""); addComment(entry, 0, ";****************************"); if (coff_shared->coffheader.characteristics & COFF_DLL) { addComment(entry, 0, "; library entry point"); } else { addComment(entry, 0, "; program entry point"); } addComment(entry, 0, ";****************************"); assignSymbol(entry, "entrypoint", label_func); setLocationTreeOptimizeThreshold(1000); setSymbolTreeOptimizeThreshold(1000); delete entry; Analyser::beginAnalysis(); } /* * */ ObjectID CoffAnalyser::getObjectID() const { return ATOM_COFF_ANALYSER; } /* * */ uint CoffAnalyser::bufPtr(Address *Addr, byte *buf, int size) { FileOfs ofs = addressToFileofs(Addr); assert(ofs != INVALID_FILE_OFS); file->seek(ofs); return file->read(buf, size); } bool CoffAnalyser::convertAddressToRVA(Address *addr, RVA *r) { if (addr->getObjectID()==ATOM_ADDRESS_X86_FLAT_32) { *r = ((AddressX86Flat32*)addr)->addr; } else if (addr->getObjectID()==ATOM_ADDRESS_FLAT_32) { *r = ((AddressFlat32*)addr)->addr; } else { return false; } return true; } Address *CoffAnalyser::createAddress() { switch (coff_shared->coffheader.machine) { case COFF_MACHINE_I386: case COFF_MACHINE_I486: case COFF_MACHINE_I586: return new AddressX86Flat32(0); default: return new AddressFlat32(0); } } Address *CoffAnalyser::createAddress32(uint32 addr) { switch (coff_shared->coffheader.machine) { case COFF_MACHINE_I386: case COFF_MACHINE_I486: case COFF_MACHINE_I586: return new AddressX86Flat32(addr); default: return new AddressFlat32(addr); } } /* * */ Assembler *CoffAnalyser::createAssembler() { switch (coff_shared->coffheader.machine) { case COFF_MACHINE_I386: case COFF_MACHINE_I486: case COFF_MACHINE_I586: Assembler *a = new x86asm(X86_OPSIZE32, X86_ADDRSIZE32); a->init(); return a; } return NULL; } /* * */ FileOfs CoffAnalyser::addressToFileofs(Address *Addr) { if (validAddress(Addr, scinitialized)) { FileOfs ofs; // Addr-=pe_shared->pe32.header_nt.image_base; RVA rva; if (!convertAddressToRVA(Addr, &rva)) return INVALID_FILE_OFS; if (!coff_rva_to_ofs(&coff_shared->sections, rva, &ofs)) return INVALID_FILE_OFS; return ofs; } else { return INVALID_FILE_OFS; } } /* * */ const char *CoffAnalyser::getSegmentNameByAddress(Address *Addr) { static char sectionname[9]; coff_section_headers *sections=&coff_shared->sections; int i; RVA rva; if (!convertAddressToRVA(Addr, &rva)) return NULL; coff_rva_to_section(sections, rva, &i); COFF_SECTION_HEADER *s=sections->sections+i; if (!coff_rva_is_valid(sections, rva)) return NULL; memcpy(sectionname, s->name, 8); sectionname[8] = 0; return sectionname; } /* * */ String &CoffAnalyser::getName(String &res) { return file->getDesc(res); } /* * */ const char *CoffAnalyser::getType() { return "COFF/Analyser"; } /* * */ void CoffAnalyser::initCodeAnalyser() { Analyser::initCodeAnalyser(); } /* * */ void CoffAnalyser::initUnasm() { DPRINTF("coff_analy: "); switch (coff_shared->coffheader.machine) { case COFF_MACHINE_I386: // Intel 386 case COFF_MACHINE_I486: // Intel 486 case COFF_MACHINE_I586: // Intel 586 DPRINTF("initing analy_x86_disassembler\n"); analy_disasm = new AnalyX86Disassembler(); ((AnalyX86Disassembler*)analy_disasm)->init(this, 0); break; case COFF_MACHINE_R3000: // MIPS little-endian, 0x160 big-endian DPRINTF("no apropriate disassembler for MIPS\n"); warnbox("No disassembler for MIPS!"); break; case COFF_MACHINE_R4000: // MIPS little-endian DPRINTF("no apropriate disassembler for MIPS\n"); warnbox("No disassembler for MIPS!"); break; case COFF_MACHINE_R10000: // MIPS little-endian DPRINTF("no apropriate disassembler for MIPS\n"); warnbox("No disassembler for MIPS!"); break; case COFF_MACHINE_ALPHA: // Alpha_AXP DPRINTF("initing alpha_axp_disassembler\n"); analy_disasm = new AnalyAlphaDisassembler(); ((AnalyAlphaDisassembler *)analy_disasm)->init(this); break; case COFF_MACHINE_POWERPC_LE: // IBM PowerPC Little-Endian DPRINTF("no apropriate disassembler for POWER PC\n"); warnbox("No disassembler for little endian POWER PC!"); break; case COFF_MACHINE_POWERPC_BE: analy_disasm = new AnalyPPCDisassembler(); ((AnalyPPCDisassembler*)analy_disasm)->init(this, ANALY_PPC_32); break; case COFF_MACHINE_ARM: case COFF_MACHINE_THUMB: analy_disasm = new AnalyArmDisassembler(); ((AnalyArmDisassembler*)analy_disasm)->init(this); break; case COFF_MACHINE_UNKNOWN: default: DPRINTF("no apropriate disassembler for machine %04x\n", coff_shared->coffheader.machine); warnbox("No disassembler for unknown machine type %04x!", coff_shared->coffheader.machine); } } /* * */ void CoffAnalyser::log(const char *msg) { /* * log() creates to much traffic so dont log * perhaps we reactivate this later * */ /* LOG(msg);*/ } /* * */ Address *CoffAnalyser::nextValid(Address *Addr) { return (Address *)validarea->findNext(Addr); } /* * */ void CoffAnalyser::store(ObjectStream &st) const { /* ht_pe_shared_data *pe_shared; ht_stream *file; area *validarea; */ PUT_OBJECT(st, validarea); Analyser::store(st); } /* * */ int CoffAnalyser::queryConfig(int mode) { switch (mode) { case Q_DO_ANALYSIS: case Q_ENGAGE_CODE_ANALYSER: case Q_ENGAGE_DATA_ANALYSER: return true; default: return 0; } } /* * */ Address *CoffAnalyser::fileofsToAddress(FileOfs fileofs) { RVA a; if (coff_ofs_to_rva(&coff_shared->sections, fileofs, &a)) { return createAddress32(a); } else { return new InvalidAddress(); } } /* * */ bool CoffAnalyser::validAddress(Address *Addr, tsectype action) { coff_section_headers *sections=&coff_shared->sections; int sec; RVA rva; if (!convertAddressToRVA(Addr, &rva)) return false; if (!coff_rva_to_section(sections, rva, &sec)) return false; COFF_SECTION_HEADER *s=sections->sections+sec; switch (action) { case scvalid: return true; case scread: return s->characteristics & COFF_SCN_MEM_READ; case scwrite: return s->characteristics & COFF_SCN_MEM_WRITE; case screadwrite: return s->characteristics & COFF_SCN_MEM_WRITE; case sccode: // FIXME: EXECUTE vs. CNT_CODE ? if (!coff_rva_is_physical(sections, rva)) return false; return (s->characteristics & (COFF_SCN_MEM_EXECUTE | COFF_SCN_CNT_CODE)); case scinitialized: if (!coff_rva_is_physical(sections, rva)) return false; return !(s->characteristics & COFF_SCN_CNT_UNINITIALIZED_DATA); } return false; } ht-2.0.22/analyser/language.h0000644000175000001440000000410110615342710012672 00000000000000/* * HT Editor * language.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef LANGUAGE_H #define LANGUAGE_H #include "io/types.h" #include "data.h" #define NL 10 #define WHITESPACE ' ' #define COMMENT '#' #define INV 255 extern byte mapchar[]; class analy_string: public Object { protected: byte *string; int len; public: void init(const byte *s, int Len); virtual void done(); virtual void render_string(char *result, int maxlen) = 0; void set_len(int Len); int length(); virtual const char *name() = 0; }; class analy_raw_string: public analy_string { public: virtual void render_string(char *result, int maxlen); static int string_test(const byte *s, int testlen, int &foundlen); virtual const char *name(); }; class analy_c_string: public analy_string { public: virtual void render_string(char *result, int maxlen); static int string_test(const byte *s, int testlen, int &foundlen); virtual const char *name(); }; class analy_unicode_string: public analy_string { public: virtual void render_string(char *result, int maxlen); static int string_test(const byte *s, int testlen, int &foundlen); virtual const char *name(); }; class analy_pascal_string: public analy_string { public: virtual void render_string(char *result, int maxlen); static int string_test(const byte *s, int testlen, int &foundlen); virtual const char *name(); }; analy_string *string_test(const byte *s, int testlen); #endif ht-2.0.22/analyser/analy_java.cc0000644000175000001440000001277510615342707013400 00000000000000/* * HT Editor * analy_java.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "analy_register.h" #include "analy_java.h" #include "htdebug.h" #include "javadis.h" #include "strtools.h" #include "snprintf.h" void AnalyJavaDisassembler::init(Analyser *A, java_token_func token_func, void *context) { disasm = new javadis(token_func, context); AnalyDisassembler::init(A); } /* * */ ObjectID AnalyJavaDisassembler::getObjectID() const { return ATOM_ANALY_JAVA; } /* * */ Address *AnalyJavaDisassembler::branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine) { javadis_insn *o = (javadis_insn*)opcode; switch (o->op[0].type) { case JAVA_OPTYPE_LABEL: return new AddressFlat32(o->op[0].label); } return new InvalidAddress(); } static uint32 read4(Analyser *a, Address &addr, byte *b) { if (a->bufPtr(&addr, b, 4) != 4) throw 1; addr.add(4); return (b[0]<<24) | (b[1]<<16) | (b[2]<<8) | b[3]; } void AnalyJavaDisassembler::examineOpcode(OPCODE *opcode) { javadis_insn *o = (javadis_insn*)opcode; const char *opcode_str = o->name; if (strcmp("lookupswitch", opcode_str) == 0) { uint32 ofs = o->addr; AddressFlat32 c(ofs); Location *loc = analy->getFunctionByAddress(&c); if (loc) { AddressFlat32 *func = (AddressFlat32 *)loc->addr; uint32 f = func->addr; ofs = ofs+1 - f; while (ofs % 4) { AddressFlat32 iofs(f+ofs); analy->data->setIntAddressType(&iofs, dst_ibyte, 1); ofs++; } AddressFlat32 iofs(f + ofs); byte buf[4]; try { analy->data->setIntAddressType(&iofs, dst_idword, 4); uint32 default_ofs = read4(analy, iofs, buf); analy->data->setIntAddressType(&iofs, dst_idword, 4); uint32 n = read4(analy, iofs, buf); for (uint32 i=0; i < n; i++) { char buffer[100]; analy->data->setIntAddressType(&iofs, dst_idword, 4); uint32 value = read4(analy, iofs, buf); analy->data->setIntAddressType(&iofs, dst_idword, 4); uint32 rel_ofs = read4(analy, iofs, buf); AddressFlat32 a(o->addr + rel_ofs); if (!analy->getLocationByAddress(&a)) analy->addComment(&a, 0, ""); ht_snprintf(buffer, sizeof buffer, "lookupswitch value: %d", value); analy->addComment(&a, 0, buffer); analy->addAddressSymbol(&a, "lookup", label_loc, loc); analy->pushAddress(&a, func); analy->addXRef(&a, &c, xrefijump); } AddressFlat32 a(o->addr + default_ofs); analy->addComment(&a, 0, ""); analy->addComment(&a, 0, "lookupswitch default"); analy->addAddressSymbol(&a, "lookup", label_loc, loc); analy->pushAddress(&a, func); analy->addXRef(&a, &c, xrefijump); } catch (...) { return; } } } else if (strcmp("tableswitch", opcode_str) == 0) { uint32 ofs = o->addr; AddressFlat32 c(ofs); Location *loc = analy->getFunctionByAddress(&c); if (loc) { AddressFlat32 *func = (AddressFlat32 *)loc->addr; uint32 f = func->addr; ofs = ofs+1 - f; while (ofs % 4) { AddressFlat32 iofs(f+ofs); analy->data->setIntAddressType(&iofs, dst_ibyte, 1); ofs++; } AddressFlat32 iofs(f + ofs); byte buf[4]; try { analy->data->setIntAddressType(&iofs, dst_idword, 4); uint32 default_ofs = read4(analy, iofs, buf); analy->data->setIntAddressType(&iofs, dst_idword, 4); sint32 low = read4(analy, iofs, buf); analy->data->setIntAddressType(&iofs, dst_idword, 4); sint32 high = read4(analy, iofs, buf); for (sint32 i=low; i <= high; i++) { char buffer[100]; analy->data->setIntAddressType(&iofs, dst_idword, 4); uint32 rel_ofs = read4(analy, iofs, buf); AddressFlat32 a(o->addr + rel_ofs); if (!analy->getLocationByAddress(&a)) analy->addComment(&a, 0, ""); ht_snprintf(buffer, sizeof buffer, "tableswitch value: %d", i); analy->addComment(&a, 0, buffer); analy->addAddressSymbol(&a, "table", label_loc, loc); analy->pushAddress(&a, func); analy->addXRef(&a, &c, xrefijump); } AddressFlat32 a(o->addr + default_ofs); analy->addComment(&a, 0, ""); analy->addComment(&a, 0, "tableswitch default"); analy->addAddressSymbol(&a, "table", label_loc, loc); analy->pushAddress(&a, func); analy->addXRef(&a, &c, xrefijump); } catch (...) { return; } } } } /* * */ branch_enum_t AnalyJavaDisassembler::isBranch(OPCODE *opcode) { javadis_insn *o = (javadis_insn*)opcode; const char *opcode_str = o->name; if ((opcode_str[0]=='i') && (opcode_str[1]=='f')) { return br_jXX; } else if ((strcmp("tableswitch", opcode_str)==0) || (strcmp("lookupswitch", opcode_str)==0)) { examineOpcode(opcode); return br_jump; } else if (ht_strncmp("ret", opcode_str, 3)==0 || ht_strncmp("ret", opcode_str+1, 3)==0 || ht_strncmp("athrow", opcode_str, 6)==0) { return br_return; } else if (ht_strncmp("goto", opcode_str, 4)==0) { return br_jump; } else if (ht_strncmp("jsr", opcode_str, 3)==0) { return br_call; } else return br_nobranch; } ht-2.0.22/analyser/class_analy.cc0000644000175000001440000001627310636023333013553 00000000000000/* * HT Editor * class_analy.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "analy.h" #include "analy_alpha.h" #include "analy_names.h" #include "analy_register.h" #include "analy_java.h" #include "class.h" #include "class_analy.h" #include "htctrl.h" #include "htdebug.h" #include "htiobox.h" #include "strtools.h" #include "snprintf.h" #include "pestruct.h" #include #include #include /* * */ void ClassAnalyser::init(ht_class_shared_data *Class_shared, File *File) { class_shared = Class_shared; file = File; Analyser::init(); initialized->done(); delete initialized; initialized = class_shared->initialized->clone(); ///////////// setLocationTreeOptimizeThreshold(100); setSymbolTreeOptimizeThreshold(100); } /* * */ void ClassAnalyser::beginAnalysis() { char buffer[1024]; String b; *java_demangle_flags(buffer, class_shared->flags) = 0; b.assignFormat("; %s%s %s", buffer, (class_shared->flags & jACC_INTERFACE)?"interface":"class", class_shared->classinfo.thisclass); if (class_shared->classinfo.superclass) { String b2; b2.assignFormat(" extends %s", class_shared->classinfo.superclass); b += b2; } if (class_shared->classinfo.interfaces) { b += " implements"; int count = class_shared->classinfo.interfaces->count(); for (int i=0; i < count; i++) { String b2; b2.assignFormat("%y%c", (*class_shared->classinfo.interfaces)[i], (i+1fields && class_shared->fields->count()) { addComment(a, 0, ""); addComment(a, 0, "; Fields: "); addComment(a, 0, "; ========="); foreach (ClassField, cf, *class_shared->fields, { char buffer2[1024]; java_demangle_field(buffer2, cf->name, cf->type, cf->flags); ht_snprintf(buffer, 1024, "; %s", buffer2); addComment(a, 0, buffer); }); addComment(a, 0, ""); } delete a; if (class_shared->methods) { foreach (ClassMethod, cm, *class_shared->methods, { Address *a = createAddress32(cm->start); char buffer2[1024]; java_demangle(buffer2, class_shared->classinfo.thisclass, cm->name, cm->type, cm->flags); ht_snprintf(buffer, 1024, "; %s", buffer2); addComment(a, 0, ""); addComment(a, 0, ";----------------------------------------------"); addComment(a, 0, buffer); addComment(a, 0, ";----------------------------------------------"); addAddressSymbol(a, cm->name, label_func); pushAddress(a, a); if (cm->length) { Address *b = createAddress32(cm->start + cm->length - 1); initialized->add(a, b); delete b; } delete a; for (int i=0; i < cm->exctbl_len; i++) { exception_info *ei = cm->exctbl + i; if (ei->catch_type) { token_translate(buffer2, sizeof buffer2, ei->catch_type, class_shared); } else { ht_strlcpy(buffer2, "...", sizeof buffer2); } ht_snprintf(buffer, sizeof buffer, "catch (%s)", buffer2); Address *b = createAddress32(cm->start + ei->start_pc); ht_snprintf(buffer2, sizeof buffer2, "[%d] try { // %s", i, buffer); addComment(b, 0, buffer2); delete b; b = createAddress32(cm->start + ei->end_pc); ht_snprintf(buffer2, sizeof buffer2, "[%d] } // %s", i, buffer); addComment(b, 0, buffer2); delete b; b = createAddress32(cm->start + ei->handler_pc); ht_snprintf(buffer2, sizeof buffer2, "[%d] %s:", i, buffer); addComment(b, 0, buffer2); pushAddress(b, b); delete b; } }); } setLocationTreeOptimizeThreshold(1000); setSymbolTreeOptimizeThreshold(1000); Analyser::beginAnalysis(); } /* * */ ObjectID ClassAnalyser::getObjectID() const { return ATOM_CLASS_ANALYSER; } /* * */ uint ClassAnalyser::bufPtr(Address *Addr, byte *buf, int size) { FileOfs ofs = addressToFileofs(Addr); assert(ofs != INVALID_FILE_OFS); file->seek(ofs); return file->read(buf, size); } /* * */ Address *ClassAnalyser::createAddress() { return new AddressFlat32(0); } /* * */ Address *ClassAnalyser::createAddress32(ClassAddress addr) { return new AddressFlat32(uint32(addr)); } /* * */ Assembler *ClassAnalyser::createAssembler() { return NULL; } /* * */ FileOfs ClassAnalyser::addressToFileofs(Address *Addr) { if (validAddress(Addr, scinitialized)) { return ((AddressFlat32*)Addr)->addr; } else { return INVALID_FILE_OFS; } } /* * */ const char *ClassAnalyser::getSegmentNameByAddress(Address *Addr) { static char sectionname[1]; Location *loc = getFunctionByAddress(Addr); if (loc && loc->label && loc->label->name) { return loc->label->name; } else { sectionname[0] = 0; return sectionname; } } /* * */ String &ClassAnalyser::getName(String &res) { return file->getDesc(res); } /* * */ const char *ClassAnalyser::getType() { return "Java-Class/Analyser"; } /* * */ void ClassAnalyser::initCodeAnalyser() { Analyser::initCodeAnalyser(); } int class_token_func(char *result, int maxlen, uint32 token, void *context) { return token_translate(result, maxlen, token, (ht_class_shared_data *)context); } /* * */ void ClassAnalyser::initUnasm() { DPRINTF("class_analy: "); analy_disasm = new AnalyJavaDisassembler(); ((AnalyJavaDisassembler*)analy_disasm)->init(this, class_token_func, class_shared); } /* * */ void ClassAnalyser::log(const char *msg) { /* * log() creates to much traffic so dont log * perhaps we reactivate this later * */ /* LOG(msg);*/ } /* * */ Address *ClassAnalyser::nextValid(Address *Addr) { return (Address *)class_shared->valid->findNext(Addr); } /* * */ int ClassAnalyser::queryConfig(int mode) { switch (mode) { case Q_DO_ANALYSIS: case Q_ENGAGE_CODE_ANALYSER: case Q_ENGAGE_DATA_ANALYSER: return true; default: return 0; } } void ClassAnalyser::reinit(ht_class_shared_data *cl_shared, File *f) { class_shared = cl_shared; file = f; if (disasm->getObjectID() == ATOM_DISASM_JAVA) { ((javadis *)disasm)->initialize(class_token_func, class_shared); } } /* * */ Address *ClassAnalyser::fileofsToAddress(FileOfs fileaddr) { Address *a = createAddress32(fileaddr); if (validAddress(a, scvalid)) { return a; } else { delete a; return NULL; } } /* * */ bool ClassAnalyser::validAddress(Address *Addr, tsectype action) { if (!Addr->isValid() || !class_shared->valid->contains(Addr)) return false; switch (action) { case scinitialized: case sccode: return class_shared->initialized->contains(Addr); default: return true; } } ht-2.0.22/analyser/analy_il.cc0000644000175000001440000000312310615342706013045 00000000000000/* * HT Editor * analy_il.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "analy_il.h" #include "analy_register.h" #include "ildis.h" #include "htiobox.h" #include "snprintf.h" void AnalyILDisassembler::init(Analyser *A, char* (*string_func)(uint32 string_ofs, void *context), char* (*token_func)(uint32 token, void *context), void *context) { disasm = new ILDisassembler(string_func, token_func, context); AnalyDisassembler::init(A); } ObjectID AnalyILDisassembler::getObjectID() const { return ATOM_ANALY_IL; } /* * */ Address *AnalyILDisassembler::branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine) { return new InvalidAddress(); } Address *AnalyILDisassembler::createAddress(uint32 offset) { return new AddressFlat32(offset); } /* * */ void AnalyILDisassembler::examineOpcode(OPCODE *opcode) { } /* * */ branch_enum_t AnalyILDisassembler::isBranch(OPCODE *opcode) { return br_nobranch; } ht-2.0.22/analyser/analy_ppc.cc0000644000175000001440000000513610615342707013232 00000000000000/* * HT Editor * analy_ppc.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "analy_ppc.h" #include "analy_register.h" #include "ppcdis.h" #include "htiobox.h" #include "snprintf.h" void AnalyPPCDisassembler::init(Analyser *A, int aMode) { mode = aMode; disasm = new PPCDisassembler((aMode == ANALY_PPC_32) ? PPC_MODE_32 : PPC_MODE_64); AnalyDisassembler::init(A); } void AnalyPPCDisassembler::load(ObjectStream &f) { GET_INT32X(f, mode); AnalyDisassembler::load(f); } /* * */ void AnalyPPCDisassembler::done() { AnalyDisassembler::done(); } ObjectID AnalyPPCDisassembler::getObjectID() const { return ATOM_ANALY_PPC; } /* * */ Address *AnalyPPCDisassembler::branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine) { Address *a; a = createAddress(((ppcdis_insn *)opcode)->op[((ppcdis_insn *)opcode)->ops-1].rel.mem); if (/*examine &&*/ analy->validAddress(a, scvalid)) { return a; } delete a; return new InvalidAddress(); } Address *AnalyPPCDisassembler::createAddress(uint64 offset) { if (mode == ANALY_PPC_32) { return new AddressFlat32(offset); } else { return new AddressFlat64(offset); } } /* * */ void AnalyPPCDisassembler::examineOpcode(OPCODE *opcode) { } /* * */ branch_enum_t AnalyPPCDisassembler::isBranch(OPCODE *opcode) { // FIXME: needs work!! ppcdis_insn *ppc_insn = (ppcdis_insn *) opcode; if (ppc_insn->name[0]=='b') { if (ppc_insn->name[1]=='l') { if (ppc_insn->name[2]==0) { return br_call; } if (ppc_insn->name[2]=='r') { if (ppc_insn->name[3]=='l') { return br_call; } else { return br_return; } } return br_jXX; } if (ppc_insn->name[strlen(ppc_insn->name)] == 'l') { return br_call; } if (ppc_insn->name[1] == 0 || strcmp(ppc_insn->name, "bctr") == 0) { return br_jump; } return br_jXX; } return br_nobranch; } void AnalyPPCDisassembler::store(ObjectStream &f) const { PUT_INT32X(f, mode); AnalyDisassembler::store(f); } ht-2.0.22/analyser/elf_analy.h0000644000175000001440000000403512156417020013046 00000000000000/* * HT Editor * elf_analy.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef elf_analy_h #define elf_analy_h #include "analy.h" #include "htelf.h" //test #include "elfstruc.h" class ElfAnalyser: public Analyser { public: ht_elf_shared_data *elf_shared; File *file; Area *validarea; ElfAnalyser() {}; ElfAnalyser(BuildCtorArg&a): Analyser(a) {}; void init(ht_elf_shared_data *elf_shared, File *File); void load(ObjectStream &f); virtual void done(); virtual ObjectID getObjectID() const; virtual void beginAnalysis(); virtual uint bufPtr(Address *Addr, byte *buf, int size); bool convertAddressToELFAddress(Address *addr, ELFAddress *r); virtual Address *createAddress(); Address *createAddress32(uint32 addr); Address *createAddress64(uint64 addr); virtual Assembler *createAssembler(); virtual String & getName(String &res); virtual const char *getType(); virtual void initCodeAnalyser(); void initInsertSymbols(int shidx); void initInsertFakeSymbols(); virtual void initUnasm(); virtual Address *nextValid(Address *Addr); virtual void store(ObjectStream &f) const; virtual int queryConfig(int mode); virtual bool validAddress(Address *Addr, tsectype action); virtual Address *fileofsToAddress(FileOfs fileofs); virtual FileOfs addressToFileofs(Address *Addr); virtual const char *getSegmentNameByAddress(Address *Addr); }; #endif ht-2.0.22/analyser/Makefile.in0000644000175000017500000003734012127657374013041 00000000000000# Makefile.in generated by automake 1.10.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = analyser DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in TODO ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) ARFLAGS = cru libanalyser_a_AR = $(AR) $(ARFLAGS) libanalyser_a_LIBADD = am_libanalyser_a_OBJECTS = analy.$(OBJEXT) analy_alpha.$(OBJEXT) \ analy_names.$(OBJEXT) analy_x86.$(OBJEXT) code_analy.$(OBJEXT) \ data_analy.$(OBJEXT) language.$(OBJEXT) pe_analy.$(OBJEXT) \ stddata.$(OBJEXT) elf_analy.$(OBJEXT) analy_register.$(OBJEXT) \ coff_analy.$(OBJEXT) analy_java.$(OBJEXT) \ class_analy.$(OBJEXT) ne_analy.$(OBJEXT) analy_il.$(OBJEXT) \ analy_ia64.$(OBJEXT) le_analy.$(OBJEXT) analy_ppc.$(OBJEXT) \ macho_analy.$(OBJEXT) flt_analy.$(OBJEXT) xbe_analy.$(OBJEXT) \ pef_analy.$(OBJEXT) analy_arm.$(OBJEXT) xex_analy.$(OBJEXT) libanalyser_a_OBJECTS = $(am_libanalyser_a_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libanalyser_a_SOURCES) DIST_SOURCES = $(libanalyser_a_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GREP = @GREP@ HT_LDFLAGS = @HT_LDFLAGS@ HT_LIBS = @HT_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ IO_DIR = @IO_DIR@ LDFLAGS = @LDFLAGS@ LEX = @LEX@ LEXLIB = @LEXLIB@ LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ LZO_LIBS = @LZO_LIBS@ MAKE = @MAKE@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ VERSION = @VERSION@ YACC = @YACC@ YFLAGS = @YFLAGS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ curses_CPPFLAGS = @curses_CPPFLAGS@ curses_LIBS = @curses_LIBS@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ ncurses_config = @ncurses_config@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = foreign AM_CPPFLAGS = ${my_CPPFLAGS} -I$(top_srcdir) -I$(top_srcdir)/asm \ -I$(top_srcdir)/io/@IO_DIR@ -I$(top_srcdir)/io \ -I$(top_srcdir)/output -I$(top_srcdir)/eval AM_CFLAGS = ${my_CFLAGS} AM_CXXFLAGS = ${my_CXXFLAGS} noinst_LIBRARIES = libanalyser.a libanalyser_a_SOURCES = analy.cc analy.h analy_alpha.cc analy_alpha.h \ analy_names.cc analy_names.h analy_x86.cc analy_x86.h analyinfo.h \ code_analy.cc code_analy.h data_analy.cc data_analy.h \ language.cc language.h pe_analy.cc pe_analy.h stddata.cc stddata.h \ elf_analy.cc elf_analy.h analy_register.cc analy_register.h \ coff_analy.cc coff_analy.h analy_java.cc analy_java.h \ class_analy.cc class_analy.h ne_analy.cc ne_analy.h \ analy_il.cc analy_il.h analy_ia64.cc analy_ia64.h le_analy.cc le_analy.h \ analy_ppc.cc analy_ppc.h macho_analy.cc macho_analy.h flt_analy.cc flt_analy.h \ xbe_analy.cc xbe_analy.h pef_analy.cc pef_analy.h analy_arm.cc analy_arm.h \ xex_analy.cc xex_analy.h all: all-am .SUFFIXES: .SUFFIXES: .cc .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign analyser/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign analyser/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libanalyser.a: $(libanalyser_a_OBJECTS) $(libanalyser_a_DEPENDENCIES) -rm -f libanalyser.a $(libanalyser_a_AR) libanalyser.a $(libanalyser_a_OBJECTS) $(libanalyser_a_LIBADD) $(RANLIB) libanalyser.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/analy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/analy_alpha.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/analy_arm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/analy_ia64.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/analy_il.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/analy_java.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/analy_names.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/analy_ppc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/analy_register.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/analy_x86.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/class_analy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/code_analy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff_analy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/data_analy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf_analy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flt_analy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/language.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/le_analy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/macho_analy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ne_analy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pe_analy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pef_analy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stddata.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xbe_analy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xex_analy.Po@am__quote@ .cc.o: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cc.obj: @am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: ht-2.0.22/analyser/TODO0000644000175000001440000000076707507606624011461 00000000000000This is file TODO from the HT-Analyser version 0.6.0 ********************* ** Analyser TODOs: ** ********************* _____________________________________________________________________________ simple todos: --- more interactive functions! --- mz_analyser, le_analyser _____________________________________________________________________________ advanced todos: --- jmp/call tables (will be done in near future) --- the code_analyser (only stub) --- the data_analyser (almost only stub) ht-2.0.22/analyser/xbe_analy.cc0000644000175000001440000002660510615342710013224 00000000000000/* * HT Editor * xbe_analy.cc * * Copyright (C) 2003 Stefan Esser * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "analy.h" #include "analy_alpha.h" #include "analy_ia64.h" #include "analy_il.h" #include "analy_names.h" #include "analy_register.h" #include "analy_ppc.h" #include "analy_x86.h" #include "htctrl.h" #include "htdebug.h" #include "htiobox.h" #include "htxbeimp.h" #include "htxbe.h" #include "strtools.h" #include "ilopc.h" #include "xbe_analy.h" #include "xbestruct.h" #include "snprintf.h" #include "x86asm.h" /* * */ void XBEAnalyser::init(ht_xbe_shared_data *XBE_shared, File *File) { xbe_shared = XBE_shared; file = File; validarea = new Area(); validarea->init(); Analyser::init(); } /* * */ void XBEAnalyser::load(ObjectStream &f) { GET_OBJECT(f, validarea); Analyser::load(f); } /* * */ void XBEAnalyser::done() { validarea->done(); delete validarea; Analyser::done(); } /* * */ void XBEAnalyser::beginAnalysis() { char buffer[1024]; setLocationTreeOptimizeThreshold(100); setSymbolTreeOptimizeThreshold(100); /* * entrypoint */ Address *entry; entry = createAddress32(xbe_shared->header.entry_point); pushAddress(entry, entry); /* * give all sections a descriptive comment: */ XBE_SECTION_HEADER *s=xbe_shared->sections.sections; char blub[100]; for (uint i=0; isections.number_of_sections; i++) { Address *secaddr; secaddr = createAddress32(s->virtual_address); ht_snprintf(blub, sizeof blub, "; TEST section %d <%s>", i+1, getSegmentNameByAddress(secaddr)); addComment(secaddr, 0, ""); addComment(secaddr, 0, ";******************************************************************"); addComment(secaddr, 0, blub); ht_snprintf(blub, sizeof blub, "; virtual address %08x virtual size %08x", s->virtual_address, s->virtual_size); addComment(secaddr, 0, blub); ht_snprintf(blub, sizeof blub, "; file offset %08x file size %08x", s->raw_address, s->raw_size); addComment(secaddr, 0, blub); addComment(secaddr, 0, ";******************************************************************"); // mark end of sections ht_snprintf(blub, sizeof blub, "; end of section <%s>", getSegmentNameByAddress(secaddr)); Address *secend_addr = secaddr->clone(); secend_addr->add(MAX(s->virtual_size, s->raw_size)); newLocation(secend_addr)->flags |= AF_FUNCTION_END; addComment(secend_addr, 0, ""); addComment(secend_addr, 0, ";******************************************************************"); addComment(secend_addr, 0, blub); addComment(secend_addr, 0, ";******************************************************************"); validarea->add(secaddr, secend_addr); Address *seciniaddr = secaddr->clone(); seciniaddr->add(MIN(s->virtual_size, s->raw_size)); if (validAddress(secaddr, scinitialized) && validAddress(seciniaddr, scinitialized)) { initialized->add(secaddr, seciniaddr); } s++; delete secaddr; delete secend_addr; delete seciniaddr; } int import_count=xbe_shared->imports.funcs->count(); int *entropy = random_permutation(import_count); for (int i = 0; i < import_count; i++) { ht_xbe_import_function *f=(ht_xbe_import_function *) (*xbe_shared->imports.funcs)[entropy[i]]; // ht_pe_import_library *d=(ht_pe_import_library *)(*pe_shared->imports.libs)[f->libidx]; char *label; label = import_func_name("NTOSKRNL.EXE", (f->byname) ? f->name.name : NULL, f->ordinal); Address *faddr; faddr = createAddress32(f->address+xbe_shared->header.base_address); addComment(faddr, 0, ""); if (!assignSymbol(faddr, label, label_func)) { // multiple import of a function (duplicate labelname) // -> mangle name a bit more addComment(faddr, 0, "; duplicate import"); ht_snprintf(buffer, sizeof buffer, "%s_%x", label, f->address); assignSymbol(faddr, buffer, label_func); } data->setIntAddressType(faddr, dst_idword, 4); free(label); delete faddr; } if (entropy) free(entropy); addComment(entry, 0, ""); addComment(entry, 0, ";****************************"); addComment(entry, 0, "; program entry point"); addComment(entry, 0, ";****************************"); assignSymbol(entry, "entrypoint", label_func); setLocationTreeOptimizeThreshold(1000); setSymbolTreeOptimizeThreshold(1000); delete entry; Address *tls; tls = createAddress32(xbe_shared->header.tls_address+xbe_shared->header.base_address+0); assignSymbol(tls, "tls.data_start_address", label_data); free(tls); tls = createAddress32(xbe_shared->header.tls_address+xbe_shared->header.base_address+4); assignSymbol(tls, "tls.data_end_address", label_data); free(tls); tls = createAddress32(xbe_shared->header.tls_address+xbe_shared->header.base_address+8); assignSymbol(tls, "tls.index_address", label_data); free(tls); tls = createAddress32(xbe_shared->header.tls_address+xbe_shared->header.base_address+12); assignSymbol(tls, "tls.callback_address", label_data); free(tls); tls = createAddress32(xbe_shared->header.tls_address+xbe_shared->header.base_address+16); assignSymbol(tls, "tls.size_of_zero_fill", label_data); free(tls); tls = createAddress32(xbe_shared->header.tls_address+xbe_shared->header.base_address+20); assignSymbol(tls, "tls.characteristics", label_data); free(tls); Analyser::beginAnalysis(); } /* * */ ObjectID XBEAnalyser::getObjectID() const { return ATOM_XBE_ANALYSER; } /* * */ uint XBEAnalyser::bufPtr(Address *Addr, byte *buf, int size) { FileOfs ofs = addressToFileofs(Addr); /* if (ofs == INVALID_FILE_OFS) { int as=0; }*/ assert(ofs != INVALID_FILE_OFS); file->seek(ofs); return file->read(buf, size); } bool XBEAnalyser::convertAddressToRVA(Address *addr, RVA *r) { ObjectID oid = addr->getObjectID(); if (oid==ATOM_ADDRESS_FLAT_32) { *r = ((AddressFlat32*)addr)->addr - xbe_shared->header.base_address; return true; } else if (oid == ATOM_ADDRESS_X86_FLAT_32) { *r = ((AddressX86Flat32*)addr)->addr - xbe_shared->header.base_address; return true; } // *r = ((AddressFlat32*)addr)->addr - xbe_shared->header.base_address; // *r = ((AddressX86Flat32*)addr)->addr - xbe_shared->header.base_address; return false; } /* * */ Address *XBEAnalyser::createAddress32(uint32 addr) { return new AddressX86Flat32(addr); // return new AddressFlat32(addr); } /* * */ Address *XBEAnalyser::createAddress64(uint64 addr) { return NULL; } Address *XBEAnalyser::createAddress() { return new AddressX86Flat32(); // return new AddressFlat32(); } /* * */ Assembler *XBEAnalyser::createAssembler() { Assembler *a = new x86asm(X86_OPSIZE32, X86_ADDRSIZE32); a->init(); return a; } /* * */ FileOfs XBEAnalyser::addressToFileofs(Address *Addr) { /* char tbuf[1024]; Addr->stringify(tbuf, 1024, 0); printf("ADDR=%s", tbuf);*/ if (validAddress(Addr, scinitialized)) { // printf(" v1\n"); FileOfs ofs; RVA r; if (!convertAddressToRVA(Addr, &r)) return INVALID_FILE_OFS; if (!xbe_rva_to_ofs(&xbe_shared->sections, r, &ofs)) return INVALID_FILE_OFS; return ofs; } else { // printf(" IV1\n"); return INVALID_FILE_OFS; } } /* * */ const char *XBEAnalyser::getSegmentNameByAddress(Address *Addr) { static char sectionname[9]; xbe_section_headers *sections=&xbe_shared->sections; int i; RVA r; bool b; // Addr-=pe_shared->pe32.header_nt.image_base; if (!convertAddressToRVA(Addr, &r)) return NULL; // { FILE *f;f=fopen("/tmp/rva","a+");if (f){fprintf(f,"rva: %08x\n",r);fclose(f);} } xbe_rva_to_section(sections, r, &i); // XBE_SECTION_HEADER *s=sections->sections+i; b = xbe_rva_is_valid(sections, r); // { FILE *f;f=fopen("/tmp/rva","a+");if (f){fprintf(f,"rva: %08x %u\n",r,(uint)b);fclose(f);} } if (!b) return NULL; strcpy(sectionname, ""); return sectionname; } /* * */ String &XBEAnalyser::getName(String &res) { return file->getDesc(res); } /* * */ const char *XBEAnalyser::getType() { return "XBE/Analyser"; } /* * */ void XBEAnalyser::initCodeAnalyser() { Analyser::initCodeAnalyser(); } /* static char *string_func(uint32 ofs, void *context) { char str[1024]; static char str2[1024]; ht_pe_shared_data *pe = (ht_pe_shared_data*)context; if (ofs < pe->il->string_pool_size) { uint32 length; uint32 o = ILunpackDword(length, (byte*)&pe->il->string_pool[ofs], 10); wide_char_to_multi_byte(str, (byte*)&pe->il->string_pool[ofs+o], length/2+1); escape_special_str(str2, sizeof str2, str, "\""); return str2; } else { return NULL; } } static char *token_func(uint32 token, void *context) { static char tokenstr[1024]; switch (token & IL_META_TOKEN_MASK) { case IL_META_TOKEN_TYPE_REF: case IL_META_TOKEN_TYPE_DEF: { sprintf(tokenstr, "typedef"); break; } case IL_META_TOKEN_FIELD_DEF: { sprintf(tokenstr, "fielddef"); break; } case IL_META_TOKEN_METHOD_DEF: { sprintf(tokenstr, "methoddef"); break; } case IL_META_TOKEN_MEMBER_REF: { sprintf(tokenstr, "memberref"); break; } case IL_META_TOKEN_TYPE_SPEC: { sprintf(tokenstr, "typespec"); break; } default: return NULL; } return tokenstr; } */ /* * */ void XBEAnalyser::initUnasm() { DPRINTF("xbe_analy: "); DPRINTF("initing analy_x86_disassembler\n"); analy_disasm = new AnalyX86Disassembler(); ((AnalyX86Disassembler *)analy_disasm)->init(this, 0); } /* * */ void XBEAnalyser::log(const char *msg) { /* * log() creates to much traffic so dont log * perhaps we reactivate this later * */ /* LOG(msg);*/ } /* * */ Address *XBEAnalyser::nextValid(Address *Addr) { return (Address *)validarea->findNext(Addr); } /* * */ void XBEAnalyser::store(ObjectStream &st) const { /* ht_pe_shared_data *pe_shared; ht_stream *file; area *validarea; */ PUT_OBJECT(st, validarea); Analyser::store(st); } /* * */ int XBEAnalyser::queryConfig(int mode) { switch (mode) { case Q_DO_ANALYSIS: case Q_ENGAGE_CODE_ANALYSER: case Q_ENGAGE_DATA_ANALYSER: return true; default: return 0; } } /* * */ Address *XBEAnalyser::fileofsToAddress(FileOfs fileofs) { RVA r; if (xbe_ofs_to_rva(&xbe_shared->sections, fileofs, &r)) { return createAddress32(r+xbe_shared->header.base_address); } else { return new InvalidAddress(); } } /* * */ bool XBEAnalyser::validAddress(Address *Addr, tsectype action) { xbe_section_headers *sections=&xbe_shared->sections; int sec; RVA r; if (!convertAddressToRVA(Addr, &r)) return false; if (!xbe_rva_to_section(sections, r, &sec)) return false; XBE_SECTION_HEADER *s=sections->sections+sec; switch (action) { case scvalid: return true; case scread: return true; case scwrite: return s->section_flags & XBE_SECTION_FLAGS_WRITABLE; case screadwrite: return s->section_flags & XBE_SECTION_FLAGS_WRITABLE; case sccode: if (!xbe_rva_is_physical(sections, r)) return false; return s->section_flags & XBE_SECTION_FLAGS_EXECUTABLE; case scinitialized: if (!xbe_rva_is_physical(sections, r)) return false; return true; } return false; } ht-2.0.22/analyser/stddata.cc0000644000175000001440000001336010636023333012700 00000000000000/* * HT Editor * stddata.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "analy.h" #include "atom.h" #include "stddata.h" #include "stream.h" #include "tools.h" /* * Area */ void Area::init() { a = NULL; } static void areaload(ObjectStream &st, area_s *&p, int level, int &left) { if (left <= 0) { p = NULL; return; } p = new area_s; if (level <= 1 || left <= 1) { p->start = st.getObject("start"); p->end = st.getObject("end"); p->left = p->right = NULL; left--; } else { areaload(st, p->left, level / 2, left); p->start = st.getObject("start"); p->end = st.getObject("end"); left--; areaload(st, p->right, level / 2 -1, left); } } void Area::load(ObjectStream &st) { int count; GET_INT32D(st, count); areaload(st, a, count, count); } void Area::done() { freeRecursive(a); } ObjectID Area::getObjectID() const { return ATOM_AREA; } static area_s *do_clone(area_s *p) { if (p) { area_s *q = new area_s; q->left = do_clone(p->left); q->right = do_clone(p->right); q->start = p->start->clone(); q->end = p->end->clone(); return q; } else { return NULL; } } Area *Area::clone() const { Area *area = new Area(); area->init(); area->a = do_clone(a); return area; } static area_s *areaget(area_s *p, Object *V) { if (p) { if (V->compareTo(p->start) < 0) return areaget(p->left, V); if (V->compareTo(p->end) >= 0) return areaget(p->right, V); /*if ((V >= (p->start)) && (V < (p->end)))*/ return p; } else return NULL; } area_s *Area::getArea(Object *at) { return areaget(a, at); } static void areaadd(area_s *&p, Object *Start, Object *End) { if (p) { if (Start->compareTo(p->start) >= 0 && Start->compareTo(p->end)<=0) { if (p->end->compareTo(End) < 0) { delete p->end; p->end = End->clone(); } if ((End->compareTo(p->start) >= 0) && (End->compareTo(p->end)<=0)) { if (p->start->compareTo(Start) > 0) { delete p->start; p->start = Start->clone(); } } return; } if (End->compareTo(p->start) >= 0 && End->compareTo(p->end) <= 0) { if (p->start->compareTo(Start) > 0) { delete p->start; p->start = Start->clone(); } return; } if (Start->compareTo(p->end) > 0) areaadd(p->right, Start, End); else areaadd(p->left, Start, End); } else { // new p area_s *tmp = new area_s; p = tmp; p->start = Start->clone(); p->end = End->clone(); p->left = NULL; p->right = NULL; } } void Area::add(Object *Start, Object *End) { areaadd(a, Start, End); } static bool areacontains(area_s *p, Object *V) { if (p) { if (V->compareTo(p->start) < 0) return areacontains(p->left, V); if (V->compareTo(p->end) >= 0) return areacontains(p->right, V); /*if ((V >= (p->start)) && (V < (p->end)))*/ return true; } else return false; } bool Area::contains(Object *v) { if (instanceOf(v)) return false; return areacontains(a, v); } static void areafindnext(area_s *p, Object *from, Object **res) { if (!from || from->compareTo(p->start) < 0) { *res = p->start; if (p->left) areafindnext(p->left, from, res); } else if (from->compareTo(p->end) >= 0) { if (p->right) areafindnext(p->right, from, res); } else *res = from; } Object *Area::findNext(Object *from) { Object *res = NULL; if (a) areafindnext(a, from, &res); return res; } static void areafindprev(area_s *p, Object *from, Object **res) { //FIXME ??: if (p) { if (!from || from->compareTo(p->end) >= 0) { *res = p->end; areafindprev(p->right, from, res); } else if (from->compareTo(p->start) < 0) { areafindprev(p->left, from, res); } else *res = from; }; } Object *Area::findPrev(Object *from) { Object *res = NULL; areafindprev(a, from, &res); return res; } void Area::freeRecursive(area_s *p) { if (p) { freeRecursive(p->left); freeRecursive(p->right); delete p->start; delete p->end; delete p; } } static void areacount(area_s *p, int &c, Object **startend) { if (p) { areacount(p->left, c, startend); if (!*startend || p->start->compareTo(*startend) != 0) c++; *startend = p->end; areacount(p->right, c, startend); } } static void areastore(ObjectStream &f, area_s *p, Object **startend) { if (p) { areastore(f, p->left, startend); if (!*startend) { f.putObject(p->start, "start"); } else { if ((*startend)->compareTo(p->start) != 0) { f.putObject(*startend, "end"); f.putObject(p->start, "start"); } } *startend = p->end; areastore(f, p->right, startend); } } void Area::store(ObjectStream &f) const { int count = 0; Object *start = NULL; areacount(a, count, &start); PUT_INT32D(f, count); start = NULL; areastore(f, a, &start); if (start != NULL) f.putObject(start, "end"); } #ifdef DEBUG_FIXNEW static void areadump(int sp, area_s *A) { if (A) { for (int i=0; istart, A->end); printf(buf); ++sp;++sp; areadump(sp, A->left); areadump(sp, A->right); } } void Area::dump() { areadump(1, a); } #endif BUILDER(ATOM_AREA, Area, Object) bool init_stddata() { REGISTER(ATOM_AREA, Area) return true; } void done_stddata() { UNREGISTER(ATOM_AREA, Area) } ht-2.0.22/analyser/analy_il.h0000644000175000001440000000257510615342706012721 00000000000000/* * HT Editor * analy_il.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ANALY_IL_H #define ANALY_IL_H #include "analy.h" #include "ildis.h" class AnalyILDisassembler: public AnalyDisassembler { public: AnalyILDisassembler() {}; AnalyILDisassembler(BuildCtorArg&a): AnalyDisassembler(a) {}; void init(Analyser *A, char* (*string_func)(uint32 string_ofs, void *context), char* (*token_func)(uint32 token, void *context), void *context); virtual ObjectID getObjectID() const; virtual Address *branchAddr(OPCODE *opcode, branch_enum_t branchtype, bool examine); Address *createAddress(uint32 offset); virtual void examineOpcode(OPCODE *opcode); virtual branch_enum_t isBranch(OPCODE *opcode); }; #endif ht-2.0.22/analyser/analy_names.cc0000644000175000001440000000554110615342707013553 00000000000000/* * HT Editor * analy_names.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "analy_names.h" #include "htdebug.h" #include "strtools.h" #include "language.h" #include "snprintf.h" #include "stdio.h" #include "string.h" #include "tools.h" char *import_func_name(const char *dllname, const char *funcname, int ordinal) { char res[1024]; if (funcname) { ht_snprintf(res, sizeof res, "%s:%s", dllname, funcname); } else { ht_snprintf(res, sizeof res, "%s:%04x", dllname, ordinal); } return ht_strdup(res); } char *export_func_name(const char *funcname, int ordinal) { char res[1024]; if (funcname) { ht_snprintf(res, sizeof res, "exp_%s_%x", funcname, ordinal); } else { ht_snprintf(res, sizeof res, "exp_%x", ordinal); } return ht_strdup(res); } const char *label_types[] = {"unknown", "function", "location ", "data"}; const char *label_types_short[] = {"? ", "func", "loc ", "data"}; const char *label_type(int lt) { assert(lt < 4); return label_types[lt]; } const char *label_type_short(int lt) { assert(lt < 4); return label_types_short[lt]; } const char *xref_types[] = {"read", "write", "offset", "jump", "call", "ijump", "icall"}; const char *xref_types_short = "rwojcJC"; const char *xref_type(int xt) { assert(xt < 7); return xref_types[xt]; } char xref_type_short(int xt) { assert(xt < 7); return xref_types_short[xt]; } bool valid_name(const char *str) { if (!str || !*str) return false; char mc = mapchar[(uint8)*str]; if (mc == '_' || mc == '?' || mc == 'A' || mc == '@') { str++; while (*str) { mc = mapchar[(uint8)*str]; if (mc == '_' || mc == '?' || mc == 'A' || mc == '0' || mc == ':' || mc == '.' || mc == '@') { str++; } else return false; } return true; } else { return false; } } void make_valid_name(char *result, const char *str) { if (!str || !*str) { *result++ = '_'; *result = '\0'; return; } char mc = mapchar[(uint8)*str]; if (!(mc == '_' || mc == '?' || mc == 'A' || mc == '@')) { *result++ = '_'; str++; } while (*str) { mc = mapchar[(uint8)*str]; if (mc == '_' || mc == '?' || mc == 'A' || mc == '0' || mc == ':' || mc == '.' || mc == '@') { *result++ = *str; } else { *result++ = '_'; } str++; } *result = 0; } ht-2.0.22/analyser/analy_names.h0000644000175000001440000000312510615342707013411 00000000000000/* * HT Editor * analy_names.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef ANALY_NAMES_H #define ANALY_NAMES_H char *import_func_name(const char *dllname, const char *funcname, int ordinal); char *export_func_name(const char *funcname, int ordinal); const char *label_type(int lt); const char *label_type_short(int lt); const char *xref_type(int xt); char xref_type_short(int xt); #define LPRFX_LOC "loc" #define LPRFX_SUB "sub" #define LPRFX_STUB "stub" #define LPRFX_WRAP "wrapper" #define LPRFX_OFS "offset" #define LPRFX_DTA "data" #define LPRFX_DTU "?data" #define LPRFX_STR "str" bool valid_name(const char *str); void make_valid_name(char *result, const char *str); /* * generated names */ #define M_PREFIX_DUP ' ' #define M_PREFIX_DUPs " " #define M_PREFIX_REF '*' #define M_PREFIX_REFs "*" #define M_PREFIX_LABEL 'l' #define M_PREFIX_LABELs "l" #define QUOTED_STRING(s) M_PREFIX_DUPs##s #define REF_STRING(s) M_PREFIX_REFs##s #endif ht-2.0.22/analyser/language.cc0000644000175000001440000001421711141174741013043 00000000000000/* * HT Editor * language.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include #include "htdebug.h" #include "strtools.h" #include "language.h" #include "tools.h" /* * ' ' = separator -> skip * INV = invalid char -> error */ byte mapchar[] = { ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', 10,' ',' ',' ',' ',' ', // 0-15 ' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ',' ', // 16-31 ' ','!','"','#','$','%','&', 39,'(',')','*','+',',','-','.','/', // 32-47 '0','0','0','0','0','0','0','0','0','0',':',';','<','=','>','?', // 48-63 '@','A','A','A','A','A','A','A','A','A','A','A','A','A','A','A', // 64-79 'A','A','A','A','A','A','A','A','A','A','A','[', 92,']','^','_', // 80-95 INV,'A','A','A','A','A','A','A','A','A','A','A','A','A','A','A', // 96-111 'A','A','A','A','A','A','A','A','A','A','A','{','|','}','~',INV, // 112-127 INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV, INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV,INV }; int analy_string__raw_test(const byte *s, int len) { // could be a "" string if (!len) return 1; int all_word_len=0; int bad_chars=0; int words=0; bool word_start=false; for (int i=0; i no string if (bad_chars*10>len) return -1; // no words found if (!words) return len/2-bad_chars*5+1; int average_word_len = all_word_len / words; int av_res[10] = {1, 2, 4, 8, 16, 16, 10, 8, 6, 3}; int av_plus = 0; if (average_word_len > 1 && average_word_len < 12) av_plus = av_res[average_word_len - 2]; return words*2 + av_plus - bad_chars*5 + len/5 + average_word_len; } /* * CLASS analy_string */ void analy_string::init(const byte *s, int Len) { string = ht_malloc(Len); memcpy(string, s, Len); len = Len; } void analy_string::done() { free(string); } int analy_string::length() { return len; } void analy_string::set_len(int Len) { len = Len; } /* * CLASS analy_raw_string */ void analy_raw_string::render_string(char *result, int maxlen) { } int analy_raw_string::string_test(const byte *s, int testlen, int &foundlen) { foundlen = 0; return 0; } const char *analy_raw_string::name() { return "raw"; } /* * CLASS analy_c_string */ void analy_c_string::render_string(char *result, int maxlen) { assert(maxlen); maxlen--; int Len = MIN(len, maxlen); if (Len) Len--; memcpy(result, string, Len); result[Len]=0; } int analy_c_string::string_test(const byte *s, int testlen, int &foundlen) { // search for \0 byte *np = (byte *)memchr(s, 0, testlen); if (!np) return -1; int len = np-s+1; foundlen = len; return analy_string__raw_test(s, len-1); } const char *analy_c_string::name() { return "strz"; } /* * CLASS analy_unicode_string */ void analy_unicode_string::render_string(char *result, int maxlen) { wide_char_to_multi_byte(result, string, maxlen); } int analy_unicode_string::string_test(const byte *s, int testlen, int &foundlen) { // this is not good byte *a = ht_malloc(testlen/2+1); wide_char_to_multi_byte((char*)a, s, testlen/2); // search for \0 byte *np = (byte *)memchr(a, 0, testlen/2); if (!np) { free(a); return -1; } int len = np-a; foundlen = len*2+2; int res = analy_string__raw_test(a, len); free(a); return res; } const char *analy_unicode_string::name() { return "strw"; } /* * CLASS analy_pascal_string */ void analy_pascal_string::render_string(char *result, int maxlen) { assert(maxlen); maxlen--; int Len = MIN(*string, maxlen); if (Len) memcpy(result, string+1, Len); result[Len]=0; } int analy_pascal_string::string_test(const byte *s, int testlen, int &foundlen) { int len = *s; if (len>testlen) return -1; foundlen = len+1; return analy_string__raw_test(s+1, len); } const char *analy_pascal_string::name() { return "strp"; } #define STRING_TESTS 2 analy_string *string_test(const byte *s, int testlen) { if (!testlen) return NULL; int p[STRING_TESTS+1]; int len[STRING_TESTS]; p[0] = analy_c_string::string_test(s, testlen, len[0]); p[1] = analy_unicode_string::string_test(s, testlen, len[1]); // p[2] = analy_pascal_string::string_test(s, testlen, len[2]); p[STRING_TESTS] = 5; int j = STRING_TESTS; for (int i=0; i < STRING_TESTS; i++) { if (p[i] > p[j]) j = i; } analy_string *as = NULL;; switch (j) { case 0: as = new analy_c_string(); break; case 1: as = new analy_unicode_string(); break; /* case 2: as = new analy_pascal_string(); break;*/ default: break; } if (as) { as->init(s, testlen); as->set_len(len[j]); } return as; } ht-2.0.22/analyser/data_analy.cc0000644000175000001440000001053610615342710013353 00000000000000/* * HT Editor * data_analy.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "analy.h" #include "analy_register.h" #include "data_analy.h" #include "io/types.h" #include "snprintf.h" //#undef DPRINTF //#define DPRINTF(msg...) {global_analyser_address_string_format = ADDRESS_STRING_FORMAT_LEADING_ZEROS;char buf[1024]; ht_snprintf(buf, sizeof buf, ##msg); fprintf(stdout, buf);} #define DPRINTF(msg...) void analyser_put_addrtype(ObjectStream &f, const taddr_type *at) { byte t = (taddr_typetype)at->type; f.putInt(t, 1, "type"); switch (t) { case dt_unknown: break; case dt_code: f.putInt(at->code_subtype, 1, "type"); break; case dt_unknown_data: break; case dt_int: f.putInt(at->int_subtype, 1, "type"); f.putInt(at->length, 1, "length"); break; case dt_float: f.putInt(at->float_subtype, 1, "type"); f.putInt(at->length, 1, "length"); break; case dt_array: f.putInt(at->array_subtype, 1, "type"); f.putInt(at->length, 1, "length"); break; } } void analyser_get_addrtype(ObjectStream &f, taddr_type *at) { at->type = (taddr_typetype)f.getInt(1, "type"); at->length = 0; switch (at->type) { case dt_unknown: break; case dt_code: at->code_subtype = (taddr_code_subtype)f.getInt(1, "type"); break; case dt_unknown_data: break; case dt_int: at->int_subtype = (taddr_int_subtype)f.getInt(1, "type"); at->length = f.getInt(1, "length"); break; case dt_float: at->float_subtype = (taddr_float_subtype)f.getInt(1, "type"); at->length = f.getInt(1, "length"); break; case dt_array: at->array_subtype = (taddr_array_subtype)f.getInt(1, "type"); at->length = f.getInt(1, "length"); break; } } DataAnalyser::DataAnalyser() { } void DataAnalyser::init(Analyser *Analy) { analy = Analy; } void DataAnalyser::load(ObjectStream &f) { } void DataAnalyser::done() { } ObjectID DataAnalyser::getObjectID() const { return ATOM_DATA_ANALYSER; } void DataAnalyser::access(Address *Addr, OP op, int size) { } void DataAnalyser::setAddressType(Address *Addr, taddr_typetype type, int subtype, int length) { setAddressType(analy->newLocation(Addr), type, subtype, length); } void DataAnalyser::setAddressType(Location *Addr, taddr_typetype type, int subtype, int length) { DPRINTF("Addr %y set to %d (%d) length %d\n", Addr->addr, type, subtype, length); Addr->type.type = type; Addr->type.subtype = subtype; Addr->type.length = length; } void DataAnalyser::setCodeAddressType(Address *Addr, taddr_code_subtype subtype) { setAddressType(analy->newLocation(Addr), dt_code, subtype, 0); } void DataAnalyser::setCodeAddressType(Location *Addr, taddr_code_subtype subtype) { setAddressType(Addr, dt_code, subtype, 0); } void DataAnalyser::setIntAddressType(Address *Addr, taddr_int_subtype subtype, int length) { setAddressType(analy->newLocation(Addr), dt_int, subtype, length); } void DataAnalyser::setIntAddressType(Location *Addr, taddr_int_subtype subtype, int length) { setAddressType(Addr, dt_int, subtype, length); } void DataAnalyser::setFloatAddressType(Address *Addr, taddr_float_subtype subtype, int length) { setAddressType(analy->newLocation(Addr), dt_float, subtype, length); } void DataAnalyser::setFloatAddressType(Location *Addr, taddr_float_subtype subtype, int length) { setAddressType(Addr, dt_float, subtype, length); } void DataAnalyser::setArrayAddressType(Address *Addr, taddr_array_subtype subtype, int length) { setAddressType(analy->newLocation(Addr), dt_array, subtype, length); } void DataAnalyser::setArrayAddressType(Location *Addr, taddr_array_subtype subtype, int length) { setAddressType(Addr, dt_array, subtype, length); } void DataAnalyser::store(ObjectStream &f) const { } ht-2.0.22/analyser/pef_analy.cc0000644000175000001440000003347710615342710013225 00000000000000/* * HT Editor * pef_analy.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "analy.h" #include "analy_names.h" #include "analy_ppc.h" #include "analy_register.h" #include "pef_analy.h" #include "htctrl.h" #include "htdebug.h" #include "htiobox.h" #include "htpef.h" #include "strtools.h" #include "pestruct.h" #include "snprintf.h" #include "x86asm.h" extern "C" { #include "demangle.h" } #include #include #include /* * */ PEFAnalyser::PEFAnalyser() { } void PEFAnalyser::init(ht_pef_shared_data *Pef_shared, File *File) { pef_shared = Pef_shared; file = File; validarea = new Area(); validarea->init(); Analyser::init(); } void PEFAnalyser::beginAnalysis() { // Address *entry = NULL; // entry = createAddress32(pef_shared->header32.e_entry); setLocationTreeOptimizeThreshold(100); setSymbolTreeOptimizeThreshold(100); /* * entrypoint */ // pushAddress(entry, entry); /* * give all sections a descriptive comment: */ PEF_SECTION_HEADER *s32=pef_shared->sheaders.sheaders; char blub[100]; for (uint i=0; i < pef_shared->sheaders.count; i++) { Address *secaddr; secaddr = createAddress32(s32->defaultAddress); if (validAddress(secaddr, scvalid)) { ht_snprintf(blub, sizeof blub, "; section %d <%s>", i, getSegmentNameByAddress(secaddr)); addComment(secaddr, 0, ""); addComment(secaddr, 0, ";******************************************************************"); addComment(secaddr, 0, blub); ht_snprintf(blub, sizeof blub, "; virtual address %08x virtual size %08x", s32->defaultAddress, s32->totalSize); addComment(secaddr, 0, blub); ht_snprintf(blub, sizeof blub, "; file offset %08x file size %08x", s32->containerOffset, s32->packedSize); addComment(secaddr, 0, blub); addComment(secaddr, 0, ";******************************************************************"); // mark end of sections ht_snprintf(blub, sizeof blub, "; end of section <%s>", getSegmentNameByAddress(secaddr)); Address *secend_addr = secaddr->clone(); secend_addr->add(s32->totalSize); newLocation(secend_addr)->flags |= AF_FUNCTION_END; addComment(secend_addr, 0, ""); addComment(secend_addr, 0, ";******************************************************************"); addComment(secend_addr, 0, blub); addComment(secend_addr, 0, ";******************************************************************"); validarea->add(secaddr, secend_addr); delete secend_addr; } delete secaddr; s32++; } /* symbols */ /* for (uint i=1; isheaders.count; i++) { if ((pef_shared->sheaders.sheaders32[i].sh_type==PEF_SHT_SYMTAB) || (pef_shared->sheaders.sheaders32[i].sh_type==PEF_SHT_DYNSYM)) { initInsertSymbols(i); } }*/ /* assignSymbol(entry, "entrypoint", label_func); addComment(entry, 0, ""); addComment(entry, 0, ";****************************"); addComment(entry, 0, "; executable entry point"); addComment(entry, 0, ";****************************");*/ setLocationTreeOptimizeThreshold(1000); setSymbolTreeOptimizeThreshold(1000); // delete entry; Analyser::beginAnalysis(); } /* * */ void PEFAnalyser::initInsertSymbols(int shidx) { /* char pef_buffer[1024]; if (pef_shared->ident.e_ident[PEF_EI_CLASS] == PEFCLASS32) { FileOfs h=pef_shared->sheaders.sheaders32[shidx].sh_offset; FileOfs sto=pef_shared->sheaders.sheaders32[pef_shared->sheaders.sheaders32[shidx].sh_link].sh_offset; uint symnum=pef_shared->sheaders.sheaders32[shidx].sh_size / sizeof (PEF_SYMBOL32); int *entropy = random_permutation(symnum); for (uint i=0; iseek(h+entropy[i]*sizeof (PEF_SYMBOL32)); file->read(&sym, sizeof sym); createHostStruct(&sym, PEF_SYMBOL32_struct, pef_shared->byte_order); file->seek(sto+sym.st_name); char *name = fgetstrz(*file); if (!name) continue; switch (sym.st_shndx) { case PEF_SHN_UNDEF: break; case PEF_SHN_ABS: break; case PEF_SHN_COMMON: break; default: { // sym.st_shndx break; } } char *bind; switch (PEF32_ST_BIND(sym.st_info)) { case PEF_STB_LOCAL: bind="local"; break; case PEF_STB_GLOBAL: bind="global"; break; case PEF_STB_WEAK: bind="weak"; break; default: bind="?"; break; } switch (PEF32_ST_TYPE(sym.st_info)) { case PEF_STT_NOTYPE: case PEF_STT_FUNC: { char *label = name; if (!getSymbolByName(label)) { Address *address = createAddress32(sym.st_value); if (validAddress(address, scvalid)) { char *demangled = cplus_demangle(label, DMGL_PARAMS | DMGL_ANSI); make_valid_name(label, label); ht_snprintf(pef_buffer, sizeof pef_buffer, "; function %s (%s)", (demangled) ? demangled : label, bind); if (demangled) free(demangled); addComment(address, 0, ""); addComment(address, 0, ";********************************************************"); addComment(address, 0, pef_buffer); addComment(address, 0, ";********************************************************"); pushAddress(address, address); assignSymbol(address, label, label_func); } delete address; } break; } case PEF_STT_OBJECT: { char *label = name; if (!getSymbolByName(label)) { Address *address = createAddress32(sym.st_value); if (validAddress(address, scvalid)) { char *demangled = cplus_demangle(label, DMGL_PARAMS | DMGL_ANSI); make_valid_name(label, label); ht_snprintf(pef_buffer, sizeof pef_buffer, "; data object %s, size %d (%s)", (demangled) ? demangled : label, sym.st_size, bind); if (demangled) free(demangled); addComment(address, 0, ""); addComment(address, 0, ";********************************************************"); addComment(address, 0, pef_buffer); addComment(address, 0, ";********************************************************"); assignSymbol(address, label, label_data); } delete address; } break; } case PEF_STT_SECTION: case PEF_STT_FILE: break; } free(name); } if (entropy) free(entropy); } else { // FIXME: 64 bit FileOfs h=pef_shared->sheaders.sheaders64[shidx].sh_offset.lo; FileOfs sto=pef_shared->sheaders.sheaders64[pef_shared->sheaders.sheaders64[shidx].sh_link].sh_offset.lo; uint symnum=pef_shared->sheaders.sheaders64[shidx].sh_size.lo / sizeof (PEF_SYMBOL64); int *entropy = random_permutation(symnum); for (uint i=0; iseek(h+entropy[i]*sizeof (PEF_SYMBOL64)); file->read(&sym, sizeof sym); createHostStruct(&sym, PEF_SYMBOL64_struct, pef_shared->byte_order); file->seek(sto+sym.st_name); char *name = fgetstrz(file); if (!name) continue; switch (sym.st_shndx) { case PEF_SHN_UNDEF: break; case PEF_SHN_ABS: break; case PEF_SHN_COMMON: break; default: { // sym.st_shndx break; } } char *bind; switch (PEF64_ST_BIND(sym.st_info)) { case PEF_STB_LOCAL: bind="local"; break; case PEF_STB_GLOBAL: bind="global"; break; case PEF_STB_WEAK: bind="weak"; break; default: bind="?"; break; } switch (PEF64_ST_TYPE(sym.st_info)) { case PEF_STT_NOTYPE: case PEF_STT_FUNC: { char *label = name; if (!getSymbolByName(label)) { Address *address = createAddress64(sym.st_value); char *demangled = cplus_demangle(label, DMGL_PARAMS | DMGL_ANSI); make_valid_name(label, label); ht_snprintf(pef_buffer, sizeof pef_buffer, "; function %s (%s)", (demangled) ? demangled : label, bind); if (demangled) free(demangled); addComment(address, 0, ""); addComment(address, 0, ";********************************************************"); addComment(address, 0, pef_buffer); addComment(address, 0, ";********************************************************"); pushAddress(address, address); assignSymbol(address, label, label_func); delete address; } break; } case PEF_STT_OBJECT: { char *label = name; if (!getSymbolByName(label)) { Address *address = createAddress64(sym.st_value); char *demangled = cplus_demangle(label, DMGL_PARAMS | DMGL_ANSI); make_valid_name(label, label); ht_snprintf(pef_buffer, sizeof pef_buffer, "; data object %s, size %d (%s)", (demangled) ? demangled : label, sym.st_size.lo, bind); if (demangled) free(demangled); addComment(address, 0, ""); addComment(address, 0, ";********************************************************"); addComment(address, 0, pef_buffer); addComment(address, 0, ";********************************************************"); assignSymbol(address, label, label_data); delete address; } break; } case PEF_STT_SECTION: case PEF_STT_FILE: break; } free(name); } if (entropy) free(entropy); }*/ } /* * */ void PEFAnalyser::load(ObjectStream &f) { GET_OBJECT(f, validarea); return Analyser::load(f); } /* * */ void PEFAnalyser::done() { validarea->done(); delete validarea; Analyser::done(); } ObjectID PEFAnalyser::getObjectID() const { return ATOM_PEF_ANALYSER; } /* * */ uint PEFAnalyser::bufPtr(Address *Addr, byte *buf, int size) { FileOfs ofs = addressToFileofs(Addr); /* if (ofs == INVALID_FILE_OFS) { int as = 1; }*/ assert(ofs != INVALID_FILE_OFS); file->seek(ofs); return file->read(buf, size);; } bool PEFAnalyser::convertAddressToPEFAddress(Address *addr, PEFAddress *r) { if (addr->getObjectID()==ATOM_ADDRESS_FLAT_32) { r->a32 = ((AddressFlat32*)addr)->addr; return true; } else { return false; } } Address *PEFAnalyser::createAddress() { return new AddressFlat32(); } Address *PEFAnalyser::createAddress32(uint32 addr) { return new AddressFlat32(addr); } Address *PEFAnalyser::createAddress64(uint64 addr) { return new AddressFlat64(addr); } /* * */ Assembler *PEFAnalyser::createAssembler() { return NULL; } /* * */ FileOfs PEFAnalyser::addressToFileofs(Address *Addr) { if (validAddress(Addr, scinitialized)) { uint32 ofs; PEFAddress ea; if (!convertAddressToPEFAddress(Addr, &ea)) return INVALID_FILE_OFS; if (!pef_addr_to_ofs(&pef_shared->sheaders, ea, &ofs)) return INVALID_FILE_OFS; return ofs; } else { return INVALID_FILE_OFS; } } /* * */ const char *PEFAnalyser::getSegmentNameByAddress(Address *Addr) { static char pef_sectionname[33]; pef_section_headers *sections=&pef_shared->sheaders; int i; PEFAddress ea; if (!convertAddressToPEFAddress(Addr, &ea)) return NULL; if (!pef_addr_to_section(sections, ea, &i)) return NULL; if (pef_shared->sheaders.sheaders[i].nameOffset == 0xffffffff) { ht_snprintf(pef_sectionname, sizeof pef_sectionname, "unnamed%d", i); } else { // ht_strlcpy(pef_sectionname, pef_shared->shnames[i], 32); strcpy(pef_sectionname, "nyi"); } return pef_sectionname; } /* * */ String &PEFAnalyser::getName(String &res) { return file->getDesc(res); } /* * */ const char *PEFAnalyser::getType() { return "PEF/Analyser"; } /* * */ void PEFAnalyser::initCodeAnalyser() { Analyser::initCodeAnalyser(); } /* * */ void PEFAnalyser::initUnasm() { DPRINTF("pef_analy: "); switch (pef_shared->arch) { case PEFARCH_PowerPC: DPRINTF("initing analy_ppc_disassembler\n"); analy_disasm = new AnalyPPCDisassembler(); ((AnalyPPCDisassembler*)analy_disasm)->init(this, ANALY_PPC_32); break; case PEFARCH_M68K: DPRINTF("no disassembler for machine 'm68k'\n"); warnbox("No disassembler for machine 'm68k'!"); break; default: break; } } /* * */ void PEFAnalyser::log(const char *msg) { /* * log() does to much traffic so dont log * perhaps we reactivate this later * */ /* LOG(msg);*/ } /* * */ Address *PEFAnalyser::nextValid(Address *Addr) { return (Address *)validarea->findNext(Addr); } /* * */ void PEFAnalyser::store(ObjectStream &f) const { PUT_OBJECT(f, validarea); Analyser::store(f); } /* * */ int PEFAnalyser::queryConfig(int mode) { switch (mode) { case Q_DO_ANALYSIS: case Q_ENGAGE_CODE_ANALYSER: case Q_ENGAGE_DATA_ANALYSER: return true; default: return 0; } } /* * */ Address *PEFAnalyser::fileofsToAddress(FileOfs fileofs) { PEFAddress ea; if (pef_ofs_to_addr(&pef_shared->sheaders, fileofs, &ea)) { return createAddress32(ea.a32); } else { return new InvalidAddress(); } } /* * */ bool PEFAnalyser::validAddress(Address *Addr, tsectype action) { pef_section_headers *sections=&pef_shared->sheaders; int sec; PEFAddress ea; if (!convertAddressToPEFAddress(Addr, &ea)) return false; if (!pef_addr_to_section(sections, ea, &sec)) return false; PEF_SECTION_HEADER *s = sections->sheaders + sec; switch (action) { case scvalid: return true; case scread: return true; case scwrite: case screadwrite: return (s->sectionKind == 1) || (s->sectionKind == 2) || (s->sectionKind == 6); case sccode: return (s->sectionKind == 0); case scinitialized: return (s->sectionKind == 0) || (s->sectionKind == 1) || (s->sectionKind == 3) || (s->sectionKind == 6) /* FIXME: is 6 really initialized ? */; } return false; } ht-2.0.22/htctrl.cc0000644000175000001440000000174611245514241010743 00000000000000/* * HT Editor * htctrl.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "htctrl.h" static char sglobalerror[GLOBAL_ERROR_SIZE]; char *globalerror = sglobalerror; ht_view *app; ht_view *baseview; SystemDisplay *screen; char appname[HT_NAME_MAX+1]; List *virtual_fs_list; Object *project; int some_analyser_active = 0; int num_ops_parsed = 0; ht-2.0.22/htpef.h0000644000175000001440000000500510615341623010405 00000000000000/* * HT Editor * htpef.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTPEF_H__ #define __HTPEF_H__ #include "pefstruc.h" #include "htpefimp.h" #include "formats.h" #include "endianess.h" #include "htformat.h" #define DESC_PEF "pef" #define DESC_PEF_HEADER "pef/header" #define DESC_PEF_IMPORTS "pef/imports" #define DESC_PEF_IMAGE "pef/image" #define ATOM_PEF_ARCH 0x50454600 #define ATOM_PEF_ARCH_STR "50454600" #define ATOM_PEF_SECTION_KIND 0x50454601 #define ATOM_PEF_SECTION_KIND_STR "50454601" #define ATOM_PEF_SHARE_KIND 0x50454602 #define ATOM_PEF_SHARE_KIND_STR "50454602" extern format_viewer_if htpef_if; struct pef_section_headers { uint count; PEF_SECTION_HEADER *sheaders; }; struct ht_pef_shared_data { FileOfs header_ofs; PEF_CONTAINER_HEADER contHeader; Endianess byte_order; pef_section_headers sheaders; PEF_ARCH arch; FileOfs loader_info_header_ofs; // 0 if not loader_info_header PEF_LOADER_INFO_HEADER loader_info_header; ht_pef_import imports; ht_format_viewer *v_header; ht_view *v_imports; ht_format_viewer *v_image; }; /* * ht_pef */ class ht_pef: public ht_format_group { protected: bool loc_enum; /* new */ public: void init(Bounds *b, File *file, format_viewer_if **ifs, ht_format_group *format_group, FileOfs header_ofs); virtual void done(); }; bool pef_phys_and_mem_section(PEF_SECTION_HEADER *s); bool pef_valid_section(PEF_SECTION_HEADER *s); bool pef_addr_to_section(pef_section_headers *section_headers, PEFAddress addr, int *section); bool pef_addr_to_ofs(pef_section_headers *section_headers, PEFAddress addr, uint32 *ofs); bool pef_addr_is_valid(pef_section_headers *section_headers, PEFAddress addr); bool pef_ofs_to_addr(pef_section_headers *section_headers, uint32 ofs, PEFAddress *addr); bool pef_ofs_to_section(pef_section_headers *section_headers, uint32 ofs, uint32 *section); #endif /* !__HTPEF_H__ */ ht-2.0.22/config.h.in0000644000175000017500000000524412127657403011170 00000000000000/* config.h.in. Generated from configure.in by autoheader. */ /* This system provides ncurses.h */ #undef CURSES_HDR /* Define to 1 if you have the `acosh' function. */ #undef HAVE_ACOSH /* Define to 1 if you have the `asinh' function. */ #undef HAVE_ASINH /* Define to 1 if you have the `atanh' function. */ #undef HAVE_ATANH /* Define to 1 if you have the header file. */ #undef HAVE_CURSES_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_LZO1X_H /* Define to 1 if you have the header file. */ #undef HAVE_LZO_LZO1X_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file. */ #undef HAVE_NCURSES_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* This system has Xlib support and we shall use it */ #undef HAVE_TEXTMODE_X11 /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* The size of `char', as computed by sizeof. */ #undef SIZEOF_CHAR /* The size of `int', as computed by sizeof. */ #undef SIZEOF_INT /* The size of `long int', as computed by sizeof. */ #undef SIZEOF_LONG_INT /* The size of `short', as computed by sizeof. */ #undef SIZEOF_SHORT /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Location of io/$IO_DIR/types.h */ #undef SYSTEM_OSAPI_SPECIFIC_TYPES_HDR /* whether to use the included minilzo */ #undef USE_MINILZO /* Version number of package */ #undef VERSION /* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a `char[]'. */ #undef YYTEXT_POINTER /* Define to empty if `const' does not conform to ANSI C. */ #undef const ht-2.0.22/htcoffhd.h0000644000175000001440000000214410206756707011076 00000000000000/* * HT Editor * htcoffhd.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTCOFFHD_H__ #define __HTCOFFHD_H__ #include "httag.h" #include "formats.h" extern ht_mask_ptable coffheader[]; extern ht_mask_ptable coff32header[]; extern ht_mask_ptable coff_section[]; extern int_hash coff_machines[]; extern ht_tag_flags_s coff_characteristics[]; extern ht_tag_flags_s coff_section_characteristics[]; extern format_viewer_if htcoffheader_if; #endif /* !__HTCOFFHD_H__ */ ht-2.0.22/classimg.cc0000644000175000001440000000526710636023333011247 00000000000000/* * HT Editor * classimg.cc * * Copyright (C) 2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "class.h" #include "class_analy.h" #include "classimg.h" #include "formats.h" #include "htanaly.h" #include "htpal.h" #include "log.h" #include "snprintf.h" ht_view *htclassimage_init(Bounds *b, File *file, ht_format_group *group) { ht_class_shared_data *class_shared=(ht_class_shared_data *)group->get_shared_data(); String fn; LOG("%y: JAVA: loading image (starting analyser)...", &file->getFilename(fn)); ClassAnalyser *a = new ClassAnalyser(); a->init(class_shared, file); Bounds c = *b; ht_group *g = new ht_group(); g->init(&c, VO_RESIZE, DESC_JAVA_IMAGE"-g"); AnalyInfoline *head; c.y+=2; c.h-=2; ht_class_aviewer *v = new ht_class_aviewer(); v->init(&c, DESC_JAVA_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, a, class_shared); c.y-=2; c.h=2; head=new AnalyInfoline(); head->init(&c, v, ANALY_STATUS_DEFAULT); v->attachInfoline(head); ht_analy_sub *analy=new ht_analy_sub(); Address *low = a->createAddress32(0); Address *high = (Address*)class_shared->valid->findPrev(NULL); if (!high) { high = a->createAddress32(0); } else { high = high->clone(); high->add(-1); } analy->init(file, v, a, low, high); delete low; delete high; v->analy_sub = analy; v->insertsub(analy); v->sendmsg(msg_complete_init, 0); viewer_pos entrypoint; if (v->string_to_pos("entrypoint", &entrypoint)) { v->goto_pos(entrypoint, false); } g->insert(head); g->insert(v); g->setpalette(palkey_generic_window_default); // class_shared->v_image = v; return g; } format_viewer_if htclassimage_if = { htclassimage_init, 0 }; /* * CLASS ht_class_aviewer */ void ht_class_aviewer::init(Bounds *b, const char *desc, int caps, File *File, ht_format_group *format_group, Analyser *Analy, ht_class_shared_data *Class_shared) { ht_aviewer::init(b, desc, caps, File, format_group, Analy); class_shared = Class_shared; file = File; } void ht_class_aviewer::setAnalyser(Analyser *a) { ((ClassAnalyser *)a)->reinit(class_shared, file); analy = a; analy_sub->setAnalyser(a); } ht-2.0.22/htpeexp.cc0000644000175000001440000002255510771304342011123 00000000000000/* * HT Editor * htpeexp.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "formats.h" #include "htanaly.h" #include "htctrl.h" #include "data.h" #include "htdebug.h" #include "endianess.h" #include "htiobox.h" #include "htnewexe.h" #include "htpal.h" #include "htpe.h" #include "htpeexp.h" #include "strtools.h" #include "httag.h" #include "log.h" #include "pe_analy.h" #include "snprintf.h" #include "stream.h" #include "tools.h" #include #include static ht_view *htpeexports_init(Bounds *b, File *file, ht_format_group *group) { ht_pe_shared_data *pe_shared=(ht_pe_shared_data *)group->get_shared_data(); if (pe_shared->opt_magic!=COFF_OPTMAGIC_PE32) return NULL; uint32 sec_rva, sec_size; sec_rva = pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_EXPORT].address; sec_size = pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_EXPORT].size; if (!sec_rva || !sec_size) return NULL; int h0=new_timer(); start_timer(h0); uint32 *efunct=NULL, *enamet=NULL; uint16 *eordt=NULL; String filename; char *esectionbuf = NULL; char eline[256]; FileOfs ename_ofs; char *ename; bool *lord; String s; ConstMemMapFile *efile = NULL; ht_group *g = NULL; Bounds c; ht_statictext *head; ht_pe_export_viewer *v = NULL; file->getFilename(filename); /* get export directory offset */ /* 1. get export directory rva */ FileOfs eofs; uint32 erva=pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_EXPORT].address; uint32 esize=pe_shared->pe32.header_nt.directory[PE_DIRECTORY_ENTRY_EXPORT].size; /* 2. transform it into an offset */ if (!pe_rva_to_ofs(&pe_shared->sections, erva, &eofs)) goto pe_read_error; LOG("%y: PE: reading export directory at offset 0x%08qx, rva %08x, size %08x...", &filename, eofs, erva, esize); /* make a memfile out of this section */ esectionbuf = ht_malloc(esize); file->seek(eofs); file->readx(esectionbuf, esize); efile = new ConstMemMapFile(esectionbuf, esize, eofs); file = efile; /* read export directory header */ PE_EXPORT_DIRECTORY edir; file->seek(eofs); file->readx(&edir, sizeof edir); createHostStruct(&edir, PE_EXPORT_DIRECTORY_struct, little_endian); /* get export filename */ if (!pe_rva_to_ofs(&pe_shared->sections, edir.name_address, &ename_ofs)) goto pe_read_error; file->seek(ename_ofs); ename = efile->fgetstrz(); /* read in function entrypoint table */ FileOfs efunct_ofs; efunct = ht_malloc(edir.function_count*sizeof *efunct); if (!pe_rva_to_ofs(&pe_shared->sections, edir.function_table_address, &efunct_ofs)) goto pe_read_error; file->seek(efunct_ofs); file->readx(efunct, edir.function_count*sizeof *efunct); for (uint i=0; isections, edir.name_table_address, &enamet_ofs)) goto pe_read_error; file->seek(enamet_ofs); file->readx(enamet, edir.name_count*sizeof *enamet); for (uint i=0; isections, edir.ordinal_table_address, &eordt_ofs)) goto pe_read_error; file->seek(eordt_ofs); file->readx(eordt, edir.name_count*sizeof *eordt); for (uint i=0; iexports.funcs->insert(efd); } free(lord); /* exports by name */ for (uint i=0; i < edir.name_count; i++) { uint o = eordt[i]; RVA f = efunct[o]; FileOfs en; if (!pe_rva_to_ofs(&pe_shared->sections, *(enamet+i), &en)) goto pe_read_error; file->seek(en); efile->readStringz(s); ht_pe_export_function *efd = new ht_pe_export_function(f, o+edir.ordinal_base, s.contentChar()); pe_shared->exports.funcs->insert(efd); } } else { /* exports by ordinal */ for (uint i=0; i < edir.function_count; i++) { RVA f = efunct[i]; ht_pe_export_function *efd = new ht_pe_export_function(f, i+edir.ordinal_base); pe_shared->exports.funcs->insert(efd); } } // sdgfdg c = *b; c.x = 0; c.y = 0; g = new ht_group(); g->init(&c, VO_RESIZE, DESC_PE_EXPORTS"-g"); c.y = 1; c.h--; v = new ht_pe_export_viewer(); v->init(&c, group); c.y = 0; c.h = 1; ht_snprintf(eline, sizeof eline, "* PE export directory at offset %08qx (dllname = %s)", eofs, ename); head = new ht_statictext(); head->init(&c, eline, align_left); g->insert(head); g->insert(v); // for (uint i=0; iexports.funcs->count(); i++) { ht_pe_export_function *e = (ht_pe_export_function *)(*pe_shared->exports.funcs)[i]; char ord[32], addr[32]; ht_snprintf(ord, sizeof ord, "%04x", e->ordinal); ht_snprintf(addr, sizeof addr, "%08x", e->address); v->insert_str(i, ord, addr, e->byname ? e->name : ""); } // v->update(); g->setpalette(palkey_generic_window_default); stop_timer(h0); // LOG("%y: PE: %d ticks (%d msec) to read exports", filename, get_timer_tick(h0), get_timer_msec(h0)); delete_timer(h0); free(ename); free(efunct); free(enamet); free(eordt); pe_shared->v_exports = v; delete efile; free(esectionbuf); return g; pe_read_error: delete_timer(h0); errorbox("%y: PE export directory seems to be corrupted.", &filename); free(efunct); free(enamet); free(eordt); if (g) { g->done(); delete g; } if (v) { v->done(); delete v; } delete efile; free(esectionbuf); return NULL; } format_viewer_if htpeexports_if = { htpeexports_init, NULL }; /* * CLASS ht_pe_export_viewer */ void ht_pe_export_viewer::init(Bounds *b, ht_format_group *fg) { ht_text_listbox::init(b, 3, 2, LISTBOX_QUICKFIND); options |= VO_BROWSABLE; desc = strdup(DESC_PE_EXPORTS); format_group = fg; } void ht_pe_export_viewer::done() { ht_text_listbox::done(); } const char *ht_pe_export_viewer::func(uint i, bool execute) { ht_text_listbox_sort_order sortord; switch (i) { case 2: if (execute) { sortord.col = 0; sortord.compare_func = strcmp; sort(1, &sortord); } return "sortord"; case 4: if (execute) { sortord.col = 1; sortord.compare_func = strcmp; sort(1, &sortord); } return "sortva"; case 5: if (execute) { sortord.col = 2; sortord.compare_func = strcmp; sort(1, &sortord); } return "sortname"; } return NULL; } void ht_pe_export_viewer::handlemsg(htmsg *msg) { switch (msg->msg) { case msg_funcexec: if (func(msg->data1.integer, 1)) { clearmsg(msg); return; } break; case msg_funcquery: { const char *s=func(msg->data1.integer, 0); if (s) { msg->msg=msg_retval; msg->data1.cstr=s; } break; } case msg_keypressed: { if (msg->data1.integer == K_Return) { select_entry(e_cursor); clearmsg(msg); } break; } } ht_text_listbox::handlemsg(msg); } bool ht_pe_export_viewer::select_entry(void *entry) { ht_text_listbox_item *i = (ht_text_listbox_item *)entry; ht_pe_shared_data *pe_shared=(ht_pe_shared_data *)format_group->get_shared_data(); ht_pe_export_function *e = (ht_pe_export_function*)(*pe_shared->exports.funcs)[i->id]; if (!e) return true; if (pe_shared->v_image) { ht_aviewer *av = (ht_aviewer*)pe_shared->v_image; PEAnalyser *a = (PEAnalyser*)av->analy; Address *addr; if (pe_shared->opt_magic == COFF_OPTMAGIC_PE32) { addr = a->createAddress32(e->address+pe_shared->pe32.header_nt.image_base); } else { addr = a->createAddress64(e->address+pe_shared->pe64.header_nt.image_base); } if (av->gotoAddress(addr, NULL)) { app->focus(av); vstate_save(); } else { global_analyser_address_string_format = ADDRESS_STRING_FORMAT_COMPACT | ADDRESS_STRING_FORMAT_ADD_0X; errorbox("can't follow: %s %y is not valid!", "export address", addr); } delete addr; } else errorbox("can't follow: no image viewer"); return true; } /* * class ht_pe_export_function */ ht_pe_export_function::ht_pe_export_function(RVA addr, uint ord) { ordinal = ord; address = addr; byname = false; } ht_pe_export_function::ht_pe_export_function(RVA addr, uint ord, const char *n) { ordinal = ord; name = ht_strdup(n); address = addr; byname = true; } ht_pe_export_function::~ht_pe_export_function() { if (byname) free(name); } ht-2.0.22/htneimp.cc0000644000175000001440000000324310615341623011103 00000000000000/* * HT Editor * htneimp.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "atom.h" #include "endianess.h" #include "htne.h" #include "htneent.h" #include "httag.h" #include "formats.h" #include "snprintf.h" #include static ht_view *htneimports_init(Bounds *b, File *file, ht_format_group *group) { ht_ne_shared_data *ne_shared = (ht_ne_shared_data *)group->get_shared_data(); FileOfs h = ne_shared->hdr_ofs; ht_uformat_viewer *v = new ht_uformat_viewer(); v->init(b, DESC_NE_IMPORTS, VC_EDIT | VC_SEARCH, file, group); ht_mask_sub *m = new ht_mask_sub(); m->init(file, 0); char line[256]; /* secure */ ht_snprintf(line, sizeof line, "* NE imported names and module reference table at offset %08qx / %08qx", h+ne_shared->hdr.imptab, h+ne_shared->hdr.modtab); m->add_mask(line); for (uint i=0; imodnames_count; i++) { ht_snprintf(line, sizeof line, "%0d: %s", i+1, ne_shared->modnames[i]); m->add_mask(line); } v->insertsub(m); return v; } format_viewer_if htneimports_if = { htneimports_init, 0 }; ht-2.0.22/httree.cc0000644000175000017500000002334712127651420010744 00000000000000/* * HT Editor * httree.cc * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "string.h" #include "htdialog.h" #include "htpal.h" #include "keyb.h" #include "strtools.h" #include "httree.h" #include "stream.h" void ht_treeview::init(Bounds *b, const char *d) { ht_view::init(b, VO_SELECTABLE | VO_BROWSABLE/* <- FIXME */ | VO_RESIZE, d); VIEW_DEBUG_NAME("ht_treeview"); growmode = MK_GM(GMH_FIT, GMV_FIT); foc = 0; delta_x = delta_y = 0; maxsize_y = 5; selected = NULL; } void ht_treeview::done() { ht_view::done(); } void ht_treeview::adjust_focus(int Focus) { if (Focus < 0) Focus = 0; else if (Focus >= maxsize_y) Focus = maxsize_y - 1; if (foc != Focus) has_focused(Focus); if (Focus < delta_y) scroll_to(delta_x, Focus); else if ((Focus - size.h) >= delta_y) scroll_to(delta_x, Focus - size.h + 1); } int ht_treeview::create_graph(AbstractChar *s, void *node, int level, int lines, int width, int endwidth, const AbstractChar *Chars) { // Chars: space, vbar, T, last L,hbar,+,-,[,] for (int i=0; i < level; i++) { s[i*width] = (lines&(1<= delta_y) { if (*pos >= (delta_y+size.h)) break; if (is_selected(*pos)) { selected = node; // only for getdata() if (focused) color=foc_color; else color=sel_color; fill(0, *pos-delta_y, size.w, 1, color, ' '); } else color = normal_color; if (get_graph(s, node, level, lines) > delta_x) buf->nprintW(0, *pos-delta_y, color, &s[delta_x], size.w); } (*pos)++; if (has_children(node) && is_expanded(node)) { draw_r(get_child(node, 1), level+1, pos, (get_next_node(node)) ? lines|(1< 1. node */ void *ht_treeview::get_node(int i) { if (i <= 0) return 0; void *Node = get_root(); return get_node_r(Node, &i); } void ht_treeview::handlemsg(htmsg *msg) { ht_view::handlemsg(msg); if (msg->msg==msg_keypressed) { int Foc = foc; switch (msg->data1.integer) { case K_Up: Foc--; break; case K_Down: Foc++; break; case K_Control_Right: if (delta_x < maxsize_x-1) delta_x++; break; case K_Control_Left: if (delta_x > 0) delta_x--; break; case K_PageUp: Foc -= size.h-1; break; case K_PageDown: Foc += size.h-1; break; case K_Control_PageUp: Foc = 0; break; case K_Control_PageDown: Foc = maxsize_y - 1; break; case '+': case K_Right: { void *p = get_node(Foc+1); if (has_children(p)) adjust(p, true); break; } case '-': adjust(get_node(Foc+1), false); break; case K_Left: { void *n = get_node(Foc+1); if (is_expanded(n)) { adjust(n, false); } else { if (Foc) { do { Foc-=count_children(n)+1; n = get_prev_node(n); } while (n); adjust(get_node(Foc+1), false); } } break; } case '*': expand_all(get_node(Foc+1)); break; case '/': collapse_all(get_node(Foc+1)); break; case K_Return: { void *n = get_node(Foc+1); if (has_children(n)) { adjust(n, !is_expanded(n)); } else { select_node(n); } break; } default: return; } update(); adjust_focus(Foc); dirtyview(); clearmsg(msg); } } void ht_treeview::has_focused(int i) { foc = i; } /* * can be overwritten to handle mutiple selections */ bool ht_treeview::is_selected(int i) { return (foc == i); } void ht_treeview::scroll_to(int x, int y) { delta_x = x; delta_y = y; } /* * stub */ void ht_treeview::setdata(ObjectStream &s) { } /* * called whenever a node is being selected * can be overwritten */ void ht_treeview::select_node(void *node) { } void ht_treeview::set_limit(int x, int y) { maxsize_x = x; maxsize_y = y; } void ht_treeview::update_r(void *node, int level, int *pos, int *x) { AbstractChar s[2048]; while (node) { int l = get_graph(s, node, level, 0); if (l > *x) *x = l; (*pos)++; if (has_children(node) && is_expanded(node)) { update_r(get_child(node, 1), level+1, pos, x); } node = get_next_node(node); } } /* * must be called whenever the data of the tree has changed */ void ht_treeview::update() { int count = 0, maxx = 0; update_r(get_root(), 0, &count, &maxx); set_limit(maxx, count); adjust_focus(foc); } /****************************************************************************/ void ht_static_treeview::init(Bounds *b, const char *desc) { ht_treeview::init(b, desc); VIEW_DEBUG_NAME("ht_static_treeview"); root=0; } void ht_static_treeviewdone_r(static_node *node) { while (node) { ht_static_treeviewdone_r(node->child); free(node->text); if (node->data) { node->data->done(); delete node->data; } static_node *temp = node->next; free(node); node = temp; } } void ht_static_treeview::done() { ht_static_treeviewdone_r(root); ht_treeview::done(); } void *ht_static_treeview::add_child(void *node, const char *text, Object *Data) { if (node) { return add_node(&((static_node *)node)->child, text, Data); } else { if (root) { return add_node(&root, text, Data); } else { root=create_node(text, NULL, Data); return root; } } } void *ht_static_treeview::add_node(static_node **node, const char *text, Object *Data) { static_node **p = node; static_node *prev = NULL; if (*p) { while (*p) { prev = *p; p = &(*p)->next; } } *p=create_node(text, prev, Data); return *p; } void ht_static_treeview::adjust(void *node, bool expand) { ((static_node *)node)->expanded = expand; } static_node *ht_static_treeview::create_node(const char *text, static_node *prev, Object *Data) { static_node *node = ht_malloc(sizeof(static_node)); node->text = ht_strdup(text); node->next = NULL; node->prev = prev; node->child = NULL; node->expanded = false; node->data = Data; return node; } void *ht_static_treeview::get_child(void *node, int i) { static_node *p; if (node) { p = ((static_node *)node)->child; } else { p = root; } while (p && (--i)) p = p->next; return p; } void *ht_static_treeview::get_next_node(void *node) { return ((static_node *)node)->next; } void *ht_static_treeview::get_prev_node(void *node) { return ((static_node *)node)->prev; } void *ht_static_treeview::get_root() { return root; } char *ht_static_treeview::get_text(void *node) { return ((static_node *)node)->text; } void *ht_static_treeview::get_cursor_node() { // FIXME: said to be the wrong thing, works however return selected; } void ht_static_treeview::goto_node(void *node) { } bool ht_static_treeview::has_children(void *node) { return (((static_node *)node)->child); } bool ht_static_treeview::is_expanded(void *node) { return (((static_node *)node)->expanded); } void ht_static_treeview::select_node(void *node) { } ht-2.0.22/htctrl.h0000644000175000001440000000212411245514241010574 00000000000000/* * HT Editor * htctrl.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTCTRL_H__ #define __HTCTRL_H__ #include "data.h" #include "htobj.h" #define GLOBAL_ERROR_SIZE 1024 extern char *globalerror; extern ht_view *app; extern ht_view *baseview; extern SystemDisplay *screen; extern List *virtual_fs_list; extern Object *project; extern char appname[HT_NAME_MAX+1]; extern int some_analyser_active; extern int num_ops_parsed; #endif /* __HTCTRL_H__ */ ht-2.0.22/README0000644000175000001440000003146212156423374010022 00000000000000HT Editor ========= This is HT 2.0.22; Have fun... About ===== This program is a file viewer, editor and analyzer for text, binary, and (especially) executable files. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Key bindings ============ * General key bindings Return follow link (if applicable) Backspace undo "follow link" Space/F6 choose view mode Alt+[1-9] select window Alt+0 select window list Ctrl+Left/Right scroll left/right Cursor keys move around Page Up/Down next/prev page Alt+S toggle select Ctrl+Ins/Alt+C copy Shift+Ins/Alt+V insert Ctrl+Del/Alt+D delete Shift+Del/Alt+X cut * Window key bindings Alt+F3/Ctrl+W close window Ctrl+F5 resize/move mode (in resize/move mode only:) Space toggle resize/move mode Cursor keys resize/move window Escape/Return/Ctrl+F5leave resize/move mode * Analyser key bindings c continue code analysis at cursor f follow dword ptr at address n name current address (empty string to delete) x show xrefs (search for xrefs) # edit comments s define a string i define an integer (32bit) h define a halfword (16bit) b define a byte (8bit) Ctrl+A call assembler Ctrl+F goto start of current function (indicated in the 2nd line) Ctrl+L goto previous label Ctrl+T show recursive function references Note: Some keys don't work in HT-posix. Try using Escape instead of Control or something... Authors ======= * Stefan Weyergraf * Sebastian Biallas Features ======== HT contains some very advanced and useful features, which you should carefully inspect: General features ================ 1. Supported file formats * common object file format (COFF/XCOFF32) - header - image with code/data analyser (x86) * executable and linkable format (ELF) - header - section headers - program headers - symbol tables - image with code/data analyser (x86, AMD64, IA-64, Alpha, PowerPC, ARM) and relocations * linear executables (LE) - header - VxD descriptor - object table - page table - image with code/data analyser (x86) - auto-relocation layer (only internal refs for now) * standard dos executables (MZ) - header - relocations - image (disassembly only) * new executables (NE) - header - segments - names - entrypoints - image with code/data analyser (x86) - auto-relocation layer (pretty complete) * portable executables (PE32, PE64) - header - import section - delay-import section - export section - resources - image with code/data analyser (x86, AMD64, PowerPC, IA-64, Alpha, ARM) - preliminary support for .net executables * java class files (CLASS) - header - image with code/data analyser (java bytecode disassembler) * Mach exe/link format (MachO) - header - image with code/data analyser (x86, AMD64, PowerPC, ARM) * X-Box executable (XBE) - header - imports - image with code/data analyser (x86) * Flat (FLT) - header - image with data analyser (no disassembler yet) * PowerPC executable format (PEF) - header - imports - image with code/data analyser (PowerPC) * Still some to be implemented (M$-OBJ, ARCH, LX) 2. Code & Data Analyser - finds branch sources and destinations recursively - finds procedure entries - creates labels based on this information - creates xref information - allows to interactively analyse unexplored code (press 'c') - allows to create/rename/delete labels (press 'n') - allows to create/edit comments (press '#') 3. Target systems - DJGPP - GNU/Linux - FreeBSD - Win32 Configuration files =================== Global configuration -------------------- HT automatically creates a file to store its configuration. It is called '~/.htcfg2' on Unices and 'ht.cfg2' (where ht.exe resides) on Windows. More specifically it contains HT's registry and the *Note Global history::. Per file configuration ---------------------- The analyser (for analysable files) will be stored in an extra file called 'FILENAME.htcfg', where FILENAME is the analysed file. This file contains all information to restore the complete state of the analyser. Clipboard ========= All open files and dialogs use the common clipboard, where all copied and cut text or binary data is stored. Clipboard operations are normally binary safe, that means you can copy some binary data out of a file and paste it into an input line. Exceptions are only the \0 character (binary null), it will be converted to a space in places where it would not make sense (e.g. file open). Although the clipboard won't be saved between different HT sessions (ie. you will loose it when exiting HT), you can either save and load it or part of it manually (via Edit->paste into/copy from file) or rely on the input lines' *Note history: Global history, which is stored and retrieved from the config file automatically. Global history ============== HTs history system is global, which means that you can use it for all open files. Histories are also grouped by their context. I.e. file-related and regex-search-related dialogs have their own history (who would want to open "[0-9][0-9a-z]+" anyway?). History entries are stored within the *Note Configuration files::, so they can be reused when you relaunch. You can delete a history entry by pressing DEL inside the history popup. Expression evaluation ===================== HT contains a very powerful expression evaluator which is used in all dialogs where expressions are expected. These are mainly blockoperation, goto, search and of course evaluate itself (Edit->Evaluate). You can use all standard math operators (+ - / * % **), logical operators (! && || ^^), relational operators (== != < > <= >=), bit operators (~ & | ^), string operators (. for concatenation), parenthesis, the ternary operator (a?b:c), functions and symbols (both depending on context). The evaluator uses integer, string and float types depending on context. You can always convert a result via the 'int()', 'string()' and 'float()' functions to appropriate type. Try Edit->Evaluate to see how it works... Functions and symbols --------------------- You can always use the standard built-in math ('round', 'sin', 'random', etc.) and string ('strcmp', 'strchr', 'sprintf', etc.) functions, they work more or less like the corresponding C functions (actually they ARE more or less wrappers for them); see 'eval/eval.y' for details (sorry but a detailed help would get outdated rather soon). The symbol _ always refers to the last result. If you are in a hex buffer, the variable 'first' contains the offset of the first byte and the variable 'last' contains the offset of the last byte. This is useful, for instace, if you want to jump to the last byte of a file. If you are in a hex buffer, the variable 'first' contains the offset of the first byte and the variable 'last' contains the offset of the last byte. This is useful, for instance, if you want to jump to the last byte of a file. When using *Note Block operations::, or searching you have some context depending functions and symbols; see these sections for explanation. Block operations ================ Block operation (Blockop) is a very powerful tool to perform modifications on binary files. It is available in hex viewer only. Blockop takes four parameters: START, END, MODE and EXPRESSION. Blockop works as follows: * START: Start at the offset specified by START * REPEAT: Evaluate EXPRESSION and store n bytes (1 - byte, 2 - word, 4 - dword, variable - string) at the current offset. Increment current offset by n. Stop if END has been reached. Special variables/functions that can be used in EXPRESSION: 'readbyte(ofs)' read a byte from offset OFS, returns a number 'readstring(ofs, size)' read SIZE bytes from offset OFS, returns a string 'i' contains the iteration count/index starting with 0 Search and its different modes ============================== The search function is one of the most advanced functions of HT. It is invoked through F7, Shift-F7 continues a search from cursor. Depending on context (ie. file type and mode) the following modes are enabled: bin: ASCII / Hex ---------------- Enter an exact search string either via ascii characters or via hexadecimal interpretation. This is the fastest search mode. You may specify a case-insensitive search. bin: eval str ------------- Enter an expression, it will be evaluated ONCE (difference to the 4th mode), and HT will then search for the result-string. This is pretty useful when searching for intermixed text and control-chars/binary, e.g. '"hello world\n\0"' display: regex -------------- As the prefix indicates, this search doesn't search in the binary file but in the display on screen. HT searches for a regular expression so this can be very powerful, e.g. in PE/Image you can search for '(add|sub).+?,\ [78]$'. This will find all add or sub instructions with second parameter 7 or 8. expr nonzero ------------ This is the slowest but also most advanced search mode. Enter an expression and the search stops if this expression evaluates to non-zero (it will be evaluated on every byte). In this mode there are two predefined symbols and some functions: I is always the number of current iteration and O stands for the current offset in file. With the functions 'readbyte(ofs)' and 'readstring(ofs, size)' you access the file's content. It's easier to understand this with examples: 1. Searching for patterns: a. Enter 'readbyte(o) == readbyte(o+1)' This will search for two equal bytes ("AA", "55", "!!", etc.). b. Enter '(readbyte(o) == readbyte(o+1)-1) && (readbyte(o)==readbyte(o+2)-2)' This will search for three ascending bytes ("ABC", "123", etc). 2. Search with special functions: With HT you can easily detect the RSA key in the 'ADVAPI32.DLL': Search for 'entropy(readstring(o, 64)) > 82' in expr!=0 mode, and you will find it very quickly. How does it work? 'readstring(o, 64)' reads a 64 byte string from current offset and entropy calculates the entropy ("randomness") of a string (result is 0..100). So the search stops if a entropy greater than 82% (guessed value) is encountered, which normally indicates packed or encryted data. Note: the 'entropy()' function is not the best of its kind, if you know of a better one please let us know! Command line options ==================== '--' treat all additional parameters as file names '-v' '--version' show version and copyright on console '-h' '--help' show help '-t' '--text' load file(s) in text editor mode '-b' '--bin' load file(s) in hex editor mode '-a' '--auto' try to guess file type Where to download? ================== The HT homepage is located at Downloads are available from the 'download' section. Please also take a look at ht-2.0.22/htcoffimg.h0000644000175000001440000000231210615341616011245 00000000000000/* * HT Editor * htcoffimg.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTCOFFIMG_H__ #define __HTCOFFIMG_H__ #include "formats.h" #include "htanaly.h" #include "htcoff.h" extern format_viewer_if htcoffimage_if; /* * CLASS ht_coff_aviewer */ class ht_coff_aviewer: public ht_aviewer { public: ht_coff_shared_data *coff_shared; File *file; void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Analyser *analyser, ht_coff_shared_data *coff_shared); virtual void setAnalyser(Analyser *a); }; #endif /* !__HTCOFFIMG_H__ */ ht-2.0.22/htelfrel.cc0000644000175000017500000002032112127651417011251 00000000000000/* * HT Editor * htelfrel.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "elfstruc.h" #include "atom.h" #include "htelf.h" #include "htelfrel.h" #include "httag.h" #include "formats.h" #include "snprintf.h" #include static int_hash elf_r_386_type[] = { {ELF_R_386_NONE, "ELF_R_386_NONE"}, {ELF_R_386_32, "ELF_R_386_32"}, {ELF_R_386_PC32, "ELF_R_386_PC32"}, {ELF_R_386_GOT32, "ELF_R_386_GOT32"}, {ELF_R_386_PLT32, "ELF_R_386_PLT32"}, {ELF_R_386_COPY, "ELF_R_386_COPY"}, {ELF_R_386_GLOB_DAT, "ELF_R_386_GLOB_DAT"}, {ELF_R_386_JMP_SLOT, "ELF_R_386_JMP_SLOT"}, {ELF_R_386_RELATIVE, "ELF_R_386_RELATIVE"}, {ELF_R_386_GOTOFF, "ELF_R_386_GOTOFF"}, {ELF_R_386_GOTPC, "ELF_R_386_GOTPC"}, {0, 0} }; static int_hash elf_r_x86_64_type[] = { {ELF_R_X86_64_NONE, "ELF_R_X86_64_NONE"}, {ELF_R_X86_64_64, "ELF_R_X86_64_64"}, {ELF_R_X86_64_PC32, "ELF_R_X86_64_PC32"}, {ELF_R_X86_64_GOT32, "ELF_R_X86_64_GOT32"}, {ELF_R_X86_64_PLT32, "ELF_R_X86_64_PLT32"}, {ELF_R_X86_64_COPY, "ELF_R_X86_64_COPY"}, {ELF_R_X86_64_GLOB_DAT, "ELF_R_X86_64_GLOB_DAT"}, {ELF_R_X86_64_JUMP_SLOT, "ELF_R_X86_64_JUMP_SLOT"}, {ELF_R_X86_64_RELATIVE, "ELF_R_X86_64_RELATIVE"}, {ELF_R_X86_64_GOTPCREL, "ELF_R_X86_64_GOTPCREL"}, {ELF_R_X86_64_32, "ELF_R_X86_64_32"}, {ELF_R_X86_64_32S, "ELF_R_X86_64_32S"}, {ELF_R_X86_64_16, "ELF_R_X86_64_16"}, {ELF_R_X86_64_PC16, "ELF_R_X86_64_PC16"}, {ELF_R_X86_64_8, "ELF_R_X86_64_8"}, {ELF_R_X86_64_PC8, "ELF_R_X86_64_PC8"}, {0, 0} }; static ht_view *htelfreloctable_init(Bounds *b, File *file, ht_format_group *group) { ht_elf_shared_data *elf_shared=(ht_elf_shared_data *)group->get_shared_data(); if (elf_shared->ident.e_ident[ELF_EI_CLASS] == ELFCLASS32) { if (elf_shared->header32.e_machine != ELF_EM_386) return NULL; } else if (elf_shared->ident.e_ident[ELF_EI_CLASS] == ELFCLASS64) { if (elf_shared->header32.e_machine != ELF_EM_X86_64) return NULL; } else { return NULL; } if ( elf_shared->ident.e_ident[ELF_EI_DATA] != ELFDATA2LSB) return NULL; bool elf32 = elf_shared->ident.e_ident[ELF_EI_CLASS] == ELFCLASS32; uint skip = elf_shared->reloctables; uint reloctab_shidx = ELF_SHN_UNDEF; uint reloctab_sh_type = ELF_SHT_NULL; for (uint i=1; isheaders.count; i++) { reloctab_sh_type = elf32 ? elf_shared->sheaders.sheaders32[i].sh_type : elf_shared->sheaders.sheaders64[i].sh_type; if ((reloctab_sh_type == ELF_SHT_REL) || (reloctab_sh_type==ELF_SHT_RELA)) { if (!skip--) { reloctab_shidx=i; break; } } } if (!isValidELFSectionIdx(elf_shared, reloctab_shidx)) return NULL; FileOfs h; /* section index of associated symbol table */ int si_symbol; /* section index of section to be relocated */ int si_dest; String reloctab_name("?"); int rel_size; int rela_size; uint relnum; if (elf32) { h = elf_shared->sheaders.sheaders32[reloctab_shidx].sh_offset; si_symbol = elf_shared->sheaders.sheaders32[reloctab_shidx].sh_link; si_dest = elf_shared->sheaders.sheaders32[reloctab_shidx].sh_info; if (isValidELFSectionIdx(elf_shared, elf_shared->header32.e_shstrndx)) { file->seek(elf_shared->sheaders.sheaders32[elf_shared->header32.e_shstrndx].sh_offset + elf_shared->sheaders.sheaders32[reloctab_shidx].sh_name); file->readStringz(reloctab_name); } rel_size = sizeof (ELF_REL32); rela_size = sizeof (ELF_RELA32); relnum = elf_shared->sheaders.sheaders32[reloctab_shidx].sh_size / (reloctab_sh_type == ELF_SHT_REL ? rel_size : rela_size); } else { h = elf_shared->sheaders.sheaders64[reloctab_shidx].sh_offset; si_symbol = elf_shared->sheaders.sheaders64[reloctab_shidx].sh_link; si_dest = elf_shared->sheaders.sheaders64[reloctab_shidx].sh_info; if (isValidELFSectionIdx(elf_shared, elf_shared->header64.e_shstrndx)) { file->seek(elf_shared->sheaders.sheaders64[elf_shared->header64.e_shstrndx].sh_offset + elf_shared->sheaders.sheaders64[reloctab_shidx].sh_name); file->readStringz(reloctab_name); } rel_size = sizeof (ELF_REL64); rela_size = sizeof (ELF_RELA64); relnum = elf_shared->sheaders.sheaders64[reloctab_shidx].sh_size / (reloctab_sh_type == ELF_SHT_REL ? rel_size : rela_size); } char desc[128]; ht_snprintf(desc, sizeof desc, DESC_ELF_RELOCTAB, &reloctab_name, reloctab_shidx); ht_uformat_viewer *v = new ht_uformat_viewer(); v->init(b, desc, VC_EDIT, file, group); ht_mask_sub *m = new ht_mask_sub(); m->init(file, 0); registerAtom(ATOM_ELF_R_386_TYPE, elf_r_386_type); registerAtom(ATOM_ELF_R_X86_64_TYPE, elf_r_x86_64_type); char t[256]; ht_snprintf(t, sizeof t, "* ELF relocation table at offset %08qx, relocates section %d, symtab %d", h, si_dest, si_symbol); m->add_mask(t); bool elf_bigendian = (elf_shared->ident.e_ident[ELF_EI_DATA] == ELFDATA2MSB); tag_endian endianness = elf_bigendian ? tag_endian_big : tag_endian_little; #define tt_end sizeof t - (tt-t) switch (reloctab_sh_type) { case ELF_SHT_REL: { if (elf32) { m->add_mask("destofs symidx type"); } else { m->add_mask("destofs symidx type"); } for (uint i=0; iadd_mask(t); } break; } case ELF_SHT_RELA: { if (elf32) { m->add_mask("destofs symidx addend type"); } else { m->add_mask("destofs symidx addend type"); } for (uint i=0; iadd_mask(t); } break; } } v->insertsub(m); return v; } format_viewer_if htelfreloctable_if = { htelfreloctable_init, 0 }; ht-2.0.22/htdisasm.cc0000644000175000001440000003134710620204005011245 00000000000000/* * HT Editor * htdisasm.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "cmds.h" #include "htctrl.h" #include "htdisasm.h" #include "hthist.h" #include "htiobox.h" #include "htmenu.h" #include "httag.h" #include "snprintf.h" #include "x86asm.h" #include "x86dis.h" #include "ppcdis.h" extern "C" { #include "evalx.h" #include "regex.h" } ht_view *htdisasm_init(Bounds *b, File *file, ht_format_group *group) { int t1632; #if 1 Assembler *assembler=new x86asm(X86_OPSIZE32, X86_ADDRSIZE32); x86dis *disassembler=new x86dis(X86_OPSIZE32, X86_ADDRSIZE32); #else Assembler *assembler = NULL; Disassembler *disassembler = new PPCDisassembler(PPC_MODE_32); #endif t1632 = 0; ht_disasm_viewer *v=new ht_disasm_viewer(); v->init(b, DESC_DISASM, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, assembler, disassembler, t1632); ht_disasm_sub *d=new ht_disasm_sub(); d->init(file, 0, file->getSize(), disassembler, false, X86DIS_STYLE_OPTIMIZE_ADDR); v->insertsub(d); return v; } format_viewer_if htdisasm_if = { htdisasm_init, 0 }; /* * dialog_assemble */ static int opcode_compare(const char *a, const char *b) { int al = strlen(a); int bl = strlen(b); if (al > bl) return 1; else if (al < bl) return -1; else return strcmp(a, b); } void dialog_assemble(ht_format_viewer *f, viewer_pos vaddr, CPU_ADDR cpuaddr, Assembler *a, Disassembler *disasm, const char *default_str, int want_length) { char instr[257] = ""; if (default_str) strcpy(instr, default_str); asm_insn *insn = a->alloc_insn(); asm_code *ac = NULL; while (inputbox(a->get_name(), "~instruction:", instr, 255, HISTATOM_ASSEMBLER)) { if ((a->translate_str(insn, instr)) && (ac = a->encode(insn, 0, cpuaddr))) { break; } else { errorbox("%s: %s", a->get_name(), a->get_error_msg()); } } if (ac) { bool ok=true; asm_code *chosen_ac = ac; if (ac->next) { // choose from list if ambigous Bounds b; b.w = 60; b.h = 15; center_bounds(&b); ht_dialog *dialog = new ht_dialog(); dialog->init(&b, "choose opcode", FS_KILLER | FS_TITLE | FS_MOVE); b.assign(1, 0, 56, 1); ht_listbox_title *text = new ht_listbox_title(); text->init(&b); text->setText(2, "opcode", "disassembly"); dialog->insert(text); b.assign(1, 1, 56, 12); ht_text_listbox *list=new ht_text_listbox(); list->init(&b, 2, 0); list->attachTitle(text); asm_code *ac2 = ac; uint aci = 0; int best = 0; while (ac2) { char s[1024], *tmp = s; for (int i=0; i < ac2->size; i++) { tmp += sprintf(tmp, "%02x ", ac2->data[i]); } if (best == 0 && want_length == ac2->size) { best = aci+1; } const char *tmp2; if (disasm) { dis_insn *o=disasm->decode((byte *)ac2->data, ac2->size, cpuaddr); tmp2 = disasm->strf(o, DIS_STYLE_HEX_NOZEROPAD+DIS_STYLE_HEX_ASMSTYLE, DISASM_STRF_SMALL_FORMAT); } else { tmp2 = ""; } list->insert_str(aci, s, tmp2); ac2 = ac2->next; aci++; } ht_text_listbox_sort_order so; so.col = 0; so.compare_func = opcode_compare; list->update(); if (best) { list->gotoItemByPosition(best-1); } list->sort(1, &so); if (!best) { list->gotoItemByPosition(0); } dialog->insert(list); int r = dialog->run(0); ok = r; if (r == button_ok) { ht_listbox_data d; ViewDataBuf vdb(list, &d, sizeof d); ht_text_listbox_item *i = (ht_text_listbox_item *)d.data->cursor_ptr; asm_code *ac3 = ac; int ac3i = 0; while (ac3) { if (ac3i == i->id) { chosen_ac = ac3; break; } ac3 = ac3->next; ac3i++; } } dialog->done(); delete dialog; } if (ok) { baseview->sendmsg(cmd_edit_mode_i, f->get_file(), NULL); if (f->get_file() && (f->get_file()->getAccessMode() & IOAM_WRITE)) { f->vwrite(vaddr, chosen_ac->data, chosen_ac->size); } } } free(insn); } /* * CLASS ht_disasm_viewer */ void ht_disasm_viewer::init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Assembler *a, Disassembler *d, int t) { ht_uformat_viewer::init(b, desc, caps, file, format_group); assem = a; disasm = d; op1632 = t; } void ht_disasm_viewer::done() { ht_uformat_viewer::done(); delete assem; delete disasm; } int ht_disasm_viewer::get_pindicator_str(char *buf, int max_len) { FileOfs o; if (get_current_offset(&o)) { return ht_snprintf(buf, max_len, " %s 0x%08qx/%qu ", edit() ? "edit" : "view", o, o); } else { return ht_snprintf(buf, max_len, " ? "); } } bool ht_disasm_viewer::get_vscrollbar_pos(int *pstart, int *psize) { FileOfs s=file->getSize(); if (s) { int z = MIN(size.h*16, s-(int)top.line_id.id1); return scrollbar_pos(top.line_id.id1, z, s, pstart, psize); } return false; } void ht_disasm_viewer::handlemsg(htmsg *msg) { switch (msg->msg) { case msg_contextmenuquery: { ht_static_context_menu *m=new ht_static_context_menu(); m->init("~Local-Disasm"); m->insert_entry("~Assemble", "Ctrl+A", cmd_disasm_call_assembler, K_Control_A, 1); // FIXME: wrong implementation m->insert_entry("~Toggle 16/32", NULL, cmd_disasm_toggle1632, 0, 1); msg->msg = msg_retval; msg->data1.ptr = m; return; } case msg_get_scrollinfo: { switch (msg->data1.integer) { case gsi_hscrollbar: { gsi_scrollbar_t *p=(gsi_scrollbar_t*)msg->data2.ptr; if (!get_hscrollbar_pos(&p->pstart, &p->psize)) { p->pstart = 0; p->psize = 100; } clearmsg(msg); return; } case gsi_vscrollbar: { gsi_scrollbar_t *p=(gsi_scrollbar_t*)msg->data2.ptr; if (!get_vscrollbar_pos(&p->pstart, &p->psize)) { p->pstart = 0; p->psize = 100; } clearmsg(msg); return; } } break; } case msg_filesize_changed: { htmsg m; m.msg=msg_filesize_changed; m.type=mt_broadcast; sendsubmsg(&m); // FIXME: hack uf_initialized=false; complete_init(); dirtyview(); return; } case cmd_disasm_call_assembler: { viewer_pos current_pos; get_current_pos(¤t_pos); CPU_ADDR cpuaddr; cpuaddr.addr32.seg = 0; cpuaddr.addr32.offset = current_pos.u.line_id.id1; assem->set_imm_eval_proc(NULL, NULL); byte data[32]; int datalen = vread(current_pos, data, sizeof data); dis_insn *o = disasm->decode(data, datalen, cpuaddr); const char *curinsn = disasm->strf(o, DIS_STYLE_HEX_NOZEROPAD+DIS_STYLE_HEX_ASMSTYLE, DISASM_STRF_SMALL_FORMAT); int want_length = disasm->getSize(o); dialog_assemble(this, current_pos, cpuaddr, assem, disasm, curinsn, want_length); clearmsg(msg); return; } case cmd_disasm_toggle1632: { // FIXME: very beautiful... op1632 ^= 1; if (op1632) { ((x86asm *)assem)->opsize = X86_OPSIZE16; ((x86asm *)assem)->addrsize = X86_ADDRSIZE16; ((x86dis *)disasm)->opsize = X86_OPSIZE16; ((x86dis *)disasm)->addrsize = X86_ADDRSIZE16; } else { ((x86asm *)assem)->opsize = X86_OPSIZE32; ((x86asm *)assem)->addrsize = X86_ADDRSIZE32; ((x86dis *)disasm)->opsize = X86_OPSIZE32; ((x86dis *)disasm)->addrsize = X86_ADDRSIZE32; } dirtyview(); clearmsg(msg); return; } } ht_uformat_viewer::handlemsg(msg); } ht_disasm_sub *ht_disasm_viewer::get_disasm_sub() { return (ht_disasm_sub*)cursor.sub; } bool ht_disasm_viewer::offset_to_pos(FileOfs ofs, viewer_pos *p) { p->u.sub = get_disasm_sub(); p->u.line_id.id1 = ofs; p->u.line_id.id2 = 0; p->u.tag_idx = 0; return true; } bool ht_disasm_viewer::pos_to_offset(viewer_pos p, FileOfs *ofs) { *ofs = p.u.line_id.id1; return true; } bool ht_disasm_viewer::ref_sel(LINE_ID *id) { return goto_offset(id->id1, true); } bool ht_disasm_viewer::qword_to_pos(uint64 q, viewer_pos *p) { ht_linear_sub *s = get_disasm_sub(); FileOfs ofs = q; clear_viewer_pos(p); p->u.sub = s; p->u.tag_idx = 0; return s->convert_ofs_to_id(ofs, &p->u.line_id); } bool ht_disasm_viewer::symbol_handler(eval_scalar *result, char *name) { if (strcmp(name, "$") == 0) { FileOfs ofs; if (!pos_to_offset(*(viewer_pos*)&cursor, &ofs)) return 0; scalar_create_int_q(result, ofs); return true; } return ht_uformat_viewer::symbol_handler(result, name); } const char *ht_disasm_viewer::func(uint i, bool execute) { switch (i) { // FIXME: wrong implementation case 8: if (execute) sendmsg(cmd_disasm_toggle1632); return op1632 ? (char*)"use32" : (char*)"use16"; } return ht_uformat_viewer::func(i, execute); } /* * CLASS ht_disasm_sub */ void ht_disasm_sub::init(File *f, FileOfs ofs, int size, Disassembler *u, bool own_u, int ds) { ht_linear_sub::init(f, ofs, size); disasm = u; own_disasm = own_u; display_style = ds; } void ht_disasm_sub::done() { if (own_disasm) { delete disasm; } ht_linear_sub::done(); } bool ht_disasm_sub::convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id) { if ((offset >= fofs) && (offset < fofs+fsize)) { line_id->id1=offset; line_id->id2=0; return true; } return false; } bool ht_disasm_sub::convert_id_to_ofs(const LINE_ID line_id, FileOfs *offset) { *offset = line_id.id1; return true; } static char *diasm_addr_sym_func(CPU_ADDR Addr, int *symstrlen, void *context) { ht_disasm_sub *sub = (ht_disasm_sub *) context; static char buf[120]; LINE_ID line_id; sub->first_line_id(&line_id); if (Addr.addr32.offset >= line_id.id1) { sub->last_line_id(&line_id); if (Addr.addr32.offset <= line_id.id1) { char buf2[60]; ht_snprintf(buf2, sizeof buf2, "0x%x", Addr.addr32.offset); char *b = tag_make_ref(buf, sizeof buf-1, Addr.addr32.offset, 0, 0, 0, buf2); *b = 0; if (symstrlen) *symstrlen = b-buf; return buf; } } return NULL; } bool ht_disasm_sub::getline(char *line, int maxlen, const LINE_ID line_id) { if (line_id.id2) return false; uint64 ofs = line_id.id1; byte buf[16]; int c = MIN(16, sint64(fofs+fsize-ofs)); if (c <= 0) return false; file->seek(ofs); c = file->read(buf, c); CPU_ADDR caddr; caddr.addr32.seg = 0; caddr.addr32.offset = ofs; const char *s; char *l = line; if (c) { dis_insn *insn = disasm->decode(buf, c, caddr); addr_sym_func_context = this; addr_sym_func = &diasm_addr_sym_func; s = disasm->str(insn, display_style); addr_sym_func = NULL; c = disasm->getSize(insn); } else { s = "db ?"; c = 0; } l += ht_snprintf(l, maxlen, "%08qx ", ofs); for (int i=0; i<15; i++) { if (iid1 = fofs; } void ht_disasm_sub::last_line_id(LINE_ID *line_id) { clear_line_id(line_id); line_id->id1 = fofs+fsize-1; } int ht_disasm_sub::prev_line_id(LINE_ID *line_id, int n) { if (line_id->id2) return 0; uint32 *ofs=&line_id->id1; int min_length; int max_length; int min_look_ahead; int avg_look_ahead; int addr_align; disasm->getOpcodeMetrics(min_length, max_length, min_look_ahead, avg_look_ahead, addr_align); unsigned char buf[avg_look_ahead*50], *bufp=buf; int offsets[avg_look_ahead*50]; int *of=offsets; int r=n<6 ? 6*avg_look_ahead : n*avg_look_ahead; if (r > (int)sizeof buf) r = sizeof buf; uint32 o=*ofs-r; int c=r, d; int s; if (*ofsfofs+fsize) { c=fofs+fsize-o; } file->seek(o); d=file->read(buf, c); CPU_ADDR caddr; caddr.addr32.seg = 0; caddr.addr32.offset = 0; do { if (d>0) { dis_insn *insn=disasm->decode(bufp, d, caddr); s=disasm->getSize(insn); /* if (s!=4) { insn=disasm->decode(bufp, d, caddr); } assert(s==4);*/ d-=s; } else { s=1; } *(of++)=o; o+=s; bufp+=s; } while (o<=*ofs); if (of-n-1id2) return 0; uint32 *ofs = &line_id->id1; unsigned char buf[15]; int c=0, s; uint z; CPU_ADDR caddr; caddr.addr32.seg = 0; caddr.addr32.offset = 0; while (n--) { z=MIN(15, (uint)(fofs+fsize-*ofs)); file->seek(*ofs); z=file->read(buf, z); if (z) { dis_insn *insn=disasm->decode(buf, z, caddr); s=disasm->getSize(insn); } else { s=1; } if (*ofs+s>fofs+fsize-1) return c; *ofs+=s; c++; } return c; } ht-2.0.22/aclocal.m40000644000175000017500000010235512127657373011014 00000000000000# generated automatically by aclocal 1.10.3 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.10' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.10.3], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.10.3])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 8 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 10 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 13 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.60])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) ]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_PROG_LEX # ----------- # Autoconf leaves LEX=: if lex or flex can't be found. Change that to a # "missing" invocation, for better error output. AC_DEFUN([AM_PROG_LEX], [AC_PREREQ(2.50)dnl AC_REQUIRE([AM_MISSING_HAS_RUN])dnl AC_REQUIRE([AC_PROG_LEX])dnl if test "$LEX" = :; then LEX=${am_missing_run}flex fi]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 3 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo done .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # We grep out `Entering directory' and `Leaving directory' # messages which can occur if `w' ends up in MAKEFLAGS. # In particular we don't look at `^make:' because GNU make might # be invoked under some other name (usually "gmake"), in which # case it prints its new name instead of `make'. if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then am__include=include am__quote= _am_result=GNU fi # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then am__include=.include am__quote="\"" _am_result=BSD fi fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # ------------------------------ # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR ht-2.0.22/textfile.h0000644000175000001440000001310310615341624011122 00000000000000/* * HT Editor * textfile.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __TEXTFILE_H__ #define __TEXTFILE_H__ #include "data.h" #include "stream.h" #include "syntax.h" /* * CLASS ht_textfile */ class ht_textfile: public FileLayer { public: ht_textfile(File *file, bool own_file); /* new */ virtual bool convert_ofs2line(FileOfs o, uint *line, uint *pofs) const =0; virtual bool convert_line2ofs(uint line, uint pofs, FileOfs *o) const =0; virtual void delete_lines(uint line, uint count)=0; virtual void delete_chars(uint line, uint ofs, uint count)=0; virtual bool get_char(uint line, char *ch, uint pos)=0; virtual bool getline(uint line, uint pofs, void *buf, uint buflen, uint *retlen, lexer_state *state)=0; virtual uint getlinelength(uint line) const =0; virtual void insert_lines(uint before, uint count, void **line_ends = NULL, int *lineendlens = NULL)=0; virtual void insert_chars(uint line, uint ofs, void *chars, uint len)=0; virtual bool has_line(uint line)=0; virtual uint linecount() const=0; virtual void set_layered_assume(File *streamfile, bool ownNewLayered, bool changes_applied)=0; virtual void set_lexer(ht_syntax_lexer *lexer)=0; }; /* * CLASS ht_layer_textfile */ class ht_layer_textfile: public ht_textfile { public: ht_layer_textfile(ht_textfile *textfile, bool own_textfile); /* overwritten */ virtual bool convert_ofs2line(FileOfs o, uint *line, uint *pofs) const; virtual bool convert_line2ofs(uint line, uint pofs, FileOfs *o) const; virtual void delete_lines(uint line, uint count); virtual void delete_chars(uint line, uint ofs, uint count); virtual bool get_char(uint line, char *ch, uint pos); virtual bool getline(uint line, uint pofs, void *buf, uint buflen, uint *retlen, lexer_state *state); virtual uint getlinelength(uint line) const; virtual void insert_lines(uint before, uint count, void **line_ends, int *lineendlens); virtual void insert_chars(uint line, uint ofs, void *chars, uint len); virtual bool has_line(uint line); virtual uint linecount() const; virtual void set_layered_assume(File *streamfile, bool ownNewLayered, bool changes_applied); virtual void set_lexer(ht_syntax_lexer *lexer); }; /* * CLASS ht_ltextfile_line */ class ht_ltextfile_line: public Object { public: virtual ~ht_ltextfile_line(); lexer_state instate; struct { FileOfs ofs; uint len; } on_disk; bool is_in_memory; struct { char *data; uint len; } in_memory; FileOfs nofs; byte lineendlen; byte lineend[2]; }; /* * CLASS ht_ltextfile */ class ht_ltextfile: public ht_textfile { protected: FileOfs ofs; Array *lines; Array *orig_lines; ht_syntax_lexer *lexer; uint first_parse_dirty_line; mutable uint first_nofs_dirty_line; bool dirty; void cache_invd(); void cache_flush(); void dirty_nofs(uint line); void dirty_parse(uint line); uint find_linelen_forwd(byte *buf, uint maxbuflen, FileOfs ofs, int *le_len); virtual ht_ltextfile_line *fetch_line(uint line) const; ht_ltextfile_line *fetch_line_nofs_ok(uint line) const; ht_ltextfile_line *fetch_line_into_memory(uint line); uint getlinelength_i(ht_ltextfile_line *e) const; bool is_dirty_nofs(uint line) const; bool is_dirty_parse(uint line) const; byte *match_lineend_forwd(byte *buf, uint buflen, int *le_len); lexer_state next_instate(uint line); FileOfs next_nofs(ht_ltextfile_line *l) const; void split_line(uint a, uint pos, void *line_end, int line_end_len); void update_nofs(uint line) const; void update_parse(uint line); public: void reread(); ht_ltextfile(File *file, bool own_file, ht_syntax_lexer *lexer); virtual ~ht_ltextfile(); /* overwritten (streamfile) */ virtual FileOfs copyAllTo(Stream *stream); virtual void extend(FileOfs newsize); virtual FileOfs getSize() const; virtual void pstat(pstat_t &s) const; virtual uint read(void *buf, uint size); virtual void setLayered(File *newLayered, bool ownNewLayered); virtual void seek(FileOfs offset); virtual FileOfs tell() const; virtual void truncate(FileOfs newsize); virtual int vcntl(uint cmd, va_list vargs); virtual uint write(const void *buf, uint size); /* overwritten (textfile) */ virtual bool convert_ofs2line(FileOfs o, uint *line, uint *pofs) const; virtual bool convert_line2ofs(uint line, uint pofs, FileOfs *o) const; virtual void delete_lines(uint line, uint count); virtual void delete_chars(uint line, uint ofs, uint count); virtual bool get_char(uint line, char *ch, uint pos); virtual bool getline(uint line, uint pofs, void *buf, uint buflen, uint *retlen, lexer_state *state); virtual uint getlinelength(uint line) const; virtual void insert_lines(uint before, uint count, void **line_ends, int *lineendlens); virtual void insert_chars(uint line, uint ofs, void *chars, uint len); virtual bool has_line(uint line); virtual uint linecount() const; virtual void set_layered_assume(File *streamfile, bool ownNewLayered, bool changes_applied); virtual void set_lexer(ht_syntax_lexer *lexer); }; #endif /* __TEXTFILE_H__ */ ht-2.0.22/except.h0000644000175000001440000000564010615344716010602 00000000000000/* * HT Editor * except.h * * Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __EXCEPT_H__ #define __EXCEPT_H__ #include // for IOException #include "data.h" /** * A exception. */ class Exception: public Object { public: /* new */ virtual String & reason(String &result) const; virtual int toString(char *buf, int buflen) const; }; #define MSG_EXCEPTION_MAX_ERRSTR 256 /** * A described exception. */ class MsgException: public Exception { protected: char estr[MSG_EXCEPTION_MAX_ERRSTR]; public: MsgException(const char *errstr); MsgException() {}; /* new */ virtual String &reason(String &result) const; }; /** * A formatted described exception. */ class MsgfException: public MsgException { public: MsgfException(const char *errstr, ...); }; /** * A I/O exception. */ class IOException: public Exception { protected: String errstr; public: int mPosixErrno; IOException(int aPosixErrno); /* new */ virtual String &reason(String &result) const; }; class EOFException: public IOException { public: EOFException(); /* new */ virtual String &reason(String &result) const; }; typedef Exception InternalException; /** * A exception, indicating a not-implemented function. */ class NotImplementedException: public InternalException { protected: String location; public: NotImplementedException(const String &filename, int line_number); /* new */ virtual String &reason(String &result) const; }; /** * A exception, indicating a illegal argument. */ class IllegalArgumentException: public InternalException { protected: String location; public: IllegalArgumentException(const String &filename, int line_number); /* new */ virtual String &reason(String &result) const; }; /** * An index out-of-bounds exception */ class IndexOutOfBoundsException: public InternalException { protected: String location; public: IndexOutOfBoundsException(const String &filename, int line_number); /* new */ virtual String &reason(String &result) const; }; /** * A exception, indicating a illegal type-cast. */ class TypeCastException: public InternalException { protected: String aresult; public: TypeCastException(const String &cast_type, const String &obj_type); /* new */ virtual String &reason(String &result) const; }; #endif /* __EXCEPT_H__ */ ht-2.0.22/htdisasm.h0000644000175000001440000000520210620173115011105 00000000000000/* * HT Editor * htdisasm.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTDISASM_H__ #define __HTDISASM_H__ #include "asm.h" #include "htobj.h" #include "htformat.h" #define DESC_DISASM "disasm/x86" extern format_viewer_if htdisasm_if; void dialog_assemble(ht_format_viewer *f, viewer_pos vaddr, CPU_ADDR cpuaddr, Assembler *a, Disassembler *disasm, const char *default_str, int want_length); /* * CLASS ht_disasm_viewer */ class ht_disasm_sub; class ht_disasm_viewer: public ht_uformat_viewer { protected: Assembler *assem; Disassembler *disasm; int op1632; /* new */ virtual ht_disasm_sub *get_disasm_sub(); public: void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Assembler *a, Disassembler *d, int t); virtual void done(); /* overwritten */ virtual const char *func(uint i, bool execute); virtual int get_pindicator_str(char *buf, int max_len); virtual bool get_vscrollbar_pos(int *pstart, int *psize); virtual void handlemsg(htmsg *msg); virtual bool offset_to_pos(FileOfs ofs, viewer_pos *addr); virtual bool pos_to_offset(viewer_pos addr, FileOfs *ofs); virtual bool qword_to_pos(uint64 q, viewer_pos *pos); virtual bool ref_sel(LINE_ID *id); virtual bool symbol_handler(eval_scalar *result, char *name); }; /* * CLASS ht_disasm_sub */ class ht_disasm_sub: public ht_linear_sub { private: Disassembler *disasm; bool own_disasm; int display_style; public: void init(File *file, FileOfs ofs, int size, Disassembler *disasm, bool own_disasm, int display_style); virtual void done(); /* overwritten */ virtual bool convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id); virtual bool convert_id_to_ofs(const LINE_ID line_id, FileOfs *offset); virtual void first_line_id(LINE_ID *line_id); virtual bool getline(char *line, int maxlen, const LINE_ID line_id); virtual void last_line_id(LINE_ID *line_id); virtual int next_line_id(LINE_ID *line_id, int n); virtual int prev_line_id(LINE_ID *line_id, int n); }; #endif /* !__HTDISASM_H__ */ ht-2.0.22/data.cc0000644000175000001440000015023610615344716010363 00000000000000/* * HT Editor * data.cc * * Copyright (C) 2002 Stefan Weyergraf (stefan@weyergraf.de) * Copyright (C) 2002, 2003 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "atom.h" #include "except.h" #include "data.h" #include "htdebug.h" #include "snprintf.h" #include "stream.h" #include "store.h" int autoCompare(const Object *a, const Object *b) { // FIXME: better use instanceOf // SB: warum auskommentieren? // SW: weil nicht so gute logik // wie gesagt FIXME, aber bin mir unsicher wie genau /* uint ida = a->getObjectID(); uint idb = b->getObjectID(); if (ida != idb) return ida-idb;*/ return a->compareTo(b); } /* * Object */ int Object::compareTo(const Object *obj) const { // int a=1; throw NotImplementedException(HERE); } int Object::toString(char *buf, int buflen) const { ObjectID oid = getObjectID(); unsigned char c[20]; int l = 4; c[0] = (oid >> 24) & 0xff; c[1] = (oid >> 16) & 0xff; c[2] = (oid >> 8) & 0xff; c[3] = oid & 0xff; for (int i = 0; i < 4; i++) { if (c[i] < 32 || c[i] > 127) { c[l] = '\\'; c[l+1] = "0123456789abcdef"[c[i] >> 4]; c[l+2] = "0123456789abcdef"[c[i] & 0xf]; l += 3; } else { c[l] = c[i]; l++; } } c[l] = 0; return ht_snprintf(buf, buflen, "Object-%s", c+4); } Object *Object::clone() const { throw NotImplementedException(HERE); } bool Object::idle() { return false; } void Object::load(ObjectStream &s) { } ObjectID Object::getObjectID() const { return OBJID_OBJECT; } void Object::store(ObjectStream &s) const { } /* * Enumerator */ /*Object *Enumerator::operator [] (int idx) const { ObjHandle h = findByIdx(idx); return (h != invObjHandle) ? get(h) : NULL; }*/ ObjHandle Enumerator::find(const Object *key) const { ObjHandle h = findFirst(); while (h != invObjHandle) { if (compareObjects(get(h), key) == 0) return h; h = findNext(h); } return invObjHandle; } ObjHandle Enumerator::findG(const Object *key) const { ObjHandle h = findFirst(); ObjHandle best = invObjHandle; while (h != invObjHandle) { int c = compareObjects(get(h), key); if (c > 0) { // h is greater than key if (best != invObjHandle) { if (compareObjects(get(h), get(best)) < 0) best = h; } else { best = h; } } h = findNext(h); } return best; } ObjHandle Enumerator::findGE(const Object *key) const { ObjHandle h = findFirst(); ObjHandle best = invObjHandle; while (h != invObjHandle) { int c = compareObjects(get(h), key); if (c == 0) return h; if (c > 0) { // h is greater than key if (best != invObjHandle) { if (compareObjects(get(h), get(best)) < 0) best = h; } else { best = h; } } h = findNext(h); } return best; } ObjHandle Enumerator::findLE(const Object *key) const { ObjHandle h = findFirst(); ObjHandle best = invObjHandle; while (h != invObjHandle) { int c = compareObjects(get(h), key); if (c == 0) return h; if (c < 0) { // h is lower than key if (best != invObjHandle) { if (compareObjects(get(h), get(best)) > 0) best = h; } else { best = h; } } h = findNext(h); } return best; } ObjHandle Enumerator::findL(const Object *key) const { ObjHandle h = findFirst(); ObjHandle best = invObjHandle; while (h != invObjHandle) { int c = compareObjects(get(h), key); if (c < 0) { // h is lower than key if (best != invObjHandle) { if (compareObjects(get(h), get(best)) > 0) best = h; } else { best = h; } } h = findNext(h); } return best; } int Enumerator::toString(char *buf, int buflen) const { ObjHandle h = findFirst(); int n = 0; if (buflen>1) { *buf++ = '('; buflen--; n++; } while ((buflen>0) && h) { Object *d = get(h); int k = d->toString(buf, buflen); buflen -= k; buf += k; n += k; bool comma; if (buflen>1) { *buf++ = ','; buflen--; n++; comma = true; } else comma = false; h = findNext(h); if (!h && comma) { buf--; buflen++; n--; } } if (buflen>1) { *buf++ = ')'; buflen--; n++; } if (buflen>0) *buf++ = 0; return n; } /* * Container */ Container::Container() { hom_objid = OBJID_TEMP; } bool Container::delObj(Object *sig) { return del(find(sig)); } ObjHandle Container::findOrInsert(Object *obj, bool &inserted) { ObjHandle h = find(obj); if (h == invObjHandle) { h = insert(obj); inserted = true; } else { inserted = false; } return h; } void Container::notifyInsertOrSet(const Object *o) { if (!o) return; if (hom_objid == OBJID_TEMP) { hom_objid = o->getObjectID(); } else if (hom_objid != OBJID_INVALID) { if (hom_objid != o->getObjectID()) hom_objid = OBJID_INVALID; } } Object *Container::removeObj(const Object *sig) { return remove(find(sig)); } /* * Array */ #define ARRAY_ALLOC_MIN 4 /* * grow array size by factor (ARRAY_ALLOC_GROW_NUM / ARRAY_ALLOC_GROW_DENOM) * but never by more than ARRAY_ALLOC_GROW_ABSMAX. */ #define ARRAY_ALLOC_GROW_NUM 3 #define ARRAY_ALLOC_GROW_DENOM 2 #define ARRAY_ALLOC_GROW_ABSMAX 64*1024 Array::Array(bool oo, int prealloc) { own_objects = oo; ecount = 0; acount = 0; elems = NULL; realloc(prealloc); } Array::~Array() { delAll(); } void Array::delAll() { // SB: Doppelte ueberpruefung von oo if (elems) { if (own_objects) { for (uint i=0; i end) return 0; if ((uint)end >= ecount) end = ecount - 1; if (own_objects) { uint ende = end; for (uint i = start; i <= ende; i++) { freeObj(elems[i]); } } memmove(elems+start, elems+end+1, sizeof (*elems) * (ecount-end-1)); ecount -= end-start+1; checkShrink(); return end-start+1; } Array *Array::clone() const { Array *a = new Array(own_objects, ecount); for (uint i = 0; iclone(); a->insert(e); } return a; } void Array::load(ObjectStream &s) { own_objects = true; GET_INT32D(s, ecount); acount = 0; elems = NULL; realloc(ecount); if (ecount) { GET_INT32X(s, hom_objid); for (uint i=0; i < ecount; i++) { Object *obj = s.getObjectInternal("element", hom_objid); elems[i] = obj; } } else { hom_objid = OBJID_TEMP; } } ObjectID Array::getObjectID() const { return OBJID_ARRAY; } void Array::store(ObjectStream &s) const { PUT_INT32D(s, ecount); if (ecount) { assert(hom_objid != OBJID_TEMP); putIDComment(s, hom_objid); PUT_INT32X(s, hom_objid); for (uint i = 0; i min_newbufsize) { n *= ARRAY_ALLOC_GROW_DENOM; n /= ARRAY_ALLOC_GROW_NUM; } } if (n-curbufsize > ARRAY_ALLOC_GROW_ABSMAX) { n = curbufsize + ARRAY_ALLOC_GROW_ABSMAX; } if (n < ARRAY_ALLOC_MIN) n = ARRAY_ALLOC_MIN; if (n < min_newbufsize) { n = min_newbufsize; } return n; } void Array::checkShrink() { // FIXME: implement automatic shrinking memset(elems+ecount, 0, (acount-ecount) * sizeof (*elems)); } void Array::freeObj(Object *obj) { if (own_objects && obj) { obj->done(); delete obj; } } void Array::realloc(int n) { if (n == 0) n = 1; /* alloc'ing 0 bytes not allowed */ assert((uint)n >= ecount); elems = (Object**)::realloc(elems, sizeof (*elems) * n); acount = n; memset(elems+ecount, 0, (acount-ecount)*sizeof(*elems)); } /** * Prepare a write access * @param i position of planned write access */ void Array::prepareWriteAccess(int i) { if (i < 0) throw MsgException("data structure too big (Array)"); uint n = calcNewBufferSize(acount, i+1); if (n > acount) realloc(n); } /*uint Array::count() const { return ecount; }*/ int Array::compareObjects(const Object *a, const Object *b) const { return autoCompare(a, b); } void Array::forceSetByIdx(int i, Object *obj) { // FIXME: sanity check, better idea ? if (i < 0) assert(0); prepareWriteAccess(i); freeObj(elems[i]); elems[i] = obj; notifyInsertOrSet(obj); if ((uint)i>=ecount) ecount = i+1; } Object *Array::get(ObjHandle h) const { uint i = handleToNative(h); return validHandle(h) ? elems[i] : NULL; } uint Array::getObjIdx(ObjHandle h) const { return invObjHandle ? invIdx : handleToNative(h); } ObjHandle Array::findByIdx(int i) const { return validHandle(nativeToHandle(i)) ? nativeToHandle(i) : invObjHandle; } ObjHandle Array::findFirst() const { return ecount ? nativeToHandle(0) : invObjHandle; } ObjHandle Array::findLast() const { return ecount ? nativeToHandle(ecount-1) : invObjHandle; } ObjHandle Array::findNext(ObjHandle h) const { if (!validHandle(h)) return findFirst(); uint i = handleToNative(h); return (i0) ? nativeToHandle(i-1) : invObjHandle; } ObjHandle Array::insert(Object *obj) { prepareWriteAccess(ecount); elems[ecount++] = obj; notifyInsertOrSet(obj); return nativeToHandle(ecount-1); } bool Array::del(ObjHandle h) { if (!validHandle(h)) return false; freeObj(remove(h)); return true; } bool Array::moveTo(ObjHandle from, ObjHandle to) { if (!validHandle(from)) return false; if (!validHandle(to)) return false; uint i = handleToNative(from); uint t = handleToNative(to); if (i == t) return true; Object *o = elems[i]; if (i < t) { memmove(elems+i, elems+i+1, sizeof (*elems) * (t - i)); } else { memmove(elems+t+1, elems+t, sizeof (*elems) * (i - t)); } elems[t] = o; return true; } Object *Array::remove(ObjHandle h) { if (!validHandle(h)) return NULL; uint i = handleToNative(h); Object *o = elems[i]; if (i < ecount) memmove(elems+i, elems+i+1, sizeof (*elems) * (ecount - i - 1)); ecount--; checkShrink(); return o; } bool Array::set(ObjHandle h, Object *obj) { if (!validHandle(h)) return false; uint i = handleToNative(h); freeObj(elems[i]); elems[i] = obj; notifyInsertOrSet(obj); return true; } bool Array::swap(ObjHandle h, ObjHandle i) { if (!validHandle(h)) return false; if (!validHandle(i)) return false; uint H = handleToNative(h); uint I = handleToNative(i); Object *t = elems[H]; elems[H] = elems[I]; elems[I] = t; return true; } void Array::insertAt(ObjHandle h, Object *obj) { if (!validHandle(h)) { insert(obj); } else { uint i = handleToNative(h); if (i < ecount) { prepareWriteAccess(ecount); memmove(elems+i+1, elems+i, sizeof (*elems) * (ecount - i)); ecount++; } else { prepareWriteAccess(i); memset(elems+ecount, 0, sizeof (*elems) * (i - ecount)); ecount = i+1; } elems[i] = obj; notifyInsertOrSet(obj); } } /* * Stack */ Stack::Stack(bool own_objects) : Array(own_objects) { } void Stack::push(Object *obj) { insert(obj); } Object *Stack::pop() { return remove(findLast()); } ObjectID Stack::getObjectID() const { return OBJID_STACK; } /* * SLinkedList */ SLinkedList::SLinkedList(bool oo) { own_objects = oo; ecount = 0; first = last = NULL; } SLinkedList::~SLinkedList() { delAll(); } void SLinkedList::delAll() { SLinkedListNode *n = first, *m; while (n) { m = n->next; freeObj(n->obj); deleteNode(n); n = m; } ecount = 0; first = last = NULL; } SLinkedListNode *SLinkedList::allocNode() const { return new SLinkedListNode; } void SLinkedList::deleteNode(SLinkedListNode *node) const { delete node; } void SLinkedList::freeObj(Object *obj) const { if (own_objects && obj) { obj->done(); delete obj; } } SLinkedList *SLinkedList::clone() const { SLinkedList *l = new SLinkedList(own_objects); SLinkedListNode *n = first, *m; while (n) { m = n->next; Object *o = m->obj; if (own_objects) o = o->clone(); l->insert(o); n = m; } return l; } void SLinkedList::load(ObjectStream &s) { own_objects = true; first = last = NULL; ecount = 0; int ecount; GET_INT32D(s, ecount); if (ecount) { GET_INT32X(s, hom_objid); for (int i=0; i < ecount; i++) { Object *obj = s.getObjectInternal("element", hom_objid); insert(obj); } } else { hom_objid = OBJID_TEMP; } } ObjectID SLinkedList::getObjectID() const { return OBJID_SLINKED_LIST; } void SLinkedList::store(ObjectStream &s) const { PUT_INT32D(s, ecount); if (ecount) { putIDComment(s, hom_objid); PUT_INT32X(s, hom_objid); ObjHandle h = findFirst(); assert(h == invObjHandle || hom_objid != OBJID_TEMP); while (h != invObjHandle) { Object *o = get(h); s.putObject(o, "element", hom_objid); h = findNext(h); } } } uint SLinkedList::count() const { return ecount; } int SLinkedList::compareObjects(const Object *a, const Object *b) const { return autoCompare(a, b); } void SLinkedList::forceSetByIdx(int idx, Object *obj) { // FIXME: throw NotImplementedException(HERE); } Object *SLinkedList::get(ObjHandle h) const { SLinkedListNode *n = handleToNative(h); return validHandle(h) ? n->obj : NULL; } uint SLinkedList::getObjIdx(ObjHandle g) const { int i = 0; ObjHandle h = findFirst(); Object *obj = get(g); while (h != invObjHandle) { if (compareObjects(get(h), obj) == 0) return i; i++; h = findNext(h); } return invIdx; } ObjHandle SLinkedList::findByIdx(int i) const { ObjHandle h = findFirst(); while (h != invObjHandle) { if (!i--) break; h = findNext(h); } return h; } ObjHandle SLinkedList::findFirst() const { return nativeToHandle(first); } ObjHandle SLinkedList::findLast() const { return nativeToHandle(last); } ObjHandle SLinkedList::findNext(ObjHandle h) const { if (!validHandle(h)) return findFirst(); SLinkedListNode *n = handleToNative(h); return nativeToHandle(n->next); } ObjHandle SLinkedList::findPrev(ObjHandle g) const { if (!validHandle(g)) return findLast(); SLinkedListNode *ng = handleToNative(g); if (ng == first) return invObjHandle; ObjHandle h = findFirst(); while (h != invObjHandle) { SLinkedListNode *nh = handleToNative(h); if (nh->next == ng) return nativeToHandle(nh); h = findNext(h); } return invObjHandle; } bool SLinkedList::del(ObjHandle h) { if (!h) return false; freeObj(remove(h)); return true; } ObjHandle SLinkedList::insert(Object *obj) { SLinkedListNode *n = allocNode(); n->obj = obj; n->next = NULL; if (last) { last->next = n; last = n; } else { first = last = n; } ecount++; notifyInsertOrSet(obj); return nativeToHandle(n); } Object *SLinkedList::remove(ObjHandle h) { if (!validHandle(h)) return NULL; SLinkedListNode *n = handleToNative(h); Object *o = n->obj; if (n == first) { if (n == last) { first = NULL; last = NULL; } else { first = n->next; } } else { SLinkedListNode *p = handleToNative(findPrev(h)); p->next = n->next; if (n == last) last = p; } deleteNode(n); ecount--; return o; } void SLinkedList::insertAt(ObjHandle h, Object *obj) { // FIXME: nyi throw NotImplementedException(HERE); #if 0 uint i = ((uint)h)-1; // WRONG! if (i>ecount-1) { insert(obj); return; } ObjHandle q = i ? findByIdx(i-1) : invObjHandle; SLinkedListNode *n; if (q != invObjHandle) { n = handleToNative(q); } else if (i==0) { n = NULL; } else { insert(obj); return; } SLinkedListNode *m = allocNode(); m->obj = obj; if (n) { m->next = n->next; n->next = m; if (n == last) last = m; } else { m->next = first; first = m; if (!last) last = m; } ecount++; notifyInsertOrSet(obj); #endif } bool SLinkedList::moveTo(ObjHandle from, ObjHandle to) { // FIXME: throw NotImplementedException(HERE); } bool SLinkedList::set(ObjHandle h, Object *obj) { SLinkedListNode *n = handleToNative(h); if (!n) return false; freeObj(n->obj); n->obj = obj; return true; } bool SLinkedList::swap(ObjHandle h, ObjHandle i) { SLinkedListNode *H = handleToNative(h); SLinkedListNode *I = handleToNative(i); Object *t = H->obj; H->obj = I->obj; I->obj = t; return true; } bool SLinkedList::validHandle(ObjHandle h) const { return h != invObjHandle; } SLinkedListNode* SLinkedList::handleToNative(ObjHandle h) const { return (SLinkedListNode*)h; } ObjHandle SLinkedList::nativeToHandle(SLinkedListNode *n) const { return (ObjHandle)n; } /* * DLinkedList */ DLinkedList::DLinkedList(bool oo) { own_objects = oo; ecount = 0; first = last = NULL; } DLinkedList::~DLinkedList() { delAll(); } void DLinkedList::delAll() { DLinkedListNode *n = first, *m; while (n) { m = n->next; freeObj(n->obj); deleteNode(n); n = m; } ecount = 0; first = last = NULL; } DLinkedListNode *DLinkedList::allocNode() const { return new DLinkedListNode; } void DLinkedList::deleteNode(DLinkedListNode *node) const { delete node; } void DLinkedList::freeObj(Object *obj) const { if (own_objects && obj) { obj->done(); delete obj; } } DLinkedList *DLinkedList::clone() const { DLinkedList *l = new DLinkedList(own_objects); DLinkedListNode *n = first, *m; while (n) { m = n->next; Object *o = m->obj; if (own_objects) o = o->clone(); l->insert(o); n = m; } return l; } void DLinkedList::load(ObjectStream &s) { own_objects = true; first = last = NULL; ecount = 0; int ecount; GET_INT32D(s, ecount); if (ecount) { GET_INT32X(s, hom_objid); for (int i=0; iobj : NULL; } uint DLinkedList::getObjIdx(ObjHandle g) const { int i = 0; ObjHandle h = findFirst(); Object *obj = get(g); while (h != invObjHandle) { if (compareObjects(get(h), obj) == 0) return i; i++; h = findNext(h); } return invIdx; } ObjHandle DLinkedList::findByIdx(int i) const { ObjHandle h = findFirst(); while (h != invObjHandle) { if (!i--) break; h = findNext(h); } return h; } ObjHandle DLinkedList::findFirst() const { return nativeToHandle(first); } ObjHandle DLinkedList::findLast() const { return nativeToHandle(last); } ObjHandle DLinkedList::findNext(ObjHandle h) const { if (!validHandle(h)) return findFirst(); DLinkedListNode *n = handleToNative(h); return nativeToHandle(n->next); } ObjHandle DLinkedList::findPrev(ObjHandle h) const { if (!validHandle(h)) return findLast(); DLinkedListNode *n = handleToNative(h); return nativeToHandle(n->prev); } bool DLinkedList::del(ObjHandle h) { if (!h) return false; freeObj(remove(h)); return true; } ObjHandle DLinkedList::insert(Object *obj) { DLinkedListNode *n = allocNode(); n->obj = obj; n->next = NULL; if (last) { last->next = n; n->prev = last; last = n; } else { first = last = n; } ecount++; notifyInsertOrSet(obj); return nativeToHandle(n); } Object *DLinkedList::remove(ObjHandle h) { if (!validHandle(h)) return NULL; DLinkedListNode *n = handleToNative(h); Object *o = n->obj; if (n == first) { if (n == last) { first = NULL; last = NULL; } else { first = n->next; first->prev = NULL; } } else if (n == last) { last = n->prev; last->next = NULL; } else { n->prev->next = n->next; n->next->prev = n->prev; } deleteNode(n); ecount--; return o; } void DLinkedList::insertAt(ObjHandle h, Object *obj) { // FIXME: nyi throw NotImplementedException(HERE); } bool DLinkedList::moveTo(ObjHandle from, ObjHandle to) { // FIXME: throw NotImplementedException(HERE); } bool DLinkedList::set(ObjHandle h, Object *obj) { DLinkedListNode *n = handleToNative(h); if (!n) return false; freeObj(n->obj); n->obj = obj; return true; } bool DLinkedList::swap(ObjHandle h, ObjHandle i) { DLinkedListNode *H = handleToNative(h); DLinkedListNode *I = handleToNative(i); Object *t = H->obj; H->obj = I->obj; I->obj = t; return true; } bool DLinkedList::validHandle(ObjHandle h) const { return h != invObjHandle; } DLinkedListNode* DLinkedList::handleToNative(ObjHandle h) const { return (DLinkedListNode*)h; } ObjHandle DLinkedList::nativeToHandle(DLinkedListNode *n) const { return (ObjHandle)n; } /* * Queue */ Queue::Queue(bool own_objects) : SLinkedList(own_objects) { } ObjectID Queue::getObjectID() const { return OBJID_QUEUE; } /* * BinaryTree */ BinaryTree::BinaryTree(bool oo, Comparator comp) { root = NULL; own_objects = oo; compare = comp; ecount = 0; } BinaryTree::~BinaryTree() { delAll(); } void BinaryTree::delAll() { freeAll(root); root = NULL; ecount = 0; } BinTreeNode *BinaryTree::allocNode() const { return new BinTreeNode; } void BinaryTree::deleteNode(BinTreeNode *node) const { delete node; } BinTreeNode **BinaryTree::findNodePtr(BinTreeNode **nodeptr, const Object *obj) const { BinTreeNode **x = nodeptr; while (x) { int c = compareObjects((*x)->key, obj); if (c < 0) { x = &(*x)->right; } else if (c > 0) { x = &(*x)->left; } else break; } return x; } BinTreeNode *BinaryTree::findNode(BinTreeNode *node, const Object *obj) const { while (node) { int c = compareObjects(node->key, obj); if (c < 0) { node = node->right; } else if (c > 0) { node = node->left; } else break; } return node; } BinTreeNode *BinaryTree::findNodeG(BinTreeNode *node, const Object *obj) const { if (!node) return NULL; BinTreeNode *lastGreater = NULL; while (true) { int c = compareObjects(obj, node->key); if (c < 0) { if (!node->left) return node; lastGreater = node; node = node->left; } else { if (!node->right) return lastGreater; node = node->right; } } } BinTreeNode *BinaryTree::findNodeGE(BinTreeNode *node, const Object *obj) const { if (!node) return NULL; BinTreeNode *lastGreater = NULL; while (true) { int c = compareObjects(obj, node->key); if (c < 0) { if (!node->left) return node; lastGreater = node; node = node->left; } else if (c > 0) { if (!node->right) return lastGreater; node = node->right; } else { return node; } } } BinTreeNode *BinaryTree::findNodeL(BinTreeNode *node, const Object *obj) const { if (!node) return NULL; BinTreeNode *lastLower = NULL; while (true) { int c = compareObjects(obj, node->key); if (c <= 0) { if (!node->left) return lastLower; node = node->left; } else { if (!node->right) return node; lastLower = node; node = node->right; } } } BinTreeNode *BinaryTree::findNodeLE(BinTreeNode *node, const Object *obj) const { if (!node) return NULL; BinTreeNode *lastLower = NULL; while (true) { int c = compareObjects(obj, node->key); if (c < 0) { if (!node->left) return lastLower; node = node->left; } else if (c > 0) { if (!node->right) return node; lastLower = node; node = node->right; } else { return node; } } } void BinaryTree::freeAll(BinTreeNode *n) { if (!n) return; freeAll(n->left); freeObj(n->key); freeAll(n->right); deleteNode(n); } void BinaryTree::freeObj(Object *obj) const { if (own_objects && obj) { obj->done(); delete obj; } } ObjHandle BinaryTree::findByIdxR(BinTreeNode *n, int &i) const { if (!n) return invObjHandle; ObjHandle h; if ((h = findByIdxR(n->left, i))) return h; if (i == 0) return nativeToHandle(n); i--; if ((h = findByIdxR(n->right, i))) return h; return invObjHandle; } BinTreeNode *BinaryTree::getLeftmost(BinTreeNode *node) const { if (node) while (node->left) node = node->left; return node; } BinTreeNode *BinaryTree::getRightmost(BinTreeNode *node) const { if (node) while (node->right) node = node->right; return node; } BinTreeNode **BinaryTree::getLeftmostPtr(BinTreeNode **p) const { if (*p) while ((*p)->left) p = &(*p)->left; return p; } BinTreeNode **BinaryTree::getRightmostPtr(BinTreeNode **p) const { if (*p) while ((*p)->right) p = &(*p)->right; return p; } void BinaryTree::cloneR(BinTreeNode *node) { if (!node) return; Object *o = own_objects ? node->key->clone() : node->key; // SB: nicht gut: (unnoetige compares) insert(o); cloneR(node->left); cloneR(node->right); } BinaryTree *BinaryTree::clone() const { BinaryTree *c = new BinaryTree(own_objects, compare); c->cloneR(root); return c; } void BinaryTree::loadR(ObjectStream &s, BinTreeNode **n, int l, int r) { if (l > r) { *n = NULL; return; } *n = allocNode(); uint m = (l+r)/2; loadR(s, &(*n)->left, l, m-1); (*n)->key = s.getObjectInternal("element", hom_objid); loadR(s, &(*n)->right, m+1, r); } void BinaryTree::load(ObjectStream &s) { const void *m = getAtomValue(GETX_INT32(s, "comparator")); if (!m) throw MsgException("BinaryTree::load(): invalid comparator!"); compare = (Comparator)m; GET_INT32D(s, ecount); root = NULL; own_objects = true; if (ecount) { GET_INT32X(s, hom_objid); loadR(s, &root, 0, ecount-1); } else { hom_objid = OBJID_TEMP; } } ObjectID BinaryTree::getObjectID() const { return OBJID_BINARY_TREE; } void BinaryTree::storeR(ObjectStream &s, BinTreeNode *n) const { if (!n) return; storeR(s, n->left); s.putObject(n->key, "element", hom_objid); storeR(s, n->right); } void BinaryTree::store(ObjectStream &s) const { int aId = getAtomId((void*)compare); if (!aId) throw MsgException("BinaryTree::store() : comparator not registered!"); putIDComment(s, aId); PUTX_INT32X(s, aId, "comparator"); PUT_INT32D(s, ecount); if (ecount) { assert(hom_objid != OBJID_TEMP); putIDComment(s, hom_objid); PUT_INT32X(s, hom_objid); storeR(s, root); } } uint BinaryTree::count() const { return ecount; } int BinaryTree::compareObjects(const Object *a, const Object *b) const { return compare(a, b); } ObjHandle BinaryTree::find(const Object *key) const { return findNode(root, key); } ObjHandle BinaryTree::findG(const Object *key) const { return findNodeG(root, key); } ObjHandle BinaryTree::findGE(const Object *key) const { return findNodeGE(root, key); } ObjHandle BinaryTree::findL(const Object *key) const { return findNodeL(root, key); } ObjHandle BinaryTree::findLE(const Object *key) const { return findNodeLE(root, key); } Object *BinaryTree::get(ObjHandle h) const { BinTreeNode *n = handleToNative(h); return validHandle(h) ? n->key : NULL; } uint BinaryTree::getObjIdx(ObjHandle h) const { // FIXME: implement it throw NotImplementedException(HERE); } ObjHandle BinaryTree::findByIdx(int i) const { return findByIdxR(root, i); } ObjHandle BinaryTree::findFirst() const { return nativeToHandle(getLeftmost(root)); } ObjHandle BinaryTree::findLast() const { return nativeToHandle(getRightmost(root)); } ObjHandle BinaryTree::findNext(ObjHandle h) const { if (!validHandle(h)) return findFirst(); BinTreeNode *n = handleToNative(h); if (n->right) return nativeToHandle(getLeftmost(n->right)); BinTreeNode *x = root, *result = NULL; while (x) { int c = compareObjects(x->key, n->key); if (c > 0) { result = x; x = x->left; } else { x = x->right; } } return nativeToHandle(result); } ObjHandle BinaryTree::findPrev(ObjHandle h) const { if (!validHandle(h)) return findLast(); BinTreeNode *n = handleToNative(h); if (n->left) return nativeToHandle(getRightmost(n->left)); BinTreeNode *x = root, *result = NULL; while (x) { int c = compareObjects(x->key, n->key); if (c < 0) { result = x; x = x->right; } else { x = x->left; } } return nativeToHandle(result); } bool BinaryTree::del(ObjHandle h) { if (!validHandle(h)) return false; BinTreeNode *n = handleToNative(h); Object *obj = n->key; bool r = remove(h); freeObj(obj); return r; } // SB: ich haette gerne noch ein findOrInsert (besserer Name noetig), // das entweder einfuegt oder - wenns das schon gibt - // das ObjHandle zurueckgibt (bzw immer das objHandle zurueckgibt) // SW: interface + naive implementierung in Container sind da ObjHandle BinaryTree::insert(Object *obj) { return insertR(root, obj); } ObjHandle BinaryTree::insertR(BinTreeNode *&node, Object *obj) { if (!node) { node = allocNode(); node->key = obj; node->left = NULL; node->right = NULL; ecount++; notifyInsertOrSet(obj); return nativeToHandle(node); } int c = compareObjects(obj, node->key); if (c > 0) { return insertR(node->right, obj); } else if (c < 0) { return insertR(node->left, obj); } else return invObjHandle; } Object *BinaryTree::remove(ObjHandle h) { if (!validHandle(h)) return NULL; /* n is the node, whose key has to be removed */ BinTreeNode *n = handleToNative(h); /* d is node that is to be removed - not necessarily n. */ BinTreeNode *d; Object *o = n->key; if (n->left && n->right) { /* p is pointer to left/right inside Parent(d) with: *p = d */ BinTreeNode **p = getLeftmostPtr(&n->right); d = *p; *p = (*p)->right; } else if (n->left || n->right) { d = n->left ? n->left : n->right; n->left = d->left; n->right = d->right; } else { // SB: hier wuerde ein remove(Object *o) mit integriertem find() // auch (etwas) schneller sein, da man kein findNodePtr mehr braucht // SW: interface ist da: remove(Object *o) BinTreeNode **p = findNodePtr(&root, n->key); d = *p; *p = NULL; } n->key = d->key; deleteNode(d); ecount--; return o; } void BinaryTree::setNodeIdentity(BinTreeNode *node, BinTreeNode *newident) { node->key = newident->key; } /* * AVLTree */ AVLTree::AVLTree(bool aOwnObjects, Comparator aComparator) : BinaryTree(aOwnObjects, aComparator) { } void debugOutNode(FILE *f, BinTreeNode *n, BinTreeNode *p) { if (n) { char b[1024]; ht_snprintf(b, sizeof b, "node: { title: \"%y\" label: \"%y (%d)\" }\n", n->key, n->key, n->unbalance); fputs(b, f); if (p) { ht_snprintf(b, sizeof b, "edge: { sourcename: \"%y\" targetname: \"%y\" }\n", p->key, n->key); fputs(b, f); } debugOutNode(f, n->right, n); debugOutNode(f, n->left, n); } } void AVLTree::debugOut() { FILE *f = fopen("test.vcg", "wb"); fputs("graph: {\nlayoutalgorithm: tree\n", f); debugOutNode(f, root, NULL); fputs("}\n", f); fclose(f); } bool AVLTree__expensiveCheck(BinTreeNode *n, int &height) { if (n) { int left, right; if (!AVLTree__expensiveCheck(n->left, left)) return false; if (!AVLTree__expensiveCheck(n->right, right)) return false; height = MAX(left, right)+1; if (left < right) { return n->unbalance == 1; } else if (left > right) { return n->unbalance == -1; } else { return n->unbalance == 0; } } else { height = 0; return true; } } bool AVLTree::expensiveCheck() const { int dummy; return AVLTree__expensiveCheck(root, dummy); } void AVLTree::cloneR(BinTreeNode *node) { if (!node) return; Object *o = own_objects ? node->key->clone() : node->key; // SB: nicht gut: (unnoetige compares) insert(o); cloneR(node->left); cloneR(node->right); } AVLTree *AVLTree::clone() const { AVLTree *c = new AVLTree(own_objects, compare); c->cloneR(root); return c; } int AVLTree::loadR(ObjectStream &s, BinTreeNode *&n, int l, int r) { if (l > r) { n = NULL; return 0; } n = allocNode(); uint m = (l+r)/2; int L = loadR(s, n->left, l, m-1); n->key = s.getObject("element", hom_objid); int R = loadR(s, n->right, m+1, r); if (L < R) { n->unbalance = +1; } else if (L > R) { n->unbalance = -1; } else { n->unbalance = 0; } return MAX(L, R)+1; } void AVLTree::load(ObjectStream &s) { const void *m = getAtomValue(GETX_INT32X(s, "comparator")); if (!m) throw MsgException("AVLTree::load(): invalid 'comparator'!"); compare = (Comparator)m; GET_INT32D(s, ecount); root = NULL; own_objects = true; if (ecount) { GET_INT32X(s, hom_objid); loadR(s, root, 0, ecount-1); } else { hom_objid = OBJID_TEMP; } } ObjectID AVLTree::getObjectID() const { return OBJID_AVL_TREE; } ObjHandle AVLTree::insert(Object *obj) { /* t will point to the node where rebalancing may be necessary */ BinTreeNode **t = &root; /* *pp will walk through the tree */ BinTreeNode **pp = &root; // Search while (*pp) { int c = compareObjects(obj, (*pp)->key); if (c < 0) { pp = &(*pp)->left; } else if (c > 0) { pp = &(*pp)->right; } else { // element found return invObjHandle; } if (*pp && (*pp)->unbalance) { t = pp; } } /* s points to the node where rebalancing may be necessary */ BinTreeNode *s = *t; // Insert *pp = allocNode(); BinTreeNode *retval = *pp; retval->key = obj; retval->left = retval->right = NULL; retval->unbalance = 0; ecount++; notifyInsertOrSet(obj); if (!s) return nativeToHandle(retval); // Rebalance int a; BinTreeNode *r; BinTreeNode *p; if (compareObjects(obj, s->key) < 0) { a = -1; r = p = s->left; } else { a = 1; r = p = s->right; } while (p != retval) { if (compareObjects(obj, p->key) < 0) { p->unbalance = -1; p = p->left; } else { p->unbalance = 1; p = p->right; } } if (!s->unbalance) { // tree was balanced before insertion s->unbalance = a; } else if (s->unbalance == -a) { // tree has become more balanced s->unbalance = 0; } else { // tree is out of balance if (r->unbalance == a) { // single rotation p = r; if (a < 0) { s->left = r->right; r->right = s; } else { s->right = r->left; r->left = s; } s->unbalance = r->unbalance = 0; } else { // double rotation if (a < 0) { p = r->right; r->right = p->left; p->left = r; s->left = p->right; p->right = s; } else { p = r->left; r->left = p->right; p->right = r; s->right = p->left; p->left = s; } s->unbalance = (p->unbalance == a) ? -a : 0; r->unbalance = (p->unbalance == -a) ? a : 0; p->unbalance = 0; } // finalization *t = p; } assert(root); return nativeToHandle(retval); } BinTreeNode *AVLTree::removeR(Object *key, BinTreeNode *&node, int &change, int cmp) { if (node == NULL) { change = 0; return NULL; } BinTreeNode *found = NULL; int decrease = 0; int result; if (!cmp) { result = compareObjects(key, node->key); if (result < 0) { result = -1; } else if (result > 0) { result = 1; } } else if (cmp < 0) { result = (node->left == NULL) ? 0 : -1; } else { result = (node->right == NULL) ? 0 : 1; } if (result) { found = removeR(key, (result < 0) ? node->left : node->right, change, cmp); if (!found) return NULL; decrease = result * change; } else { found = node; /* * Same logic as in BinaryTree::remove() */ if (!node->left && !node->right) { node = NULL; change = 1; return found; } else if (!node->left || !node->right) { node = node->right ? node->right : node->left; change = 1; return found; } else { BinTreeNode *n = removeR(key, node->right, decrease, -1); setNodeIdentity(node, n); found = n; } } node->unbalance -= decrease; if (decrease) { if (node->unbalance) { change = 0; int a; BinTreeNode *r = NULL; if (node->unbalance < -1) { a = -1; r = node->left; } else if (node->unbalance > 1) { a = 1; r = node->right; } else { a = 0; } if (a) { /* * If r->unbalance == 0 do also a single rotation. * This case cant occure with insert operations. */ if (r->unbalance == -a) { /* * double rotation. * See insert */ BinTreeNode *p; if (a > 0) { p = r->left; r->left = p->right; p->right = r; node->right = p->left; p->left = node; } else { p = r->right; r->right = p->left; p->left = r; node->left = p->right; p->right = node; } node->unbalance = (p->unbalance == a) ? -a: 0; r->unbalance = (p->unbalance == -a) ? a: 0; p->unbalance = 0; node = p; change = 1; } else { /* * single rotation * Height of tree changes if r is/was unbalanced */ change = r->unbalance?1:0; if (a > 0) { node->right = r->left; r->left = node; r->unbalance--; } else { node->left = r->right; r->right = node; r->unbalance++; } node->unbalance = - r->unbalance; node = r; } } } else { /* * Tree has become more balanced */ change = 1; } } else { change = 0; } return found; } Object *AVLTree::remove(ObjHandle h) { if (!validHandle(h)) return NULL; BinTreeNode *n = handleToNative(h); Object *o = n->key; int change; BinTreeNode *node = removeR(n->key, root, change, 0); if (node) { deleteNode(node); ecount--; return o; } return NULL; } /** * A MRU Cache */ MRUCache::MRUCache(bool own_objects, Comparator comparator) : AVLTree(own_objects, comparator) { mostRU = leastRU = NULL; } MRUCacheNode *MRUCache::allocNode() const { MRUCacheNode *a = new MRUCacheNode(); // ((MRUCacheNode*)a)->lessRU = (MRUCacheNode*)0xfffff789; // ((MRUCacheNode*)a)->moreRU = (MRUCacheNode*)0xfffff888; return a; } MRUCache *MRUCache::clone() const { throw NotImplementedException(HERE); } void MRUCache::delAll() { AVLTree::delAll(); mostRU = leastRU = NULL; } void MRUCache::deleteNode(BinTreeNode *node) const { // ((MRUCacheNode*)node)->lessRU = (MRUCacheNode*)0xdeadf0cc; // ((MRUCacheNode*)node)->moreRU = (MRUCacheNode*)0xdeadf0c2; delete node; } ObjHandle MRUCache::insert(Object *obj) { // checkList(); uint count0 = count(); ObjHandle h = AVLTree::insert(obj); // DPRINTF("mru_insert: %08x\n", (int)h); if (count0 != count()) { // make mostRU in MRU list MRUCacheNode *n = handleToNative(h); n->moreRU = NULL; n->lessRU = mostRU; if (mostRU == NULL) { mostRU = leastRU = n; } else { mostRU->moreRU = n; mostRU = n; } // checkList(); } return h; } Object *MRUCache::remove(ObjHandle h) { /* static int debug_rc = 0; ++debug_rc; DPRINTF("mru_remove(%d): %08x\n", debug_rc, (int)h); if (debug_rc == 19) { int sdf=32; } checkList();*/ if (h != invObjHandle) { MRUCacheNode *n = handleToNative(h); // remove from MRU list if (n == mostRU) { if (n == leastRU) { // DPRINTF(" --> removing leastRU entry --> empty list\n"); mostRU = NULL; leastRU = NULL; } else { // DPRINTF(" --> removing mostRU entry\n"); mostRU = n->lessRU; mostRU->moreRU = NULL; } } else if (n == leastRU) { // DPRINTF(" --> removing leastRU entry\n"); // DPRINTF(" mostRU was: %08x, leastRU was: %08x\n", mostRU, leastRU); leastRU = n->moreRU; leastRU->lessRU = NULL; // DPRINTF(" mostRU is now: %08x, leastRU is now: %08x\n", mostRU, leastRU); // DPRINTF(" mostRU->moreRU: %08x\n", mostRU->moreRU); } else { // DPRINTF(" --> removing entry\n"); n->moreRU->lessRU = n->lessRU; n->lessRU->moreRU = n->moreRU; } } // checkList(); Object *o = AVLTree::remove(h); if ((h != invObjHandle) && (o == NULL)) assert(0); // checkList(); return o; } void MRUCache::setNodeIdentity(BinTreeNode *node, BinTreeNode *newident) { MRUCacheNode *_node = (MRUCacheNode *)node; MRUCacheNode *_newident = (MRUCacheNode *)newident; _node->key = _newident->key; _node->moreRU = _newident->moreRU; _node->lessRU = _newident->lessRU; if (_newident->moreRU) { _newident->moreRU->lessRU = _node; } else { mostRU = _node; } if (_newident->lessRU) { _newident->lessRU->moreRU = _node; } else { leastRU = _node; } } void MRUCache::store(ObjectStream &s) const { throw NotImplementedException(HERE); } void MRUCache::propagate(ObjHandle h) { if (h != invObjHandle) { MRUCacheNode *n = handleToNative(h); // remove from MRU list if (n == mostRU) { if (n == leastRU) { mostRU = NULL; leastRU = NULL; } else { mostRU = n->lessRU; mostRU->moreRU = NULL; } } else if (n == leastRU) { leastRU = n->moreRU; leastRU->lessRU = NULL; } else { n->moreRU->lessRU = n->lessRU; n->lessRU->moreRU = n->moreRU; } // checkList(); // make mostRU in MRU list n->moreRU = NULL; n->lessRU = mostRU; if (mostRU == NULL) { mostRU = leastRU = n; } else { mostRU->moreRU = n; mostRU = n; } // checkList(); } } ObjHandle MRUCache::getLRU() { return nativeToHandle(leastRU); } void MRUCache::checkList() const { assert(expensiveCheck()); DPRINTF("======================================================\n"); if (!mostRU || !leastRU) { DPRINTF("empty\n"); assert(!mostRU); assert(!leastRU); return; } DPRINTF("list: \n"); MRUCacheNode *i = mostRU; while (i) { DPRINTF(" moreRU | this | lessRU "); if (i->lessRU) DPRINTF("||"); i = i->lessRU; } DPRINTF("\n"); i = mostRU; while (i) { #if 0 DPRINTF("%08x|%08x|%08x", i->moreRU, i, i->lessRU); if (i->lessRU) DPRINTF("||"); #else DPRINTF("%08x\n", i->moreRU); DPRINTF("%08x\n", i); DPRINTF("%08x\n", i->lessRU); if (i->lessRU) DPRINTF(" ||\n"); #endif i = i->lessRU; } DPRINTF("\n"); uint c1 = 1; i = mostRU; while (i->lessRU) { if (i->lessRU->moreRU != i) { DPRINTF("ecount =%08x\n", ecount); DPRINTF("mostRU: %08x, leastRU: %08x\n", mostRU, leastRU); DPRINTF("i: %08x, i->lessRU: %08x, i->np: %08x\n", i, i->lessRU, i->lessRU->moreRU); } assert(i->lessRU->moreRU == i); assert(((i == mostRU) && (i->moreRU == NULL)) || ((i != mostRU) && (i->moreRU != NULL))); i = i->lessRU; c1++; assert(c1<=ecount); } assert(i == leastRU); uint c2 = 1; i = leastRU; while (i->moreRU) { assert(i->moreRU->lessRU == i); assert(((i == leastRU) && (i->lessRU == NULL)) || ((i != leastRU) && (i->lessRU != NULL))); i = i->moreRU; c2++; assert(c2<=ecount); } assert(i == mostRU); // assert(c1 == ecount); // assert(c2 == ecount); } /* * Set */ Set::Set(bool oo) : AVLTree(oo) { } ObjectID Set::getObjectID() const { return OBJID_SET; } void Set::intersectWith(Set *b) { foreach(Object, elem, *this, if (!b->contains(elem)) delObj(elem); ); } void Set::unionWith(Set *b) { foreach(Object, elem, *b, if (!contains(elem)) insert(own_objects ? elem->clone() : elem); ); } /* * */ KeyValue::~KeyValue() { if (mKey) mKey->done(); delete mKey; if (mValue) mValue->done(); delete mValue; } KeyValue *KeyValue::clone() const { return new KeyValue(mKey->clone(), mValue->clone()); } int KeyValue::compareTo(const Object *obj) const { return mKey->compareTo(((KeyValue*)obj)->mKey); } int KeyValue::toString(char *buf, int buflen) const { return ht_snprintf(buf, buflen, "[Key: %y; Value: %y]", mKey, mValue); } void KeyValue::load(ObjectStream &s) { GET_OBJECT(s, mKey); GET_OBJECT(s, mValue); } ObjectID KeyValue::getObjectID() const { return OBJID_KEYVALUE; } void KeyValue::store(ObjectStream &s) const { PUT_OBJECT(s, mKey); PUT_OBJECT(s, mValue); } /* * SInt */ SInt *SInt::clone() const { return new SInt(value); } int SInt::compareTo(const Object *obj) const { SInt *s = (SInt*)obj; return value - s->value; } int SInt::toString(char *buf, int buflen) const { return ht_snprintf(buf, buflen, "%d", value); } void SInt::load(ObjectStream &s) { GET_INT32D(s, value); } ObjectID SInt::getObjectID() const { return OBJID_SINT; } void SInt::store(ObjectStream &s) const { PUT_INT32D(s, value); } /* * A signed Integer (64-bit) */ SInt64 *SInt64::clone() const { return new SInt64(value); } int SInt64::compareTo(const Object *obj) const { SInt64 *u = (SInt64*)obj; if (value < u->value) { return -1; } else if (value > u->value) { return 1; } else { return 0; } } int SInt64::toString(char *buf, int buflen) const { return ht_snprintf(buf, buflen, "%qd", value); } void SInt64::load(ObjectStream &s) { GET_INT64D(s, value); } ObjectID SInt64::getObjectID() const { return OBJID_SINT64; } void SInt64::store(ObjectStream &s) const { PUT_INT64D(s, value); } /* * UInt */ UInt *UInt::clone() const { return new UInt(value); } int UInt::compareTo(const Object *obj) const { UInt *u = (UInt*)obj; if (value < u->value) { return -1; } else if (value > u->value) { return 1; } else { return 0; } } int UInt::toString(char *buf, int buflen) const { return ht_snprintf(buf, buflen, "%u", value); } void UInt::load(ObjectStream &s) { GET_INT32D(s, value); } ObjectID UInt::getObjectID() const { return OBJID_UINT; } void UInt::store(ObjectStream &s) const { PUT_INT32D(s, value); } /* * A unsigned Integer (64-bit) */ UInt64 *UInt64::clone() const { return new UInt64(value); } int UInt64::compareTo(const Object *obj) const { UInt64 *u = (UInt64*)obj; if (value < u->value) { return -1; } else if (value > u->value) { return 1; } else { return 0; } } int UInt64::toString(char *buf, int buflen) const { return ht_snprintf(buf, buflen, "%qu", value); } void UInt64::load(ObjectStream &s) { GET_INT64D(s, value); } ObjectID UInt64::getObjectID() const { return OBJID_UINT64; } void UInt64::store(ObjectStream &s) const { PUT_INT64D(s, value); } /* * A floating-point number (FIXME: no portable storage yet) */ Float *Float::clone() const { return new Float(value); } int Float::compareTo(const Object *obj) const { // FIXME: do we want to compare for equality using some error term epsilon ? Float *f = (Float*)obj; if (value < f->value) { return -1; } else if (value > f->value) { return 1; } else { return 0; } } int Float::toString(char *buf, int buflen) const { return ht_snprintf(buf, buflen, "%f", value); } ObjectID Float::getObjectID() const { return OBJID_FLOAT; } /** * A memory area. */ MemArea::MemArea(const void *p, uint s, bool d) { duplicate = d; size = s; if (duplicate) { ptr = malloc(size); if (!ptr) throw std::bad_alloc(); memcpy(ptr, p, size); } else { // FIXME: un-const'ing p ptr = const_cast(p); } } MemArea::~MemArea() { if (duplicate) free(ptr); } MemArea *MemArea::clone() const { return new MemArea(ptr, size, true); } int MemArea::compareTo(const Object *obj) const { const MemArea *a = this; const MemArea *b = (const MemArea*)obj; if (a->size != b->size) return a->size - b->size; return memcmp(a->ptr, b->ptr, a->size); } int MemArea::toString(char *buf, int buflen) const { throw NotImplementedException(HERE); } void MemArea::load(ObjectStream &s) { GET_INT32D(s, size); ptr = malloc(size); if (!ptr) throw std::bad_alloc(); GET_BINARY(s, ptr, size); } ObjectID MemArea::getObjectID() const { return OBJID_MEMAREA; } void MemArea::store(ObjectStream &s) const { PUT_INT32D(s, size), PUT_BINARY(s, ptr, size); } /* * IntSet */ IntSet::IntSet(uint aMaxSetSize) { mMaxSetSize = aMaxSetSize; mSetSize = 0; mSet = NULL; } IntSet::~IntSet() { free(mSet); } void IntSet::assign(const IntSet &from) { delAll(); if (from.mSetSize) makeAccessible(from.mSetSize-1); uint s = from.mSetSize ? idx2ByteOfs(from.mSetSize-1)+1 : 0; if (s) memcpy(mSet, from.mSet, s); } IntSet *IntSet::clone() const { IntSet *s = new IntSet(mMaxSetSize); s->assign(*this); return s; } int IntSet::compareTo(const Object *obj) const { const IntSet *a = (const IntSet*)this; const IntSet *b = (const IntSet*)obj; if (a->mSetSize == b->mSetSize) { uint s = a->mSetSize ? idx2ByteOfs(a->mSetSize-1)+1 : 0; return memcmp(a->mSet, b->mSet, s); } return a->mSetSize - b->mSetSize; } inline uint IntSet::idx2ByteOfs(uint i) const { return i >> 3; } inline uint IntSet::idx2BitMask(uint i) const { return 1 << (i & 7); } void IntSet::makeAccessible(uint i) { if (!isAccessible(i)) { if (i+1 > mMaxSetSize) throw IndexOutOfBoundsException(HERE); uint oldByteSize = mSetSize ? idx2ByteOfs(mSetSize-1)+1 : 0; uint newByteSize = idx2ByteOfs(i)+1; // grow exponentially if (newByteSize < 3*oldByteSize/2) newByteSize = 3*oldByteSize/2; mSet = (byte*)realloc(mSet, newByteSize); if (!mSet) throw std::bad_alloc(); memset(mSet+oldByteSize, 0, newByteSize-oldByteSize); mSetSize = i+1; } } inline bool IntSet::isAccessible(uint i) const { return i < mSetSize; } bool IntSet::contains(uint i) const { if (!isAccessible(i)) return false; return mSet[idx2ByteOfs(i)] & idx2BitMask(i); } void IntSet::del(uint i) { makeAccessible(i); mSet[idx2ByteOfs(i)] &= ~idx2BitMask(i); } void IntSet::delAll() { free(mSet); mSet = NULL; mSetSize = 0; } bool IntSet::findFirst(uint &i, bool set) const { i = (uint)-1; return findNext(i, set); } bool IntSet::findNext(uint &i, bool set) const { // FIXME: naive impl for (uint j=i+1; j < mSetSize; j++) { if (contains(j) == set) { i = j; return true; } } if (i+1 >= mSetSize && i+1 < mMaxSetSize && !set) { i++; return true; } return false; } bool IntSet::findPrev(uint &i, bool set) const { // FIXME: naive impl if (i == 0) return false; if (i-1 >= mSetSize && i-1 < mMaxSetSize && !set) { i--; return true; } for (uint j=i-1; j >= 0; j--) { if (contains(j) == set) { i = j; return true; } } return false; } void IntSet::insert(uint i) { makeAccessible(i); mSet[idx2ByteOfs(i)] |= idx2BitMask(i); } int IntSet::toString(char *buf, int buflen) const { int w = 0; uint s; if (!findFirst(s, true)) return 0; w += ht_snprintf(buf+w, buflen-w, "("); while (buflen-w > 0) { w += ht_snprintf(buf+w, buflen-w, "%d", s); if (!findNext(s, true)) break; w += ht_snprintf(buf+w, buflen-w, ","); } w += ht_snprintf(buf+w, buflen-w, ")"); return w; } /* * sorter */ static void quickSortR(List &list, int l, int r) { int m = (l+r)/2; int L = l; int R = r; Object *c = list[m]; do { while ((l<=r) && (list.compareObjects(list[l], c)<0)) l++; while ((l<=r) && (list.compareObjects(list[r], c)>0)) r--; if (l<=r) { list.swap(list.findByIdx(l), list.findByIdx(r)); l++; r--; } } while (ldesc) { if (hash_table->value==value) return hash_table->desc; hash_table++; } } return NULL; } /* * Module Init/Done */ BUILDER2(OBJID_OBJECT, Object); BUILDER(OBJID_ARRAY, Array, List); BUILDER(OBJID_STACK, Stack, Array); BUILDER(OBJID_BINARY_TREE, BinaryTree, Container); BUILDER(OBJID_AVL_TREE, AVLTree, BinaryTree); BUILDER(OBJID_SET, Set, AVLTree); BUILDER(OBJID_SLINKED_LIST, SLinkedList, List); BUILDER(OBJID_QUEUE, Queue, SLinkedList); BUILDER(OBJID_DLINKED_LIST, DLinkedList, List); BUILDER(OBJID_KEYVALUE, KeyValue, Object); BUILDER(OBJID_SINT, SInt, Object); BUILDER(OBJID_UINT, UInt, Object); BUILDER(OBJID_MEMAREA, MemArea, Object); BUILDER(OBJID_STRING, String, Object); BUILDER(OBJID_ISTRING, IString, String); bool init_data() { registerAtom(OBJID_AUTO_COMPARE, (void*)&autoCompare); REGISTER(OBJID_OBJECT, Object); REGISTER(OBJID_ARRAY, Array); REGISTER(OBJID_STACK, Stack); REGISTER(OBJID_BINARY_TREE, BinaryTree); REGISTER(OBJID_AVL_TREE, AVLTree); REGISTER(OBJID_SET, Set); REGISTER(OBJID_SLINKED_LIST, SLinkedList); REGISTER(OBJID_QUEUE, Queue); REGISTER(OBJID_DLINKED_LIST, DLinkedList); REGISTER(OBJID_KEYVALUE, KeyValue); REGISTER(OBJID_SINT, SInt); REGISTER(OBJID_UINT, UInt); REGISTER(OBJID_MEMAREA, MemArea); REGISTER(OBJID_STRING, String); REGISTER(OBJID_ISTRING, IString); return true; } void done_data() { unregisterAtom(OBJID_AUTO_COMPARE); UNREGISTER(OBJID_OBJECT, Object); UNREGISTER(OBJID_ARRAY, Array); UNREGISTER(OBJID_STACK, Stack); UNREGISTER(OBJID_BINARY_TREE, BinaryTree); UNREGISTER(OBJID_AVL_TREE, AVLTree); UNREGISTER(OBJID_SET, Set); UNREGISTER(OBJID_SLINKED_LIST, SLinkedList); UNREGISTER(OBJID_QUEUE, Queue); UNREGISTER(OBJID_DLINKED_LIST, DLinkedList); UNREGISTER(OBJID_KEYVALUE, KeyValue); UNREGISTER(OBJID_SINT, SInt); UNREGISTER(OBJID_UINT, UInt); UNREGISTER(OBJID_MEMAREA, MemArea); UNREGISTER(OBJID_STRING, String); UNREGISTER(OBJID_ISTRING, IString); } ht-2.0.22/cplus-dem.c0000644000175000001440000035110111655554266011202 00000000000000/* Demangler for GNU C++ Copyright 1989, 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.uucp) Rewritten by Fred Fish (fnf@cygnus.com) for ARM and Lucid demangling Modified by Satish Pai (pai@apollo.hp.com) for HP demangling This file is part of the libiberty library. Libiberty is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. In addition to the permissions in the GNU Library General Public License, the Free Software Foundation gives you unlimited permission to link the compiled version of this file into combinations with other programs, and to distribute those combinations without any restriction coming from the use of this file. (The Library Public License restrictions do apply in other respects; for example, they cover modification of the file, and distribution when not linked into a combined executable.) Libiberty is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with libiberty; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ /* This file exports two functions; cplus_mangle_opname and cplus_demangle. This file imports xmalloc and xrealloc, which are like malloc and realloc except that they generate a fatal error if there is no available memory. */ #define xmalloc malloc #define xrealloc realloc #define xstrdup strdup /* This file lives in both GCC and libiberty. When making changes, please try not to break either. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "safe-ctype.h" #define bl _sch_isblank #define cn _sch_iscntrl #define di _sch_isdigit #define is _sch_isidst #define lo _sch_islower #define nv _sch_isnvsp #define pn _sch_ispunct #define pr _sch_isprint #define sp _sch_isspace #define up _sch_isupper #define vs _sch_isvsp #define xd _sch_isxdigit #define L (const unsigned short) (lo|is |pr) /* lower case letter */ #define XL (const unsigned short) (lo|is|xd|pr) /* lowercase hex digit */ #define U (const unsigned short) (up|is |pr) /* upper case letter */ #define XU (const unsigned short) (up|is|xd|pr) /* uppercase hex digit */ #define D (const unsigned short) (di |xd|pr) /* decimal digit */ #define P (const unsigned short) (pn |pr) /* punctuation */ #define _ (const unsigned short) (pn|is |pr) /* underscore */ #define C (const unsigned short) ( cn) /* control character */ #define Z (const unsigned short) (nv |cn) /* NUL */ #define M (const unsigned short) (nv|sp |cn) /* cursor movement: \f \v */ #define V (const unsigned short) (vs|sp |cn) /* vertical space: \r \n */ #define T (const unsigned short) (nv|sp|bl|cn) /* tab */ #define S (const unsigned short) (nv|sp|bl|pr) /* space */ const unsigned short _sch_istable[256] = { Z, C, C, C, C, C, C, C, /* NUL SOH STX ETX EOT ENQ ACK BEL */ C, T, V, M, M, V, C, C, /* BS HT LF VT FF CR SO SI */ C, C, C, C, C, C, C, C, /* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */ C, C, C, C, C, C, C, C, /* CAN EM SUB ESC FS GS RS US */ S, P, P, P, P, P, P, P, /* SP ! " # $ % & ' */ P, P, P, P, P, P, P, P, /* ( ) * + , - . / */ D, D, D, D, D, D, D, D, /* 0 1 2 3 4 5 6 7 */ D, D, P, P, P, P, P, P, /* 8 9 : ; < = > ? */ P, XU, XU, XU, XU, XU, XU, U, /* @ A B C D E F G */ U, U, U, U, U, U, U, U, /* H I J K L M N O */ U, U, U, U, U, U, U, U, /* P Q R S T U V W */ U, U, U, P, P, P, P, _, /* X Y Z [ \ ] ^ _ */ P, XL, XL, XL, XL, XL, XL, L, /* ` a b c d e f g */ L, L, L, L, L, L, L, L, /* h i j k l m n o */ L, L, L, L, L, L, L, L, /* p q r s t u v w */ L, L, L, P, P, P, P, C, /* x y z { | } ~ DEL */ /* high half of unsigned char is locale-specific, so all tests are false in "C" locale */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #include #include #include #ifdef HAVE_STDLIB_H #include #else char * malloc (); char * realloc (); #endif #include #undef CURRENT_DEMANGLING_STYLE #define CURRENT_DEMANGLING_STYLE work->options #define min(X,Y) (((X) < (Y)) ? (X) : (Y)) /* A value at least one greater than the maximum number of characters that will be output when using the `%d' format with `printf'. */ #define INTBUF_SIZE 32 extern void fancy_abort (void); /* In order to allow a single demangler executable to demangle strings using various common values of CPLUS_MARKER, as well as any specific one set at compile time, we maintain a string containing all the commonly used ones, and check to see if the marker we are looking for is in that string. CPLUS_MARKER is usually '$' on systems where the assembler can deal with that. Where the assembler can't, it's usually '.' (but on many systems '.' is used for other things). We put the current defined CPLUS_MARKER first (which defaults to '$'), followed by the next most common value, followed by an explicit '$' in case the value of CPLUS_MARKER is not '$'. We could avoid this if we could just get g++ to tell us what the actual cplus marker character is as part of the debug information, perhaps by ensuring that it is the character that terminates the gcc_compiled marker symbol (FIXME). */ #if !defined (CPLUS_MARKER) #define CPLUS_MARKER '$' #endif enum demangling_styles current_demangling_style = auto_demangling; static char cplus_markers[] = { CPLUS_MARKER, '.', '$', '\0' }; static char char_str[2] = { '\000', '\000' }; void set_cplus_marker_for_demangling (int ch) { cplus_markers[0] = ch; } typedef struct string /* Beware: these aren't required to be */ { /* '\0' terminated. */ char *b; /* pointer to start of string */ char *p; /* pointer after last character */ char *e; /* pointer after end of allocated space */ } string; /* Stuff that is shared between sub-routines. Using a shared structure allows cplus_demangle to be reentrant. */ struct work_stuff { int options; char **typevec; char **ktypevec; char **btypevec; int numk; int numb; int ksize; int bsize; int ntypes; int typevec_size; int constructor; int destructor; int static_type; /* A static member function */ int temp_start; /* index in demangled to start of template args */ int type_quals; /* The type qualifiers. */ int dllimported; /* Symbol imported from a PE DLL */ char **tmpl_argvec; /* Template function arguments. */ int ntmpl_args; /* The number of template function arguments. */ int forgetting_types; /* Nonzero if we are not remembering the types we see. */ string* previous_argument; /* The last function argument demangled. */ int nrepeats; /* The number of times to repeat the previous argument. */ }; #define PRINT_ANSI_QUALIFIERS (work -> options & DMGL_ANSI) #define PRINT_ARG_TYPES (work -> options & DMGL_PARAMS) static const struct optable { const char *const in; const char *const out; const int flags; } optable[] = { {"nw", " new", DMGL_ANSI}, /* new (1.92, ansi) */ {"dl", " delete", DMGL_ANSI}, /* new (1.92, ansi) */ {"new", " new", 0}, /* old (1.91, and 1.x) */ {"delete", " delete", 0}, /* old (1.91, and 1.x) */ {"vn", " new []", DMGL_ANSI}, /* GNU, pending ansi */ {"vd", " delete []", DMGL_ANSI}, /* GNU, pending ansi */ {"as", "=", DMGL_ANSI}, /* ansi */ {"ne", "!=", DMGL_ANSI}, /* old, ansi */ {"eq", "==", DMGL_ANSI}, /* old, ansi */ {"ge", ">=", DMGL_ANSI}, /* old, ansi */ {"gt", ">", DMGL_ANSI}, /* old, ansi */ {"le", "<=", DMGL_ANSI}, /* old, ansi */ {"lt", "<", DMGL_ANSI}, /* old, ansi */ {"plus", "+", 0}, /* old */ {"pl", "+", DMGL_ANSI}, /* ansi */ {"apl", "+=", DMGL_ANSI}, /* ansi */ {"minus", "-", 0}, /* old */ {"mi", "-", DMGL_ANSI}, /* ansi */ {"ami", "-=", DMGL_ANSI}, /* ansi */ {"mult", "*", 0}, /* old */ {"ml", "*", DMGL_ANSI}, /* ansi */ {"amu", "*=", DMGL_ANSI}, /* ansi (ARM/Lucid) */ {"aml", "*=", DMGL_ANSI}, /* ansi (GNU/g++) */ {"convert", "+", 0}, /* old (unary +) */ {"negate", "-", 0}, /* old (unary -) */ {"trunc_mod", "%", 0}, /* old */ {"md", "%", DMGL_ANSI}, /* ansi */ {"amd", "%=", DMGL_ANSI}, /* ansi */ {"trunc_div", "/", 0}, /* old */ {"dv", "/", DMGL_ANSI}, /* ansi */ {"adv", "/=", DMGL_ANSI}, /* ansi */ {"truth_andif", "&&", 0}, /* old */ {"aa", "&&", DMGL_ANSI}, /* ansi */ {"truth_orif", "||", 0}, /* old */ {"oo", "||", DMGL_ANSI}, /* ansi */ {"truth_not", "!", 0}, /* old */ {"nt", "!", DMGL_ANSI}, /* ansi */ {"postincrement","++", 0}, /* old */ {"pp", "++", DMGL_ANSI}, /* ansi */ {"postdecrement","--", 0}, /* old */ {"mm", "--", DMGL_ANSI}, /* ansi */ {"bit_ior", "|", 0}, /* old */ {"or", "|", DMGL_ANSI}, /* ansi */ {"aor", "|=", DMGL_ANSI}, /* ansi */ {"bit_xor", "^", 0}, /* old */ {"er", "^", DMGL_ANSI}, /* ansi */ {"aer", "^=", DMGL_ANSI}, /* ansi */ {"bit_and", "&", 0}, /* old */ {"ad", "&", DMGL_ANSI}, /* ansi */ {"aad", "&=", DMGL_ANSI}, /* ansi */ {"bit_not", "~", 0}, /* old */ {"co", "~", DMGL_ANSI}, /* ansi */ {"call", "()", 0}, /* old */ {"cl", "()", DMGL_ANSI}, /* ansi */ {"alshift", "<<", 0}, /* old */ {"ls", "<<", DMGL_ANSI}, /* ansi */ {"als", "<<=", DMGL_ANSI}, /* ansi */ {"arshift", ">>", 0}, /* old */ {"rs", ">>", DMGL_ANSI}, /* ansi */ {"ars", ">>=", DMGL_ANSI}, /* ansi */ {"component", "->", 0}, /* old */ {"pt", "->", DMGL_ANSI}, /* ansi; Lucid C++ form */ {"rf", "->", DMGL_ANSI}, /* ansi; ARM/GNU form */ {"indirect", "*", 0}, /* old */ {"method_call", "->()", 0}, /* old */ {"addr", "&", 0}, /* old (unary &) */ {"array", "[]", 0}, /* old */ {"vc", "[]", DMGL_ANSI}, /* ansi */ {"compound", ", ", 0}, /* old */ {"cm", ", ", DMGL_ANSI}, /* ansi */ {"cond", "?:", 0}, /* old */ {"cn", "?:", DMGL_ANSI}, /* pseudo-ansi */ {"max", ">?", 0}, /* old */ {"mx", ">?", DMGL_ANSI}, /* pseudo-ansi */ {"min", "*", DMGL_ANSI}, /* ansi */ {"sz", "sizeof ", DMGL_ANSI} /* pseudo-ansi */ }; /* These values are used to indicate the various type varieties. They are all non-zero so that they can be used as `success' values. */ typedef enum type_kind_t { tk_none, tk_pointer, tk_reference, tk_integral, tk_bool, tk_char, tk_real } type_kind_t; const struct demangler_engine libiberty_demanglers[] = { { NO_DEMANGLING_STYLE_STRING, no_demangling, "Demangling disabled" } , { AUTO_DEMANGLING_STYLE_STRING, auto_demangling, "Automatic selection based on executable" } , { GNU_DEMANGLING_STYLE_STRING, gnu_demangling, "GNU (g++) style demangling" } , { LUCID_DEMANGLING_STYLE_STRING, lucid_demangling, "Lucid (lcc) style demangling" } , { ARM_DEMANGLING_STYLE_STRING, arm_demangling, "ARM style demangling" } , { HP_DEMANGLING_STYLE_STRING, hp_demangling, "HP (aCC) style demangling" } , { EDG_DEMANGLING_STYLE_STRING, edg_demangling, "EDG style demangling" } , { GNU_V3_DEMANGLING_STYLE_STRING, gnu_v3_demangling, "GNU (g++) V3 ABI-style demangling" } , { JAVA_DEMANGLING_STYLE_STRING, java_demangling, "Java style demangling" } , { GNAT_DEMANGLING_STYLE_STRING, gnat_demangling, "GNAT style demangling" } , { NULL, unknown_demangling, NULL } }; #define STRING_EMPTY(str) ((str) -> b == (str) -> p) #define APPEND_BLANK(str) {if (!STRING_EMPTY(str)) \ string_append(str, " ");} #define LEN_STRING(str) ( (STRING_EMPTY(str))?0:((str)->p - (str)->b)) /* The scope separator appropriate for the language being demangled. */ #define SCOPE_STRING(work) ((work->options & DMGL_JAVA) ? "." : "::") #define ARM_VTABLE_STRING "__vtbl__" /* Lucid/ARM virtual table prefix */ #define ARM_VTABLE_STRLEN 8 /* strlen (ARM_VTABLE_STRING) */ /* Prototypes for local functions */ static void delete_work_stuff (struct work_stuff *); static void delete_non_B_K_work_stuff (struct work_stuff *); static char *mop_up (struct work_stuff *, string *, int); static void squangle_mop_up (struct work_stuff *); static void work_stuff_copy_to_from (struct work_stuff *, struct work_stuff *); #if 0 static int demangle_method_args (struct work_stuff *, const char **, string *); #endif static char * internal_cplus_demangle (struct work_stuff *, const char *); static int demangle_template_template_parm (struct work_stuff *work, const char **, string *); static int demangle_template (struct work_stuff *work, const char **, string *, string *, int, int); static int arm_pt (struct work_stuff *, const char *, int, const char **, const char **); static int demangle_class_name (struct work_stuff *, const char **, string *); static int demangle_qualified (struct work_stuff *, const char **, string *, int, int); static int demangle_class (struct work_stuff *, const char **, string *); static int demangle_fund_type (struct work_stuff *, const char **, string *); static int demangle_signature (struct work_stuff *, const char **, string *); static int demangle_prefix (struct work_stuff *, const char **, string *); static int gnu_special (struct work_stuff *, const char **, string *); static int arm_special (const char **, string *); static void string_need (string *, int); static void string_delete (string *); static void string_init (string *); static void string_clear (string *); #if 0 static int string_empty (string *); #endif static void string_append (string *, const char *); static void string_appends (string *, string *); static void string_appendn (string *, const char *, int); static void string_prepend (string *, const char *); static void string_prependn (string *, const char *, int); static void string_append_template_idx (string *, int); static int get_count (const char **, int *); static int consume_count (const char **); static int consume_count_with_underscores (const char**); static int demangle_args (struct work_stuff *, const char **, string *); static int demangle_nested_args (struct work_stuff*, const char**, string*); static int do_type (struct work_stuff *, const char **, string *); static int do_arg (struct work_stuff *, const char **, string *); static int demangle_function_name (struct work_stuff *, const char **, string *, const char *); static int iterate_demangle_function (struct work_stuff *, const char **, string *, const char *); static void remember_type (struct work_stuff *, const char *, int); static void remember_Btype (struct work_stuff *, const char *, int, int); static int register_Btype (struct work_stuff *); static void remember_Ktype (struct work_stuff *, const char *, int); static void forget_types (struct work_stuff *); static void forget_B_and_K_types (struct work_stuff *); static void string_prepends (string *, string *); static int demangle_template_value_parm (struct work_stuff*, const char**, string*, type_kind_t); static int do_hpacc_template_const_value (struct work_stuff *, const char **, string *); static int do_hpacc_template_literal (struct work_stuff *, const char **, string *); static int snarf_numeric_literal (const char **, string *); /* There is a TYPE_QUAL value for each type qualifier. They can be combined by bitwise-or to form the complete set of qualifiers for a type. */ #define TYPE_UNQUALIFIED 0x0 #define TYPE_QUAL_CONST 0x1 #define TYPE_QUAL_VOLATILE 0x2 #define TYPE_QUAL_RESTRICT 0x4 static int code_for_qualifier (int); static const char* qualifier_string (int); static const char* demangle_qualifier (int); static int demangle_expression (struct work_stuff *, const char **, string *, type_kind_t); static int demangle_integral_value (struct work_stuff *, const char **, string *); static int demangle_real_value (struct work_stuff *, const char **, string *); static void demangle_arm_hp_template (struct work_stuff *, const char **, int, string *); static void recursively_demangle (struct work_stuff *, const char **, string *, int); static void grow_vect (char **, size_t *, size_t, int); /* Translate count to integer, consuming tokens in the process. Conversion terminates on the first non-digit character. Trying to consume something that isn't a count results in no consumption of input and a return of -1. Overflow consumes the rest of the digits, and returns -1. */ static int consume_count (const char **type) { int count = 0; if (! ISDIGIT ((unsigned char)**type)) return -1; while (ISDIGIT ((unsigned char)**type)) { count *= 10; /* Check for overflow. We assume that count is represented using two's-complement; no power of two is divisible by ten, so if an overflow occurs when multiplying by ten, the result will not be a multiple of ten. */ if ((count % 10) != 0) { while (ISDIGIT ((unsigned char) **type)) (*type)++; return -1; } count += **type - '0'; (*type)++; } if (count < 0) count = -1; return (count); } /* Like consume_count, but for counts that are preceded and followed by '_' if they are greater than 10. Also, -1 is returned for failure, since 0 can be a valid value. */ static int consume_count_with_underscores (const char **mangled) { int idx; if (**mangled == '_') { (*mangled)++; if (!ISDIGIT ((unsigned char)**mangled)) return -1; idx = consume_count (mangled); if (**mangled != '_') /* The trailing underscore was missing. */ return -1; (*mangled)++; } else { if (**mangled < '0' || **mangled > '9') return -1; idx = **mangled - '0'; (*mangled)++; } return idx; } /* C is the code for a type-qualifier. Return the TYPE_QUAL corresponding to this qualifier. */ static int code_for_qualifier (int c) { switch (c) { case 'C': return TYPE_QUAL_CONST; case 'V': return TYPE_QUAL_VOLATILE; case 'u': return TYPE_QUAL_RESTRICT; default: break; } /* C was an invalid qualifier. */ abort (); } /* Return the string corresponding to the qualifiers given by TYPE_QUALS. */ static const char* qualifier_string (int type_quals) { switch (type_quals) { case TYPE_UNQUALIFIED: return ""; case TYPE_QUAL_CONST: return "const"; case TYPE_QUAL_VOLATILE: return "volatile"; case TYPE_QUAL_RESTRICT: return "__restrict"; case TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE: return "const volatile"; case TYPE_QUAL_CONST | TYPE_QUAL_RESTRICT: return "const __restrict"; case TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT: return "volatile __restrict"; case TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE | TYPE_QUAL_RESTRICT: return "const volatile __restrict"; default: break; } /* TYPE_QUALS was an invalid qualifier set. */ abort (); } /* C is the code for a type-qualifier. Return the string corresponding to this qualifier. This function should only be called with a valid qualifier code. */ static const char* demangle_qualifier (int c) { return qualifier_string (code_for_qualifier (c)); } int cplus_demangle_opname (const char *opname, char *result, int options) { int len, len1, ret; string type; struct work_stuff work[1]; const char *tem; len = strlen(opname); result[0] = '\0'; ret = 0; memset ((char *) work, 0, sizeof (work)); work->options = options; if (opname[0] == '_' && opname[1] == '_' && opname[2] == 'o' && opname[3] == 'p') { /* ANSI. */ /* type conversion operator. */ tem = opname + 4; if (do_type (work, &tem, &type)) { strcat (result, "operator "); strncat (result, type.b, type.p - type.b); string_delete (&type); ret = 1; } } else if (opname[0] == '_' && opname[1] == '_' && ISLOWER((unsigned char)opname[2]) && ISLOWER((unsigned char)opname[3])) { if (opname[4] == '\0') { /* Operator. */ size_t i; for (i = 0; i < ARRAY_SIZE (optable); i++) { if (strlen (optable[i].in) == 2 && memcmp (optable[i].in, opname + 2, 2) == 0) { strcat (result, "operator"); strcat (result, optable[i].out); ret = 1; break; } } } else { if (opname[2] == 'a' && opname[5] == '\0') { /* Assignment. */ size_t i; for (i = 0; i < ARRAY_SIZE (optable); i++) { if (strlen (optable[i].in) == 3 && memcmp (optable[i].in, opname + 2, 3) == 0) { strcat (result, "operator"); strcat (result, optable[i].out); ret = 1; break; } } } } } else if (len >= 3 && opname[0] == 'o' && opname[1] == 'p' && strchr (cplus_markers, opname[2]) != NULL) { /* see if it's an assignment expression */ if (len >= 10 /* op$assign_ */ && memcmp (opname + 3, "assign_", 7) == 0) { size_t i; for (i = 0; i < ARRAY_SIZE (optable); i++) { len1 = len - 10; if ((int) strlen (optable[i].in) == len1 && memcmp (optable[i].in, opname + 10, len1) == 0) { strcat (result, "operator"); strcat (result, optable[i].out); strcat (result, "="); ret = 1; break; } } } else { size_t i; for (i = 0; i < ARRAY_SIZE (optable); i++) { len1 = len - 3; if ((int) strlen (optable[i].in) == len1 && memcmp (optable[i].in, opname + 3, len1) == 0) { strcat (result, "operator"); strcat (result, optable[i].out); ret = 1; break; } } } } else if (len >= 5 && memcmp (opname, "type", 4) == 0 && strchr (cplus_markers, opname[4]) != NULL) { /* type conversion operator */ tem = opname + 5; if (do_type (work, &tem, &type)) { strcat (result, "operator "); strncat (result, type.b, type.p - type.b); string_delete (&type); ret = 1; } } squangle_mop_up (work); return ret; } /* Takes operator name as e.g. "++" and returns mangled operator name (e.g. "postincrement_expr"), or NULL if not found. If OPTIONS & DMGL_ANSI == 1, return the ANSI name; if OPTIONS & DMGL_ANSI == 0, return the old GNU name. */ const char * cplus_mangle_opname (const char *opname, int options) { size_t i; int len; len = strlen (opname); for (i = 0; i < ARRAY_SIZE (optable); i++) { if ((int) strlen (optable[i].out) == len && (options & DMGL_ANSI) == (optable[i].flags & DMGL_ANSI) && memcmp (optable[i].out, opname, len) == 0) return optable[i].in; } return (0); } /* Add a routine to set the demangling style to be sure it is valid and allow for any demangler initialization that maybe necessary. */ enum demangling_styles cplus_demangle_set_style (enum demangling_styles style) { const struct demangler_engine *demangler = libiberty_demanglers; for (; demangler->demangling_style != unknown_demangling; ++demangler) if (style == demangler->demangling_style) { current_demangling_style = style; return current_demangling_style; } return unknown_demangling; } /* Do string name to style translation */ enum demangling_styles cplus_demangle_name_to_style (const char *name) { const struct demangler_engine *demangler = libiberty_demanglers; for (; demangler->demangling_style != unknown_demangling; ++demangler) if (strcmp (name, demangler->demangling_style_name) == 0) return demangler->demangling_style; return unknown_demangling; } /* char *cplus_demangle (const char *mangled, int options) If MANGLED is a mangled function name produced by GNU C++, then a pointer to a @code{malloc}ed string giving a C++ representation of the name will be returned; otherwise NULL will be returned. It is the caller's responsibility to free the string which is returned. The OPTIONS arg may contain one or more of the following bits: DMGL_ANSI ANSI qualifiers such as `const' and `void' are included. DMGL_PARAMS Function parameters are included. For example, cplus_demangle ("foo__1Ai", DMGL_PARAMS) => "A::foo(int)" cplus_demangle ("foo__1Ai", DMGL_PARAMS | DMGL_ANSI) => "A::foo(int)" cplus_demangle ("foo__1Ai", 0) => "A::foo" cplus_demangle ("foo__1Afe", DMGL_PARAMS) => "A::foo(float,...)" cplus_demangle ("foo__1Afe", DMGL_PARAMS | DMGL_ANSI)=> "A::foo(float,...)" cplus_demangle ("foo__1Afe", 0) => "A::foo" Note that any leading underscores, or other such characters prepended by the compilation system, are presumed to have already been stripped from MANGLED. */ char *ada_demangle (const char *mangled, int options) { return NULL; } char * cplus_demangle (const char *mangled, int options) { char *ret; struct work_stuff work[1]; if (current_demangling_style == no_demangling) return xstrdup (mangled); memset ((char *) work, 0, sizeof (work)); work->options = options; if ((work->options & DMGL_STYLE_MASK) == 0) work->options |= (int) current_demangling_style & DMGL_STYLE_MASK; /* The V3 ABI demangling is implemented elsewhere. */ if (GNU_V3_DEMANGLING || AUTO_DEMANGLING) { ret = cplus_demangle_v3 (mangled, work->options); if (ret || GNU_V3_DEMANGLING) return ret; } if (JAVA_DEMANGLING) { ret = java_demangle_v3 (mangled); if (ret) return ret; } if (GNAT_DEMANGLING) return ada_demangle(mangled,options); ret = internal_cplus_demangle (work, mangled); squangle_mop_up (work); return (ret); } /* Assuming *OLD_VECT points to an array of *SIZE objects of size ELEMENT_SIZE, grow it to contain at least MIN_SIZE objects, updating *OLD_VECT and *SIZE as necessary. */ static void grow_vect (char **old_vect, size_t *size, size_t min_size, int element_size) { if (*size < min_size) { *size *= 2; if (*size < min_size) *size = min_size; *old_vect = XRESIZEVAR (char, *old_vect, *size * element_size); } } /* This function performs most of what cplus_demangle use to do, but to be able to demangle a name with a B, K or n code, we need to have a longer term memory of what types have been seen. The original now initializes and cleans up the squangle code info, while internal calls go directly to this routine to avoid resetting that info. */ static char * internal_cplus_demangle (struct work_stuff *work, const char *mangled) { string decl; int success = 0; char *demangled = NULL; int s1, s2, s3, s4; s1 = work->constructor; s2 = work->destructor; s3 = work->static_type; s4 = work->type_quals; work->constructor = work->destructor = 0; work->type_quals = TYPE_UNQUALIFIED; work->dllimported = 0; if ((mangled != NULL) && (*mangled != '\0')) { string_init (&decl); /* First check to see if gnu style demangling is active and if the string to be demangled contains a CPLUS_MARKER. If so, attempt to recognize one of the gnu special forms rather than looking for a standard prefix. In particular, don't worry about whether there is a "__" string in the mangled string. Consider "_$_5__foo" for example. */ if ((AUTO_DEMANGLING || GNU_DEMANGLING)) { success = gnu_special (work, &mangled, &decl); } if (!success) { success = demangle_prefix (work, &mangled, &decl); } if (success && (*mangled != '\0')) { success = demangle_signature (work, &mangled, &decl); } if (work->constructor == 2) { string_prepend (&decl, "global constructors keyed to "); work->constructor = 0; } else if (work->destructor == 2) { string_prepend (&decl, "global destructors keyed to "); work->destructor = 0; } else if (work->dllimported == 1) { string_prepend (&decl, "import stub for "); work->dllimported = 0; } demangled = mop_up (work, &decl, success); } work->constructor = s1; work->destructor = s2; work->static_type = s3; work->type_quals = s4; return demangled; } /* Clear out and squangling related storage */ static void squangle_mop_up (struct work_stuff *work) { /* clean up the B and K type mangling types. */ forget_B_and_K_types (work); if (work -> btypevec != NULL) { free ((char *) work -> btypevec); } if (work -> ktypevec != NULL) { free ((char *) work -> ktypevec); } } /* Copy the work state and storage. */ static void work_stuff_copy_to_from (struct work_stuff *to, struct work_stuff *from) { int i; delete_work_stuff (to); /* Shallow-copy scalars. */ memcpy (to, from, sizeof (*to)); /* Deep-copy dynamic storage. */ if (from->typevec_size) to->typevec = XNEWVEC (char *, from->typevec_size); for (i = 0; i < from->ntypes; i++) { int len = strlen (from->typevec[i]) + 1; to->typevec[i] = XNEWVEC (char, len); memcpy (to->typevec[i], from->typevec[i], len); } if (from->ksize) to->ktypevec = XNEWVEC (char *, from->ksize); for (i = 0; i < from->numk; i++) { int len = strlen (from->ktypevec[i]) + 1; to->ktypevec[i] = XNEWVEC (char, len); memcpy (to->ktypevec[i], from->ktypevec[i], len); } if (from->bsize) to->btypevec = XNEWVEC (char *, from->bsize); for (i = 0; i < from->numb; i++) { int len = strlen (from->btypevec[i]) + 1; to->btypevec[i] = XNEWVEC (char , len); memcpy (to->btypevec[i], from->btypevec[i], len); } if (from->ntmpl_args) to->tmpl_argvec = XNEWVEC (char *, from->ntmpl_args); for (i = 0; i < from->ntmpl_args; i++) { int len = strlen (from->tmpl_argvec[i]) + 1; to->tmpl_argvec[i] = XNEWVEC (char, len); memcpy (to->tmpl_argvec[i], from->tmpl_argvec[i], len); } if (from->previous_argument) { to->previous_argument = XNEW (string); string_init (to->previous_argument); string_appends (to->previous_argument, from->previous_argument); } } /* Delete dynamic stuff in work_stuff that is not to be re-used. */ static void delete_non_B_K_work_stuff (struct work_stuff *work) { /* Discard the remembered types, if any. */ forget_types (work); if (work -> typevec != NULL) { free ((char *) work -> typevec); work -> typevec = NULL; work -> typevec_size = 0; } if (work->tmpl_argvec) { int i; for (i = 0; i < work->ntmpl_args; i++) if (work->tmpl_argvec[i]) free ((char*) work->tmpl_argvec[i]); free ((char*) work->tmpl_argvec); work->tmpl_argvec = NULL; } if (work->previous_argument) { string_delete (work->previous_argument); free ((char*) work->previous_argument); work->previous_argument = NULL; } } /* Delete all dynamic storage in work_stuff. */ static void delete_work_stuff (struct work_stuff *work) { delete_non_B_K_work_stuff (work); squangle_mop_up (work); } /* Clear out any mangled storage */ static char * mop_up (struct work_stuff *work, string *declp, int success) { char *demangled = NULL; delete_non_B_K_work_stuff (work); /* If demangling was successful, ensure that the demangled string is null terminated and return it. Otherwise, free the demangling decl. */ if (!success) { string_delete (declp); } else { string_appendn (declp, "", 1); demangled = declp->b; } return (demangled); } /* LOCAL FUNCTION demangle_signature -- demangle the signature part of a mangled name SYNOPSIS static int demangle_signature (struct work_stuff *work, const char **mangled, string *declp); DESCRIPTION Consume and demangle the signature portion of the mangled name. DECLP is the string where demangled output is being built. At entry it contains the demangled root name from the mangled name prefix. I.E. either a demangled operator name or the root function name. In some special cases, it may contain nothing. *MANGLED points to the current unconsumed location in the mangled name. As tokens are consumed and demangling is performed, the pointer is updated to continuously point at the next token to be consumed. Demangling GNU style mangled names is nasty because there is no explicit token that marks the start of the outermost function argument list. */ static int demangle_signature (struct work_stuff *work, const char **mangled, string *declp) { int success = 1; int func_done = 0; int expect_func = 0; int expect_return_type = 0; const char *oldmangled = NULL; string trawname; string tname; while (success && (**mangled != '\0')) { switch (**mangled) { case 'Q': oldmangled = *mangled; success = demangle_qualified (work, mangled, declp, 1, 0); if (success) remember_type (work, oldmangled, *mangled - oldmangled); if (AUTO_DEMANGLING || GNU_DEMANGLING) expect_func = 1; oldmangled = NULL; break; case 'K': oldmangled = *mangled; success = demangle_qualified (work, mangled, declp, 1, 0); if (AUTO_DEMANGLING || GNU_DEMANGLING) { expect_func = 1; } oldmangled = NULL; break; case 'S': /* Static member function */ if (oldmangled == NULL) { oldmangled = *mangled; } (*mangled)++; work -> static_type = 1; break; case 'C': case 'V': case 'u': work->type_quals |= code_for_qualifier (**mangled); /* a qualified member function */ if (oldmangled == NULL) oldmangled = *mangled; (*mangled)++; break; case 'L': /* Local class name follows after "Lnnn_" */ if (HP_DEMANGLING) { while (**mangled && (**mangled != '_')) (*mangled)++; if (!**mangled) success = 0; else (*mangled)++; } else success = 0; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (oldmangled == NULL) { oldmangled = *mangled; } work->temp_start = -1; /* uppermost call to demangle_class */ success = demangle_class (work, mangled, declp); if (success) { remember_type (work, oldmangled, *mangled - oldmangled); } if (AUTO_DEMANGLING || GNU_DEMANGLING || EDG_DEMANGLING) { /* EDG and others will have the "F", so we let the loop cycle if we are looking at one. */ if (**mangled != 'F') expect_func = 1; } oldmangled = NULL; break; case 'B': { string s; success = do_type (work, mangled, &s); if (success) { string_append (&s, SCOPE_STRING (work)); string_prepends (declp, &s); string_delete (&s); } oldmangled = NULL; expect_func = 1; } break; case 'F': /* Function */ /* ARM/HP style demangling includes a specific 'F' character after the class name. For GNU style, it is just implied. So we can safely just consume any 'F' at this point and be compatible with either style. */ oldmangled = NULL; func_done = 1; (*mangled)++; /* For lucid/ARM/HP style we have to forget any types we might have remembered up to this point, since they were not argument types. GNU style considers all types seen as available for back references. See comment in demangle_args() */ if (LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) { forget_types (work); } success = demangle_args (work, mangled, declp); /* After picking off the function args, we expect to either find the function return type (preceded by an '_') or the end of the string. */ if (success && (AUTO_DEMANGLING || EDG_DEMANGLING) && **mangled == '_') { ++(*mangled); /* At this level, we do not care about the return type. */ success = do_type (work, mangled, &tname); string_delete (&tname); } break; case 't': /* G++ Template */ string_init(&trawname); string_init(&tname); if (oldmangled == NULL) { oldmangled = *mangled; } success = demangle_template (work, mangled, &tname, &trawname, 1, 1); if (success) { remember_type (work, oldmangled, *mangled - oldmangled); } string_append (&tname, SCOPE_STRING (work)); string_prepends(declp, &tname); if (work -> destructor & 1) { string_prepend (&trawname, "~"); string_appends (declp, &trawname); work->destructor -= 1; } if ((work->constructor & 1) || (work->destructor & 1)) { string_appends (declp, &trawname); work->constructor -= 1; } string_delete(&trawname); string_delete(&tname); oldmangled = NULL; expect_func = 1; break; case '_': if ((AUTO_DEMANGLING || GNU_DEMANGLING) && expect_return_type) { /* Read the return type. */ string return_type; (*mangled)++; success = do_type (work, mangled, &return_type); APPEND_BLANK (&return_type); string_prepends (declp, &return_type); string_delete (&return_type); break; } else /* At the outermost level, we cannot have a return type specified, so if we run into another '_' at this point we are dealing with a mangled name that is either bogus, or has been mangled by some algorithm we don't know how to deal with. So just reject the entire demangling. */ /* However, "_nnn" is an expected suffix for alternate entry point numbered nnn for a function, with HP aCC, so skip over that without reporting failure. pai/1997-09-04 */ if (HP_DEMANGLING) { (*mangled)++; while (**mangled && ISDIGIT ((unsigned char)**mangled)) (*mangled)++; } else success = 0; break; case 'H': if (AUTO_DEMANGLING || GNU_DEMANGLING) { /* A G++ template function. Read the template arguments. */ success = demangle_template (work, mangled, declp, 0, 0, 0); if (!(work->constructor & 1)) expect_return_type = 1; (*mangled)++; break; } else /* fall through */ {;} default: if (AUTO_DEMANGLING || GNU_DEMANGLING) { /* Assume we have stumbled onto the first outermost function argument token, and start processing args. */ func_done = 1; success = demangle_args (work, mangled, declp); } else { /* Non-GNU demanglers use a specific token to mark the start of the outermost function argument tokens. Typically 'F', for ARM/HP-demangling, for example. So if we find something we are not prepared for, it must be an error. */ success = 0; } break; } /* if (AUTO_DEMANGLING || GNU_DEMANGLING) */ { if (success && expect_func) { func_done = 1; if (LUCID_DEMANGLING || ARM_DEMANGLING || EDG_DEMANGLING) { forget_types (work); } success = demangle_args (work, mangled, declp); /* Since template include the mangling of their return types, we must set expect_func to 0 so that we don't try do demangle more arguments the next time we get here. */ expect_func = 0; } } } if (success && !func_done) { if (AUTO_DEMANGLING || GNU_DEMANGLING) { /* With GNU style demangling, bar__3foo is 'foo::bar(void)', and bar__3fooi is 'foo::bar(int)'. We get here when we find the first case, and need to ensure that the '(void)' gets added to the current declp. Note that with ARM/HP, the first case represents the name of a static data member 'foo::bar', which is in the current declp, so we leave it alone. */ success = demangle_args (work, mangled, declp); } } if (success && PRINT_ARG_TYPES) { if (work->static_type) string_append (declp, " static"); if (work->type_quals != TYPE_UNQUALIFIED) { APPEND_BLANK (declp); string_append (declp, qualifier_string (work->type_quals)); } } return (success); } #if 0 static int demangle_method_args (struct work_stuff *work, const char **mangled, string *declp) { int success = 0; if (work -> static_type) { string_append (declp, *mangled + 1); *mangled += strlen (*mangled); success = 1; } else { success = demangle_args (work, mangled, declp); } return (success); } #endif static int demangle_template_template_parm (struct work_stuff *work, const char **mangled, string *tname) { int i; int r; int need_comma = 0; int success = 1; string temp; string_append (tname, "template <"); /* get size of template parameter list */ if (get_count (mangled, &r)) { for (i = 0; i < r; i++) { if (need_comma) { string_append (tname, ", "); } /* Z for type parameters */ if (**mangled == 'Z') { (*mangled)++; string_append (tname, "class"); } /* z for template parameters */ else if (**mangled == 'z') { (*mangled)++; success = demangle_template_template_parm (work, mangled, tname); if (!success) { break; } } else { /* temp is initialized in do_type */ success = do_type (work, mangled, &temp); if (success) { string_appends (tname, &temp); } string_delete(&temp); if (!success) { break; } } need_comma = 1; } } if (tname->p[-1] == '>') string_append (tname, " "); string_append (tname, "> class"); return (success); } static int demangle_expression (struct work_stuff *work, const char **mangled, string *s, type_kind_t tk) { int need_operator = 0; int success; success = 1; string_appendn (s, "(", 1); (*mangled)++; while (success && **mangled != 'W' && **mangled != '\0') { if (need_operator) { size_t i; size_t len; success = 0; len = strlen (*mangled); for (i = 0; i < ARRAY_SIZE (optable); ++i) { size_t l = strlen (optable[i].in); if (l <= len && memcmp (optable[i].in, *mangled, l) == 0) { string_appendn (s, " ", 1); string_append (s, optable[i].out); string_appendn (s, " ", 1); success = 1; (*mangled) += l; break; } } if (!success) break; } else need_operator = 1; success = demangle_template_value_parm (work, mangled, s, tk); } if (**mangled != 'W') success = 0; else { string_appendn (s, ")", 1); (*mangled)++; } return success; } static int demangle_integral_value (struct work_stuff *work, const char **mangled, string *s) { int success; if (**mangled == 'E') success = demangle_expression (work, mangled, s, tk_integral); else if (**mangled == 'Q' || **mangled == 'K') success = demangle_qualified (work, mangled, s, 0, 1); else { int value; /* By default, we let the number decide whether we shall consume an underscore. */ int multidigit_without_leading_underscore = 0; int leave_following_underscore = 0; success = 0; if (**mangled == '_') { if (mangled[0][1] == 'm') { /* Since consume_count_with_underscores does not handle the `m'-prefix we must do it here, using consume_count and adjusting underscores: we have to consume the underscore matching the prepended one. */ multidigit_without_leading_underscore = 1; string_appendn (s, "-", 1); (*mangled) += 2; } else { /* Do not consume a following underscore; consume_count_with_underscores will consume what should be consumed. */ leave_following_underscore = 1; } } else { /* Negative numbers are indicated with a leading `m'. */ if (**mangled == 'm') { string_appendn (s, "-", 1); (*mangled)++; } /* Since consume_count_with_underscores does not handle multi-digit numbers that do not start with an underscore, and this number can be an integer template parameter, we have to call consume_count. */ multidigit_without_leading_underscore = 1; /* These multi-digit numbers never end on an underscore, so if there is one then don't eat it. */ leave_following_underscore = 1; } /* We must call consume_count if we expect to remove a trailing underscore, since consume_count_with_underscores expects the leading underscore (that we consumed) if it is to handle multi-digit numbers. */ if (multidigit_without_leading_underscore) value = consume_count (mangled); else value = consume_count_with_underscores (mangled); if (value != -1) { char buf[INTBUF_SIZE]; sprintf (buf, "%d", value); string_append (s, buf); /* Numbers not otherwise delimited, might have an underscore appended as a delimeter, which we should skip. ??? This used to always remove a following underscore, which is wrong. If other (arbitrary) cases are followed by an underscore, we need to do something more radical. */ if ((value > 9 || multidigit_without_leading_underscore) && ! leave_following_underscore && **mangled == '_') (*mangled)++; /* All is well. */ success = 1; } } return success; } /* Demangle the real value in MANGLED. */ static int demangle_real_value (struct work_stuff *work, const char **mangled, string *s) { if (**mangled == 'E') return demangle_expression (work, mangled, s, tk_real); if (**mangled == 'm') { string_appendn (s, "-", 1); (*mangled)++; } while (ISDIGIT ((unsigned char)**mangled)) { string_appendn (s, *mangled, 1); (*mangled)++; } if (**mangled == '.') /* fraction */ { string_appendn (s, ".", 1); (*mangled)++; while (ISDIGIT ((unsigned char)**mangled)) { string_appendn (s, *mangled, 1); (*mangled)++; } } if (**mangled == 'e') /* exponent */ { string_appendn (s, "e", 1); (*mangled)++; while (ISDIGIT ((unsigned char)**mangled)) { string_appendn (s, *mangled, 1); (*mangled)++; } } return 1; } static int demangle_template_value_parm (struct work_stuff *work, const char **mangled, string *s, type_kind_t tk) { int success = 1; if (**mangled == 'Y') { /* The next argument is a template parameter. */ int idx; (*mangled)++; idx = consume_count_with_underscores (mangled); if (idx == -1 || (work->tmpl_argvec && idx >= work->ntmpl_args) || consume_count_with_underscores (mangled) == -1) return -1; if (work->tmpl_argvec) string_append (s, work->tmpl_argvec[idx]); else string_append_template_idx (s, idx); } else if (tk == tk_integral) success = demangle_integral_value (work, mangled, s); else if (tk == tk_char) { char tmp[2]; int val; if (**mangled == 'm') { string_appendn (s, "-", 1); (*mangled)++; } string_appendn (s, "'", 1); val = consume_count(mangled); if (val <= 0) success = 0; else { tmp[0] = (char)val; tmp[1] = '\0'; string_appendn (s, &tmp[0], 1); string_appendn (s, "'", 1); } } else if (tk == tk_bool) { int val = consume_count (mangled); if (val == 0) string_appendn (s, "false", 5); else if (val == 1) string_appendn (s, "true", 4); else success = 0; } else if (tk == tk_real) success = demangle_real_value (work, mangled, s); else if (tk == tk_pointer || tk == tk_reference) { if (**mangled == 'Q') success = demangle_qualified (work, mangled, s, /*isfuncname=*/0, /*append=*/1); else { int symbol_len = consume_count (mangled); if (symbol_len == -1) return -1; if (symbol_len == 0) string_appendn (s, "0", 1); else { char *p = XNEWVEC (char, symbol_len + 1), *q; strncpy (p, *mangled, symbol_len); p [symbol_len] = '\0'; /* We use cplus_demangle here, rather than internal_cplus_demangle, because the name of the entity mangled here does not make use of any of the squangling or type-code information we have built up thus far; it is mangled independently. */ q = cplus_demangle (p, work->options); if (tk == tk_pointer) string_appendn (s, "&", 1); /* FIXME: Pointer-to-member constants should get a qualifying class name here. */ if (q) { string_append (s, q); free (q); } else string_append (s, p); free (p); } *mangled += symbol_len; } } return success; } /* Demangle the template name in MANGLED. The full name of the template (e.g., S) is placed in TNAME. The name without the template parameters (e.g. S) is placed in TRAWNAME if TRAWNAME is non-NULL. If IS_TYPE is nonzero, this template is a type template, not a function template. If both IS_TYPE and REMEMBER are nonzero, the template is remembered in the list of back-referenceable types. */ static int demangle_template (struct work_stuff *work, const char **mangled, string *tname, string *trawname, int is_type, int remember) { int i; int r; int need_comma = 0; int success = 0; int is_java_array = 0; string temp; (*mangled)++; if (is_type) { /* get template name */ if (**mangled == 'z') { int idx; (*mangled)++; (*mangled)++; idx = consume_count_with_underscores (mangled); if (idx == -1 || (work->tmpl_argvec && idx >= work->ntmpl_args) || consume_count_with_underscores (mangled) == -1) return (0); if (work->tmpl_argvec) { string_append (tname, work->tmpl_argvec[idx]); if (trawname) string_append (trawname, work->tmpl_argvec[idx]); } else { string_append_template_idx (tname, idx); if (trawname) string_append_template_idx (trawname, idx); } } else { if ((r = consume_count (mangled)) <= 0 || (int) strlen (*mangled) < r) { return (0); } is_java_array = (work -> options & DMGL_JAVA) && strncmp (*mangled, "JArray1Z", 8) == 0; if (! is_java_array) { string_appendn (tname, *mangled, r); } if (trawname) string_appendn (trawname, *mangled, r); *mangled += r; } } if (!is_java_array) string_append (tname, "<"); /* get size of template parameter list */ if (!get_count (mangled, &r)) { return (0); } if (!is_type) { /* Create an array for saving the template argument values. */ work->tmpl_argvec = XNEWVEC (char *, r); work->ntmpl_args = r; for (i = 0; i < r; i++) work->tmpl_argvec[i] = 0; } for (i = 0; i < r; i++) { if (need_comma) { string_append (tname, ", "); } /* Z for type parameters */ if (**mangled == 'Z') { (*mangled)++; /* temp is initialized in do_type */ success = do_type (work, mangled, &temp); if (success) { string_appends (tname, &temp); if (!is_type) { /* Save the template argument. */ int len = temp.p - temp.b; work->tmpl_argvec[i] = XNEWVEC (char, len + 1); memcpy (work->tmpl_argvec[i], temp.b, len); work->tmpl_argvec[i][len] = '\0'; } } string_delete(&temp); if (!success) { break; } } /* z for template parameters */ else if (**mangled == 'z') { int r2; (*mangled)++; success = demangle_template_template_parm (work, mangled, tname); if (success && (r2 = consume_count (mangled)) > 0 && (int) strlen (*mangled) >= r2) { string_append (tname, " "); string_appendn (tname, *mangled, r2); if (!is_type) { /* Save the template argument. */ int len = r2; work->tmpl_argvec[i] = XNEWVEC (char, len + 1); memcpy (work->tmpl_argvec[i], *mangled, len); work->tmpl_argvec[i][len] = '\0'; } *mangled += r2; } if (!success) { break; } } else { string param; string* s; /* otherwise, value parameter */ /* temp is initialized in do_type */ success = do_type (work, mangled, &temp); string_delete(&temp); if (!success) break; if (!is_type) { s = ¶m; string_init (s); } else s = tname; success = demangle_template_value_parm (work, mangled, s, (type_kind_t) success); if (!success) { if (!is_type) string_delete (s); success = 0; break; } if (!is_type) { int len = s->p - s->b; work->tmpl_argvec[i] = XNEWVEC (char, len + 1); memcpy (work->tmpl_argvec[i], s->b, len); work->tmpl_argvec[i][len] = '\0'; string_appends (tname, s); string_delete (s); } } need_comma = 1; } if (is_java_array) { string_append (tname, "[]"); } else { if (tname->p[-1] == '>') string_append (tname, " "); string_append (tname, ">"); } if (is_type && remember) { const int bindex = register_Btype (work); remember_Btype (work, tname->b, LEN_STRING (tname), bindex); } /* if (work -> static_type) { string_append (declp, *mangled + 1); *mangled += strlen (*mangled); success = 1; } else { success = demangle_args (work, mangled, declp); } } */ return (success); } static int arm_pt (struct work_stuff *work, const char *mangled, int n, const char **anchor, const char **args) { /* Check if ARM template with "__pt__" in it ("parameterized type") */ /* Allow HP also here, because HP's cfront compiler follows ARM to some extent */ if ((ARM_DEMANGLING || HP_DEMANGLING) && (*anchor = strstr (mangled, "__pt__"))) { int len; *args = *anchor + 6; len = consume_count (args); if (len == -1) return 0; if (*args + len == mangled + n && **args == '_') { ++*args; return 1; } } if (AUTO_DEMANGLING || EDG_DEMANGLING) { if ((*anchor = strstr (mangled, "__tm__")) || (*anchor = strstr (mangled, "__ps__")) || (*anchor = strstr (mangled, "__pt__"))) { int len; *args = *anchor + 6; len = consume_count (args); if (len == -1) return 0; if (*args + len == mangled + n && **args == '_') { ++*args; return 1; } } else if ((*anchor = strstr (mangled, "__S"))) { int len; *args = *anchor + 3; len = consume_count (args); if (len == -1) return 0; if (*args + len == mangled + n && **args == '_') { ++*args; return 1; } } } return 0; } static void demangle_arm_hp_template (struct work_stuff *work, const char **mangled, int n, string *declp) { const char *p; const char *args; const char *e = *mangled + n; string arg; /* Check for HP aCC template spec: classXt1t2 where t1, t2 are template args */ if (HP_DEMANGLING && ((*mangled)[n] == 'X')) { char *start_spec_args = NULL; int hold_options; /* First check for and omit template specialization pseudo-arguments, such as in "Spec<#1,#1.*>" */ start_spec_args = strchr (*mangled, '<'); if (start_spec_args && (start_spec_args - *mangled < n)) string_appendn (declp, *mangled, start_spec_args - *mangled); else string_appendn (declp, *mangled, n); (*mangled) += n + 1; string_init (&arg); if (work->temp_start == -1) /* non-recursive call */ work->temp_start = declp->p - declp->b; /* We want to unconditionally demangle parameter types in template parameters. */ hold_options = work->options; work->options |= DMGL_PARAMS; string_append (declp, "<"); while (1) { string_delete (&arg); switch (**mangled) { case 'T': /* 'T' signals a type parameter */ (*mangled)++; if (!do_type (work, mangled, &arg)) goto hpacc_template_args_done; break; case 'U': case 'S': /* 'U' or 'S' signals an integral value */ if (!do_hpacc_template_const_value (work, mangled, &arg)) goto hpacc_template_args_done; break; case 'A': /* 'A' signals a named constant expression (literal) */ if (!do_hpacc_template_literal (work, mangled, &arg)) goto hpacc_template_args_done; break; default: /* Today, 1997-09-03, we have only the above types of template parameters */ /* FIXME: maybe this should fail and return null */ goto hpacc_template_args_done; } string_appends (declp, &arg); /* Check if we're at the end of template args. 0 if at end of static member of template class, _ if done with template args for a function */ if ((**mangled == '\000') || (**mangled == '_')) break; else string_append (declp, ","); } hpacc_template_args_done: string_append (declp, ">"); string_delete (&arg); if (**mangled == '_') (*mangled)++; work->options = hold_options; return; } /* ARM template? (Also handles HP cfront extensions) */ else if (arm_pt (work, *mangled, n, &p, &args)) { int hold_options; string type_str; string_init (&arg); string_appendn (declp, *mangled, p - *mangled); if (work->temp_start == -1) /* non-recursive call */ work->temp_start = declp->p - declp->b; /* We want to unconditionally demangle parameter types in template parameters. */ hold_options = work->options; work->options |= DMGL_PARAMS; string_append (declp, "<"); /* should do error checking here */ while (args < e) { string_delete (&arg); /* Check for type or literal here */ switch (*args) { /* HP cfront extensions to ARM for template args */ /* spec: Xt1Lv1 where t1 is a type, v1 is a literal value */ /* FIXME: We handle only numeric literals for HP cfront */ case 'X': /* A typed constant value follows */ args++; if (!do_type (work, &args, &type_str)) goto cfront_template_args_done; string_append (&arg, "("); string_appends (&arg, &type_str); string_delete (&type_str); string_append (&arg, ")"); if (*args != 'L') goto cfront_template_args_done; args++; /* Now snarf a literal value following 'L' */ if (!snarf_numeric_literal (&args, &arg)) goto cfront_template_args_done; break; case 'L': /* Snarf a literal following 'L' */ args++; if (!snarf_numeric_literal (&args, &arg)) goto cfront_template_args_done; break; default: /* Not handling other HP cfront stuff */ { const char* old_args = args; if (!do_type (work, &args, &arg)) goto cfront_template_args_done; /* Fail if we didn't make any progress: prevent infinite loop. */ if (args == old_args) { work->options = hold_options; return; } } } string_appends (declp, &arg); string_append (declp, ","); } cfront_template_args_done: string_delete (&arg); if (args >= e) --declp->p; /* remove extra comma */ string_append (declp, ">"); work->options = hold_options; } else if (n>10 && strncmp (*mangled, "_GLOBAL_", 8) == 0 && (*mangled)[9] == 'N' && (*mangled)[8] == (*mangled)[10] && strchr (cplus_markers, (*mangled)[8])) { /* A member of the anonymous namespace. */ string_append (declp, "{anonymous}"); } else { if (work->temp_start == -1) /* non-recursive call only */ work->temp_start = 0; /* disable in recursive calls */ string_appendn (declp, *mangled, n); } *mangled += n; } /* Extract a class name, possibly a template with arguments, from the mangled string; qualifiers, local class indicators, etc. have already been dealt with */ static int demangle_class_name (struct work_stuff *work, const char **mangled, string *declp) { int n; int success = 0; n = consume_count (mangled); if (n == -1) return 0; if ((int) strlen (*mangled) >= n) { demangle_arm_hp_template (work, mangled, n, declp); success = 1; } return (success); } /* LOCAL FUNCTION demangle_class -- demangle a mangled class sequence SYNOPSIS static int demangle_class (struct work_stuff *work, const char **mangled, strint *declp) DESCRIPTION DECLP points to the buffer into which demangling is being done. *MANGLED points to the current token to be demangled. On input, it points to a mangled class (I.E. "3foo", "13verylongclass", etc.) On exit, it points to the next token after the mangled class on success, or the first unconsumed token on failure. If the CONSTRUCTOR or DESTRUCTOR flags are set in WORK, then we are demangling a constructor or destructor. In this case we prepend "class::class" or "class::~class" to DECLP. Otherwise, we prepend "class::" to the current DECLP. Reset the constructor/destructor flags once they have been "consumed". This allows demangle_class to be called later during the same demangling, to do normal class demangling. Returns 1 if demangling is successful, 0 otherwise. */ static int demangle_class (struct work_stuff *work, const char **mangled, string *declp) { int success = 0; int btype; string class_name; char *save_class_name_end = 0; string_init (&class_name); btype = register_Btype (work); if (demangle_class_name (work, mangled, &class_name)) { save_class_name_end = class_name.p; if ((work->constructor & 1) || (work->destructor & 1)) { /* adjust so we don't include template args */ if (work->temp_start && (work->temp_start != -1)) { class_name.p = class_name.b + work->temp_start; } string_prepends (declp, &class_name); if (work -> destructor & 1) { string_prepend (declp, "~"); work -> destructor -= 1; } else { work -> constructor -= 1; } } class_name.p = save_class_name_end; remember_Ktype (work, class_name.b, LEN_STRING(&class_name)); remember_Btype (work, class_name.b, LEN_STRING(&class_name), btype); string_prepend (declp, SCOPE_STRING (work)); string_prepends (declp, &class_name); success = 1; } string_delete (&class_name); return (success); } /* Called when there's a "__" in the mangled name, with `scan' pointing to the rightmost guess. Find the correct "__"-sequence where the function name ends and the signature starts, which is ambiguous with GNU mangling. Call demangle_signature here, so we can make sure we found the right one; *mangled will be consumed so caller will not make further calls to demangle_signature. */ static int iterate_demangle_function (struct work_stuff *work, const char **mangled, string *declp, const char *scan) { const char *mangle_init = *mangled; int success = 0; string decl_init; struct work_stuff work_init; if (*(scan + 2) == '\0') return 0; /* Do not iterate for some demangling modes, or if there's only one "__"-sequence. This is the normal case. */ if (ARM_DEMANGLING || LUCID_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING || strstr (scan + 2, "__") == NULL) return demangle_function_name (work, mangled, declp, scan); /* Save state so we can restart if the guess at the correct "__" was wrong. */ string_init (&decl_init); string_appends (&decl_init, declp); memset (&work_init, 0, sizeof work_init); work_stuff_copy_to_from (&work_init, work); /* Iterate over occurrences of __, allowing names and types to have a "__" sequence in them. We must start with the first (not the last) occurrence, since "__" most often occur between independent mangled parts, hence starting at the last occurence inside a signature might get us a "successful" demangling of the signature. */ while (scan[2]) { if (demangle_function_name (work, mangled, declp, scan)) { success = demangle_signature (work, mangled, declp); if (success) break; } /* Reset demangle state for the next round. */ *mangled = mangle_init; string_clear (declp); string_appends (declp, &decl_init); work_stuff_copy_to_from (work, &work_init); /* Leave this underscore-sequence. */ scan += 2; /* Scan for the next "__" sequence. */ while (*scan && (scan[0] != '_' || scan[1] != '_')) scan++; /* Move to last "__" in this sequence. */ while (*scan && *scan == '_') scan++; scan -= 2; } /* Delete saved state. */ delete_work_stuff (&work_init); string_delete (&decl_init); return success; } /* LOCAL FUNCTION demangle_prefix -- consume the mangled name prefix and find signature SYNOPSIS static int demangle_prefix (struct work_stuff *work, const char **mangled, string *declp); DESCRIPTION Consume and demangle the prefix of the mangled name. While processing the function name root, arrange to call demangle_signature if the root is ambiguous. DECLP points to the string buffer into which demangled output is placed. On entry, the buffer is empty. On exit it contains the root function name, the demangled operator name, or in some special cases either nothing or the completely demangled result. MANGLED points to the current pointer into the mangled name. As each token of the mangled name is consumed, it is updated. Upon entry the current mangled name pointer points to the first character of the mangled name. Upon exit, it should point to the first character of the signature if demangling was successful, or to the first unconsumed character if demangling of the prefix was unsuccessful. Returns 1 on success, 0 otherwise. */ static int demangle_prefix (struct work_stuff *work, const char **mangled, string *declp) { int success = 1; const char *scan; int i; if (strlen(*mangled) > 6 && (strncmp(*mangled, "_imp__", 6) == 0 || strncmp(*mangled, "__imp_", 6) == 0)) { /* it's a symbol imported from a PE dynamic library. Check for both new style prefix _imp__ and legacy __imp_ used by older versions of dlltool. */ (*mangled) += 6; work->dllimported = 1; } else if (strlen(*mangled) >= 11 && strncmp(*mangled, "_GLOBAL_", 8) == 0) { char *marker = strchr (cplus_markers, (*mangled)[8]); if (marker != NULL && *marker == (*mangled)[10]) { if ((*mangled)[9] == 'D') { /* it's a GNU global destructor to be executed at program exit */ (*mangled) += 11; work->destructor = 2; if (gnu_special (work, mangled, declp)) return success; } else if ((*mangled)[9] == 'I') { /* it's a GNU global constructor to be executed at program init */ (*mangled) += 11; work->constructor = 2; if (gnu_special (work, mangled, declp)) return success; } } } else if ((ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) && strncmp(*mangled, "__std__", 7) == 0) { /* it's a ARM global destructor to be executed at program exit */ (*mangled) += 7; work->destructor = 2; } else if ((ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) && strncmp(*mangled, "__sti__", 7) == 0) { /* it's a ARM global constructor to be executed at program initial */ (*mangled) += 7; work->constructor = 2; } /* This block of code is a reduction in strength time optimization of: scan = strstr (*mangled, "__"); */ { scan = *mangled; do { scan = strchr (scan, '_'); } while (scan != NULL && *++scan != '_'); if (scan != NULL) --scan; } if (scan != NULL) { /* We found a sequence of two or more '_', ensure that we start at the last pair in the sequence. */ i = strspn (scan, "_"); if (i > 2) { scan += (i - 2); } } if (scan == NULL) { success = 0; } else if (work -> static_type) { if (!ISDIGIT ((unsigned char)scan[0]) && (scan[0] != 't')) { success = 0; } } else if ((scan == *mangled) && (ISDIGIT ((unsigned char)scan[2]) || (scan[2] == 'Q') || (scan[2] == 't') || (scan[2] == 'K') || (scan[2] == 'H'))) { /* The ARM says nothing about the mangling of local variables. But cfront mangles local variables by prepending __ to them. As an extension to ARM demangling we handle this case. */ if ((LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING) && ISDIGIT ((unsigned char)scan[2])) { *mangled = scan + 2; consume_count (mangled); string_append (declp, *mangled); *mangled += strlen (*mangled); success = 1; } else { /* A GNU style constructor starts with __[0-9Qt]. But cfront uses names like __Q2_3foo3bar for nested type names. So don't accept this style of constructor for cfront demangling. A GNU style member-template constructor starts with 'H'. */ if (!(LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING)) work -> constructor += 1; *mangled = scan + 2; } } else if (ARM_DEMANGLING && scan[2] == 'p' && scan[3] == 't') { /* Cfront-style parameterized type. Handled later as a signature. */ success = 1; /* ARM template? */ demangle_arm_hp_template (work, mangled, strlen (*mangled), declp); } else if (EDG_DEMANGLING && ((scan[2] == 't' && scan[3] == 'm') || (scan[2] == 'p' && scan[3] == 's') || (scan[2] == 'p' && scan[3] == 't'))) { /* EDG-style parameterized type. Handled later as a signature. */ success = 1; /* EDG template? */ demangle_arm_hp_template (work, mangled, strlen (*mangled), declp); } else if ((scan == *mangled) && !ISDIGIT ((unsigned char)scan[2]) && (scan[2] != 't')) { /* Mangled name starts with "__". Skip over any leading '_' characters, then find the next "__" that separates the prefix from the signature. */ if (!(ARM_DEMANGLING || LUCID_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) || (arm_special (mangled, declp) == 0)) { while (*scan == '_') { scan++; } if ((scan = strstr (scan, "__")) == NULL || (*(scan + 2) == '\0')) { /* No separator (I.E. "__not_mangled"), or empty signature (I.E. "__not_mangled_either__") */ success = 0; } else return iterate_demangle_function (work, mangled, declp, scan); } } else if (*(scan + 2) != '\0') { /* Mangled name does not start with "__" but does have one somewhere in there with non empty stuff after it. Looks like a global function name. Iterate over all "__":s until the right one is found. */ return iterate_demangle_function (work, mangled, declp, scan); } else { /* Doesn't look like a mangled name */ success = 0; } if (!success && (work->constructor == 2 || work->destructor == 2)) { string_append (declp, *mangled); *mangled += strlen (*mangled); success = 1; } return (success); } /* LOCAL FUNCTION gnu_special -- special handling of gnu mangled strings SYNOPSIS static int gnu_special (struct work_stuff *work, const char **mangled, string *declp); DESCRIPTION Process some special GNU style mangling forms that don't fit the normal pattern. For example: _$_3foo (destructor for class foo) _vt$foo (foo virtual table) _vt$foo$bar (foo::bar virtual table) __vt_foo (foo virtual table, new style with thunks) _3foo$varname (static data member) _Q22rs2tu$vw (static data member) __t6vector1Zii (constructor with template) __thunk_4__$_7ostream (virtual function thunk) */ static int gnu_special (struct work_stuff *work, const char **mangled, string *declp) { int n; int success = 1; const char *p; if ((*mangled)[0] == '_' && strchr (cplus_markers, (*mangled)[1]) != NULL && (*mangled)[2] == '_') { /* Found a GNU style destructor, get past "__" */ (*mangled) += 3; work -> destructor += 1; } else if ((*mangled)[0] == '_' && (((*mangled)[1] == '_' && (*mangled)[2] == 'v' && (*mangled)[3] == 't' && (*mangled)[4] == '_') || ((*mangled)[1] == 'v' && (*mangled)[2] == 't' && strchr (cplus_markers, (*mangled)[3]) != NULL))) { /* Found a GNU style virtual table, get past "_vt" and create the decl. Note that we consume the entire mangled input string, which means that demangle_signature has no work to do. */ if ((*mangled)[2] == 'v') (*mangled) += 5; /* New style, with thunks: "__vt_" */ else (*mangled) += 4; /* Old style, no thunks: "_vt" */ while (**mangled != '\0') { switch (**mangled) { case 'Q': case 'K': success = demangle_qualified (work, mangled, declp, 0, 1); break; case 't': success = demangle_template (work, mangled, declp, 0, 1, 1); break; default: if (ISDIGIT((unsigned char)*mangled[0])) { n = consume_count(mangled); /* We may be seeing a too-large size, or else a "." indicating a static local symbol. In any case, declare victory and move on; *don't* try to use n to allocate. */ if (n > (int) strlen (*mangled)) { success = 1; break; } } else { n = strcspn (*mangled, cplus_markers); } string_appendn (declp, *mangled, n); (*mangled) += n; } p = strpbrk (*mangled, cplus_markers); if (success && ((p == NULL) || (p == *mangled))) { if (p != NULL) { string_append (declp, SCOPE_STRING (work)); (*mangled)++; } } else { success = 0; break; } } if (success) string_append (declp, " virtual table"); } else if ((*mangled)[0] == '_' && (strchr("0123456789Qt", (*mangled)[1]) != NULL) && (p = strpbrk (*mangled, cplus_markers)) != NULL) { /* static data member, "_3foo$varname" for example */ (*mangled)++; switch (**mangled) { case 'Q': case 'K': success = demangle_qualified (work, mangled, declp, 0, 1); break; case 't': success = demangle_template (work, mangled, declp, 0, 1, 1); break; default: n = consume_count (mangled); if (n < 0 || n > (long) strlen (*mangled)) { success = 0; break; } if (n > 10 && strncmp (*mangled, "_GLOBAL_", 8) == 0 && (*mangled)[9] == 'N' && (*mangled)[8] == (*mangled)[10] && strchr (cplus_markers, (*mangled)[8])) { /* A member of the anonymous namespace. There's information about what identifier or filename it was keyed to, but it's just there to make the mangled name unique; we just step over it. */ string_append (declp, "{anonymous}"); (*mangled) += n; /* Now p points to the marker before the N, so we need to update it to the first marker after what we consumed. */ p = strpbrk (*mangled, cplus_markers); break; } string_appendn (declp, *mangled, n); (*mangled) += n; } if (success && (p == *mangled)) { /* Consumed everything up to the cplus_marker, append the variable name. */ (*mangled)++; string_append (declp, SCOPE_STRING (work)); n = strlen (*mangled); string_appendn (declp, *mangled, n); (*mangled) += n; } else { success = 0; } } else if (strncmp (*mangled, "__thunk_", 8) == 0) { int delta; (*mangled) += 8; delta = consume_count (mangled); if (delta == -1) success = 0; else { char *method = internal_cplus_demangle (work, ++*mangled); if (method) { char buf[50]; sprintf (buf, "virtual function thunk (delta:%d) for ", -delta); string_append (declp, buf); string_append (declp, method); free (method); n = strlen (*mangled); (*mangled) += n; } else { success = 0; } } } else if (strncmp (*mangled, "__t", 3) == 0 && ((*mangled)[3] == 'i' || (*mangled)[3] == 'f')) { p = (*mangled)[3] == 'i' ? " type_info node" : " type_info function"; (*mangled) += 4; switch (**mangled) { case 'Q': case 'K': success = demangle_qualified (work, mangled, declp, 0, 1); break; case 't': success = demangle_template (work, mangled, declp, 0, 1, 1); break; default: success = do_type (work, mangled, declp); break; } if (success && **mangled != '\0') success = 0; if (success) string_append (declp, p); } else { success = 0; } return (success); } static void recursively_demangle(struct work_stuff *work, const char **mangled, string *result, int namelength) { char * recurse = (char *)NULL; char * recurse_dem = (char *)NULL; recurse = XNEWVEC (char, namelength + 1); memcpy (recurse, *mangled, namelength); recurse[namelength] = '\000'; recurse_dem = cplus_demangle (recurse, work->options); if (recurse_dem) { string_append (result, recurse_dem); free (recurse_dem); } else { string_appendn (result, *mangled, namelength); } free (recurse); *mangled += namelength; } /* LOCAL FUNCTION arm_special -- special handling of ARM/lucid mangled strings SYNOPSIS static int arm_special (const char **mangled, string *declp); DESCRIPTION Process some special ARM style mangling forms that don't fit the normal pattern. For example: __vtbl__3foo (foo virtual table) __vtbl__3foo__3bar (bar::foo virtual table) */ static int arm_special (const char **mangled, string *declp) { int n; int success = 1; const char *scan; if (strncmp (*mangled, ARM_VTABLE_STRING, ARM_VTABLE_STRLEN) == 0) { /* Found a ARM style virtual table, get past ARM_VTABLE_STRING and create the decl. Note that we consume the entire mangled input string, which means that demangle_signature has no work to do. */ scan = *mangled + ARM_VTABLE_STRLEN; while (*scan != '\0') /* first check it can be demangled */ { n = consume_count (&scan); if (n == -1) { return (0); /* no good */ } scan += n; if (scan[0] == '_' && scan[1] == '_') { scan += 2; } } (*mangled) += ARM_VTABLE_STRLEN; while (**mangled != '\0') { n = consume_count (mangled); if (n == -1 || n > (long) strlen (*mangled)) return 0; string_prependn (declp, *mangled, n); (*mangled) += n; if ((*mangled)[0] == '_' && (*mangled)[1] == '_') { string_prepend (declp, "::"); (*mangled) += 2; } } string_append (declp, " virtual table"); } else { success = 0; } return (success); } /* LOCAL FUNCTION demangle_qualified -- demangle 'Q' qualified name strings SYNOPSIS static int demangle_qualified (struct work_stuff *, const char *mangled, string *result, int isfuncname, int append); DESCRIPTION Demangle a qualified name, such as "Q25Outer5Inner" which is the mangled form of "Outer::Inner". The demangled output is prepended or appended to the result string according to the state of the append flag. If isfuncname is nonzero, then the qualified name we are building is going to be used as a member function name, so if it is a constructor or destructor function, append an appropriate constructor or destructor name. I.E. for the above example, the result for use as a constructor is "Outer::Inner::Inner" and the result for use as a destructor is "Outer::Inner::~Inner". BUGS Numeric conversion is ASCII dependent (FIXME). */ static int demangle_qualified (struct work_stuff *work, const char **mangled, string *result, int isfuncname, int append) { int qualifiers = 0; int success = 1; char num[2]; string temp; string last_name; int bindex = register_Btype (work); /* We only make use of ISFUNCNAME if the entity is a constructor or destructor. */ isfuncname = (isfuncname && ((work->constructor & 1) || (work->destructor & 1))); string_init (&temp); string_init (&last_name); if ((*mangled)[0] == 'K') { /* Squangling qualified name reuse */ int idx; (*mangled)++; idx = consume_count_with_underscores (mangled); if (idx == -1 || idx >= work -> numk) success = 0; else string_append (&temp, work -> ktypevec[idx]); } else switch ((*mangled)[1]) { case '_': /* GNU mangled name with more than 9 classes. The count is preceded by an underscore (to distinguish it from the <= 9 case) and followed by an underscore. */ (*mangled)++; qualifiers = consume_count_with_underscores (mangled); if (qualifiers == -1) success = 0; break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': /* The count is in a single digit. */ num[0] = (*mangled)[1]; num[1] = '\0'; qualifiers = atoi (num); /* If there is an underscore after the digit, skip it. This is said to be for ARM-qualified names, but the ARM makes no mention of such an underscore. Perhaps cfront uses one. */ if ((*mangled)[2] == '_') { (*mangled)++; } (*mangled) += 2; break; case '0': default: success = 0; } if (!success) return success; /* Pick off the names and collect them in the temp buffer in the order in which they are found, separated by '::'. */ while (qualifiers-- > 0) { int remember_K = 1; string_clear (&last_name); if (*mangled[0] == '_') (*mangled)++; if (*mangled[0] == 't') { /* Here we always append to TEMP since we will want to use the template name without the template parameters as a constructor or destructor name. The appropriate (parameter-less) value is returned by demangle_template in LAST_NAME. We do not remember the template type here, in order to match the G++ mangling algorithm. */ success = demangle_template(work, mangled, &temp, &last_name, 1, 0); if (!success) break; } else if (*mangled[0] == 'K') { int idx; (*mangled)++; idx = consume_count_with_underscores (mangled); if (idx == -1 || idx >= work->numk) success = 0; else string_append (&temp, work->ktypevec[idx]); remember_K = 0; if (!success) break; } else { if (EDG_DEMANGLING) { int namelength; /* Now recursively demangle the qualifier * This is necessary to deal with templates in * mangling styles like EDG */ namelength = consume_count (mangled); if (namelength == -1) { success = 0; break; } recursively_demangle(work, mangled, &temp, namelength); } else { string_delete (&last_name); success = do_type (work, mangled, &last_name); if (!success) break; string_appends (&temp, &last_name); } } if (remember_K) remember_Ktype (work, temp.b, LEN_STRING (&temp)); if (qualifiers > 0) string_append (&temp, SCOPE_STRING (work)); } remember_Btype (work, temp.b, LEN_STRING (&temp), bindex); /* If we are using the result as a function name, we need to append the appropriate '::' separated constructor or destructor name. We do this here because this is the most convenient place, where we already have a pointer to the name and the length of the name. */ if (isfuncname) { string_append (&temp, SCOPE_STRING (work)); if (work -> destructor & 1) string_append (&temp, "~"); string_appends (&temp, &last_name); } /* Now either prepend the temp buffer to the result, or append it, depending upon the state of the append flag. */ if (append) string_appends (result, &temp); else { if (!STRING_EMPTY (result)) string_append (&temp, SCOPE_STRING (work)); string_prepends (result, &temp); } string_delete (&last_name); string_delete (&temp); return (success); } /* LOCAL FUNCTION get_count -- convert an ascii count to integer, consuming tokens SYNOPSIS static int get_count (const char **type, int *count) DESCRIPTION Assume that *type points at a count in a mangled name; set *count to its value, and set *type to the next character after the count. There are some weird rules in effect here. If *type does not point at a string of digits, return zero. If *type points at a string of digits followed by an underscore, set *count to their value as an integer, advance *type to point *after the underscore, and return 1. If *type points at a string of digits not followed by an underscore, consume only the first digit. Set *count to its value as an integer, leave *type pointing after that digit, and return 1. The excuse for this odd behavior: in the ARM and HP demangling styles, a type can be followed by a repeat count of the form `Nxy', where: `x' is a single digit specifying how many additional copies of the type to append to the argument list, and `y' is one or more digits, specifying the zero-based index of the first repeated argument in the list. Yes, as you're unmangling the name you can figure this out yourself, but it's there anyway. So, for example, in `bar__3fooFPiN51', the first argument is a pointer to an integer (`Pi'), and then the next five arguments are the same (`N5'), and the first repeat is the function's second argument (`1'). */ static int get_count (const char **type, int *count) { const char *p; int n; if (!ISDIGIT ((unsigned char)**type)) return (0); else { *count = **type - '0'; (*type)++; if (ISDIGIT ((unsigned char)**type)) { p = *type; n = *count; do { n *= 10; n += *p - '0'; p++; } while (ISDIGIT ((unsigned char)*p)); if (*p == '_') { *type = p + 1; *count = n; } } } return (1); } /* RESULT will be initialised here; it will be freed on failure. The value returned is really a type_kind_t. */ static int do_type (struct work_stuff *work, const char **mangled, string *result) { int n; int done; int success; string decl; const char *remembered_type; int type_quals; type_kind_t tk = tk_none; string_init (&decl); string_init (result); done = 0; success = 1; while (success && !done) { int member; switch (**mangled) { /* A pointer type */ case 'P': case 'p': (*mangled)++; if (! (work -> options & DMGL_JAVA)) string_prepend (&decl, "*"); if (tk == tk_none) tk = tk_pointer; break; /* A reference type */ case 'R': (*mangled)++; string_prepend (&decl, "&"); if (tk == tk_none) tk = tk_reference; break; /* An array */ case 'A': { ++(*mangled); if (!STRING_EMPTY (&decl) && (decl.b[0] == '*' || decl.b[0] == '&')) { string_prepend (&decl, "("); string_append (&decl, ")"); } string_append (&decl, "["); if (**mangled != '_') success = demangle_template_value_parm (work, mangled, &decl, tk_integral); if (**mangled == '_') ++(*mangled); string_append (&decl, "]"); break; } /* A back reference to a previously seen type */ case 'T': (*mangled)++; if (!get_count (mangled, &n) || n >= work -> ntypes) { success = 0; } else { remembered_type = work -> typevec[n]; mangled = &remembered_type; } break; /* A function */ case 'F': (*mangled)++; if (!STRING_EMPTY (&decl) && (decl.b[0] == '*' || decl.b[0] == '&')) { string_prepend (&decl, "("); string_append (&decl, ")"); } /* After picking off the function args, we expect to either find the function return type (preceded by an '_') or the end of the string. */ if (!demangle_nested_args (work, mangled, &decl) || (**mangled != '_' && **mangled != '\0')) { success = 0; break; } if (success && (**mangled == '_')) (*mangled)++; break; case 'M': case 'O': { type_quals = TYPE_UNQUALIFIED; member = **mangled == 'M'; (*mangled)++; string_append (&decl, ")"); /* We don't need to prepend `::' for a qualified name; demangle_qualified will do that for us. */ if (**mangled != 'Q') string_prepend (&decl, SCOPE_STRING (work)); if (ISDIGIT ((unsigned char)**mangled)) { n = consume_count (mangled); if (n == -1 || (int) strlen (*mangled) < n) { success = 0; break; } string_prependn (&decl, *mangled, n); *mangled += n; } else if (**mangled == 'X' || **mangled == 'Y') { string temp; do_type (work, mangled, &temp); string_prepends (&decl, &temp); string_delete (&temp); } else if (**mangled == 't') { string temp; string_init (&temp); success = demangle_template (work, mangled, &temp, NULL, 1, 1); if (success) { string_prependn (&decl, temp.b, temp.p - temp.b); string_delete (&temp); } else break; } else if (**mangled == 'Q') { success = demangle_qualified (work, mangled, &decl, /*isfuncnam=*/0, /*append=*/0); if (!success) break; } else { success = 0; break; } string_prepend (&decl, "("); if (member) { switch (**mangled) { case 'C': case 'V': case 'u': type_quals |= code_for_qualifier (**mangled); (*mangled)++; break; default: break; } if (*(*mangled)++ != 'F') { success = 0; break; } } if ((member && !demangle_nested_args (work, mangled, &decl)) || **mangled != '_') { success = 0; break; } (*mangled)++; if (! PRINT_ANSI_QUALIFIERS) { break; } if (type_quals != TYPE_UNQUALIFIED) { APPEND_BLANK (&decl); string_append (&decl, qualifier_string (type_quals)); } break; } case 'G': (*mangled)++; break; case 'C': case 'V': case 'u': if (PRINT_ANSI_QUALIFIERS) { if (!STRING_EMPTY (&decl)) string_prepend (&decl, " "); string_prepend (&decl, demangle_qualifier (**mangled)); } (*mangled)++; break; /* } */ /* fall through */ default: done = 1; break; } } if (success) switch (**mangled) { /* A qualified name, such as "Outer::Inner". */ case 'Q': case 'K': { success = demangle_qualified (work, mangled, result, 0, 1); break; } /* A back reference to a previously seen squangled type */ case 'B': (*mangled)++; if (!get_count (mangled, &n) || n >= work -> numb) success = 0; else string_append (result, work->btypevec[n]); break; case 'X': case 'Y': /* A template parm. We substitute the corresponding argument. */ { int idx; (*mangled)++; idx = consume_count_with_underscores (mangled); if (idx == -1 || (work->tmpl_argvec && idx >= work->ntmpl_args) || consume_count_with_underscores (mangled) == -1) { success = 0; break; } if (work->tmpl_argvec) string_append (result, work->tmpl_argvec[idx]); else string_append_template_idx (result, idx); success = 1; } break; default: success = demangle_fund_type (work, mangled, result); if (tk == tk_none) tk = (type_kind_t) success; break; } if (success) { if (!STRING_EMPTY (&decl)) { string_append (result, " "); string_appends (result, &decl); } } else string_delete (result); string_delete (&decl); if (success) /* Assume an integral type, if we're not sure. */ return (int) ((tk == tk_none) ? tk_integral : tk); else return 0; } /* Given a pointer to a type string that represents a fundamental type argument (int, long, unsigned int, etc) in TYPE, a pointer to the string in which the demangled output is being built in RESULT, and the WORK structure, decode the types and add them to the result. For example: "Ci" => "const int" "Sl" => "signed long" "CUs" => "const unsigned short" The value returned is really a type_kind_t. */ static int demangle_fund_type (struct work_stuff *work, const char **mangled, string *result) { int done = 0; int success = 1; char buf[INTBUF_SIZE + 5 /* 'int%u_t' */]; unsigned int dec = 0; type_kind_t tk = tk_integral; /* First pick off any type qualifiers. There can be more than one. */ while (!done) { switch (**mangled) { case 'C': case 'V': case 'u': if (PRINT_ANSI_QUALIFIERS) { if (!STRING_EMPTY (result)) string_prepend (result, " "); string_prepend (result, demangle_qualifier (**mangled)); } (*mangled)++; break; case 'U': (*mangled)++; APPEND_BLANK (result); string_append (result, "unsigned"); break; case 'S': /* signed char only */ (*mangled)++; APPEND_BLANK (result); string_append (result, "signed"); break; case 'J': (*mangled)++; APPEND_BLANK (result); string_append (result, "__complex"); break; default: done = 1; break; } } /* Now pick off the fundamental type. There can be only one. */ switch (**mangled) { case '\0': case '_': break; case 'v': (*mangled)++; APPEND_BLANK (result); string_append (result, "void"); break; case 'x': (*mangled)++; APPEND_BLANK (result); string_append (result, "long long"); break; case 'l': (*mangled)++; APPEND_BLANK (result); string_append (result, "long"); break; case 'i': (*mangled)++; APPEND_BLANK (result); string_append (result, "int"); break; case 's': (*mangled)++; APPEND_BLANK (result); string_append (result, "short"); break; case 'b': (*mangled)++; APPEND_BLANK (result); string_append (result, "bool"); tk = tk_bool; break; case 'c': (*mangled)++; APPEND_BLANK (result); string_append (result, "char"); tk = tk_char; break; case 'w': (*mangled)++; APPEND_BLANK (result); string_append (result, "wchar_t"); tk = tk_char; break; case 'r': (*mangled)++; APPEND_BLANK (result); string_append (result, "long double"); tk = tk_real; break; case 'd': (*mangled)++; APPEND_BLANK (result); string_append (result, "double"); tk = tk_real; break; case 'f': (*mangled)++; APPEND_BLANK (result); string_append (result, "float"); tk = tk_real; break; case 'G': (*mangled)++; if (!ISDIGIT ((unsigned char)**mangled)) { success = 0; break; } case 'I': (*mangled)++; if (**mangled == '_') { int i; (*mangled)++; for (i = 0; i < (long) sizeof (buf) - 1 && **mangled && **mangled != '_'; (*mangled)++, i++) buf[i] = **mangled; if (**mangled != '_') { success = 0; break; } buf[i] = '\0'; (*mangled)++; } else { strncpy (buf, *mangled, 2); buf[2] = '\0'; *mangled += min (strlen (*mangled), 2); } sscanf (buf, "%x", &dec); sprintf (buf, "int%u_t", dec); APPEND_BLANK (result); string_append (result, buf); break; /* fall through */ /* An explicit type, such as "6mytype" or "7integer" */ case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { int bindex = register_Btype (work); string btype; string_init (&btype); if (demangle_class_name (work, mangled, &btype)) { remember_Btype (work, btype.b, LEN_STRING (&btype), bindex); APPEND_BLANK (result); string_appends (result, &btype); } else success = 0; string_delete (&btype); break; } case 't': { string btype; string_init (&btype); success = demangle_template (work, mangled, &btype, 0, 1, 1); string_appends (result, &btype); string_delete (&btype); break; } default: success = 0; break; } return success ? ((int) tk) : 0; } /* Handle a template's value parameter for HP aCC (extension from ARM) **mangled points to 'S' or 'U' */ static int do_hpacc_template_const_value (struct work_stuff *work, const char **mangled, string *result) { int unsigned_const; if (**mangled != 'U' && **mangled != 'S') return 0; unsigned_const = (**mangled == 'U'); (*mangled)++; switch (**mangled) { case 'N': string_append (result, "-"); /* fall through */ case 'P': (*mangled)++; break; case 'M': /* special case for -2^31 */ string_append (result, "-2147483648"); (*mangled)++; return 1; default: return 0; } /* We have to be looking at an integer now */ if (!(ISDIGIT ((unsigned char)**mangled))) return 0; /* We only deal with integral values for template parameters -- so it's OK to look only for digits */ while (ISDIGIT ((unsigned char)**mangled)) { char_str[0] = **mangled; string_append (result, char_str); (*mangled)++; } if (unsigned_const) string_append (result, "U"); /* FIXME? Some day we may have 64-bit (or larger :-) ) constants with L or LL suffixes. pai/1997-09-03 */ return 1; /* success */ } /* Handle a template's literal parameter for HP aCC (extension from ARM) **mangled is pointing to the 'A' */ static int do_hpacc_template_literal (struct work_stuff *work, const char **mangled, string *result) { int literal_len = 0; char * recurse; char * recurse_dem; if (**mangled != 'A') return 0; (*mangled)++; literal_len = consume_count (mangled); if (literal_len <= 0) return 0; /* Literal parameters are names of arrays, functions, etc. and the canonical representation uses the address operator */ string_append (result, "&"); /* Now recursively demangle the literal name */ recurse = XNEWVEC (char, literal_len + 1); memcpy (recurse, *mangled, literal_len); recurse[literal_len] = '\000'; recurse_dem = cplus_demangle (recurse, work->options); if (recurse_dem) { string_append (result, recurse_dem); free (recurse_dem); } else { string_appendn (result, *mangled, literal_len); } (*mangled) += literal_len; free (recurse); return 1; } static int snarf_numeric_literal (const char **args, string *arg) { if (**args == '-') { char_str[0] = '-'; string_append (arg, char_str); (*args)++; } else if (**args == '+') (*args)++; if (!ISDIGIT ((unsigned char)**args)) return 0; while (ISDIGIT ((unsigned char)**args)) { char_str[0] = **args; string_append (arg, char_str); (*args)++; } return 1; } /* Demangle the next argument, given by MANGLED into RESULT, which *should be an uninitialized* string. It will be initialized here, and free'd should anything go wrong. */ static int do_arg (struct work_stuff *work, const char **mangled, string *result) { /* Remember where we started so that we can record the type, for non-squangling type remembering. */ const char *start = *mangled; string_init (result); if (work->nrepeats > 0) { --work->nrepeats; if (work->previous_argument == 0) return 0; /* We want to reissue the previous type in this argument list. */ string_appends (result, work->previous_argument); return 1; } if (**mangled == 'n') { /* A squangling-style repeat. */ (*mangled)++; work->nrepeats = consume_count(mangled); if (work->nrepeats <= 0) /* This was not a repeat count after all. */ return 0; if (work->nrepeats > 9) { if (**mangled != '_') /* The repeat count should be followed by an '_' in this case. */ return 0; else (*mangled)++; } /* Now, the repeat is all set up. */ return do_arg (work, mangled, result); } /* Save the result in WORK->previous_argument so that we can find it if it's repeated. Note that saving START is not good enough: we do not want to add additional types to the back-referenceable type vector when processing a repeated type. */ if (work->previous_argument) string_delete (work->previous_argument); else work->previous_argument = XNEW (string); if (!do_type (work, mangled, work->previous_argument)) return 0; string_appends (result, work->previous_argument); remember_type (work, start, *mangled - start); return 1; } static void remember_type (struct work_stuff *work, const char *start, int len) { char *tem; if (work->forgetting_types) return; if (work -> ntypes >= work -> typevec_size) { if (work -> typevec_size == 0) { work -> typevec_size = 3; work -> typevec = XNEWVEC (char *, work->typevec_size); } else { work -> typevec_size *= 2; work -> typevec = XRESIZEVEC (char *, work->typevec, work->typevec_size); } } tem = XNEWVEC (char, len + 1); memcpy (tem, start, len); tem[len] = '\0'; work -> typevec[work -> ntypes++] = tem; } /* Remember a K type class qualifier. */ static void remember_Ktype (struct work_stuff *work, const char *start, int len) { char *tem; if (work -> numk >= work -> ksize) { if (work -> ksize == 0) { work -> ksize = 5; work -> ktypevec = XNEWVEC (char *, work->ksize); } else { work -> ksize *= 2; work -> ktypevec = XRESIZEVEC (char *, work->ktypevec, work->ksize); } } tem = XNEWVEC (char, len + 1); memcpy (tem, start, len); tem[len] = '\0'; work -> ktypevec[work -> numk++] = tem; } /* Register a B code, and get an index for it. B codes are registered as they are seen, rather than as they are completed, so map > registers map > as B0, and temp as B1 */ static int register_Btype (struct work_stuff *work) { int ret; if (work -> numb >= work -> bsize) { if (work -> bsize == 0) { work -> bsize = 5; work -> btypevec = XNEWVEC (char *, work->bsize); } else { work -> bsize *= 2; work -> btypevec = XRESIZEVEC (char *, work->btypevec, work->bsize); } } ret = work -> numb++; work -> btypevec[ret] = NULL; return(ret); } /* Store a value into a previously registered B code type. */ static void remember_Btype (struct work_stuff *work, const char *start, int len, int index) { char *tem; tem = XNEWVEC (char, len + 1); memcpy (tem, start, len); tem[len] = '\0'; work -> btypevec[index] = tem; } /* Lose all the info related to B and K type codes. */ static void forget_B_and_K_types (struct work_stuff *work) { int i; while (work -> numk > 0) { i = --(work -> numk); if (work -> ktypevec[i] != NULL) { free (work -> ktypevec[i]); work -> ktypevec[i] = NULL; } } while (work -> numb > 0) { i = --(work -> numb); if (work -> btypevec[i] != NULL) { free (work -> btypevec[i]); work -> btypevec[i] = NULL; } } } /* Forget the remembered types, but not the type vector itself. */ static void forget_types (struct work_stuff *work) { int i; while (work -> ntypes > 0) { i = --(work -> ntypes); if (work -> typevec[i] != NULL) { free (work -> typevec[i]); work -> typevec[i] = NULL; } } } /* Process the argument list part of the signature, after any class spec has been consumed, as well as the first 'F' character (if any). For example: "__als__3fooRT0" => process "RT0" "complexfunc5__FPFPc_PFl_i" => process "PFPc_PFl_i" DECLP must be already initialised, usually non-empty. It won't be freed on failure. Note that g++ differs significantly from ARM and lucid style mangling with regards to references to previously seen types. For example, given the source fragment: class foo { public: foo::foo (int, foo &ia, int, foo &ib, int, foo &ic); }; foo::foo (int, foo &ia, int, foo &ib, int, foo &ic) { ia = ib = ic; } void foo (int, foo &ia, int, foo &ib, int, foo &ic) { ia = ib = ic; } g++ produces the names: __3fooiRT0iT2iT2 foo__FiR3fooiT1iT1 while lcc (and presumably other ARM style compilers as well) produces: foo__FiR3fooT1T2T1T2 __ct__3fooFiR3fooT1T2T1T2 Note that g++ bases its type numbers starting at zero and counts all previously seen types, while lucid/ARM bases its type numbers starting at one and only considers types after it has seen the 'F' character indicating the start of the function args. For lucid/ARM style, we account for this difference by discarding any previously seen types when we see the 'F' character, and subtracting one from the type number reference. */ static int demangle_args (struct work_stuff *work, const char **mangled, string *declp) { string arg; int need_comma = 0; int r; int t; const char *tem; char temptype; if (PRINT_ARG_TYPES) { string_append (declp, "("); if (**mangled == '\0') { string_append (declp, "void"); } } while ((**mangled != '_' && **mangled != '\0' && **mangled != 'e') || work->nrepeats > 0) { if ((**mangled == 'N') || (**mangled == 'T')) { temptype = *(*mangled)++; if (temptype == 'N') { if (!get_count (mangled, &r)) { return (0); } } else { r = 1; } if ((HP_DEMANGLING || ARM_DEMANGLING || EDG_DEMANGLING) && work -> ntypes >= 10) { /* If we have 10 or more types we might have more than a 1 digit index so we'll have to consume the whole count here. This will lose if the next thing is a type name preceded by a count but it's impossible to demangle that case properly anyway. Eg if we already have 12 types is T12Pc "(..., type1, Pc, ...)" or "(..., type12, char *, ...)" */ if ((t = consume_count(mangled)) <= 0) { return (0); } } else { if (!get_count (mangled, &t)) { return (0); } } if (LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) { t--; } /* Validate the type index. Protect against illegal indices from malformed type strings. */ if ((t < 0) || (t >= work -> ntypes)) { return (0); } while (work->nrepeats > 0 || --r >= 0) { tem = work -> typevec[t]; if (need_comma && PRINT_ARG_TYPES) { string_append (declp, ", "); } if (!do_arg (work, &tem, &arg)) { return (0); } if (PRINT_ARG_TYPES) { string_appends (declp, &arg); } string_delete (&arg); need_comma = 1; } } else { if (need_comma && PRINT_ARG_TYPES) string_append (declp, ", "); if (!do_arg (work, mangled, &arg)) return (0); if (PRINT_ARG_TYPES) string_appends (declp, &arg); string_delete (&arg); need_comma = 1; } } if (**mangled == 'e') { (*mangled)++; if (PRINT_ARG_TYPES) { if (need_comma) { string_append (declp, ","); } string_append (declp, "..."); } } if (PRINT_ARG_TYPES) { string_append (declp, ")"); } return (1); } /* Like demangle_args, but for demangling the argument lists of function and method pointers or references, not top-level declarations. */ static int demangle_nested_args (struct work_stuff *work, const char **mangled, string *declp) { string* saved_previous_argument; int result; int saved_nrepeats; /* The G++ name-mangling algorithm does not remember types on nested argument lists, unless -fsquangling is used, and in that case the type vector updated by remember_type is not used. So, we turn off remembering of types here. */ ++work->forgetting_types; /* For the repeat codes used with -fsquangling, we must keep track of the last argument. */ saved_previous_argument = work->previous_argument; saved_nrepeats = work->nrepeats; work->previous_argument = 0; work->nrepeats = 0; /* Actually demangle the arguments. */ result = demangle_args (work, mangled, declp); /* Restore the previous_argument field. */ if (work->previous_argument) { string_delete (work->previous_argument); free ((char *) work->previous_argument); } work->previous_argument = saved_previous_argument; --work->forgetting_types; work->nrepeats = saved_nrepeats; return result; } /* Returns 1 if a valid function name was found or 0 otherwise. */ static int demangle_function_name (struct work_stuff *work, const char **mangled, string *declp, const char *scan) { size_t i; string type; const char *tem; string_appendn (declp, (*mangled), scan - (*mangled)); string_need (declp, 1); *(declp -> p) = '\0'; /* Consume the function name, including the "__" separating the name from the signature. We are guaranteed that SCAN points to the separator. */ (*mangled) = scan + 2; /* We may be looking at an instantiation of a template function: foo__Xt1t2_Ft3t4, where t1, t2, ... are template arguments and a following _F marks the start of the function arguments. Handle the template arguments first. */ if (HP_DEMANGLING && (**mangled == 'X')) { demangle_arm_hp_template (work, mangled, 0, declp); /* This leaves MANGLED pointing to the 'F' marking func args */ } if (LUCID_DEMANGLING || ARM_DEMANGLING || HP_DEMANGLING || EDG_DEMANGLING) { /* See if we have an ARM style constructor or destructor operator. If so, then just record it, clear the decl, and return. We can't build the actual constructor/destructor decl until later, when we recover the class name from the signature. */ if (strcmp (declp -> b, "__ct") == 0) { work -> constructor += 1; string_clear (declp); return 1; } else if (strcmp (declp -> b, "__dt") == 0) { work -> destructor += 1; string_clear (declp); return 1; } } if (declp->p - declp->b >= 3 && declp->b[0] == 'o' && declp->b[1] == 'p' && strchr (cplus_markers, declp->b[2]) != NULL) { /* see if it's an assignment expression */ if (declp->p - declp->b >= 10 /* op$assign_ */ && memcmp (declp->b + 3, "assign_", 7) == 0) { for (i = 0; i < ARRAY_SIZE (optable); i++) { int len = declp->p - declp->b - 10; if ((int) strlen (optable[i].in) == len && memcmp (optable[i].in, declp->b + 10, len) == 0) { string_clear (declp); string_append (declp, "operator"); string_append (declp, optable[i].out); string_append (declp, "="); break; } } } else { for (i = 0; i < ARRAY_SIZE (optable); i++) { int len = declp->p - declp->b - 3; if ((int) strlen (optable[i].in) == len && memcmp (optable[i].in, declp->b + 3, len) == 0) { string_clear (declp); string_append (declp, "operator"); string_append (declp, optable[i].out); break; } } } } else if (declp->p - declp->b >= 5 && memcmp (declp->b, "type", 4) == 0 && strchr (cplus_markers, declp->b[4]) != NULL) { /* type conversion operator */ tem = declp->b + 5; if (do_type (work, &tem, &type)) { string_clear (declp); string_append (declp, "operator "); string_appends (declp, &type); string_delete (&type); } } else if (declp->b[0] == '_' && declp->b[1] == '_' && declp->b[2] == 'o' && declp->b[3] == 'p') { /* ANSI. */ /* type conversion operator. */ tem = declp->b + 4; if (do_type (work, &tem, &type)) { string_clear (declp); string_append (declp, "operator "); string_appends (declp, &type); string_delete (&type); } } else if (declp->b[0] == '_' && declp->b[1] == '_' && ISLOWER((unsigned char)declp->b[2]) && ISLOWER((unsigned char)declp->b[3])) { if (declp->b[4] == '\0') { /* Operator. */ for (i = 0; i < ARRAY_SIZE (optable); i++) { if (strlen (optable[i].in) == 2 && memcmp (optable[i].in, declp->b + 2, 2) == 0) { string_clear (declp); string_append (declp, "operator"); string_append (declp, optable[i].out); break; } } } else { if (declp->b[2] == 'a' && declp->b[5] == '\0') { /* Assignment. */ for (i = 0; i < ARRAY_SIZE (optable); i++) { if (strlen (optable[i].in) == 3 && memcmp (optable[i].in, declp->b + 2, 3) == 0) { string_clear (declp); string_append (declp, "operator"); string_append (declp, optable[i].out); break; } } } } } /* If a function name was obtained but it's not valid, we were not successful. */ if (LEN_STRING (declp) == 1 && declp->b[0] == '.') return 0; else return 1; } /* a mini string-handling package */ static void string_need (string *s, int n) { int tem; if (s->b == NULL) { if (n < 32) { n = 32; } s->p = s->b = XNEWVEC (char, n); s->e = s->b + n; } else if (s->e - s->p < n) { tem = s->p - s->b; n += tem; n *= 2; s->b = XRESIZEVEC (char, s->b, n); s->p = s->b + tem; s->e = s->b + n; } } static void string_delete (string *s) { if (s->b != NULL) { free (s->b); s->b = s->e = s->p = NULL; } } static void string_init (string *s) { s->b = s->p = s->e = NULL; } static void string_clear (string *s) { s->p = s->b; } #if 0 static int string_empty (string *s) { return (s->b == s->p); } #endif static void string_append (string *p, const char *s) { int n; if (s == NULL || *s == '\0') return; n = strlen (s); string_need (p, n); memcpy (p->p, s, n); p->p += n; } static void string_appends (string *p, string *s) { int n; if (s->b != s->p) { n = s->p - s->b; string_need (p, n); memcpy (p->p, s->b, n); p->p += n; } } static void string_appendn (string *p, const char *s, int n) { if (n != 0) { string_need (p, n); memcpy (p->p, s, n); p->p += n; } } static void string_prepend (string *p, const char *s) { if (s != NULL && *s != '\0') { string_prependn (p, s, strlen (s)); } } static void string_prepends (string *p, string *s) { if (s->b != s->p) { string_prependn (p, s->b, s->p - s->b); } } static void string_prependn (string *p, const char *s, int n) { char *q; if (n != 0) { string_need (p, n); for (q = p->p - 1; q >= p->b; q--) { q[n] = q[0]; } memcpy (p->b, s, n); p->p += n; } } static void string_append_template_idx (string *s, int idx) { char buf[INTBUF_SIZE + 1 /* 'T' */]; sprintf(buf, "T%d", idx); string_append (s, buf); } ht-2.0.22/htcoffimg.cc0000644000175000001440000000607210615341616011412 00000000000000/* * HT Editor * htcoffimg.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "log.h" #include "htnewexe.h" #include "htpal.h" #include "htcoffimg.h" #include "strtools.h" #include "formats.h" #include "coff_s.h" #include "htanaly.h" #include "coff_analy.h" static ht_view *htcoffimage_init(Bounds *b, File *file, ht_format_group *group) { ht_coff_shared_data *coff_shared = (ht_coff_shared_data *)group->get_shared_data(); String fn; LOG("%y: COFF: loading image (starting analyser)...", &file->getFilename(fn)); CoffAnalyser *p = new CoffAnalyser(); p->init(coff_shared, file); Bounds c = *b; ht_group *g = new ht_group(); g->init(&c, VO_RESIZE, DESC_COFF_IMAGE"-g"); AnalyInfoline *head; c.y+=2; c.h-=2; ht_coff_aviewer *v = new ht_coff_aviewer(); v->init(&c, DESC_COFF_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, p, coff_shared); c.y-=2; c.h=2; head=new AnalyInfoline(); head->init(&c, v, ANALY_STATUS_DEFAULT); v->attachInfoline(head); /* search for lowest/highest */ RVA l=(RVA)-1, h=0; COFF_SECTION_HEADER *s=coff_shared->sections.sections; for (uint i=0; isections.section_count; i++) { if (s->data_address < l) l = s->data_address; if ((s->data_address + s->data_size > h) && s->data_size) { h = s->data_address + s->data_size - 1; } s++; } /**/ Address *low = p->createAddress32(l); Address *high = p->createAddress32(h); ht_analy_sub *analy=new ht_analy_sub(); analy->init(file, v, p, low, high); v->analy_sub = analy; v->insertsub(analy); delete high; delete low; v->sendmsg(msg_complete_init, 0); // entrypoint switch (coff_shared->opt_magic) { case COFF_OPTMAGIC_COFF32: Address *tmpaddr = p->createAddress32(coff_shared->coff32header.entrypoint_address); v->gotoAddress(tmpaddr, NULL); delete tmpaddr; break; } g->insert(head); g->insert(v); g->setpalette(palkey_generic_window_default); coff_shared->v_image=v; return g; } format_viewer_if htcoffimage_if = { htcoffimage_init, 0 }; /* * CLASS ht_coff_aviewer */ void ht_coff_aviewer::init(Bounds *b, const char *desc, int caps, File *File, ht_format_group *format_group, Analyser *Analy, ht_coff_shared_data *Coff_shared) { ht_aviewer::init(b, desc, caps, File, format_group, Analy); coff_shared = Coff_shared; file = File; } void ht_coff_aviewer::setAnalyser(Analyser *a) { ((CoffAnalyser *)a)->coff_shared = coff_shared; ((CoffAnalyser *)a)->file = file; analy = a; analy_sub->setAnalyser(a); } ht-2.0.22/htxbeimg.cc0000644000175000001440000001271210615341624011250 00000000000000/* * HT Editor * htxbeimg.cc * * Copyright (C) 2003 Stefan Esser * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "log.h" #include "formats.h" #include "htpal.h" #include "htxbeimg.h" #include "strtools.h" #include "xbe_analy.h" #include "xbestruct.h" #include "snprintf.h" static ht_view *htxbeimage_init(Bounds *b, File *file, ht_format_group *group) { ht_xbe_shared_data *xbe_shared=(ht_xbe_shared_data *)group->get_shared_data(); String fn; LOG("%y: XBE: loading image (starting analyser)...", &file->getFilename(fn)); XBEAnalyser *p = new XBEAnalyser(); p->init(xbe_shared, file); Bounds c=*b; ht_group *g=new ht_group(); g->init(&c, VO_RESIZE, DESC_XBE_IMAGE"-g"); AnalyInfoline *head; c.y+=2; c.h-=2; ht_xbe_aviewer *v=new ht_xbe_aviewer(); v->init(&c, DESC_XBE_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, p, xbe_shared); c.y-=2; c.h=2; head=new AnalyInfoline(); head->init(&c, v, ANALY_STATUS_DEFAULT); v->attachInfoline(head); /* search for lowest/highest */ RVA l=(RVA)-1, h=0; XBE_SECTION_HEADER *s=xbe_shared->sections.sections; for (uint i=0; isections.number_of_sections; i++) { if (s->virtual_address < l) l = s->virtual_address; if ((s->virtual_address + s->virtual_size > h) && s->virtual_size) h = s->virtual_address + s->virtual_size - 1; s++; } /**/ Address *low; Address *high; l+=xbe_shared->header.base_address; h+=xbe_shared->header.base_address; low = p->createAddress32(l); high = p->createAddress32(h); ht_analy_sub *analy=new ht_analy_sub(); analy->init(file, v, p, low, high); delete low; delete high; v->analy_sub = analy; v->insertsub(analy); v->sendmsg(msg_complete_init, 0); Address *tmpaddr; tmpaddr = p->createAddress32(xbe_shared->header.entry_point); v->gotoAddress(tmpaddr, NULL); delete tmpaddr; g->insert(head); g->insert(v); g->setpalette(palkey_generic_window_default); xbe_shared->v_image=v; return g; } format_viewer_if htxbeimage_if = { htxbeimage_init, 0 }; static int xbe_viewer_func_rva(eval_scalar *result, eval_int *i) { ht_xbe_aviewer *aviewer = (ht_xbe_aviewer*)eval_get_context(); RVA rva = i->value; viewer_pos p; FileOfs ofs; if (xbe_rva_to_ofs(&aviewer->xbe_shared->sections, rva, &ofs) && aviewer->offset_to_pos(ofs, &p)) { Address *a; int b; aviewer->convertViewerPosToAddress(p, &a); a->putIntoArray((byte*)&b); delete a; scalar_create_int_c(result, b); return 1; } else { set_eval_error("invalid file offset or no corresponding RVA for '0%xh'", rva); } return 0; } static int xbe_viewer_func_section_int(eval_scalar *result, eval_int *q) { ht_xbe_aviewer *aviewer = (ht_xbe_aviewer*)eval_get_context(); sint64 i = q->value-1; if (i >= 0 && (i < aviewer->xbe_shared->sections.number_of_sections)) { viewer_pos p; FileOfs ofs; if (xbe_rva_to_ofs(&aviewer->xbe_shared->sections, aviewer->xbe_shared->sections.sections[i].virtual_address, &ofs) && aviewer->offset_to_pos(ofs, &p)) { Address *a; int b; aviewer->convertViewerPosToAddress(p, &a); a->putIntoArray((byte*)&b); delete a; scalar_create_int_c(result, b); return 1; } else { // set_eval_error("invalid file offset or no corresponding RVA for '0%xh'", rva); } } else { set_eval_error("no section number %qd", &q->value); } return 0; } static int xbe_viewer_func_section_str(eval_scalar *result, eval_str *str) { ht_xbe_aviewer *aviewer = (ht_xbe_aviewer*)eval_get_context(); int section; if (xbe_section_name_to_section(&aviewer->xbe_shared->sections, str->value, §ion)) { eval_scalar i; scalar_create_int_c(&i, section+1); return xbe_viewer_func_section_int(result, &i.scalar.integer); } return 0; } static int xbe_viewer_func_section(eval_scalar *result, eval_scalar *q) { if (q->type == SCALAR_STR) return xbe_viewer_func_section_str(result, &q->scalar.str); else { eval_int i; scalar_context_int(q, &i); return xbe_viewer_func_section_int(result, &i); } } /* * ht_xbe_aviewer */ void ht_xbe_aviewer::init(Bounds *b, const char *desc, int caps, File *File, ht_format_group *format_group, Analyser *Analy, ht_xbe_shared_data *XBE_shared) { ht_aviewer::init(b, desc, caps, File, format_group, Analy); xbe_shared = XBE_shared; } bool ht_xbe_aviewer::func_handler(eval_scalar *result, char *name, eval_scalarlist *params) { eval_func myfuncs[] = { {"rva", (void*)&xbe_viewer_func_rva, {SCALAR_INT}, "returns address of rva"}, {"section", (void*)&xbe_viewer_func_section, {SCALAR_ANY}, "returns address of section named param1 if param1 is a string\n" "returns address of section with index param1 otherwise"}, {NULL} }; if (std_eval_func_handler(result, name, params, myfuncs)) return true; return ht_aviewer::func_handler(result, name, params); } void ht_xbe_aviewer::setAnalyser(Analyser *a) { ((XBEAnalyser *)a)->xbe_shared = xbe_shared; ((XBEAnalyser *)a)->file = file; analy = a; analy_sub->setAnalyser(a); } ht-2.0.22/htmzhead.h0000644000175000001440000000155310206756710011112 00000000000000/* * HT Editor * htmzhead.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTMZHEAD_H__ #define __HTMZHEAD_H__ #include "htobj.h" #include "formats.h" extern format_viewer_if htmzheader_if; #endif /* !__HTMZHEAD_H__ */ ht-2.0.22/htcoffhd.cc0000644000175000001440000002422710771304342011231 00000000000000/* * HT Editor * htcoffhd.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "atom.h" #include "htcoff.h" #include "htcoffhd.h" #include "httag.h" #include "strtools.h" #include "formats.h" #include "snprintf.h" #include int_hash coff_machines[] = { // {COFF_MACHINE_UNKNOWN, "generic"}, {COFF_MACHINE_I386, "Intel 386"}, {COFF_MACHINE_I486, "Intel 486"}, {COFF_MACHINE_I586, "Intel 586"}, {COFF_MACHINE_R3000BE, "R3000(be)"}, {COFF_MACHINE_R3000, "R3000"}, {COFF_MACHINE_R4000, "R4000"}, {COFF_MACHINE_R10000, "R10000"}, {COFF_MACHINE_ALPHA, "Alpha AXP"}, {COFF_MACHINE_SH3, "Hitachi SH3"}, {COFF_MACHINE_SH4, "Hitachi SH4"}, {COFF_MACHINE_ARM, "ARM"}, {COFF_MACHINE_THUMB, "THUMB"}, {COFF_MACHINE_POWERPC_LE, "PowerPC (little-endian)"}, {COFF_MACHINE_POWERPC_BE, "PowerPC (big-endian)"}, {COFF_MACHINE_POWERPC64_BE, "PowerPC64 (big-endian)"}, {COFF_MACHINE_IA64, "Intel IA64"}, {COFF_MACHINE_MIPS16, "MIPS16"}, {COFF_MACHINE_68k, "Motorola 68k"}, {COFF_MACHINE_ALPHA_AXP_64, "Alpha AXP 64"}, {COFF_MACHINE_MIPSf, "MIPSf"}, {COFF_MACHINE_MIPS16f, "MIPS16f"}, {COFF_MACHINE_AMD64, "x86-64 (AMD Opteron)"}, {0, 0} }; static int_hash coff_optional_magics[] = { {COFF_OPTMAGIC_ROMIMAGE, "ROM image"}, {COFF_OPTMAGIC_COFF32, "COFF"}, {0, 0} }; static int_hash coff_optional_sizes[] = { {COFF_OPTSIZE_COFF32, "COFF32"}, {COFF_OPTSIZE_XCOFF32, "XCOFF32"}, {0, 0} }; ht_tag_flags_s coff_characteristics[] = { {-1, "COFF - file characteristics"}, {0, "[00] relocations stripped"}, {1, "[01] file is executable"}, {2, "[02] line numbers stripped"}, {3, "[03] local symbols stripped"}, {4, "[04] aggressively trim working set"}, {5, "[05] >2 GiB addresses aware"}, {6, "[06] * reserved"}, {7, "[07] low bytes of machine uint16 are reversed"}, {8, "[08] 32 bit machine"}, {9, "[09] debugging information stripped"}, {10, "[10] run from swap if image on removable media"}, {11, "[11] run from swap if image is on net"}, {12, "[12] system file"}, {13, "[13] file is dynamic link library (dll)"}, {14, "[14] single processor (UP) only"}, {15, "[15] high bytes of machine uint16 are reversed"}, {0, 0} }; ht_tag_flags_s coff_section_characteristics[] = { {-1, "COFF - section characteristics"}, {0, "[00] * reserved"}, {1, "[01] * reserved"}, {2, "[02] * reserved"}, {3, "[03] * reserved"}, {4, "[04] * reserved"}, {5, "[05] code"}, {6, "[06] initialized"}, {7, "[07] uninitialized"}, {8, "[08] * reserved"}, {9, "[09] * reserved"}, {10, "[10] * reserved"}, {11, "[11] link remove"}, {12, "[12] comdat"}, {13, "[13] * reserved"}, {14, "[14] * reserved (obsolete - protected)"}, {15, "[15] fardata"}, {16, "[16] * reserved (obsolete - sysheap)"}, {17, "[17] purgeable/16bit?"}, {18, "[18] locked"}, {19, "[19] preload"}, {20, "[20] * reserved"}, {21, "[21] * reserved"}, {22, "[22] * reserved"}, {23, "[23] * reserved"}, {24, "[24] extended relocations"}, {25, "[25] discardable"}, {26, "[26] not cachable"}, {27, "[27] not pageable"}, {28, "[28] shareable"}, {29, "[29] executable"}, {30, "[30] readable"}, {31, "[31] writable"}, {0, 0} }; ht_mask_ptable coffheader[]= { {"machine", STATICTAG_EDIT_WORD_VE("00000000")" "STATICTAG_DESC_WORD_VE("00000000", ATOM_COFF_MACHINES_STR)}, {"number of sections", STATICTAG_EDIT_WORD_VE("00000002")}, {"time-date stamp", STATICTAG_EDIT_TIME_VE("00000004")}, {"pointer to symbol table", STATICTAG_EDIT_DWORD_VE("00000008")}, {"number of symbols", STATICTAG_EDIT_DWORD_VE("0000000c")}, {"size of optional header", STATICTAG_EDIT_WORD_VE("00000010")" "STATICTAG_DESC_WORD_VE("00000010", ATOM_COFF_OPTIONAL_SIZES_STR)}, {"characteristics", STATICTAG_EDIT_WORD_VE("00000012")" "STATICTAG_FLAGS("00000012", ATOM_COFF_CHARACTERISTICS_STR)}, {0, 0} }; ht_mask_ptable coff32header[] = { {"optional magic", STATICTAG_EDIT_WORD_VE("00000014")" "STATICTAG_DESC_WORD_VE("00000014", ATOM_COFF_OPTIONAL_MAGICS_STR)}, {"major linker version", STATICTAG_EDIT_BYTE("00000016")}, {"minor linker version", STATICTAG_EDIT_BYTE("00000017")}, {"size of code", STATICTAG_EDIT_DWORD_VE("00000018")}, {"size of data", STATICTAG_EDIT_DWORD_VE("0000001c")}, {"size of bss", STATICTAG_EDIT_DWORD_VE("00000020")}, {"entry point", STATICTAG_EDIT_DWORD_VE("00000024")}, {"code base", STATICTAG_EDIT_DWORD_VE("00000028")}, {"data base", STATICTAG_EDIT_DWORD_VE("0000002c")}, {0, 0} }; ht_mask_ptable xcoff32header[] = { {"optional magic", STATICTAG_EDIT_WORD_VE("00000014")" "STATICTAG_DESC_WORD_VE("00000014", ATOM_COFF_OPTIONAL_MAGICS_STR)}, {"major linker version", STATICTAG_EDIT_BYTE("00000016")}, {"minor linker version", STATICTAG_EDIT_BYTE("00000017")}, {"size of code", STATICTAG_EDIT_DWORD_VE("00000018")}, {"size of data", STATICTAG_EDIT_DWORD_VE("0000001c")}, {"size of bss", STATICTAG_EDIT_DWORD_VE("00000020")}, {"address of entrypoint", STATICTAG_EDIT_DWORD_VE("00000024")}, {"code base", STATICTAG_EDIT_DWORD_VE("00000028")}, {"data base", STATICTAG_EDIT_DWORD_VE("0000002c")}, {"address of TOC anchor", STATICTAG_EDIT_DWORD_VE("00000030")}, {"section of entrypoint", STATICTAG_EDIT_WORD_VE("00000034")}, {"section of .text", STATICTAG_EDIT_WORD_VE("00000036")}, {"section of .data", STATICTAG_EDIT_WORD_VE("00000038")}, {"section of TOC", STATICTAG_EDIT_WORD_VE("0000003a")}, {"section of loader data", STATICTAG_EDIT_WORD_VE("0000003c")}, {"section of .bss", STATICTAG_EDIT_WORD_VE("0000003e")}, {"max. alignment for .text", STATICTAG_EDIT_WORD_VE("00000040")}, {"max. alignment for .data", STATICTAG_EDIT_WORD_VE("00000042")}, {"module type field", STATICTAG_EDIT_WORD_VE("00000044")}, {"cpu type", STATICTAG_EDIT_BYTE("00000046")}, {"cpu type (reserved)", STATICTAG_EDIT_BYTE("00000047")}, {"max. stack size", STATICTAG_EDIT_DWORD_VE("00000048")}, {"max. data size", STATICTAG_EDIT_DWORD_VE("0000004c")}, {"reserved for debuggers", STATICTAG_EDIT_DWORD_VE("00000050")}, {"reserved field", STATICTAG_EDIT_DWORD_VE("00000054")}, {"reserved field", STATICTAG_EDIT_DWORD_VE("00000058")}, {0, 0} }; ht_mask_ptable coff_section[] = { {"name", STATICTAG_EDIT_CHAR("00000000") STATICTAG_EDIT_CHAR("00000001") STATICTAG_EDIT_CHAR("00000002") STATICTAG_EDIT_CHAR("00000003") STATICTAG_EDIT_CHAR("00000004") STATICTAG_EDIT_CHAR("00000005") STATICTAG_EDIT_CHAR("00000006") STATICTAG_EDIT_CHAR("00000007")}, {"virt. size OR phys. address", STATICTAG_EDIT_DWORD_VE("00000008")}, {"virtual address", STATICTAG_EDIT_DWORD_VE("0000000c")}, {"size", STATICTAG_EDIT_DWORD_VE("00000010")}, {"offset", STATICTAG_EDIT_DWORD_VE("00000014")}, {"relocation table offset", STATICTAG_EDIT_DWORD_VE("00000018")}, {"line number table offset", STATICTAG_EDIT_DWORD_VE("0000001c")}, {"relocation count", STATICTAG_EDIT_WORD_VE("00000020")}, {"line number count", STATICTAG_EDIT_WORD_VE("00000022")}, {"characteristics", STATICTAG_EDIT_DWORD_VE("00000024")" "STATICTAG_FLAGS("00000024", ATOM_COFF_SECTION_CHARACTERISTICS_STR)}, {0, 0} }; static ht_view *htcoffheader_init(Bounds *b, File *file, ht_format_group *group) { ht_coff_shared_data *coff_shared = (ht_coff_shared_data *)group->get_shared_data(); bool coff_bigendian = coff_shared->endian == big_endian; uint32 h = coff_shared->hdr_ofs; ht_uformat_viewer *v = new ht_uformat_viewer(); v->init(b, DESC_COFF_HEADER, VC_EDIT, file, group); ht_mask_sub *m = new ht_mask_sub(); m->init(file, 0); registerAtom(ATOM_COFF_MACHINES, coff_machines); registerAtom(ATOM_COFF_OPTIONAL_MAGICS, coff_optional_magics); registerAtom(ATOM_COFF_OPTIONAL_SIZES, coff_optional_sizes); registerAtom(ATOM_COFF_CHARACTERISTICS, coff_characteristics); registerAtom(ATOM_COFF_SECTION_CHARACTERISTICS, coff_section_characteristics); char info[128]; ht_snprintf(info, sizeof info, "* COFF header at offset %08x", h); m->add_mask(info); /* COFF header */ m->add_mask("--- COFF header ---"); m->add_staticmask_ptable(coffheader, h, coff_bigendian); /* optional header */ if (coff_shared->coffheader.optional_header_size >= 2) { m->add_mask("--- optional header ---"); uint16 opt = coff_shared->opt_magic; /* file->seek(h+20); file->read(&opt, 2);*/ switch (opt) { case COFF_OPTMAGIC_COFF32: switch (coff_shared->coffheader.optional_header_size) { case COFF_OPTSIZE_COFF32: m->add_staticmask_ptable(coff32header, h, coff_bigendian); break; case COFF_OPTSIZE_XCOFF32: m->add_staticmask_ptable(xcoff32header, h, coff_bigendian); break; } break; default: { m->add_staticmask("optional magic "STATICTAG_EDIT_WORD_VE("00000018")" "STATICTAG_DESC_WORD_VE("00000018", ATOM_COFF_OPTIONAL_MAGICS_STR), h+20, coff_bigendian); m->add_mask("-------------------------------------------------------------------------"); m->add_mask("Unsupported optional magic! If you get this message in an original"); m->add_mask("(unmodified) file, please contact us (see help)."); } } } /* section headers */ int sc = coff_shared->sections.section_count; int os = coff_shared->coffheader.optional_header_size; /* file->seek(h+16); file->read(&os, 2); file->seek(h+os+20);*/ v->insertsub(m); for (int i=0; i < sc; i++) { ht_mask_sub *n=new ht_mask_sub(); n->init(file, i); n->add_staticmask_ptable(coff_section, h+20+os+i*40, coff_bigendian); char nm[9]; memcpy(nm, coff_shared->sections.sections[i].name, 8); nm[8] = 0; char t[32]; ht_snprintf(t, sizeof t, "section %d: %s", i, nm); ht_collapsable_sub *cn=new ht_collapsable_sub(); cn->init(file, n, 1, t, 1); v->insertsub(cn); } return v; } format_viewer_if htcoffheader_if = { htcoffheader_init, 0 }; ht-2.0.22/htfinfo.cc0000644000175000001440000001001310772434307011073 00000000000000/* * HT Editor * htfinfo.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "htfinfo.h" #include "snprintf.h" #include #include ht_view *htfinfo_init(Bounds *b, File *file, ht_format_group *group) { ht_finfo_text *v = new ht_finfo_text(); v->init(b, file); return v; } format_viewer_if htfinfo_if = { htfinfo_init, 0 }; /* * ht_finfo_text */ void ht_finfo_text::init(Bounds *b, File *f) { ht_statictext::init(b, FINFO_DESC, align_left, 1); options |= VO_BROWSABLE; // olddesc = desc; // desc =; file = f; } void ht_finfo_text::done() { // desc = olddesc; ht_statictext::done(); } #define FINFO_IDENTIFIER_WIDTH 24 #define FINFO_IDENTIFIER_WIDTH_STR "24" int print_time(char *f, int max_len, const char *prefix, time_t time) { tm tt; memcpy(&tt, localtime(&time), sizeof tt); return ht_snprintf(f, max_len, "%-"FINFO_IDENTIFIER_WIDTH_STR"s%s", prefix, asctime(&tt)); } int ht_finfo_text::gettext(char *text, int max_len) { if (max_len <= 0) return 0; char *t = text; pstat_t s; file->pstat(s); if (s.caps & pstat_ctime) t += print_time(t, max_len-(t-text), "time of creation", s.ctime); if (s.caps & pstat_mtime) t += print_time(t, max_len-(t-text), "time of modification", s.mtime); if (s.caps & pstat_atime) t += print_time(t, max_len-(t-text), "time of last access", s.atime); if (s.caps & pstat_uid) t += ht_snprintf(t, max_len-(t-text), "%-"FINFO_IDENTIFIER_WIDTH_STR"s%d\n", "user id", s.uid); if (s.caps & pstat_gid) t += ht_snprintf(t, max_len-(t-text), "%-"FINFO_IDENTIFIER_WIDTH_STR"s%d\n", "group id", s.gid); if (s.caps & pstat_size) { t += ht_snprintf(t, max_len-(t-text), "%-"FINFO_IDENTIFIER_WIDTH_STR"s%qd (%.2f KiB, %.2f MiB)" " / 0x%08qx\n", "size", s.size, ((float)s.size)/1024, ((float)s.size)/1024/1024, s.size); } if (s.caps & pstat_inode) t += ht_snprintf(t, max_len-(t-text), "%-"FINFO_IDENTIFIER_WIDTH_STR"s%d\n", "inode", s.fsid); else if (s.caps & pstat_cluster) t += ht_snprintf(t, max_len-(t-text), "%-"FINFO_IDENTIFIER_WIDTH_STR"s%d\n", "cluster (?)", s.fsid); else if (s.caps & pstat_fsid) t += ht_snprintf(t, max_len-(t-text), "%-"FINFO_IDENTIFIER_WIDTH_STR"s%d\n", "fsid", s.fsid); if (s.caps & pstat_mode_all) { uint32 am[3][3]={ {HT_S_IRUSR, HT_S_IWUSR, HT_S_IXUSR}, {HT_S_IRGRP, HT_S_IWGRP, HT_S_IXGRP}, {HT_S_IROTH, HT_S_IWOTH, HT_S_IXOTH} }; uint32 ulm[3]={pstat_mode_usr, pstat_mode_grp, pstat_mode_oth}; const char *uls[3]={"user", "group", "world"}; uint32 alm[3]={pstat_mode_r, pstat_mode_w, pstat_mode_x}; const char *als[3]={"read", "write", "execute"}; if (max_len-(t-text) > 1) *t++ = '\n'; int cols=0; t += ht_snprintf(t, max_len-(t-text), "%-"FINFO_IDENTIFIER_WIDTH_STR"s", ""); for (int u=0; u<3; u++) { if (s.caps & ulm[u]) { t += ht_snprintf(t, max_len-(t-text), " %-8s", uls[u]); cols++; } } if (max_len-(t-text) > 1) *t++ = '\n'; for (int q=0; q < FINFO_IDENTIFIER_WIDTH+cols*9; q++) if (max_len-(t-text) > 1) *t++ = '-'; if (max_len-(t-text) > 1) *t++ = '\n'; for (int a=0; a<3; a++) { if (s.caps & alm[a]) { t += ht_snprintf(t, max_len-(t-text), "%-"FINFO_IDENTIFIER_WIDTH_STR"s", als[a]); for (int u=0; u<3; u++) { if (s.caps & ulm[u]) { t += ht_snprintf(t, max_len-(t-text), " %-8s", (s.mode & am[u][a]) ? "[x]" : "[ ]"); } } if (max_len-(t-text) > 1) *t++ = '\n'; } } *t = 0; } return t-text; } ht-2.0.22/htxeximg.cc0000644000175000001440000001252410615345251011277 00000000000000/* * HT Editor * htxeximg.cc * * Copyright (C) 2006 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "log.h" #include "formats.h" #include "htpal.h" #include "htxeximg.h" #include "strtools.h" #include "xex_analy.h" #include "xexstruct.h" #include "snprintf.h" #define DESC_XEX_IMAGE "xex/image" static ht_view *htxeximage_init(Bounds *b, File *file, ht_format_group *group) { ht_xex_shared_data *xex_shared=(ht_xex_shared_data *)group->get_shared_data(); String fn; LOG("%y: XEX: loading image (starting analyser)...", &file->getFilename(fn)); file = xex_shared->image; XEXAnalyser *p = new XEXAnalyser(); p->init(xex_shared, file); Bounds c=*b; ht_group *g=new ht_group(); g->init(&c, VO_RESIZE, DESC_XEX_IMAGE"-g"); AnalyInfoline *head; c.y+=2; c.h-=2; ht_xex_aviewer *v=new ht_xex_aviewer(); v->init(&c, DESC_XEX_IMAGE, VC_EDIT | VC_GOTO | VC_SEARCH, file, group, p, xex_shared); c.y-=2; c.h=2; head=new AnalyInfoline(); head->init(&c, v, ANALY_STATUS_DEFAULT); v->attachInfoline(head); Address *low = p->createAddress32(xex_shared->image_base); Address *high = p->createAddress32(xex_shared->image_base+xex_shared->image_size-1); p->validarea->add(low, high); ht_analy_sub *analy=new ht_analy_sub(); analy->init(file, v, p, low, high); delete low; delete high; v->analy_sub = analy; v->insertsub(analy); v->sendmsg(msg_complete_init, 0); Address *tmpaddr; tmpaddr = p->createAddress32(xex_shared->entrypoint); v->gotoAddress(tmpaddr, NULL); delete tmpaddr; g->insert(head); g->insert(v); g->setpalette(palkey_generic_window_default); xex_shared->v_image=v; return g; } format_viewer_if htxeximage_if = { htxeximage_init, 0 }; #if 0 static int pe_viewer_func_rva(eval_scalar *result, eval_int *i) { ht_pe_aviewer *aviewer = (ht_pe_aviewer*)eval_get_context(); RVA rva = i->value; viewer_pos p; FileOfs ofs; if (pe_rva_to_ofs(&aviewer->pe_shared->sections, rva, &ofs) && aviewer->offset_to_pos(ofs, &p)) { Address *a; int b; aviewer->convertViewerPosToAddress(p, &a); a->putIntoArray((byte*)&b); delete a; scalar_create_int_c(result, b); return 1; } else { set_eval_error("invalid file offset or no corresponding RVA for '0%xh'", rva); } return 0; } static int pe_viewer_func_section_int(eval_scalar *result, eval_int *q) { ht_pe_aviewer *aviewer = (ht_pe_aviewer*)eval_get_context(); uint64 i = q->value - 1; if (i >= 0 && i < aviewer->pe_shared->sections.section_count) { viewer_pos p; FileOfs ofs; if (pe_rva_to_ofs(&aviewer->pe_shared->sections, aviewer->pe_shared->sections.sections[i].data_address, &ofs) && aviewer->offset_to_pos(ofs, &p)) { Address *a; uint64 b; aviewer->convertViewerPosToAddress(p, &a); a->putIntoUInt64(b); delete a; scalar_create_int_q(result, b); return 1; } else { // set_eval_error("invalid file offset or no corresponding RVA for '0%xh'", rva); } } else { set_eval_error("no section number %qd", q->value); } return 0; } static int pe_viewer_func_section_str(eval_scalar *result, eval_str *str) { ht_pe_aviewer *aviewer = (ht_pe_aviewer*)eval_get_context(); int section; char str2[COFF_SIZEOF_SHORT_NAME+1]; memset(str2, 0, COFF_SIZEOF_SHORT_NAME+1); memcpy(str2, str->value, MIN(str->len, COFF_SIZEOF_SHORT_NAME)); if (pe_section_name_to_section(&aviewer->pe_shared->sections, str2, §ion)) { eval_scalar i; scalar_create_int_c(&i, section+1); return pe_viewer_func_section_int(result, &i.scalar.integer); } return 0; } static int pe_viewer_func_section(eval_scalar *result, eval_scalar *q) { if (q->type == SCALAR_STR) return pe_viewer_func_section_str(result, &q->scalar.str); else { eval_int i; scalar_context_int(q, &i); return pe_viewer_func_section_int(result, &i); } } #endif /* * CLASS ht_pe_aviewer */ void ht_xex_aviewer::init(Bounds *b, const char *desc, int caps, File *File, ht_format_group *format_group, Analyser *Analy, ht_xex_shared_data *XEX_shared) { ht_aviewer::init(b, desc, caps, File, format_group, Analy); xex_shared = XEX_shared; } #if 0 bool ht_pe_aviewer::func_handler(eval_scalar *result, char *name, eval_scalarlist *params) { eval_func myfuncs[] = { {"rva", (void*)&pe_viewer_func_rva, {SCALAR_INT}, "returns address of rva"}, {"section", (void*)&pe_viewer_func_section, {SCALAR_ANY}, "returns address of section named param1 if param1 is a string\n" "returns address of section with index param1 otherwise"}, {NULL} }; if (std_eval_func_handler(result, name, params, myfuncs)) return true; return ht_aviewer::func_handler(result, name, params); } #endif void ht_xex_aviewer::setAnalyser(Analyser *a) { ((XEXAnalyser*)a)->xex_shared = xex_shared; ((XEXAnalyser*)a)->file = xex_shared->image; analy = a; analy_sub->setAnalyser(a); } ht-2.0.22/cp-demangle.c0000644000175000001440000041725611705332241011462 00000000000000/* Demangler for g++ V3 ABI. Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Written by Ian Lance Taylor . This file is part of the libiberty library, which is part of GCC. This file is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. In addition to the permissions in the GNU General Public License, the Free Software Foundation gives you unlimited permission to link the compiled version of this file into combinations with other programs, and to distribute those combinations without any restriction coming from the use of this file. (The General Public License restrictions do apply in other respects; for example, they cover modification of the file, and distribution when not linked into a combined executable.) This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ /* This code implements a demangler for the g++ V3 ABI. The ABI is described on this web page: http://www.codesourcery.com/cxx-abi/abi.html#mangling This code was written while looking at the demangler written by Alex Samuel . This code first pulls the mangled name apart into a list of components, and then walks the list generating the demangled name. This file will normally define the following functions, q.v.: char *cplus_demangle_v3(const char *mangled, int options) char *java_demangle_v3(const char *mangled) int cplus_demangle_v3_callback(const char *mangled, int options, demangle_callbackref callback) int java_demangle_v3_callback(const char *mangled, demangle_callbackref callback) enum gnu_v3_ctor_kinds is_gnu_v3_mangled_ctor (const char *name) enum gnu_v3_dtor_kinds is_gnu_v3_mangled_dtor (const char *name) Also, the interface to the component list is public, and defined in demangle.h. The interface consists of these types, which are defined in demangle.h: enum demangle_component_type struct demangle_component demangle_callbackref and these functions defined in this file: cplus_demangle_fill_name cplus_demangle_fill_extended_operator cplus_demangle_fill_ctor cplus_demangle_fill_dtor cplus_demangle_print cplus_demangle_print_callback and other functions defined in the file cp-demint.c. This file also defines some other functions and variables which are only to be used by the file cp-demint.c. Preprocessor macros you can define while compiling this file: IN_LIBGCC2 If defined, this file defines the following functions, q.v.: char *__cxa_demangle (const char *mangled, char *buf, size_t *len, int *status) int __gcclibcxx_demangle_callback (const char *, void (*) (const char *, size_t, void *), void *) instead of cplus_demangle_v3[_callback]() and java_demangle_v3[_callback](). IN_GLIBCPP_V3 If defined, this file defines only __cxa_demangle() and __gcclibcxx_demangle_callback(), and no other publically visible functions or variables. STANDALONE_DEMANGLER If defined, this file defines a main() function which demangles any arguments, or, if none, demangles stdin. CP_DEMANGLE_DEBUG If defined, turns on debugging mode, which prints information on stdout about the mangled string. This is not generally useful. */ #if defined (_AIX) && !defined (__GNUC__) #pragma alloca #endif #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #ifdef HAVE_STDLIB_H #include #endif #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_ALLOCA_H # include #else # ifndef alloca # ifdef __GNUC__ # define alloca __builtin_alloca # else extern char *alloca (); # endif /* __GNUC__ */ # endif /* alloca */ #endif /* HAVE_ALLOCA_H */ #include "demangle.h" #include "cp-demangle.h" /* If IN_GLIBCPP_V3 is defined, some functions are made static. We also rename them via #define to avoid compiler errors when the static definition conflicts with the extern declaration in a header file. */ #ifdef IN_GLIBCPP_V3 #define CP_STATIC_IF_GLIBCPP_V3 static #define cplus_demangle_fill_name d_fill_name static int d_fill_name (struct demangle_component *, const char *, int); #define cplus_demangle_fill_extended_operator d_fill_extended_operator static int d_fill_extended_operator (struct demangle_component *, int, struct demangle_component *); #define cplus_demangle_fill_ctor d_fill_ctor static int d_fill_ctor (struct demangle_component *, enum gnu_v3_ctor_kinds, struct demangle_component *); #define cplus_demangle_fill_dtor d_fill_dtor static int d_fill_dtor (struct demangle_component *, enum gnu_v3_dtor_kinds, struct demangle_component *); #define cplus_demangle_mangled_name d_mangled_name static struct demangle_component *d_mangled_name (struct d_info *, int); #define cplus_demangle_type d_type static struct demangle_component *d_type (struct d_info *); #define cplus_demangle_print d_print static char *d_print (int, const struct demangle_component *, int, size_t *); #define cplus_demangle_print_callback d_print_callback static int d_print_callback (int, const struct demangle_component *, demangle_callbackref, void *); #define cplus_demangle_init_info d_init_info static void d_init_info (const char *, int, size_t, struct d_info *); #else /* ! defined(IN_GLIBCPP_V3) */ #define CP_STATIC_IF_GLIBCPP_V3 #endif /* ! defined(IN_GLIBCPP_V3) */ /* See if the compiler supports dynamic arrays. */ #ifdef __GNUC__ #define CP_DYNAMIC_ARRAYS #else #ifdef __STDC__ #ifdef __STDC_VERSION__ #if __STDC_VERSION__ >= 199901L #define CP_DYNAMIC_ARRAYS #endif /* __STDC__VERSION >= 199901L */ #endif /* defined (__STDC_VERSION__) */ #endif /* defined (__STDC__) */ #endif /* ! defined (__GNUC__) */ /* We avoid pulling in the ctype tables, to prevent pulling in additional unresolved symbols when this code is used in a library. FIXME: Is this really a valid reason? This comes from the original V3 demangler code. As of this writing this file has the following undefined references when compiled with -DIN_GLIBCPP_V3: realloc, free, memcpy, strcpy, strcat, strlen. */ #define IS_DIGIT(c) ((c) >= '0' && (c) <= '9') #define IS_UPPER(c) ((c) >= 'A' && (c) <= 'Z') #define IS_LOWER(c) ((c) >= 'a' && (c) <= 'z') /* The prefix prepended by GCC to an identifier represnting the anonymous namespace. */ #define ANONYMOUS_NAMESPACE_PREFIX "_GLOBAL_" #define ANONYMOUS_NAMESPACE_PREFIX_LEN \ (sizeof (ANONYMOUS_NAMESPACE_PREFIX) - 1) /* Information we keep for the standard substitutions. */ struct d_standard_sub_info { /* The code for this substitution. */ char code; /* The simple string it expands to. */ const char *simple_expansion; /* The length of the simple expansion. */ int simple_len; /* The results of a full, verbose, expansion. This is used when qualifying a constructor/destructor, or when in verbose mode. */ const char *full_expansion; /* The length of the full expansion. */ int full_len; /* What to set the last_name field of d_info to; NULL if we should not set it. This is only relevant when qualifying a constructor/destructor. */ const char *set_last_name; /* The length of set_last_name. */ int set_last_name_len; }; /* Accessors for subtrees of struct demangle_component. */ #define d_left(dc) ((dc)->u.s_binary.left) #define d_right(dc) ((dc)->u.s_binary.right) /* A list of templates. This is used while printing. */ struct d_print_template { /* Next template on the list. */ struct d_print_template *next; /* This template. */ const struct demangle_component *template_decl; }; /* A list of type modifiers. This is used while printing. */ struct d_print_mod { /* Next modifier on the list. These are in the reverse of the order in which they appeared in the mangled string. */ struct d_print_mod *next; /* The modifier. */ const struct demangle_component *mod; /* Whether this modifier was printed. */ int printed; /* The list of templates which applies to this modifier. */ struct d_print_template *templates; }; /* We use these structures to hold information during printing. */ struct d_growable_string { /* Buffer holding the result. */ char *buf; /* Current length of data in buffer. */ size_t len; /* Allocated size of buffer. */ size_t alc; /* Set to 1 if we had a memory allocation failure. */ int allocation_failure; }; enum { D_PRINT_BUFFER_LENGTH = 256 }; struct d_print_info { /* The options passed to the demangler. */ int options; /* Fixed-length allocated buffer for demangled data, flushed to the callback with a NUL termination once full. */ char buf[D_PRINT_BUFFER_LENGTH]; /* Current length of data in buffer. */ size_t len; /* The last character printed, saved individually so that it survives any buffer flush. */ char last_char; /* Callback function to handle demangled buffer flush. */ demangle_callbackref callback; /* Opaque callback argument. */ void *opaque; /* The current list of templates, if any. */ struct d_print_template *templates; /* The current list of modifiers (e.g., pointer, reference, etc.), if any. */ struct d_print_mod *modifiers; /* Set to 1 if we saw a demangling error. */ int demangle_failure; /* The current index into any template argument packs we are using for printing. */ int pack_index; /* Number of d_print_flush calls so far. */ unsigned long int flush_count; }; #ifdef CP_DEMANGLE_DEBUG static void d_dump (struct demangle_component *, int); #endif static struct demangle_component * d_make_empty (struct d_info *); static struct demangle_component * d_make_comp (struct d_info *, enum demangle_component_type, struct demangle_component *, struct demangle_component *); static struct demangle_component * d_make_name (struct d_info *, const char *, int); static struct demangle_component * d_make_demangle_mangled_name (struct d_info *, const char *); static struct demangle_component * d_make_builtin_type (struct d_info *, const struct demangle_builtin_type_info *); static struct demangle_component * d_make_operator (struct d_info *, const struct demangle_operator_info *); static struct demangle_component * d_make_extended_operator (struct d_info *, int, struct demangle_component *); static struct demangle_component * d_make_ctor (struct d_info *, enum gnu_v3_ctor_kinds, struct demangle_component *); static struct demangle_component * d_make_dtor (struct d_info *, enum gnu_v3_dtor_kinds, struct demangle_component *); static struct demangle_component * d_make_template_param (struct d_info *, long); static struct demangle_component * d_make_sub (struct d_info *, const char *, int); static int has_return_type (struct demangle_component *); static int is_ctor_dtor_or_conversion (struct demangle_component *); static struct demangle_component *d_encoding (struct d_info *, int); static struct demangle_component *d_name (struct d_info *); static struct demangle_component *d_nested_name (struct d_info *); static struct demangle_component *d_prefix (struct d_info *); static struct demangle_component *d_unqualified_name (struct d_info *); static struct demangle_component *d_source_name (struct d_info *); static long d_number (struct d_info *); static struct demangle_component *d_identifier (struct d_info *, int); static struct demangle_component *d_operator_name (struct d_info *); static struct demangle_component *d_special_name (struct d_info *); static int d_call_offset (struct d_info *, int); static struct demangle_component *d_ctor_dtor_name (struct d_info *); static struct demangle_component ** d_cv_qualifiers (struct d_info *, struct demangle_component **, int); static struct demangle_component * d_function_type (struct d_info *); static struct demangle_component * d_bare_function_type (struct d_info *, int); static struct demangle_component * d_class_enum_type (struct d_info *); static struct demangle_component *d_array_type (struct d_info *); static struct demangle_component *d_vector_type (struct d_info *); static struct demangle_component * d_pointer_to_member_type (struct d_info *); static struct demangle_component * d_template_param (struct d_info *); static struct demangle_component *d_template_args (struct d_info *); static struct demangle_component * d_template_arg (struct d_info *); static struct demangle_component *d_expression (struct d_info *); static struct demangle_component *d_expr_primary (struct d_info *); static struct demangle_component *d_local_name (struct d_info *); static int d_discriminator (struct d_info *); static struct demangle_component *d_lambda (struct d_info *); static struct demangle_component *d_unnamed_type (struct d_info *); static int d_add_substitution (struct d_info *, struct demangle_component *); static struct demangle_component *d_substitution (struct d_info *, int); static void d_growable_string_init (struct d_growable_string *, size_t); static inline void d_growable_string_resize (struct d_growable_string *, size_t); static inline void d_growable_string_append_buffer (struct d_growable_string *, const char *, size_t); static void d_growable_string_callback_adapter (const char *, size_t, void *); static void d_print_init (struct d_print_info *, int, demangle_callbackref, void *); static inline void d_print_error (struct d_print_info *); static inline int d_print_saw_error (struct d_print_info *); static inline void d_print_flush (struct d_print_info *); static inline void d_append_char (struct d_print_info *, char); static inline void d_append_buffer (struct d_print_info *, const char *, size_t); static inline void d_append_string (struct d_print_info *, const char *); static inline char d_last_char (struct d_print_info *); static void d_print_comp (struct d_print_info *, const struct demangle_component *); static void d_print_java_identifier (struct d_print_info *, const char *, int); static void d_print_mod_list (struct d_print_info *, struct d_print_mod *, int); static void d_print_mod (struct d_print_info *, const struct demangle_component *); static void d_print_function_type (struct d_print_info *, const struct demangle_component *, struct d_print_mod *); static void d_print_array_type (struct d_print_info *, const struct demangle_component *, struct d_print_mod *); static void d_print_expr_op (struct d_print_info *, const struct demangle_component *); static void d_print_cast (struct d_print_info *, const struct demangle_component *); static int d_demangle_callback (const char *, int, demangle_callbackref, void *); static char *d_demangle (const char *, int, size_t *); #ifdef CP_DEMANGLE_DEBUG static void d_dump (struct demangle_component *dc, int indent) { int i; if (dc == NULL) { if (indent == 0) printf ("failed demangling\n"); return; } for (i = 0; i < indent; ++i) putchar (' '); switch (dc->type) { case DEMANGLE_COMPONENT_NAME: printf ("name '%.*s'\n", dc->u.s_name.len, dc->u.s_name.s); return; case DEMANGLE_COMPONENT_TEMPLATE_PARAM: printf ("template parameter %ld\n", dc->u.s_number.number); return; case DEMANGLE_COMPONENT_CTOR: printf ("constructor %d\n", (int) dc->u.s_ctor.kind); d_dump (dc->u.s_ctor.name, indent + 2); return; case DEMANGLE_COMPONENT_DTOR: printf ("destructor %d\n", (int) dc->u.s_dtor.kind); d_dump (dc->u.s_dtor.name, indent + 2); return; case DEMANGLE_COMPONENT_SUB_STD: printf ("standard substitution %s\n", dc->u.s_string.string); return; case DEMANGLE_COMPONENT_BUILTIN_TYPE: printf ("builtin type %s\n", dc->u.s_builtin.type->name); return; case DEMANGLE_COMPONENT_OPERATOR: printf ("operator %s\n", dc->u.s_operator.op->name); return; case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: printf ("extended operator with %d args\n", dc->u.s_extended_operator.args); d_dump (dc->u.s_extended_operator.name, indent + 2); return; case DEMANGLE_COMPONENT_QUAL_NAME: printf ("qualified name\n"); break; case DEMANGLE_COMPONENT_LOCAL_NAME: printf ("local name\n"); break; case DEMANGLE_COMPONENT_TYPED_NAME: printf ("typed name\n"); break; case DEMANGLE_COMPONENT_TEMPLATE: printf ("template\n"); break; case DEMANGLE_COMPONENT_VTABLE: printf ("vtable\n"); break; case DEMANGLE_COMPONENT_VTT: printf ("VTT\n"); break; case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE: printf ("construction vtable\n"); break; case DEMANGLE_COMPONENT_TYPEINFO: printf ("typeinfo\n"); break; case DEMANGLE_COMPONENT_TYPEINFO_NAME: printf ("typeinfo name\n"); break; case DEMANGLE_COMPONENT_TYPEINFO_FN: printf ("typeinfo function\n"); break; case DEMANGLE_COMPONENT_THUNK: printf ("thunk\n"); break; case DEMANGLE_COMPONENT_VIRTUAL_THUNK: printf ("virtual thunk\n"); break; case DEMANGLE_COMPONENT_COVARIANT_THUNK: printf ("covariant thunk\n"); break; case DEMANGLE_COMPONENT_JAVA_CLASS: printf ("java class\n"); break; case DEMANGLE_COMPONENT_GUARD: printf ("guard\n"); break; case DEMANGLE_COMPONENT_REFTEMP: printf ("reference temporary\n"); break; case DEMANGLE_COMPONENT_HIDDEN_ALIAS: printf ("hidden alias\n"); break; case DEMANGLE_COMPONENT_RESTRICT: printf ("restrict\n"); break; case DEMANGLE_COMPONENT_VOLATILE: printf ("volatile\n"); break; case DEMANGLE_COMPONENT_CONST: printf ("const\n"); break; case DEMANGLE_COMPONENT_RESTRICT_THIS: printf ("restrict this\n"); break; case DEMANGLE_COMPONENT_VOLATILE_THIS: printf ("volatile this\n"); break; case DEMANGLE_COMPONENT_CONST_THIS: printf ("const this\n"); break; case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: printf ("vendor type qualifier\n"); break; case DEMANGLE_COMPONENT_POINTER: printf ("pointer\n"); break; case DEMANGLE_COMPONENT_REFERENCE: printf ("reference\n"); break; case DEMANGLE_COMPONENT_RVALUE_REFERENCE: printf ("rvalue reference\n"); break; case DEMANGLE_COMPONENT_COMPLEX: printf ("complex\n"); break; case DEMANGLE_COMPONENT_IMAGINARY: printf ("imaginary\n"); break; case DEMANGLE_COMPONENT_VENDOR_TYPE: printf ("vendor type\n"); break; case DEMANGLE_COMPONENT_FUNCTION_TYPE: printf ("function type\n"); break; case DEMANGLE_COMPONENT_ARRAY_TYPE: printf ("array type\n"); break; case DEMANGLE_COMPONENT_PTRMEM_TYPE: printf ("pointer to member type\n"); break; case DEMANGLE_COMPONENT_FIXED_TYPE: printf ("fixed-point type\n"); break; case DEMANGLE_COMPONENT_ARGLIST: printf ("argument list\n"); break; case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: printf ("template argument list\n"); break; case DEMANGLE_COMPONENT_CAST: printf ("cast\n"); break; case DEMANGLE_COMPONENT_UNARY: printf ("unary operator\n"); break; case DEMANGLE_COMPONENT_BINARY: printf ("binary operator\n"); break; case DEMANGLE_COMPONENT_BINARY_ARGS: printf ("binary operator arguments\n"); break; case DEMANGLE_COMPONENT_TRINARY: printf ("trinary operator\n"); break; case DEMANGLE_COMPONENT_TRINARY_ARG1: printf ("trinary operator arguments 1\n"); break; case DEMANGLE_COMPONENT_TRINARY_ARG2: printf ("trinary operator arguments 1\n"); break; case DEMANGLE_COMPONENT_LITERAL: printf ("literal\n"); break; case DEMANGLE_COMPONENT_LITERAL_NEG: printf ("negative literal\n"); break; case DEMANGLE_COMPONENT_JAVA_RESOURCE: printf ("java resource\n"); break; case DEMANGLE_COMPONENT_COMPOUND_NAME: printf ("compound name\n"); break; case DEMANGLE_COMPONENT_CHARACTER: printf ("character '%c'\n", dc->u.s_character.character); return; case DEMANGLE_COMPONENT_DECLTYPE: printf ("decltype\n"); break; case DEMANGLE_COMPONENT_PACK_EXPANSION: printf ("pack expansion\n"); break; } d_dump (d_left (dc), indent + 2); d_dump (d_right (dc), indent + 2); } #endif /* CP_DEMANGLE_DEBUG */ /* Fill in a DEMANGLE_COMPONENT_NAME. */ CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_name (struct demangle_component *p, const char *s, int len) { if (p == NULL || s == NULL || len == 0) return 0; p->type = DEMANGLE_COMPONENT_NAME; p->u.s_name.s = s; p->u.s_name.len = len; return 1; } /* Fill in a DEMANGLE_COMPONENT_EXTENDED_OPERATOR. */ CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_extended_operator (struct demangle_component *p, int args, struct demangle_component *name) { if (p == NULL || args < 0 || name == NULL) return 0; p->type = DEMANGLE_COMPONENT_EXTENDED_OPERATOR; p->u.s_extended_operator.args = args; p->u.s_extended_operator.name = name; return 1; } /* Fill in a DEMANGLE_COMPONENT_CTOR. */ CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_ctor (struct demangle_component *p, enum gnu_v3_ctor_kinds kind, struct demangle_component *name) { if (p == NULL || name == NULL || (int) kind < gnu_v3_complete_object_ctor || (int) kind > gnu_v3_complete_object_allocating_ctor) return 0; p->type = DEMANGLE_COMPONENT_CTOR; p->u.s_ctor.kind = kind; p->u.s_ctor.name = name; return 1; } /* Fill in a DEMANGLE_COMPONENT_DTOR. */ CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_fill_dtor (struct demangle_component *p, enum gnu_v3_dtor_kinds kind, struct demangle_component *name) { if (p == NULL || name == NULL || (int) kind < gnu_v3_deleting_dtor || (int) kind > gnu_v3_base_object_dtor) return 0; p->type = DEMANGLE_COMPONENT_DTOR; p->u.s_dtor.kind = kind; p->u.s_dtor.name = name; return 1; } /* Add a new component. */ static struct demangle_component * d_make_empty (struct d_info *di) { struct demangle_component *p; if (di->next_comp >= di->num_comps) return NULL; p = &di->comps[di->next_comp]; ++di->next_comp; return p; } /* Add a new generic component. */ static struct demangle_component * d_make_comp (struct d_info *di, enum demangle_component_type type, struct demangle_component *left, struct demangle_component *right) { struct demangle_component *p; /* We check for errors here. A typical error would be a NULL return from a subroutine. We catch those here, and return NULL upward. */ switch (type) { /* These types require two parameters. */ case DEMANGLE_COMPONENT_QUAL_NAME: case DEMANGLE_COMPONENT_LOCAL_NAME: case DEMANGLE_COMPONENT_TYPED_NAME: case DEMANGLE_COMPONENT_TEMPLATE: case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE: case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: case DEMANGLE_COMPONENT_PTRMEM_TYPE: case DEMANGLE_COMPONENT_UNARY: case DEMANGLE_COMPONENT_BINARY: case DEMANGLE_COMPONENT_BINARY_ARGS: case DEMANGLE_COMPONENT_TRINARY: case DEMANGLE_COMPONENT_TRINARY_ARG1: case DEMANGLE_COMPONENT_TRINARY_ARG2: case DEMANGLE_COMPONENT_LITERAL: case DEMANGLE_COMPONENT_LITERAL_NEG: case DEMANGLE_COMPONENT_COMPOUND_NAME: case DEMANGLE_COMPONENT_VECTOR_TYPE: if (left == NULL || right == NULL) return NULL; break; /* These types only require one parameter. */ case DEMANGLE_COMPONENT_VTABLE: case DEMANGLE_COMPONENT_VTT: case DEMANGLE_COMPONENT_TYPEINFO: case DEMANGLE_COMPONENT_TYPEINFO_NAME: case DEMANGLE_COMPONENT_TYPEINFO_FN: case DEMANGLE_COMPONENT_THUNK: case DEMANGLE_COMPONENT_VIRTUAL_THUNK: case DEMANGLE_COMPONENT_COVARIANT_THUNK: case DEMANGLE_COMPONENT_JAVA_CLASS: case DEMANGLE_COMPONENT_GUARD: case DEMANGLE_COMPONENT_REFTEMP: case DEMANGLE_COMPONENT_HIDDEN_ALIAS: case DEMANGLE_COMPONENT_POINTER: case DEMANGLE_COMPONENT_REFERENCE: case DEMANGLE_COMPONENT_RVALUE_REFERENCE: case DEMANGLE_COMPONENT_COMPLEX: case DEMANGLE_COMPONENT_IMAGINARY: case DEMANGLE_COMPONENT_VENDOR_TYPE: case DEMANGLE_COMPONENT_CAST: case DEMANGLE_COMPONENT_JAVA_RESOURCE: case DEMANGLE_COMPONENT_DECLTYPE: case DEMANGLE_COMPONENT_PACK_EXPANSION: case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: if (left == NULL) return NULL; break; /* This needs a right parameter, but the left parameter can be empty. */ case DEMANGLE_COMPONENT_ARRAY_TYPE: if (right == NULL) return NULL; break; /* These are allowed to have no parameters--in some cases they will be filled in later. */ case DEMANGLE_COMPONENT_FUNCTION_TYPE: case DEMANGLE_COMPONENT_RESTRICT: case DEMANGLE_COMPONENT_VOLATILE: case DEMANGLE_COMPONENT_CONST: case DEMANGLE_COMPONENT_RESTRICT_THIS: case DEMANGLE_COMPONENT_VOLATILE_THIS: case DEMANGLE_COMPONENT_CONST_THIS: case DEMANGLE_COMPONENT_ARGLIST: case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: break; /* Other types should not be seen here. */ default: return NULL; } p = d_make_empty (di); if (p != NULL) { p->type = type; p->u.s_binary.left = left; p->u.s_binary.right = right; } return p; } /* Add a new demangle mangled name component. */ static struct demangle_component * d_make_demangle_mangled_name (struct d_info *di, const char *s) { if (d_peek_char (di) != '_' || d_peek_next_char (di) != 'Z') return d_make_name (di, s, strlen (s)); d_advance (di, 2); return d_encoding (di, 0); } /* Add a new name component. */ static struct demangle_component * d_make_name (struct d_info *di, const char *s, int len) { struct demangle_component *p; p = d_make_empty (di); if (! cplus_demangle_fill_name (p, s, len)) return NULL; return p; } /* Add a new builtin type component. */ static struct demangle_component * d_make_builtin_type (struct d_info *di, const struct demangle_builtin_type_info *type) { struct demangle_component *p; if (type == NULL) return NULL; p = d_make_empty (di); if (p != NULL) { p->type = DEMANGLE_COMPONENT_BUILTIN_TYPE; p->u.s_builtin.type = type; } return p; } /* Add a new operator component. */ static struct demangle_component * d_make_operator (struct d_info *di, const struct demangle_operator_info *op) { struct demangle_component *p; p = d_make_empty (di); if (p != NULL) { p->type = DEMANGLE_COMPONENT_OPERATOR; p->u.s_operator.op = op; } return p; } /* Add a new extended operator component. */ static struct demangle_component * d_make_extended_operator (struct d_info *di, int args, struct demangle_component *name) { struct demangle_component *p; p = d_make_empty (di); if (! cplus_demangle_fill_extended_operator (p, args, name)) return NULL; return p; } static struct demangle_component * d_make_default_arg (struct d_info *di, int num, struct demangle_component *sub) { struct demangle_component *p = d_make_empty (di); if (p) { p->type = DEMANGLE_COMPONENT_DEFAULT_ARG; p->u.s_unary_num.num = num; p->u.s_unary_num.sub = sub; } return p; } /* Add a new constructor component. */ static struct demangle_component * d_make_ctor (struct d_info *di, enum gnu_v3_ctor_kinds kind, struct demangle_component *name) { struct demangle_component *p; p = d_make_empty (di); if (! cplus_demangle_fill_ctor (p, kind, name)) return NULL; return p; } /* Add a new destructor component. */ static struct demangle_component * d_make_dtor (struct d_info *di, enum gnu_v3_dtor_kinds kind, struct demangle_component *name) { struct demangle_component *p; p = d_make_empty (di); if (! cplus_demangle_fill_dtor (p, kind, name)) return NULL; return p; } /* Add a new template parameter. */ static struct demangle_component * d_make_template_param (struct d_info *di, long i) { struct demangle_component *p; p = d_make_empty (di); if (p != NULL) { p->type = DEMANGLE_COMPONENT_TEMPLATE_PARAM; p->u.s_number.number = i; } return p; } /* Add a new function parameter. */ static struct demangle_component * d_make_function_param (struct d_info *di, long i) { struct demangle_component *p; p = d_make_empty (di); if (p != NULL) { p->type = DEMANGLE_COMPONENT_FUNCTION_PARAM; p->u.s_number.number = i; } return p; } /* Add a new standard substitution component. */ static struct demangle_component * d_make_sub (struct d_info *di, const char *name, int len) { struct demangle_component *p; p = d_make_empty (di); if (p != NULL) { p->type = DEMANGLE_COMPONENT_SUB_STD; p->u.s_string.string = name; p->u.s_string.len = len; } return p; } /* ::= _Z TOP_LEVEL is non-zero when called at the top level. */ CP_STATIC_IF_GLIBCPP_V3 struct demangle_component * cplus_demangle_mangled_name (struct d_info *di, int top_level) { if (! d_check_char (di, '_') /* Allow missing _ if not at toplevel to work around a bug in G++ abi-version=2 mangling; see the comment in write_template_arg. */ && top_level) return NULL; if (! d_check_char (di, 'Z')) return NULL; return d_encoding (di, top_level); } /* Return whether a function should have a return type. The argument is the function name, which may be qualified in various ways. The rules are that template functions have return types with some exceptions, function types which are not part of a function name mangling have return types with some exceptions, and non-template function names do not have return types. The exceptions are that constructors, destructors, and conversion operators do not have return types. */ static int has_return_type (struct demangle_component *dc) { if (dc == NULL) return 0; switch (dc->type) { default: return 0; case DEMANGLE_COMPONENT_TEMPLATE: return ! is_ctor_dtor_or_conversion (d_left (dc)); case DEMANGLE_COMPONENT_RESTRICT_THIS: case DEMANGLE_COMPONENT_VOLATILE_THIS: case DEMANGLE_COMPONENT_CONST_THIS: return has_return_type (d_left (dc)); } } /* Return whether a name is a constructor, a destructor, or a conversion operator. */ static int is_ctor_dtor_or_conversion (struct demangle_component *dc) { if (dc == NULL) return 0; switch (dc->type) { default: return 0; case DEMANGLE_COMPONENT_QUAL_NAME: case DEMANGLE_COMPONENT_LOCAL_NAME: return is_ctor_dtor_or_conversion (d_right (dc)); case DEMANGLE_COMPONENT_CTOR: case DEMANGLE_COMPONENT_DTOR: case DEMANGLE_COMPONENT_CAST: return 1; } } /* ::= <(function) name> ::= <(data) name> ::= TOP_LEVEL is non-zero when called at the top level, in which case if DMGL_PARAMS is not set we do not demangle the function parameters. We only set this at the top level, because otherwise we would not correctly demangle names in local scopes. */ static struct demangle_component * d_encoding (struct d_info *di, int top_level) { char peek = d_peek_char (di); if (peek == 'G' || peek == 'T') return d_special_name (di); else { struct demangle_component *dc; dc = d_name (di); if (dc != NULL && top_level && (di->options & DMGL_PARAMS) == 0) { /* Strip off any initial CV-qualifiers, as they really apply to the `this' parameter, and they were not output by the v2 demangler without DMGL_PARAMS. */ while (dc->type == DEMANGLE_COMPONENT_RESTRICT_THIS || dc->type == DEMANGLE_COMPONENT_VOLATILE_THIS || dc->type == DEMANGLE_COMPONENT_CONST_THIS) dc = d_left (dc); /* If the top level is a DEMANGLE_COMPONENT_LOCAL_NAME, then there may be CV-qualifiers on its right argument which really apply here; this happens when parsing a class which is local to a function. */ if (dc->type == DEMANGLE_COMPONENT_LOCAL_NAME) { struct demangle_component *dcr; dcr = d_right (dc); while (dcr->type == DEMANGLE_COMPONENT_RESTRICT_THIS || dcr->type == DEMANGLE_COMPONENT_VOLATILE_THIS || dcr->type == DEMANGLE_COMPONENT_CONST_THIS) dcr = d_left (dcr); dc->u.s_binary.right = dcr; } return dc; } peek = d_peek_char (di); if (dc == NULL || peek == '\0' || peek == 'E') return dc; return d_make_comp (di, DEMANGLE_COMPONENT_TYPED_NAME, dc, d_bare_function_type (di, has_return_type (dc))); } } /* ::= ::= ::= ::= ::= ::= St ::= ::= */ static struct demangle_component * d_name (struct d_info *di) { char peek = d_peek_char (di); struct demangle_component *dc; switch (peek) { case 'N': return d_nested_name (di); case 'Z': return d_local_name (di); case 'L': case 'U': return d_unqualified_name (di); case 'S': { int subst; if (d_peek_next_char (di) != 't') { dc = d_substitution (di, 0); subst = 1; } else { d_advance (di, 2); dc = d_make_comp (di, DEMANGLE_COMPONENT_QUAL_NAME, d_make_name (di, "std", 3), d_unqualified_name (di)); di->expansion += 3; subst = 0; } if (d_peek_char (di) != 'I') { /* The grammar does not permit this case to occur if we called d_substitution() above (i.e., subst == 1). We don't bother to check. */ } else { /* This is , which means that we just saw , which is a substitution candidate if we didn't just get it from a substitution. */ if (! subst) { if (! d_add_substitution (di, dc)) return NULL; } dc = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, dc, d_template_args (di)); } return dc; } default: dc = d_unqualified_name (di); if (d_peek_char (di) == 'I') { /* This is , which means that we just saw , which is a substitution candidate. */ if (! d_add_substitution (di, dc)) return NULL; dc = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, dc, d_template_args (di)); } return dc; } } /* ::= N [] E ::= N [] E */ static struct demangle_component * d_nested_name (struct d_info *di) { struct demangle_component *ret; struct demangle_component **pret; if (! d_check_char (di, 'N')) return NULL; pret = d_cv_qualifiers (di, &ret, 1); if (pret == NULL) return NULL; *pret = d_prefix (di); if (*pret == NULL) return NULL; if (! d_check_char (di, 'E')) return NULL; return ret; } /* ::= ::= ::= ::= ::= ::= <(template) unqualified-name> ::= ::= */ static struct demangle_component * d_prefix (struct d_info *di) { struct demangle_component *ret = NULL; while (1) { char peek; enum demangle_component_type comb_type; struct demangle_component *dc; peek = d_peek_char (di); if (peek == '\0') return NULL; /* The older code accepts a here, but I don't see that in the grammar. The older code does not accept a here. */ comb_type = DEMANGLE_COMPONENT_QUAL_NAME; if (IS_DIGIT (peek) || IS_LOWER (peek) || peek == 'C' || peek == 'D' || peek == 'U' || peek == 'L') dc = d_unqualified_name (di); else if (peek == 'S') dc = d_substitution (di, 1); else if (peek == 'I') { if (ret == NULL) return NULL; comb_type = DEMANGLE_COMPONENT_TEMPLATE; dc = d_template_args (di); } else if (peek == 'T') dc = d_template_param (di); else if (peek == 'E') return ret; else if (peek == 'M') { /* Initializer scope for a lambda. We don't need to represent this; the normal code will just treat the variable as a type scope, which gives appropriate output. */ if (ret == NULL) return NULL; d_advance (di, 1); continue; } else return NULL; if (ret == NULL) ret = dc; else ret = d_make_comp (di, comb_type, ret, dc); if (peek != 'S' && d_peek_char (di) != 'E') { if (! d_add_substitution (di, ret)) return NULL; } } } /* ::= ::= ::= ::= ::= L */ static struct demangle_component * d_unqualified_name (struct d_info *di) { char peek; peek = d_peek_char (di); if (IS_DIGIT (peek)) return d_source_name (di); else if (IS_LOWER (peek)) { struct demangle_component *ret; ret = d_operator_name (di); if (ret != NULL && ret->type == DEMANGLE_COMPONENT_OPERATOR) di->expansion += sizeof "operator" + ret->u.s_operator.op->len - 2; return ret; } else if (peek == 'C' || peek == 'D') return d_ctor_dtor_name (di); else if (peek == 'L') { struct demangle_component * ret; d_advance (di, 1); ret = d_source_name (di); if (ret == NULL) return NULL; if (! d_discriminator (di)) return NULL; return ret; } else if (peek == 'U') { switch (d_peek_next_char (di)) { case 'l': return d_lambda (di); case 't': return d_unnamed_type (di); default: return NULL; } } else return NULL; } /* ::= <(positive length) number> */ static struct demangle_component * d_source_name (struct d_info *di) { long len; struct demangle_component *ret; len = d_number (di); if (len <= 0) return NULL; ret = d_identifier (di, len); di->last_name = ret; return ret; } /* number ::= [n] <(non-negative decimal integer)> */ static long d_number (struct d_info *di) { int negative; char peek; long ret; negative = 0; peek = d_peek_char (di); if (peek == 'n') { negative = 1; d_advance (di, 1); peek = d_peek_char (di); } ret = 0; while (1) { if (! IS_DIGIT (peek)) { if (negative) ret = - ret; return ret; } ret = ret * 10 + peek - '0'; d_advance (di, 1); peek = d_peek_char (di); } } /* Like d_number, but returns a demangle_component. */ static struct demangle_component * d_number_component (struct d_info *di) { struct demangle_component *ret = d_make_empty (di); if (ret) { ret->type = DEMANGLE_COMPONENT_NUMBER; ret->u.s_number.number = d_number (di); } return ret; } /* identifier ::= <(unqualified source code identifier)> */ static struct demangle_component * d_identifier (struct d_info *di, int len) { const char *name; name = d_str (di); if (di->send - name < len) return NULL; d_advance (di, len); /* A Java mangled name may have a trailing '$' if it is a C++ keyword. This '$' is not included in the length count. We just ignore the '$'. */ if ((di->options & DMGL_JAVA) != 0 && d_peek_char (di) == '$') d_advance (di, 1); /* Look for something which looks like a gcc encoding of an anonymous namespace, and replace it with a more user friendly name. */ if (len >= (int) ANONYMOUS_NAMESPACE_PREFIX_LEN + 2 && memcmp (name, ANONYMOUS_NAMESPACE_PREFIX, ANONYMOUS_NAMESPACE_PREFIX_LEN) == 0) { const char *s; s = name + ANONYMOUS_NAMESPACE_PREFIX_LEN; if ((*s == '.' || *s == '_' || *s == '$') && s[1] == 'N') { di->expansion -= len - sizeof "(anonymous namespace)"; return d_make_name (di, "(anonymous namespace)", sizeof "(anonymous namespace)" - 1); } } return d_make_name (di, name, len); } /* operator_name ::= many different two character encodings. ::= cv ::= v */ #define NL(s) s, (sizeof s) - 1 CP_STATIC_IF_GLIBCPP_V3 const struct demangle_operator_info cplus_demangle_operators[] = { { "aN", NL ("&="), 2 }, { "aS", NL ("="), 2 }, { "aa", NL ("&&"), 2 }, { "ad", NL ("&"), 1 }, { "an", NL ("&"), 2 }, { "cl", NL ("()"), 2 }, { "cm", NL (","), 2 }, { "co", NL ("~"), 1 }, { "dV", NL ("/="), 2 }, { "da", NL ("delete[]"), 1 }, { "de", NL ("*"), 1 }, { "dl", NL ("delete"), 1 }, { "dt", NL ("."), 2 }, { "dv", NL ("/"), 2 }, { "eO", NL ("^="), 2 }, { "eo", NL ("^"), 2 }, { "eq", NL ("=="), 2 }, { "ge", NL (">="), 2 }, { "gt", NL (">"), 2 }, { "ix", NL ("[]"), 2 }, { "lS", NL ("<<="), 2 }, { "le", NL ("<="), 2 }, { "ls", NL ("<<"), 2 }, { "lt", NL ("<"), 2 }, { "mI", NL ("-="), 2 }, { "mL", NL ("*="), 2 }, { "mi", NL ("-"), 2 }, { "ml", NL ("*"), 2 }, { "mm", NL ("--"), 1 }, { "na", NL ("new[]"), 1 }, { "ne", NL ("!="), 2 }, { "ng", NL ("-"), 1 }, { "nt", NL ("!"), 1 }, { "nw", NL ("new"), 1 }, { "oR", NL ("|="), 2 }, { "oo", NL ("||"), 2 }, { "or", NL ("|"), 2 }, { "pL", NL ("+="), 2 }, { "pl", NL ("+"), 2 }, { "pm", NL ("->*"), 2 }, { "pp", NL ("++"), 1 }, { "ps", NL ("+"), 1 }, { "pt", NL ("->"), 2 }, { "qu", NL ("?"), 3 }, { "rM", NL ("%="), 2 }, { "rS", NL (">>="), 2 }, { "rm", NL ("%"), 2 }, { "rs", NL (">>"), 2 }, { "st", NL ("sizeof "), 1 }, { "sz", NL ("sizeof "), 1 }, { "at", NL ("alignof "), 1 }, { "az", NL ("alignof "), 1 }, { NULL, NULL, 0, 0 } }; static struct demangle_component * d_operator_name (struct d_info *di) { char c1; char c2; c1 = d_next_char (di); c2 = d_next_char (di); if (c1 == 'v' && IS_DIGIT (c2)) return d_make_extended_operator (di, c2 - '0', d_source_name (di)); else if (c1 == 'c' && c2 == 'v') return d_make_comp (di, DEMANGLE_COMPONENT_CAST, cplus_demangle_type (di), NULL); else { /* LOW is the inclusive lower bound. */ int low = 0; /* HIGH is the exclusive upper bound. We subtract one to ignore the sentinel at the end of the array. */ int high = ((sizeof (cplus_demangle_operators) / sizeof (cplus_demangle_operators[0])) - 1); while (1) { int i; const struct demangle_operator_info *p; i = low + (high - low) / 2; p = cplus_demangle_operators + i; if (c1 == p->code[0] && c2 == p->code[1]) return d_make_operator (di, p); if (c1 < p->code[0] || (c1 == p->code[0] && c2 < p->code[1])) high = i; else low = i + 1; if (low == high) return NULL; } } } static struct demangle_component * d_make_character (struct d_info *di, int c) { struct demangle_component *p; p = d_make_empty (di); if (p != NULL) { p->type = DEMANGLE_COMPONENT_CHARACTER; p->u.s_character.character = c; } return p; } static struct demangle_component * d_java_resource (struct d_info *di) { struct demangle_component *p = NULL; struct demangle_component *next = NULL; long len, i; char c; const char *str; len = d_number (di); if (len <= 1) return NULL; /* Eat the leading '_'. */ if (d_next_char (di) != '_') return NULL; len--; str = d_str (di); i = 0; while (len > 0) { c = str[i]; if (!c) return NULL; /* Each chunk is either a '$' escape... */ if (c == '$') { i++; switch (str[i++]) { case 'S': c = '/'; break; case '_': c = '.'; break; case '$': c = '$'; break; default: return NULL; } next = d_make_character (di, c); d_advance (di, i); str = d_str (di); len -= i; i = 0; if (next == NULL) return NULL; } /* ... or a sequence of characters. */ else { while (i < len && str[i] && str[i] != '$') i++; next = d_make_name (di, str, i); d_advance (di, i); str = d_str (di); len -= i; i = 0; if (next == NULL) return NULL; } if (p == NULL) p = next; else { p = d_make_comp (di, DEMANGLE_COMPONENT_COMPOUND_NAME, p, next); if (p == NULL) return NULL; } } p = d_make_comp (di, DEMANGLE_COMPONENT_JAVA_RESOURCE, p, NULL); return p; } /* ::= TV ::= TT ::= TI ::= TS ::= GV <(object) name> ::= T <(base) encoding> ::= Tc <(base) encoding> Also g++ extensions: ::= TC <(offset) number> _ <(base) type> ::= TF ::= TJ ::= GR ::= GA ::= Gr */ static struct demangle_component * d_special_name (struct d_info *di) { di->expansion += 20; if (d_check_char (di, 'T')) { switch (d_next_char (di)) { case 'V': di->expansion -= 5; return d_make_comp (di, DEMANGLE_COMPONENT_VTABLE, cplus_demangle_type (di), NULL); case 'T': di->expansion -= 10; return d_make_comp (di, DEMANGLE_COMPONENT_VTT, cplus_demangle_type (di), NULL); case 'I': return d_make_comp (di, DEMANGLE_COMPONENT_TYPEINFO, cplus_demangle_type (di), NULL); case 'S': return d_make_comp (di, DEMANGLE_COMPONENT_TYPEINFO_NAME, cplus_demangle_type (di), NULL); case 'h': if (! d_call_offset (di, 'h')) return NULL; return d_make_comp (di, DEMANGLE_COMPONENT_THUNK, d_encoding (di, 0), NULL); case 'v': if (! d_call_offset (di, 'v')) return NULL; return d_make_comp (di, DEMANGLE_COMPONENT_VIRTUAL_THUNK, d_encoding (di, 0), NULL); case 'c': if (! d_call_offset (di, '\0')) return NULL; if (! d_call_offset (di, '\0')) return NULL; return d_make_comp (di, DEMANGLE_COMPONENT_COVARIANT_THUNK, d_encoding (di, 0), NULL); case 'C': { struct demangle_component *derived_type; long offset; struct demangle_component *base_type; derived_type = cplus_demangle_type (di); offset = d_number (di); if (offset < 0) return NULL; if (! d_check_char (di, '_')) return NULL; base_type = cplus_demangle_type (di); /* We don't display the offset. FIXME: We should display it in verbose mode. */ di->expansion += 5; return d_make_comp (di, DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE, base_type, derived_type); } case 'F': return d_make_comp (di, DEMANGLE_COMPONENT_TYPEINFO_FN, cplus_demangle_type (di), NULL); case 'J': return d_make_comp (di, DEMANGLE_COMPONENT_JAVA_CLASS, cplus_demangle_type (di), NULL); default: return NULL; } } else if (d_check_char (di, 'G')) { switch (d_next_char (di)) { case 'V': return d_make_comp (di, DEMANGLE_COMPONENT_GUARD, d_name (di), NULL); case 'R': return d_make_comp (di, DEMANGLE_COMPONENT_REFTEMP, d_name (di), NULL); case 'A': return d_make_comp (di, DEMANGLE_COMPONENT_HIDDEN_ALIAS, d_encoding (di, 0), NULL); case 'r': return d_java_resource (di); default: return NULL; } } else return NULL; } /* ::= h _ ::= v _ ::= <(offset) number> ::= <(offset) number> _ <(virtual offset) number> The C parameter, if not '\0', is a character we just read which is the start of the . We don't display the offset information anywhere. FIXME: We should display it in verbose mode. */ static int d_call_offset (struct d_info *di, int c) { if (c == '\0') c = d_next_char (di); if (c == 'h') d_number (di); else if (c == 'v') { d_number (di); if (! d_check_char (di, '_')) return 0; d_number (di); } else return 0; if (! d_check_char (di, '_')) return 0; return 1; } /* ::= C1 ::= C2 ::= C3 ::= D0 ::= D1 ::= D2 */ static struct demangle_component * d_ctor_dtor_name (struct d_info *di) { if (di->last_name != NULL) { if (di->last_name->type == DEMANGLE_COMPONENT_NAME) di->expansion += di->last_name->u.s_name.len; else if (di->last_name->type == DEMANGLE_COMPONENT_SUB_STD) di->expansion += di->last_name->u.s_string.len; } switch (d_peek_char (di)) { case 'C': { enum gnu_v3_ctor_kinds kind; switch (d_peek_next_char (di)) { case '1': kind = gnu_v3_complete_object_ctor; break; case '2': kind = gnu_v3_base_object_ctor; break; case '3': kind = gnu_v3_complete_object_allocating_ctor; break; default: return NULL; } d_advance (di, 2); return d_make_ctor (di, kind, di->last_name); } case 'D': { enum gnu_v3_dtor_kinds kind; switch (d_peek_next_char (di)) { case '0': kind = gnu_v3_deleting_dtor; break; case '1': kind = gnu_v3_complete_object_dtor; break; case '2': kind = gnu_v3_base_object_dtor; break; default: return NULL; } d_advance (di, 2); return d_make_dtor (di, kind, di->last_name); } default: return NULL; } } /* ::= ::= ::= ::= ::= ::= ::= ::= ::= ::= P ::= R ::= O (C++0x) ::= C ::= G ::= U ::= various one letter codes ::= u */ CP_STATIC_IF_GLIBCPP_V3 const struct demangle_builtin_type_info cplus_demangle_builtin_types[D_BUILTIN_TYPE_COUNT] = { /* a */ { NL ("signed char"), NL ("signed char"), D_PRINT_DEFAULT }, /* b */ { NL ("bool"), NL ("boolean"), D_PRINT_BOOL }, /* c */ { NL ("char"), NL ("byte"), D_PRINT_DEFAULT }, /* d */ { NL ("double"), NL ("double"), D_PRINT_FLOAT }, /* e */ { NL ("long double"), NL ("long double"), D_PRINT_FLOAT }, /* f */ { NL ("float"), NL ("float"), D_PRINT_FLOAT }, /* g */ { NL ("__float128"), NL ("__float128"), D_PRINT_FLOAT }, /* h */ { NL ("unsigned char"), NL ("unsigned char"), D_PRINT_DEFAULT }, /* i */ { NL ("int"), NL ("int"), D_PRINT_INT }, /* j */ { NL ("unsigned int"), NL ("unsigned"), D_PRINT_UNSIGNED }, /* k */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, /* l */ { NL ("long"), NL ("long"), D_PRINT_LONG }, /* m */ { NL ("unsigned long"), NL ("unsigned long"), D_PRINT_UNSIGNED_LONG }, /* n */ { NL ("__int128"), NL ("__int128"), D_PRINT_DEFAULT }, /* o */ { NL ("unsigned __int128"), NL ("unsigned __int128"), D_PRINT_DEFAULT }, /* p */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, /* q */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, /* r */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, /* s */ { NL ("short"), NL ("short"), D_PRINT_DEFAULT }, /* t */ { NL ("unsigned short"), NL ("unsigned short"), D_PRINT_DEFAULT }, /* u */ { NULL, 0, NULL, 0, D_PRINT_DEFAULT }, /* v */ { NL ("void"), NL ("void"), D_PRINT_VOID }, /* w */ { NL ("wchar_t"), NL ("char"), D_PRINT_DEFAULT }, /* x */ { NL ("long long"), NL ("long"), D_PRINT_LONG_LONG }, /* y */ { NL ("unsigned long long"), NL ("unsigned long long"), D_PRINT_UNSIGNED_LONG_LONG }, /* z */ { NL ("..."), NL ("..."), D_PRINT_DEFAULT }, /* 26 */ { NL ("decimal32"), NL ("decimal32"), D_PRINT_DEFAULT }, /* 27 */ { NL ("decimal64"), NL ("decimal64"), D_PRINT_DEFAULT }, /* 28 */ { NL ("decimal128"), NL ("decimal128"), D_PRINT_DEFAULT }, /* 29 */ { NL ("half"), NL ("half"), D_PRINT_FLOAT }, /* 30 */ { NL ("char16_t"), NL ("char16_t"), D_PRINT_DEFAULT }, /* 31 */ { NL ("char32_t"), NL ("char32_t"), D_PRINT_DEFAULT }, /* 32 */ { NL ("decltype(nullptr)"), NL ("decltype(nullptr)"), D_PRINT_DEFAULT }, }; CP_STATIC_IF_GLIBCPP_V3 struct demangle_component * cplus_demangle_type (struct d_info *di) { char peek; struct demangle_component *ret; int can_subst; /* The ABI specifies that when CV-qualifiers are used, the base type is substitutable, and the fully qualified type is substitutable, but the base type with a strict subset of the CV-qualifiers is not substitutable. The natural recursive implementation of the CV-qualifiers would cause subsets to be substitutable, so instead we pull them all off now. FIXME: The ABI says that order-insensitive vendor qualifiers should be handled in the same way, but we have no way to tell which vendor qualifiers are order-insensitive and which are order-sensitive. So we just assume that they are all order-sensitive. g++ 3.4 supports only one vendor qualifier, __vector, and it treats it as order-sensitive when mangling names. */ peek = d_peek_char (di); if (peek == 'r' || peek == 'V' || peek == 'K') { struct demangle_component **pret; pret = d_cv_qualifiers (di, &ret, 0); if (pret == NULL) return NULL; *pret = cplus_demangle_type (di); if (! *pret || ! d_add_substitution (di, ret)) return NULL; return ret; } can_subst = 1; switch (peek) { case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'l': case 'm': case 'n': case 'o': case 's': case 't': case 'v': case 'w': case 'x': case 'y': case 'z': ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[peek - 'a']); di->expansion += ret->u.s_builtin.type->len; can_subst = 0; d_advance (di, 1); break; case 'u': d_advance (di, 1); ret = d_make_comp (di, DEMANGLE_COMPONENT_VENDOR_TYPE, d_source_name (di), NULL); break; case 'F': ret = d_function_type (di); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case 'N': case 'Z': ret = d_class_enum_type (di); break; case 'A': ret = d_array_type (di); break; case 'M': ret = d_pointer_to_member_type (di); break; case 'T': ret = d_template_param (di); if (d_peek_char (di) == 'I') { /* This is . The part is a substitution candidate. */ if (! d_add_substitution (di, ret)) return NULL; ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret, d_template_args (di)); } break; case 'S': /* If this is a special substitution, then it is the start of . */ { char peek_next; peek_next = d_peek_next_char (di); if (IS_DIGIT (peek_next) || peek_next == '_' || IS_UPPER (peek_next)) { ret = d_substitution (di, 0); /* The substituted name may have been a template name and may be followed by tepmlate args. */ if (d_peek_char (di) == 'I') ret = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, ret, d_template_args (di)); else can_subst = 0; } else { ret = d_class_enum_type (di); /* If the substitution was a complete type, then it is not a new substitution candidate. However, if the substitution was followed by template arguments, then the whole thing is a substitution candidate. */ if (ret != NULL && ret->type == DEMANGLE_COMPONENT_SUB_STD) can_subst = 0; } } break; case 'O': d_advance (di, 1); ret = d_make_comp (di, DEMANGLE_COMPONENT_RVALUE_REFERENCE, cplus_demangle_type (di), NULL); break; case 'P': d_advance (di, 1); ret = d_make_comp (di, DEMANGLE_COMPONENT_POINTER, cplus_demangle_type (di), NULL); break; case 'R': d_advance (di, 1); ret = d_make_comp (di, DEMANGLE_COMPONENT_REFERENCE, cplus_demangle_type (di), NULL); break; case 'C': d_advance (di, 1); ret = d_make_comp (di, DEMANGLE_COMPONENT_COMPLEX, cplus_demangle_type (di), NULL); break; case 'G': d_advance (di, 1); ret = d_make_comp (di, DEMANGLE_COMPONENT_IMAGINARY, cplus_demangle_type (di), NULL); break; case 'U': d_advance (di, 1); ret = d_source_name (di); ret = d_make_comp (di, DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL, cplus_demangle_type (di), ret); break; case 'D': can_subst = 0; d_advance (di, 1); peek = d_next_char (di); switch (peek) { case 'T': case 't': /* decltype (expression) */ ret = d_make_comp (di, DEMANGLE_COMPONENT_DECLTYPE, d_expression (di), NULL); if (ret && d_next_char (di) != 'E') ret = NULL; break; case 'p': /* Pack expansion. */ ret = d_make_comp (di, DEMANGLE_COMPONENT_PACK_EXPANSION, cplus_demangle_type (di), NULL); break; case 'f': /* 32-bit decimal floating point */ ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[26]); di->expansion += ret->u.s_builtin.type->len; break; case 'd': /* 64-bit DFP */ ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[27]); di->expansion += ret->u.s_builtin.type->len; break; case 'e': /* 128-bit DFP */ ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[28]); di->expansion += ret->u.s_builtin.type->len; break; case 'h': /* 16-bit half-precision FP */ ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[29]); di->expansion += ret->u.s_builtin.type->len; break; case 's': /* char16_t */ ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[30]); di->expansion += ret->u.s_builtin.type->len; break; case 'i': /* char32_t */ ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[31]); di->expansion += ret->u.s_builtin.type->len; break; case 'F': /* Fixed point types. DF */ ret = d_make_empty (di); ret->type = DEMANGLE_COMPONENT_FIXED_TYPE; if ((ret->u.s_fixed.accum = IS_DIGIT (d_peek_char (di)))) /* For demangling we don't care about the bits. */ d_number (di); ret->u.s_fixed.length = cplus_demangle_type (di); if (ret->u.s_fixed.length == NULL) return NULL; d_number (di); peek = d_next_char (di); ret->u.s_fixed.sat = (peek == 's'); break; case 'v': ret = d_vector_type (di); break; case 'n': /* decltype(nullptr) */ ret = d_make_builtin_type (di, &cplus_demangle_builtin_types[32]); di->expansion += ret->u.s_builtin.type->len; break; default: return NULL; } break; default: return NULL; } if (can_subst) { if (! d_add_substitution (di, ret)) return NULL; } return ret; } /* ::= [r] [V] [K] */ static struct demangle_component ** d_cv_qualifiers (struct d_info *di, struct demangle_component **pret, int member_fn) { char peek; peek = d_peek_char (di); while (peek == 'r' || peek == 'V' || peek == 'K') { enum demangle_component_type t; d_advance (di, 1); if (peek == 'r') { t = (member_fn ? DEMANGLE_COMPONENT_RESTRICT_THIS : DEMANGLE_COMPONENT_RESTRICT); di->expansion += sizeof "restrict"; } else if (peek == 'V') { t = (member_fn ? DEMANGLE_COMPONENT_VOLATILE_THIS : DEMANGLE_COMPONENT_VOLATILE); di->expansion += sizeof "volatile"; } else { t = (member_fn ? DEMANGLE_COMPONENT_CONST_THIS : DEMANGLE_COMPONENT_CONST); di->expansion += sizeof "const"; } *pret = d_make_comp (di, t, NULL, NULL); if (*pret == NULL) return NULL; pret = &d_left (*pret); peek = d_peek_char (di); } return pret; } /* ::= F [Y] E */ static struct demangle_component * d_function_type (struct d_info *di) { struct demangle_component *ret; if (! d_check_char (di, 'F')) return NULL; if (d_peek_char (di) == 'Y') { /* Function has C linkage. We don't print this information. FIXME: We should print it in verbose mode. */ d_advance (di, 1); } ret = d_bare_function_type (di, 1); if (! d_check_char (di, 'E')) return NULL; return ret; } /* + */ static struct demangle_component * d_parmlist (struct d_info *di) { struct demangle_component *tl; struct demangle_component **ptl; tl = NULL; ptl = &tl; while (1) { struct demangle_component *type; char peek = d_peek_char (di); if (peek == '\0' || peek == 'E') break; type = cplus_demangle_type (di); if (type == NULL) return NULL; *ptl = d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, type, NULL); if (*ptl == NULL) return NULL; ptl = &d_right (*ptl); } /* There should be at least one parameter type besides the optional return type. A function which takes no arguments will have a single parameter type void. */ if (tl == NULL) return NULL; /* If we have a single parameter type void, omit it. */ if (d_right (tl) == NULL && d_left (tl)->type == DEMANGLE_COMPONENT_BUILTIN_TYPE && d_left (tl)->u.s_builtin.type->print == D_PRINT_VOID) { di->expansion -= d_left (tl)->u.s_builtin.type->len; d_left (tl) = NULL; } return tl; } /* ::= [J]+ */ static struct demangle_component * d_bare_function_type (struct d_info *di, int has_return_type) { struct demangle_component *return_type; struct demangle_component *tl; char peek; /* Detect special qualifier indicating that the first argument is the return type. */ peek = d_peek_char (di); if (peek == 'J') { d_advance (di, 1); has_return_type = 1; } if (has_return_type) { return_type = cplus_demangle_type (di); if (return_type == NULL) return NULL; } else return_type = NULL; tl = d_parmlist (di); if (tl == NULL) return NULL; return d_make_comp (di, DEMANGLE_COMPONENT_FUNCTION_TYPE, return_type, tl); } /* ::= */ static struct demangle_component * d_class_enum_type (struct d_info *di) { return d_name (di); } /* ::= A <(positive dimension) number> _ <(element) type> ::= A [<(dimension) expression>] _ <(element) type> */ static struct demangle_component * d_array_type (struct d_info *di) { char peek; struct demangle_component *dim; if (! d_check_char (di, 'A')) return NULL; peek = d_peek_char (di); if (peek == '_') dim = NULL; else if (IS_DIGIT (peek)) { const char *s; s = d_str (di); do { d_advance (di, 1); peek = d_peek_char (di); } while (IS_DIGIT (peek)); dim = d_make_name (di, s, d_str (di) - s); if (dim == NULL) return NULL; } else { dim = d_expression (di); if (dim == NULL) return NULL; } if (! d_check_char (di, '_')) return NULL; return d_make_comp (di, DEMANGLE_COMPONENT_ARRAY_TYPE, dim, cplus_demangle_type (di)); } /* ::= Dv _ ::= Dv _ _ */ static struct demangle_component * d_vector_type (struct d_info *di) { char peek; struct demangle_component *dim; peek = d_peek_char (di); if (peek == '_') { d_advance (di, 1); dim = d_expression (di); } else dim = d_number_component (di); if (dim == NULL) return NULL; if (! d_check_char (di, '_')) return NULL; return d_make_comp (di, DEMANGLE_COMPONENT_VECTOR_TYPE, dim, cplus_demangle_type (di)); } /* ::= M <(class) type> <(member) type> */ static struct demangle_component * d_pointer_to_member_type (struct d_info *di) { struct demangle_component *cl; struct demangle_component *mem; struct demangle_component **pmem; if (! d_check_char (di, 'M')) return NULL; cl = cplus_demangle_type (di); /* The ABI specifies that any type can be a substitution source, and that M is followed by two types, and that when a CV-qualified type is seen both the base type and the CV-qualified types are substitution sources. The ABI also specifies that for a pointer to a CV-qualified member function, the qualifiers are attached to the second type. Given the grammar, a plain reading of the ABI suggests that both the CV-qualified member function and the non-qualified member function are substitution sources. However, g++ does not work that way. g++ treats only the CV-qualified member function as a substitution source. FIXME. So to work with g++, we need to pull off the CV-qualifiers here, in order to avoid calling add_substitution() in cplus_demangle_type(). But for a CV-qualified member which is not a function, g++ does follow the ABI, so we need to handle that case here by calling d_add_substitution ourselves. */ pmem = d_cv_qualifiers (di, &mem, 1); if (pmem == NULL) return NULL; *pmem = cplus_demangle_type (di); if (*pmem == NULL) return NULL; if (pmem != &mem && (*pmem)->type != DEMANGLE_COMPONENT_FUNCTION_TYPE) { if (! d_add_substitution (di, mem)) return NULL; } return d_make_comp (di, DEMANGLE_COMPONENT_PTRMEM_TYPE, cl, mem); } /* _ */ static long d_compact_number (struct d_info *di) { long num; if (d_peek_char (di) == '_') num = 0; else if (d_peek_char (di) == 'n') return -1; else num = d_number (di) + 1; if (! d_check_char (di, '_')) return -1; return num; } /* ::= T_ ::= T <(parameter-2 non-negative) number> _ */ static struct demangle_component * d_template_param (struct d_info *di) { long param; if (! d_check_char (di, 'T')) return NULL; param = d_compact_number (di); if (param < 0) return NULL; ++di->did_subs; return d_make_template_param (di, param); } /* ::= I + E */ static struct demangle_component * d_template_args (struct d_info *di) { struct demangle_component *hold_last_name; struct demangle_component *al; struct demangle_component **pal; /* Preserve the last name we saw--don't let the template arguments clobber it, as that would give us the wrong name for a subsequent constructor or destructor. */ hold_last_name = di->last_name; if (! d_check_char (di, 'I')) return NULL; if (d_peek_char (di) == 'E') { /* An argument pack can be empty. */ d_advance (di, 1); return d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, NULL, NULL); } al = NULL; pal = &al; while (1) { struct demangle_component *a; a = d_template_arg (di); if (a == NULL) return NULL; *pal = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE_ARGLIST, a, NULL); if (*pal == NULL) return NULL; pal = &d_right (*pal); if (d_peek_char (di) == 'E') { d_advance (di, 1); break; } } di->last_name = hold_last_name; return al; } /* ::= ::= X E ::= */ static struct demangle_component * d_template_arg (struct d_info *di) { struct demangle_component *ret; switch (d_peek_char (di)) { case 'X': d_advance (di, 1); ret = d_expression (di); if (! d_check_char (di, 'E')) return NULL; return ret; case 'L': return d_expr_primary (di); case 'I': /* An argument pack. */ return d_template_args (di); default: return cplus_demangle_type (di); } } /* Subroutine of ::= cl + E */ static struct demangle_component * d_exprlist (struct d_info *di) { struct demangle_component *list = NULL; struct demangle_component **p = &list; if (d_peek_char (di) == 'E') { d_advance (di, 1); return d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, NULL, NULL); } while (1) { struct demangle_component *arg = d_expression (di); if (arg == NULL) return NULL; *p = d_make_comp (di, DEMANGLE_COMPONENT_ARGLIST, arg, NULL); if (*p == NULL) return NULL; p = &d_right (*p); if (d_peek_char (di) == 'E') { d_advance (di, 1); break; } } return list; } /* ::= <(unary) operator-name> ::= <(binary) operator-name> ::= <(trinary) operator-name> ::= cl + E ::= st ::= ::= sr ::= sr ::= */ static struct demangle_component * d_expression (struct d_info *di) { char peek; peek = d_peek_char (di); if (peek == 'L') return d_expr_primary (di); else if (peek == 'T') return d_template_param (di); else if (peek == 's' && d_peek_next_char (di) == 'r') { struct demangle_component *type; struct demangle_component *name; d_advance (di, 2); type = cplus_demangle_type (di); name = d_unqualified_name (di); if (d_peek_char (di) != 'I') return d_make_comp (di, DEMANGLE_COMPONENT_QUAL_NAME, type, name); else return d_make_comp (di, DEMANGLE_COMPONENT_QUAL_NAME, type, d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, name, d_template_args (di))); } else if (peek == 's' && d_peek_next_char (di) == 'p') { d_advance (di, 2); return d_make_comp (di, DEMANGLE_COMPONENT_PACK_EXPANSION, d_expression (di), NULL); } else if (peek == 'f' && d_peek_next_char (di) == 'p') { /* Function parameter used in a late-specified return type. */ int index; d_advance (di, 2); index = d_compact_number (di); if (index < 0) return NULL; return d_make_function_param (di, index); } else if (IS_DIGIT (peek) || (peek == 'o' && d_peek_next_char (di) == 'n')) { /* We can get an unqualified name as an expression in the case of a dependent function call, i.e. decltype(f(t)). */ struct demangle_component *name; if (peek == 'o') /* operator-function-id, i.e. operator+(t). */ d_advance (di, 2); name = d_unqualified_name (di); if (name == NULL) return NULL; if (d_peek_char (di) == 'I') return d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, name, d_template_args (di)); else return name; } else { struct demangle_component *op; int args; op = d_operator_name (di); if (op == NULL) return NULL; if (op->type == DEMANGLE_COMPONENT_OPERATOR) di->expansion += op->u.s_operator.op->len - 2; if (op->type == DEMANGLE_COMPONENT_OPERATOR && strcmp (op->u.s_operator.op->code, "st") == 0) return d_make_comp (di, DEMANGLE_COMPONENT_UNARY, op, cplus_demangle_type (di)); switch (op->type) { default: return NULL; case DEMANGLE_COMPONENT_OPERATOR: args = op->u.s_operator.op->args; break; case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: args = op->u.s_extended_operator.args; break; case DEMANGLE_COMPONENT_CAST: args = 1; break; } switch (args) { case 1: { struct demangle_component *operand; if (op->type == DEMANGLE_COMPONENT_CAST && d_check_char (di, '_')) operand = d_exprlist (di); else operand = d_expression (di); return d_make_comp (di, DEMANGLE_COMPONENT_UNARY, op, operand); } case 2: { struct demangle_component *left; struct demangle_component *right; const char *code = op->u.s_operator.op->code; left = d_expression (di); if (!strcmp (code, "cl")) right = d_exprlist (di); else if (!strcmp (code, "dt") || !strcmp (code, "pt")) { right = d_unqualified_name (di); if (d_peek_char (di) == 'I') right = d_make_comp (di, DEMANGLE_COMPONENT_TEMPLATE, right, d_template_args (di)); } else right = d_expression (di); return d_make_comp (di, DEMANGLE_COMPONENT_BINARY, op, d_make_comp (di, DEMANGLE_COMPONENT_BINARY_ARGS, left, right)); } case 3: { struct demangle_component *first; struct demangle_component *second; first = d_expression (di); second = d_expression (di); return d_make_comp (di, DEMANGLE_COMPONENT_TRINARY, op, d_make_comp (di, DEMANGLE_COMPONENT_TRINARY_ARG1, first, d_make_comp (di, DEMANGLE_COMPONENT_TRINARY_ARG2, second, d_expression (di)))); } default: return NULL; } } } /* ::= L <(value) number> E ::= L <(value) float> E ::= L E */ static struct demangle_component * d_expr_primary (struct d_info *di) { struct demangle_component *ret; if (! d_check_char (di, 'L')) return NULL; if (d_peek_char (di) == '_' /* Workaround for G++ bug; see comment in write_template_arg. */ || d_peek_char (di) == 'Z') ret = cplus_demangle_mangled_name (di, 0); else { struct demangle_component *type; enum demangle_component_type t; const char *s; type = cplus_demangle_type (di); if (type == NULL) return NULL; /* If we have a type we know how to print, we aren't going to print the type name itself. */ if (type->type == DEMANGLE_COMPONENT_BUILTIN_TYPE && type->u.s_builtin.type->print != D_PRINT_DEFAULT) di->expansion -= type->u.s_builtin.type->len; /* Rather than try to interpret the literal value, we just collect it as a string. Note that it's possible to have a floating point literal here. The ABI specifies that the format of such literals is machine independent. That's fine, but what's not fine is that versions of g++ up to 3.2 with -fabi-version=1 used upper case letters in the hex constant, and dumped out gcc's internal representation. That makes it hard to tell where the constant ends, and hard to dump the constant in any readable form anyhow. We don't attempt to handle these cases. */ t = DEMANGLE_COMPONENT_LITERAL; if (d_peek_char (di) == 'n') { t = DEMANGLE_COMPONENT_LITERAL_NEG; d_advance (di, 1); } s = d_str (di); while (d_peek_char (di) != 'E') { if (d_peek_char (di) == '\0') return NULL; d_advance (di, 1); } ret = d_make_comp (di, t, type, d_make_name (di, s, d_str (di) - s)); } if (! d_check_char (di, 'E')) return NULL; return ret; } /* ::= Z <(function) encoding> E <(entity) name> [] ::= Z <(function) encoding> E s [] */ static struct demangle_component * d_local_name (struct d_info *di) { struct demangle_component *function; if (! d_check_char (di, 'Z')) return NULL; function = d_encoding (di, 0); if (! d_check_char (di, 'E')) return NULL; if (d_peek_char (di) == 's') { d_advance (di, 1); if (! d_discriminator (di)) return NULL; return d_make_comp (di, DEMANGLE_COMPONENT_LOCAL_NAME, function, d_make_name (di, "string literal", sizeof "string literal" - 1)); } else { struct demangle_component *name; int num = -1; if (d_peek_char (di) == 'd') { /* Default argument scope: d _. */ d_advance (di, 1); num = d_compact_number (di); if (num < 0) return NULL; } name = d_name (di); if (name) switch (name->type) { /* Lambdas and unnamed types have internal discriminators. */ case DEMANGLE_COMPONENT_LAMBDA: case DEMANGLE_COMPONENT_UNNAMED_TYPE: break; default: if (! d_discriminator (di)) return NULL; } if (num >= 0) name = d_make_default_arg (di, num, name); return d_make_comp (di, DEMANGLE_COMPONENT_LOCAL_NAME, function, name); } } /* ::= _ <(non-negative) number> We demangle the discriminator, but we don't print it out. FIXME: We should print it out in verbose mode. */ static int d_discriminator (struct d_info *di) { long discrim; if (d_peek_char (di) != '_') return 1; d_advance (di, 1); discrim = d_number (di); if (discrim < 0) return 0; return 1; } /* ::= Ul E [ ] _ */ static struct demangle_component * d_lambda (struct d_info *di) { struct demangle_component *tl; struct demangle_component *ret; int num; if (! d_check_char (di, 'U')) return NULL; if (! d_check_char (di, 'l')) return NULL; tl = d_parmlist (di); if (tl == NULL) return NULL; if (! d_check_char (di, 'E')) return NULL; num = d_compact_number (di); if (num < 0) return NULL; ret = d_make_empty (di); if (ret) { ret->type = DEMANGLE_COMPONENT_LAMBDA; ret->u.s_unary_num.sub = tl; ret->u.s_unary_num.num = num; } if (! d_add_substitution (di, ret)) return NULL; return ret; } /* ::= Ut [ ] _ */ static struct demangle_component * d_unnamed_type (struct d_info *di) { struct demangle_component *ret; long num; if (! d_check_char (di, 'U')) return NULL; if (! d_check_char (di, 't')) return NULL; num = d_compact_number (di); if (num < 0) return NULL; ret = d_make_empty (di); if (ret) { ret->type = DEMANGLE_COMPONENT_UNNAMED_TYPE; ret->u.s_number.number = num; } if (! d_add_substitution (di, ret)) return NULL; return ret; } /* Add a new substitution. */ static int d_add_substitution (struct d_info *di, struct demangle_component *dc) { if (dc == NULL) return 0; if (di->next_sub >= di->num_subs) return 0; di->subs[di->next_sub] = dc; ++di->next_sub; return 1; } /* ::= S _ ::= S_ ::= St ::= Sa ::= Sb ::= Ss ::= Si ::= So ::= Sd If PREFIX is non-zero, then this type is being used as a prefix in a qualified name. In this case, for the standard substitutions, we need to check whether we are being used as a prefix for a constructor or destructor, and return a full template name. Otherwise we will get something like std::iostream::~iostream() which does not correspond particularly well to any function which actually appears in the source. */ static const struct d_standard_sub_info standard_subs[] = { { 't', NL ("std"), NL ("std"), NULL, 0 }, { 'a', NL ("std::allocator"), NL ("std::allocator"), NL ("allocator") }, { 'b', NL ("std::basic_string"), NL ("std::basic_string"), NL ("basic_string") }, { 's', NL ("std::string"), NL ("std::basic_string, std::allocator >"), NL ("basic_string") }, { 'i', NL ("std::istream"), NL ("std::basic_istream >"), NL ("basic_istream") }, { 'o', NL ("std::ostream"), NL ("std::basic_ostream >"), NL ("basic_ostream") }, { 'd', NL ("std::iostream"), NL ("std::basic_iostream >"), NL ("basic_iostream") } }; static struct demangle_component * d_substitution (struct d_info *di, int prefix) { char c; if (! d_check_char (di, 'S')) return NULL; c = d_next_char (di); if (c == '_' || IS_DIGIT (c) || IS_UPPER (c)) { unsigned int id; id = 0; if (c != '_') { do { unsigned int new_id; if (IS_DIGIT (c)) new_id = id * 36 + c - '0'; else if (IS_UPPER (c)) new_id = id * 36 + c - 'A' + 10; else return NULL; if (new_id < id) return NULL; id = new_id; c = d_next_char (di); } while (c != '_'); ++id; } if (id >= (unsigned int) di->next_sub) return NULL; ++di->did_subs; return di->subs[id]; } else { int verbose; const struct d_standard_sub_info *p; const struct d_standard_sub_info *pend; verbose = (di->options & DMGL_VERBOSE) != 0; if (! verbose && prefix) { char peek; peek = d_peek_char (di); if (peek == 'C' || peek == 'D') verbose = 1; } pend = (&standard_subs[0] + sizeof standard_subs / sizeof standard_subs[0]); for (p = &standard_subs[0]; p < pend; ++p) { if (c == p->code) { const char *s; int len; if (p->set_last_name != NULL) di->last_name = d_make_sub (di, p->set_last_name, p->set_last_name_len); if (verbose) { s = p->full_expansion; len = p->full_len; } else { s = p->simple_expansion; len = p->simple_len; } di->expansion += len; return d_make_sub (di, s, len); } } return NULL; } } /* Initialize a growable string. */ static void d_growable_string_init (struct d_growable_string *dgs, size_t estimate) { dgs->buf = NULL; dgs->len = 0; dgs->alc = 0; dgs->allocation_failure = 0; if (estimate > 0) d_growable_string_resize (dgs, estimate); } /* Grow a growable string to a given size. */ static inline void d_growable_string_resize (struct d_growable_string *dgs, size_t need) { size_t newalc; char *newbuf; if (dgs->allocation_failure) return; /* Start allocation at two bytes to avoid any possibility of confusion with the special value of 1 used as a return in *palc to indicate allocation failures. */ newalc = dgs->alc > 0 ? dgs->alc : 2; while (newalc < need) newalc <<= 1; newbuf = (char *) realloc (dgs->buf, newalc); if (newbuf == NULL) { free (dgs->buf); dgs->buf = NULL; dgs->len = 0; dgs->alc = 0; dgs->allocation_failure = 1; return; } dgs->buf = newbuf; dgs->alc = newalc; } /* Append a buffer to a growable string. */ static inline void d_growable_string_append_buffer (struct d_growable_string *dgs, const char *s, size_t l) { size_t need; need = dgs->len + l + 1; if (need > dgs->alc) d_growable_string_resize (dgs, need); if (dgs->allocation_failure) return; memcpy (dgs->buf + dgs->len, s, l); dgs->buf[dgs->len + l] = '\0'; dgs->len += l; } /* Bridge growable strings to the callback mechanism. */ static void d_growable_string_callback_adapter (const char *s, size_t l, void *opaque) { struct d_growable_string *dgs = (struct d_growable_string*) opaque; d_growable_string_append_buffer (dgs, s, l); } /* Initialize a print information structure. */ static void d_print_init (struct d_print_info *dpi, int options, demangle_callbackref callback, void *opaque) { dpi->options = options; dpi->len = 0; dpi->last_char = '\0'; dpi->templates = NULL; dpi->modifiers = NULL; dpi->flush_count = 0; dpi->callback = callback; dpi->opaque = opaque; dpi->demangle_failure = 0; } /* Indicate that an error occurred during printing, and test for error. */ static inline void d_print_error (struct d_print_info *dpi) { dpi->demangle_failure = 1; } static inline int d_print_saw_error (struct d_print_info *dpi) { return dpi->demangle_failure != 0; } /* Flush buffered characters to the callback. */ static inline void d_print_flush (struct d_print_info *dpi) { dpi->buf[dpi->len] = '\0'; dpi->callback (dpi->buf, dpi->len, dpi->opaque); dpi->len = 0; dpi->flush_count++; } /* Append characters and buffers for printing. */ static inline void d_append_char (struct d_print_info *dpi, char c) { if (dpi->len == sizeof (dpi->buf) - 1) d_print_flush (dpi); dpi->buf[dpi->len++] = c; dpi->last_char = c; } static inline void d_append_buffer (struct d_print_info *dpi, const char *s, size_t l) { size_t i; for (i = 0; i < l; i++) d_append_char (dpi, s[i]); } static inline void d_append_string (struct d_print_info *dpi, const char *s) { d_append_buffer (dpi, s, strlen (s)); } static inline void d_append_num (struct d_print_info *dpi, long l) { char buf[25]; sprintf (buf,"%ld", l); d_append_string (dpi, buf); } static inline char d_last_char (struct d_print_info *dpi) { return dpi->last_char; } /* Turn components into a human readable string. OPTIONS is the options bits passed to the demangler. DC is the tree to print. CALLBACK is a function to call to flush demangled string segments as they fill the intermediate buffer, and OPAQUE is a generalized callback argument. On success, this returns 1. On failure, it returns 0, indicating a bad parse. It does not use heap memory to build an output string, so cannot encounter memory allocation failure. */ CP_STATIC_IF_GLIBCPP_V3 int cplus_demangle_print_callback (int options, const struct demangle_component *dc, demangle_callbackref callback, void *opaque) { struct d_print_info dpi; d_print_init (&dpi, options, callback, opaque); d_print_comp (&dpi, dc); d_print_flush (&dpi); return ! d_print_saw_error (&dpi); } /* Turn components into a human readable string. OPTIONS is the options bits passed to the demangler. DC is the tree to print. ESTIMATE is a guess at the length of the result. This returns a string allocated by malloc, or NULL on error. On success, this sets *PALC to the size of the allocated buffer. On failure, this sets *PALC to 0 for a bad parse, or to 1 for a memory allocation failure. */ CP_STATIC_IF_GLIBCPP_V3 char * cplus_demangle_print (int options, const struct demangle_component *dc, int estimate, size_t *palc) { struct d_growable_string dgs; d_growable_string_init (&dgs, estimate); if (! cplus_demangle_print_callback (options, dc, d_growable_string_callback_adapter, &dgs)) { free (dgs.buf); *palc = 0; return NULL; } *palc = dgs.allocation_failure ? 1 : dgs.alc; return dgs.buf; } /* Returns the I'th element of the template arglist ARGS, or NULL on failure. */ static struct demangle_component * d_index_template_argument (struct demangle_component *args, int i) { struct demangle_component *a; for (a = args; a != NULL; a = d_right (a)) { if (a->type != DEMANGLE_COMPONENT_TEMPLATE_ARGLIST) return NULL; if (i <= 0) break; --i; } if (i != 0 || a == NULL) return NULL; return d_left (a); } /* Returns the template argument from the current context indicated by DC, which is a DEMANGLE_COMPONENT_TEMPLATE_PARAM, or NULL. */ static struct demangle_component * d_lookup_template_argument (struct d_print_info *dpi, const struct demangle_component *dc) { if (dpi->templates == NULL) { d_print_error (dpi); return NULL; } return d_index_template_argument (d_right (dpi->templates->template_decl), dc->u.s_number.number); } /* Returns a template argument pack used in DC (any will do), or NULL. */ static struct demangle_component * d_find_pack (struct d_print_info *dpi, const struct demangle_component *dc) { struct demangle_component *a; if (dc == NULL) return NULL; switch (dc->type) { case DEMANGLE_COMPONENT_TEMPLATE_PARAM: a = d_lookup_template_argument (dpi, dc); if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST) return a; return NULL; case DEMANGLE_COMPONENT_PACK_EXPANSION: return NULL; case DEMANGLE_COMPONENT_LAMBDA: case DEMANGLE_COMPONENT_NAME: case DEMANGLE_COMPONENT_OPERATOR: case DEMANGLE_COMPONENT_BUILTIN_TYPE: case DEMANGLE_COMPONENT_SUB_STD: case DEMANGLE_COMPONENT_CHARACTER: case DEMANGLE_COMPONENT_FUNCTION_PARAM: return NULL; case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: return d_find_pack (dpi, dc->u.s_extended_operator.name); case DEMANGLE_COMPONENT_CTOR: return d_find_pack (dpi, dc->u.s_ctor.name); case DEMANGLE_COMPONENT_DTOR: return d_find_pack (dpi, dc->u.s_dtor.name); default: a = d_find_pack (dpi, d_left (dc)); if (a) return a; return d_find_pack (dpi, d_right (dc)); } } /* Returns the length of the template argument pack DC. */ static int d_pack_length (const struct demangle_component *dc) { int count = 0; while (dc && dc->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST && d_left (dc) != NULL) { ++count; dc = d_right (dc); } return count; } /* DC is a component of a mangled expression. Print it, wrapped in parens if needed. */ static void d_print_subexpr (struct d_print_info *dpi, const struct demangle_component *dc) { int simple = 0; if (dc->type == DEMANGLE_COMPONENT_NAME || dc->type == DEMANGLE_COMPONENT_FUNCTION_PARAM) simple = 1; if (!simple) d_append_char (dpi, '('); d_print_comp (dpi, dc); if (!simple) d_append_char (dpi, ')'); } /* Subroutine to handle components. */ static void d_print_comp (struct d_print_info *dpi, const struct demangle_component *dc) { if (dc == NULL) { d_print_error (dpi); return; } if (d_print_saw_error (dpi)) return; switch (dc->type) { case DEMANGLE_COMPONENT_NAME: if ((dpi->options & DMGL_JAVA) == 0) d_append_buffer (dpi, dc->u.s_name.s, dc->u.s_name.len); else d_print_java_identifier (dpi, dc->u.s_name.s, dc->u.s_name.len); return; case DEMANGLE_COMPONENT_QUAL_NAME: case DEMANGLE_COMPONENT_LOCAL_NAME: d_print_comp (dpi, d_left (dc)); if ((dpi->options & DMGL_JAVA) == 0) d_append_string (dpi, "::"); else d_append_char (dpi, '.'); d_print_comp (dpi, d_right (dc)); return; case DEMANGLE_COMPONENT_TYPED_NAME: { struct d_print_mod *hold_modifiers; struct demangle_component *typed_name; struct d_print_mod adpm[4]; unsigned int i; struct d_print_template dpt; /* Pass the name down to the type so that it can be printed in the right place for the type. We also have to pass down any CV-qualifiers, which apply to the this parameter. */ hold_modifiers = dpi->modifiers; dpi->modifiers = 0; i = 0; typed_name = d_left (dc); while (typed_name != NULL) { if (i >= sizeof adpm / sizeof adpm[0]) { d_print_error (dpi); return; } adpm[i].next = dpi->modifiers; dpi->modifiers = &adpm[i]; adpm[i].mod = typed_name; adpm[i].printed = 0; adpm[i].templates = dpi->templates; ++i; if (typed_name->type != DEMANGLE_COMPONENT_RESTRICT_THIS && typed_name->type != DEMANGLE_COMPONENT_VOLATILE_THIS && typed_name->type != DEMANGLE_COMPONENT_CONST_THIS) break; typed_name = d_left (typed_name); } if (typed_name == NULL) { d_print_error (dpi); return; } /* If typed_name is a template, then it applies to the function type as well. */ if (typed_name->type == DEMANGLE_COMPONENT_TEMPLATE) { dpt.next = dpi->templates; dpi->templates = &dpt; dpt.template_decl = typed_name; } /* If typed_name is a DEMANGLE_COMPONENT_LOCAL_NAME, then there may be CV-qualifiers on its right argument which really apply here; this happens when parsing a class which is local to a function. */ if (typed_name->type == DEMANGLE_COMPONENT_LOCAL_NAME) { struct demangle_component *local_name; local_name = d_right (typed_name); if (local_name->type == DEMANGLE_COMPONENT_DEFAULT_ARG) local_name = local_name->u.s_unary_num.sub; while (local_name->type == DEMANGLE_COMPONENT_RESTRICT_THIS || local_name->type == DEMANGLE_COMPONENT_VOLATILE_THIS || local_name->type == DEMANGLE_COMPONENT_CONST_THIS) { if (i >= sizeof adpm / sizeof adpm[0]) { d_print_error (dpi); return; } adpm[i] = adpm[i - 1]; adpm[i].next = &adpm[i - 1]; dpi->modifiers = &adpm[i]; adpm[i - 1].mod = local_name; adpm[i - 1].printed = 0; adpm[i - 1].templates = dpi->templates; ++i; local_name = d_left (local_name); } } d_print_comp (dpi, d_right (dc)); if (typed_name->type == DEMANGLE_COMPONENT_TEMPLATE) dpi->templates = dpt.next; /* If the modifiers didn't get printed by the type, print them now. */ while (i > 0) { --i; if (! adpm[i].printed) { d_append_char (dpi, ' '); d_print_mod (dpi, adpm[i].mod); } } dpi->modifiers = hold_modifiers; return; } case DEMANGLE_COMPONENT_TEMPLATE: { struct d_print_mod *hold_dpm; struct demangle_component *dcl; /* Don't push modifiers into a template definition. Doing so could give the wrong definition for a template argument. Instead, treat the template essentially as a name. */ hold_dpm = dpi->modifiers; dpi->modifiers = NULL; dcl = d_left (dc); if ((dpi->options & DMGL_JAVA) != 0 && dcl->type == DEMANGLE_COMPONENT_NAME && dcl->u.s_name.len == 6 && strncmp (dcl->u.s_name.s, "JArray", 6) == 0) { /* Special-case Java arrays, so that JArray appears instead as TYPE[]. */ d_print_comp (dpi, d_right (dc)); d_append_string (dpi, "[]"); } else { d_print_comp (dpi, dcl); if (d_last_char (dpi) == '<') d_append_char (dpi, ' '); d_append_char (dpi, '<'); d_print_comp (dpi, d_right (dc)); /* Avoid generating two consecutive '>' characters, to avoid the C++ syntactic ambiguity. */ if (d_last_char (dpi) == '>') d_append_char (dpi, ' '); d_append_char (dpi, '>'); } dpi->modifiers = hold_dpm; return; } case DEMANGLE_COMPONENT_TEMPLATE_PARAM: { struct d_print_template *hold_dpt; struct demangle_component *a = d_lookup_template_argument (dpi, dc); if (a && a->type == DEMANGLE_COMPONENT_TEMPLATE_ARGLIST) a = d_index_template_argument (a, dpi->pack_index); if (a == NULL) { d_print_error (dpi); return; } /* While processing this parameter, we need to pop the list of templates. This is because the template parameter may itself be a reference to a parameter of an outer template. */ hold_dpt = dpi->templates; dpi->templates = hold_dpt->next; d_print_comp (dpi, a); dpi->templates = hold_dpt; return; } case DEMANGLE_COMPONENT_CTOR: d_print_comp (dpi, dc->u.s_ctor.name); return; case DEMANGLE_COMPONENT_DTOR: d_append_char (dpi, '~'); d_print_comp (dpi, dc->u.s_dtor.name); return; case DEMANGLE_COMPONENT_VTABLE: d_append_string (dpi, "vtable for "); d_print_comp (dpi, d_left (dc)); return; case DEMANGLE_COMPONENT_VTT: d_append_string (dpi, "VTT for "); d_print_comp (dpi, d_left (dc)); return; case DEMANGLE_COMPONENT_CONSTRUCTION_VTABLE: d_append_string (dpi, "construction vtable for "); d_print_comp (dpi, d_left (dc)); d_append_string (dpi, "-in-"); d_print_comp (dpi, d_right (dc)); return; case DEMANGLE_COMPONENT_TYPEINFO: d_append_string (dpi, "typeinfo for "); d_print_comp (dpi, d_left (dc)); return; case DEMANGLE_COMPONENT_TYPEINFO_NAME: d_append_string (dpi, "typeinfo name for "); d_print_comp (dpi, d_left (dc)); return; case DEMANGLE_COMPONENT_TYPEINFO_FN: d_append_string (dpi, "typeinfo fn for "); d_print_comp (dpi, d_left (dc)); return; case DEMANGLE_COMPONENT_THUNK: d_append_string (dpi, "non-virtual thunk to "); d_print_comp (dpi, d_left (dc)); return; case DEMANGLE_COMPONENT_VIRTUAL_THUNK: d_append_string (dpi, "virtual thunk to "); d_print_comp (dpi, d_left (dc)); return; case DEMANGLE_COMPONENT_COVARIANT_THUNK: d_append_string (dpi, "covariant return thunk to "); d_print_comp (dpi, d_left (dc)); return; case DEMANGLE_COMPONENT_JAVA_CLASS: d_append_string (dpi, "java Class for "); d_print_comp (dpi, d_left (dc)); return; case DEMANGLE_COMPONENT_GUARD: d_append_string (dpi, "guard variable for "); d_print_comp (dpi, d_left (dc)); return; case DEMANGLE_COMPONENT_REFTEMP: d_append_string (dpi, "reference temporary for "); d_print_comp (dpi, d_left (dc)); return; case DEMANGLE_COMPONENT_HIDDEN_ALIAS: d_append_string (dpi, "hidden alias for "); d_print_comp (dpi, d_left (dc)); return; case DEMANGLE_COMPONENT_SUB_STD: d_append_buffer (dpi, dc->u.s_string.string, dc->u.s_string.len); return; case DEMANGLE_COMPONENT_RESTRICT: case DEMANGLE_COMPONENT_VOLATILE: case DEMANGLE_COMPONENT_CONST: { struct d_print_mod *pdpm; /* When printing arrays, it's possible to have cases where the same CV-qualifier gets pushed on the stack multiple times. We only need to print it once. */ for (pdpm = dpi->modifiers; pdpm != NULL; pdpm = pdpm->next) { if (! pdpm->printed) { if (pdpm->mod->type != DEMANGLE_COMPONENT_RESTRICT && pdpm->mod->type != DEMANGLE_COMPONENT_VOLATILE && pdpm->mod->type != DEMANGLE_COMPONENT_CONST) break; if (pdpm->mod->type == dc->type) { d_print_comp (dpi, d_left (dc)); return; } } } } /* Fall through. */ case DEMANGLE_COMPONENT_RESTRICT_THIS: case DEMANGLE_COMPONENT_VOLATILE_THIS: case DEMANGLE_COMPONENT_CONST_THIS: case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: case DEMANGLE_COMPONENT_POINTER: case DEMANGLE_COMPONENT_REFERENCE: case DEMANGLE_COMPONENT_RVALUE_REFERENCE: case DEMANGLE_COMPONENT_COMPLEX: case DEMANGLE_COMPONENT_IMAGINARY: { /* We keep a list of modifiers on the stack. */ struct d_print_mod dpm; dpm.next = dpi->modifiers; dpi->modifiers = &dpm; dpm.mod = dc; dpm.printed = 0; dpm.templates = dpi->templates; d_print_comp (dpi, d_left (dc)); /* If the modifier didn't get printed by the type, print it now. */ if (! dpm.printed) d_print_mod (dpi, dc); dpi->modifiers = dpm.next; return; } case DEMANGLE_COMPONENT_BUILTIN_TYPE: if ((dpi->options & DMGL_JAVA) == 0) d_append_buffer (dpi, dc->u.s_builtin.type->name, dc->u.s_builtin.type->len); else d_append_buffer (dpi, dc->u.s_builtin.type->java_name, dc->u.s_builtin.type->java_len); return; case DEMANGLE_COMPONENT_VENDOR_TYPE: d_print_comp (dpi, d_left (dc)); return; case DEMANGLE_COMPONENT_FUNCTION_TYPE: { if ((dpi->options & DMGL_RET_POSTFIX) != 0) d_print_function_type (dpi, dc, dpi->modifiers); /* Print return type if present */ if (d_left (dc) != NULL) { struct d_print_mod dpm; /* We must pass this type down as a modifier in order to print it in the right location. */ dpm.next = dpi->modifiers; dpi->modifiers = &dpm; dpm.mod = dc; dpm.printed = 0; dpm.templates = dpi->templates; d_print_comp (dpi, d_left (dc)); dpi->modifiers = dpm.next; if (dpm.printed) return; /* In standard prefix notation, there is a space between the return type and the function signature. */ if ((dpi->options & DMGL_RET_POSTFIX) == 0) d_append_char (dpi, ' '); } if ((dpi->options & DMGL_RET_POSTFIX) == 0) d_print_function_type (dpi, dc, dpi->modifiers); return; } case DEMANGLE_COMPONENT_ARRAY_TYPE: { struct d_print_mod *hold_modifiers; struct d_print_mod adpm[4]; unsigned int i; struct d_print_mod *pdpm; /* We must pass this type down as a modifier in order to print multi-dimensional arrays correctly. If the array itself is CV-qualified, we act as though the element type were CV-qualified. We do this by copying the modifiers down rather than fiddling pointers, so that we don't wind up with a d_print_mod higher on the stack pointing into our stack frame after we return. */ hold_modifiers = dpi->modifiers; adpm[0].next = hold_modifiers; dpi->modifiers = &adpm[0]; adpm[0].mod = dc; adpm[0].printed = 0; adpm[0].templates = dpi->templates; i = 1; pdpm = hold_modifiers; while (pdpm != NULL && (pdpm->mod->type == DEMANGLE_COMPONENT_RESTRICT || pdpm->mod->type == DEMANGLE_COMPONENT_VOLATILE || pdpm->mod->type == DEMANGLE_COMPONENT_CONST)) { if (! pdpm->printed) { if (i >= sizeof adpm / sizeof adpm[0]) { d_print_error (dpi); return; } adpm[i] = *pdpm; adpm[i].next = dpi->modifiers; dpi->modifiers = &adpm[i]; pdpm->printed = 1; ++i; } pdpm = pdpm->next; } d_print_comp (dpi, d_right (dc)); dpi->modifiers = hold_modifiers; if (adpm[0].printed) return; while (i > 1) { --i; d_print_mod (dpi, adpm[i].mod); } d_print_array_type (dpi, dc, dpi->modifiers); return; } case DEMANGLE_COMPONENT_PTRMEM_TYPE: case DEMANGLE_COMPONENT_VECTOR_TYPE: { struct d_print_mod dpm; dpm.next = dpi->modifiers; dpi->modifiers = &dpm; dpm.mod = dc; dpm.printed = 0; dpm.templates = dpi->templates; d_print_comp (dpi, d_right (dc)); /* If the modifier didn't get printed by the type, print it now. */ if (! dpm.printed) d_print_mod (dpi, dc); dpi->modifiers = dpm.next; return; } case DEMANGLE_COMPONENT_FIXED_TYPE: if (dc->u.s_fixed.sat) d_append_string (dpi, "_Sat "); /* Don't print "int _Accum". */ if (dc->u.s_fixed.length->u.s_builtin.type != &cplus_demangle_builtin_types['i'-'a']) { d_print_comp (dpi, dc->u.s_fixed.length); d_append_char (dpi, ' '); } if (dc->u.s_fixed.accum) d_append_string (dpi, "_Accum"); else d_append_string (dpi, "_Fract"); return; case DEMANGLE_COMPONENT_ARGLIST: case DEMANGLE_COMPONENT_TEMPLATE_ARGLIST: if (d_left (dc) != NULL) d_print_comp (dpi, d_left (dc)); if (d_right (dc) != NULL) { size_t len; unsigned long int flush_count; /* Make sure ", " isn't flushed by d_append_string, otherwise dpi->len -= 2 wouldn't work. */ if (dpi->len >= sizeof (dpi->buf) - 2) d_print_flush (dpi); d_append_string (dpi, ", "); len = dpi->len; flush_count = dpi->flush_count; d_print_comp (dpi, d_right (dc)); /* If that didn't print anything (which can happen with empty template argument packs), remove the comma and space. */ if (dpi->flush_count == flush_count && dpi->len == len) dpi->len -= 2; } return; case DEMANGLE_COMPONENT_OPERATOR: { char c; d_append_string (dpi, "operator"); c = dc->u.s_operator.op->name[0]; if (IS_LOWER (c)) d_append_char (dpi, ' '); d_append_buffer (dpi, dc->u.s_operator.op->name, dc->u.s_operator.op->len); return; } case DEMANGLE_COMPONENT_EXTENDED_OPERATOR: d_append_string (dpi, "operator "); d_print_comp (dpi, dc->u.s_extended_operator.name); return; case DEMANGLE_COMPONENT_CAST: d_append_string (dpi, "operator "); d_print_cast (dpi, dc); return; case DEMANGLE_COMPONENT_UNARY: if (d_left (dc)->type != DEMANGLE_COMPONENT_CAST) d_print_expr_op (dpi, d_left (dc)); else { d_append_char (dpi, '('); d_print_cast (dpi, d_left (dc)); d_append_char (dpi, ')'); } d_print_subexpr (dpi, d_right (dc)); return; case DEMANGLE_COMPONENT_BINARY: if (d_right (dc)->type != DEMANGLE_COMPONENT_BINARY_ARGS) { d_print_error (dpi); return; } /* We wrap an expression which uses the greater-than operator in an extra layer of parens so that it does not get confused with the '>' which ends the template parameters. */ if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR && d_left (dc)->u.s_operator.op->len == 1 && d_left (dc)->u.s_operator.op->name[0] == '>') d_append_char (dpi, '('); d_print_subexpr (dpi, d_left (d_right (dc))); if (strcmp (d_left (dc)->u.s_operator.op->code, "ix") == 0) { d_append_char (dpi, '['); d_print_comp (dpi, d_right (d_right (dc))); d_append_char (dpi, ']'); } else { if (strcmp (d_left (dc)->u.s_operator.op->code, "cl") != 0) d_print_expr_op (dpi, d_left (dc)); d_print_subexpr (dpi, d_right (d_right (dc))); } if (d_left (dc)->type == DEMANGLE_COMPONENT_OPERATOR && d_left (dc)->u.s_operator.op->len == 1 && d_left (dc)->u.s_operator.op->name[0] == '>') d_append_char (dpi, ')'); return; case DEMANGLE_COMPONENT_BINARY_ARGS: /* We should only see this as part of DEMANGLE_COMPONENT_BINARY. */ d_print_error (dpi); return; case DEMANGLE_COMPONENT_TRINARY: if (d_right (dc)->type != DEMANGLE_COMPONENT_TRINARY_ARG1 || d_right (d_right (dc))->type != DEMANGLE_COMPONENT_TRINARY_ARG2) { d_print_error (dpi); return; } d_print_subexpr (dpi, d_left (d_right (dc))); d_print_expr_op (dpi, d_left (dc)); d_print_subexpr (dpi, d_left (d_right (d_right (dc)))); d_append_string (dpi, " : "); d_print_subexpr (dpi, d_right (d_right (d_right (dc)))); return; case DEMANGLE_COMPONENT_TRINARY_ARG1: case DEMANGLE_COMPONENT_TRINARY_ARG2: /* We should only see these are part of DEMANGLE_COMPONENT_TRINARY. */ d_print_error (dpi); return; case DEMANGLE_COMPONENT_LITERAL: case DEMANGLE_COMPONENT_LITERAL_NEG: { enum d_builtin_type_print tp; /* For some builtin types, produce simpler output. */ tp = D_PRINT_DEFAULT; if (d_left (dc)->type == DEMANGLE_COMPONENT_BUILTIN_TYPE) { tp = d_left (dc)->u.s_builtin.type->print; switch (tp) { case D_PRINT_INT: case D_PRINT_UNSIGNED: case D_PRINT_LONG: case D_PRINT_UNSIGNED_LONG: case D_PRINT_LONG_LONG: case D_PRINT_UNSIGNED_LONG_LONG: if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME) { if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG) d_append_char (dpi, '-'); d_print_comp (dpi, d_right (dc)); switch (tp) { default: break; case D_PRINT_UNSIGNED: d_append_char (dpi, 'u'); break; case D_PRINT_LONG: d_append_char (dpi, 'l'); break; case D_PRINT_UNSIGNED_LONG: d_append_string (dpi, "ul"); break; case D_PRINT_LONG_LONG: d_append_string (dpi, "ll"); break; case D_PRINT_UNSIGNED_LONG_LONG: d_append_string (dpi, "ull"); break; } return; } break; case D_PRINT_BOOL: if (d_right (dc)->type == DEMANGLE_COMPONENT_NAME && d_right (dc)->u.s_name.len == 1 && dc->type == DEMANGLE_COMPONENT_LITERAL) { switch (d_right (dc)->u.s_name.s[0]) { case '0': d_append_string (dpi, "false"); return; case '1': d_append_string (dpi, "true"); return; default: break; } } break; default: break; } } d_append_char (dpi, '('); d_print_comp (dpi, d_left (dc)); d_append_char (dpi, ')'); if (dc->type == DEMANGLE_COMPONENT_LITERAL_NEG) d_append_char (dpi, '-'); if (tp == D_PRINT_FLOAT) d_append_char (dpi, '['); d_print_comp (dpi, d_right (dc)); if (tp == D_PRINT_FLOAT) d_append_char (dpi, ']'); } return; case DEMANGLE_COMPONENT_NUMBER: d_append_num (dpi, dc->u.s_number.number); return; case DEMANGLE_COMPONENT_JAVA_RESOURCE: d_append_string (dpi, "java resource "); d_print_comp (dpi, d_left (dc)); return; case DEMANGLE_COMPONENT_COMPOUND_NAME: d_print_comp (dpi, d_left (dc)); d_print_comp (dpi, d_right (dc)); return; case DEMANGLE_COMPONENT_CHARACTER: d_append_char (dpi, dc->u.s_character.character); return; case DEMANGLE_COMPONENT_DECLTYPE: d_append_string (dpi, "decltype ("); d_print_comp (dpi, d_left (dc)); d_append_char (dpi, ')'); return; case DEMANGLE_COMPONENT_PACK_EXPANSION: { int len; int i; struct demangle_component *a = d_find_pack (dpi, d_left (dc)); if (a == NULL) { /* d_find_pack won't find anything if the only packs involved in this expansion are function parameter packs; in that case, just print the pattern and "...". */ d_print_subexpr (dpi, d_left (dc)); d_append_string (dpi, "..."); return; } len = d_pack_length (a); dc = d_left (dc); for (i = 0; i < len; ++i) { dpi->pack_index = i; d_print_comp (dpi, dc); if (i < len-1) d_append_string (dpi, ", "); } } return; case DEMANGLE_COMPONENT_FUNCTION_PARAM: d_append_string (dpi, "{parm#"); d_append_num (dpi, dc->u.s_number.number + 1); d_append_char (dpi, '}'); return; case DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS: d_append_string (dpi, "global constructors keyed to "); d_print_comp (dpi, dc->u.s_binary.left); return; case DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS: d_append_string (dpi, "global destructors keyed to "); d_print_comp (dpi, dc->u.s_binary.left); return; case DEMANGLE_COMPONENT_LAMBDA: d_append_string (dpi, "{lambda("); d_print_comp (dpi, dc->u.s_unary_num.sub); d_append_string (dpi, ")#"); d_append_num (dpi, dc->u.s_unary_num.num + 1); d_append_char (dpi, '}'); return; case DEMANGLE_COMPONENT_UNNAMED_TYPE: d_append_string (dpi, "{unnamed type#"); d_append_num (dpi, dc->u.s_number.number + 1); d_append_char (dpi, '}'); return; default: d_print_error (dpi); return; } } /* Print a Java dentifier. For Java we try to handle encoded extended Unicode characters. The C++ ABI doesn't mention Unicode encoding, so we don't it for C++. Characters are encoded as __U+_. */ static void d_print_java_identifier (struct d_print_info *dpi, const char *name, int len) { const char *p; const char *end; end = name + len; for (p = name; p < end; ++p) { if (end - p > 3 && p[0] == '_' && p[1] == '_' && p[2] == 'U') { unsigned long c; const char *q; c = 0; for (q = p + 3; q < end; ++q) { int dig; if (IS_DIGIT (*q)) dig = *q - '0'; else if (*q >= 'A' && *q <= 'F') dig = *q - 'A' + 10; else if (*q >= 'a' && *q <= 'f') dig = *q - 'a' + 10; else break; c = c * 16 + dig; } /* If the Unicode character is larger than 256, we don't try to deal with it here. FIXME. */ if (q < end && *q == '_' && c < 256) { d_append_char (dpi, c); p = q; continue; } } d_append_char (dpi, *p); } } /* Print a list of modifiers. SUFFIX is 1 if we are printing qualifiers on this after printing a function. */ static void d_print_mod_list (struct d_print_info *dpi, struct d_print_mod *mods, int suffix) { struct d_print_template *hold_dpt; if (mods == NULL || d_print_saw_error (dpi)) return; if (mods->printed || (! suffix && (mods->mod->type == DEMANGLE_COMPONENT_RESTRICT_THIS || mods->mod->type == DEMANGLE_COMPONENT_VOLATILE_THIS || mods->mod->type == DEMANGLE_COMPONENT_CONST_THIS))) { d_print_mod_list (dpi, mods->next, suffix); return; } mods->printed = 1; hold_dpt = dpi->templates; dpi->templates = mods->templates; if (mods->mod->type == DEMANGLE_COMPONENT_FUNCTION_TYPE) { d_print_function_type (dpi, mods->mod, mods->next); dpi->templates = hold_dpt; return; } else if (mods->mod->type == DEMANGLE_COMPONENT_ARRAY_TYPE) { d_print_array_type (dpi, mods->mod, mods->next); dpi->templates = hold_dpt; return; } else if (mods->mod->type == DEMANGLE_COMPONENT_LOCAL_NAME) { struct d_print_mod *hold_modifiers; struct demangle_component *dc; /* When this is on the modifier stack, we have pulled any qualifiers off the right argument already. Otherwise, we print it as usual, but don't let the left argument see any modifiers. */ hold_modifiers = dpi->modifiers; dpi->modifiers = NULL; d_print_comp (dpi, d_left (mods->mod)); dpi->modifiers = hold_modifiers; if ((dpi->options & DMGL_JAVA) == 0) d_append_string (dpi, "::"); else d_append_char (dpi, '.'); dc = d_right (mods->mod); if (dc->type == DEMANGLE_COMPONENT_DEFAULT_ARG) { d_append_string (dpi, "{default arg#"); d_append_num (dpi, dc->u.s_unary_num.num + 1); d_append_string (dpi, "}::"); dc = dc->u.s_unary_num.sub; } while (dc->type == DEMANGLE_COMPONENT_RESTRICT_THIS || dc->type == DEMANGLE_COMPONENT_VOLATILE_THIS || dc->type == DEMANGLE_COMPONENT_CONST_THIS) dc = d_left (dc); d_print_comp (dpi, dc); dpi->templates = hold_dpt; return; } d_print_mod (dpi, mods->mod); dpi->templates = hold_dpt; d_print_mod_list (dpi, mods->next, suffix); } /* Print a modifier. */ static void d_print_mod (struct d_print_info *dpi, const struct demangle_component *mod) { switch (mod->type) { case DEMANGLE_COMPONENT_RESTRICT: case DEMANGLE_COMPONENT_RESTRICT_THIS: d_append_string (dpi, " restrict"); return; case DEMANGLE_COMPONENT_VOLATILE: case DEMANGLE_COMPONENT_VOLATILE_THIS: d_append_string (dpi, " volatile"); return; case DEMANGLE_COMPONENT_CONST: case DEMANGLE_COMPONENT_CONST_THIS: d_append_string (dpi, " const"); return; case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: d_append_char (dpi, ' '); d_print_comp (dpi, d_right (mod)); return; case DEMANGLE_COMPONENT_POINTER: /* There is no pointer symbol in Java. */ if ((dpi->options & DMGL_JAVA) == 0) d_append_char (dpi, '*'); return; case DEMANGLE_COMPONENT_REFERENCE: d_append_char (dpi, '&'); return; case DEMANGLE_COMPONENT_RVALUE_REFERENCE: d_append_string (dpi, "&&"); return; case DEMANGLE_COMPONENT_COMPLEX: d_append_string (dpi, "complex "); return; case DEMANGLE_COMPONENT_IMAGINARY: d_append_string (dpi, "imaginary "); return; case DEMANGLE_COMPONENT_PTRMEM_TYPE: if (d_last_char (dpi) != '(') d_append_char (dpi, ' '); d_print_comp (dpi, d_left (mod)); d_append_string (dpi, "::*"); return; case DEMANGLE_COMPONENT_TYPED_NAME: d_print_comp (dpi, d_left (mod)); return; case DEMANGLE_COMPONENT_VECTOR_TYPE: d_append_string (dpi, " __vector("); d_print_comp (dpi, d_left (mod)); d_append_char (dpi, ')'); return; default: /* Otherwise, we have something that won't go back on the modifier stack, so we can just print it. */ d_print_comp (dpi, mod); return; } } /* Print a function type, except for the return type. */ static void d_print_function_type (struct d_print_info *dpi, const struct demangle_component *dc, struct d_print_mod *mods) { int need_paren; int need_space; struct d_print_mod *p; struct d_print_mod *hold_modifiers; need_paren = 0; need_space = 0; for (p = mods; p != NULL; p = p->next) { if (p->printed) break; switch (p->mod->type) { case DEMANGLE_COMPONENT_POINTER: case DEMANGLE_COMPONENT_REFERENCE: case DEMANGLE_COMPONENT_RVALUE_REFERENCE: need_paren = 1; break; case DEMANGLE_COMPONENT_RESTRICT: case DEMANGLE_COMPONENT_VOLATILE: case DEMANGLE_COMPONENT_CONST: case DEMANGLE_COMPONENT_VENDOR_TYPE_QUAL: case DEMANGLE_COMPONENT_COMPLEX: case DEMANGLE_COMPONENT_IMAGINARY: case DEMANGLE_COMPONENT_PTRMEM_TYPE: need_space = 1; need_paren = 1; break; case DEMANGLE_COMPONENT_RESTRICT_THIS: case DEMANGLE_COMPONENT_VOLATILE_THIS: case DEMANGLE_COMPONENT_CONST_THIS: break; default: break; } if (need_paren) break; } if (need_paren) { if (! need_space) { if (d_last_char (dpi) != '(' && d_last_char (dpi) != '*') need_space = 1; } if (need_space && d_last_char (dpi) != ' ') d_append_char (dpi, ' '); d_append_char (dpi, '('); } hold_modifiers = dpi->modifiers; dpi->modifiers = NULL; d_print_mod_list (dpi, mods, 0); if (need_paren) d_append_char (dpi, ')'); d_append_char (dpi, '('); if (d_right (dc) != NULL) d_print_comp (dpi, d_right (dc)); d_append_char (dpi, ')'); d_print_mod_list (dpi, mods, 1); dpi->modifiers = hold_modifiers; } /* Print an array type, except for the element type. */ static void d_print_array_type (struct d_print_info *dpi, const struct demangle_component *dc, struct d_print_mod *mods) { int need_space; need_space = 1; if (mods != NULL) { int need_paren; struct d_print_mod *p; need_paren = 0; for (p = mods; p != NULL; p = p->next) { if (! p->printed) { if (p->mod->type == DEMANGLE_COMPONENT_ARRAY_TYPE) { need_space = 0; break; } else { need_paren = 1; need_space = 1; break; } } } if (need_paren) d_append_string (dpi, " ("); d_print_mod_list (dpi, mods, 0); if (need_paren) d_append_char (dpi, ')'); } if (need_space) d_append_char (dpi, ' '); d_append_char (dpi, '['); if (d_left (dc) != NULL) d_print_comp (dpi, d_left (dc)); d_append_char (dpi, ']'); } /* Print an operator in an expression. */ static void d_print_expr_op (struct d_print_info *dpi, const struct demangle_component *dc) { if (dc->type == DEMANGLE_COMPONENT_OPERATOR) d_append_buffer (dpi, dc->u.s_operator.op->name, dc->u.s_operator.op->len); else d_print_comp (dpi, dc); } /* Print a cast. */ static void d_print_cast (struct d_print_info *dpi, const struct demangle_component *dc) { if (d_left (dc)->type != DEMANGLE_COMPONENT_TEMPLATE) d_print_comp (dpi, d_left (dc)); else { struct d_print_mod *hold_dpm; struct d_print_template dpt; /* It appears that for a templated cast operator, we need to put the template parameters in scope for the operator name, but not for the parameters. The effect is that we need to handle the template printing here. */ hold_dpm = dpi->modifiers; dpi->modifiers = NULL; dpt.next = dpi->templates; dpi->templates = &dpt; dpt.template_decl = d_left (dc); d_print_comp (dpi, d_left (d_left (dc))); dpi->templates = dpt.next; if (d_last_char (dpi) == '<') d_append_char (dpi, ' '); d_append_char (dpi, '<'); d_print_comp (dpi, d_right (d_left (dc))); /* Avoid generating two consecutive '>' characters, to avoid the C++ syntactic ambiguity. */ if (d_last_char (dpi) == '>') d_append_char (dpi, ' '); d_append_char (dpi, '>'); dpi->modifiers = hold_dpm; } } /* Initialize the information structure we use to pass around information. */ CP_STATIC_IF_GLIBCPP_V3 void cplus_demangle_init_info (const char *mangled, int options, size_t len, struct d_info *di) { di->s = mangled; di->send = mangled + len; di->options = options; di->n = mangled; /* We can not need more components than twice the number of chars in the mangled string. Most components correspond directly to chars, but the ARGLIST types are exceptions. */ di->num_comps = 2 * len; di->next_comp = 0; /* Similarly, we can not need more substitutions than there are chars in the mangled string. */ di->num_subs = len; di->next_sub = 0; di->did_subs = 0; di->last_name = NULL; di->expansion = 0; } /* Internal implementation for the demangler. If MANGLED is a g++ v3 ABI mangled name, return strings in repeated callback giving the demangled name. OPTIONS is the usual libiberty demangler options. On success, this returns 1. On failure, returns 0. */ static int d_demangle_callback (const char *mangled, int options, demangle_callbackref callback, void *opaque) { enum { DCT_TYPE, DCT_MANGLED, DCT_GLOBAL_CTORS, DCT_GLOBAL_DTORS } type; struct d_info di; struct demangle_component *dc; int status; if (mangled[0] == '_' && mangled[1] == 'Z') type = DCT_MANGLED; else if (strncmp (mangled, "_GLOBAL_", 8) == 0 && (mangled[8] == '.' || mangled[8] == '_' || mangled[8] == '$') && (mangled[9] == 'D' || mangled[9] == 'I') && mangled[10] == '_') type = mangled[9] == 'I' ? DCT_GLOBAL_CTORS : DCT_GLOBAL_DTORS; else { if ((options & DMGL_TYPES) == 0) return 0; type = DCT_TYPE; } cplus_demangle_init_info (mangled, options, strlen (mangled), &di); { #ifdef CP_DYNAMIC_ARRAYS __extension__ struct demangle_component comps[di.num_comps]; __extension__ struct demangle_component *subs[di.num_subs]; di.comps = comps; di.subs = subs; #else di.comps = alloca (di.num_comps * sizeof (*di.comps)); di.subs = alloca (di.num_subs * sizeof (*di.subs)); #endif switch (type) { case DCT_TYPE: dc = cplus_demangle_type (&di); break; case DCT_MANGLED: dc = cplus_demangle_mangled_name (&di, 1); break; case DCT_GLOBAL_CTORS: case DCT_GLOBAL_DTORS: d_advance (&di, 11); dc = d_make_comp (&di, (type == DCT_GLOBAL_CTORS ? DEMANGLE_COMPONENT_GLOBAL_CONSTRUCTORS : DEMANGLE_COMPONENT_GLOBAL_DESTRUCTORS), d_make_demangle_mangled_name (&di, d_str (&di)), NULL); d_advance (&di, strlen (d_str (&di))); break; } /* If DMGL_PARAMS is set, then if we didn't consume the entire mangled string, then we didn't successfully demangle it. If DMGL_PARAMS is not set, we didn't look at the trailing parameters. */ if (((options & DMGL_PARAMS) != 0) && d_peek_char (&di) != '\0') dc = NULL; #ifdef CP_DEMANGLE_DEBUG d_dump (dc, 0); #endif status = (dc != NULL) ? cplus_demangle_print_callback (options, dc, callback, opaque) : 0; } return status; } /* Entry point for the demangler. If MANGLED is a g++ v3 ABI mangled name, return a buffer allocated with malloc holding the demangled name. OPTIONS is the usual libiberty demangler options. On success, this sets *PALC to the allocated size of the returned buffer. On failure, this sets *PALC to 0 for a bad name, or 1 for a memory allocation failure, and returns NULL. */ static char * d_demangle (const char *mangled, int options, size_t *palc) { struct d_growable_string dgs; int status; d_growable_string_init (&dgs, 0); status = d_demangle_callback (mangled, options, d_growable_string_callback_adapter, &dgs); if (status == 0) { free (dgs.buf); *palc = 0; return NULL; } *palc = dgs.allocation_failure ? 1 : dgs.alc; return dgs.buf; } #if defined(IN_LIBGCC2) || defined(IN_GLIBCPP_V3) extern char *__cxa_demangle (const char *, char *, size_t *, int *); /* ia64 ABI-mandated entry point in the C++ runtime library for performing demangling. MANGLED_NAME is a NUL-terminated character string containing the name to be demangled. OUTPUT_BUFFER is a region of memory, allocated with malloc, of *LENGTH bytes, into which the demangled name is stored. If OUTPUT_BUFFER is not long enough, it is expanded using realloc. OUTPUT_BUFFER may instead be NULL; in that case, the demangled name is placed in a region of memory allocated with malloc. If LENGTH is non-NULL, the length of the buffer containing the demangled name, is placed in *LENGTH. The return value is a pointer to the start of the NUL-terminated demangled name, or NULL if the demangling fails. The caller is responsible for deallocating this memory using free. *STATUS is set to one of the following values: 0: The demangling operation succeeded. -1: A memory allocation failure occurred. -2: MANGLED_NAME is not a valid name under the C++ ABI mangling rules. -3: One of the arguments is invalid. The demangling is performed using the C++ ABI mangling rules, with GNU extensions. */ char * __cxa_demangle (const char *mangled_name, char *output_buffer, size_t *length, int *status) { char *demangled; size_t alc; if (mangled_name == NULL) { if (status != NULL) *status = -3; return NULL; } if (output_buffer != NULL && length == NULL) { if (status != NULL) *status = -3; return NULL; } demangled = d_demangle (mangled_name, DMGL_PARAMS | DMGL_TYPES, &alc); if (demangled == NULL) { if (status != NULL) { if (alc == 1) *status = -1; else *status = -2; } return NULL; } if (output_buffer == NULL) { if (length != NULL) *length = alc; } else { if (strlen (demangled) < *length) { strcpy (output_buffer, demangled); free (demangled); demangled = output_buffer; } else { free (output_buffer); *length = alc; } } if (status != NULL) *status = 0; return demangled; } extern int __gcclibcxx_demangle_callback (const char *, void (*) (const char *, size_t, void *), void *); /* Alternative, allocationless entry point in the C++ runtime library for performing demangling. MANGLED_NAME is a NUL-terminated character string containing the name to be demangled. CALLBACK is a callback function, called with demangled string segments as demangling progresses; it is called at least once, but may be called more than once. OPAQUE is a generalized pointer used as a callback argument. The return code is one of the following values, equivalent to the STATUS values of __cxa_demangle() (excluding -1, since this function performs no memory allocations): 0: The demangling operation succeeded. -2: MANGLED_NAME is not a valid name under the C++ ABI mangling rules. -3: One of the arguments is invalid. The demangling is performed using the C++ ABI mangling rules, with GNU extensions. */ int __gcclibcxx_demangle_callback (const char *mangled_name, void (*callback) (const char *, size_t, void *), void *opaque) { int status; if (mangled_name == NULL || callback == NULL) return -3; status = d_demangle_callback (mangled_name, DMGL_PARAMS | DMGL_TYPES, callback, opaque); if (status == 0) return -2; return 0; } #else /* ! (IN_LIBGCC2 || IN_GLIBCPP_V3) */ /* Entry point for libiberty demangler. If MANGLED is a g++ v3 ABI mangled name, return a buffer allocated with malloc holding the demangled name. Otherwise, return NULL. */ char * cplus_demangle_v3 (const char *mangled, int options) { size_t alc; return d_demangle (mangled, options, &alc); } int cplus_demangle_v3_callback (const char *mangled, int options, demangle_callbackref callback, void *opaque) { return d_demangle_callback (mangled, options, callback, opaque); } /* Demangle a Java symbol. Java uses a subset of the V3 ABI C++ mangling conventions, but the output formatting is a little different. This instructs the C++ demangler not to emit pointer characters ("*"), to use Java's namespace separator symbol ("." instead of "::"), and to output JArray as TYPE[]. */ char * java_demangle_v3 (const char *mangled) { size_t alc; return d_demangle (mangled, DMGL_JAVA | DMGL_PARAMS | DMGL_RET_POSTFIX, &alc); } int java_demangle_v3_callback (const char *mangled, demangle_callbackref callback, void *opaque) { return d_demangle_callback (mangled, DMGL_JAVA | DMGL_PARAMS | DMGL_RET_POSTFIX, callback, opaque); } #endif /* IN_LIBGCC2 || IN_GLIBCPP_V3 */ #ifndef IN_GLIBCPP_V3 /* Demangle a string in order to find out whether it is a constructor or destructor. Return non-zero on success. Set *CTOR_KIND and *DTOR_KIND appropriately. */ static int is_ctor_or_dtor (const char *mangled, enum gnu_v3_ctor_kinds *ctor_kind, enum gnu_v3_dtor_kinds *dtor_kind) { struct d_info di; struct demangle_component *dc; int ret; *ctor_kind = (enum gnu_v3_ctor_kinds) 0; *dtor_kind = (enum gnu_v3_dtor_kinds) 0; cplus_demangle_init_info (mangled, DMGL_GNU_V3, strlen (mangled), &di); { #ifdef CP_DYNAMIC_ARRAYS __extension__ struct demangle_component comps[di.num_comps]; __extension__ struct demangle_component *subs[di.num_subs]; di.comps = comps; di.subs = subs; #else di.comps = alloca (di.num_comps * sizeof (*di.comps)); di.subs = alloca (di.num_subs * sizeof (*di.subs)); #endif dc = cplus_demangle_mangled_name (&di, 1); /* Note that because we did not pass DMGL_PARAMS, we don't expect to demangle the entire string. */ ret = 0; while (dc != NULL) { switch (dc->type) { default: dc = NULL; break; case DEMANGLE_COMPONENT_TYPED_NAME: case DEMANGLE_COMPONENT_TEMPLATE: case DEMANGLE_COMPONENT_RESTRICT_THIS: case DEMANGLE_COMPONENT_VOLATILE_THIS: case DEMANGLE_COMPONENT_CONST_THIS: dc = d_left (dc); break; case DEMANGLE_COMPONENT_QUAL_NAME: case DEMANGLE_COMPONENT_LOCAL_NAME: dc = d_right (dc); break; case DEMANGLE_COMPONENT_CTOR: *ctor_kind = dc->u.s_ctor.kind; ret = 1; dc = NULL; break; case DEMANGLE_COMPONENT_DTOR: *dtor_kind = dc->u.s_dtor.kind; ret = 1; dc = NULL; break; } } } return ret; } /* Return whether NAME is the mangled form of a g++ V3 ABI constructor name. A non-zero return indicates the type of constructor. */ enum gnu_v3_ctor_kinds is_gnu_v3_mangled_ctor (const char *name) { enum gnu_v3_ctor_kinds ctor_kind; enum gnu_v3_dtor_kinds dtor_kind; if (! is_ctor_or_dtor (name, &ctor_kind, &dtor_kind)) return (enum gnu_v3_ctor_kinds) 0; return ctor_kind; } /* Return whether NAME is the mangled form of a g++ V3 ABI destructor name. A non-zero return indicates the type of destructor. */ enum gnu_v3_dtor_kinds is_gnu_v3_mangled_dtor (const char *name) { enum gnu_v3_ctor_kinds ctor_kind; enum gnu_v3_dtor_kinds dtor_kind; if (! is_ctor_or_dtor (name, &ctor_kind, &dtor_kind)) return (enum gnu_v3_dtor_kinds) 0; return dtor_kind; } #endif /* IN_GLIBCPP_V3 */ #ifdef STANDALONE_DEMANGLER #include "getopt.h" #include "dyn-string.h" static void print_usage (FILE* fp, int exit_value); #define IS_ALPHA(CHAR) \ (((CHAR) >= 'a' && (CHAR) <= 'z') \ || ((CHAR) >= 'A' && (CHAR) <= 'Z')) /* Non-zero if CHAR is a character than can occur in a mangled name. */ #define is_mangled_char(CHAR) \ (IS_ALPHA (CHAR) || IS_DIGIT (CHAR) \ || (CHAR) == '_' || (CHAR) == '.' || (CHAR) == '$') /* The name of this program, as invoked. */ const char* program_name; /* Prints usage summary to FP and then exits with EXIT_VALUE. */ static void print_usage (FILE* fp, int exit_value) { fprintf (fp, "Usage: %s [options] [names ...]\n", program_name); fprintf (fp, "Options:\n"); fprintf (fp, " -h,--help Display this message.\n"); fprintf (fp, " -p,--no-params Don't display function parameters\n"); fprintf (fp, " -v,--verbose Produce verbose demanglings.\n"); fprintf (fp, "If names are provided, they are demangled. Otherwise filters standard input.\n"); exit (exit_value); } /* Option specification for getopt_long. */ static const struct option long_options[] = { { "help", no_argument, NULL, 'h' }, { "no-params", no_argument, NULL, 'p' }, { "verbose", no_argument, NULL, 'v' }, { NULL, no_argument, NULL, 0 }, }; /* Main entry for a demangling filter executable. It will demangle its command line arguments, if any. If none are provided, it will filter stdin to stdout, replacing any recognized mangled C++ names with their demangled equivalents. */ int main (int argc, char *argv[]) { int i; int opt_char; int options = DMGL_PARAMS | DMGL_ANSI | DMGL_TYPES; /* Use the program name of this program, as invoked. */ program_name = argv[0]; /* Parse options. */ do { opt_char = getopt_long (argc, argv, "hpv", long_options, NULL); switch (opt_char) { case '?': /* Unrecognized option. */ print_usage (stderr, 1); break; case 'h': print_usage (stdout, 0); break; case 'p': options &= ~ DMGL_PARAMS; break; case 'v': options |= DMGL_VERBOSE; break; } } while (opt_char != -1); if (optind == argc) /* No command line arguments were provided. Filter stdin. */ { dyn_string_t mangled = dyn_string_new (3); char *s; /* Read all of input. */ while (!feof (stdin)) { char c; /* Pile characters into mangled until we hit one that can't occur in a mangled name. */ c = getchar (); while (!feof (stdin) && is_mangled_char (c)) { dyn_string_append_char (mangled, c); if (feof (stdin)) break; c = getchar (); } if (dyn_string_length (mangled) > 0) { #ifdef IN_GLIBCPP_V3 s = __cxa_demangle (dyn_string_buf (mangled), NULL, NULL, NULL); #else s = cplus_demangle_v3 (dyn_string_buf (mangled), options); #endif if (s != NULL) { fputs (s, stdout); free (s); } else { /* It might not have been a mangled name. Print the original text. */ fputs (dyn_string_buf (mangled), stdout); } dyn_string_clear (mangled); } /* If we haven't hit EOF yet, we've read one character that can't occur in a mangled name, so print it out. */ if (!feof (stdin)) putchar (c); } dyn_string_delete (mangled); } else /* Demangle command line arguments. */ { /* Loop over command line arguments. */ for (i = optind; i < argc; ++i) { char *s; #ifdef IN_GLIBCPP_V3 int status; #endif /* Attempt to demangle. */ #ifdef IN_GLIBCPP_V3 s = __cxa_demangle (argv[i], NULL, NULL, &status); #else s = cplus_demangle_v3 (argv[i], options); #endif /* If it worked, print the demangled name. */ if (s != NULL) { printf ("%s\n", s); free (s); } else { #ifdef IN_GLIBCPP_V3 fprintf (stderr, "Failed: %s (status %d)\n", argv[i], status); #else fprintf (stderr, "Failed: %s\n", argv[i]); #endif } } } return 0; } #endif /* STANDALONE_DEMANGLER */ ht-2.0.22/htpeimp.h0000644000175000001440000000357410615341624010757 00000000000000/* * HT Editor * htpeimp.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTPEIMP_H__ #define __HTPEIMP_H__ #include "formats.h" extern format_viewer_if htpeimports_if; /* * class ht_pe_import_library */ class ht_pe_import_library: public Object { public: char *name; ht_pe_import_library(const char *name); ~ht_pe_import_library(); }; /* * class ht_pe_import_function */ class ht_pe_import_function: public Object { public: uint libidx; bool byname; union { uint ordinal; struct { char *name; uint hint; } name; }; RVA address; ht_pe_import_function(uint libidx, RVA address, uint ordinal); ht_pe_import_function(uint libidx, RVA address, const char *name, uint hint); ~ht_pe_import_function(); }; struct ht_pe_import { Container *funcs; Container *libs; }; /* * CLASS ht_pe_import_viewer */ class ht_pe_import_viewer: public ht_itext_listbox { protected: ht_format_group *format_group; bool grouplib; uint sortby; /* new */ void dosort(); public: void init(Bounds *b, const char *desc, ht_format_group *fg); virtual void done(); /* overwritten */ virtual void handlemsg(htmsg *msg); virtual bool select_entry(void *entry); /* new */ const char *func(uint i, bool execute); }; #endif /* !__HTPEIMP_H__ */ ht-2.0.22/htanaly.h0000644000175000017500000001577312127651417010765 00000000000000/* * HT Editor * htanaly.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef HTANALY_H #define HTANALY_H #include "analy.h" #include "cmds.h" #include "io/types.h" #include "htdialog.h" #include "htformat.h" #include "httree.h" #include "out.h" /* * Commands */ #define cmd_analyser_call_assembler HT_COMMAND(501) #define cmd_analyser_this_function HT_COMMAND(502) #define cmd_analyser_previous_label HT_COMMAND(503) #define cmd_analyser_continue HT_COMMAND(504) #define cmd_analyser_comments HT_COMMAND(505) #define cmd_analyser_name_addr HT_COMMAND(506) #define cmd_analyser_xrefs HT_COMMAND(507) #define cmd_analyser_follow HT_COMMAND(508) #define cmd_analyser_follow_ex HT_COMMAND(509) #define cmd_analyser_pause_resume HT_COMMAND(510) #define cmd_analyser_del_addr_bindings HT_COMMAND(511) #define cmd_analyser_call_chain HT_COMMAND(512) #define cmd_analyser_generate_output HT_COMMAND(513) #define cmd_analyser_data_string HT_COMMAND(514) #define cmd_analyser_info HT_COMMAND(515) #define cmd_analyser_symbols HT_COMMAND(516) #define cmd_analyser_export_file HT_COMMAND(517) #define cmd_analyser_data_int HT_COMMAND(518) #define cmd_analyser_data_half HT_COMMAND(519) #define cmd_analyser_data_byte HT_COMMAND(520) /* FIXME: srt-experimental */ #define cmd_analyser_srt HT_COMMAND(550) class ht_aviewer; /* * */ class AnalyserInformation: public ht_statictext { ht_aviewer *analy; int addrs, labels; const char *atype, *adis; String aname; public: void init(Bounds *b, ht_aviewer *a); virtual void done(); virtual int gettext(char *text, int maxlen); virtual bool idle(); }; /* * */ class SymbolBox: public ht_listbox { public: Analyser *analy; char *str; int idle_count; int symbols; void init(Bounds *b, Analyser *Analy); virtual void done(); virtual int calcCount(); virtual int cursorAdjust(); virtual int estimateEntryPos(void *entry); virtual void * getFirst(); virtual void * getLast(); virtual void * getNext(void *entry); virtual void * getPrev(void *entry); virtual const char *getStr(int col, void *entry); virtual bool idle(); virtual int numColumns(); virtual void * quickfind(const char *s); virtual char * quickfindCompletition(const char *s); }; struct CallChainNode { CallChainNode *next, *prev, *child; bool examined; Address *xa; Address *fa; Location *faddr; bool expanded; }; class CallChain: public ht_treeview { Analyser *analy; CallChainNode *root; public: void init(Bounds *b, Analyser *analy, Address *a, char *desc); virtual void done(); virtual void adjust(void *node, bool expand); virtual void *get_child(void *node, int i); virtual void *get_next_node(void *node); virtual void *get_prev_node(void *node); virtual void *get_root(); virtual char *get_text(void *node); virtual bool has_children(void *node); virtual bool is_expanded(void *node); virtual void select_node(void *node); CallChainNode *get_current_node(); private: CallChainNode *createNode(Address *a); void examineNode(CallChainNode *n); }; /* * */ #define ANALY_STATUS_DEFAULT "<%s> @%O %u\n%f" #define ANALY_STATUS_ARG_SECTION 's' #define ANALY_STATUS_ARG_FILEOFFSET 'O' #define ANALY_STATUS_ARG_RAW_UNASM 'u' #define ANALY_STATUS_ARG_FUNCTION 'f' #define ANALY_STATUS_ARG_OFFSET 'o' class AnalyInfoline: public ht_statictext { public: ht_aviewer *analy; char *s; FileOfs fofs; Address *addr; char *displayformat; void init(Bounds *b, ht_aviewer *A, const char *Format); virtual void done(); virtual int gettext(char *text, int maxlen); void update(Address *cursor_addr, FileOfs ecursor_addr); bool valid(); }; /* * CLASS ht_analy_sub */ class ht_aviewer; class ht_analy_sub: public ht_sub { public: Analyser *analy; Address *lowestaddress, *highestaddress; AnalyserOutput *output; ht_aviewer *aviewer; void init(File *file, ht_aviewer *A, Analyser *analyser, Address *Lowestaddress, Address *Highestaddress); virtual void done(); virtual bool convert_ofs_to_id(const FileOfs offset, LINE_ID *line_id); virtual bool closest_line_id(LINE_ID *line_id); virtual void first_line_id(LINE_ID *line_id); virtual bool getline(char *line, int maxlen, const LINE_ID line_id); virtual void last_line_id(LINE_ID *line_id); virtual int next_line_id(LINE_ID *line_id, int n); virtual int prev_line_id(LINE_ID *line_id, int n); void setAnalyser(Analyser *Analy); virtual ht_search_result *search(ht_search_request *search, FileOfs start, FileOfs end); }; /* * CLASS ht_aviewer */ class ht_aviewer: public ht_uformat_viewer { public: int idle_count; Analyser *analy; int last_active; AnalyInfoline *infoline; ht_analy_sub *analy_sub; bool one_load_hack; bool pause; void init(Bounds *b, const char *desc, int caps, File *file, ht_format_group *format_group, Analyser *Analy); virtual void done(); bool convertAddressToViewerPos(Address *a, viewer_pos *p); bool convertViewerPosToAddress(const viewer_pos &p, Address **a); void attachInfoline(AnalyInfoline *V); bool canCreateAddress(Address *addr, bool error_msg); void dataStringDialog(); void dataIntDialog(taddr_int_subtype subtype, int length); void exportFileDialog(); virtual const char *func(uint i, bool execute); void generateOutputDialog(); bool getCurrentAddress(Address **a); virtual bool get_current_offset(FileOfs *ofs); virtual int get_pindicator_str(char *buf, int max_len); virtual bool get_hscrollbar_pos(int *pstart, int *psize); virtual void getminbounds(int *width, int *height); bool gotoAddress(Address *a, ht_view *source_object); virtual void handlemsg(htmsg *msg); virtual bool idle(); virtual bool offset_to_pos(FileOfs ofs, viewer_pos *p); virtual bool pos_to_offset(viewer_pos p, FileOfs *ofs); bool pos_to_string(viewer_pos p, char *result, int maxlen); virtual bool ref_sel(LINE_ID *id); virtual void reloadpalette(); virtual void setAnalyser(Analyser *a) = 0; void showCallChain(Address *addr); void showComments(Address *addr); void showInfo(Address *addr); void showSymbols(Address *addr); void showXRefs(Address *addr); void searchForXRefs(Address *addr); virtual bool qword_to_pos(uint64 q, viewer_pos *p); virtual bool func_handler(eval_scalar *result, char *name, eval_scalarlist *params); virtual bool symbol_handler(eval_scalar *result, char *name); }; #endif ht-2.0.22/tools.h0000644000175000017500000000246311724770012010450 00000000000000/* * HT Editor * tools.h * * Copyright (C) 1999-2002 Sebastian Biallas (sb@biallas.net) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __TOOLS_H__ #define __TOOLS_H__ #include #include #include "io/types.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif uint32 delinearize(uint32 d); uint64 delinearize64(uint64 d); int *random_permutation(int max); double calc_entropy(byte *buf, int size); int calc_entropy2(byte *buf, int size); #define OUT_OF_MEMORY_FAIL 0 #define OUT_OF_MEMORY_IGNORE 1 #define OUT_OF_MEMORY_RETRY 2 extern int (*out_of_memory_func)(int size); int out_of_memory(int size); // savety mallocs void *smalloc(size_t size); void *smalloc0(size_t size); #endif /* __TOOLS_H__ */ ht-2.0.22/htdialog.h0000644000175000001440000003266510615341616011110 00000000000000/* * HT Editor * htdialog.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTDIALOG_H__ #define __HTDIALOG_H__ #include #include "htdebug.h" #include "htobj.h" #include "strtools.h" #include "io/keyb.h" /* * CLASS ht_dialog */ #define ds_normal 0 #define ds_term_ok 1 #define ds_term_cancel 2 #define button_cancel 0 #define button_ok 1 #define button_yes button_ok #define button_no 2 #define button_skip button_no #define button_all 3 #define button_none 4 class ht_queued_msg: public Object { public: ht_view *target; htmsg msg; ht_queued_msg(ht_view *target, htmsg &msg); }; class ht_dialog: public ht_window { protected: int state; int return_val; Queue *msgqueue; /* overwritten */ virtual const char *defaultpalette(); ht_queued_msg *dequeuemsg(); public: ht_dialog() {}; ht_dialog(BuildCtorArg&a): ht_window(a) {}; void init(Bounds *b, const char *desc, uint framestyle); virtual void done(); /* overwritten */ virtual int aclone(); virtual void draw(); virtual void handlemsg(htmsg *msg); /* new */ void queuemsg(ht_view *target, htmsg &msg); virtual int getstate(int *return_val); virtual int run(bool modal); virtual void setstate(int state, int return_val); }; /* * CLASS ht_cluster */ class ht_cluster: public ht_dialog_widget { protected: ht_string_list *strings; int sel; int scount; ht_key shortcuts[32]; /* overwritten */ virtual const char *defaultpalette(); public: void init(Bounds *b, ht_string_list *strings); virtual void done(); }; /* * CLASS ht_checkboxes */ struct ht_checkboxes_data { DDECL_UINT(state); }; class ht_checkboxes: public ht_cluster { protected: uint32 state; public: void init(Bounds *b, ht_string_list *strings); virtual void done(); /* overwritten */ virtual int datasize(); virtual void draw(); virtual void handlemsg(htmsg *msg); virtual void getdata(ObjectStream &s); virtual void setdata(ObjectStream &s); }; /* * CLASS ht_radioboxes */ struct ht_radioboxes_data { DDECL_UINT(sel); }; class ht_radioboxes: public ht_cluster { public: void init(Bounds *b, ht_string_list *strings); virtual void done(); /* overwritten */ virtual int datasize(); virtual void draw(); virtual void handlemsg(htmsg *msg); virtual void getdata(ObjectStream &s); virtual void setdata(ObjectStream &s); }; /* * CLASS ht_inputfield */ class ht_inputfield; struct ht_inputfield_data { DDECL_UINT(textlen); DDECL_PTR(byte, text); }; class ht_inputfield: public ht_dialog_widget { protected: byte **text, *textv; byte **curchar, *curcharv; byte **selstart, *selstartv; byte **selend, *selendv; int *textlen, textlenv; int *maxtextlen, maxtextlenv; int insert; int ofs; ht_inputfield *attachedto; List *history; void freebuf(); int insertbyte(byte *pos, byte b); void select_add(byte *start, byte *end); /* overwritten */ virtual const char *defaultpalette(); public: void init(Bounds *b, int maxtextlen, List *history = NULL); virtual void done(); /* overwritten */ virtual int datasize(); virtual void getdata(ObjectStream &s); virtual void setdata(ObjectStream &s); /* new */ void attach(ht_inputfield *inputfield); void query(byte ***curchar, byte ***text, byte ***selstart, byte ***selend, int **textlen, int **maxtextlen); void isetcursor(uint pos); }; /* * CLASS ht_strinputfield */ #define ht_strinputfield_data ht_inputfield_data class ht_strinputfield: public ht_inputfield { protected: bool is_virgin; /* untouched except for cursor keys */ bool selectmode; /* new */ void correct_viewpoint(); void history_dialog(); bool inputbyte(byte a); bool setbyte(byte a); public: void init(Bounds *b, int maxtextlen, List *history = NULL); virtual void done(); /* overwritten */ virtual void draw(); virtual void handlemsg(htmsg *msg); virtual void receivefocus(); }; /* * CLASS ht_hexinputfield */ #define ht_hexinputfield_data ht_inputfield_data class ht_hexinputfield: public ht_inputfield { protected: int nib; void correct_viewpoint(); public: void init(Bounds *b, int maxtextlen); virtual void done(); /* overwritten */ virtual void draw(); virtual void handlemsg(htmsg *msg); virtual void receivefocus(); /* new */ void setnibble(byte a); }; /* * CLASS ht_button */ class ht_button: public ht_dialog_widget { protected: int value; int pressed; char *text; char *magicchar; ht_key shortcut1; ht_key shortcut2; /* overwritten */ virtual const char *defaultpalette(); public: void init(Bounds *b, const char *text, int value); virtual void done(); /* overwritten */ virtual void draw(); virtual void handlemsg(htmsg *msg); virtual void getminbounds(int *width, int *height); /* new */ virtual void push(); }; /* * CLASS ht_listbox_title */ class ht_listbox; class ht_listbox_title: public ht_dialog_widget { public: ht_listbox *listbox; protected: char **texts; int cols; /* overwritten */ virtual const char *defaultpalette(); public: void init(Bounds *b); virtual void done(); /* overwritten */ virtual void draw(); /* new */ virtual vcp getTextColor(); void setText(int cols, ...); void setTextv(int cols, va_list arguments); void update(); }; /* * CLASS ht_listbox */ struct ht_listbox_data_internal { void *top_ptr; void *cursor_ptr; }; struct ht_listbox_data { DDECL_PTR(ht_listbox_data_internal, data); }; #define LISTBOX_NORMAL 0 #define LISTBOX_QUICKFIND 1 class ht_listbox: public ht_dialog_widget { protected: public: int cursor, pos, cached_count; int visible_height; void *e_top, *e_cursor; int x; char quickfinder[100]; char *qpos; uint listboxcaps; int cols; int *widths; ht_scrollbar *scrollbar; bool mScrollbarEnabled; ht_listbox_title *title; public: void init(Bounds *b, uint Listboxcaps=LISTBOX_QUICKFIND); virtual void done(); void attachTitle(ht_listbox_title *title); void adjustPosHack(); void adjustScrollbar(); virtual int calcCount() = 0; void clearQuickfind(); virtual int cursorAdjust(); int cursorUp(int n); int cursorDown(int n); virtual int datasize(); virtual const char * defaultpalette(); virtual void draw(); virtual int estimateEntryPos(void *entry); virtual void getdata(ObjectStream &s); virtual void * getFirst() = 0; virtual void * getLast() = 0; virtual void * getNext(void *entry) = 0; virtual void * getPrev(void *entry) = 0; virtual const char * getStr(int col, void *entry) = 0; void gotoItemByEntry(void *entry, bool clear_quickfind = true); virtual void gotoItemByPosition(uint pos); virtual void handlemsg(htmsg *msg); virtual int numColumns(); virtual void * quickfind(const char *s) = 0; virtual char * quickfindCompletition(const char *s); virtual void redraw(); virtual void resize(int rw, int rh); virtual bool selectEntry(void *entry); virtual void setdata(ObjectStream &s); virtual void stateChanged(); virtual void update(); void updateCursor(); virtual Object * vstate_create(); void vstate_save(); protected: void rearrangeColumns(); }; /* * CLASS ht_text_listbox */ #define ht_text_listbox_data ht_listbox_data struct ht_text_listbox_item { ht_text_listbox_item *next, *prev; int id; void *extra_data; char *data[0]; }; struct ht_text_listbox_sort_order { int col; int (*compare_func)(const char *key_a, const char *key_b); }; class ht_text_listbox: public ht_listbox { protected: int cols, keycol, count; ht_text_listbox_item *first, *last; int Cursor_adjust; public: void init(Bounds *b, int Cols=1, int Keycol=0, uint Listboxcaps=LISTBOX_QUICKFIND); virtual void done(); virtual int calcCount(); virtual int compare_strn(const char *s1, const char *s2, int l); virtual int compare_ccomm(const char *s1, const char *s2); virtual int cursorAdjust(); void * getEntryByID(uint id); virtual void * getFirst(); virtual void * getLast(); uint getID(void *entry); void * getExtra(void *entry); virtual void * getNext(void *entry); virtual void * getPrev(void *entry); virtual const char *getStr(int col, void *entry); void insert_str(int id, const char *str, ...); void insert_str(int id, const char **strs); void insert_str_extra(int id, void *extra_data, const char *str, ...); void insert_str_extra(int id, void *extra_data, const char **strs); virtual int numColumns(); virtual void * quickfind(const char *s); virtual char * quickfindCompletition(const char *s); void sort(int count, ht_text_listbox_sort_order *so); virtual void update(); protected: virtual void clearAll(); virtual void freeExtraData(void *extra_data); }; #define ht_itext_listbox_data ht_text_listbox_data class ht_itext_listbox: public ht_text_listbox { public: void init(Bounds *b, int Cols=1, int Keycol=0); virtual int compare_strn(const char *s1, const char *s2, int l); virtual int compare_ccomm(const char *s1, const char *s2); }; /* * CLASS ht_statictext */ enum statictext_align { align_left, align_center, align_right, align_custom }; #define ALIGN_CHAR_ESCAPE '\e' #define ALIGN_CHAR_LEFT 'l' #define ALIGN_CHAR_CENTER 'c' #define ALIGN_CHAR_RIGHT 'r' struct ht_statictext_linedesc { int ofs; int len; char *text; }; class ht_statictext: public ht_text { protected: char *text; statictext_align align; bool breaklines; bool transparent; /* overwritten */ virtual const char *defaultpalette(); public: void init(Bounds *b, const char *text, statictext_align align, bool breaklines=true, bool transparent=false); virtual void done(); /* overwritten */ virtual void draw(); virtual void settext(const char *text); /* new */ virtual int gettext(char *text, int maxlen); virtual vcp gettextcolor(); }; /* * CLASS ht_listpopup_dialog */ struct ht_listpopup_dialog_data { DDECL_UINT(cursor_pos); DDECL_PTR(char, cursor_string); }; class ht_listpopup_dialog: public ht_dialog { protected: ht_listbox *listbox; virtual void init_text_listbox(Bounds *b); public: void init(Bounds *b, const char *desc); /* overwritten */ virtual const char *defaultpalette(); virtual int datasize(); virtual void getdata(ObjectStream &s); void insertstring(const char *string); virtual void setdata(ObjectStream &s); /* new */ void select_next(); void select_prev(); }; /* * CLASS ht_listpopup */ #define ht_listpopup_data ht_listpopup_dialog_data class ht_listpopup: public ht_statictext { protected: ht_listpopup_dialog *listpopup; /* new */ int run_listpopup(); public: void init(Bounds *b); virtual void done(); /* overwritten */ virtual int datasize(); virtual void draw(); virtual vcp gettextcolor(); virtual void getdata(ObjectStream &s); virtual int gettext(char *text, int maxlen); virtual void handlemsg(htmsg *msg); virtual void setdata(ObjectStream &s); /* new */ void insertstring(const char *string); }; /* * CLASS ht_history_listbox */ class ht_history_listbox: public ht_listbox { List *history; public: void init(Bounds *b, List *hist); virtual int calcCount(); virtual void *getFirst(); virtual void *getLast(); virtual void *getNext(void *entry); virtual void *getPrev(void *entry); virtual const char *getStr(int col, void *entry); virtual void handlemsg(htmsg *msg); virtual void *quickfind(const char *s); virtual char *quickfindCompletition(const char *s); }; /* * CLASS ht_history_popup_dialog */ class ht_history_popup_dialog: public ht_listpopup_dialog { protected: List *history; virtual void init_text_listbox(Bounds *b); public: void init(Bounds *b, List *hist); virtual void getdata(ObjectStream &s); virtual void setdata(ObjectStream &s); }; /* * CLASS ht_label */ class ht_label: public ht_dialog_widget { protected: ht_view *connected; char *text; char *magicchar; ht_key shortcut; /* overwritten */ virtual const char *defaultpalette(); public: void init(Bounds *b, const char *text, ht_view *connected); virtual void done(); /* overwritten */ virtual void draw(); virtual void handlemsg(htmsg *msg); }; /* * CLASS ht_progress_indicator */ class ht_progress_indicator: public ht_window { protected: /* overwritten */ virtual const char *defaultpalette(); public: ht_statictext *text; void init(Bounds *b, const char *hint); /* new */ void settext(const char *text); }; /* * CLASS ht_color_block */ struct ht_color_block_data { DDECL_UINT(color); }; #define cf_light 1 #define cf_transparent 2 class ht_color_block: public ht_dialog_widget { protected: int color; int colors; int flags; /* overwritten */ virtual const char *defaultpalette(); public: void init(Bounds *b, int selected, int flags); virtual void done(); /* overwritten */ virtual int datasize(); virtual void draw(); virtual void getdata(ObjectStream &s); virtual void setdata(ObjectStream &s); virtual void handlemsg(htmsg *msg); }; /* * CLASS ht_listbox_ptr */ class ht_listbox_ptr: public Object { public: ht_listbox *listbox; ht_listbox_ptr(ht_listbox *aListbox) : listbox(aListbox) { } }; void center_bounds(Bounds *b); #endif /* !__HTDIALOG_H__ */ ht-2.0.22/ChangeLog0000644000175000017500000005000612156430772010713 00000000000000 HT ChangeLog ============== version 2.0.22: - Fixed selection of nodes in call chain - Added ability to view/edit 64 bit symbols and relocation for ELFs (Thanks tecknicaltom) - Added new option "editor/scroll offset" which determines how many extra lines the cursor should be visible when scolling (Thanks tecknicaltom) - Fixed loading of ELF files for alpha - Fixed some compilation problems with newer toolchain - Updated address of FSF version 2.0.21: - [x86] AVX2 updates - Fixed usage of unaliged pointers (Thanks Jan) - Restructed configure/makefile for better handling of ncurses depedency (Thanks Jan) version 2.0.20: - Fixed loading of 32 bit ELFs (Thanks Oleg) - Use wide ncurses if necessars (Thanks Jan) - Show search progress in MiB (Thanks Jan) version 2.0.19: - [x86] fixed a lot of small bugs - fixed a crash with the "follow" function on invalid addresses in analyser - [x86] AVX updates - [x86] AVX2 - [x86] BMI, BMI2 and TBM instructions - fixed loading of ELF files with no section headers - [Win32] Fixed loading of files with path length > 100 (thanks Vitaliy) version 2.0.18: - updated c++ demangler - [x86] SSE5/XOP/AVX merge - [x86] AMD LWP instructions - symbols "first" and "last" in hex view - project manager works again version 2.0.17: - compilation fixes for gcc 4.4 - fixed crash on garbage in elf section headers version 2.0.16: - [x86] intel avx update - updated c++ demangler - small crash fix version 2.0.15: - [Win32] removed a debug printf - fixed clipboard view - fixed ELF symbol viewer version 2.0.14: - [x86] movbe, invept, invvpid - [eval] better help - [eval] last result (symbol _) - [eval] u8, u16 etc. for current byte, word.. - fixed embarrassing endianess bug version 2.0.13: - [win32] optimize redrawing (reduce flicker) - [x86] intel avx, aes and pclmulqdq extension version 2.0.12: - fixed crash with too long lines - fixed some cosmetic resizing things in dialogs (File-Open, Show-Xrefs) - c++-demangler from gcc 4.3 version 2.0.11: - [Win32] Save config in home directory - fixed crash while changing text highlighting - small bug fixes version 2.0.10: - [x86] SSE5 :) version 2.0.9: - [Mach-O] ARM and X86_64 support - [Mach-O] support for 64 bit images - small bugs fixes version 2.0.8: - Loading Analyser for java class files was broken - Fixed some cosmetic resizing bugs - Fixed infinite loop in fgetstrz version 2.0.7: - Added a missing #include found by gcc 4.3 - Fixed minor problems found by gcc 4.3 version 2.0.6: - [POSIX] Ignore mouse events - Dump analyser output function was broken - Fixed a lot of (possible) buffer overflows version 2.0.5: - Editing bytes in image mode was broken under subtile circumstances version 2.0.4: - Fixed some 64 bit issues version 2.0.3: - [POSIX] Resize application on SIGWINCH - [x86] SSE4.1/SSE4.2 - [x86] small bug fixes - [x86] reduced opcode table bloat - Allow different displacements in hex view version 2.0.2: - [IA64] disassembler works again (is anybody using this?) - [Java] fixed stupid undefined behaviour bug - [Java] use Signature information when available (annotates generic functions etc.) version 2.0.1: - [Java] annotate exception handlers in byte code - [Java] some byte code improvements (lookupswitch, tableswitch) - Analyser can export HTML files again - [PowerPC] added Cell and POWER6 instructions version 2.0: - renamed process.h to htprocess.h because of some stupid cygwin build problems - fixed some problem with file sizes > 4 GiB version 2.0beta6: - fixed crash when opening read only files in obscure situations - [ELF & java] fixed binary search in image view - [ELF64] some cosmetic fixes - [java] off by one version 2.0beta5: - [Win32] messed up file-saving code version 2.0beta4: - fixed crash in cp-demangle - [Win32] Relax CPU version 2.0beta3: - fixed crash in drop-down widget - fixed loading of class files - fixed generating text output files of analyser - implemented automatic window tiling - fixed saving of text files version 2.0beta2: - should now really support file sizes > 4 GiB - some ncurses wuerg-arounds - better handling of ELFs without program headers - bug fixes version 2.0beta: - new disassembler: (PE and ELF) * x86_64 * ARM * 64 bit PowerPC * VMX128 extension for PowerPC - x86_64 assembler - Allow file sizes > 4 GiB - Rewrote a lot version 0.9.5: - [x86] wrong mnemnonics for iret/d/q version 0.9.4: - [x86] Fixed stupid bug in assembler (group insns weren't accessible) - [x86] Some labels generated by the analyzer were had wrong prefix version 0.9.3: - [x86] added SSSE3 and missing vanderpool/pacifica instructions - [x86] andpd had wrong mnemonic - [x86] allow alternative mnemonics (like jz vs. je) version 0.9.2: - updated ELF program header types - better Mach-O executable sections detection - allow ':' key for changing comments in analyser - [Win] use unicode output - compile with gcc 4.1 - updated minilzo - small bug fixes version 0.9.1: - updated cp-demangle.c from gcc: This fixes two bugs in the symbol name demangler which could crash HT. version 0.9.0: - analyser: support for int, half and byte data-types. - x86 disasm: invlpg, fisttp instructions added - x86 disasm: sse, sse2, sse3 instructions added - x86 asm: support for mmx instructions - configure: set -DNO_NATIVE_UNALIGNED_MOVES for platforms other than x86 - removed 'include ' from cp-demangle.c - fixed a buffer overflow in htperes.cc - handle ELFs w/o segment or program sections (Thanks Daniel Black) - don't malloc(0) (Thanks Daniel Black) - some keyboard fixed for windows xp version 0.8.0: - g++ v3 abi demangler - x86 disasm: added undocumented ffreep (df c0) instruction - compiles with gcc 3.4 - fixed buggy blockop-progress indicator - fixed ugly segfault with elf symbol loading - ppc disassebler updated (altivec instructions) - removed stefan's email address (dead) version 0.8.0pre1: - disassembler: - IBM/Motorola PowerPC (PPC) (new) - file formats: - XBE (X-Box executable) support by Stefan Esser (experimental) - Mach-O header and image support for PPC and x86 (experimental) - FLT (Flat) support (experimental) - PEF support (experimental) - XCOFF32 support - COFF support for coff files without optional header - COFF big-endian support - ELF PPC support - ELF relocatable file support (experimental) - fixed buggy ELF reading code partially (thanks rpm28) - eval dialog: added function help - eval: not ('~') and logical-not ('!') operators - disassembler interface (int maxlen, not byte maxlen) - Win32: fixed access to native windows clipboard - Win32: high CPU usage problems fixed (sys_suspend() bugged) version 0.7.5: - fixed bug in bnstr() with defaultbase > 10 - fixed buffer overflow in htelfsym.cc (thanks Luis Barrancos) - fixed bug in ht_sys_file/ht_stdio_file::extend() - fixed bug, causing invalid history entries when specifying files on the command-line - fixed bug in x86-assembler (correct opcode for [ebp+esp]) - minor fixes in eval-lexer version 0.7.4: - fixed bug in COFF code (hdr_ofs sometimes fixed to 0x800) - fixed bug in blockop (checking if const/var op didn't set 'i' and 'o' and sometimes failed) - fixed bug in Java bytecode disassembler: invalid opcodes crash. Thanks Jerome (freejazz). - fixed bug in Java class processing code: errors always crash HT - fixed: 0xcafebabe in mach_kernel... made classread more strict - fixed object streaming bug in GET_OBJECT (only when compiled with GCC 3.3+) version 0.7.3: - some keys were assigned to multiple commands in hex-viewer - percent display for searches and scrollbars in big files was incorrect - POSIX: improved keyboard handling (merge from 0.9.0 tree) - POSIX: X11 textmode keyboard support didn't work :-), was not configured correctly branch_only - configure now does final (release) builds by default (ie. -O2 -fomit-frame-pointer) branch_only - binary search in */image disabled because its buggy version 0.7.2: - Hexview: Number of bytes per line can be changed now - PE/header: can now follow bound import directory link (it's offset not RVA !) - x86dis: "0f 0f 0f" is now marked invalid (as it should be) - alt-x in blockop dialog was used twice by "cut" and "select expr" - fixed problem in streams that caused files not to be flagged "modified" - security fix: main.cc: strncpy(appname, argv[0], sizeof appname-1); - qword "x shl/shr 32" returns invalid result - ELF/section headers: flags now displayed correctly (thanks "scut") - (POSIX) slightly improved keyboard handling (Ctrl+W = close window) version 0.7.1: - (win2k/xp) fixed bug that caused ht to create ht.cfg in current directory instead of executable's - (win32) findfirst/next now fill the ctime, mtime and atime fields - (win32) chdir() to "X:\" fixed - cmdline param '-h' works again - new config.guess/config.sub version 0.7.0: - whole new Address class for the analyser. Much more flexible. Enables segmented and 64-bit addresses. - ht_snprintf/ht_vsnprintf + many possible buffer overflows fixed - projects (groups of files) - LE: image/analyser,VxD support, internal relocations (beta, no imports) - Java: disassembler, image/analyser - NE: relocations improved - IA-64 disassembler + PE64 support - .Net IL disassembler + PE .Net support (alpha) - submenus - view current/cursor offset in a different view - tools/int2info.pl: converts Ralf Brown's Interrupt List to TexInfo - htpehead.cc: directory goto works now, OFSs really are RVAs ! - sys/djgpp: ff2pstat(...) fixed - got rid of fmt_vaddress - PE/imports,exports,delay-imports based on ht_listbox - x86dis: movzx/movsx and "mov mem32/16, seg" param size ambiguity fixed and many minor fixes - goto dialog auto-documents available eval() functions - Inter-process communication (IPC) via console redirection on all existing platforms. Primitive terminal emulation. - qword support - new streamfiles: ht_sys_file, ht_stdio_file, ht_temp_file, ht_null_file - some memory leaks killed (Valgrind sessions) - log-window scrolling fixed - virtual file system (VFS) rewritten, VFS viewer rewritten - many bugs fixed version 0.6.0b: - textedit: save-bug fixed - sys/posix: pstat() fixed version 0.6.0: - ELF: new OS ABI values supported (eg. FreeBSD) - built-in registry - data not code - palette system redesigned - bin2c text-open-bug for djgpp fixed - physical search modes in image/analyser views implemented - huge memory leak in binary search eliminated - text viewer/editor: many bugs fixed, improved visualization, full undo support, speed ups, save works now - analyser output core rewritten - context menus - syntax highlighting in image/analyser views - text editor: choose syntax highlighting - x86-assembler: lock, repz, repnz support added - "save as" asks before overwriting :-) - search in PE/export, imports and ELF/symbols - history bug with visual search fixed - COFF/image and analyser implemented (experimental) - NE/image and analyser implemented (experimental) - NE/imports added, NE relocations started - info-viewer rewritten to cope with external files/references and to support big files - x86dis: fixed 16/32 bug with "jmp far x:y", fixed bug with lss,lfs,lgs - ht-posix: X11 textmode support (for better key handling) - analyser speed ups - many bugs fixed version 0.5.0: - htdata interface changes (list- and tree-enum) - improved ht-posix keyboard handling (home, end) - analyser can save and load its entire state ! .htcfg files are written for all analysed files - cstream rewritten and renamed to mfile - file truncate/extend now undoable - scrollbar in textedit - replace implemented, htsearch partially rewritten - resize/move behaviour changed (different modes for move/resize, works better on unices) - display if in edit or view mode (hex) - x86asm: "jmp far x:y" works now - select,copy,insert,delete through alt+s,alt+c,alt+v,alt+d - ht_compressed_stream implemented (uses miniLZO). it's used to compress all config files (down to about 30% of their original size) - time tag edit (!) - file/new implemented - textfile save implemented - "save as" implemented - vfs create file implemented - improved handling for broken files - textedit cut/delete - text editor undo + protocol - new info file viewer - byte-order/endianess problems fixed (PE, ELF, etc...) - ELF64 support started - x86dis: fixed signed imm bug (e.g. add word ptr [...], s_imm) - make-system updated and fixed - documentation updated - fixed bug with emptied histories - many bugs fixed version 0.4.5: - file truncate/extend - file has been modified, save ? - text viewer - analyser string detection - improved write caching (consumes less memory) - ht_textfile (allows intermixed line/offset-based read and write access) - text editor with syntax highlighting (C/C++) - handlemsg for ht_subs - ht_group_sub implemented - very powerful yacc/lex-based expression evaluator (supports functions and symbols), replaces old integer and old c/asm string evaluators. works inside: goto, search (eval once), blockop, search (halt if != 0). - evaluate dialog - str- and hex-inputfields fixed - statictext fixed (again...) - ht_view resizing rewritten - non-modal clipboard window - atoms based on tree - delete_timer didn't work ?! - textfile autodetect - file manager: copy files - edit comments - delete history entries - LE: object-flags update - improved scrollbar - scrollbar in hex/analyser - position indicators - new search mode: halt if eval(expr) != 0 - entropy/entropy2 functions search (halt if != 0) - LE: USE16 segments - improved non-x86 support - many bugs fixed version 0.4.4d: - prefixed genericdrawbuf methods with "b_" to avoid macro problems on some systems (printf on hppa) - compiles with gcc 3.0 version 0.4.4c: - linux/htsys.cc to include string.h (needed by FreeBSD, thanks Fyodor) - word/dword tags work again - 386-specific debug code removed - tools.h includes stdlib.h instead of malloc.h version 0.4.4b: - PE/exports ordinal bug fixed - escape in registry bug fixed - window-list on empty desktop bug fixed - build system errors fixed (hthelp.inc missing) version 0.4.4: - exposed() implemented (redraw view only if exposed()) - vfs-viewer (NC/MC-style abstract file manager) implemented - vfs's implemented: file, registry - registry edit dialogs (symlink, color) - block operations (fill file blocks with bytes, words, dwords or fixed strings) - dtree bugs fixed :-( - read caching fixed (ate up too much mem...) and disabled (now that it works its too slow...) - write caching speed-up. especially for linear writes (e.g. block ops) - configuration store/load (re)implemented, new config file format, architecture independant (32+ bits). - object-streams implemented (bin, text, memmap) - statictext (finally ?) fixed - i/o-system abstracted further - win32- and dj-suspend functions implemented - per-file not per-viewer edit-mode - registry store/load - history store/load - ELF support improved: relocations - search for xrefs - show recursive function references - many bugs fixed version 0.4.3: - statictext rewritten (finally ?) - pe and coff share some more data - quickfind completition (tab) for ht_listbox - htdata.cc rewritten (whole new data architecture) - rewrote resize mechanism - auto-select pasted data - registry implemented (replaces old palette system, more flexible) - color editor scrapped - viewer interfaces cleaned up (new name: format) - assembler fully integrated (write) - ht_listpopup is now based on ht_listbox - dialog histories (search, goto & files) - improved linux support (select-mode through alt+v, better menus, no longer wastes CPU time when idle) - empty uformats-bug fixed - message queuing implemented (dirty but works...) - listbox scrollbar works correctly now - enhanced win32 support - heavily improved ELF support: section headers, program headers, symbol tables and code/data analyser - collapsable hts_subs + collapsable headers - listbox sorting by row(s) - follow dword ptr at cursor (press 'f') - name demangling via libiberty's cplus-dem - more efficient growing algorithm for memstreams - general file information viewer - cancel searches in progress - customizable status (time, date, analyser activity) - LE support improved: entrypoints - visual (regex) searching implemented - packed statictag-tables - various asm/disasm(x86), search and clipboard bugs fixed - many bugs fixed version 0.4.2: - empty files/streams and empty ht_uviewers supported correctly - clipboard implemented (copy, paste, show, clear, copy from, paste to) - NE support started (header, segments, entrypoints, names) - close windows, always start - statictext finally works - Space in char-tag and in bit-tag work now - 'jmp/call Ep'-bug fixed - automatically select search results in hex - battlefield implemented - select, delete, copy and paste in inputlines - descs have a selection dialog - per bit dirty - only PE head when unknown optmagic - much x86-assembler work - pe resource refs - always-on-top child-windows implemented - some scrollbars bugs fixed - COFF support started, PE code rewired - LE virtual section memory supported (crashed on bigmem.drv) - fixed a crash in pe/image when analysis changed page layout heavily - bad ht_cached_stream bug fixed (lets hope...) - select hex visualisation problems fixed - inputline's Shift+Del works - search speed improved (caching disabled) - ht_cached_stream large reads improved - dynamic menus - listboxes merged - many bugs fixed version 0.4.1: - PE delay-imports work now - 'db 0'-bug fixed - 'push ff/ffff'-bug fixed - pressing 'c' in image edit mode now works correctly - editing dos read-only files handled - I/O error handling started - continue searches - per-viewer history - x86dis now emits explicit " ptr" on ambigous insns - rewrote ht_uviewer - everybody uses the mktag_* functions now - tag-system rewritten (binary tags, 64-bit ids) - partially rewrote htstream.cc (ht_cached_stream, ht_layer_stream) - ht_tree delete bug fixed - Ctrl-PageDown-bug in log fixed - selections implemented - bit-tag implemented - ELF support started (header) - color-transparency - MZ image (re)implemented - LE image (re)implemented (LE non-linear image mapping supported!) - new search feature: range - active and move windows different colors + help - menus implemented - color- and flags-tag implemented - sort delay-imports - full C-like expression support in all address dialogs (+,-,*,/,%,&,|,^, (subexpr)), token evaluation interceptable through hook-procs - window management (resize, move) - many bugs fixed version 0.4.0: - htstream bug fixed (seems to be a DJGPP/libc/doc? bug) - helpviewer scrollbar added - helpviewer scrollbar-bugs fixed - LE support started (header, objects, pagemap for now) - dialog-idle, analysis continues in background - radio/checkboxes implemented - statictext automatic line breaking - sort imports/exports by ord/addr/name or unsorted/like in file - search system (search for hex/ascii and C/asm strings) - new search feature: case insensitive search - search progress indicator - letter highlight and ALT-shortcut - palette system changed - tree-viewer implemented - PE-resource support started - better linux visualization support - edit in image viewer - win32 console support started - many other changes version 0.3.992: - analyser speed up - analyser xrefs work correctly on imports/exports - various analyser improvements - "undo follow" function introduced - finshed help system - wrote help - palette system restructered - htstream bug on small files fixed. - VxD support started - config file support started version 0.3.991: - linux-io - makefile - messageboxes - code speedup - introduced the new disassembler - dynamic palettes - analyser tags work - help system started - search system started - source code cleaner tool (solves tab/space, CR/CRLF problems) version 20000114 (snapshot): - The initial HT (0.3.0-0.3.9) has been completly (!) rewritten. First release of the new version. ht-2.0.22/nestruct.h0000644000175000001440000001453710615341624011161 00000000000000/* * HT Editor * nestruct.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __NESTRUCT_H_ #define __NESTRUCT_H_ #define NE_MAGIC0 'N' #define NE_MAGIC1 'E' #define NE_OS_UNKNOWN 0x0000 #define NE_OS_OS2 0x0001 #define NE_OS_WINDOWS 0x0002 #define NE_OS_DOS4 0x0003 #define NE_FLAGS_NOTAPROCESS 0x8000 /* Not a process */ #define NE_FLAGS_ERRORS 0x2000 /* Errors in image */ #define NE_FLAGS_SELFLOAD 0x0800 #define NE_FLAGS_NOTWINCOMPAT 0x0100 /* Not compatible with P.M. Windowing */ #define NE_FLAGS_WINCOMPAT 0x0200 /* Compatible with P.M. Windowing */ #define NE_FLAGS_WINAPI 0x0300 /* Uses P.M. Windowing API */ #define NE_FLAGS_FLOAT 0x0080 /* Floating-point instructions */ #define NE_FLAGS_I80386 0x0040 /* 80386 instructions */ #define NE_FLAGS_I80286 0x0020 /* 80286 instructions */ #define NE_FLAGS_I8086 0x0010 /* 8086 instructions */ #define NE_FLAGS_PROT_ONLY 0x0008 /* Runs in protected mode only */ #define NE_FLAGS_PPLI 0x0004 /* Per-Process Library Initialization */ #define NE_FLAGS_INST 0x0002 /* Instance data */ #define NE_FLAGS_SOLO 0x0001 /* Solo data */ struct NE_HEADER { uint16 magic; // Magic number byte ver; // Version number byte rev; // Revision number uint16 enttab; // Offset of Entry Table uint16 cbenttab; // Number of bytes in Entry Table uint32 crc; // Checksum of whole file uint16 flags; // Flag uint16 uint16 autodata; // Automatic data segment number uint16 heap; // Initial heap allocation uint16 stack; // Initial stack allocation uint32 csip; // Initial CS:IP setting uint32 sssp; // Initial SS:SP setting uint16 cseg; // Count of file segments uint16 cmod; // Entries in Module Reference Table uint16 cbnrestab; // Size of non-resident name table uint16 segtab; // Offset of Segment Table uint16 rsrctab; // Offset of Resource Table uint16 restab; // Offset of resident name table uint16 modtab; // Offset of Module Reference Table uint16 imptab; // Offset of Imported Names Table uint32 nrestab; // Offset of Non-resident Names Table uint16 cmovent; // Count of movable entries uint16 align; // Segment alignment shift count uint16 cres; // Count of resource segments byte os; // Target Operating system byte flagsothers; // Other .EXE flags uint16 pretthunks; // offset to return thunks uint16 psegrefbytes; // offset to segment ref. bytes uint16 swaparea; // Minimum code swap area size uint16 expver; // Expected Windows version number } PACKED; /* * segment */ struct NE_SEGMENT { uint16 offset; uint16 size; uint16 flags; uint16 minalloc; } PACKED; #define NE_DATA 0x0001 #define NE_ITERATED 0x0008 #define NE_MOVABLE 0x0010 #define NE_SHARABLE 0x0020 #define NE_PRELOAD 0x0040 #define NE_READONLY 0x0080 #define NE_HASRELOC 0x0100 #define NE_CONFORMING 0x0200 /* 2 bits priv-level */ #define NE_DISCARDABLE 0x1000 #define NE_32BIT 0x2000 #define NE_HUGE 0x4000 /* * entrypoint table */ struct NE_ENTRYPOINT_HEADER { byte entry_count; byte seg_index; } PACKED; /* 00H 1 Entry point flags Bit(s) Significance 0 0 = entry point not exported 1 = entry point exported 1 0 = entry point uses instance data 1 = entry point uses single data 2 Reserved 3Ä7 Number of stack parameter words 01H 2 Int 3FH instruction (CDH 3FH) 03H 1 Segment number of entry point 04H 2 Offset of entry point within segment */ #define NE_ENT_FLAGS_EXPORTED 0x01 #define NE_ENT_FLAGS_SINGLE_DATA 0x02 #define NE_ENT_FLAGS_PARAM_WORDS 0xf8 struct NE_ENTRYPOINT_MOVABLE { byte flags; uint16 int3f; byte seg; uint16 offset; } PACKED; /* 00H 1 Entry point flags (See above) 01H 2 Offset of entry point within segment*/ struct NE_ENTRYPOINT_FIXED { byte flags; uint16 offset; } PACKED; /* relocations */ struct NE_RELOC_HEADER { byte type; byte flags; uint16 src_ofs; } PACKED; #define NE_RF_ADD 0x04 /* Additive fixup */ #define NE_RF_RT_MASK 0x03 /* Reference type mask */ #define NE_RF_INTERNAL 0x00 /* Internal reference */ #define NE_RF_IMPORT_ORD 0x01 /* Import by ordinal */ #define NE_RF_IMPORT_NAME 0x02 /* Import by name */ #define NE_RF_OSFIXUP 0x03 /* Operating system fixup */ #define NE_RT_MASK 0x0f /* Source type mask */ #define NE_RT_OFS8 0x00 /* lo byte */ #define NE_RT_SEG16 0x02 /* 16-bit segment */ #define NE_RT_PTR32 0x03 /* 32-bit pointer */ #define NE_RT_OFS16 0x05 /* 16-bit offset */ #define NE_RT_PTR48 0x0B /* 48-bit pointer */ #define NE_RT_OFS32 0x0D /* 32-bit offset */ struct NE_RELOC_INTERNAL { byte seg; byte reserved; uint16 ofs; }; struct NE_RELOC_IMPORT { uint16 module; union { uint16 ord; uint16 name_ofs; }; }; struct NE_RELOC_FIXUP { uint16 type; uint16 reserved; }; extern byte NE_HEADER_struct[]; extern byte NE_SEGMENT_struct[]; extern byte NE_ENTRYPOINT_HEADER_struct[]; extern byte NE_ENTRYPOINT_MOVABLE_struct[]; extern byte NE_ENTRYPOINT_FIXED_struct[]; extern byte NE_RELOC_HEADER_struct[]; extern byte NE_RELOC_INTERNAL_struct[]; extern byte NE_RELOC_IMPORT_struct[]; extern byte NE_RELOC_FIXUP_struct[]; #endif /* __NESTRUCT_H_ */ ht-2.0.22/endianess.h0000755000175000001440000000303310615344716011260 00000000000000/* * HT Editor * endianess.h * * Copyright (C) 1999-2002 Stefan Weyergraf (stefan@weyergraf.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __ENDIANESS_H__ #define __ENDIANESS_H__ #include "io/types.h" // This is _NOT_ a bitmask ! #define STRUCT_ENDIAN_8 1 #define STRUCT_ENDIAN_16 2 #define STRUCT_ENDIAN_32 4 #define STRUCT_ENDIAN_64 8 // This is a bitmask. #define STRUCT_ENDIAN_HOST 128 enum Endianess { big_endian, little_endian }; void createForeignInt(void *buf, int i, int size, Endianess to_endianess); void createForeignInt64(void *buf, uint64 i, int size, Endianess to_endianess); int createHostInt(const void *buf, int size, Endianess from_endianess); uint64 createHostInt64(const void *buf, int size, Endianess from_endianess); void createHostStruct(void *buf, const uint8 *table, Endianess from_endianess); void createHostStructx(void *buf, uint bufsize, const uint8 *table, Endianess from_endianess); #endif /* __ENDIANESS_H__ */ ht-2.0.22/ilstruct.cc0000644000175000001440000000204510615341624011310 00000000000000/* * HT Editor * ilstruct.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "endianess.h" #include "ilstruct.h" byte IL_METADATA_SECTION_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_16 | STRUCT_ENDIAN_HOST, 0 }; byte IL_METADATA_SECTION_ENTRY_struct[] = { STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, STRUCT_ENDIAN_32 | STRUCT_ENDIAN_HOST, 0 }; ht-2.0.22/syntax.cc0000644000175000017500000004333212127651420010773 00000000000000/* * HT Editor * syntax.cc * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include "except.h" extern "C" { #include "regex.h" } #include "syntax.h" #include "htpal.h" bool regmatch(char *str, regex_t *preg, int *len) { // FIXME: use REG_STARTEND ? non-POSIX but could be pretty useful. regmatch_t m; int r=regexec(preg, str, 1, &m, 0); if ((r==0) && (m.rm_so==0)) { if (len) *len=m.rm_eo-m.rm_so; return true; } return false; } bool match_sorted_stringtable(char *s, uint slen, const char **strings, uint strings_count) { int a=0, b=strings_count-1; int m; while (a <= b) { m = (a+b) >> 1; uint x = strlen(strings[m]); if (slen > x) x = slen; int d = ht_strncmp(s, strings[m], x); if (d < 0) { b = m-1; } else if (d > 0) { a = m+1; } else { return true; } } return false; } /* * CLASS ht_syntax_lexer */ void ht_syntax_lexer::config_changed() { } /* * CLASS ht_lang_syntax_lexer */ #define LSTSET(state) (1<<(state)) #define SL_RULE_ANYCHAR(needstates, token)\ { needstates,\ false, LRST_ANYCHAR, NULL, 0, token } #define SL_RULE_LINEEND(needstates, state)\ { needstates,\ false, LRST_REGEX, "$", state, 0 } void ht_lang_syntax_lexer::init(syntax_lexer_rule *lr) { ht_syntax_lexer::init(); set_lexer_rules(lr); } void ht_lang_syntax_lexer::done() { free_lexer_rules(); ht_syntax_lexer::done(); } void ht_lang_syntax_lexer::free_lexer_rules() { for (int i=0; ineedstate) { if ((lr->needstate & LSTSET(*ret_state)) && (!lr->need_line_start || start_of_line)) { int l=0; bool matched=false; bool preserve_state=false; switch (lr->string_type) { case LRST_ANYCHAR: { if (buflen>0) l=1; break; } case LRST_WHITESPACE: { // if ((buflen>0) && ((byte)*buf<=32)) l=1; if ((buflen>0) && ((*buf==32) || (*buf=='\t'))) l=1; break; } case LRST_STRING: { uint sl = strlen(lr->string); if ((buflen >= sl) && (memcmp(buf, lr->string, sl)==0)) { l = sl; } break; } case LRST_STRING_EXPECT: { /* char *q = strstr(buf, lr->string); if (q) { l=q-buf+strlen(lr->string); } else { l = strlen(buf); preserve_state=true; }*/ break; } case LRST_REGEX: { #if 0 if /*(*/(strcmp(lr->string, "$")==0)/* && (buflen>0))*/ { matched=true; } else if (regmatch(buf, (regex_t*)lexer_rules_precompiled[i], &l)) { } #else if (strcmp(lr->string, "$") == 0) { matched = (buflen == 0); } else if (regmatch(buf, (regex_t*)lexer_rules_precompiled[i], &l)) { } #endif break; } case LRST_CHARSET: { if (buflen) { if (*buf && (strchr(lr->string, *buf))) l=1; } break; } case LRST_IDENTIFIER: { if (isalpha(*buf) || *buf == '_') { char *b = buf+1; while (isalnum(*b) || *b == '_') b++; l = b-buf; } break; } case LRST_DQSTRING: { if (*buf == '"') { char *b = buf+1; while (*b && (*b != '"')) b++; if (*b == '"') l = b+1-buf; } break; } case LRST_QSTRING: { if (*buf == '\'') { char *b = buf+1; while (*b && (*b != '\'')) b++; if (*b == '\'') l = b+1-buf; } break; } case LRST_EMPTY: break; } if (matched || l) { if (lr->state && !preserve_state) *ret_state=lr->state; *ret_len=l; return lr->token; } } lr++; i++; } /* error, no rule matched... */ if (buflen) { *ret_len=1; return geterrortoken(); } *ret_len=0; return 0; } void ht_lang_syntax_lexer::set_lexer_rules(syntax_lexer_rule *lr) { lexer_rules=lr; lexer_rules_count=0; while (lexer_rules[lexer_rules_count].needstate) { lexer_rules_count++; } lexer_rules_precompiled = ht_malloc(sizeof (void**) * lexer_rules_count); for (int i=0; i < lexer_rules_count; i++) { if (lexer_rules[i].string_type==LRST_REGEX) { regex_t *preg = ht_malloc(sizeof (regex_t)); /* add an anchor in front of regex */ int rl = strlen(lexer_rules[i].string)+1; char *regex = ht_malloc(1+rl); *regex='^'; memcpy(regex+1, lexer_rules[i].string, rl); if (regcomp(preg, regex, REG_EXTENDED)) throw Exception(); free(regex); lexer_rules_precompiled[i]=preg; } else { lexer_rules_precompiled[i]=NULL; } } } /* * CLASS ht_c_syntax_lexer */ /* C lexer states */ #define LEX_CST_NORMAL 1 #define LEX_CST_STRING 2 #define LEX_CST_PREPROCESS 3 #define LEX_CST_COMMENT 4 #define LEX_CST_COMMENT_EOL 5 /* C lexer tokens */ #define LEX_CTOK_ERROR 1 #define LEX_CTOK_WHITESPACE 2 #define LEX_CTOK_COMMENT 3 #define LEX_CTOK_PREPROCESS 4 #define LEX_CTOK_IDENTIFIER 5 #define LEX_CTOK_RIDENTIFIER 6 #define LEX_CTOK_NUMBER 7 #define LEX_CTOK_FNUMBER 8 #define LEX_CTOK_STRING 9 #define LEX_CTOK_CHAR 10 #define LEX_CTOK_SYMBOL 11 syntax_lexer_rule c_syntax_lexer_rules[]={ /* preprocessor directives */ { LSTSET(LEX_CST_NORMAL), true, LRST_REGEX, " *#", LEX_CST_PREPROCESS, LEX_CTOK_PREPROCESS }, SL_RULE_LINEEND(LSTSET(LEX_CST_PREPROCESS), LEX_CST_NORMAL), SL_RULE_ANYCHAR(LSTSET(LEX_CST_PREPROCESS), LEX_CTOK_PREPROCESS), /* whitespaces */ { LSTSET(LEX_CST_NORMAL), false, LRST_WHITESPACE, NULL, 0, LEX_CTOK_WHITESPACE }, /* '/ *' - '* /' multiline comments */ { LSTSET(LEX_CST_NORMAL) | LSTSET(LEX_CST_PREPROCESS), false, LRST_STRING, "/*", LEX_CST_COMMENT, LEX_CTOK_COMMENT }, { LSTSET(LEX_CST_COMMENT), false, LRST_STRING, "*/", LEX_CST_NORMAL, LEX_CTOK_COMMENT }, SL_RULE_ANYCHAR(LSTSET(LEX_CST_COMMENT), LEX_CTOK_COMMENT), /* "..." (multiline) strings */ { LSTSET(LEX_CST_NORMAL), false, LRST_STRING, "\"", LEX_CST_STRING, LEX_CTOK_STRING }, { LSTSET(LEX_CST_STRING), false, LRST_STRING, "\\\"", LEX_CST_STRING, LEX_CTOK_STRING }, { LSTSET(LEX_CST_STRING), false, LRST_STRING, "\"", LEX_CST_NORMAL, LEX_CTOK_STRING }, SL_RULE_ANYCHAR(LSTSET(LEX_CST_STRING), LEX_CTOK_STRING), /* '//' one line comments */ { LSTSET(LEX_CST_NORMAL) | LSTSET(LEX_CST_PREPROCESS), false, LRST_STRING, "//", LEX_CST_COMMENT_EOL, LEX_CTOK_COMMENT }, SL_RULE_LINEEND(LSTSET(LEX_CST_COMMENT_EOL), LEX_CST_NORMAL), SL_RULE_ANYCHAR(LSTSET(LEX_CST_COMMENT_EOL), LEX_CTOK_COMMENT), /* symbols */ { LSTSET(LEX_CST_NORMAL), false, LRST_CHARSET, "(){};,.[]!~%+-/*=<>|&^?:", 0, LEX_CTOK_SYMBOL }, /* identifiers */ { LSTSET(LEX_CST_NORMAL), false, LRST_IDENTIFIER, NULL, 0, LEX_CTOK_IDENTIFIER }, /* floats */ { LSTSET(LEX_CST_NORMAL), false, LRST_REGEX, "[0-9]+\\.[0-9]+(e[+-]?[0-9]+)?", 0, LEX_CTOK_FNUMBER }, /* numbers */ { LSTSET(LEX_CST_NORMAL), false, LRST_REGEX, "0[xX][0-9a-fA-F]+", 0, LEX_CTOK_NUMBER }, { LSTSET(LEX_CST_NORMAL), false, LRST_REGEX, "[0-9]+", 0, LEX_CTOK_NUMBER }, /* chars */ { LSTSET(LEX_CST_NORMAL), false, LRST_REGEX, "'[^'\\]'", 0, LEX_CTOK_CHAR }, { LSTSET(LEX_CST_NORMAL), false, LRST_REGEX, "'\\\\.{1,3}'", 0, LEX_CTOK_CHAR }, /**/ { 0 } }; const char *c_reserved[]= { /* types */ "bool", "char", "void", "int", "short", "long", "unsigned", "signed", "float", "double", /* consts */ "true", "false", /* statements */ "return", "if", "else", "while", "do", "goto", "asm", "switch", "case", "default", "break", "continue", "for", /* object */ "new", "delete", "this", /* declarations */ "struct", "union", "enum", "class", "template", "operator", "typedef", /* modifiers */ "public", "protected", "private", "friend", "const", "extern", "inline", "register", "static", "volatile", "virtual", /* exceptions */ "try", "catch", "throw", /* misc */ "sizeof", /**/ NULL }; #define palkey_syntax_c_default "c/default" void ht_c_syntax_lexer::init() { ht_lang_syntax_lexer::init(c_syntax_lexer_rules); c_reserved_sorted = create_sorted_stringtable(c_reserved); const char **table=c_reserved; const char **x=table; while (*x) x++; c_reserved_count=x-table; c_pal.data = NULL; c_pal.size = 0; config_changed(); } void ht_c_syntax_lexer::done() { free(c_pal.data); free(c_reserved_sorted); ht_lang_syntax_lexer::done(); } void ht_c_syntax_lexer::config_changed() { reloadpalette(); } vcp ht_c_syntax_lexer::getcolor_syntax(uint pal_index) { return getcolorv(&c_pal, pal_index); } lexer_token ht_c_syntax_lexer::geterrortoken() { return LEX_CTOK_ERROR; } lexer_state ht_c_syntax_lexer::getinitstate() { return LEX_CST_NORMAL; } const char *ht_c_syntax_lexer::getname() { return "C/C++"; } lexer_token ht_c_syntax_lexer::gettoken(void *buf, uint buflen, text_pos p, bool start_of_line, lexer_state *ret_state, uint *ret_len) { lexer_token t=ht_lang_syntax_lexer::gettoken(buf, buflen, p, start_of_line, ret_state, ret_len); if (t==LEX_CTOK_IDENTIFIER) { if (match_sorted_stringtable((char*)buf, *ret_len, c_reserved_sorted, c_reserved_count)) { t=LEX_CTOK_RIDENTIFIER; } } return t; } vcp ht_c_syntax_lexer::gettoken_color(lexer_token t) { switch (t) { case LEX_CTOK_WHITESPACE: return getcolor_syntax(palidx_syntax_whitespace); case LEX_CTOK_COMMENT: return getcolor_syntax(palidx_syntax_comment); case LEX_CTOK_PREPROCESS: return getcolor_syntax(palidx_syntax_preprocess); case LEX_CTOK_IDENTIFIER: return getcolor_syntax(palidx_syntax_identifier); case LEX_CTOK_RIDENTIFIER: return getcolor_syntax(palidx_syntax_reserved); case LEX_CTOK_NUMBER: return getcolor_syntax(palidx_syntax_intnum); case LEX_CTOK_FNUMBER: return getcolor_syntax(palidx_syntax_floatnum); case LEX_CTOK_STRING: return getcolor_syntax(palidx_syntax_string); case LEX_CTOK_CHAR: return getcolor_syntax(palidx_syntax_char); case LEX_CTOK_SYMBOL: return getcolor_syntax(palidx_syntax_symbol); } return VCP(VC_BLACK, VC_RED); } void ht_c_syntax_lexer::reloadpalette() { if (c_pal.data) { free(c_pal.data); c_pal.data = NULL; } load_pal(palclasskey_syntax, palkey_syntax_c_default, &c_pal); } #ifdef HT_HTML_SYNTAX_LEXER /* * CLASS ht_html_syntax_lexer */ #if 0 /* HTML lexer states */ #define LEX_HTMLST_NORMAL 1 #define LEX_HTMLST_TAG 2 #define LEX_HTMLST_COMMENT 3 #define LEX_HTMLST_CSS 4 #define LEX_HTMLST_SCRIPT 5 /* HTML lexer tokens */ #define LEX_HTMLTOK_ERROR 1 #define LEX_HTMLTOK_WHITESPACE 2 #define LEX_HTMLTOK_NORMAL 3 #define LEX_HTMLTOK_COMMENT 4 #define LEX_HTMLTOK_TAG 5 #define LEX_HTMLTOK_ATTRIBUTE 6 #define LEX_HTMLTOK_SYMBOL 7 #define LEX_HTMLTOK_CDATA 8 #define LEX_HTMLTOK_ENTITY 9 syntax_lexer_rule html_syntax_lexer_rules[] = { /* whitespaces */ { LSTSET(LEX_HTMLST_NORMAL), false, LRST_WHITESPACE, NULL, 0, LEX_CTOK_WHITESPACE }, /* '' multiline comments */ { LSTSET(LEX_HTMLST_NORMAL), false, LRST_STRING, "", LEX_HTMLST_NORMAL, LEX_HTMLTOK_COMMENT }, SL_RULE_ANYCHAR(LSTSET(LEX_HTMLST_COMMENT), LEX_HTMLTOK_COMMENT), /* '<' - '>' tags */ { LSTSET(LEX_HTMLST_NORMAL), false, LRST_STRING, "", LEX_HTMLST_NORMAL, LEX_HTMLTOK_TAG}, { LSTSET(LEX_HTMLST_TAG), false, LRST_STRING, "/>", LEX_HTMLST_NORMAL, LEX_HTMLTOK_TAG}, { LSTSET(LEX_HTMLST_TAG), false, LRST_WHITESPACE, NULL, 0, LEX_HTMLTOK_TAG }, { LSTSET(LEX_HTMLST_TAG), false, LRST_REGEX, "[-_A-Za-z0-9]+", 0, LEX_HTMLTOK_ATTRIBUTE }, { LSTSET(LEX_HTMLST_TAG), false, LRST_CHARSET, "=", 0, LEX_HTMLTOK_SYMBOL }, { LSTSET(LEX_HTMLST_TAG), false, LRST_DQSTRING, NULL, 0, LEX_HTMLTOK_CDATA }, { LSTSET(LEX_HTMLST_TAG), false, LRST_QSTRING, NULL, 0, LEX_HTMLTOK_CDATA }, { LSTSET(LEX_HTMLST_NORMAL), false, LRST_REGEX, "&[#A-Za-z0-9]+?;", 0, LEX_HTMLTOK_ENTITY }, SL_RULE_ANYCHAR(LSTSET(LEX_HTMLST_NORMAL), LEX_HTMLTOK_NORMAL), /**/ { 0, 0, LRST_EMPTY, false, false, 0 } }; #else /* HTML lexer states */ #define LEX_HTMLST_NORMAL 1 #define LEX_HTMLST_TAG_OPEN 2 #define LEX_HTMLST_TAG 3 #define LEX_HTMLST_COMMENT 4 #define LEX_HTMLST_CSS 5 #define LEX_HTMLST_SCRIPT 6 /* HTML lexer tokens */ #define LEX_HTMLTOK_ERROR 1 #define LEX_HTMLTOK_WHITESPACE 2 #define LEX_HTMLTOK_NORMAL 3 #define LEX_HTMLTOK_COMMENT 4 #define LEX_HTMLTOK_TAG 5 #define LEX_HTMLTOK_ATTRIBUTE 6 #define LEX_HTMLTOK_SYMBOL 7 #define LEX_HTMLTOK_CDATA 8 #define LEX_HTMLTOK_ENTITY 9 syntax_lexer_rule html_syntax_lexer_rules[] = { /* whitespaces */ { LSTSET(LEX_HTMLST_NORMAL), false, LRST_WHITESPACE, NULL, 0, LEX_CTOK_WHITESPACE }, /* '' multiline comments */ { LSTSET(LEX_HTMLST_NORMAL), false, LRST_STRING, "", LEX_HTMLST_NORMAL, LEX_HTMLTOK_COMMENT }, SL_RULE_ANYCHAR(LSTSET(LEX_HTMLST_COMMENT), LEX_HTMLTOK_COMMENT), /* '<' - '>' tags */ { LSTSET(LEX_HTMLST_NORMAL), false, LRST_STRING, "<", LEX_HTMLST_TAG_OPEN, LEX_HTMLTOK_TAG}, { LSTSET(LEX_HTMLST_TAG_OPEN), false, LRST_STRING, "/", LEX_HTMLST_TAG_OPEN, LEX_HTMLTOK_TAG}, { LSTSET(LEX_HTMLST_TAG_OPEN), false, LRST_STRING, "!", LEX_HTMLST_TAG, LEX_HTMLTOK_TAG}, { LSTSET(LEX_HTMLST_TAG_OPEN), false, LRST_REGEX, "[-_A-Za-z0-9]+", LEX_HTMLST_TAG, LEX_HTMLTOK_TAG}, { LSTSET(LEX_HTMLST_TAG), false, LRST_STRING, ">", LEX_HTMLST_NORMAL, LEX_HTMLTOK_TAG}, { LSTSET(LEX_HTMLST_TAG), false, LRST_STRING, "/>", LEX_HTMLST_NORMAL, LEX_HTMLTOK_TAG}, { LSTSET(LEX_HTMLST_TAG), false, LRST_WHITESPACE, NULL, 0, LEX_HTMLTOK_TAG }, { LSTSET(LEX_HTMLST_TAG), false, LRST_REGEX, "[-_A-Za-z0-9]+", 0, LEX_HTMLTOK_ATTRIBUTE }, { LSTSET(LEX_HTMLST_TAG), false, LRST_CHARSET, "=", 0, LEX_HTMLTOK_SYMBOL }, { LSTSET(LEX_HTMLST_TAG), false, LRST_DQSTRING, NULL, 0, LEX_HTMLTOK_CDATA }, { LSTSET(LEX_HTMLST_TAG), false, LRST_QSTRING, NULL, 0, LEX_HTMLTOK_CDATA }, { LSTSET(LEX_HTMLST_NORMAL), false, LRST_REGEX, "[^&<]", 0, LEX_HTMLTOK_NORMAL }, { LSTSET(LEX_HTMLST_NORMAL), false, LRST_REGEX, "&[#A-Za-z0-9]+?;", 0, LEX_HTMLTOK_ENTITY }, // SL_RULE_ANYCHAR(LSTSET(LEX_HTMLST_NORMAL), LEX_HTMLTOK_NORMAL), /**/ { 0 } }; #endif void ht_html_syntax_lexer::init() { ht_lang_syntax_lexer::init(html_syntax_lexer_rules); /* html_reserved_sorted=create_sorted_stringtable(html_reserved); char **table=c_reserved; char **x=table; while (*x) x++; c_reserved_count=x-table; c_pal.data = NULL; c_pal.size = 0;*/ config_changed(); } void ht_html_syntax_lexer::done() { // free(c_pal.data); // free(c_reserved_sorted); ht_lang_syntax_lexer::done(); } void ht_html_syntax_lexer::config_changed() { reloadpalette(); } vcp ht_html_syntax_lexer::getcolor_syntax(uint pal_index) { // return getcolorv(&c_pal, pal_index); return VCP(VC_LIGHT(VC_BLUE), VC_TRANSPARENT); } lexer_token ht_html_syntax_lexer::geterrortoken() { return LEX_HTMLTOK_ERROR; } lexer_state ht_html_syntax_lexer::getinitstate() { return LEX_HTMLST_NORMAL; } const char *ht_html_syntax_lexer::getname() { return "HTML"; } lexer_token ht_html_syntax_lexer::gettoken(void *buf, uint buflen, text_pos p, bool start_of_line, lexer_state *ret_state, uint *ret_len) { lexer_token t=ht_lang_syntax_lexer::gettoken(buf, buflen, p, start_of_line, ret_state, ret_len); /* if (t==LEX_CTOK_IDENTIFIER) { if (match_sorted_stringtable((char*)buf, *ret_len, c_reserved_sorted, c_reserved_count)) { t=LEX_CTOK_RIDENTIFIER; } }*/ return t; } vcp ht_html_syntax_lexer::gettoken_color(lexer_token t) { switch (t) { case LEX_HTMLTOK_ERROR: return VCP(VC_BLACK, VC_RED); case LEX_HTMLTOK_WHITESPACE: return VCP(VC_LIGHT(VC_YELLOW), VC_TRANSPARENT); case LEX_HTMLTOK_NORMAL: return VCP(VC_LIGHT(VC_YELLOW), VC_TRANSPARENT); case LEX_HTMLTOK_COMMENT: return VCP(VC_WHITE, VC_TRANSPARENT); case LEX_HTMLTOK_TAG: return VCP(VC_LIGHT(VC_GREEN), VC_TRANSPARENT); case LEX_HTMLTOK_ATTRIBUTE: return VCP(VC_GREEN, VC_TRANSPARENT); case LEX_HTMLTOK_SYMBOL: return VCP(VC_LIGHT(VC_WHITE), VC_TRANSPARENT); case LEX_HTMLTOK_CDATA: return VCP(VC_LIGHT(VC_MAGENTA), VC_TRANSPARENT); case LEX_HTMLTOK_ENTITY: return VCP(VC_LIGHT(VC_WHITE), VC_TRANSPARENT); } return VCP(VC_BLACK, VC_RED); } void ht_html_syntax_lexer::reloadpalette() { /* if (c_pal.data) { free(c_pal.data); c_pal.data = NULL; } load_pal(palclasskey_syntax, palkey_syntax_c_default, &c_pal);*/ } #endif /* * sorted stringtable */ int qsort_stringlist(const void *e1, const void *e2) { return strcmp(*(char **)e1, *(char **)e2); } const char **create_sorted_stringtable(const char **table) { const char **x=table; while (*x) x++; const char **stab = ht_malloc(sizeof (char*) * (x-table+1)); memcpy(stab, table, sizeof (char*) * (x-table+1)); qsort(stab, x-table, sizeof(char*), qsort_stringlist); return stab; } ht-2.0.22/htobj.h0000644000175000001440000002675710615341623010426 00000000000000/* * HT Editor * htobj.h * * Copyright (C) 1999-2002 Stefan Weyergraf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef __HTOBJ_H__ #define __HTOBJ_H__ class ht_view; class ht_group; #include "io/types.h" #include "io/display.h" #include "data.h" struct palette { uint size; vcp *data; }; /* messages (like in "MESS of AGES") */ #define msg_message 0x00000000 #define HT_MESSAGE(m) (msg_message+(m)) #define msg_empty HT_MESSAGE(0) #define msg_retval HT_MESSAGE(1) #define msg_draw HT_MESSAGE(2) #define msg_keypressed HT_MESSAGE(3) #define msg_kill HT_MESSAGE(4) #define msg_complete_init HT_MESSAGE(5) #define msg_funcexec HT_MESSAGE(6) #define msg_funcquery HT_MESSAGE(7) #define msg_menucapquery HT_MESSAGE(8) #define msg_menuquery HT_MESSAGE(9) #define msg_button_pressed HT_MESSAGE(10) #define msg_dirtyview HT_MESSAGE(11) #define msg_config_changed HT_MESSAGE(12) #define msg_accept_close HT_MESSAGE(13) #define msg_file_changed HT_MESSAGE(14) #define msg_get_scrollinfo HT_MESSAGE(15) #define msg_get_pindicator HT_MESSAGE(16) #define msg_get_analyser HT_MESSAGE(17) #define msg_set_analyser HT_MESSAGE(18) // (Analyser *) #define msg_postinit HT_MESSAGE(19) #define msg_contextmenuquery HT_MESSAGE(20) #define msg_project_changed HT_MESSAGE(21) #define msg_vstate_save HT_MESSAGE(22) // (Object *data, ht_view *) #define msg_vstate_restore HT_MESSAGE(23) // (Object *data) #define msg_goto_offset HT_MESSAGE(24) // (FileOfs ofs) #define msg_filesize_changed HT_MESSAGE(100) #define msg_log_changed HT_MESSAGE(101) #define gsi_hscrollbar 1 #define gsi_vscrollbar 2 struct gsi_scrollbar_t { int pstart; int psize; }; /* message types */ #define mt_empty 0 #define mt_broadcast 1 #define mt_preprocess 2 #define mt_postprocess 3 /* * CLASS ht_view */ /* options */ #define VO_OWNBUFFER 1 #define VO_BROWSABLE 2 #define VO_SELECTABLE 4 #define VO_SELBOUND 8 #define VO_PREPROCESS 16 #define VO_POSTPROCESS 32 #define VO_MOVE 64 #define VO_RESIZE 128 #define VO_FORMAT_VIEW 256 #define VO_TRANSPARENT_CHARS 512 /* grow modes */ #define VIEW_DEBUG_NAME(name) ht_view::view_debug_name=name; #define GMV_TOP 0 #define GMV_BOTTOM 1 #define GMV_FIT 2 #define GMH_LEFT 0 #define GMH_RIGHT 1 #define GMH_FIT 2 #define GET_GM_H(gm) ((gm)>>16) #define GET_GM_V(gm) ((gm)&0xffff) #define MK_GM(gmh, gmv) ((gmv) | ((gmh)<<16)) void clearmsg(htmsg *msg); class ht_view: public Object { protected: bool view_is_dirty; void cleanview(); virtual const char *defaultpalette(); virtual const char *defaultpaletteclass(); virtual void reloadpalette(); public: bool focused; bool enabled; ht_group *group; int options; char *desc; int browse_idx; Display *buf; ht_view *prev, *next; Bounds size; Bounds vsize; /* visual Bounds */ uint growmode; uint g_hdist, g_vdist; palette pal; const char *pal_class; const char *pal_name; /*debug:*/const char *view_debug_name; ht_view() {} ht_view(BuildCtorArg&a): Object(a) {}; void init(Bounds *b, int options, const char *desc); virtual void done(); /* new */ virtual int aclone(); /* int buf_lprint(int x, int y, int c, int l, const char *text, Codepage cp = CP_DEVICE); int buf_lprintw(int x, int y, int c, int l, const AbstractChar *text, Codepage cp = CP_DEVICE); int buf_print(int x, int y, int c, const char *text, Codepage cp = CP_DEVICE); void buf_printchar(int x, int y, int c, int ch, Codepage cp = CP_DEVICE); int buf_printf(int x, int y, int c, Codepage cp, const char *format, ...); int buf_printw(int x, int y, int c, const AbstractChar *text, Codepage cp = CP_DEVICE); */ virtual int childcount() const; void clear(int color); virtual void clipbounds(Bounds *b); virtual void config_changed(); virtual int countselectables(); void databuf_free(void *handle); void *databuf_get(void *buf, int bufsize); void databuf_set(void *buf, int bufsize); virtual int datasize(); void dirtyview(); virtual void disable(); void disable_buffering(); virtual void draw(); virtual void enable(); void enable_buffering(); virtual int enum_start(); virtual ht_view *enum_next(int *handle); bool exposed(); void fill(int x, int y, int w, int h, int c, char chr, Codepage cp = CP_DEVICE); virtual bool focus(ht_view *view); void getbounds(Bounds *b); virtual void getminbounds(int *width, int *height); vcp getcolor(uint index); virtual void getdata(ObjectStream &s); virtual ht_view *getfirstchild(); virtual uint getnumber(); const char *getpalette(); virtual ht_view *getselected(); virtual void handlemsg(htmsg *msg); void hidecursor(); int isviewdirty(); virtual int isaclone(ht_view *view); virtual void load(ObjectStream &s); virtual void move(int rx, int ry); virtual ObjectID getObjectID() const; bool pointvisible(int x, int y); virtual void receivefocus(); virtual void redraw(); void relocate_to(ht_view *view); virtual void resize(int rw, int rh); virtual void releasefocus(); virtual int select(ht_view *view); virtual void selectfirst(); virtual void selectlast(); void sendmsg(htmsg *msg); void sendmsg(int msg, int data1=0, int data2=0); void sendmsg(int msg, void *data1, void *data2=0); void setbounds(Bounds *b); void setvisualbounds(Bounds *b); void setcursor(int x, int y, CursorMode c=CURSOR_NORMAL); virtual void setdata(ObjectStream &s); virtual void setgroup(ht_group *group); virtual void setnumber(uint number); void setoptions(int options); virtual void setpalette(const char *pal_name); void setpalettefull(const char *pal_name, const char *pal_class); virtual void store(ObjectStream &s) const; void unrelocate_to(ht_view *view); }; /* * Easier use of data buffers: */ class ViewDataBuf: public Object { void *mBuf; ht_view *mView; public: ViewDataBuf(ht_view *view, void *buf, int bufsize) : mBuf(view->databuf_get(buf, bufsize)), mView(view) { } virtual ~ViewDataBuf() { mView->databuf_free(mBuf); } }; class ht_dialog_widget: public ht_view { public: void getminbounds(int *width, int *height); }; /* * CLASS ht_group */ class ht_group: public ht_view { protected: int view_count; public: ht_view *first, *current, *last; void *shared_data; ht_group() {} ht_group(BuildCtorArg&a): ht_view(a) {}; void init(Bounds *b, int options, const char *desc); virtual void done(); /* overwritten */ virtual int childcount() const; virtual int countselectables(); virtual int datasize(); virtual int enum_start(); virtual ht_view *enum_next(int *handle); virtual bool focus(ht_view *view); virtual void getdata(ObjectStream &s); virtual ht_view *getfirstchild(); virtual void getminbounds(int *width, int *height); virtual ht_view *getselected(); virtual void handlemsg(htmsg *msg); virtual int isaclone(ht_view *view); int isviewdirty(); virtual void load(ObjectStream &s); virtual void move(int x, int y); virtual ObjectID getObjectID() const; void putontop(ht_view *view); virtual void receivefocus(); virtual void resize(int rw, int rh); virtual void releasefocus(); virtual int select(ht_view *view); virtual void selectfirst(); virtual void selectlast(); virtual void setdata(ObjectStream &s); virtual void setpalette(const char *pal_name); virtual void store(ObjectStream &s) const; /* new */ virtual void reorder_view(ht_view *v, int rx, int ry); void remove(ht_view *view); virtual void insert(ht_view *view); bool focusnext(); bool focusprev(); ht_view *get_by_browse_idx(int i); }; /* * CLASS ht_xgroup */ class ht_xgroup: public ht_group { public: ht_xgroup() {} ht_xgroup(BuildCtorArg&a): ht_group(a) {}; void init(Bounds *b, int options, const char *desc); virtual void done(); /* overwritten */ virtual int countselectables(); virtual void handlemsg(htmsg *msg); virtual int isaclone(ht_view *view); virtual void load(ObjectStream &s); virtual ObjectID getObjectID() const; virtual void redraw(); virtual void selectfirst(); virtual void selectlast(); virtual void store(ObjectStream &s) const; }; /* * CLASS ht_scrollbar */ class ht_scrollbar: public ht_view { protected: int pstart, psize; palette *gpal; bool isvertical; public: ht_scrollbar() {} ht_scrollbar(BuildCtorArg&a): ht_view(a) {}; void init(Bounds *b, palette *gpal, bool isvertical); virtual void done(); /* overwritten */ virtual void enable(); virtual void disable(); virtual void draw(); virtual ObjectID getObjectID() const; virtual void getminbounds(int *width, int *height); /* new */ virtual void setpos(int pstart, int psize); }; /* * CLASS ht_text */ class ht_text: public ht_dialog_widget { public: /* new */ virtual void settext(const char *text); }; /* * CLASS ht_frame */ #define FS_KILLER 1 #define FS_TITLE 2 #define FS_NUMBER 4 #define FS_RESIZE 8 #define FS_MOVE 16 #define FS_THICK 32 #define FST_FOCUSED 0 #define FST_UNFOCUSED 1 #define FST_MOVE 2 #define FST_RESIZE 3 class ht_frame: public ht_text { protected: uint number; uint style; uint framestate; /* new */ virtual vcp getcurcol_normal(); virtual vcp getcurcol_killer(); public: void init(Bounds *b, const char *desc, uint style, uint number=0); virtual void done(); /* overwritten */ virtual void draw(); virtual uint getnumber(); virtual ObjectID getObjectID() const; virtual void setnumber(uint number); virtual void settext(const char *text); /* new */ uint getstyle(); void setframestate(uint framestate); void setstyle(uint style); }; /* * CLASS ht_window */ #define WAC_NORMAL 0 #define WAC_MOVE 1 #define WAC_RESIZE 2 class ht_window: public ht_group { protected: ht_frame *frame; ht_scrollbar *hscrollbar; ht_scrollbar *vscrollbar; ht_text *pindicator; uint number; int action_state; bool next_action_state(); public: ht_window() {} ht_window(BuildCtorArg&a): ht_group(a) {}; void init(Bounds *b, const char *desc, uint framestyle, uint number=0); virtual void done(); /* overwritten */ virtual void draw(); virtual uint getnumber(); virtual void handlemsg(htmsg *msg); virtual void insert(ht_view *view); virtual void load(ObjectStream &s); virtual ObjectID getObjectID() const; virtual void receivefocus(); virtual void releasefocus(); virtual void redraw(); virtual void setnumber(uint number); virtual void store(ObjectStream &s) const; /* new */ void getclientarea(Bounds *b); ht_frame *getframe(); void setframe(ht_frame *frame); void sethscrollbar(ht_scrollbar *scrollbar); void setpindicator(ht_text *pindicator); void settitle(char *title); void setvscrollbar(ht_scrollbar *scrollbar); }; bool scrollbar_pos(sint64 start, sint64 size, sint64 all, int *pstart, int *psize); /* * CLASS ht_hbar */ class ht_hbar: public ht_view { public: /* overwritten */ virtual void draw(); }; /* * CLASS ht_vbar */ class ht_vbar: public ht_view { public: /* overwritten */ virtual void draw(); }; /* * INIT */ bool init_obj(); /* * DONE */ void done_obj(); #endif /* !__HTOBJ_H__ */