char db_createUser( const char *username, const char *password ) { int userId, userLen, passLen; User_t *user; unsigned char hashpass[ SHA256_LEN ]; userId = 0; userLen = strlen( username ); passLen = strlen( password ); memset( hashpass, 0, sizeof( hashpass ) ); if( userLen < 1 || userLen > USER_MAX || passLen < 1 || passLen > SHA256_LEN ) return DB_ERR_CREATE_LENGTH; if( userExists( username ) ) return DB_ERR_CREATE_EXISTS; db_hashPass( password, hashpass ); userId = getNextID(); user = malloc( sizeof( User_t ) ); memset( user, 0, sizeof( User_t ) ); user->userId = userId; memcpy( user->username, username, strlen( username ) ); memcpy( user->userpass, hashpass, SHA256_LEN ); user->flags = 0; addUser( user ); free( user ); return DB_CREATE; }
void LLXferManager::requestFile(const std::string& remote_filename, ELLPath remote_path, const LLHost& remote_host, BOOL delete_remote_on_completion, void (*callback)(void*,S32,void**,S32,LLExtStat), void** user_data, BOOL is_priority) { LLXfer *xferp; xferp = (LLXfer *) new LLXfer_Mem(); if (xferp) { addToList(xferp, mReceiveList, is_priority); ((LLXfer_Mem *)xferp)->initializeRequest(getNextID(), remote_filename, remote_path, remote_host, delete_remote_on_completion, callback, user_data); startPendingDownloads(); } else { llerrs << "Xfer allocation error" << llendl; } }
void System::onRawArrival( HANDLE handle ) { UINT pathLength = 0; if ( GetRawInputDeviceInfoW( handle, RIDI_DEVICENAME, NULL, &pathLength ) ) NIL_EXCEPT_WINAPI( "GetRawInputDeviceInfoW failed" ); wideString rawPath( pathLength, '\0' ); GetRawInputDeviceInfoW( handle, RIDI_DEVICENAME, &rawPath[0], &pathLength ); rawPath.resize( rawPath.length() - 1 ); for ( auto device : mDevices ) { if ( device->getHandler() != Device::Handler_RawInput ) continue; auto rawDevice = static_cast<RawInputDevice*>( device ); if ( !_wcsicmp( rawDevice->getRawPath().c_str(), rawPath.c_str() ) ) { deviceConnect( rawDevice ); return; } } auto device = new RawInputDevice( this, getNextID(), handle, rawPath ); if ( isInitializing() ) device->setStatus( Device::Status_Connected ); else deviceConnect( device ); mDevices.push_back( device ); }
//============================================================================= // Write the current values into the database. //============================================================================= QString CAddress::saveChanges () { QString intro, firstValue, where, newid; unsigned int row; //---------------------------------------------------------------------------- // If nothing was changed, nothing has to be done. //---------------------------------------------------------------------------- if (!mContentChanged) return mCurrent; for (row = 0; row < mAddress.count(); row++) { if (!mAddress.at(row)->hasChanged()) continue; //-------------------------------------------------------------------------- // Build the SQL statement. //-------------------------------------------------------------------------- if (row < mIDs.count()) { intro = "UPDATE contacts_addresses ("; firstValue = ""; where = "WHERE address_id = " + mIDs[row]; } else { newid = getNextID(); mIDs << newid; intro = "INSERT contacts_addresses (address_id, "; firstValue = newid + ", "; where = ""; } //-------------------------------------------------------------------------- // Execute the SQL statement. //-------------------------------------------------------------------------- QSqlQuery query (intro + "person_id, type, street, zip, city, state, country, " "last_modified) VALUES (" + firstValue + mCurrent + ", " + QString::number (mAddress.at(row)->type()) + ", '" + mAddress.at(row)->street() + "', '" + mAddress.at(row)->zip() + "', '" + mAddress.at(row)->city() + "', '" + mAddress.at(row)->state() + "', '" + mAddress.at(row)->country() + "', TIMESTAMP) " + where); if (!query.isActive()) { SHOW_DB_ERROR(tr ("Error during writing of data"), query); return ""; } } mContentChanged = false; mNew = false; return mCurrent; }
U64 LLXferManager::registerXfer(const void *datap, const S32 length) { LLXfer *xferp; U64 xfer_id = getNextID(); xferp = (LLXfer *) new LLXfer_Mem(); if (xferp) { xferp->mNext = mSendList; mSendList = xferp; xfer_id = ((LLXfer_Mem *)xferp)->registerXfer(xfer_id, datap,length); if (!xfer_id) { removeXfer(xferp,&mSendList); } } else { llerrs << "Xfer allocation error" << llendl; xfer_id = 0; } return(xfer_id); }
Entity* EntityManager::createEntity() { EntityID id = getNextID(); Entity* entity = new Entity(); entity->id = id; entities.push_back(*entity); return entity; }
int Manager::createAccount(const std::string &accountName, const double startValue, const Time &time) { const int newID = getNextID(); Account *newAccount = new Account(newID, accountName, startValue, time); account.push_back(newAccount); amountAccounts++; ID.push_back(newID); return newID; }
Neithal::Neithal(Inventory* p, int stack) : Resource(p){ setName("Neithal"); setWeight(float(0.1)); setSymbol(new Symbol('*', 1)); setItemID(getNextID()); setStack(stack); totWeight = getWeight()*stack; setResourceType(neithal); }
Iron::Iron(Inventory* p, int stack) : Resource(p){ setName("Iron"); setWeight(float(0.5)); setSymbol(new Symbol('*', 8)); setItemID(getNextID()); setStack(stack); totWeight = getWeight()*stack; setResourceType(iron); }
Wood::Wood(Inventory* p, int stack) : Resource(p){ setName("Wood"); setWeight(float(0.1)); setSymbol(new Symbol('*', 6)); setItemID(getNextID()); setStack(stack); totWeight = getWeight()*stack; setResourceType(wood); }
Leather::Leather(Inventory* p, int stack) : Resource(p){ setName("Leather"); setWeight(float(0.1)); setSymbol(new Symbol('*', 14)); setItemID(getNextID()); setStack(stack); totWeight = getWeight()*stack; setResourceType(leather); }
Cloth::Cloth(Inventory* p, int stack) : Resource(p){ setName("Cloth"); setWeight(float(0.1)); setSymbol(new Symbol('*', 7)); setItemID(getNextID()); setStack(stack); totWeight = getWeight()*stack; setResourceType(cloth); }
Selentine::Selentine(Inventory* p, int stack) : Resource(p){ setName("Selentine"); setWeight(float(0.1)); setSymbol(new Symbol('*', 7)); setItemID(getNextID()); setStack(stack); totWeight = getWeight()*stack; setResourceType(selentine); }
void LLXferManager::requestFile(const std::string& local_filename, const std::string& remote_filename, ELLPath remote_path, const LLHost& remote_host, BOOL delete_remote_on_completion, void (*callback)(void**,S32,LLExtStat), void** user_data, BOOL is_priority, BOOL use_big_packets) { LLXfer *xferp; for (xferp = mReceiveList; xferp ; xferp = xferp->mNext) { if (xferp->getXferTypeTag() == LLXfer::XFER_FILE && (((LLXfer_File*)xferp)->matchesLocalFilename(local_filename)) && (((LLXfer_File*)xferp)->matchesRemoteFilename(remote_filename, remote_path)) && (remote_host == xferp->mRemoteHost) && (callback == xferp->mCallback) && (user_data == xferp->mCallbackDataHandle)) { // cout << "requested a xfer already in progress" << endl; return; } } S32 chunk_size = use_big_packets ? LL_XFER_LARGE_PAYLOAD : -1; xferp = (LLXfer *) new LLXfer_File(chunk_size); if (xferp) { addToList(xferp, mReceiveList, is_priority); // Remove any file by the same name that happens to be lying // around. // Note: according to AaronB, this is here to deal with locks on files that were // in transit during a crash, if(delete_remote_on_completion && (remote_filename.substr(remote_filename.length()-4) == ".tmp")) { LLFile::remove(local_filename); } ((LLXfer_File *)xferp)->initializeRequest( getNextID(), local_filename, remote_filename, remote_path, remote_host, delete_remote_on_completion, callback,user_data); startPendingDownloads(); } else { llerrs << "Xfer allocation error" << llendl; } }
Veilron::Veilron(Inventory* p, int stack) : Resource(p){ setName("Veilron"); setWeight(float(0.1)); setSymbol(new Symbol('*', 0, BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED)); setItemID(getNextID()); setStack(stack); totWeight = getWeight()*stack; setResourceType(veilron); }
Theyril::Theyril(Inventory* p, int stack) : Resource(p){ setName("Theyril"); setWeight(float(0.1)); setSymbol(new Symbol('*', 15)); setItemID(getNextID()); setStack(stack); totWeight = getWeight()*stack; setResourceType(theyril); }
GameObject::GameObject( string name, Transform* t , World* scene ) { mScene = scene; this->name = name; this->id = getNextID(); t->gameObject = this; this->transform = t; }
void System::initializeDevices() { mXInputIDs.resize( XUSER_MAX_COUNT ); for ( int i = 0; i < XUSER_MAX_COUNT; i++ ) { mXInputIDs[i] = getNextID(); auto device = new XInputDevice( this, mXInputIDs[i], i ); mDevices.push_back( device ); } }
ID VectorSysObj::put(SystemObject *systemObject){ if(shouldExpand()) expand(); ID id = getNextID(); ocupied++; vector[id] = systemObject; if(id>lastOcupiedID) lastOcupiedID = id; return id; }
Controller::Player::Player ( std::string const & inName, Model::Color::Color inColor, std::map< Model::Piece::PieceType, std::size_t > const & inMeepleSupply ) : mName( inName ), mPlayerID( getNextID() ), mColor( inColor ), mScore( 0 ), mMeepleSupply( inMeepleSupply ) { }
FileID addWord(std::string word, std::fstream& f, bool createIfReauired = true) { Block b = getWordBlock(word, f, createIfReauired); FileID fid {b.data}; if (!createIfReauired) return fid; if (fid == 0) fid = getNextID(); b.data = fid; writeBlockToFile(b, f); return fid; }
unsigned OMenu::appendItem(const tstring& text, const Dispatcher::F& f /*nullptr*/, int flags /*0*/) { // init structure for new item CMenuItemInfo info; info.fMask = MIIM_ID | MIIM_TYPE | MIIM_DATA; info.fType = MFT_STRING; if(flags & FLAG_DISABLED) { info.fMask |= MIIM_STATE; info.fState |= MFS_DISABLED; } if (flags & FLAG_DEFAULT && !defaultSet) { info.fMask |= MIIM_STATE; info.fState |= MFS_DEFAULT; defaultSet = true; } if(flags & FLAG_CHECKED) { info.fMask |= MIIM_STATE; info.fState |= MFS_CHECKED; } info.dwTypeData = const_cast< LPTSTR >( text.c_str() ); const auto index = GetMenuItemCount(); info.wID = getNextID(); if(f) { OMenuItem* mi = new OMenuItem(); mi->ownerdrawn = false; if (flags & FLAG_THREADED) { mi->f = [=] { MainFrame::getMainFrame()->addThreadedTask(f); }; } else { mi->f = f; } //mi->f = (flags & FLAG_THREADED) ? [=] { MainFrame::getMainFrame()->addThreadedTask(f); } : f; mi->text = text; mi->parent = this; addItem(mi); info.dwItemData = reinterpret_cast<ULONG_PTR>(mi); } CMenu::InsertMenuItem(index, TRUE, &info); return index; }
void LLXferManager::requestVFile(const LLUUID& local_id, const LLUUID& remote_id, LLAssetType::EType type, LLVFS* vfs, const LLHost& remote_host, void (*callback)(void**,S32,LLExtStat), void** user_data, BOOL is_priority) { LLXfer *xferp; for (xferp = mReceiveList; xferp ; xferp = xferp->mNext) { if (xferp->getXferTypeTag() == LLXfer::XFER_VFILE && (((LLXfer_VFile*)xferp)->matchesLocalFile(local_id, type)) && (((LLXfer_VFile*)xferp)->matchesRemoteFile(remote_id, type)) && (remote_host == xferp->mRemoteHost) && (callback == xferp->mCallback) && (user_data == xferp->mCallbackDataHandle)) { // cout << "requested a xfer already in progress" << endl; return; } } xferp = (LLXfer *) new LLXfer_VFile(); if (xferp) { addToList(xferp, mReceiveList, is_priority); ((LLXfer_VFile *)xferp)->initializeRequest(getNextID(), vfs, local_id, remote_id, type, remote_host, callback, user_data); startPendingDownloads(); } else { llerrs << "Xfer allocation error" << llendl; } }
BOOL CALLBACK System::diDeviceEnumCallback( LPCDIDEVICEINSTANCEW instance, LPVOID referer ) { auto system = reinterpret_cast<System*>( referer ); for ( auto identifier : system->mXInputDeviceIDs ) if ( instance->guidProduct.Data1 == identifier ) return DIENUM_CONTINUE; for ( auto device : system->mDevices ) { if ( device->getHandler() != Device::Handler_DirectInput ) continue; auto diDevice = static_cast<DirectInputDevice*>( device ); if ( diDevice->getInstanceID() == instance->guidInstance ) { if ( device->getSavedStatus() == Device::Status_Disconnected ) system->deviceConnect( device ); else device->setStatus( Device::Status_Connected ); return DIENUM_CONTINUE; } } Device* device = new DirectInputDevice( system, system->getNextID(), instance ); if ( system->isInitializing() ) device->setStatus( Device::Status_Connected ); else system->deviceConnect( device ); system->mDevices.push_back( device ); return DIENUM_CONTINUE; }
void CArchTaskBarWindows::addReceiver(IArchTaskBarReceiver* receiver) { // ignore bogus receiver if (receiver == NULL) { return; } // add receiver if necessary CReceiverToInfoMap::iterator index = m_receivers.find(receiver); if (index == m_receivers.end()) { // add it, creating a new message ID for it CReceiverInfo info; info.m_id = getNextID(); index = m_receivers.insert(std::make_pair(receiver, info)).first; // add ID to receiver mapping m_idTable.insert(std::make_pair(info.m_id, index)); } // add receiver PostMessage(m_hwnd, kAddReceiver, index->second.m_id, 0); }
void CRtTable::addRecord(const QVariantList& values) { // 按顺序添加记录到表中,分析各字段的数据类型,然后根据类型解析值,放到数据库中 if (m_fields.count() == values.count()) { QString strSQL ; strSQL = "INSERT INTO "; strSQL += m_tb_descr.table_name; strSQL += "("; strSQL += m_strfield; strSQL += ") VALUES("; QSqlQuery query(m_db); for (int i = 0 ; i < m_fields.count() ;i++) { const FIELD_PARA_STRU& stField = m_fields[i]; // 添加KEYID if (i == 0) { int keyid = getNextID(); strSQL += QString::number(keyid); strSQL += ","; continue; } strSQL += getSqlValue(stField.data_type,values[i]); if (i < m_fields.count() -1) { strSQL += ","; } } strSQL += ")"; query.exec(strSQL); updateNextID(); } }
void GLRenderer::startMesh(int* id) { *id = getNextID(); activeID = *id; activeMesh.translation = glm::vec3(0,0,0); }
polygon_id NavMesh::addPolygon(NavPoly& p) { p.id = getNextID(); p.parent = this; polygon.push_back(p); return p.id; }
Text& TextSet::addNew(){ Text t(getNextID()); add(t); return get(t.getId()); }