| 4037 | } |
| 4038 | |
| 4039 | void CServer::ConAddSqlServer(IConsole::IResult *pResult, void *pUserData) |
| 4040 | { |
| 4041 | CServer *pSelf = (CServer *)pUserData; |
| 4042 | |
| 4043 | if(!MysqlAvailable()) |
| 4044 | { |
| 4045 | pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "can't add MySQL server: compiled without MySQL support"); |
| 4046 | return; |
| 4047 | } |
| 4048 | |
| 4049 | if(!pSelf->Config()->m_SvUseSql) |
| 4050 | return; |
| 4051 | |
| 4052 | if(pResult->NumArguments() != 7 && pResult->NumArguments() != 8) |
| 4053 | { |
| 4054 | pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "7 or 8 arguments are required"); |
| 4055 | return; |
| 4056 | } |
| 4057 | |
| 4058 | CMysqlConfig Config; |
| 4059 | bool Write; |
| 4060 | if(str_comp_nocase(pResult->GetString(0), "r") == 0) |
| 4061 | Write = false; |
| 4062 | else if(str_comp_nocase(pResult->GetString(0), "w") == 0) |
| 4063 | Write = true; |
| 4064 | else |
| 4065 | { |
| 4066 | pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", "choose either 'r' for SqlReadServer or 'w' for SqlWriteServer"); |
| 4067 | return; |
| 4068 | } |
| 4069 | |
| 4070 | str_copy(Config.m_aDatabase, pResult->GetString(1), sizeof(Config.m_aDatabase)); |
| 4071 | str_copy(Config.m_aPrefix, pResult->GetString(2), sizeof(Config.m_aPrefix)); |
| 4072 | str_copy(Config.m_aUser, pResult->GetString(3), sizeof(Config.m_aUser)); |
| 4073 | str_copy(Config.m_aPass, pResult->GetString(4), sizeof(Config.m_aPass)); |
| 4074 | str_copy(Config.m_aIp, pResult->GetString(5), sizeof(Config.m_aIp)); |
| 4075 | Config.m_aBindaddr[0] = '\0'; |
| 4076 | Config.m_Port = pResult->GetInteger(6); |
| 4077 | Config.m_Setup = pResult->NumArguments() == 8 ? pResult->GetInteger(7) : true; |
| 4078 | |
| 4079 | char aBuf[512]; |
| 4080 | str_format(aBuf, sizeof(aBuf), |
| 4081 | "Adding new Sql%sServer: DB: '%s' Prefix: '%s' User: '%s' IP: <{%s}> Port: %d", |
| 4082 | Write ? "Write" : "Read", |
| 4083 | Config.m_aDatabase, Config.m_aPrefix, Config.m_aUser, Config.m_aIp, Config.m_Port); |
| 4084 | pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "server", aBuf); |
| 4085 | pSelf->DbPool()->RegisterMysqlDatabase(Write ? CDbConnectionPool::WRITE : CDbConnectionPool::READ, &Config); |
| 4086 | } |
| 4087 | |
| 4088 | void CServer::ConDumpSqlServers(IConsole::IResult *pResult, void *pUserData) |
| 4089 | { |
nothing calls this directly
no test coverage detected