void debug() { Logger::getInstance()->info(0,"[Debug] Magic %c%c%c%c and packet length=%d\n",_buffer[0],_buffer[1],_buffer[2],_buffer[3],_length); if(getMagic() == UDPFILEMAGICBEGIN) { UDPTSPacketBegin* begin = (UDPTSPacketBegin*)_buffer; const unsigned char* out = (unsigned char*)begin->md5; Logger::getInstance()->info(0,"[Debug] ---Debug Begin----\n"); Logger::getInstance()->info(0,"[Debug] recv file package begin\n"); Logger::getInstance()->info(0,"[Debug] packet count=%d\n",begin->packet_count); Logger::getInstance()->info(0,"[Debug] md5=%X%X%X%X%X%X%X%X%X%X%X%X%X%X%X%X\n",out[0],out[1],out[2],out[3] ,out[4],out[5],out[6],out[7] ,out[8],out[9],out[10],out[11] ,out[12],out[13],out[14],out[15]); Logger::getInstance()->info(0,"[Debug] recv filename=%s\n",begin->filename); Logger::getInstance()->info(0,"[Debug] ---end---\n"); }else if(getMagic() == UDPFILEMAGICLOOP) { UDPTSPacket* packet = (UDPTSPacket*)_buffer; Logger::getInstance()->info(0,"[Debug] ---Debug loop----\n"); Logger::getInstance()->info(0,"[Debug] recv file package loop\n"); Logger::getInstance()->info(0,"[Debug] packetid=%d\n",packet->packetid); Logger::getInstance()->info(0,"[Debug] filepos=%d\n",packet->filepos); Logger::getInstance()->info(0,"[Debug] packet length=%d\n",packet->pklen); Logger::getInstance()->info(0,"[Debug] packet filename=%s\n",packet->filename); Logger::getInstance()->info(0,"[Debug] ---end---\n"); }else{ Logger::getInstance()->error("[UDPFileTransfer] recv error packet\n"); } }
unsigned short LoadPGM( FILE * fi, Image * img ) { char magic[3]; getMagic( fi, magic, sizeof(magic) ); if ( !magic[0] ) return 0; img->magic[0] = magic[0]; img->magic[1] = magic[1]; char last; getComments( fi, img, &last ); char width[100]; getWidth( fi, width, sizeof(width), last ); if ( !atoi(width) ) return 0; img->width = atoi(width); char height[100]; getHeight( fi, height, sizeof(height) ); if ( !atoi(height) ) return 0; img->height = atoi(height); char depth[100]; getDepth( fi, depth, sizeof(depth) ); if ( !atoi(depth) ) return 0; img->depth = atoi(depth); getData( fi, magic, img ); return 1; };
const char* getTsPacketName() { if(getMagic() == UDPFILEMAGICBEGIN)return NULL; UDPTSPacket* packet = (UDPTSPacket*)_buffer; return packet->filename; }
int Cleric::getDamage() { int magic_dealt = getMagic(); int damage_dealt = magic_dealt; return damage_dealt; }
Magic* Save::getRoleLearnedMagic(Role* r, int i) { if (i < 0 || i >= ROLE_MAGIC_COUNT) { return nullptr; } return getMagic(r->MagicID[i]); }
void check(PUP::dataType t,int n) const { compare("magic number", "you unpacked more than you packed, or the values were corrupted during transport", getMagic(),pupMagic); compare("data type", "the pack and unpack paths do not match up", getType(),t); compare("length", "you may have forgotten to pup the array length", getLength(),n); }
int module_start( SceSize args, void *argp ) { int fw = initPatches(); sceIoAssign("ms0:", "msstor0p1:", "fatms0:", IOASSIGN_RDWR, NULL, 0); log( "Firmware Version: %08x\n", fw ); cxmb_magic = getMagic(); if ( cxmb_magic == 0 ) { log( "Not supported firmware version!\n" ); } log( "CXMB Magic: %08x\n", cxmb_magic ); initUtils(); install_cxmb(); int thid = sceKernelCreateThread("cxmb_thread", main_thread, 47, 0x400, 0x00100001, NULL); if( thid >= 0 ) sceKernelStartThread(thid, 0, 0); return 0; }
static ParseResult _reparse(const char* fn, const std::string& cache_fn, AST_Module*& module) { FILE* cache_fp = fopen(cache_fn.c_str(), "w"); if (!cache_fp) return ParseResult::PYC_UNWRITABLE; fwrite(getMagic(), 1, MAGIC_STRING_LENGTH, cache_fp); int checksum_start = ftell(cache_fp); int bytes_written = -1; // Currently just use the length as the checksum static_assert(sizeof(bytes_written) >= CHECKSUM_LENGTH, ""); fwrite(&bytes_written, 1, CHECKSUM_LENGTH, cache_fp); bytes_written = 0; if (ENABLE_PYPA_PARSER) { module = pypa_parse(fn); if (!module) return ParseResult::FAILURE; bytes_written += serializeAST(module, cache_fp); } else { FILE* parser = popen(getParserCommandLine(fn).c_str(), "r"); char buf[80]; while (true) { int nread = fread(buf, 1, 80, parser); if (nread == 0) break; bytes_written += nread; fwrite(buf, 1, nread, cache_fp); } int code = pclose(parser); assert(code == 0); } fseek(cache_fp, checksum_start, SEEK_SET); fwrite(&bytes_written, 1, CHECKSUM_LENGTH, cache_fp); fclose(cache_fp); return ParseResult::SUCCESS; }
VKRecord::VKRecord(RegistryByteBuffer * buf, uint32_t offset) : Record(buf, offset) { if (!(getMagic() == MAGIC)) { throw RegistryParseException("VKRecord magic value not found."); } }
bool Archive::Header::isArchive() const { return memcmp(magic_, getMagic(), kMagicStringLength) == 0; }
Archive::Header::Header() : major_version_(kCurMajorVersion), minor_version_(kCurMinorVersion) { memcpy(magic_, getMagic(), kMagicStringLength); }
IndexFile::IndexFileHeader::IndexFileHeader() : numStreams(0) { memcpy(magic, getMagic().c_str(), sizeof(magic)); }
// Parsing the file is somewhat expensive since we have to shell out to cpython; // it's not a huge deal right now, but this caching version can significantly cut down // on the startup time (40ms -> 10ms). AST_Module* caching_parse_file(const char* fn) { STAT_TIMER(t0, "us_timer_caching_parse_file"); static StatCounter us_parsing("us_parsing"); Timer _t("parsing"); _t.setExitCallback([](uint64_t t) { us_parsing.log(t); }); int code; std::string cache_fn = std::string(fn) + "c"; struct stat source_stat, cache_stat; code = stat(fn, &source_stat); assert(code == 0); code = stat(cache_fn.c_str(), &cache_stat); if (code != 0 || cache_stat.st_mtime < source_stat.st_mtime || (cache_stat.st_mtime == source_stat.st_mtime && cache_stat.st_mtim.tv_nsec < source_stat.st_mtim.tv_nsec)) { AST_Module* mod = 0; auto result = _reparse(fn, cache_fn, mod); if (mod) return mod; if (result == ParseResult::FAILURE) return NULL; if (result == ParseResult::PYC_UNWRITABLE) return parse_file(fn); code = stat(cache_fn.c_str(), &cache_stat); assert(code == 0); } FILE* fp = fopen(cache_fn.c_str(), "r"); assert(fp); while (true) { bool good = true; if (good) { char buf[MAGIC_STRING_LENGTH]; int read = fread(buf, 1, MAGIC_STRING_LENGTH, fp); if (read != MAGIC_STRING_LENGTH || strncmp(buf, getMagic(), MAGIC_STRING_LENGTH) != 0) { if (VERBOSITY()) { printf("Warning: corrupt or non-Pyston .pyc file found; ignoring\n"); } good = false; } } if (good) { int length = 0; fseek(fp, MAGIC_STRING_LENGTH, SEEK_SET); static_assert(sizeof(length) >= CHECKSUM_LENGTH, ""); int read = fread(&length, 1, CHECKSUM_LENGTH, fp); int expected_total_length = MAGIC_STRING_LENGTH + CHECKSUM_LENGTH + length; if (read != CHECKSUM_LENGTH || expected_total_length != cache_stat.st_size) { if (VERBOSITY()) { printf("Warning: truncated .pyc file found; ignoring\n"); } good = false; } } if (!good) { fclose(fp); AST_Module* mod = 0; auto result = _reparse(fn, cache_fn, mod); if (mod) return mod; if (result == ParseResult::FAILURE) return NULL; if (result == ParseResult::PYC_UNWRITABLE) return parse_file(fn); code = stat(cache_fn.c_str(), &cache_stat); assert(code == 0); fp = fopen(cache_fn.c_str(), "r"); assert(fp); } else { break; } } BufferedReader* reader = new BufferedReader(fp); AST* rtn = readASTMisc(reader); reader->fill(); assert(reader->bytesBuffered() == 0); delete reader; fclose(fp); assert(rtn->type == AST_TYPE::Module); return ast_cast<AST_Module>(rtn); }
Cleric::Cleric(std::string name, int maxHP, int strength, int speed, int magic): Fighter(name, maxHP, strength, speed, magic), max_mana(getMagic() * MANA_MULTIPLIER), mana(max_mana) { }