]> git.stg.codes - stg.git/blobdiff - stglibs/srvconf.lib/parser_send_message.cpp
Moved base and utility classes from global scope.
[stg.git] / stglibs / srvconf.lib / parser_send_message.cpp
index 77aba248dd14c2ffd6d2dd9a99fc1e4c1a2c859f..318cc8ebb5e48cdf4cb0bb4796604e2cca0f2683 100644 (file)
  *    Author : Maxim Mamontov <faust@stargazer.dp.ua>
  */
 
-#include "stg/parser_send_message.h"
+#include "parser_send_message.h"
 
 #include <cstddef>
 
 #include <strings.h>
 
-PARSER_SEND_MESSAGE::PARSER_SEND_MESSAGE()
+using namespace STG;
+
+SEND_MESSAGE::PARSER::PARSER()
     : callback(NULL),
       data(NULL),
       depth(0)
 {
 }
 //-----------------------------------------------------------------------------
-int  PARSER_SEND_MESSAGE::ParseStart(const char * el, const char ** attr)
+int SEND_MESSAGE::PARSER::ParseStart(const char * el, const char ** attr)
 {
 depth++;
 if (depth == 1)
@@ -41,19 +43,22 @@ if (depth == 1)
 return 0;
 }
 //-----------------------------------------------------------------------------
-void PARSER_SEND_MESSAGE::ParseEnd(const char * /*el*/)
+void SEND_MESSAGE::PARSER::ParseEnd(const char * /*el*/)
 {
 depth--;
 }
 //-----------------------------------------------------------------------------
-void PARSER_SEND_MESSAGE::ParseAnswer(const char * /*el*/, const char **attr)
+void SEND_MESSAGE::PARSER::ParseAnswer(const char * /*el*/, const char **attr)
 {
+if (!callback)
+    return;
 if (attr && attr[0] && attr[1])
-    if (callback)
-        callback(attr[1], data);
+    callback(strcasecmp(attr[1], "ok") == 0, attr[1], data);
+else
+    callback(false, "Invalid response.", data);
 }
 //-----------------------------------------------------------------------------
-void PARSER_SEND_MESSAGE::SetCallback(CALLBACK f, void * d)
+void SEND_MESSAGE::PARSER::SetCallback(CALLBACK f, void * d)
 {
 callback = f;
 data = d;