void CL_CSSDocument_Impl::load(const CL_String &filename, const CL_VirtualDirectory &directory) { CL_String path = CL_PathHelp::get_fullpath(filename, CL_PathHelp::path_type_file); // Load document into a buffer: CL_IODevice input = directory.open_file_read(filename); int size = input.get_size(); if (size < 0) throw CL_Exception("IODevice does not support get_size()"); CL_DataBuffer data(size); int bytes_read = input.read(data.get_data(), data.get_size()); data.set_size(bytes_read); // Start parsing: unsigned char *data_ptr = (unsigned char *) data.get_data(); whitespace_comments(data_ptr, bytes_read); int pos = 0; while (pos < bytes_read) { unsigned char ch = data_ptr[pos]; switch (ch) { case ' ': case '\t': case '\r': case '\n': pos++; break; case '@': // import pos = load_import(data_ptr, pos, bytes_read, directory, path); break; default: // ruleset pos = load_ruleset(data_ptr, pos, bytes_read); break; } } }
void CL_CSSDocument_Impl::load(const CL_StringRef &path, CL_IODevice &input) { // Load document into a buffer: int size = input.get_size(); if (size < 0) throw CL_Exception("IODevice does not support get_size()"); CL_DataBuffer data(size); int bytes_read = input.read(data.get_data(), data.get_size()); data.set_size(bytes_read); // Start parsing: unsigned char *data_ptr = (unsigned char *) data.get_data(); whitespace_comments(data_ptr, bytes_read); int pos = 0; while (pos < bytes_read) { unsigned char ch = data_ptr[pos]; switch (ch) { case ' ': case '\t': case '\r': case '\n': pos++; break; case '@': // import pos = load_import(data_ptr, pos, bytes_read, path); break; default: // ruleset pos = load_ruleset(data_ptr, pos, bytes_read); break; } } }
uint STDCALL ge_load( pbuf in ) { pubyte cur, end, ptemp; uint size; pgehead phead = ( pgehead )buf_ptr( in ); // Проверка заголовка и целостности // Сравниваем с 'GE' с двумя нулями на конце if ( *( puint )phead != GE_STRING )//0x00004547 ) msg( MNotGE | MSG_EXIT ); if ( phead->crc != crc( ( pubyte )phead + 12, phead->size - 12, 0xFFFFFFFF )) msg( MCrcGE | MSG_EXIT ); if ( phead->vermajor != GEVER_MAJOR || phead->verminor > GEVER_MINOR ) msg( MVerGE | MSG_EXIT ); _vm.loadmode = VMLOAD_GE; _vm.icnv = arr_count( &_vm.objtbl ) - KERNEL_COUNT; // print("icnv=%i\n", _vm.icnv ); cur = ( pubyte )phead + phead->headsize; end = ( pubyte )phead + phead->size; while ( cur < end ) { ptemp = cur + 5; // type + flag _vm.ipack = ( *( puint )( cur + 1 )) & GHCOM_PACK ? 1 : 0; size = load_bwd( &ptemp ); ptemp = cur; // print("size=%i type=%i flag = %x\n", size, *cur, *( puint )( cur + 1 ) ); switch ( *cur ) { case OVM_NONE: load_none(); break; case OVM_BYTECODE: load_bytecode( &cur, VMLOAD_GE ); break; case OVM_EXFUNC: load_exfunc( &cur, 0 ); _vm.loadmode = VMLOAD_GE; break; case OVM_TYPE: load_type( &cur ); break; case OVM_GLOBAL: load_global( &cur ); break; case OVM_DEFINE: load_define( &cur ); break; case OVM_IMPORT: load_import( &cur ); break; case OVM_RESOURCE: load_resource( &cur ); break; case OVM_ALIAS: load_alias( &cur ); break; default: msg( MUnkGE | MSG_DVAL, cur - ( pubyte )phead ); } cur = ptemp + size; } _vm.loadmode = VMLOAD_G; _vm.icnv = 0; return 1; }