diff options
author | George Hazan <george.hazan@gmail.com> | 2015-08-11 13:33:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-08-11 13:33:42 +0000 |
commit | 85bd008c039eb1d93894e94fba9d158a42a71a12 (patch) | |
tree | 2d72d10759f6928e9e4b960175d2de01b5cf7e12 /protocols/Xfire/src/xfirefoundbuddys.cpp | |
parent | 222802c2986dcaf029fdfb828b7679bdabfa7bb2 (diff) |
massive code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@14910 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Xfire/src/xfirefoundbuddys.cpp')
-rw-r--r-- | protocols/Xfire/src/xfirefoundbuddys.cpp | 123 |
1 files changed, 62 insertions, 61 deletions
diff --git a/protocols/Xfire/src/xfirefoundbuddys.cpp b/protocols/Xfire/src/xfirefoundbuddys.cpp index dacae8f885..610ff00edd 100644 --- a/protocols/Xfire/src/xfirefoundbuddys.cpp +++ b/protocols/Xfire/src/xfirefoundbuddys.cpp @@ -23,70 +23,71 @@ */ #include "stdafx.h" -#include <vector> -#include <string> #include "xfirefoundbuddys.h" #include "xfireparse.h" #include "variablevalue.h" #include "xdebug.h" -namespace xfirelib { - using namespace std; - - XFireFoundBuddys::XFireFoundBuddys() { - usernames = 0; - fname = 0; - lname = 0; - } - XFireFoundBuddys::~XFireFoundBuddys() { - delete usernames; - delete fname; - delete lname; - } - - void XFireFoundBuddys::parseContent(char *buf, int length, int numberOfAtts) { - int index = 0; - - VariableValue bs; - - XDEBUG2( "Len: %ld\n", length ); - - XDEBUG2( "Byte1: %ld\n", (char)buf[index] ); - XDEBUG2( "Byte2: %ld\n", (char)buf[index+1] ); - XDEBUG2( "Byte3: %ld\n", (char)buf[index+2] ); - - usernames = new vector<string>; - index = readStrings(usernames,buf,index); - - fname = new vector<string>; - index = readStrings(fname,buf,index); - - lname = new vector<string>; - index = readStrings(lname,buf,index); - - } - - int XFireFoundBuddys::readStrings(vector<string> *strings, char *buf, int index) { - VariableValue friends; - index+=friends.readName(buf,index); - index ++; // Ignore 04 - index ++; // Ignore 01 - - index+=friends.readValue(buf,index,2); - - int numberOfStrings = friends.getValueAsLong(); - XDEBUG3( "name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings ); - for(int i = 0 ; i < numberOfStrings ; i++) { - XDEBUG2( "Index: %ld\n", index ); - int length = (unsigned char)buf[index++]; - index++; - index += friends.readValue(buf,index,length); - string stringvalue = string(friends.getValue(),length); - strings->push_back(stringvalue); - XDEBUG3( "String length: %2d : %s\n", length, stringvalue.c_str() ); - } - return index; - } - -}; +using namespace std; + +namespace xfirelib +{ + XFireFoundBuddys::XFireFoundBuddys() + { + usernames = 0; + fname = 0; + lname = 0; + } + XFireFoundBuddys::~XFireFoundBuddys() + { + delete usernames; + delete fname; + delete lname; + } + + void XFireFoundBuddys::parseContent(char *buf, int, int) + { + int index = 0; + + VariableValue bs; + + XDEBUG2("Len: %ld\n", length); + + XDEBUG2("Byte1: %ld\n", (char)buf[index]); + XDEBUG2("Byte2: %ld\n", (char)buf[index + 1]); + XDEBUG2("Byte3: %ld\n", (char)buf[index + 2]); + + usernames = new vector<string>; + index = readStrings(usernames, buf, index); + + fname = new vector<string>; + index = readStrings(fname, buf, index); + + lname = new vector<string>; + index = readStrings(lname, buf, index); + } + + int XFireFoundBuddys::readStrings(vector<string> *strings, char *buf, int index) + { + VariableValue friends; + index += friends.readName(buf, index); + index++; // Ignore 04 + index++; // Ignore 01 + + index += friends.readValue(buf, index, 2); + + int numberOfStrings = friends.getValueAsLong(); + XDEBUG3("name: %s numberOfStrings: %d\n", friends.getName().c_str(), numberOfStrings); + for (int i = 0; i < numberOfStrings; i++) { + XDEBUG2("Index: %ld\n", index); + int length = (unsigned char)buf[index++]; + index++; + index += friends.readValue(buf, index, length); + string stringvalue = string(friends.getValue(), length); + strings->push_back(stringvalue); + XDEBUG3("String length: %2d : %s\n", length, stringvalue.c_str()); + } + return index; + } +} |