CmdResult CommandUser::HandleLocal(LocalUser* user, const Params& parameters) { /* A user may only send the USER command once */ if (!(user->registered & REG_USER)) { if (!ServerInstance->IsIdent(parameters[0])) { user->WriteNumeric(ERR_INVALIDUSERNAME, name, "Your username is not valid"); return CMD_FAILURE; } else { user->ChangeIdent(parameters[0]); user->ChangeRealName(parameters[3]); user->registered = (user->registered | REG_USER); } } else { user->WriteNumeric(ERR_ALREADYREGISTERED, "You may not reregister"); user->CommandFloodPenalty += 1000; return CMD_FAILURE; } /* parameters 2 and 3 are local and remote hosts, and are ignored */ return CheckRegister(user); }
void SysReg::OnButtonRegster() { // TODO: Add your control notification handler code here UpdateData(TRUE); if(CheckRegister(m_sn)) { HKEY hKey; RegCreateKey(HKEY_LOCAL_MACHINE, theStr, &hKey); RegSetValue(hKey, NULL, REG_SZ, m_sn, m_sn.GetLength()); RegCloseKey(hKey); ((CMainFrame*)AfxGetMainWnd())->m_bMenuItemDataOption = true; MessageBox("×¢²á³É¹¦"); CDialog::OnOK(); } else MessageBox("ʧ°Ü£¬·Ç·¨×¢²áÂë"); }
bool CMorphAutomatBuilder::IsValid() const { // en empty automat is OK if (!m_pRoot) return true; // checking register if (!CheckRegister()) return false; // checking CTrieNodeBuild::m_IncomingRelationsCount map<const CTrieNodeBuild*, size_t> Node2Incoming; m_pRoot->GetIncomingRelationsCountRecursive(Node2Incoming); if (!m_pRoot->CheckIncomingRelationsCountRecursive(Node2Incoming)) return false; return true; };
CmdResult CommandUser::HandleLocal(const std::vector<std::string>& parameters, LocalUser *user) { /* A user may only send the USER command once */ if (!(user->registered & REG_USER)) { if (!ServerInstance->IsIdent(parameters[0])) { /* * RFC says we must use this numeric, so we do. Let's make it a little more nub friendly though. :) * -- Craig, and then w00t. */ user->WriteNumeric(ERR_NEEDMOREPARAMS, "USER :Your username is not valid"); return CMD_FAILURE; } else { /* * The ident field is IDENTMAX+2 in size to account for +1 for the optional * ~ character, and +1 for null termination, therefore we can safely use up to * IDENTMAX here. */ user->ChangeIdent(parameters[0]); user->fullname.assign(parameters[3].empty() ? "No info" : parameters[3], 0, ServerInstance->Config->Limits.MaxGecos); user->registered = (user->registered | REG_USER); } } else { user->WriteNumeric(ERR_ALREADYREGISTERED, ":You may not reregister"); user->CommandFloodPenalty += 1000; return CMD_FAILURE; } /* parameters 2 and 3 are local and remote hosts, and are ignored */ return CheckRegister(user); }