Updated Copyright year to 2013
[getmangos.git] / src / realmd / PatchHandler.h
blob72e12b11d6c54e93dabfa99b708cc339700def42
1 /*
2 * Copyright (C) 2005-2013 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 /** \file
20 \ingroup realmd
23 #ifndef _PATCHHANDLER_H_
24 #define _PATCHHANDLER_H_
26 #include <ace/Basic_Types.h>
27 #include <ace/Synch_Traits.h>
28 #include <ace/Svc_Handler.h>
29 #include <ace/SOCK_Stream.h>
30 #include <ace/Message_Block.h>
31 #include <ace/Auto_Ptr.h>
32 #include <map>
34 #include <openssl/bn.h>
35 #include <openssl/md5.h>
37 /**
38 * @brief Caches MD5 hash of client patches present on the server
40 class PatchCache
42 public:
43 ~PatchCache();
44 PatchCache();
46 static PatchCache* instance();
48 struct PATCH_INFO
50 ACE_UINT8 md5[MD5_DIGEST_LENGTH];
53 typedef std::map<std::string, PATCH_INFO*> Patches;
55 Patches::const_iterator begin() const
57 return patches_.begin();
60 Patches::const_iterator end() const
62 return patches_.end();
65 void LoadPatchMD5(const char*);
66 bool GetHash(const char* pat, ACE_UINT8 mymd5[MD5_DIGEST_LENGTH]);
68 private:
69 void LoadPatchesInfo();
70 Patches patches_;
74 class PatchHandler: public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
76 protected:
77 typedef ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH> Base;
79 public:
80 PatchHandler(ACE_HANDLE socket, ACE_HANDLE patch);
81 virtual ~PatchHandler();
83 int open(void* = 0) override;
85 protected:
86 virtual int svc(void) override;
88 private:
89 ACE_HANDLE patch_fd_;
93 #endif /* _BK_PATCHHANDLER_H__ */