/* ------------------------------------------------------------------------------------ */ int CLogic::RestoreFrom(FILE *RestoreFD, bool type) { geEntity_EntitySet *pSet; geEntity *pEntity; // Ok, check to see if there are triggers in this world pSet = geWorld_GetEntitySet(CCD->World(), "LogicGate"); if(!pSet) return RGF_SUCCESS; // No gates, whatever... for(pEntity=geEntity_EntitySetGetNextEntity(pSet, NULL); pEntity; pEntity=geEntity_EntitySetGetNextEntity(pSet, pEntity)) { LogicGate *pSource = (LogicGate*)geEntity_GetUserData(pEntity); READDATA(type, &pSource->active, sizeof(geBoolean), 1, RestoreFD); READDATA(type, &pSource->bState, sizeof(geBoolean), 1, RestoreFD); READDATA(type, &pSource->OldState, sizeof(geBoolean), 1, RestoreFD); READDATA(type, &pSource->inDelay, sizeof(geBoolean), 1, RestoreFD); READDATA(type, &pSource->time, sizeof(float), 1, RestoreFD); } return RGF_SUCCESS; }
/* ------------------------------------------------------------------------------------ */ int CAutoDoors::RestoreFrom(FILE *RestoreFD, bool type) { geEntity_EntitySet *pSet; geEntity *pEntity; // Ok, check to see if there are automatic doors in this world pSet = geWorld_GetEntitySet(CCD->World(), "Door"); if(!pSet) return RGF_SUCCESS; // No doors, whatever... for(pEntity=geEntity_EntitySetGetNextEntity(pSet, NULL); pEntity; pEntity=geEntity_EntitySetGetNextEntity(pSet, pEntity)) { Door *pDoor = (Door*)geEntity_GetUserData(pEntity); READDATA(type, &pDoor->bInAnimation, sizeof(geBoolean), 1, RestoreFD); READDATA(type, &pDoor->bTrigger, sizeof(geBoolean), 1, RestoreFD); READDATA(type, &pDoor->AnimationTime, sizeof(int), 1, RestoreFD); READDATA(type, &pDoor->bInCollision, sizeof(geBoolean), 1, RestoreFD); READDATA(type, &pDoor->bActive, sizeof(geBoolean), 1, RestoreFD); READDATA(type, &pDoor->LastIncrement, sizeof(int), 1, RestoreFD); READDATA(type, &pDoor->tDoor, sizeof(geFloat), 1, RestoreFD); READDATA(type, &pDoor->CallBack, sizeof(geBoolean), 1, RestoreFD); READDATA(type, &pDoor->CallBackCount, sizeof(int), 1, RestoreFD); if(pDoor->bInAnimation) geWorld_OpenModel(CCD->World(), pDoor->Model, GE_TRUE); } return RGF_SUCCESS; }
//---------------------------------------------------------------------------------- u8 s_read_byte(u8 ack) //---------------------------------------------------------------------------------- // reads a byte form the Sensibus and gives an acknowledge in case of "ack=1" { u8 i,val=0; MAKE_I2CDATA_INPUT(); SETDATA(); //release DATA-line asm("nop");asm("nop"); for (i=0x80;i>0;i/=2) //shift bit for masking { SETSCK(); //clk for SENSI-BUS asm("nop");asm("nop"); if (READDATA()) val=(val | i); //read bit CLRSCK(); asm("nop");asm("nop"); } MAKE_I2CDATA_OUTPUT(); if(ack) CLRDATA(); else SETDATA(); //in case of "ack==1" pull down DATA-Line SETSCK(); //clk #9 for ack asm("nop");asm("nop"); //pulswith approx. 250 ns CLRSCK(); asm("nop");asm("nop"); SETDATA(); //release DATA-line return val; }
/* ------------------------------------------------------------------------------------ */ int CPersistentAttributes::RestoreFrom(FILE *RestoreFD, bool type) { char szTempTag[256]; int nValue, nCount, nLen, nUserDataSize, Low, High, PowerUpLevel; int nInFile; unsigned char *theUserData; PersistAttribute *pTemp = NULL; Clear(); // Zap everything first fread(&nInFile, sizeof(int), 1, RestoreFD); for(int nTemp = 0; nTemp < nInFile; nTemp++) { READDATA(type, &nLen, sizeof(int), 1, RestoreFD); // Tag size READDATA(type, &szTempTag, 1, nLen, RestoreFD); READDATA(type, &nCount, sizeof(int), 1, RestoreFD); READDATA(type, &nValue, sizeof(int), 1, RestoreFD); READDATA(type, &Low, sizeof(int), 1, RestoreFD); READDATA(type, &High, sizeof(int), 1, RestoreFD); // changed QD 12/15/05 READDATA(type, &PowerUpLevel, sizeof(int), 1, RestoreFD); // end change READDATA(type, &nUserDataSize, sizeof(int), 1, RestoreFD); if(nUserDataSize != 0) { theUserData = new unsigned char[nUserDataSize]; READDATA(type, &theUserData, 1, nUserDataSize, RestoreFD); } else theUserData = NULL; pTemp = AddNew(szTempTag, nValue); pTemp->ValueLowLimit = Low; pTemp->ValueHighLimit = High; // changed QD 12/15/05 pTemp->PowerUpLevel = PowerUpLevel; // end change pTemp->Count = nCount; // Adjust count pTemp->UserDataSize = nUserDataSize; pTemp->UserData = theUserData; } return RGF_SUCCESS; }
/* ------------------------------------------------------------------------------------ */ int CChangeLevel::RestoreFrom(FILE *RestoreFD, bool type) { geEntity_EntitySet *pSet; geEntity *pEntity; // Ok, check to see if there are ChangeLevel in this world pSet = geWorld_GetEntitySet(CCD->World(), "ChangeLevel"); if(!pSet) return RGF_SUCCESS; // No doors, whatever... for(pEntity=geEntity_EntitySetGetNextEntity(pSet, NULL); pEntity; pEntity=geEntity_EntitySetGetNextEntity(pSet, pEntity)) { ChangeLevel *pItem = (ChangeLevel*)geEntity_GetUserData(pEntity); READDATA(type, &pItem->CallBack, sizeof(geBoolean), 1, RestoreFD); READDATA(type, &pItem->CallBackCount, sizeof(int), 1, RestoreFD); } return RGF_SUCCESS; }
bool verify_integrity() { /* Ensure our client is running a valid binary! * Send to server for validation! */ uint32_t res = 0; #if !(defined(PATCHED_1) || defined(DEBUG)) res = getshifty(); #endif res ^= get_text_checksum(); //verify that this is correct //in practice, the poll just refuses to respond if wrong printf("@h",res); if(!READDATA(res)) return 0; return res; }
//---------------------------------------------------------------------------------- u8 s_write_byte(u8 value) //---------------------------------------------------------------------------------- // writes a byte on the Sensibus and checks the acknowledge { u8 i,error=0; MAKE_I2CDATA_OUTPUT(); for (i=0x80;i>0;i/=2) //shift bit for masking { if (i & value) SETDATA(); //masking value with i , write to SENSI-BUS else CLRDATA(); SETSCK(); //clk for SENSI-BUS asm("nop");asm("nop"); //pulswith approx. 250 ns CLRSCK(); } SETDATA(); //release DATA-line MAKE_I2CDATA_INPUT(); asm("nop");asm("nop"); SETSCK(); //clk #9 for ack error=READDATA(); //check ack (DATA will be pulled down by SHT11) CLRSCK(); MAKE_I2CDATA_OUTPUT(); return error; //error=1 in case of no acknowledge }
/** * Main request handling loop * * @return 0 on success, err code on failure */ int go(void) { int i; int res; uint32_t tmp = 0; uint32_t *seed; char *resend; size_t tosend; size_t offset; uint32_t *f; init_fs(); debug("fs init complete\n"); if (!READDATATIMEOUT(conf)) { debug("failed to recv conf\n"); res = 0; SENDDATA(res); return 3; } if (conf.min_ver > VERSION || conf.max_ver < VERSION) { debug("version mismatch\n"); res = 0; SENDDATA(res); return 5; } //send success ack res = 1; SENDDATA(res); //seed our PRNG //because of how it works, seeding with 0's == no encryption seed = (uint32_t*)(FLAG_PAGE + (8*sizeof(uint32_t))); f = malloc(8*sizeof(uint32_t)); if (!f) return 1; cgc_memcpy(f, seed, 8*sizeof(uint32_t)); if (!conf.encrypt) seed = calloc(8*sizeof(uint32_t)); srand(seed); //inform client of seed for (i = 0; i < 8; i+=2) { if (conf.encrypt) tmp = f[i]^f[i+1]; SENDDATA(tmp); } #ifdef PATCHED_1 cgc_memset(f, '\0', 8*sizeof(uint32_t)); #endif debug("flag data: @h\n",f); free(f); while (1) { res = process_req(); if (res == ERR || res == EXIT) { break; } else if (res == DISCON && conf.allow_reconnect && last) { debug("disconnected, retrying\n"); if (!READDATATIMEOUT(conf)) { debug("failed to recv conf\n"); return 3; } if (!last) continue; debug("Allocating resend buffer of @h bytes.\n",conf.buf_size+sizeof(resp_t)); #ifdef PATCHED_1 resend = calloc(conf.buf_size+sizeof(resp_t)); #else resend = malloc(conf.buf_size+sizeof(resp_t)); #endif debug("resend data: @h\n",resend); if (!READDATA(offset)) { debug("failed to recv offset\n"); return 4; } tosend = sizeof(resp_t)-offset; tosend = tosend > sizeof(resp_t) ? sizeof(resp_t) : tosend; if (offset > conf.buf_size || offset > sizeof(resp_t) #ifdef PATCHED_1 || tosend > (conf.buf_size+sizeof(resp_t)) #endif ) { debug("failed to validate offset.\n"); return 1; } else { debug("copying last out\n"); cgc_memcpy(resend, last+offset, sizeof(resp_t)-offset); } #ifdef PATCHED_1 if (tosend != esendall(stdout, resend, tosend)) #else if (tosend != esendall(stdout, resend, sizeof(resp_t))) #endif return 4; debug("Resent all, should be back!\n"); free(resend); free(last); last = NULL; } } return 0; }
HRESULT CControlState::Load( LPSTREAM pStm ) { HRESULT hr = S_OK; CComVariant var; DWORD dwVer; READDATA( dwVer ); // version 1 and 2 are pre-2.0 and are not backward compatible. Ignore this data. if ( dwVer < 3 ) { return S_FALSE; } READDATA( m_bColorSyntax ); READDATA( m_bAllowHSplit ); READDATA( m_bAllowVSplit ); READDATA( m_bHScroll ); READDATA( m_bVScroll ); READDATA( m_bSmoothScroll ); READDATA( m_bLineToolTips ); READDATA( m_bShowLeftMargin ); READDATA( m_bAllowColumnSel ); READDATA( m_bAllowDragDrop ); READDATA( m_bExpandTabs ); READDATA( m_xPosHSplitter ); READDATA( m_yPosVSplitter ); READDATA( m_eIndentStyle ); READDATA( m_nTabSize ); READDATA( m_Colors ); READDATA( m_lf ); // dealloc old strings FreeStrings(); if ( SUCCEEDED( hr = var.ReadFromStream( pStm ) ) ) { m_bstrText = var.bstrVal; var.bstrVal = NULL; var.vt = VT_EMPTY; } else goto bail; if ( SUCCEEDED( hr = var.ReadFromStream( pStm ) ) ) { m_bstrLang = var.bstrVal; var.bstrVal = NULL; var.vt = VT_EMPTY; } else goto bail; READDATA( m_bDisplayWhitespace ); READDATA( m_bWantCarriageReturn ); READDATA( m_bEnabled ); READDATA( m_bGlobalProps ); READDATA( m_bModified ); READDATA( m_bOverType ); READDATA( m_bReadOnly ); READDATA( m_bPreserveCase ); READDATA( m_bCaseSensitiveSearch ); READDATA( m_bWholeWordOnly ); READDATA( m_nMaxUndo ); READDATA( m_bSelBounds ); READDATA( m_bRegExp ); READDATA( m_FontStyles ); READDATA( m_LineNum ); READDATA( m_bHideSel ); READDATA( m_bNormalizeCase ); READDATA( m_bOvertypeCaret ); READDATA( m_nHighlightedLine ); if ( dwVer < 4 ) goto bail; READDATA( m_dwBorderStyle ); if ( dwVer < 5 ) goto bail; READDATA( m_bStealKeys ); bail: return hr; }