bool uninitializeCache() { void *threadResult; bool res = true; // Stop the cache controller thread _stopCacheControllerThread = true; _work++; if (pthread_join(_cacheThread, &threadResult)) { ERRORMSG(_("An error occurred while waiting the end of the cache " "controller thread")); res = false; } // Check if all pages has been read. Otherwise free them for (unsigned long i=0; i < _maxPagesInTable; i++) { if (_pages[i]) { ERRORMSG(_("Cache: page %lu hasn't be used!"), i+1); delete _pages[i]->page(); delete _pages[i]; } } delete[] _pages; return res; }
bool CacheEntry::restoreIntoMemory() { int fd; if (!_tempFile) { ERRORMSG(_("Trying to restore a page instance into memory which is " "aready into memory")); return false; } // Open the swap file if ((fd = open(_tempFile, O_RDONLY)) == -1) { ERRORMSG(_("Cannot restore page into memory (%i)"), errno); return false; } // Restore the instance if (!(_page = Page::restoreIntoMemory(fd))) { ERRORMSG(_("Cannot restore page into memory")); return false; } // Destroy the swap file close(fd); unlink(_tempFile); delete[] _tempFile; _tempFile = NULL; DEBUGMSG(_("Page %lu restored into memory"), _page->pageNr()); return true; }
static void writebits(FILE *file,unsigned int value,int bits) { if (bits<0 || bits>32) ERRORMSG(); if (bits==0) return; value&=DDS_shiftl(1,bits)-1; if (DDS_bufsize+bits<32) { DDS_buffer=DDS_shiftl(DDS_buffer,bits)|value; DDS_bufsize+=bits; } else { DDS_buffer=DDS_shiftl(DDS_buffer,32-DDS_bufsize); DDS_bufsize+=bits-32; DDS_buffer|=DDS_shiftr(value,DDS_bufsize); if (DDS_ISINTEL) DDS_swapuint(&DDS_buffer); if (fwrite(&DDS_buffer,4,1,file)!=1) ERRORMSG(); DDS_buffer=value&(DDS_shiftl(1,DDS_bufsize)-1); } DDS_bitcnt+=bits; }
int GTO2Slater::parse(const char* fname) { // build an XML tree from a the file; xmlDocPtr m_doc = xmlParseFile(fname); if (m_doc == NULL) { ERRORMSG("File " << fname << " is invalid") xmlFreeDoc(m_doc); return 1; } // Check the document is of the right kind xmlNodePtr cur = xmlDocGetRootElement(m_doc); if (cur == NULL) { ERRORMSG("Empty document"); xmlFreeDoc(m_doc); return 1; } xmlXPathContextPtr m_context = xmlXPathNewContext(m_doc); xmlXPathObjectPtr result = xmlXPathEvalExpression((const xmlChar*)"//atomicBasisSet",m_context); if(!xmlXPathNodeSetIsEmpty(result->nodesetval)) { for(int ic=0; ic<result->nodesetval->nodeNr; ic++) { cout << "Going to optimize" << endl; if(put(result->nodesetval->nodeTab[ic])) { optimize(); } } } xmlXPathFreeObject(result); return 1; }
// swap byte ordering between MSB and LSB void MiniDatabuf::swapbytes() { unsigned int i,b; unsigned char *ptr,tmp; if (type==0 || (type>=3 && type<=6)) return; if (type==1) b=2; else if (type==2) b=4; else ERRORMSG(); if (bytes==0 || bytes%b!=0) ERRORMSG(); ptr=(unsigned char *)data+bytes; while (ptr!=data) { ptr-=b; for (i=0; i<(b>>1); i++) { tmp=ptr[i]; ptr[i]=ptr[b-1-i]; ptr[b-1-i]=tmp; } } }
// write an optionally compressed PNM image void writePNMimage(const char *filename,unsigned const char *image,unsigned int width,unsigned int height,unsigned int components,int dds) { char str[DDS_MAXSTR]; unsigned char *data; if (width<1 || height<1) ERRORMSG(); switch (components) { case 1: snprintf(str,DDS_MAXSTR,"P5\n%d %d\n255\n",width,height); break; case 2: snprintf(str,DDS_MAXSTR,"P5\n%d %d\n32767\n",width,height); break; case 3: snprintf(str,DDS_MAXSTR,"P6\n%d %d\n255\n",width,height); break; default: ERRORMSG(); } if ((data=(unsigned char *)malloc(strlen(str)+width*height*components))==NULL) ERRORMSG(); memcpy(data,str,strlen(str)); memcpy(data+strlen(str),image,width*height*components); if (DDS_ISINTEL) if (components==2) swapshort(data+strlen(str),width*height); if (dds!=0) writeDDSfile(filename,data,strlen(str)+width*height*components,components,width); else writeRAWfile(filename,data,strlen(str)+width*height*components); }
bool CheckWork(CBlock* pblock, CWallet& wallet) { // uint256 hash = pblock->GetHash(); // uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); // // if (hash > hashTarget) // return false; //// debug print // LogPrint("INFO","proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex(), hashTarget.GetHex()); pblock->print(*pAccountViewTip); // LogPrint("INFO","generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue)); // Found a solution { LOCK(cs_main); if (pblock->GetHashPrevBlock() != chainActive.Tip()->GetBlockHash()) return ERRORMSG("HonghuoMiner : generated block is stale"); // Remove key from key pool // reservekey.KeepKey(); // Track how many getdata requests this block gets // { // LOCK(wallet.cs_wallet); // wallet.mapRequestCount[pblock->GetHash()] = 0; // } // Process this block the same as if we had received it from another node CValidationState state; if (!ProcessBlock(state, NULL, pblock)) return ERRORMSG("HonghuoMiner : ProcessBlock, block not accepted"); } return true; }
/**file main.cpp *@brief a main function for QMC simulation. *Actual works are done by QMCApps and its derived classe. *For other simulations, one can derive a class from QMCApps, similarly to MolecuApps. * *Only requirements are the constructor and init function to initialize. */ int main(int argc, char **argv) { OHMMS::Controller->initialize(argc,argv); OhmmsInfo welcome(argc,argv,OHMMS::Controller->mycontext()); ohmmsqmc::MolecuApps qmc(argc,argv); if(argc>1) { // build an XML tree from a the file; xmlDocPtr m_doc = xmlParseFile(argv[1]); if (m_doc == NULL) { ERRORMSG("File " << argv[1] << " is invalid") xmlFreeDoc(m_doc); return 1; } // Check the document is of the right kind xmlNodePtr cur = xmlDocGetRootElement(m_doc); if (cur == NULL) { ERRORMSG("Empty document"); xmlFreeDoc(m_doc); return 1; } qmc.run(cur); } else { WARNMSG("No argument is given. Assume that does not need an input file") qmc.run(NULL); } LOGMSG("Bye") OHMMS::Controller->finalize(); return 0; }
// Miscellaneous internal routines. PUCHAR static CCSer_InternalMapRegisterAddresses( ULONG HWAddress, ULONG Size ) { PUCHAR ioPortBase; DEBUGMSG(ZONE_FUNCTION, (TEXT("+CCSer_InternalMapRegisterAddresses: adr=0x%x len=0x%x\r\n"), HWAddress, Size)); ioPortBase = VirtualAlloc(0, Size, MEM_RESERVE, PAGE_NOACCESS); if ( ioPortBase == NULL ) { ERRORMSG(1, (TEXT("CCSer_InternalMapRegisterAddresses: VirtualAlloc failed!\r\n"))); } else if ( !VirtualCopy((PVOID)ioPortBase, (PVOID)HWAddress, Size, PAGE_READWRITE|PAGE_NOCACHE) ) { ERRORMSG(1, (TEXT("CCSer_InternalMapRegisterAddresses: VirtualCopy failed!\r\n"))); VirtualFree( (PVOID)ioPortBase, 0, MEM_RELEASE ); ioPortBase = 0; } DEBUGMSG(ZONE_FUNCTION, (TEXT("-CCSer_InternalMapRegisterAddresses: mapped at 0x%x\r\n"), ioPortBase )); return ioPortBase; }
static void read_gz(int f, int fd, const char *arg) { gzFile g; int nBuf; char buf[BUFFER_SIZE]; g=gzdopen(f, "rb"); if (!g) { ERRORMSG(_("Invalid/corrupt .gz file.\n")); close(f); close(fd); return; } while ((nBuf=gzread(g, buf, BUFFER_SIZE))>0) { if (write(fd, buf, nBuf)!=nBuf) { gzclose(g); close(fd); return; } } if (nBuf) { ERRORMSG("\033[0m"); ERRORMSG(_("gzip: Error during decompression.\n")); } gzclose(g); close(fd); }
void transfer_creature(struct Thing *boxtng, struct Thing *transftng, unsigned char plyr_idx) { SYNCDBG(7,"Starting"); struct CreatureControl *cctrl; if (!thing_exists(boxtng) || (box_thing_to_special(boxtng) != SpcKind_TrnsfrCrtr) ) { ERRORMSG("Invalid transfer box object!"); return; } // Check if 'things' are correct if (!thing_exists(transftng) || !thing_is_creature(transftng) || (transftng->owner != plyr_idx)) { ERRORMSG("Invalid transfer creature thing!"); return; } cctrl = creature_control_get_from_thing(transftng); set_transfered_creature(plyr_idx, transftng->model, cctrl->explevel); remove_thing_from_power_hand_list(transftng, plyr_idx); kill_creature(transftng, INVALID_THING, -1, CrDed_NoEffects|CrDed_NotReallyDying); create_special_used_effect(&boxtng->mappos, plyr_idx); remove_events_thing_is_attached_to(boxtng); force_any_creature_dragging_owned_thing_to_drop_it(boxtng); delete_thing_structure(boxtng, 0); if (is_my_player_number(plyr_idx)) output_message(SMsg_CommonAcknowledge, 0, true); }
void lunascan::setstringsize(int size) { if (STRING!=NULL) ERRORMSG(); if (size<1) ERRORMSG(); STRINGSIZE=size; }
void lunascan::setscopestacksize(int size) { if (SCOPESTACK!=NULL) ERRORMSG(); if (size<1) ERRORMSG(); SCOPESTACKSIZE=size; }
void lunascan::sethashsize(int size) { if (HASH!=NULL) ERRORMSG(); if (size<1) ERRORMSG(); HASHSIZE=size; }
void lunascan::setcodestacksize(int size) { if (CODE!=NULL) ERRORMSG(); if (size<1) ERRORMSG(); CODESTACKMAX=size; }
void lunascan::setcomment(char comment) { if (CODESTACKSIZE>0) ERRORMSG(); if (comment==' ' || comment=='\n' || comment=='\r' || comment=='\0') ERRORMSG(); COMMENT=comment; }
int lunascan::getinfo(int serial) { if (CODESTACKSIZE<1) ERRORMSG(); if (serial<0 || serial>=POOLSIZE) ERRORMSG(); return(POOL[serial].info); }
int lunascan::getinfo() { if (CODESTACKSIZE<1) ERRORMSG(); if (SERIAL==LUNA_UNKNOWN) ERRORMSG(); return(POOL[SERIAL].info); }
static BOOL InitializeIST() { BOOL r; gMfcIntrEvent = CreateEvent(NULL, FALSE, FALSE, NULL); if (!gMfcIntrEvent) { ERRORMSG(1, (L"Unable to create interrupt event")); return(FALSE); } if (!CreateInterruptNotification()) { ERRORMSG(1, (L"Unable to create interrupt notification")); CloseHandle(gMfcIntrEvent); return FALSE; } r = KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &g_MfcIrq, sizeof(UINT32), &g_MfcSysIntr, sizeof(UINT32), NULL); if (r != TRUE) { ERRORMSG(1, (L"Failed to request sysintr value for MFC interrupt.\r\n")); DeleteInterruptNotification(); CloseHandle(gMfcIntrEvent); return FALSE; } r = InterruptInitialize(g_MfcSysIntr, gMfcIntrEvent, NULL, 0); if (r != TRUE) { ERRORMSG(1, (L"Unable to initialize output interrupt")); DeleteInterruptNotification(); CloseHandle(gMfcIntrEvent); return FALSE; } gMfcIntrThread = CreateThread((LPSECURITY_ATTRIBUTES)NULL, 0, (LPTHREAD_START_ROUTINE)MFC_IntrThread, 0, 0, NULL); if (!gMfcIntrThread) { ERRORMSG(1, (L"Unable to create interrupt thread")); InterruptDisable(g_MfcSysIntr); DeleteInterruptNotification(); CloseHandle(gMfcIntrEvent); return FALSE; } // Bump up the priority since the interrupt must be serviced immediately. CeSetThreadPriority(gMfcIntrThread, MFC_THREAD_PRIORITY_DEFAULT); RETAILMSG(1, (L"MFC Interrupt has been initialized.\n")); return TRUE; }
void initglobal(int argc,char *argv[]) { char *ptr; parseargs(argc,argv); ptr=strrchr(PROGNAME,'/'); if (ptr==NULL) PROGNAME[0]='\0'; else *ptr='\0'; VOLREN=new volren(PROGNAME); if (strlen(OUTNAME)>0) { loadvolume(); VOLREN->savePVMvolume(OUTNAME); exit(0); } EYE_X=0.0f; EYE_Y=0.0f; EYE_Z=3.0f; EYE_SPEED=0.0f; VOLREN->get_tfunc()->set_line(0.0f,0.0f,0.33f,1.0f,VOLREN->get_tfunc()->get_be()); VOLREN->get_tfunc()->set_line(0.33f,1.0f,0.67f,0.0f,VOLREN->get_tfunc()->get_be()); VOLREN->get_tfunc()->set_line(0.33f,0.0f,0.67f,1.0f,VOLREN->get_tfunc()->get_ge()); VOLREN->get_tfunc()->set_line(0.67f,1.0f,1.0f,0.0f,VOLREN->get_tfunc()->get_ge()); VOLREN->get_tfunc()->set_line(0.67f,0.0f,1.0f,1.0f,VOLREN->get_tfunc()->get_re()); VOLREN->get_tfunc()->set_line(0.0f,0.0f,1.0f,1.0f,VOLREN->get_tfunc()->get_ra()); VOLREN->get_tfunc()->set_line(0.0f,0.0f,1.0f,1.0f,VOLREN->get_tfunc()->get_ga()); VOLREN->get_tfunc()->set_line(0.0f,0.0f,1.0f,1.0f,VOLREN->get_tfunc()->get_ba()); loadhook(); if ((GUI_recfile=fopen(RECORD,"rb"))!=NULL) { GUI_demo=TRUE; fclose(GUI_recfile); } if (GUI_record) { if ((GUI_recfile=fopen(RECORD,"wb"))==NULL) ERRORMSG(); GUI_demo=FALSE; } if (GUI_demo) { if ((GUI_recfile=fopen(RECORD,"rb"))==NULL) ERRORMSG(); GUI_start=gettime(); } }
// write a RAW file void writeRAWfile(const char *filename,unsigned char *data,size_t bytes,int nofree) { if (bytes<1) ERRORMSG(); if ((DDS_file=fopen(filename,"wb"))==NULL) ERRORMSG(); if (fwrite(data,1,bytes,DDS_file)!=bytes) ERRORMSG(); fclose(DDS_file); if (nofree==0) free(data); }
static int LoadGfwList_Thread(ConfigFileInfo *ConfigInfo) { int UpdateInterval = ConfigGetInt32(ConfigInfo, "GfwListUpdateInterval"); int RetryInterval = ConfigGetInt32(ConfigInfo, "GfwListRetryInterval"); BOOL NeedBase64Decode = ConfigGetBoolean(ConfigInfo, "GfwListBase64Decode"); int Count; if( RetryInterval < 0 ) { RetryInterval = 0; } while( TRUE ) { INFO("Loading GFW List From %s ...\n", GfwList); if( GetFromInternet_Base(GfwList, File, FALSE) != 0 ) { ERRORMSG("Downloading GFW List failed. Waiting %d second(s) for retry.\n", RetryInterval); SLEEP(RetryInterval * 1000); } else { INFO("GFW List saved at %s.\n", File); Count = LoadGfwListFile(File, NeedBase64Decode); switch( Count ) { case -1: case -2: case -3: break; case -4: ERRORMSG("Loading GFW List failed, cannot open file %s. Stop loading.\n", File); return -1; break; default: INFO("Loading GFW List completed. %d effective items.\n", Count); break; } if( UpdateInterval < 0 ) { return 0; } SLEEP(UpdateInterval * 1000); } } return 0; }
VISIBILITY_ENABLE #include "ttyrec.h" VISIBILITY_DISABLE #include "stream.h" #include "error.h" #include "gettext.h" #define ERRORMSG(x) do if (write(fd,(x),strlen(x))) {} while(0) #define BUFFER_SIZE 32768 #if (defined HAVE_LIBBZ2) || (defined SHIPPED_LIBBZ2) static void read_bz2(int f, int fd, const char *arg) { BZFILE* b; int nBuf; char buf[BUFFER_SIZE]; int bzerror; b = BZ2_bzReadOpen(&bzerror, fdopen(f,"rb"), 0, 0, NULL, 0); if (bzerror != BZ_OK) { BZ2_bzReadClose(&bzerror, b); // error ERRORMSG(_("Invalid/corrupt .bz2 file.\n")); close(fd); return; } bzerror = BZ_OK; while (bzerror == BZ_OK) { nBuf = BZ2_bzRead(&bzerror, b, buf, BUFFER_SIZE); if (write(fd, buf, nBuf)!=nBuf) { BZ2_bzReadClose(&bzerror, b); close(fd); return; } } if (bzerror != BZ_STREAM_END) { BZ2_bzReadClose(&bzerror, b); // error ERRORMSG("\033[0m"); ERRORMSG(_("bzip2: Error during decompression.\n")); } else BZ2_bzReadClose(&bzerror, b); close(fd); }
struct Thing *allocate_free_thing_structure_f(unsigned char allocflags, const char *func_name) { struct Thing *thing; long i; // Get a thing from "free things list" i = game.free_things_start_index; // If there is no free thing, try to free an effect if (i >= THINGS_COUNT-1) { if ((allocflags & FTAF_FreeEffectIfNoSlots) != 0) { thing = thing_get(game.thing_lists[TngList_EffectElems].index); if (!thing_is_invalid(thing)) { delete_thing_structure(thing, 0); } else { #if (BFDEBUG_LEVEL > 0) ERRORMSG("%s: Cannot free up effect element to allocate new thing!",func_name); #endif } } i = game.free_things_start_index; } // Now, if there is still no free thing (we couldn't free any) if (i >= THINGS_COUNT-1) { #if (BFDEBUG_LEVEL > 0) ERRORMSG("%s: Cannot allocate new thing, no free slots!",func_name); #endif return INVALID_THING; } // And if there is free one, allocate it thing = thing_get(game.free_things[i]); #if (BFDEBUG_LEVEL > 0) if (thing_exists(thing)) { ERRORMSG("%s: Found existing thing %d in free things list at pos %d!",func_name,(int)game.free_things[i],(int)i); } #endif LbMemorySet(thing, 0, sizeof(struct Thing)); if (thing_is_invalid(thing)) { ERRORMSG("%s: Got invalid thing slot instead of free one!",func_name); return INVALID_THING; } thing->alloc_flags |= TAlF_Exists; thing->index = game.free_things[i]; game.free_things[game.free_things_start_index] = 0; game.free_things_start_index++; TRACE_THING(thing); return thing; }
static int read_end_of_cent_dir (FILE *fp, t_end_of_cent_dir *ecd) { int count, read; int sigoffset; int err; sigoffset=0; /* determine how many bytes to read */ if (gZipLen > BUFSIZE) count = BUFSIZE; else count = gZipLen; /* seek to end of file - count */ err = fseek (fp, -count, SEEK_END); if (err!=0){ ERRORMSG ("Error in zipfile: fseek failed\n"); return err; } /* read entire file or BUFSIZE bytes into buffer */ read = fread (input_buffer, 1, count, fp); if (read == count){ /* locate end-of-central-dir sig */ err = find_ecd_sig (input_buffer, count, &sigoffset); if (err==0){ char *p = input_buffer+sigoffset; /* read end-of-central-dir */ ecd->end_of_cent_dir_sig = read_dword (p+ZIPESIG); ecd->number_of_this_disk = read_word (p+ZIPEDSK); ecd->number_of_disk_start_cent_dir = read_word (p+ZIPECEN); ecd->total_entries_cent_dir_this_disk = read_word (p+ZIPENUM); ecd->total_entries_cent_dir = read_word (p+ZIPECENN); ecd->size_of_cent_dir = read_dword (p+ZIPECSZ); ecd->offset_to_start_of_cent_dir = read_dword (p+ZIPEOFST); ecd->zipfile_comment_length = read_word (p+ZIPECOML); } else{ ERRORMSG ("Error in zipfile: couldn't find 'end of central dir' signature\n"); } } else{ ERRORMSG ("Error in zipfile: couldn't read %d bytes from end of file\n", count); err = -1; } return err; }
BOOL _stdcall DllMain (HANDLE hModule, DWORD reason, void * unused) { if (reason != DLL_PROCESS_ATTACH) return true; MGEFlags = NULL; bool iniLoaded = LoadSettings (); if (!IsMorrowind ()) return true; if (FindWindow (0, GUI_VERSION)) { ERRORMSG ("Error: MGEgui is running. Please shut it down before launching morrowind."); } if (!iniLoaded) { ERRORMSG ("Error: MGE is not configured. Please run MGEgui to configure it before launching Morrowind."); } Initialized = !BitTst (&MGEFlags, MGE_DISABLED_BIT); HANDLE MWSEpipe; HANDLE MGEpipe; if (Initialized) { MWSEpipe = CreateNamedPipeA ("\\\\.\\pipe\\MWSEMGEpipe", PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, PIPE_UNLIMITED_INSTANCES, 4096, 4096, 20000, NULL ); MWSEpipe2 = CreateNamedPipeA ("\\\\.\\pipe\\MWSEMGEpipe2", PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, PIPE_UNLIMITED_INSTANCES, 4096, 4096, 20000, NULL ); if (MWSEpipe == INVALID_HANDLE_VALUE || MWSEpipe2 == INVALID_HANDLE_VALUE) { LOG::log ("Failed to create mge-mwse pipe\r\n"); return false; } MGEpipe = CreateFile ("\\\\.\\pipe\\MWSEMGEpipe", GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL); MGEpipe2 = CreateFile ("\\\\.\\pipe\\MWSEMGEpipe2", GENERIC_WRITE|GENERIC_READ,0,NULL,OPEN_EXISTING,0,NULL); if (MGEpipe == INVALID_HANDLE_VALUE || MGEpipe2 == INVALID_HANDLE_VALUE) { LOG::log ("Failed to open mge-mwse pipe\r\n"); return false; } } else MWSEpipe = INVALID_HANDLE_VALUE; if (MGEFlags & MWSE_DISABLED) LOG::log ("MWSE: Disabled\r\n"); else MWSEOnProcessStart (MWSEpipe); if (Initialized) { MGEOnProcessStart (MGEpipe); DInputOnProcessStart (); } else LOG::log ("MGE: Disabled\r\n"); return true; }
AlignmentSet * AlignmentSet::CreateFromMultiple(StructureBase *parent, const BlockMultipleAlignment *multiple, const vector < unsigned int >& rowOrder) { // sanity check on the row order map map < unsigned int, unsigned int > rowCheck; for (unsigned int i=0; i<rowOrder.size(); ++i) rowCheck[rowOrder[i]] = i; if (rowOrder.size() != multiple->NRows() || rowCheck.size() != multiple->NRows() || rowOrder[0] != 0) { ERRORMSG("AlignmentSet::CreateFromMultiple() - bad row order vector"); return NULL; } // create a single Seq-annot, with 'align' data that holds one Seq-align per dependent auto_ptr<SeqAnnotList> newAsnAlignmentData(new SeqAnnotList(1)); CSeq_annot *seqAnnot = new CSeq_annot(); newAsnAlignmentData->back().Reset(seqAnnot); CSeq_annot::C_Data::TAlign& seqAligns = seqAnnot->SetData().SetAlign(); seqAligns.resize((multiple->NRows() == 1) ? 1 : multiple->NRows() - 1); CSeq_annot::C_Data::TAlign::iterator sa = seqAligns.begin(); BlockMultipleAlignment::UngappedAlignedBlockList blocks; multiple->GetUngappedAlignedBlocks(&blocks); // create Seq-aligns; if there's only one row (the master), then cheat and create an alignment // of the master with itself, because asn data doesn't take well to single-row "alignment" if (multiple->NRows() > 1) { unsigned int newRow; for (unsigned int row=1; row<multiple->NRows(); ++row, ++sa) { newRow = rowOrder[row]; CSeq_align *seqAlign = CreatePairwiseSeqAlignFromMultipleRow(multiple, blocks, newRow); sa->Reset(seqAlign); } } else sa->Reset(CreatePairwiseSeqAlignFromMultipleRow(multiple, blocks, 0)); auto_ptr<AlignmentSet> newAlignmentSet; try { newAlignmentSet.reset(new AlignmentSet(parent, multiple->GetMaster(), *newAsnAlignmentData)); } catch (exception& e) { ERRORMSG( "AlignmentSet::CreateFromMultiple() - failed to create AlignmentSet from new asn object; " << "exception: " << e.what()); return NULL; } newAlignmentSet->newAsnAlignmentData = newAsnAlignmentData.release(); return newAlignmentSet.release(); }
void *Phy2Vir_AddrMapping(unsigned int phy_addr, int mem_size) { #if 1 void *mappedAddr = NULL; mappedAddr = DrvLib_MapIoSpace(phy_addr, mem_size, FALSE); if (mappedAddr == NULL) { RETAILMSG(1, (L"[MFC:ERR] Phy2Vir_AddrMapping() : Mapping Failed [PA:0x%08x]\n\r", phy_addr)); } return mappedAddr; #else BOOL b; void *reserved_mem; reserved_mem = (void *)VirtualAlloc(NULL, mem_size, MEM_RESERVE, PAGE_NOACCESS); if (reserved_mem == NULL) { ERRORMSG(1,(TEXT("For IOPreg: VirtualAlloc failed!\r\n"))); return 0; } b = VirtualCopy(reserved_mem, (void *)(phy_addr >> 8), mem_size, PAGE_PHYSICAL | PAGE_READWRITE | PAGE_NOCACHE); if (b == FALSE) { VirtualFree(reserved_mem, 0, MEM_RELEASE); return NULL; } return reserved_mem; #endif }
// render the globe void miniglobe::render() { if (DONE==0) { switch (SHAPE) { case SHAPE_SUN: create_sun(); break; case SHAPE_MERCURY: create_orb(minicoord::MINICOORD_ORB_MERCURY); break; case SHAPE_VENUS: create_orb(minicoord::MINICOORD_ORB_VENUS); break; case SHAPE_EARTH: create_earth(); break; case SHAPE_MARS: create_orb(minicoord::MINICOORD_ORB_MARS); break; case SHAPE_JUPITER: create_orb(minicoord::MINICOORD_ORB_JUPITER); break; case SHAPE_SATURN: create_orb(minicoord::MINICOORD_ORB_SATURN); break; case SHAPE_URANUS: create_orb(minicoord::MINICOORD_ORB_URANUS); break; case SHAPE_NEPTUNE: create_orb(minicoord::MINICOORD_ORB_NEPTUNE); break; case SHAPE_CERES: create_orb(minicoord::MINICOORD_ORB_CERES); break; case SHAPE_PLUTO: create_orb(minicoord::MINICOORD_ORB_PLUTO); break; case SHAPE_ERIS: create_orb(minicoord::MINICOORD_ORB_ERIS); break; case SHAPE_MOON: create_moon(); break; default: ERRORMSG(); } create_shader(CONFIGURE_FRONTNAME,CONFIGURE_BACKNAME, CONFIGURE_FRONTBUF,CONFIGURE_BACKBUF); DONE=1; } initstate(); STRIP->render(); exitstate(); }
struct PlayerInfo *get_player_f(long plyr_idx,const char *func_name) { if ((plyr_idx >= 0) && (plyr_idx < PLAYERS_COUNT)) return &game.players[plyr_idx]; ERRORMSG("%s: Tried to get non-existing player %d!",func_name,(int)plyr_idx); return INVALID_PLAYER; }