From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/login__cookie_8h-source.html | 190 ++++++++++++++++++++++++++ 1 file changed, 190 insertions(+) create mode 100644 docs/doxygen/nel/login__cookie_8h-source.html (limited to 'docs/doxygen/nel/login__cookie_8h-source.html') diff --git a/docs/doxygen/nel/login__cookie_8h-source.html b/docs/doxygen/nel/login__cookie_8h-source.html new file mode 100644 index 00000000..974c4364 --- /dev/null +++ b/docs/doxygen/nel/login__cookie_8h-source.html @@ -0,0 +1,190 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

login_cookie.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2001 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NeL Network Services.
+00010  * NEVRAX NeL Network Services is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NeL Network Services is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NeL Network Services; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #ifndef NL_LOGIN_COOKIE_H
+00027 #define NL_LOGIN_COOKIE_H
+00028 
+00029 #include "nel/misc/types_nl.h"
+00030 
+00031 #include "nel/misc/stream.h"
+00032 #include "nel/misc/common.h"
+00033 
+00034 
+00035 namespace NLNET {
+00036 
+00037 
+00049 class CLoginCookie
+00050 {
+00051 public:
+00052 
+00053         CLoginCookie (uint32 addr, uint32 id);
+00054         CLoginCookie () : _Valid(false) { }
+00055 
+00056         void serial (NLMISC::IStream &s)
+00057         {
+00058                 // verify that we initialized the cookie before writing it
+00059                 if (!s.isReading() && !_Valid) nlwarning ("serialize a non valid cookie");
+00060 
+00061                 s.serial (_UserAddr);
+00062                 s.serial (_UserKey);
+00063                 s.serial (_UserId);
+00064 
+00065                 if (s.isReading()) _Valid = true;
+00066         }
+00067 
+00068         std::string setToString ()
+00069         {
+00070                 if (_Valid)
+00071                 {
+00072                         char cstr[8*3+2+1];
+00073                         NLMISC::smprintf(cstr, 8*3+2+1, "%08X|%08X|%08X", _UserAddr, _UserKey, _UserId);
+00074                         nlinfo ("setToString %s -> %s", toString().c_str (), cstr);
+00075                         return cstr;
+00076                 }
+00077                 else
+00078                 {
+00079                         return "0|0|0";
+00080                 }
+00081         }
+00082 
+00083         void setFromString (const std::string &str)
+00084         {
+00085                 sscanf(str.c_str(), "%08X|%08X|%08X", &_UserAddr, &_UserKey, &_UserId);
+00086 
+00087                 if(str.empty () || (_UserAddr==0 && _UserKey==0 && _UserId==0))
+00088                         _Valid = 0;
+00089                 else
+00090                         _Valid = 1;
+00091 
+00092                 nlinfo ("setFromString %s -> %s, isValid: %d", str.c_str (), toString().c_str (), _Valid);
+00093         }
+00094 
+00095         std::string toString () const
+00096         {
+00097                 if (_Valid)
+00098                         return "'" + NLMISC::toString("%08X", (unsigned int)_UserAddr) + "|" + NLMISC::toString("%08X", (unsigned int)_UserKey) + "|" + NLMISC::toString("%08X", (unsigned int)_UserId) + "'";
+00099                 else
+00100                         return "<InvalidCookie>";
+00101         }
+00102 
+00103         uint32  getUserAddr () const { nlassert (_Valid); return _UserAddr; }
+00104         uint32  getUserKey () const { nlassert (_Valid); return _UserKey; }
+00105         uint32  getUserId () const { nlassert (_Valid); return _UserId; }
+00106 
+00107         void    set (uint32 ua, uint32 uk, uint32 ui) { _Valid = true; _UserAddr = ua; _UserKey = uk; _UserId = ui; }
+00108 
+00109         bool    isValid() const { return _Valid; }
+00110         void    clear () { _Valid = false; }
+00111 
+00112         uint32  generateKey();
+00113 
+00115         friend bool operator== (const CLoginCookie &c1, const CLoginCookie &c2);
+00116 
+00117 private:
+00118 
+00119         bool    _Valid;
+00120 
+00121         uint32  _UserAddr;
+00122         uint32  _UserKey;
+00123         uint32  _UserId;
+00124 
+00125 };
+00126 
+00127 
+00128 } // NLNET
+00129 
+00130 
+00131 #endif // NL_LOGIN_COOKIE_H
+00132 
+00133 /* End of login_cookie.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1