summaryrefslogtreecommitdiff
path: root/src/broker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/broker.cc')
-rw-r--r--src/broker.cc116
1 files changed, 55 insertions, 61 deletions
diff --git a/src/broker.cc b/src/broker.cc
index 9d7f728..4cb7787 100644
--- a/src/broker.cc
+++ b/src/broker.cc
@@ -4,15 +4,16 @@
* @author Andreas Aardal Hanssen
* @date 2002-2005
* ----------------------------------------------------------------- **/
-#include <map>
-#include <string>
-
#include "broker.h"
+
#include "convert.h"
#include "operators.h"
#include "recursivedescent.h"
#include "session.h"
+#include <map>
+#include <string>
+
using namespace ::std;
using namespace Binc;
@@ -27,8 +28,7 @@ BrokerFactory::BrokerFactory(void)
//----------------------------------------------------------------------
BrokerFactory::~BrokerFactory(void)
{
- for (map<int, Broker *>::iterator i = brokers.begin();
- i != brokers.end(); ++i)
+ for (map<int, Broker *>::iterator i = brokers.begin(); i != brokers.end(); ++i)
delete i->second;
}
@@ -42,10 +42,9 @@ BrokerFactory &BrokerFactory::getInstance(void)
//----------------------------------------------------------------------
void BrokerFactory::addCapability(const std::string &c)
{
- for (map<int, Broker *>::iterator i = brokers.begin();
- i != brokers.end(); ++i) {
- CapabilityOperator * o;
- o = dynamic_cast<CapabilityOperator*>(i->second->get("CAPABILITY"));
+ for (map<int, Broker *>::iterator i = brokers.begin(); i != brokers.end(); ++i) {
+ CapabilityOperator *o;
+ o = dynamic_cast<CapabilityOperator *>(i->second->get("CAPABILITY"));
if (o != 0) {
o->addCapability(c);
break;
@@ -57,8 +56,7 @@ void BrokerFactory::addCapability(const std::string &c)
void BrokerFactory::assign(const string &fname, Operator *o)
{
int deletable = true;
- for (map<int, Broker *>::iterator i = brokers.begin();
- i != brokers.end(); ++i)
+ for (map<int, Broker *>::iterator i = brokers.begin(); i != brokers.end(); ++i)
if (i->first & o->getState()) {
i->second->assign(fname, o, deletable);
deletable = false;
@@ -86,14 +84,10 @@ Broker *BrokerFactory::getBroker(int state)
}
//----------------------------------------------------------------------
-Broker::Broker(void)
-{
-}
+Broker::Broker(void) {}
//----------------------------------------------------------------------
-Broker::~Broker(void)
-{
-}
+Broker::~Broker(void) {}
//----------------------------------------------------------------------
void Broker::assign(const string &fname, Operator *o, bool deletable)
@@ -119,70 +113,70 @@ Operator::ParseResult Broker::parseStub(Request &command)
string cmd;
switch (expectTag(tag)) {
- case Operator::ACCEPT:
- break;
- case Operator::REJECT:
- session.setLastError("Syntax error; first token must be a tag");
- case Operator::ERROR:
- return Operator::ERROR;
- case Operator::TIMEOUT:
- return Operator::TIMEOUT;
+ case Operator::ACCEPT:
+ break;
+ case Operator::REJECT:
+ session.setLastError("Syntax error; first token must be a tag");
+ case Operator::ERROR:
+ return Operator::ERROR;
+ case Operator::TIMEOUT:
+ return Operator::TIMEOUT;
}
switch (expectSPACE()) {
+ case Operator::ACCEPT:
+ break;
+ case Operator::REJECT:
+ session.setLastError("Syntax error; second token must be a SPACE");
+ case Operator::ERROR:
+ return Operator::ERROR;
+ case Operator::TIMEOUT:
+ return Operator::TIMEOUT;
+ }
+
+ switch (expectAstring(cmd)) {
+ case Operator::ACCEPT:
+ break;
+ case Operator::REJECT:
+ session.setLastError("Syntax error; third token must be a command");
+ case Operator::ERROR:
+ return Operator::ERROR;
+ case Operator::TIMEOUT:
+ return Operator::TIMEOUT;
+ }
+
+ uppercase(cmd);
+
+ if (cmd == "UID") {
+ command.setUidMode();
+
+ switch (expectSPACE()) {
case Operator::ACCEPT:
break;
case Operator::REJECT:
- session.setLastError("Syntax error; second token must be a SPACE");
+ session.setLastError("Syntax error; after UID there"
+ " must come a SPACE");
case Operator::ERROR:
return Operator::ERROR;
case Operator::TIMEOUT:
return Operator::TIMEOUT;
- }
+ }
- switch (expectAstring(cmd)) {
+ switch (expectAstring(cmd)) {
case Operator::ACCEPT:
break;
case Operator::REJECT:
- session.setLastError("Syntax error; third token must be a command");
+ session.setLastError("Syntax error; after UID "
+ "SPACE there must come a command");
case Operator::ERROR:
return Operator::ERROR;
case Operator::TIMEOUT:
return Operator::TIMEOUT;
- }
-
- uppercase(cmd);
-
- if (cmd == "UID") {
- command.setUidMode();
-
- switch (expectSPACE()) {
- case Operator::ACCEPT:
- break;
- case Operator::REJECT:
- session.setLastError("Syntax error; after UID there"
- " must come a SPACE");
- case Operator::ERROR:
- return Operator::ERROR;
- case Operator::TIMEOUT:
- return Operator::TIMEOUT;
- }
-
- switch (expectAstring(cmd)) {
- case Operator::ACCEPT:
- break;
- case Operator::REJECT:
- session.setLastError("Syntax error; after UID "
- "SPACE there must come a command");
- case Operator::ERROR:
- return Operator::ERROR;
- case Operator::TIMEOUT:
- return Operator::TIMEOUT;
- }
-
- uppercase(cmd);
}
+ uppercase(cmd);
+ }
+
command.setTag(tag);
command.setName(cmd);