Dear me, many changes
Rewrote Lang (still does not work though!) New String class funcs+name Added Queue class Added MD5 class + functions
This commit is contained in:
		@@ -52,10 +52,10 @@ public:
 | 
				
			|||||||
		friend class CmdMngr;
 | 
							friend class CmdMngr;
 | 
				
			||||||
		CPluginMngr::CPlugin* plugin;
 | 
							CPluginMngr::CPlugin* plugin;
 | 
				
			||||||
		CmdMngr* parent;
 | 
							CmdMngr* parent;
 | 
				
			||||||
		CString command;
 | 
							String command;
 | 
				
			||||||
		CString argument;
 | 
							String argument;
 | 
				
			||||||
		CString commandline;
 | 
							String commandline;
 | 
				
			||||||
		CString info;
 | 
							String info;
 | 
				
			||||||
		bool listable;
 | 
							bool listable;
 | 
				
			||||||
		int function;
 | 
							int function;
 | 
				
			||||||
		int flags;
 | 
							int flags;
 | 
				
			||||||
@@ -100,7 +100,7 @@ private:
 | 
				
			|||||||
	CmdLink* clcmdlist;
 | 
						CmdLink* clcmdlist;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	struct CmdPrefix {
 | 
						struct CmdPrefix {
 | 
				
			||||||
		CString name;
 | 
							String name;
 | 
				
			||||||
		CmdMngr* parent;
 | 
							CmdMngr* parent;
 | 
				
			||||||
		CmdLink* list;
 | 
							CmdLink* list;
 | 
				
			||||||
		CmdPrefix* next;
 | 
							CmdPrefix* next;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -88,7 +88,7 @@ public:
 | 
				
			|||||||
		{
 | 
							{
 | 
				
			||||||
			int paramId;				// the message parameter id
 | 
								int paramId;				// the message parameter id
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			CString sValue;				// value (string)
 | 
								String sValue;				// value (string)
 | 
				
			||||||
			float fValue;				// value (float)
 | 
								float fValue;				// value (float)
 | 
				
			||||||
			int iValue;					// value (int)
 | 
								int iValue;					// value (int)
 | 
				
			||||||
			int type;					// type (can be int, float, string)
 | 
								int type;					// type (can be int, float, string)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -52,7 +52,7 @@ File::operator bool ( ) const
 | 
				
			|||||||
  return fp && !feof(fp);
 | 
					  return fp && !feof(fp);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
File& operator<<( File& f, const CString& n )
 | 
					File& operator<<( File& f, const String& n )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if ( f ) fputs( n.c_str() , f.fp ) ;
 | 
					  if ( f ) fputs( n.c_str() , f.fp ) ;
 | 
				
			||||||
  return f;
 | 
					  return f;
 | 
				
			||||||
@@ -77,7 +77,7 @@ File& operator<<( File& f, const char& c )
 | 
				
			|||||||
  return f;
 | 
					  return f;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
File& operator>>( File& f, CString& n )
 | 
					File& operator>>( File& f, String& n )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  if ( !f ) return f;
 | 
					  if ( !f ) return f;
 | 
				
			||||||
  char temp[1024];
 | 
					  char temp[1024];
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,7 +30,7 @@
 | 
				
			|||||||
*/
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <stdio.h>
 | 
					#include <stdio.h>
 | 
				
			||||||
#include "CString.h"
 | 
					#include "String.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// *****************************************************
 | 
					// *****************************************************
 | 
				
			||||||
// class File
 | 
					// class File
 | 
				
			||||||
@@ -44,11 +44,11 @@ public:
 | 
				
			|||||||
	File( const char* n, const char* m );
 | 
						File( const char* n, const char* m );
 | 
				
			||||||
	~File( );
 | 
						~File( );
 | 
				
			||||||
	operator bool ( ) const;
 | 
						operator bool ( ) const;
 | 
				
			||||||
	friend File& operator<<( File& f, const CString& n );
 | 
						friend File& operator<<( File& f, const String& n );
 | 
				
			||||||
	friend File& operator<<( File& f, const char* n );
 | 
						friend File& operator<<( File& f, const char* n );
 | 
				
			||||||
	friend File& operator<<( File& f, const char& c );
 | 
						friend File& operator<<( File& f, const char& c );
 | 
				
			||||||
	friend File& operator<<( File& f, int n );
 | 
						friend File& operator<<( File& f, int n );
 | 
				
			||||||
	friend File& operator>>( File& f, CString& n );
 | 
						friend File& operator>>( File& f, String& n );
 | 
				
			||||||
	friend File& operator>>( File& f, char* n );
 | 
						friend File& operator>>( File& f, char* n );
 | 
				
			||||||
	int getline( char* buf, int sz );
 | 
						int getline( char* buf, int sz );
 | 
				
			||||||
	File& skipWs( );
 | 
						File& skipWs( );
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -35,14 +35,28 @@
 | 
				
			|||||||
#define LANG_SERVER 0
 | 
					#define LANG_SERVER 0
 | 
				
			||||||
#define LANG_PLAYER -1
 | 
					#define LANG_PLAYER -1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct md5Pair
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						String file;
 | 
				
			||||||
 | 
						String val;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct keyEntry
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						String key;
 | 
				
			||||||
 | 
						uint32_t hash;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct sKeyDef
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						sKeyDef() { key = -1; def = 0; }
 | 
				
			||||||
 | 
						~sKeyDef() { if (def) delete def; }
 | 
				
			||||||
 | 
						int key;
 | 
				
			||||||
 | 
						String *def;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class CLangMngr
 | 
					class CLangMngr
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct sKeyDef
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		const char *key;
 | 
					 | 
				
			||||||
		const char *def;
 | 
					 | 
				
			||||||
	};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	class CLang
 | 
						class CLang
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
	public:
 | 
						public:
 | 
				
			||||||
@@ -51,7 +65,7 @@ class CLangMngr
 | 
				
			|||||||
		~CLang();
 | 
							~CLang();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		const char *GetDef(const char *key);
 | 
							const char *GetDef(const char *key);
 | 
				
			||||||
		void MergeDefinitions(CVector<sKeyDef> & vec);
 | 
							void MergeDefinitions(CQueue <sKeyDef*> & vec);
 | 
				
			||||||
		void Clear();
 | 
							void Clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		friend bool operator == (const CLang &left, const char *right)
 | 
							friend bool operator == (const CLang &left, const char *right)
 | 
				
			||||||
@@ -59,9 +73,9 @@ class CLangMngr
 | 
				
			|||||||
			return strcmp(left.m_LanguageName, right)==0 ? true : false;
 | 
								return strcmp(left.m_LanguageName, right)==0 ? true : false;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		const char *GetName() { return m_LanguageName; }
 | 
							const char *GetName() { return m_LanguageName; }
 | 
				
			||||||
		void Dump();
 | 
					 | 
				
			||||||
		bool Save(FILE *fp);
 | 
							bool Save(FILE *fp);
 | 
				
			||||||
		bool Load(FILE *fp);
 | 
							bool Load(FILE *fp);
 | 
				
			||||||
 | 
							void SetMngr(CLangMngr *l) { lman = l; }
 | 
				
			||||||
	private:
 | 
						private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		static uint32_t MakeHash(const char *src, bool makeLower = false);
 | 
							static uint32_t MakeHash(const char *src, bool makeLower = false);
 | 
				
			||||||
@@ -69,56 +83,62 @@ class CLangMngr
 | 
				
			|||||||
		class LangEntry
 | 
							class LangEntry
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			uint32_t m_DefHash;
 | 
								uint32_t m_DefHash;
 | 
				
			||||||
			uint32_t m_KeyHash;
 | 
								int key;
 | 
				
			||||||
			char *m_pKey;
 | 
								String m_pDef;
 | 
				
			||||||
			char *m_pDef;
 | 
					 | 
				
			||||||
			void SetKey(const char *pKey);
 | 
					 | 
				
			||||||
			void SetDef(const char *pDef);
 | 
					 | 
				
			||||||
		public:
 | 
							public:
 | 
				
			||||||
 | 
								void SetKey(int key);
 | 
				
			||||||
 | 
								void SetDef(const char *pDef);
 | 
				
			||||||
			uint32_t GetDefHash();
 | 
								uint32_t GetDefHash();
 | 
				
			||||||
			uint32_t GetKeyHash();
 | 
					
 | 
				
			||||||
			const char *GetKey();
 | 
								int GetKey();
 | 
				
			||||||
			const char *GetDef();
 | 
								const char *GetDef();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			LangEntry();
 | 
								LangEntry();
 | 
				
			||||||
			LangEntry(const char *pKey);
 | 
								LangEntry(int key);
 | 
				
			||||||
			LangEntry(const char *pKey, const char *pDef);
 | 
								LangEntry(int key, const char *pDef);
 | 
				
			||||||
			LangEntry(const LangEntry &other);
 | 
								LangEntry(const LangEntry &other);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			void operator= (const char *pNewDef);
 | 
					 | 
				
			||||||
			bool operator== (uint32_t hash);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			void Clear();
 | 
								void Clear();
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		LangEntry & GetEntry(const char *key);
 | 
							LangEntry * GetEntry(int key);
 | 
				
			||||||
		typedef CVector<LangEntry>	LookUpVec;
 | 
							typedef CVector<LangEntry*>	LookUpVec;
 | 
				
			||||||
		typedef LookUpVec::iterator	LookUpVecIter;
 | 
							typedef LookUpVec::iterator	LookUpVecIter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		char m_LanguageName[3];
 | 
							char m_LanguageName[3];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		LookUpVec m_LookUpTable;
 | 
							LookUpVec m_LookUpTable;
 | 
				
			||||||
 | 
							CLangMngr *lman;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void MergeDefinitions(const char *lang, CVector<sKeyDef> &tmpVec);
 | 
						void MergeDefinitions(const char *lang, CQueue <sKeyDef*> &tmpVec);
 | 
				
			||||||
	static size_t strip(char *str, char *newstr, bool makelower=false);
 | 
						static size_t strip(char *str, char *newstr, bool makelower=false);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	typedef CVector<CLang> LangVec;
 | 
						typedef CVector<CLang*> LangVec;
 | 
				
			||||||
	typedef LangVec::iterator LangVecIter;
 | 
						typedef CVector<CLang*>::iterator LangVecIter;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	LangVec m_Languages;
 | 
						LangVec m_Languages;
 | 
				
			||||||
 | 
						CVector<md5Pair *> FileList;
 | 
				
			||||||
 | 
						CVector<keyEntry*> KeyList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	CLang & GetLang(const char *name);
 | 
						CLang * GetLang(const char *name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int m_CurGlobId;
 | 
						int m_CurGlobId;
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	int MergeDefinitionFile(const char *file);
 | 
						int MergeDefinitionFile(const char *file);
 | 
				
			||||||
	void Dump();
 | 
					 | 
				
			||||||
	const char *GetDef(const char *langName, const char *key);
 | 
						const char *GetDef(const char *langName, const char *key);
 | 
				
			||||||
	const char *Format(const char *src, ...);
 | 
						const char *Format(const char *src, ...);
 | 
				
			||||||
	char *FormatAmxString(AMX *amx, cell *params, int parm, int &len);
 | 
						char *FormatAmxString(AMX *amx, cell *params, int parm, int &len);
 | 
				
			||||||
	bool Save(const char *filename);
 | 
						bool Save(const char *filename);
 | 
				
			||||||
	bool Load(const char *filename);
 | 
						bool Load(const char *filename);
 | 
				
			||||||
 | 
						bool LoadCache(const char *filename);
 | 
				
			||||||
 | 
						bool SaveCache(const char *filename);
 | 
				
			||||||
 | 
						int GetKeyEntry(String &key);
 | 
				
			||||||
 | 
						int GetKeyEntry(const char *key);
 | 
				
			||||||
 | 
						int GetKeyHash(int key);
 | 
				
			||||||
 | 
						const char *GetKey(int key);
 | 
				
			||||||
 | 
						int AddKeyEntry(String &key);
 | 
				
			||||||
 | 
						uint32_t MakeHash(const char *src, bool makeLower);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int GetLangsNum();
 | 
						int GetLangsNum();
 | 
				
			||||||
	const char *GetLangName(int langId);
 | 
						const char *GetLangName(int langId);
 | 
				
			||||||
@@ -127,6 +147,9 @@ public:
 | 
				
			|||||||
	// When a language id in a format string in FormatAmxString is 0, the glob id decides which language to take.
 | 
						// When a language id in a format string in FormatAmxString is 0, the glob id decides which language to take.
 | 
				
			||||||
	void SetDefLang(int id);
 | 
						void SetDefLang(int id);
 | 
				
			||||||
	void Clear();
 | 
						void Clear();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						CLangMngr();
 | 
				
			||||||
 | 
						~CLangMngr();
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif //_INCLUDE_CLANG_H
 | 
					#endif //_INCLUDE_CLANG_H
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -63,7 +63,7 @@ public:
 | 
				
			|||||||
	friend class LogEventsMngr;
 | 
						friend class LogEventsMngr;
 | 
				
			||||||
	friend class CLogEvent;
 | 
						friend class CLogEvent;
 | 
				
			||||||
	LogEventsMngr* parent;
 | 
						LogEventsMngr* parent;
 | 
				
			||||||
    CString text;
 | 
					    String text;
 | 
				
			||||||
    int logid;
 | 
					    int logid;
 | 
				
			||||||
    int pos;
 | 
					    int pos;
 | 
				
			||||||
    int result;
 | 
					    int result;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,7 +40,7 @@ class MenuMngr
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  struct MenuIdEle
 | 
					  struct MenuIdEle
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    CString name;
 | 
					    String name;
 | 
				
			||||||
    AMX* amx;
 | 
					    AMX* amx;
 | 
				
			||||||
    MenuIdEle* next;
 | 
					    MenuIdEle* next;
 | 
				
			||||||
	int id;
 | 
						int id;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,8 +40,8 @@
 | 
				
			|||||||
class CCVar
 | 
					class CCVar
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    cvar_t cvar;
 | 
					    cvar_t cvar;
 | 
				
			||||||
    CString name;
 | 
					    String name;
 | 
				
			||||||
    CString plugin;
 | 
					    String plugin;
 | 
				
			||||||
public:	
 | 
					public:	
 | 
				
			||||||
    CCVar( const char* pname, const char* pplugin, 
 | 
					    CCVar( const char* pname, const char* pplugin, 
 | 
				
			||||||
		int pflags, float pvalue ) : name(pname) , plugin(pplugin ) {
 | 
							int pflags, float pvalue ) : name(pname) , plugin(pplugin ) {
 | 
				
			||||||
@@ -68,9 +68,9 @@ class CPlayer
 | 
				
			|||||||
public:
 | 
					public:
 | 
				
			||||||
	edict_t* pEdict;
 | 
						edict_t* pEdict;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	CString name;
 | 
						String name;
 | 
				
			||||||
	CString ip;
 | 
						String ip;
 | 
				
			||||||
	CString team;
 | 
						String team;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool initialized;
 | 
						bool initialized;
 | 
				
			||||||
	bool ingame;
 | 
						bool ingame;
 | 
				
			||||||
@@ -98,7 +98,7 @@ public:
 | 
				
			|||||||
	int death_killer;
 | 
						int death_killer;
 | 
				
			||||||
	int death_victim;
 | 
						int death_victim;
 | 
				
			||||||
	bool death_tk;
 | 
						bool death_tk;
 | 
				
			||||||
	CString death_weapon;
 | 
						String death_weapon;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	Vector lastTrace;
 | 
						Vector lastTrace;
 | 
				
			||||||
	Vector thisTrace;
 | 
						Vector thisTrace;
 | 
				
			||||||
@@ -149,7 +149,7 @@ public:
 | 
				
			|||||||
// class ForceObject
 | 
					// class ForceObject
 | 
				
			||||||
// *****************************************************
 | 
					// *****************************************************
 | 
				
			||||||
class ForceObject {
 | 
					class ForceObject {
 | 
				
			||||||
    CString filename;
 | 
					    String filename;
 | 
				
			||||||
    FORCE_TYPE type;
 | 
					    FORCE_TYPE type;
 | 
				
			||||||
    Vector mins;
 | 
					    Vector mins;
 | 
				
			||||||
    Vector maxs;
 | 
					    Vector maxs;
 | 
				
			||||||
@@ -203,7 +203,7 @@ public:
 | 
				
			|||||||
// *****************************************************
 | 
					// *****************************************************
 | 
				
			||||||
class CScript
 | 
					class CScript
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	CString filename;
 | 
						String filename;
 | 
				
			||||||
	AMX* amx;
 | 
						AMX* amx;
 | 
				
			||||||
	void* code;
 | 
						void* code;
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
@@ -220,7 +220,7 @@ public:
 | 
				
			|||||||
class TeamIds
 | 
					class TeamIds
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  struct TeamEle {
 | 
					  struct TeamEle {
 | 
				
			||||||
    CString name;
 | 
					    String name;
 | 
				
			||||||
    int id;
 | 
					    int id;
 | 
				
			||||||
	char tid;
 | 
						char tid;
 | 
				
			||||||
	static char uid;
 | 
						static char uid;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -69,7 +69,7 @@ struct amxx_module_info_s
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class CModule 
 | 
					class CModule 
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	CString m_Filename;				// Filename
 | 
						String m_Filename;				// Filename
 | 
				
			||||||
	bool m_Metamod;					// Using metamod?
 | 
						bool m_Metamod;					// Using metamod?
 | 
				
			||||||
	bool m_Amxx;					// Using new module interface?
 | 
						bool m_Amxx;					// Using new module interface?
 | 
				
			||||||
	module_info_s* m_InfoOld;		// module info (old module interface)
 | 
						module_info_s* m_InfoOld;		// module info (old module interface)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -59,10 +59,10 @@ public:
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
		AMX amx;
 | 
							AMX amx;
 | 
				
			||||||
		void* code;
 | 
							void* code;
 | 
				
			||||||
		CString name;
 | 
							String name;
 | 
				
			||||||
		CString version;
 | 
							String version;
 | 
				
			||||||
		CString title;
 | 
							String title;
 | 
				
			||||||
		CString author;
 | 
							String author;
 | 
				
			||||||
		int paused_fun;
 | 
							int paused_fun;
 | 
				
			||||||
		int status;
 | 
							int status;
 | 
				
			||||||
		CPlugin* next;
 | 
							CPlugin* next;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										125
									
								
								amxmodx/CQueue.h
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										125
									
								
								amxmodx/CQueue.h
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,125 @@
 | 
				
			|||||||
 | 
					/* AMX Mod X
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					* by the AMX Mod X Development Team
 | 
				
			||||||
 | 
					*  originally developed by OLO
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*  This program is free software; you can redistribute it and/or modify it
 | 
				
			||||||
 | 
					*  under the terms of the GNU General Public License as published by the
 | 
				
			||||||
 | 
					*  Free Software Foundation; either version 2 of the License, or (at
 | 
				
			||||||
 | 
					*  your option) any later version.
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*  This program is distributed in the hope that it will be useful, but
 | 
				
			||||||
 | 
					*  WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 | 
				
			||||||
 | 
					*  General Public License for more details.
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*  You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					*  along with this program; if not, write to the Free Software Foundation,
 | 
				
			||||||
 | 
					*  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 | 
				
			||||||
 | 
					*
 | 
				
			||||||
 | 
					*  In addition, as a special exception, the author gives permission to
 | 
				
			||||||
 | 
					*  link the code of this program with the Half-Life Game Engine ("HL
 | 
				
			||||||
 | 
					*  Engine") and Modified Game Libraries ("MODs") developed by Valve,
 | 
				
			||||||
 | 
					*  L.L.C ("Valve"). You must obey the GNU General Public License in all
 | 
				
			||||||
 | 
					*  respects for all of the code used other than the HL Engine and MODs
 | 
				
			||||||
 | 
					*  from Valve. If you modify this file, you may extend this exception
 | 
				
			||||||
 | 
					*  to your version of the file, but you are not obligated to do so. If
 | 
				
			||||||
 | 
					*  you do not wish to do so, delete this exception statement from your
 | 
				
			||||||
 | 
					*  version.
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//by David "BAILOPAN" Anderson
 | 
				
			||||||
 | 
					#ifndef _INCLUDE_CQUEUE_H
 | 
				
			||||||
 | 
					#define _INCLUDE_CQUEUE_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					template <class T>
 | 
				
			||||||
 | 
					class CQueue
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						class CQueueItem
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
						public:
 | 
				
			||||||
 | 
							CQueueItem(const T &i, CQueueItem *n)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								item = i;
 | 
				
			||||||
 | 
								next = n;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							CQueueItem *GetNext()
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return next;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							T & GetItem()
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return item;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							void SetNext(CQueueItem *n)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								next = n;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						private:
 | 
				
			||||||
 | 
							T item;
 | 
				
			||||||
 | 
							CQueueItem *next;
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						CQueue()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							mSize = 0;
 | 
				
			||||||
 | 
							mFirst = NULL;
 | 
				
			||||||
 | 
							mLast = NULL;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bool empty()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return ((mSize==0)?true:false);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void push(const T &v)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							CQueueItem *p = new CQueueItem(v, NULL);
 | 
				
			||||||
 | 
							if (empty())
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								mFirst = p;
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								mLast->SetNext(p);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							mLast = p;
 | 
				
			||||||
 | 
							mSize++;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void pop()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (mFirst == mLast)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								delete mFirst;
 | 
				
			||||||
 | 
								mFirst = NULL;
 | 
				
			||||||
 | 
								mLast = NULL;
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								CQueueItem *p = mFirst->GetNext();
 | 
				
			||||||
 | 
								delete mFirst;
 | 
				
			||||||
 | 
								mFirst = p;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							mSize--;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						T & front()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return mFirst->GetItem();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						T & back()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return mLast->GetItem();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						unsigned int size()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return mSize;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
						CQueueItem *mFirst;
 | 
				
			||||||
 | 
						CQueueItem *mLast;
 | 
				
			||||||
 | 
						unsigned int mSize;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#endif //_INCLUDE_CQUEUE_H
 | 
				
			||||||
@@ -33,30 +33,67 @@
 | 
				
			|||||||
#define _INCLUDE_CSTRING_H
 | 
					#define _INCLUDE_CSTRING_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//by David "BAILOPAN" Anderson
 | 
					//by David "BAILOPAN" Anderson
 | 
				
			||||||
class CString
 | 
					class String
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	CString() { v = NULL; mSize = 0; }
 | 
						String() 
 | 
				
			||||||
	~CString() { if (v) delete [] v; }
 | 
						{
 | 
				
			||||||
 | 
							v = NULL;
 | 
				
			||||||
 | 
							mSize = 0;
 | 
				
			||||||
 | 
							cSize = 0;
 | 
				
			||||||
 | 
							Grow(2);
 | 
				
			||||||
 | 
							assign("");
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//added these for amxx
 | 
						~String()
 | 
				
			||||||
	CString(const char *src) { v = NULL; mSize = 0; assign(src); }
 | 
						{ 
 | 
				
			||||||
	CString(CString &src) { v = NULL; mSize = 0; assign(src.c_str()); }
 | 
							if (v) 
 | 
				
			||||||
 | 
								delete [] v; 
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						String(const char *src) 
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							v = NULL; 
 | 
				
			||||||
 | 
							mSize = 0; 
 | 
				
			||||||
 | 
							cSize = 0; assign(src); 
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						String(String &src) 
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							v = NULL;
 | 
				
			||||||
 | 
							mSize = 0;
 | 
				
			||||||
 | 
							cSize = 0;
 | 
				
			||||||
 | 
							assign(src.c_str()); 
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	const char *c_str() { return v?v:""; }
 | 
						const char *c_str() { return v?v:""; }
 | 
				
			||||||
	const char *c_str() const { return v?v:""; }
 | 
						const char *c_str() const { return v?v:""; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void append(const char *t)
 | 
						void append(const char *t)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		Grow(strlen(v) + strlen(t));
 | 
							Grow(cSize + strlen(t));
 | 
				
			||||||
		strcat(v, t);
 | 
							strcat(v, t);
 | 
				
			||||||
 | 
							cSize = strlen(v);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void append(CString &d)
 | 
						void append(const char c)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							Grow(cSize + 2);
 | 
				
			||||||
 | 
							v[cSize] = c;
 | 
				
			||||||
 | 
							v[++cSize] = 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void append(String &d)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		const char *t = d.c_str();
 | 
							const char *t = d.c_str();
 | 
				
			||||||
		Grow(strlen(v) + strlen(t));
 | 
							Grow(cSize + strlen(t));
 | 
				
			||||||
		strcat(v, t);
 | 
							strcat(v, t);
 | 
				
			||||||
 | 
							cSize = strlen(v);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void assign(const String &src)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							assign(src.c_str());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void assign(const char *d)
 | 
						void assign(const char *d)
 | 
				
			||||||
@@ -64,20 +101,27 @@ public:
 | 
				
			|||||||
		if (!d)
 | 
							if (!d)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			Grow(1);
 | 
								Grow(1);
 | 
				
			||||||
 | 
								cSize = 0;
 | 
				
			||||||
			strcpy(v, "");
 | 
								strcpy(v, "");
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		Grow(strlen(d));
 | 
							Grow(strlen(d));
 | 
				
			||||||
		if (v)
 | 
							if (v)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
			strcpy(v, d);
 | 
								strcpy(v, d);
 | 
				
			||||||
 | 
								cSize = strlen(v);
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								cSize = 0;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void clear()
 | 
						void clear()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if (v)
 | 
							if (v)
 | 
				
			||||||
			delete [] v;
 | 
							{
 | 
				
			||||||
		v = NULL;
 | 
								v[0] = 0;
 | 
				
			||||||
		mSize = 0;
 | 
								cSize = 0;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	int compare (const char *d)
 | 
						int compare (const char *d)
 | 
				
			||||||
@@ -100,7 +144,7 @@ public:
 | 
				
			|||||||
	//Added this for amxx inclusion
 | 
						//Added this for amxx inclusion
 | 
				
			||||||
	bool empty()
 | 
						bool empty()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if (!v || !mSize)
 | 
							if (!v || !cSize)
 | 
				
			||||||
			return true;
 | 
								return true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
@@ -110,20 +154,218 @@ public:
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
		if (!v)
 | 
							if (!v)
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
		return strlen(v);
 | 
							return cSize;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						const char * _fread(FILE *fp)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							Grow(512);
 | 
				
			||||||
 | 
							char * ret = fgets(v, 511, fp);
 | 
				
			||||||
 | 
							cSize = strlen(v);
 | 
				
			||||||
 | 
							return ret;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						int find(const char c, int index = 0)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (!v)
 | 
				
			||||||
 | 
								return npos;
 | 
				
			||||||
 | 
							unsigned int i = 0;
 | 
				
			||||||
 | 
							for (i=index; i<cSize; i++)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if (v[i] == c)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									return i;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return npos;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						bool is_space(int c)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (c == '\f' || c == '\n' ||
 | 
				
			||||||
 | 
								c == '\t' || c == '\r' ||
 | 
				
			||||||
 | 
								c == 'v' || c == ' ')
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return true;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						void trim()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (!v)
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							unsigned int i = 0;
 | 
				
			||||||
 | 
							unsigned int j = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (cSize == 1)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if (is_space(v[i]))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									clear();
 | 
				
			||||||
 | 
									return;
 | 
				
			||||||
 | 
								} 
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							unsigned char c0 = v[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (is_space(c0))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								for (i=0; i<cSize; i++)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									if (!is_space(v[i]) || (is_space(v[i]) && ((unsigned char)i==cSize-1)))
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										erase(0, i);
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							cSize = strlen(v);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (cSize < 1)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (is_space(v[cSize-1]))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								for (i=cSize-1; i>=0; i--)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									if (!is_space(v[i])
 | 
				
			||||||
 | 
										|| (is_space(v[i]) && i==0))
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										erase(i+1, j);
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									j++;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (cSize == 1)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if (is_space(v[0]))
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									clear();
 | 
				
			||||||
 | 
									return;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						String & erase(unsigned int start, int num = npos)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (!v)
 | 
				
			||||||
 | 
								return (*this);
 | 
				
			||||||
 | 
							unsigned int i = 0;
 | 
				
			||||||
 | 
							//check for bounds
 | 
				
			||||||
 | 
							if (num == npos || start+num > cSize-num+1)
 | 
				
			||||||
 | 
								num = cSize - start;
 | 
				
			||||||
 | 
							//do the erasing
 | 
				
			||||||
 | 
							bool copyflag = false;
 | 
				
			||||||
 | 
							for (i=0; i<cSize; i++)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if (i>=start && i<start+num)
 | 
				
			||||||
 | 
								{
 | 
				
			||||||
 | 
									if (i+num < cSize)
 | 
				
			||||||
 | 
									{	
 | 
				
			||||||
 | 
										v[i] = v[i+num];
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
										v[i] = 0;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									copyflag = true;
 | 
				
			||||||
 | 
								} else if (copyflag) {
 | 
				
			||||||
 | 
									if (i+num < cSize)
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										v[i] = v[i+num];
 | 
				
			||||||
 | 
									} else {
 | 
				
			||||||
 | 
										v[i] = 0;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							v[i] = 0;
 | 
				
			||||||
 | 
							cSize -= num;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return (*this);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						String substr(unsigned int index, int num = npos)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							unsigned int rnum = (unsigned int)((num<0)?(cSize):(num));
 | 
				
			||||||
 | 
							String ns;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (index >= cSize || !v)
 | 
				
			||||||
 | 
								return ns;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (index+rnum >= cSize)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								rnum = cSize - index+1;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							unsigned int i = 0, j=0;
 | 
				
			||||||
 | 
							char *s = new char[cSize+1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						        for (i=index; i<index+rnum; i++)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								s[j++] = v[i];
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							s[j] = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							ns.assign(s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							delete [] s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return ns;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void toLower()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (!v)
 | 
				
			||||||
 | 
								return;
 | 
				
			||||||
 | 
							unsigned int i = 0;
 | 
				
			||||||
 | 
							for (i=0; i<cSize; i++)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								if (v[i] >= 65 && v[i] <= 90)
 | 
				
			||||||
 | 
									v[i] |= 32;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						String & operator = (const String &src)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							assign(src);
 | 
				
			||||||
 | 
							return *this;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						String & operator = (const char *src)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							assign(src);
 | 
				
			||||||
 | 
							return *this;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						char operator [] (unsigned int index)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (index > cSize)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								return -1;
 | 
				
			||||||
 | 
							} else {
 | 
				
			||||||
 | 
								return v[index];
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	void Grow(int d)
 | 
						void Grow(unsigned int d)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if (d<1)
 | 
							if (d<1)
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		if (d > mSize)
 | 
							if (d > mSize)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 | 
								mSize = d + 16;	// allocate a buffer
 | 
				
			||||||
			char *t = new char[d+1];
 | 
								char *t = new char[d+1];
 | 
				
			||||||
			if (v) {
 | 
								if (v) {
 | 
				
			||||||
				strcpy(t, v);
 | 
									strcpy(t, v);
 | 
				
			||||||
				t[strlen(v)] = 0;
 | 
									t[cSize] = 0;
 | 
				
			||||||
				delete [] v;
 | 
									delete [] v;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			v = t;
 | 
								v = t;
 | 
				
			||||||
@@ -132,7 +374,10 @@ private:
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	char *v;
 | 
						char *v;
 | 
				
			||||||
	int mSize;
 | 
						unsigned int mSize;
 | 
				
			||||||
 | 
						unsigned int cSize;
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
						static const int npos = -1;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#endif //_INCLUDE_CSTRING_H
 | 
					#endif //_INCLUDE_CSTRING_H
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -32,7 +32,7 @@
 | 
				
			|||||||
#ifndef VAULT_CUSTOM_H
 | 
					#ifndef VAULT_CUSTOM_H
 | 
				
			||||||
#define VAULT_CUSTOM_H
 | 
					#define VAULT_CUSTOM_H
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "CString.h"
 | 
					#include "String.h"
 | 
				
			||||||
#include "CList.h"
 | 
					#include "CList.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// *****************************************************
 | 
					// *****************************************************
 | 
				
			||||||
@@ -43,14 +43,14 @@ class Vault
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  struct Obj
 | 
					  struct Obj
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
	CString key;
 | 
						String key;
 | 
				
			||||||
	CString value;
 | 
						String value;
 | 
				
			||||||
	int number;
 | 
						int number;
 | 
				
			||||||
    Obj *next;
 | 
					    Obj *next;
 | 
				
			||||||
	Obj( const char* k,  const char* v);
 | 
						Obj( const char* k,  const char* v);
 | 
				
			||||||
  } *head;
 | 
					  } *head;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  CString path;
 | 
					  String path;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Obj** find( const char* n );
 | 
					  Obj** find( const char* n );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -79,8 +79,8 @@ public:
 | 
				
			|||||||
	iterator& operator++() { if ( a ) a = a->next; return *this; }
 | 
						iterator& operator++() { if ( a ) a = a->next; return *this; }
 | 
				
			||||||
	bool operator==(const iterator& b) const { return a == b.a; }
 | 
						bool operator==(const iterator& b) const { return a == b.a; }
 | 
				
			||||||
	bool operator!=(const iterator& b) const { return !operator==(b); }
 | 
						bool operator!=(const iterator& b) const { return !operator==(b); }
 | 
				
			||||||
	CString& key() const { return a->key; }
 | 
						String& key() const { return a->key; }
 | 
				
			||||||
	CString& value() const { return a->value; }
 | 
						String& value() const { return a->value; }
 | 
				
			||||||
  };
 | 
					  };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  inline iterator begin() const { return iterator(head); }
 | 
					  inline iterator begin() const { return iterator(head); }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -796,6 +796,41 @@ static cell AMX_NATIVE_CALL get_plugin(AMX *amx, cell *params) /* 11 param */
 | 
				
			|||||||
  return -1;
 | 
					  return -1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static cell AMX_NATIVE_CALL amx_md5(AMX *amx, cell *params)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int len = 0;
 | 
				
			||||||
 | 
						char *str = get_amxstring(amx, params[1], 0, len);
 | 
				
			||||||
 | 
						char buffer[33];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						MD5 md5;
 | 
				
			||||||
 | 
						md5.update((unsigned char *)str, len);
 | 
				
			||||||
 | 
						md5.finalize();
 | 
				
			||||||
 | 
						md5.hex_digest(buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return set_amxstring(amx, params[2], buffer, 32);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static cell AMX_NATIVE_CALL amx_md5_file(AMX *amx, cell *params)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int len = 0;
 | 
				
			||||||
 | 
						char *str = get_amxstring(amx, params[1], 0, len);
 | 
				
			||||||
 | 
						char buffer[33];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						FILE *fp = fopen(str, "rb");
 | 
				
			||||||
 | 
						if (!fp)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							amx_RaiseError(amx, AMX_ERR_NATIVE);
 | 
				
			||||||
 | 
							return 0;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						MD5 md5;
 | 
				
			||||||
 | 
						md5.update(fp);			//closes for you
 | 
				
			||||||
 | 
						md5.finalize();
 | 
				
			||||||
 | 
						md5.hex_digest(buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return set_amxstring(amx, params[2], buffer, 32);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static cell AMX_NATIVE_CALL get_pluginsnum(AMX *amx, cell *params)
 | 
					static cell AMX_NATIVE_CALL get_pluginsnum(AMX *amx, cell *params)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  return g_plugins.getPluginsNum();
 | 
					  return g_plugins.getPluginsNum();
 | 
				
			||||||
@@ -2749,5 +2784,7 @@ AMX_NATIVE_INFO amxmod_Natives[] = {
 | 
				
			|||||||
  { "get_lang",				get_lang },
 | 
					  { "get_lang",				get_lang },
 | 
				
			||||||
  { "register_dictionary",	register_dictionary },
 | 
					  { "register_dictionary",	register_dictionary },
 | 
				
			||||||
  { "lang_exists",			lang_exists },
 | 
					  { "lang_exists",			lang_exists },
 | 
				
			||||||
 | 
					  { "md5",				amx_md5 },
 | 
				
			||||||
 | 
					  { "md5_file",			amx_md5_file },
 | 
				
			||||||
  { NULL, NULL }
 | 
					  { NULL, NULL }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,8 +41,10 @@
 | 
				
			|||||||
#include "mmgr/mmgr.h"
 | 
					#include "mmgr/mmgr.h"
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "md5.h"
 | 
				
			||||||
#include "CVector.h"
 | 
					#include "CVector.h"
 | 
				
			||||||
#include "CList.h"
 | 
					#include "CList.h"
 | 
				
			||||||
 | 
					#include "CQueue.h"
 | 
				
			||||||
#include "modules.h"
 | 
					#include "modules.h"
 | 
				
			||||||
#include "CString.h"
 | 
					#include "CString.h"
 | 
				
			||||||
#include "CPlugin.h"
 | 
					#include "CPlugin.h"
 | 
				
			||||||
@@ -115,7 +117,7 @@ void UTIL_ShowMenu( edict_t* pEntity, int slots, int time, char *menu, int mlen
 | 
				
			|||||||
#define GET_PLAYER_POINTER_I(i) (&g_players[i])
 | 
					#define GET_PLAYER_POINTER_I(i) (&g_players[i])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct WeaponsVault {
 | 
					struct WeaponsVault {
 | 
				
			||||||
  CString fullName;
 | 
					  String fullName;
 | 
				
			||||||
  short int iId;
 | 
					  short int iId;
 | 
				
			||||||
  short int ammoSlot;
 | 
					  short int ammoSlot;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
@@ -145,8 +147,8 @@ extern Grenades g_grenades;
 | 
				
			|||||||
extern LogEventsMngr g_logevents;
 | 
					extern LogEventsMngr g_logevents;
 | 
				
			||||||
extern MenuMngr g_menucmds;
 | 
					extern MenuMngr g_menucmds;
 | 
				
			||||||
extern CLangMngr g_langMngr;
 | 
					extern CLangMngr g_langMngr;
 | 
				
			||||||
extern CString g_log_dir;
 | 
					extern String g_log_dir;
 | 
				
			||||||
extern CString g_mod_name;
 | 
					extern String g_mod_name;
 | 
				
			||||||
extern TeamIds g_teamsIds;
 | 
					extern TeamIds g_teamsIds;
 | 
				
			||||||
extern Vault g_vault;
 | 
					extern Vault g_vault;
 | 
				
			||||||
extern CForwardMngr  g_forwards;
 | 
					extern CForwardMngr  g_forwards;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -106,7 +106,7 @@ void CLog::CreateNewFile()
 | 
				
			|||||||
	fclose(fp);
 | 
						fclose(fp);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void CLog::UseFile(const CString &fileName)
 | 
					void CLog::UseFile(const String &fileName)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	m_LogFile.assign(build_pathname("%s/%s", g_log_dir.c_str(), fileName.c_str()));
 | 
						m_LogFile.assign(build_pathname("%s/%s", g_log_dir.c_str(), fileName.c_str()));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,11 +34,11 @@
 | 
				
			|||||||
class CLog
 | 
					class CLog
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
	CString m_LogFile;
 | 
						String m_LogFile;
 | 
				
			||||||
	int m_LogType;
 | 
						int m_LogType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void GetLastFile(int &outMonth, int &outDay, CString &outFilename);
 | 
						void GetLastFile(int &outMonth, int &outDay, String &outFilename);
 | 
				
			||||||
	void UseFile(const CString &fileName);
 | 
						void UseFile(const String &fileName);
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
	CLog();
 | 
						CLog();
 | 
				
			||||||
	~CLog();
 | 
						~CLog();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -74,7 +74,7 @@ public:
 | 
				
			|||||||
	{
 | 
						{
 | 
				
			||||||
	private:
 | 
						private:
 | 
				
			||||||
		// plugin info
 | 
							// plugin info
 | 
				
			||||||
		CString m_Path;
 | 
							String m_Path;
 | 
				
			||||||
		PLUG_STATUS m_Status;
 | 
							PLUG_STATUS m_Status;
 | 
				
			||||||
		plugin_info_t *m_Info;
 | 
							plugin_info_t *m_Info;
 | 
				
			||||||
		// Function tables
 | 
							// Function tables
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										474
									
								
								amxmodx/md5.cpp
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										474
									
								
								amxmodx/md5.cpp
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,474 @@
 | 
				
			|||||||
 | 
					// MD5.CC - source code for the C++/object oriented translation and 
 | 
				
			||||||
 | 
					//          modification of MD5.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Translation and modification (c) 1995 by Mordechai T. Abzug 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// This translation/ modification is provided "as is," without express or 
 | 
				
			||||||
 | 
					// implied warranty of any kind.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// The translator/ modifier does not claim (1) that MD5 will do what you think 
 | 
				
			||||||
 | 
					// it does; (2) that this translation/ modification is accurate; or (3) that 
 | 
				
			||||||
 | 
					// this software is "merchantible."  (Language for this disclaimer partially 
 | 
				
			||||||
 | 
					// copied from the disclaimer below).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* based on:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   MD5C.C - RSA Data Security, Inc., MD5 message-digest algorithm
 | 
				
			||||||
 | 
					   MDDRIVER.C - test driver for MD2, MD4 and MD5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
 | 
				
			||||||
 | 
					rights reserved.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					License to copy and use this software is granted provided that it
 | 
				
			||||||
 | 
					is identified as the "RSA Data Security, Inc. MD5 Message-Digest
 | 
				
			||||||
 | 
					Algorithm" in all material mentioning or referencing this software
 | 
				
			||||||
 | 
					or this function.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					License is also granted to make and use derivative works provided
 | 
				
			||||||
 | 
					that such works are identified as "derived from the RSA Data
 | 
				
			||||||
 | 
					Security, Inc. MD5 Message-Digest Algorithm" in all material
 | 
				
			||||||
 | 
					mentioning or referencing the derived work.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RSA Data Security, Inc. makes no representations concerning either
 | 
				
			||||||
 | 
					the merchantability of this software or the suitability of this
 | 
				
			||||||
 | 
					software for any particular purpose. It is provided "as is"
 | 
				
			||||||
 | 
					without express or implied warranty of any kind.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					These notices must be retained in any copies of any part of this
 | 
				
			||||||
 | 
					documentation and/or software.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "md5.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <assert.h>
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// MD5 simple initialization method
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					MD5::MD5(){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  init();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// MD5 block update operation. Continues an MD5 message-digest
 | 
				
			||||||
 | 
					// operation, processing another message block, and updating the
 | 
				
			||||||
 | 
					// context.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void MD5::update (uint1 *input, uint4 input_length) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  uint4 input_index, buffer_index;
 | 
				
			||||||
 | 
					  uint4 buffer_space;                // how much space is left in buffer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (finalized){  // so we can't update!
 | 
				
			||||||
 | 
					    /*cerr << "MD5::update:  Can't update a finalized digest!" << endl;*/
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Compute number of bytes mod 64
 | 
				
			||||||
 | 
					  buffer_index = (unsigned int)((count[0] >> 3) & 0x3F);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Update number of bits
 | 
				
			||||||
 | 
					  if (  (count[0] += ((uint4) input_length << 3))<((uint4) input_length << 3) )
 | 
				
			||||||
 | 
					    count[1]++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  count[1] += ((uint4)input_length >> 29);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  buffer_space = 64 - buffer_index;  // how much space is left in buffer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Transform as many times as possible.
 | 
				
			||||||
 | 
					  if (input_length >= buffer_space) { // ie. we have enough to fill the buffer
 | 
				
			||||||
 | 
					    // fill the rest of the buffer and transform
 | 
				
			||||||
 | 
					    memcpy (buffer + buffer_index, input, buffer_space);
 | 
				
			||||||
 | 
					    transform (buffer);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // now, transform each 64-byte piece of the input, bypassing the buffer
 | 
				
			||||||
 | 
					    for (input_index = buffer_space; input_index + 63 < input_length; 
 | 
				
			||||||
 | 
						 input_index += 64)
 | 
				
			||||||
 | 
					      transform (input+input_index);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    buffer_index = 0;  // so we can buffer remaining
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    input_index=0;     // so we can buffer the whole input
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // and here we do the buffering:
 | 
				
			||||||
 | 
					  memcpy(buffer+buffer_index, input+input_index, input_length-input_index);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// MD5 update for files.
 | 
				
			||||||
 | 
					// Like above, except that it works on files (and uses above as a primitive.)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void MD5::update(FILE *file){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  unsigned char buffer[1024];
 | 
				
			||||||
 | 
					  int len;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  while (len=fread(buffer, 1, 1024, file))
 | 
				
			||||||
 | 
					    update(buffer, len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  fclose (file);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// MD5 finalization. Ends an MD5 message-digest operation, writing the
 | 
				
			||||||
 | 
					// the message digest and zeroizing the context.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void MD5::finalize (){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  unsigned char bits[8];
 | 
				
			||||||
 | 
					  unsigned int index, padLen;
 | 
				
			||||||
 | 
					  static uint1 PADDING[64]={
 | 
				
			||||||
 | 
					    0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 | 
				
			||||||
 | 
					    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
 | 
				
			||||||
 | 
					    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (finalized){
 | 
				
			||||||
 | 
					   /* cerr << "MD5::finalize:  Already finalized this digest!" << endl;*/
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Save number of bits
 | 
				
			||||||
 | 
					  encode (bits, count, 8);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Pad out to 56 mod 64.
 | 
				
			||||||
 | 
					  index = (uint4) ((count[0] >> 3) & 0x3f);
 | 
				
			||||||
 | 
					  padLen = (index < 56) ? (56 - index) : (120 - index);
 | 
				
			||||||
 | 
					  update (PADDING, padLen);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Append length (before padding)
 | 
				
			||||||
 | 
					  update (bits, 8);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Store state in digest
 | 
				
			||||||
 | 
					  encode (digest, state, 16);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Zeroize sensitive information
 | 
				
			||||||
 | 
					  memset (buffer, 0, sizeof(*buffer));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  finalized=1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					MD5::MD5(FILE *file){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  init();  // must be called be all constructors
 | 
				
			||||||
 | 
					  update(file);
 | 
				
			||||||
 | 
					  finalize ();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					unsigned char *MD5::raw_digest(){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  uint1 *s = new uint1[16];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (!finalized){
 | 
				
			||||||
 | 
					/*    cerr << "MD5::raw_digest:  Can't get digest if you haven't "<<
 | 
				
			||||||
 | 
					      "finalized the digest!" <<endl;*/
 | 
				
			||||||
 | 
					    return ( (unsigned char*) "");
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  memcpy(s, digest, 16);
 | 
				
			||||||
 | 
					  return s;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char *MD5::hex_digest(){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int i;
 | 
				
			||||||
 | 
					  char *s= new char[33];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (!finalized){
 | 
				
			||||||
 | 
					/*    cerr << "MD5::hex_digest:  Can't get digest if you haven't "<<
 | 
				
			||||||
 | 
					      "finalized the digest!" <<endl;*/
 | 
				
			||||||
 | 
					    return "";
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (i=0; i<16; i++)
 | 
				
			||||||
 | 
					    sprintf(s+i*2, "%02x", digest[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  s[32]='\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return s;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					char *MD5::hex_digest(char buffer[33]){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if (!finalized)
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
						 /* cerr << "MD5::hex_digest:  Can't get digest if you haven't "<<
 | 
				
			||||||
 | 
					      "finalized the digest!" <<endl;*/
 | 
				
			||||||
 | 
					    return "";
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (i=0; i<16; i++)
 | 
				
			||||||
 | 
					    sprintf(buffer+i*2, "%02x", digest[i]);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  buffer[32]='\0';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  return buffer;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// PRIVATE METHODS:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void MD5::init(){
 | 
				
			||||||
 | 
					  finalized=0;  // we just started!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Nothing counted, so count=0
 | 
				
			||||||
 | 
					  count[0] = 0;
 | 
				
			||||||
 | 
					  count[1] = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Load magic initialization constants.
 | 
				
			||||||
 | 
					  state[0] = 0x67452301;
 | 
				
			||||||
 | 
					  state[1] = 0xefcdab89;
 | 
				
			||||||
 | 
					  state[2] = 0x98badcfe;
 | 
				
			||||||
 | 
					  state[3] = 0x10325476;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Constants for MD5Transform routine.
 | 
				
			||||||
 | 
					// Although we could use C++ style constants, defines are actually better,
 | 
				
			||||||
 | 
					// since they let us easily evade scope clashes.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define S11 7
 | 
				
			||||||
 | 
					#define S12 12
 | 
				
			||||||
 | 
					#define S13 17
 | 
				
			||||||
 | 
					#define S14 22
 | 
				
			||||||
 | 
					#define S21 5
 | 
				
			||||||
 | 
					#define S22 9
 | 
				
			||||||
 | 
					#define S23 14
 | 
				
			||||||
 | 
					#define S24 20
 | 
				
			||||||
 | 
					#define S31 4
 | 
				
			||||||
 | 
					#define S32 11
 | 
				
			||||||
 | 
					#define S33 16
 | 
				
			||||||
 | 
					#define S34 23
 | 
				
			||||||
 | 
					#define S41 6
 | 
				
			||||||
 | 
					#define S42 10
 | 
				
			||||||
 | 
					#define S43 15
 | 
				
			||||||
 | 
					#define S44 21
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// MD5 basic transformation. Transforms state based on block.
 | 
				
			||||||
 | 
					void MD5::transform (uint1 block[64]){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  decode (x, block, 64);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  assert(!finalized);  // not just a user error, since the method is private
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Round 1 */
 | 
				
			||||||
 | 
					  FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
 | 
				
			||||||
 | 
					  FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
 | 
				
			||||||
 | 
					  FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
 | 
				
			||||||
 | 
					  FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
 | 
				
			||||||
 | 
					  FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
 | 
				
			||||||
 | 
					  FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
 | 
				
			||||||
 | 
					  FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
 | 
				
			||||||
 | 
					  FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
 | 
				
			||||||
 | 
					  FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
 | 
				
			||||||
 | 
					  FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
 | 
				
			||||||
 | 
					  FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
 | 
				
			||||||
 | 
					  FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
 | 
				
			||||||
 | 
					  FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
 | 
				
			||||||
 | 
					  FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
 | 
				
			||||||
 | 
					  FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
 | 
				
			||||||
 | 
					  FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 /* Round 2 */
 | 
				
			||||||
 | 
					  GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
 | 
				
			||||||
 | 
					  GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
 | 
				
			||||||
 | 
					  GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
 | 
				
			||||||
 | 
					  GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
 | 
				
			||||||
 | 
					  GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
 | 
				
			||||||
 | 
					  GG (d, a, b, c, x[10], S22,  0x2441453); /* 22 */
 | 
				
			||||||
 | 
					  GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
 | 
				
			||||||
 | 
					  GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
 | 
				
			||||||
 | 
					  GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
 | 
				
			||||||
 | 
					  GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
 | 
				
			||||||
 | 
					  GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
 | 
				
			||||||
 | 
					  GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
 | 
				
			||||||
 | 
					  GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
 | 
				
			||||||
 | 
					  GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
 | 
				
			||||||
 | 
					  GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
 | 
				
			||||||
 | 
					  GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Round 3 */
 | 
				
			||||||
 | 
					  HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
 | 
				
			||||||
 | 
					  HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
 | 
				
			||||||
 | 
					  HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
 | 
				
			||||||
 | 
					  HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
 | 
				
			||||||
 | 
					  HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
 | 
				
			||||||
 | 
					  HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
 | 
				
			||||||
 | 
					  HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
 | 
				
			||||||
 | 
					  HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
 | 
				
			||||||
 | 
					  HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
 | 
				
			||||||
 | 
					  HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
 | 
				
			||||||
 | 
					  HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
 | 
				
			||||||
 | 
					  HH (b, c, d, a, x[ 6], S34,  0x4881d05); /* 44 */
 | 
				
			||||||
 | 
					  HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
 | 
				
			||||||
 | 
					  HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
 | 
				
			||||||
 | 
					  HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
 | 
				
			||||||
 | 
					  HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /* Round 4 */
 | 
				
			||||||
 | 
					  II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
 | 
				
			||||||
 | 
					  II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
 | 
				
			||||||
 | 
					  II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
 | 
				
			||||||
 | 
					  II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
 | 
				
			||||||
 | 
					  II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
 | 
				
			||||||
 | 
					  II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
 | 
				
			||||||
 | 
					  II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
 | 
				
			||||||
 | 
					  II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
 | 
				
			||||||
 | 
					  II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
 | 
				
			||||||
 | 
					  II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
 | 
				
			||||||
 | 
					  II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
 | 
				
			||||||
 | 
					  II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
 | 
				
			||||||
 | 
					  II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
 | 
				
			||||||
 | 
					  II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
 | 
				
			||||||
 | 
					  II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
 | 
				
			||||||
 | 
					  II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  state[0] += a;
 | 
				
			||||||
 | 
					  state[1] += b;
 | 
				
			||||||
 | 
					  state[2] += c;
 | 
				
			||||||
 | 
					  state[3] += d;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // Zeroize sensitive information.
 | 
				
			||||||
 | 
					  memset ( (uint1 *) x, 0, sizeof(x));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Encodes input (UINT4) into output (unsigned char). Assumes len is
 | 
				
			||||||
 | 
					// a multiple of 4.
 | 
				
			||||||
 | 
					void MD5::encode (uint1 *output, uint4 *input, uint4 len) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  unsigned int i, j;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (i = 0, j = 0; j < len; i++, j += 4) {
 | 
				
			||||||
 | 
					    output[j]   = (uint1)  (input[i] & 0xff);
 | 
				
			||||||
 | 
					    output[j+1] = (uint1) ((input[i] >> 8) & 0xff);
 | 
				
			||||||
 | 
					    output[j+2] = (uint1) ((input[i] >> 16) & 0xff);
 | 
				
			||||||
 | 
					    output[j+3] = (uint1) ((input[i] >> 24) & 0xff);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Decodes input (unsigned char) into output (UINT4). Assumes len is
 | 
				
			||||||
 | 
					// a multiple of 4.
 | 
				
			||||||
 | 
					void MD5::decode (uint4 *output, uint1 *input, uint4 len){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  unsigned int i, j;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (i = 0, j = 0; j < len; i++, j += 4)
 | 
				
			||||||
 | 
					    output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) << 8) |
 | 
				
			||||||
 | 
					      (((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Note: Replace "for loop" with standard memcpy if possible.
 | 
				
			||||||
 | 
					void MD5::memcpy (uint1 *output, uint1 *input, uint4 len){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  unsigned int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (i = 0; i < len; i++)
 | 
				
			||||||
 | 
					    output[i] = input[i];
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Note: Replace "for loop" with standard memset if possible.
 | 
				
			||||||
 | 
					void MD5::memset (uint1 *output, uint1 value, uint4 len){
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  unsigned int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for (i = 0; i < len; i++)
 | 
				
			||||||
 | 
					    output[i] = value;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// ROTATE_LEFT rotates x left n bits.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline unsigned int MD5::rotate_left  (uint4 x, uint4 n){
 | 
				
			||||||
 | 
					  return (x << n) | (x >> (32-n))  ;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// F, G, H and I are basic MD5 functions.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline unsigned int MD5::F            (uint4 x, uint4 y, uint4 z){
 | 
				
			||||||
 | 
					  return (x & y) | (~x & z);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline unsigned int MD5::G            (uint4 x, uint4 y, uint4 z){
 | 
				
			||||||
 | 
					  return (x & z) | (y & ~z);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline unsigned int MD5::H            (uint4 x, uint4 y, uint4 z){
 | 
				
			||||||
 | 
					  return x ^ y ^ z;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline unsigned int MD5::I            (uint4 x, uint4 y, uint4 z){
 | 
				
			||||||
 | 
					  return y ^ (x | ~z);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
 | 
				
			||||||
 | 
					// Rotation is separate from addition to prevent recomputation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline void MD5::FF(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 
 | 
				
			||||||
 | 
							    uint4  s, uint4 ac){
 | 
				
			||||||
 | 
					 a += F(b, c, d) + x + ac;
 | 
				
			||||||
 | 
					 a = rotate_left (a, s) +b;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline void MD5::GG(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 
 | 
				
			||||||
 | 
							    uint4 s, uint4 ac){
 | 
				
			||||||
 | 
					 a += G(b, c, d) + x + ac;
 | 
				
			||||||
 | 
					 a = rotate_left (a, s) +b;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline void MD5::HH(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 
 | 
				
			||||||
 | 
							    uint4 s, uint4 ac){
 | 
				
			||||||
 | 
					 a += H(b, c, d) + x + ac;
 | 
				
			||||||
 | 
					 a = rotate_left (a, s) +b;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline void MD5::II(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 
 | 
				
			||||||
 | 
								     uint4 s, uint4 ac){
 | 
				
			||||||
 | 
					 a += I(b, c, d) + x + ac;
 | 
				
			||||||
 | 
					 a = rotate_left (a, s) +b;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										105
									
								
								amxmodx/md5.h
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										105
									
								
								amxmodx/md5.h
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,105 @@
 | 
				
			|||||||
 | 
					// MD5.CC - source code for the C++/object oriented translation and 
 | 
				
			||||||
 | 
					//          modification of MD5.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Translation and modification (c) 1995 by Mordechai T. Abzug 
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// This translation/ modification is provided "as is," without express or 
 | 
				
			||||||
 | 
					// implied warranty of any kind.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// The translator/ modifier does not claim (1) that MD5 will do what you think 
 | 
				
			||||||
 | 
					// it does; (2) that this translation/ modification is accurate; or (3) that 
 | 
				
			||||||
 | 
					// this software is "merchantible."  (Language for this disclaimer partially 
 | 
				
			||||||
 | 
					// copied from the disclaimer below).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* based on:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   MD5.H - header file for MD5C.C
 | 
				
			||||||
 | 
					   MDDRIVER.C - test driver for MD2, MD4 and MD5
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
 | 
				
			||||||
 | 
					rights reserved.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					License to copy and use this software is granted provided that it
 | 
				
			||||||
 | 
					is identified as the "RSA Data Security, Inc. MD5 Message-Digest
 | 
				
			||||||
 | 
					Algorithm" in all material mentioning or referencing this software
 | 
				
			||||||
 | 
					or this function.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					License is also granted to make and use derivative works provided
 | 
				
			||||||
 | 
					that such works are identified as "derived from the RSA Data
 | 
				
			||||||
 | 
					Security, Inc. MD5 Message-Digest Algorithm" in all material
 | 
				
			||||||
 | 
					mentioning or referencing the derived work.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RSA Data Security, Inc. makes no representations concerning either
 | 
				
			||||||
 | 
					the merchantability of this software or the suitability of this
 | 
				
			||||||
 | 
					software for any particular purpose. It is provided "as is"
 | 
				
			||||||
 | 
					without express or implied warranty of any kind.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					These notices must be retained in any copies of any part of this
 | 
				
			||||||
 | 
					documentation and/or software.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					*/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					//#include <fstream.h>
 | 
				
			||||||
 | 
					//#include <iostream.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class MD5 {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public:
 | 
				
			||||||
 | 
					// methods for controlled operation:
 | 
				
			||||||
 | 
					  MD5              ();  // simple initializer
 | 
				
			||||||
 | 
					  void  update     (unsigned char *input, unsigned int input_length);
 | 
				
			||||||
 | 
					  void  update     (FILE *file);
 | 
				
			||||||
 | 
					  void  finalize   ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// constructors for special circumstances.  All these constructors finalize
 | 
				
			||||||
 | 
					// the MD5 context.
 | 
				
			||||||
 | 
					  MD5              (unsigned char *string); // digest string, finalize
 | 
				
			||||||
 | 
					  MD5              (FILE *file);            // digest file, close, finalize
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// methods to acquire finalized result
 | 
				
			||||||
 | 
					  unsigned char    *raw_digest ();  // digest as a 16-byte binary array
 | 
				
			||||||
 | 
					  char *            hex_digest ();  // digest as a 33-byte ascii-hex string
 | 
				
			||||||
 | 
					  char *			hex_digest (char buffer[33]); //same as above, passing buffer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					private:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// first, some types:
 | 
				
			||||||
 | 
					  typedef unsigned       int uint4; // assumes integer is 4 words long
 | 
				
			||||||
 | 
					  typedef unsigned short int uint2; // assumes short integer is 2 words long
 | 
				
			||||||
 | 
					  typedef unsigned      char uint1; // assumes char is 1 word long
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// next, the private data:
 | 
				
			||||||
 | 
					  uint4 state[4];
 | 
				
			||||||
 | 
					  uint4 count[2];     // number of *bits*, mod 2^64
 | 
				
			||||||
 | 
					  uint1 buffer[64];   // input buffer
 | 
				
			||||||
 | 
					  uint1 digest[16];
 | 
				
			||||||
 | 
					  uint1 finalized;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// last, the private methods, mostly static:
 | 
				
			||||||
 | 
					  void init             ();               // called by all constructors
 | 
				
			||||||
 | 
					  void transform        (uint1 *buffer);  // does the real update work.  Note 
 | 
				
			||||||
 | 
					                                          // that length is implied to be 64.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static void encode    (uint1 *dest, uint4 *src, uint4 length);
 | 
				
			||||||
 | 
					  static void decode    (uint4 *dest, uint1 *src, uint4 length);
 | 
				
			||||||
 | 
					  static void memcpy    (uint1 *dest, uint1 *src, uint4 length);
 | 
				
			||||||
 | 
					  static void memset    (uint1 *start, uint1 val, uint4 length);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  static inline uint4  rotate_left (uint4 x, uint4 n);
 | 
				
			||||||
 | 
					  static inline uint4  F           (uint4 x, uint4 y, uint4 z);
 | 
				
			||||||
 | 
					  static inline uint4  G           (uint4 x, uint4 y, uint4 z);
 | 
				
			||||||
 | 
					  static inline uint4  H           (uint4 x, uint4 y, uint4 z);
 | 
				
			||||||
 | 
					  static inline uint4  I           (uint4 x, uint4 y, uint4 z);
 | 
				
			||||||
 | 
					  static inline void   FF  (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 
 | 
				
			||||||
 | 
								    uint4 s, uint4 ac);
 | 
				
			||||||
 | 
					  static inline void   GG  (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 
 | 
				
			||||||
 | 
								    uint4 s, uint4 ac);
 | 
				
			||||||
 | 
					  static inline void   HH  (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 
 | 
				
			||||||
 | 
								    uint4 s, uint4 ac);
 | 
				
			||||||
 | 
					  static inline void   II  (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, 
 | 
				
			||||||
 | 
								    uint4 s, uint4 ac);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
@@ -73,8 +73,8 @@ Grenades g_grenades;
 | 
				
			|||||||
LogEventsMngr g_logevents;
 | 
					LogEventsMngr g_logevents;
 | 
				
			||||||
MenuMngr g_menucmds;
 | 
					MenuMngr g_menucmds;
 | 
				
			||||||
CLangMngr g_langMngr;
 | 
					CLangMngr g_langMngr;
 | 
				
			||||||
CString g_log_dir;
 | 
					String g_log_dir;
 | 
				
			||||||
CString g_mod_name;
 | 
					String g_mod_name;
 | 
				
			||||||
XVars g_xvars;
 | 
					XVars g_xvars;
 | 
				
			||||||
bool g_bmod_cstrike;
 | 
					bool g_bmod_cstrike;
 | 
				
			||||||
bool g_bmod_dod;
 | 
					bool g_bmod_dod;
 | 
				
			||||||
@@ -91,7 +91,7 @@ float g_auth_time;
 | 
				
			|||||||
#ifdef MEMORY_TEST
 | 
					#ifdef MEMORY_TEST
 | 
				
			||||||
float g_next_memreport_time;
 | 
					float g_next_memreport_time;
 | 
				
			||||||
unsigned int g_memreport_count;
 | 
					unsigned int g_memreport_count;
 | 
				
			||||||
CString g_memreport_dir;
 | 
					String g_memreport_dir;
 | 
				
			||||||
bool g_memreport_enabled;
 | 
					bool g_memreport_enabled;
 | 
				
			||||||
#define MEMREPORT_INTERVAL 300.0f	/* 5 mins */
 | 
					#define MEMREPORT_INTERVAL 300.0f	/* 5 mins */
 | 
				
			||||||
#endif // MEMORY_TEST
 | 
					#endif // MEMORY_TEST
 | 
				
			||||||
@@ -218,8 +218,8 @@ int	C_Spawn( edict_t *pent ) {
 | 
				
			|||||||
  g_tasksMngr.registerTimers( &gpGlobals->time,	&mp_timelimit->value,  &g_game_timeleft		);
 | 
					  g_tasksMngr.registerTimers( &gpGlobals->time,	&mp_timelimit->value,  &g_game_timeleft		);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //  ###### Load lang
 | 
					  //  ###### Load lang
 | 
				
			||||||
  g_langMngr.Load(build_pathname("%s/languages.dat", get_localinfo("amxx_datadir", "addons/amxx/data")));
 | 
					  g_langMngr.LoadCache(build_pathname("%s/dictionary.cache", get_localinfo("amxx_datadir", "addons/amxx/data")));
 | 
				
			||||||
  g_langMngr.MergeDefinitionFile(build_pathname("%s/langnames.lng", get_localinfo("amxx_datadir", "addons/amxx/data")));
 | 
					//  g_langMngr.Load(build_pathname("%s/languages.dat", get_localinfo("amxx_datadir", "addons/amxx/data")));
 | 
				
			||||||
  // ######	Initialize commands	prefixes
 | 
					  // ######	Initialize commands	prefixes
 | 
				
			||||||
  g_commands.registerPrefix( "amx" );
 | 
					  g_commands.registerPrefix( "amx" );
 | 
				
			||||||
  g_commands.registerPrefix( "amxx"	);
 | 
					  g_commands.registerPrefix( "amxx"	);
 | 
				
			||||||
@@ -402,6 +402,7 @@ void C_ServerActivate_Post( edict_t *pEdictList, int edictCount, int clientMax )
 | 
				
			|||||||
  executeForwards(FF_PluginCfg);
 | 
					  executeForwards(FF_PluginCfg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  //  ###### Save lang
 | 
					  //  ###### Save lang
 | 
				
			||||||
 | 
					  g_langMngr.SaveCache(build_pathname("%s/dictionary.cache", get_localinfo("amxx_datadir", "addons/amxx/data")));
 | 
				
			||||||
  g_langMngr.Save(build_pathname("%s/languages.dat", get_localinfo("amxx_datadir", "addons/amxx/data")));
 | 
					  g_langMngr.Save(build_pathname("%s/languages.dat", get_localinfo("amxx_datadir", "addons/amxx/data")));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Correct time in Counter-Strike	and	other mods (except DOD)
 | 
					// Correct time in Counter-Strike	and	other mods (except DOD)
 | 
				
			||||||
@@ -461,6 +462,7 @@ void C_ServerDeactivate_Post() {
 | 
				
			|||||||
  g_vault.clear();
 | 
					  g_vault.clear();
 | 
				
			||||||
  g_xvars.clear();
 | 
					  g_xvars.clear();
 | 
				
			||||||
  g_plugins.clear();
 | 
					  g_plugins.clear();
 | 
				
			||||||
 | 
					  g_langMngr.SaveCache(build_pathname("%s/dictionary.cache", get_localinfo("amxx_datadir", "addons/amxx/data")));
 | 
				
			||||||
  g_langMngr.Save(build_pathname("%s/languages.dat", get_localinfo("amxx_datadir", "addons/amxx/data")));
 | 
					  g_langMngr.Save(build_pathname("%s/languages.dat", get_localinfo("amxx_datadir", "addons/amxx/data")));
 | 
				
			||||||
  g_langMngr.Clear();
 | 
					  g_langMngr.Clear();
 | 
				
			||||||
  // last memreport
 | 
					  // last memreport
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -25,7 +25,7 @@
 | 
				
			|||||||
				AdditionalIncludeDirectories=""C:\Hry\Half-Life\SDK\Multiplayer Source\pm_shared";"C:\Hry\Half-Life\SDK\Multiplayer Source\dlls";"C:\Hry\Half-Life\SDK\Multiplayer Source\engine";"C:\Hry\Half-Life\SDK\Multiplayer Source\common";C:\Files\Programming\metamod\metamod"
 | 
									AdditionalIncludeDirectories=""C:\Hry\Half-Life\SDK\Multiplayer Source\pm_shared";"C:\Hry\Half-Life\SDK\Multiplayer Source\dlls";"C:\Hry\Half-Life\SDK\Multiplayer Source\engine";"C:\Hry\Half-Life\SDK\Multiplayer Source\common";C:\Files\Programming\metamod\metamod"
 | 
				
			||||||
				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;amxmodx_mm_EXPORTS"
 | 
									PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;amxmodx_mm_EXPORTS"
 | 
				
			||||||
				BasicRuntimeChecks="3"
 | 
									BasicRuntimeChecks="3"
 | 
				
			||||||
				RuntimeLibrary="1"
 | 
									RuntimeLibrary="5"
 | 
				
			||||||
				StructMemberAlignment="3"
 | 
									StructMemberAlignment="3"
 | 
				
			||||||
				UsePrecompiledHeader="2"
 | 
									UsePrecompiledHeader="2"
 | 
				
			||||||
				PrecompiledHeaderThrough="amxmodx.h"
 | 
									PrecompiledHeaderThrough="amxmodx.h"
 | 
				
			||||||
@@ -661,6 +661,9 @@
 | 
				
			|||||||
			<File
 | 
								<File
 | 
				
			||||||
				RelativePath="..\float.cpp">
 | 
									RelativePath="..\float.cpp">
 | 
				
			||||||
			</File>
 | 
								</File>
 | 
				
			||||||
 | 
								<File
 | 
				
			||||||
 | 
									RelativePath="..\md5.cpp">
 | 
				
			||||||
 | 
								</File>
 | 
				
			||||||
			<File
 | 
								<File
 | 
				
			||||||
				RelativePath="..\meta_api.cpp">
 | 
									RelativePath="..\meta_api.cpp">
 | 
				
			||||||
			</File>
 | 
								</File>
 | 
				
			||||||
@@ -774,6 +777,12 @@
 | 
				
			|||||||
			<File
 | 
								<File
 | 
				
			||||||
				RelativePath="..\CPlugin.h">
 | 
									RelativePath="..\CPlugin.h">
 | 
				
			||||||
			</File>
 | 
								</File>
 | 
				
			||||||
 | 
								<File
 | 
				
			||||||
 | 
									RelativePath="..\CQueue.h">
 | 
				
			||||||
 | 
								</File>
 | 
				
			||||||
 | 
								<File
 | 
				
			||||||
 | 
									RelativePath="..\CRList.h">
 | 
				
			||||||
 | 
								</File>
 | 
				
			||||||
			<File
 | 
								<File
 | 
				
			||||||
				RelativePath="..\CString.h">
 | 
									RelativePath="..\CString.h">
 | 
				
			||||||
			</File>
 | 
								</File>
 | 
				
			||||||
@@ -789,6 +798,9 @@
 | 
				
			|||||||
			<File
 | 
								<File
 | 
				
			||||||
				RelativePath="..\fakemeta.h">
 | 
									RelativePath="..\fakemeta.h">
 | 
				
			||||||
			</File>
 | 
								</File>
 | 
				
			||||||
 | 
								<File
 | 
				
			||||||
 | 
									RelativePath="..\md5.h">
 | 
				
			||||||
 | 
								</File>
 | 
				
			||||||
			<File
 | 
								<File
 | 
				
			||||||
				RelativePath="..\modules.h">
 | 
									RelativePath="..\modules.h">
 | 
				
			||||||
			</File>
 | 
								</File>
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user