operator-noop.cc (2643B)
1 /* -*- Mode: c++; -*- */ 2 /* -------------------------------------------------------------------- 3 * Filename: 4 * operator-noop.cc 5 * 6 * Description: 7 * Operator for the NOOP command. 8 * 9 * Authors: 10 * Andreas Aardal Hanssen <andreas-binc curly bincimap spot org> 11 * 12 * Bugs: 13 * 14 * ChangeLog: 15 * 16 * -------------------------------------------------------------------- 17 * Copyright 2002-2005 Andreas Aardal Hanssen 18 * 19 * This program is free software; you can redistribute it and/or modify 20 * it under the terms of the GNU General Public License as published by 21 * the Free Software Foundation; either version 2 of the License, or 22 * (at your option) any later version. 23 * 24 * This program is distributed in the hope that it will be useful, 25 * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 * GNU General Public License for more details. 28 * 29 * You should have received a copy of the GNU General Public License 30 * along with this program; if not, write to the Free Software 31 * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. 32 * -------------------------------------------------------------------- 33 */ 34 #ifdef HAVE_CONFIG_H 35 #include <config.h> 36 #endif 37 38 #include <string> 39 #include <iostream> 40 41 #include "io.h" 42 43 #include "recursivedescent.h" 44 #include "session.h" 45 #include "depot.h" 46 #include "operators.h" 47 48 using namespace ::std; 49 using namespace Binc; 50 51 //---------------------------------------------------------------------- 52 NoopOperator::NoopOperator(void) 53 { 54 } 55 56 //---------------------------------------------------------------------- 57 NoopOperator::~NoopOperator(void) 58 { 59 } 60 61 //---------------------------------------------------------------------- 62 const string NoopOperator::getName(void) const 63 { 64 return "NOOP"; 65 } 66 67 //---------------------------------------------------------------------- 68 int NoopOperator::getState(void) const 69 { 70 return Session::NONAUTHENTICATED 71 | Session::AUTHENTICATED 72 | Session::SELECTED; 73 } 74 75 //---------------------------------------------------------------------- 76 Operator::ProcessResult NoopOperator::process(Depot &depot, 77 Request &command) 78 { 79 return OK; 80 } 81 82 //---------------------------------------------------------------------- 83 Operator::ParseResult NoopOperator::parse(Request &c_in) const 84 { 85 Session &session = Session::getInstance(); 86 87 if (c_in.getUidMode()) 88 return REJECT; 89 90 Operator::ParseResult res; 91 if ((res = expectCRLF()) != ACCEPT) { 92 session.setLastError("Expected CRLF after NOOP"); 93 return res; 94 } 95 96 c_in.setName("NOOP"); 97 return ACCEPT; 98 }