bool XAP_Dictionary::save(void) { if (!m_bDirty) return true; if (!_openFile("w")) return false; UT_GenericVector<UT_UCSChar *> * pVec = m_hashWords.enumerate(); UT_ASSERT(pVec); UT_uint32 size = pVec->size(); for (UT_uint32 i = 0; i < size; i++) { UT_UCSChar * pWord = pVec->getNthItem(i); _outputUTF8(pWord, UT_UCS4_strlen(pWord)); _writeBytes(reinterpret_cast<const UT_Byte *>("\n")); } _closeFile(); delete pVec; m_bDirty = false; return true; }
bool XAP_Dictionary::_writeBytes(const UT_Byte * sz) { UT_ASSERT(m_fp); UT_ASSERT(sz); int length = strlen(reinterpret_cast<const char *>(sz)); UT_ASSERT(length); return (_writeBytes(sz,length)==static_cast<UT_uint32>(length)); }
void XAP_Dictionary::_outputUTF8(const UT_UCSChar * data, UT_uint32 length) { UT_String buf; const UT_UCSChar * pData; for (pData = data; (pData<data+length); /**/) { if (*pData > 0x007f) { gchar outbuf[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; g_unichar_to_utf8(*pData++, outbuf); buf += outbuf; } else { buf += (char)*pData++; } } _writeBytes(reinterpret_cast<const UT_Byte *>(buf.c_str()),buf.size()); }
void aADD_EAX_iIMM( int imm ) { _writeBytes(0x05); _writeInt(imm); }
void aMOV_pESIoIMM_uIMM( int off, unsigned int imm ) { _writeBytes(0xC7,0x86); _writeInt(off); _writeUint(imm); }
void aMOV_pESIoIMM_EAX( int off ) { _writeBytes(0x89,0x86); _writeInt(off); }
void aMOV_pEAX_ECX( ) { _writeBytes(0x89,0x08); }
void aMOV_ECX_pESIoIMM( int off ) { _writeBytes(0x8b,0x8e); _writeInt(off); }
void aMOV_EAX_uIMM( unsigned int imm ) { _writeBytes(0xB8); _writeUint(imm); }
void aPUSH_EAX( ) { _writeBytes(0x50); };
void aCALL_IMM( unsigned int imm ) { _writeBytes(0xE8); _writeInt((int)imm-(int)_cursor-4); }
void aJMP_IMM( unsigned int imm ) { _writeBytes(0xE9); _writeInt((int)imm-(int)_cursor-4); }
void aRETN( ) { _writeBytes(0xC3); };
void aINT3( ) { _writeBytes(0xCC); };
void aNOP( ) { _writeBytes(0x90); };
void aADD_EAX_pESIoIMM( int off ) { _writeBytes(0x03,0x86); _writeInt(off); }
void aADD_pESIoIMM_iIMM( int off, int imm ) { _writeBytes(0x81,0x86); _writeInt(off); _writeInt(imm); }
void aMOV_EAX_ECX( ) { _writeBytes(0x89,0xc1); }