more fixes
This commit is contained in:
parent
19d75eb917
commit
279faa56b7
@ -22,7 +22,7 @@ LIB = libnntpchan.a
|
|||||||
all: $(EXE) $(TOOL)
|
all: $(EXE) $(TOOL)
|
||||||
|
|
||||||
$(LIB): $(OBJECTS)
|
$(LIB): $(OBJECTS)
|
||||||
$(AR) -q $(LIB) $(OBJECTS)
|
$(AR) -r $(LIB) $(OBJECTS)
|
||||||
|
|
||||||
$(EXE): $(LIB)
|
$(EXE): $(LIB)
|
||||||
$(CXX) -o $(EXE) $(CXXFLAGS) nntpd.cpp $(LIB) $(LD_FLAGS)
|
$(CXX) -o $(EXE) $(CXXFLAGS) nntpd.cpp $(LIB) $(LD_FLAGS)
|
||||||
|
@ -45,23 +45,23 @@ namespace nntpchan
|
|||||||
void NNTPServerHandler::HandleCommand(const std::deque<std::string> & command)
|
void NNTPServerHandler::HandleCommand(const std::deque<std::string> & command)
|
||||||
{
|
{
|
||||||
auto cmd = command[0];
|
auto cmd = command[0];
|
||||||
std::transform(cmd.begin(), cmd.end(), cmd.begin(),
|
std::transform(cmd.begin(), cmd.end(), cmd.begin(), ::toupper);
|
||||||
[](unsigned char ch) { return std::toupper(ch); });
|
|
||||||
std::size_t cmdlen = command.size();
|
std::size_t cmdlen = command.size();
|
||||||
std::cerr << "handle command [" << cmd << "] " << (int) cmdlen << std::endl;
|
std::cerr << "handle command [" << cmd << "] " << (int) cmdlen << std::endl;
|
||||||
if (cmd == "QUIT") {
|
if (cmd == "QUIT") {
|
||||||
Quit();
|
Quit();
|
||||||
return;
|
return;
|
||||||
} else if (cmd == "MODE" ) {
|
} else if (cmd == "MODE" ) {
|
||||||
if(cmdlen == 1) {
|
if(cmdlen == 2) {
|
||||||
// set mode
|
// set mode
|
||||||
SwitchMode(command[1]);
|
SwitchMode(command[1]);
|
||||||
} else if(cmdlen) {
|
} else if(cmdlen) {
|
||||||
// too many arguments
|
// too many arguments
|
||||||
|
QueueLine("500 too many arguments");
|
||||||
} else {
|
} else {
|
||||||
// get mode
|
// get mode
|
||||||
|
QueueLine("500 wrong arguments");
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// unknown command
|
// unknown command
|
||||||
QueueLine("500 Unknown Command");
|
QueueLine("500 Unknown Command");
|
||||||
@ -70,15 +70,17 @@ namespace nntpchan
|
|||||||
|
|
||||||
void NNTPServerHandler::SwitchMode(const std::string & mode)
|
void NNTPServerHandler::SwitchMode(const std::string & mode)
|
||||||
{
|
{
|
||||||
if (mode == "READER") {
|
std::string m = mode;
|
||||||
m_mode = mode;
|
std::transform(m.begin(), m.end(), m.begin(), ::toupper);
|
||||||
|
if (m == "READER") {
|
||||||
|
m_mode = m;
|
||||||
if(PostingAllowed()) {
|
if(PostingAllowed()) {
|
||||||
QueueLine("200 Posting is permitted yo");
|
QueueLine("200 Posting is permitted yo");
|
||||||
} else {
|
} else {
|
||||||
QueueLine("201 Posting is not permitted yo");
|
QueueLine("201 Posting is not permitted yo");
|
||||||
}
|
}
|
||||||
} else if (mode == "STREAM") {
|
} else if (m == "STREAM") {
|
||||||
m_mode = mode;
|
m_mode = m;
|
||||||
if (PostingAllowed()) {
|
if (PostingAllowed()) {
|
||||||
QueueLine("203 Streaming enabled");
|
QueueLine("203 Streaming enabled");
|
||||||
} else {
|
} else {
|
||||||
|
Reference in New Issue
Block a user