├── .gitignore ├── LICENSE ├── README.md └── sptrunk ├── Clear.bat ├── Common ├── AdvanceLib │ ├── AdvanceLib_VC10.vcxproj │ ├── CommonHeader.h │ ├── Console │ │ ├── ConsoleI.cpp │ │ ├── ConsoleI.h │ │ ├── ConsoleO.cpp │ │ └── ConsoleO.h │ ├── GlobalDefine.h │ ├── Socket │ │ ├── Acceptor.cpp │ │ ├── Acceptor.h │ │ ├── Connector.cpp │ │ ├── Connector.h │ │ ├── IOPacket.cpp │ │ ├── IOPacket.h │ │ ├── MessageEncrypt.cpp │ │ ├── MessageEncrypt.h │ │ ├── NetMsg.cpp │ │ ├── NetMsg.h │ │ ├── Session.cpp │ │ ├── Session.h │ │ ├── Socket.cpp │ │ └── Socket.h │ └── Thread │ │ └── ThreadCPU.h └── Utility │ ├── ByteBuffer.h │ ├── CheckAndAssert_t.h │ ├── FunctionMap.cpp │ ├── FunctionMap.h │ ├── Global.cpp │ ├── Global.h │ ├── List.h │ ├── LogAssert.h │ ├── MemBand.h │ ├── MemoryCache.cpp │ ├── MemoryCache.h │ ├── MemoryPool.h │ ├── MemoryPoolBase.h │ ├── MemoryPoolFactory.h │ ├── Narray.h │ ├── Nstring.h │ ├── SafeMemoryPoolFactory.h │ ├── Singleton.h │ ├── SolarFileReader.cpp │ ├── SolarFileReader.h │ ├── Stackwalker.cpp │ ├── Stackwalker.h │ ├── Timer.h │ ├── UtilityCommon.h │ ├── Utility_VC10.vcxproj │ ├── WorldPacket.h │ ├── WzDataType.cpp │ ├── nhashtable.h │ ├── nlinebuffer.h │ ├── nlist.h │ ├── nmath.h │ ├── nnode.h │ ├── nstrlist.h │ └── nstrnode.h ├── Makefile ├── PushServer ├── ClientAcceptor.cpp ├── ClientAcceptor.h ├── CommonHeader.h ├── DBConnector.cpp ├── DBConnector.h ├── GlobalDefine.h ├── Main.cpp ├── MsgDefine.h ├── MsgHandler.cpp ├── MsgHandler.h ├── MsgHandler_CS.cpp ├── MsgHandler_WS.cpp ├── MsgStruct_CS.h ├── MsgStruct_WS.h ├── NetThread.cpp ├── NetThread.h ├── PushServer.cpp ├── PushServer.h ├── PushServer.vcxproj ├── ReadMe.txt ├── ServerConfig.cpp ├── ServerConfig.h ├── UserManager.cpp ├── UserManager.h ├── WebSvrConnector.cpp └── WebSvrConnector.h ├── PushServer_VC10.sln ├── _Android └── AndroidApp │ ├── .classpath │ ├── .project │ ├── bin │ ├── AppMain.class │ ├── MSG_C2S_USER_AUTH_SYN.class │ ├── MSG_S2C_SVR_READY_CMD.class │ ├── MSG_S2C_USER_AUTH_ACK.class │ ├── MsgBase.class │ └── MsgHandler.class │ └── src │ ├── AppMain.java │ ├── MsgBase.java │ └── MsgHandler.java ├── _Bin └── Server │ ├── AgentServer.ini │ ├── LoginServer.ini │ ├── Server.ini │ └── ServerOption.ini └── _Web ├── index.php ├── msgbase.php ├── msghandler.php └── netcommon.php /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SunPush 2 | ======= 3 | 4 | SunPush is a push server ! 5 | 6 | 已经用于生产实践,鼓励大家使用,并免费提供技术支持。 7 | -------------------------------------------------------------------------------- /sptrunk/Clear.bat: -------------------------------------------------------------------------------- 1 | del /q /s PushServer_VC10.sdf 2 | del /q /s _Bin\Server\PushServer_d.pdb 3 | del /q /s _Bin\Server\PushServer_d.ilk 4 | del /q /s _Bin\Server\PushServer_d.exe 5 | 6 | del /q /s _Bin\Server\RCXC1.tmp 7 | del /q /s _Bin\Server\RCXC3.tmp 8 | 9 | del /q /s _Bin\Server\AgentServerV3_d.pdb 10 | del /q /s _Bin\Server\AgentServerV3_d.ilk 11 | del /q /s _Bin\Server\AgentServerV3_d.exe 12 | 13 | rmdir /q /s _Build10 14 | rmdir /q /s _Lib 15 | 16 | 17 | del /q /s _Tension\_Bin\TensionClientSE.exe 18 | del /q /s _Tension\_Bin\TensionClientSE.ilk 19 | del /q /s _Tension\_Bin\TensionClientSE.pdb 20 | del /q /s _Tension\Src\TensionClientSE.sdf 21 | 22 | rmdir /q /s _Tension\_Build10 23 | rmdir /q /s _Tension\_Lib -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/AdvanceLib_VC10.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | AdvanceLib 15 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2} 16 | AdvanceLib 17 | Win32Proj 18 | 19 | 20 | 21 | StaticLibrary 22 | MultiByte 23 | true 24 | 25 | 26 | StaticLibrary 27 | MultiByte 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | <_ProjectFileVersion>10.0.40219.1 41 | ../../_Lib/ 42 | ../../_Build10/$(Configuration)/$(ProjectName)\ 43 | ../../Lib/ 44 | ../../_Build10/$(Configuration)/$(ProjectName)\ 45 | AllRules.ruleset 46 | 47 | 48 | AllRules.ruleset 49 | 50 | 51 | $(BOOST_PATH)\include;$(IncludePath) 52 | $(LibraryPath) 53 | $(ProjectName)_vc10d 54 | $(ProjectName)_vc10 55 | D:\Project\SDK\boost_1_46_1;$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(WindowsSdkDir)include;$(FrameworkSDKDir)\include; 56 | D:\Project\SDK\boost_1_46_1\stage\lib;$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(WindowsSdkDir)lib;$(FrameworkSDKDir)\lib 57 | 58 | 59 | 60 | Disabled 61 | %(AdditionalIncludeDirectories) 62 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) 63 | true 64 | EnableFastChecks 65 | MultiThreadedDebug 66 | NotUsing 67 | TurnOffAllWarnings 68 | ProgramDatabase 69 | 70 | 71 | 72 | 73 | 74 | MaxSpeed 75 | true 76 | %(AdditionalIncludeDirectories) 77 | _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) 78 | MultiThreaded 79 | true 80 | false 81 | Use 82 | TurnOffAllWarnings 83 | ProgramDatabase 84 | 85 | 86 | 87 | $(OutDir)$(TargetName)$(TargetExt) 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/CommonHeader.h: -------------------------------------------------------------------------------- 1 | 2 | #pragma once 3 | #define BOOST_NO_RTTI 4 | //#define BOOST_ASIO_ENABLE_CANCELIO 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | 29 | #define max(a,b) (((a) > (b)) ? (a) : (b)) 30 | #define min(a,b) (((a) < (b)) ? (a) : (b)) 31 | 32 | #include "Console/ConsoleO.h" 33 | 34 | -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Console/ConsoleI.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Console/ConsoleI.cpp -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Console/ConsoleI.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Console/ConsoleI.h -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Console/ConsoleO.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Console/ConsoleO.cpp -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Console/ConsoleO.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Console/ConsoleO.h -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/GlobalDefine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/GlobalDefine.h -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Socket/Acceptor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Socket/Acceptor.cpp -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Socket/Acceptor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Socket/Acceptor.h -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Socket/Connector.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Socket/Connector.cpp -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Socket/Connector.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Socket/Connector.h -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Socket/IOPacket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Socket/IOPacket.cpp -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Socket/IOPacket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Socket/IOPacket.h -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Socket/MessageEncrypt.cpp: -------------------------------------------------------------------------------- 1 | #include "../CommonHeader.h" 2 | #include "MessageEncrypt.h" 3 | 4 | MessageEncrypt::MessageEncrypt() 5 | { 6 | m_nPos1 = 0; 7 | m_nPos2 = 0; 8 | InitKey(KEY_A1, KEY_B1, KEY_C1, KEY_FST1, KEY_A2, KEY_B2, KEY_C2, KEY_FST2); 9 | } 10 | 11 | MessageEncrypt::~MessageEncrypt() 12 | { 13 | } 14 | 15 | void MessageEncrypt::InitKey(UINT8 a1, UINT8 b1, UINT8 c1, UINT8 fst1, UINT8 a2, UINT8 b2, UINT8 c2, UINT8 fst2) 16 | { 17 | unsigned char nCode = fst1; 18 | int i = 0; 19 | for(i = 0; i < 256; i++) 20 | { 21 | m_bufEncrypt1[i] = nCode; 22 | nCode = (a1*nCode*nCode + b1*nCode + c1) % 256; 23 | } 24 | 25 | nCode = fst2; 26 | for( i = 0; i < 256; i++) 27 | { 28 | m_bufEncrypt2[i] = nCode; 29 | nCode = (a2*nCode*nCode + b2*nCode + c2) % 256; 30 | } 31 | 32 | push_stack1(); 33 | push_stack2(); 34 | push_stack3(); 35 | 36 | } 37 | 38 | UINT8 MessageEncrypt::rotate_left_char(unsigned char nData, unsigned long nCount) 39 | { 40 | nCount %= 8; 41 | unsigned long lData = nData << nCount; 42 | unsigned long lData2 = nData >> (8-nCount); 43 | return static_cast((lData2 | lData) & 0xff); 44 | } 45 | 46 | 47 | UINT8 MessageEncrypt::rotate_right_char(unsigned char nData, unsigned long nCount) 48 | { 49 | nCount %= 8; 50 | unsigned lData = nData >> nCount; 51 | unsigned lData2 = nData << (8-nCount); 52 | return static_cast((lData | lData2) & 0xff); 53 | } 54 | 55 | 56 | void MessageEncrypt::Encrypt(unsigned char * bufMsg, int nLen, bool bMove, int resv,int resv2,int resv3,int resv4,int resv5,int resv6,int resv7) 57 | { 58 | try{ 59 | int nOldPos1 = m_nPos1; 60 | int nOldPos2 = m_nPos2; 61 | for(int i = 0; i < nLen; i++) 62 | { 63 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1]; 64 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * 0x33f; 65 | bufMsg[i] ^= m_bufEncrypt2[m_nPos2]; 66 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2]; 67 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2] / 0x23df; 68 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] + m_bufEncrypt2[m_nPos2] +0x34fee; 69 | bufMsg[i] ^= m_nPos1; 70 | bufMsg[i] ^= m_nPos2; 71 | if( m_nPos2 & 0x31 ) 72 | { 73 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * 0x3423f; 74 | bufMsg[i] ^= m_nPos1*2344; 75 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2]; 76 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2] / 0x233fedf * m_nPos2; 77 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] + m_bufEncrypt2[m_nPos2] +0x343fee; 78 | bufMsg[i] ^= m_nPos1; 79 | bufMsg[i] ^= m_nPos2; 80 | //bufMsg[i] = rotate_right_char(bufMsg[i],m_nPos1); 81 | } 82 | 83 | if( m_nPos1 & 0x3 ) 84 | { 85 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * 0x3422f; 86 | bufMsg[i] ^= m_nPos1+m_nPos2+0x234a; 87 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2]*2; 88 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2] / 0x233fedf * m_nPos2; 89 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] + m_bufEncrypt2[m_nPos2] + 0x343fee; 90 | bufMsg[i] ^= m_nPos2; 91 | //bufMsg[i] = rotate_left_char(bufMsg[i],m_nPos2); 92 | } 93 | 94 | if( (m_nPos1 & 0x13) == 0 ) 95 | { 96 | //bufMsg[i] = rotate_left_char(bufMsg[i],m_bufEncrypt1[m_nPos1]); 97 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * 0x3422f; 98 | bufMsg[i] ^= m_nPos1+33; 99 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2]*2; 100 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2] / 0x233fedf * m_nPos2; 101 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] + m_bufEncrypt2[m_nPos2] + 0x343fee; 102 | bufMsg[i] ^= m_nPos2; 103 | } 104 | if( m_nPos1 * m_bufEncrypt2[m_nPos2] % 0x9 == 1 ) 105 | { 106 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * 0x342f; 107 | bufMsg[i] ^= m_nPos1+31; 108 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2]*2; 109 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2] / 0x233fedf * m_nPos1; 110 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] + m_bufEncrypt2[m_nPos2] + 0x343fee; 111 | bufMsg[i] ^= m_nPos2; 112 | //bufMsg[i] = rotate_right_char(bufMsg[i],m_nPos1*3); 113 | 114 | } 115 | 116 | //bufMsg[i] = rotate_right_char(bufMsg[i],m_bufEncrypt1[m_nPos1] + m_bufEncrypt2[m_nPos2] ); 117 | bufMsg[i] = rotate_left_char(bufMsg[i],m_bufEncrypt1[m_nPos1] + m_bufEncrypt2[m_nPos2] +0x34fee); 118 | 119 | if(++m_nPos1 >= 256) 120 | { 121 | m_nPos1 = 0; 122 | if(++m_nPos2 >= 256) 123 | m_nPos2 = 0; 124 | } 125 | assert(m_nPos1 >=0 && m_nPos1 < 256); 126 | assert(m_nPos2 >=0 && m_nPos2 < 256); 127 | } 128 | 129 | if(!bMove) 130 | { 131 | m_nPos1 = nOldPos1; 132 | m_nPos2 = nOldPos2; 133 | } 134 | }catch(...){ 135 | //LOGCATCH("Encrypt fail."); 136 | } 137 | } 138 | 139 | void MessageEncrypt::Decrypt(unsigned char * bufMsg, int nLen, bool bMove,int resv,int resv2,int resv3,int resv4,int resv5,int resv6,int resv7) 140 | { 141 | try{ 142 | int nOldPos1 = m_nPos1; 143 | int nOldPos2 = m_nPos2; 144 | for(int i = 0; i < nLen; i++) 145 | { 146 | bufMsg[i] = rotate_right_char(bufMsg[i],m_bufEncrypt1[m_nPos1] + m_bufEncrypt2[m_nPos2] +0x34fee); 147 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1]; 148 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * 0x33f; 149 | bufMsg[i] ^= m_bufEncrypt2[m_nPos2]; 150 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2]; 151 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2] / 0x23df; 152 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] + m_bufEncrypt2[m_nPos2] +0x34fee; 153 | bufMsg[i] ^= m_nPos1; 154 | bufMsg[i] ^= m_nPos2; 155 | if( m_nPos2 & 0x31 ) 156 | { 157 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * 0x3423f; 158 | bufMsg[i] ^= m_nPos1*2344; 159 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2]; 160 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2] / 0x233fedf * m_nPos2; 161 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] + m_bufEncrypt2[m_nPos2] +0x343fee; 162 | bufMsg[i] ^= m_nPos1; 163 | bufMsg[i] ^= m_nPos2; 164 | //bufMsg[i] = rotate_left_char(bufMsg[i],m_nPos1); 165 | } 166 | 167 | if( m_nPos1 & 0x3 ) 168 | { 169 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * 0x3422f; 170 | bufMsg[i] ^= m_nPos1+m_nPos2+0x234a; 171 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2]*2; 172 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2] / 0x233fedf * m_nPos2; 173 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] + m_bufEncrypt2[m_nPos2] + 0x343fee; 174 | bufMsg[i] ^= m_nPos2; 175 | //bufMsg[i] = rotate_right_char(bufMsg[i],m_nPos2); 176 | } 177 | 178 | if( (m_nPos1 & 0x13) == 0 ) 179 | { 180 | //bufMsg[i] = rotate_right_char(bufMsg[i],m_bufEncrypt1[m_nPos1]); 181 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * 0x3422f; 182 | bufMsg[i] ^= m_nPos1+33; 183 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2]*2; 184 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2] / 0x233fedf * m_nPos2; 185 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] + m_bufEncrypt2[m_nPos2] + 0x343fee; 186 | bufMsg[i] ^= m_nPos2; 187 | } 188 | if( m_nPos1 * m_bufEncrypt2[m_nPos2] % 0x9 == 1 ) 189 | { 190 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * 0x342f; 191 | bufMsg[i] ^= m_nPos1+31; 192 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2]*2; 193 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] * m_bufEncrypt2[m_nPos2] / 0x233fedf * m_nPos1; 194 | bufMsg[i] ^= m_bufEncrypt1[m_nPos1] + m_bufEncrypt2[m_nPos2] + 0x343fee; 195 | bufMsg[i] ^= m_nPos2; 196 | //bufMsg[i] = rotate_left_char(bufMsg[i],m_nPos1*3); 197 | 198 | } 199 | 200 | //bufMsg[i] = rotate_left_char(bufMsg[i],m_bufEncrypt1[m_nPos1] + m_bufEncrypt2[m_nPos2] ); 201 | 202 | if(++m_nPos1 >= 256) 203 | { 204 | m_nPos1 = 0; 205 | if(++m_nPos2 >= 256) 206 | m_nPos2 = 0; 207 | } 208 | assert(m_nPos1 >=0 && m_nPos1 < 256); 209 | assert(m_nPos2 >=0 && m_nPos2 < 256); 210 | } 211 | 212 | if(!bMove) 213 | { 214 | m_nPos1 = nOldPos1; 215 | m_nPos2 = nOldPos2; 216 | } 217 | }catch(...){ 218 | //LOGCATCH("Encrypt fail."); 219 | } 220 | 221 | } 222 | 223 | 224 | void MessageEncrypt::push_stack1() 225 | { 226 | for(int i = 0; i < 10; i++ ) 227 | { 228 | m_bufEncrypt1[i*4+1] ^= m_bufEncrypt2[i*4+3]; 229 | } 230 | } 231 | void MessageEncrypt::push_stack2() 232 | { 233 | for(int i = 0; i < 5; i++ ) 234 | { 235 | m_bufEncrypt1[i*4 + 50] ^= m_bufEncrypt2[i*4+2+50]; 236 | } 237 | } 238 | void MessageEncrypt::push_stack3() 239 | { 240 | for(int i = 0; i < 5; i++ ) 241 | { 242 | m_bufEncrypt1[i*4 + 50] ^= m_bufEncrypt2[i*4+2+50]; 243 | } 244 | } 245 | 246 | void MessageEncrypt::pop_stack1() 247 | { 248 | push_stack1(); 249 | } 250 | void MessageEncrypt::pop_stack2() 251 | { 252 | push_stack2(); 253 | } 254 | 255 | void MessageEncrypt::pop_stack3() 256 | { 257 | push_stack3(); 258 | } -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Socket/MessageEncrypt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | const int KEY_A1 = 0x5a; 4 | const int KEY_B1 = 0X24; 5 | const int KEY_C1 = 0X11; 6 | const int KEY_FST1 = 0Xfe; 7 | const int KEY_A2 = 0Xa1; 8 | const int KEY_B2 = 0X88; 9 | const int KEY_C2 = 0X12; 10 | const int KEY_FST2 = 0Xfc; 11 | 12 | 13 | class MessageEncrypt 14 | { 15 | public: 16 | MessageEncrypt(); 17 | virtual ~MessageEncrypt(); 18 | 19 | void Encrypt(unsigned char * bufMsg, int nLen, bool bMove = true, 20 | int resv = 4422,int resv2 = 2244,int resv3 = 42,int resv4 = 4422,int resv5 = 4452,int resv6 = 42,int resv7 = 0xff342); 21 | void Decrypt(unsigned char * bufMsg, int nLen, bool bMove = true, 22 | int resv = 4422,int resv2 = 2244,int resv3 = 42,int resv4 = 4422,int resv5 = 4452,int resv6 = 42,int resv7 = 0xff342); 23 | 24 | protected: 25 | 26 | void InitKey(unsigned char a1, unsigned char b1, unsigned char c1, unsigned char fst1, unsigned char a2, unsigned char b2, unsigned char c2, unsigned char fst2); 27 | unsigned char rotate_left_char(unsigned char nData, unsigned long nCount); 28 | unsigned char rotate_right_char(unsigned char nData, unsigned long nCount); 29 | 30 | void inline push_stack1(); 31 | void inline push_stack2(); 32 | void inline push_stack3(); 33 | 34 | void inline pop_stack1(); 35 | void inline pop_stack2(); 36 | void inline pop_stack3(); 37 | 38 | int m_nPos1; 39 | int m_nPos2; 40 | unsigned char m_bufEncrypt1[256]; 41 | unsigned char m_bufEncrypt2[256]; 42 | 43 | }; 44 | -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Socket/NetMsg.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Socket/NetMsg.cpp -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Socket/NetMsg.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Socket/NetMsg.h -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Socket/Session.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Socket/Session.cpp -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Socket/Session.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Socket/Session.h -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Socket/Socket.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Socket/Socket.cpp -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Socket/Socket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/AdvanceLib/Socket/Socket.h -------------------------------------------------------------------------------- /sptrunk/Common/AdvanceLib/Thread/ThreadCPU.h: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | int GetProcessCount(void) 4 | { 5 | SYSTEM_INFO sysInfo; 6 | GetSystemInfo(&sysInfo); 7 | 8 | return sysInfo.dwNumberOfProcessors; 9 | } 10 | 11 | static CCriticalSection s_critical; 12 | DWORD GetCPUUsage(HANDLE hThread) 13 | { 14 | s_critical.Lock(); 15 | 16 | // Declare four FILETIME. 17 | FILETIME ftCreate, ftExit, ftKernel, ftUser; 18 | // Declare the following variable to convert FILE to 100-nanosecond unit. 19 | LARGE_INTEGER lpIntKernelStart, lpIntUserStart, lpIntKernelEnd, lpIntUserEnd; 20 | 21 | // Record the start time. 22 | clock_t startTime = clock(); 23 | 24 | // Get the first file time. 25 | if (!GetThreadTimes(hThread, &ftCreate, &ftExit, &ftKernel, &ftUser)) 26 | { 27 | return 0; 28 | } 29 | // Convert FILETIME to 100-nanosecond. 30 | lpIntKernelStart.QuadPart = MAKELONGLONG(ftKernel.dwLowDateTime, ftKernel.dwHighDateTime); 31 | lpIntUserStart.QuadPart = MAKELONGLONG(ftUser.dwLowDateTime, ftUser.dwHighDateTime); 32 | 33 | Sleep(10); // Some action, like this. 34 | 35 | // Get the second file time. 36 | if (!GetThreadTimes(hThread, &ftCreate, &ftExit, &ftKernel, &ftUser)) 37 | { 38 | return 0; 39 | } 40 | // Convert FILETIME to 100-nanosecond. 41 | lpIntKernelEnd.QuadPart = MAKELONGLONG(ftKernel.dwLowDateTime, ftKernel.dwHighDateTime); 42 | lpIntUserEnd.QuadPart = MAKELONGLONG(ftUser.dwLowDateTime, ftUser.dwHighDateTime); 43 | 44 | // Calculate the runtime that kernel time add user time. 45 | LONGLONG lRunTime = (lpIntKernelEnd.QuadPart - lpIntKernelStart.QuadPart) + (lpIntUserEnd.QuadPart - lpIntUserStart.QuadPart) / 10000; 46 | // Calculate the system time lapsed. 47 | LONGLONG lLapse = (LONGLONG)(clock() - startTime); 48 | 49 | // Get count of CPU. 50 | int CPUCount = GetProcessCount(); 51 | 52 | // Percent = (kerneltime + usertime) / (now - starttime) / numberofcpus. 53 | int nPercent = (int)(lRunTime * 100 / lLapse / CPUCount); 54 | 55 | s_critical.Unlock(); 56 | 57 | return nPercent; 58 | } 59 | -------------------------------------------------------------------------------- /sptrunk/Common/Utility/ByteBuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ByteBuffer.h 3 | * Multi Platform Network Byte Buffer 4 | * Copyright (C) 2010-2012 XXZ Team 5 | * Create by Along 2011.11.09 6 | * Last update 7 | */ 8 | 9 | #ifndef __BYTEBUFFER_H__ 10 | #define __BYTEBUFFER_H__ 11 | 12 | #include "UtilityCommon.h" 13 | #define MAX_ARR_SIZE 1024 14 | 15 | class ByteBuffer 16 | { 17 | public: 18 | class error 19 | { 20 | }; 21 | 22 | // Default 4K 23 | const static size_t DEFAULT_SIZE = 0x1000; 24 | 25 | ByteBuffer(): _rpos(0), _wpos(0) 26 | { 27 | _storage.reserve(DEFAULT_SIZE); 28 | } 29 | 30 | ByteBuffer(size_t res): _rpos(0), _wpos(0) 31 | { 32 | _storage.reserve(res); 33 | } 34 | 35 | ByteBuffer(const ByteBuffer &buf): _rpos(buf._rpos), _wpos(buf._wpos), _storage(buf._storage) { } 36 | virtual ~ByteBuffer() {} 37 | 38 | void clear() 39 | { 40 | _storage.clear(); 41 | _rpos = _wpos = 0; 42 | } 43 | 44 | //template void insert(size_t pos, T value) { 45 | // insert(pos, (uint8 *)&value, sizeof(value)); 46 | //} 47 | template void append(T value) 48 | { 49 | append((uint8 *)&value, sizeof(value)); 50 | } 51 | 52 | template void put(size_t pos, T value) 53 | { 54 | put(pos, (uint8 *)&value, sizeof(value)); 55 | } 56 | 57 | // stream like operators for storing data 58 | ByteBuffer &operator<<(bool value) 59 | { 60 | append((char)value); 61 | return *this; 62 | } 63 | 64 | // unsigned 65 | ByteBuffer &operator<<(uint8 value) 66 | { 67 | append(value); 68 | return *this; 69 | } 70 | 71 | ByteBuffer &operator<<(uint16 value) 72 | { 73 | append(value); 74 | return *this; 75 | } 76 | 77 | ByteBuffer &operator<<(uint32 value) 78 | { 79 | append(value); 80 | return *this; 81 | } 82 | 83 | ByteBuffer &operator<<(uint64 value) 84 | { 85 | append(value); 86 | return *this; 87 | } 88 | 89 | // signed 90 | ByteBuffer &operator<<(int8 value) 91 | { 92 | append(value); 93 | return *this; 94 | } 95 | 96 | ByteBuffer &operator<<(int16 value) 97 | { 98 | append(value); 99 | return *this; 100 | } 101 | 102 | ByteBuffer &operator<<(int32 value) 103 | { 104 | append(value); 105 | return *this; 106 | } 107 | 108 | ByteBuffer &operator<<(int64 value) 109 | { 110 | append(value); 111 | return *this; 112 | } 113 | 114 | ByteBuffer &operator<<(float value) 115 | { 116 | append(value); 117 | return *this; 118 | } 119 | 120 | ByteBuffer &operator<<(double value) 121 | { 122 | append(value); 123 | return *this; 124 | } 125 | 126 | ByteBuffer &operator<<(const std::string &value) 127 | { 128 | uint32 len = (uint32)value.length() + 1; 129 | *this << len; 130 | append((uint8 *)value.c_str(), value.length()); 131 | append((uint8)0); 132 | return *this; 133 | } 134 | 135 | ByteBuffer &operator<<(const char *str) 136 | { 137 | uint32 len = (uint32)strlen(str) + 1; 138 | *this << len; 139 | append((uint8 *)str, strlen(str)); 140 | append((uint8)0); 141 | return *this; 142 | } 143 | 144 | // stream like operators for reading data 145 | ByteBuffer &operator>>(bool &value) 146 | { 147 | value = read() > 0 ? true : false; 148 | return *this; 149 | } 150 | 151 | //unsigned 152 | ByteBuffer &operator>>(uint8 &value) 153 | { 154 | value = read(); 155 | return *this; 156 | } 157 | 158 | ByteBuffer &operator>>(uint16 &value) 159 | { 160 | value = read(); 161 | return *this; 162 | } 163 | 164 | ByteBuffer &operator>>(uint32 &value) 165 | { 166 | value = read(); 167 | return *this; 168 | } 169 | 170 | ByteBuffer &operator>>(uint64 &value) 171 | { 172 | value = read(); 173 | return *this; 174 | } 175 | 176 | //signed 177 | ByteBuffer &operator>>(int8 &value) 178 | { 179 | value = read(); 180 | return *this; 181 | } 182 | 183 | ByteBuffer &operator>>(int16 &value) 184 | { 185 | value = read(); 186 | return *this; 187 | } 188 | 189 | ByteBuffer &operator>>(int32 &value) 190 | { 191 | value = read(); 192 | return *this; 193 | } 194 | 195 | ByteBuffer &operator>>(int64 &value) 196 | { 197 | value = read(); 198 | return *this; 199 | } 200 | 201 | ByteBuffer &operator>>(float &value) 202 | { 203 | value = read(); 204 | return *this; 205 | } 206 | 207 | ByteBuffer &operator>>(double &value) 208 | { 209 | value = read(); 210 | return *this; 211 | } 212 | 213 | ByteBuffer &operator>>(std::string& value) 214 | { 215 | uint32 len = 0; 216 | *this >> len; 217 | 218 | value.clear(); 219 | 220 | while (len) 221 | { 222 | char c = read(); 223 | 224 | if (0 == c) 225 | break; 226 | 227 | value += c; 228 | --len; 229 | } 230 | 231 | return *this; 232 | } 233 | 234 | /* 235 | ByteBuffer &operator>>(std::string& value) 236 | { 237 | value.clear(); 238 | 239 | while (true) 240 | { 241 | char c = read(); 242 | 243 | if (0 == c) 244 | break; 245 | 246 | value += c; 247 | } 248 | 249 | return *this; 250 | }*/ 251 | 252 | uint8 operator[](size_t pos) 253 | { 254 | return read(pos); 255 | } 256 | 257 | size_t rpos() 258 | { 259 | return _rpos; 260 | }; 261 | 262 | size_t rpos(size_t rpos) 263 | { 264 | _rpos = rpos; 265 | return _rpos; 266 | }; 267 | 268 | size_t wpos() 269 | { 270 | return _wpos; 271 | } 272 | 273 | size_t wpos(size_t wpos) 274 | { 275 | _wpos = wpos; 276 | return _wpos; 277 | } 278 | 279 | template T read() 280 | { 281 | T r = read(_rpos); 282 | _rpos += sizeof(T); 283 | 284 | return r; 285 | } 286 | 287 | template T read(size_t pos) const 288 | { 289 | //ASSERT(pos + sizeof(T) <= size()); 290 | if(pos + sizeof(T) > size()) 291 | { 292 | return (T)0; 293 | } 294 | else 295 | { 296 | return *((T*)&_storage[pos]); 297 | } 298 | } 299 | 300 | void read(uint8 *dest, size_t len) 301 | { 302 | if (_rpos + len <= size()) 303 | { 304 | memcpy(dest, &_storage[_rpos], len); 305 | } 306 | else 307 | { 308 | //throw error(); 309 | memset(dest, 0, len); 310 | } 311 | 312 | _rpos += len; 313 | } 314 | 315 | const uint8 *contents() const 316 | { 317 | return &_storage[0]; 318 | }; 319 | 320 | XY_INLINE size_t size() const { return _storage.size(); }; 321 | 322 | // one should never use resize probably 323 | void resize(size_t newsize) 324 | { 325 | _storage.resize(newsize); 326 | _rpos = 0; 327 | _wpos = size(); 328 | }; 329 | 330 | void reserve(size_t ressize) 331 | { 332 | if (ressize > size()) _storage.reserve(ressize); 333 | }; 334 | 335 | // appending to the end of buffer 336 | void append(const std::string& str) 337 | { 338 | append((uint8 *)str.c_str(), str.size() + 1); 339 | } 340 | 341 | void append(const char *src, size_t cnt) 342 | { 343 | return append((const uint8 *)src, cnt); 344 | } 345 | 346 | void append(const uint8 *src, size_t cnt) 347 | { 348 | if (!cnt) return; 349 | 350 | ASSERT(size() < 10000000); 351 | 352 | if (_storage.size() < _wpos + cnt) 353 | _storage.resize(_wpos + cnt); 354 | 355 | memcpy(&_storage[_wpos], src, cnt); 356 | _wpos += cnt; 357 | } 358 | 359 | void append(const ByteBuffer& buffer) 360 | { 361 | if(buffer.size() > 0) append(buffer.contents(), buffer.size()); 362 | } 363 | 364 | void put(size_t pos, const uint8 *src, size_t cnt) 365 | { 366 | ASSERT(pos + cnt <= size()); 367 | memcpy(&_storage[pos], src, cnt); 368 | } 369 | 370 | //void insert(size_t pos, const uint8 *src, size_t cnt) { 371 | // std::copy(src, src + cnt, inserter(_storage, _storage.begin() + pos)); 372 | //} 373 | 374 | void hexlike() 375 | { 376 | uint32 j = 1, k = 1; 377 | printf("STORAGE_SIZE: %u\n", (unsigned int)size() ); 378 | for(uint32 i = 0; i < size(); ++i) 379 | { 380 | if ((i == (j*8)) && ((i != (k*16)))) 381 | { 382 | if (read(i) < 0x0F) 383 | { 384 | printf("| 0%X ", read(i) ); 385 | } 386 | else 387 | { 388 | printf("| %X ", read(i) ); 389 | } 390 | 391 | j++; 392 | } 393 | else if (i == (k * 16)) 394 | { 395 | rpos(rpos() - 16); // move read pointer 16 places back 396 | printf(" | "); // write split char 397 | 398 | for (int x = 0; x < 16; x++) 399 | { 400 | printf("%c", read(i-16 + x) ); 401 | } 402 | 403 | if (read(i) < 0x0F) 404 | { 405 | printf("\n0%X ", read(i) ); 406 | } 407 | else 408 | { 409 | printf("\n%X ", read(i) ); 410 | } 411 | 412 | k++; 413 | j++; 414 | } 415 | else 416 | { 417 | if (read(i) < 0x0F) 418 | { 419 | printf("0%X ", read(i) ); 420 | } 421 | else 422 | { 423 | printf("%X ", read(i) ); 424 | } 425 | } 426 | } 427 | printf("\n"); 428 | } 429 | 430 | XY_INLINE void reverse() 431 | { 432 | std::reverse(_storage.begin(), _storage.end()); 433 | } 434 | 435 | protected: 436 | // read and write position 437 | size_t _rpos; 438 | size_t _wpos; 439 | vector _storage; 440 | }; 441 | 442 | /////////////////////////////////////////////////////////////////////////////// 443 | ///////////////////////////////STL template//////////////////////////////////// 444 | /////////////////////////////////////////////////////////////////////////////// 445 | 446 | template ByteBuffer &operator<<(ByteBuffer &b, std::vector v) 447 | { 448 | b << (uint32)v.size(); 449 | 450 | for (typename std::vector::iterator i = v.begin(); i != v.end(); ++i) 451 | { 452 | b << *i; 453 | } 454 | return b; 455 | } 456 | 457 | template ByteBuffer &operator>>(ByteBuffer &b, std::vector &v) 458 | { 459 | uint32 vsize; 460 | b >> vsize; 461 | v.clear(); 462 | 463 | if (vsize > MAX_ARR_SIZE) 464 | { 465 | return b; 466 | } 467 | 468 | while(vsize--) 469 | { 470 | T t; 471 | b >> t; 472 | v.push_back(t); 473 | } 474 | 475 | return b; 476 | } 477 | 478 | template ByteBuffer &operator<<(ByteBuffer &b, std::list v) 479 | { 480 | b << (uint32)v.size(); 481 | 482 | for (typename std::list::iterator i = v.begin(); i != v.end(); ++i) 483 | { 484 | b << *i; 485 | } 486 | return b; 487 | } 488 | 489 | template ByteBuffer &operator>>(ByteBuffer &b, std::list &v) 490 | { 491 | uint32 vsize; 492 | b >> vsize; 493 | v.clear(); 494 | 495 | if (vsize > MAX_ARR_SIZE) 496 | { 497 | return b; 498 | } 499 | 500 | while(vsize--) 501 | { 502 | T t; 503 | b >> t; 504 | v.push_back(t); 505 | } 506 | 507 | return b; 508 | } 509 | 510 | template ByteBuffer &operator<<(ByteBuffer &b, std::map &m) 511 | { 512 | b << (uint32)m.size(); 513 | 514 | for (typename std::map::iterator i = m.begin(); i != m.end(); ++i) 515 | { 516 | b << i->first << i->second; 517 | } 518 | return b; 519 | } 520 | 521 | template ByteBuffer &operator>>(ByteBuffer &b, std::map &m) 522 | { 523 | uint32 msize; 524 | b >> msize; 525 | m.clear(); 526 | 527 | if (msize > MAX_ARR_SIZE) 528 | { 529 | return b; 530 | } 531 | 532 | while(msize--) 533 | { 534 | K k; 535 | V v; 536 | b >> k >> v; 537 | m.insert(make_pair(k, v)); 538 | } 539 | return b; 540 | } 541 | 542 | #endif 543 | -------------------------------------------------------------------------------- /sptrunk/Common/Utility/CheckAndAssert_t.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/CheckAndAssert_t.h -------------------------------------------------------------------------------- /sptrunk/Common/Utility/FunctionMap.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/FunctionMap.cpp -------------------------------------------------------------------------------- /sptrunk/Common/Utility/FunctionMap.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/FunctionMap.h -------------------------------------------------------------------------------- /sptrunk/Common/Utility/Global.cpp: -------------------------------------------------------------------------------- 1 | #include "UtilityCommon.h" 2 | #include "Global.h" 3 | #include 4 | 5 | 6 | char * buffer2048() 7 | { 8 | static char buffer[2048] = { '\0' }; 9 | return &buffer[0]; 10 | } 11 | 12 | 13 | 14 | string & ReplaceAllDistinct(string & str, const string & old_value, const string & new_value) 15 | { 16 | if (old_value.empty()) 17 | return str; 18 | 19 | if (old_value == new_value) 20 | return str; 21 | 22 | for( string::size_type pos(0); pos != string::npos; pos += new_value.length()) 23 | { 24 | if( (pos = str.find(old_value, pos)) != string::npos) 25 | { 26 | str.replace(pos, old_value.length(), new_value); 27 | } 28 | else 29 | { 30 | break; 31 | } 32 | } 33 | 34 | return str; 35 | } 36 | 37 | 38 | -------------------------------------------------------------------------------- /sptrunk/Common/Utility/Global.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/Global.h -------------------------------------------------------------------------------- /sptrunk/Common/Utility/List.h: -------------------------------------------------------------------------------- 1 | // List.h: interface for the CList class. 2 | // source code created by Min-Wook Kim (taiyo@webzen.co.kr) 3 | // Lastupdated with memoryPool at 2004-7-29 4 | // 5 | //------------------------------------------------------------------- 6 | // History. 7 | // 2004-07-28 : created with memoryPool 8 | //------------------------------------------------------------------- 9 | ////////////////////////////////////////////////////////////////////// 10 | #ifndef __LIST_H__ 11 | #define __LIST_H__ 12 | 13 | #if _MSC_VER > 1000 14 | #pragma once 15 | #endif // _MSC_VER > 1000 16 | 17 | #include "MemoryPoolFactory.h" 18 | 19 | using namespace util; 20 | 21 | typedef void* POS; 22 | 23 | 24 | namespace util 25 | { 26 | 27 | 28 | 29 | template 30 | class CList 31 | { 32 | public: 33 | CList(DWORD dwBlockSize = 10) : m_pHead(0), m_pTail(0), m_nCount(0) 34 | { 35 | m_pNodePool = new CMemoryPoolFactory; 36 | m_pNodePool->Initialize(dwBlockSize, dwBlockSize/2+1); 37 | } 38 | virtual ~CList() 39 | { 40 | DeleteAll(); 41 | m_pNodePool->Release(); 42 | delete m_pNodePool; 43 | } 44 | 45 | protected: 46 | class NODE 47 | { 48 | public: 49 | T pElement; 50 | NODE * pPrev; 51 | NODE * pNext; 52 | NODE() { pPrev=0; pElement=0; pNext=0; } 53 | }; 54 | 55 | NODE * m_pHead; 56 | NODE * m_pTail; 57 | short m_nCount; 58 | CMemoryPoolFactory * m_pNodePool; 59 | 60 | public: 61 | // Get element of head 62 | inline T GetHead(){ return m_pHead->pElement; } 63 | 64 | // Add to linked list head 65 | void AddHead(T pElement) 66 | { 67 | NODE *newNode = m_pNodePool->Alloc(); 68 | newNode->pPrev = 0; 69 | newNode->pElement = pElement; 70 | newNode->pNext = 0; 71 | 72 | if (0 == m_pHead) 73 | { 74 | m_pHead = newNode; 75 | m_pHead->pNext = 0; 76 | m_pTail = m_pHead; 77 | } 78 | else 79 | { 80 | m_pHead->pPrev = newNode; 81 | newNode->pNext = m_pHead; 82 | m_pHead = newNode; 83 | } 84 | ++m_nCount; 85 | } 86 | 87 | // Delete head 88 | T DeleteHead() 89 | { 90 | if (!m_pHead) return 0; 91 | 92 | T pElement = 0; 93 | if( m_pHead == m_pTail ) 94 | { 95 | pElement = m_pTail->pElement; 96 | 97 | m_pNodePool->Free(m_pHead); 98 | m_pHead = m_pTail = 0; 99 | m_nCount = 0; 100 | } 101 | else 102 | { 103 | NODE *pCurrent = m_pHead; 104 | m_pHead = m_pHead->pNext; 105 | m_pHead->pPrev = 0; 106 | 107 | pElement = pCurrent->pElement; 108 | 109 | m_pNodePool->Free(pCurrent); 110 | --m_nCount; 111 | } 112 | return pElement; 113 | } 114 | 115 | 116 | 117 | inline T GetTail(){ return m_pTail->pElement; } 118 | 119 | // Add to linked list tail 120 | void AddTail(T pElement) 121 | { 122 | NODE *newNode = m_pNodePool->Alloc(); 123 | newNode->pPrev = 0; 124 | newNode->pElement = pElement; 125 | newNode->pNext = 0; 126 | 127 | if (0 == m_pTail) 128 | { 129 | m_pTail = newNode; 130 | m_pHead = m_pTail; 131 | } 132 | else 133 | { 134 | m_pTail->pNext = newNode; 135 | newNode->pPrev = m_pTail; 136 | m_pTail = newNode; 137 | } 138 | ++m_nCount; 139 | } 140 | 141 | // Delete tail 142 | T DeleteTail() 143 | { 144 | if (!m_pTail) return 0; 145 | 146 | T pElement = 0; 147 | if( m_pTail == m_pHead ) 148 | { 149 | pElement = m_pTail->pElement; 150 | 151 | m_pNodePool->Free(m_pTail); 152 | m_pTail = m_pHead = 0; 153 | m_nCount = 0; 154 | } 155 | else 156 | { 157 | NODE *pCurrent = 0; 158 | NODE *pAfter = m_pHead; 159 | while(1) 160 | { 161 | pCurrent = pAfter->pNext; 162 | if( pCurrent->pNext == 0 ) 163 | break; 164 | pAfter = pCurrent; 165 | } 166 | pAfter->pNext = 0; 167 | m_pTail = pAfter; 168 | 169 | pElement = pCurrent->pElement; 170 | 171 | m_pNodePool->Free(pCurrent); 172 | --m_nCount; 173 | } 174 | return pElement; 175 | } 176 | 177 | 178 | 179 | // Insert element before index 180 | int InsertBefore(T pElement, int index) 181 | { 182 | if (index == 0) AddHead(pElement); 183 | else { 184 | NODE *pAfter = 0; 185 | NODE *pCurrent = m_pHead; 186 | while (0 < index-- && pCurrent) { 187 | pAfter = pCurrent; 188 | pCurrent = pCurrent->pNext; 189 | } 190 | 191 | NODE *newNode = m_pNodePool->Alloc(); 192 | newNode->pPrev = pCurrent->pPrev; 193 | newNode->pElement = pElement; 194 | newNode->pNext = pCurrent; 195 | 196 | pCurrent->pPrev = newNode; 197 | pAfter->pNext = newNode; 198 | 199 | ++m_nCount; 200 | } 201 | return 0; 202 | } 203 | 204 | // Insert element after index 205 | int InsertpAfter(T pElement, int index) 206 | { 207 | if( index == m_nCount - 1 ) AddTail(pElement); 208 | else 209 | { 210 | NODE *pAfter = 0; 211 | NODE *pCurrent = m_pHead; 212 | while( 0 < index-- && pCurrent ) 213 | { 214 | pAfter = pCurrent; 215 | pCurrent = pCurrent->pNext; 216 | } 217 | 218 | NODE *newNode = m_pNodePool->Alloc(); 219 | newNode->pPrev = pCurrent; 220 | newNode->pElement = pElement; 221 | newNode->pNext = pCurrent->pNext; 222 | 223 | pAfter->pPrev = newNode; 224 | pCurrent->pNext = newNode; 225 | 226 | ++m_nCount; 227 | } 228 | return 0; 229 | } 230 | 231 | 232 | inline POS GetFirstPos() { return (POS)m_pHead; } 233 | inline POS GetLastPos() { return (POS)m_pTail; } 234 | 235 | // Pos to index 236 | int GetPosIndex(POS pos) 237 | { 238 | NODE *pCurrent = m_pHead; 239 | for( int i = 0 ; pCurrent ; ++i ) 240 | { 241 | if( pos == (POS)pCurrent ) 242 | return i; 243 | pCurrent = pCurrent->pNext; 244 | } 245 | return -1; 246 | } 247 | 248 | // Index to pos 249 | POS GetIndexPos(int index) 250 | { 251 | NODE *pCurrent = m_pHead; 252 | while( 0 < index-- && pCurrent ) 253 | pCurrent = pCurrent->pNext; 254 | 255 | return (POS)pCurrent; 256 | } 257 | // taiyo test add 258 | T GetAtPos(POS& pos) 259 | { 260 | T pElement; 261 | if (pos) 262 | { 263 | pElement = ((NODE*)pos)->pElement; 264 | } 265 | else 266 | { 267 | pElement = 0; 268 | } 269 | return pElement; 270 | } 271 | 272 | // Get previous position of node 273 | T GetPrevPos(POS& pos) 274 | { 275 | T pElement; 276 | if (pos) 277 | { 278 | pElement = ((NODE*)pos)->pElement; 279 | pos = (POS)((NODE*)pos)->pPrev; 280 | } 281 | else 282 | { 283 | pElement = 0; 284 | pos = 0; 285 | } 286 | return pElement; 287 | } 288 | 289 | // Get next position of node 290 | T GetNextPos(POS& pos) 291 | { 292 | T pElement; 293 | if (pos) 294 | { 295 | pElement = ((NODE*)pos)->pElement; 296 | pos = (POS)((NODE*)pos)->pNext; 297 | } 298 | else 299 | { 300 | pElement = 0; 301 | pos = 0; 302 | } 303 | return pElement; 304 | } 305 | 306 | // Delete position of node 307 | T DeletePos(POS& pos) 308 | { 309 | T pElement = 0; 310 | if (m_pHead == (NODE*)pos) 311 | { 312 | pElement = DeleteHead(); 313 | pos = (POS)m_pHead; 314 | } 315 | else if (m_pTail == (NODE*)pos) 316 | { 317 | pElement = DeleteTail(); 318 | pos = (POS)m_pTail; 319 | } 320 | else 321 | { 322 | NODE *pAfter = m_pHead; 323 | NODE *pCurrent = m_pHead->pNext; 324 | while (pCurrent != (NODE*)pos) 325 | { 326 | pAfter = pCurrent; 327 | pCurrent = pCurrent->pNext; 328 | } 329 | pCurrent->pNext->pPrev = pAfter; 330 | pAfter->pNext = pCurrent->pNext; 331 | pos = (POS)pAfter; 332 | 333 | pElement = pCurrent->pElement; 334 | 335 | m_pNodePool->Free(pCurrent); 336 | --m_nCount; 337 | } 338 | return pElement; 339 | } 340 | 341 | 342 | // Get total number of node 343 | inline int GetCount() { return m_nCount; } 344 | 345 | // Get node by index number : 0base 346 | T GetAt(int index) 347 | { 348 | NODE *pCurrent = m_pHead; 349 | while (0 < index-- && pCurrent) 350 | pCurrent = pCurrent->pNext; 351 | 352 | return pCurrent->pElement; 353 | } 354 | 355 | // Delete at 356 | T DeleteAt(int index) 357 | { 358 | if (index == 0) return DeleteHead(); 359 | else if( index == m_nCount - 1 ) return DeleteTail(); 360 | else 361 | { 362 | NODE *pAfter = m_pHead; 363 | NODE *pCurrent = m_pHead->pNext; 364 | while( index-- ) 365 | { 366 | pAfter = pCurrent; 367 | pCurrent = pCurrent->pNext; 368 | } 369 | pCurrent->pNext->pPrev = pAfter; 370 | pAfter->pNext = pCurrent->pNext; 371 | 372 | T pElement = pCurrent->pElement; 373 | 374 | m_pNodePool->Free(pCurrent); 375 | --m_nCount; 376 | 377 | return pElement; 378 | } 379 | return 0; 380 | } 381 | 382 | // Delete all node 383 | void DeleteAll() 384 | { 385 | NODE *pCurrent = m_pHead; 386 | NODE *pAfter = 0; 387 | while( pCurrent ) 388 | { 389 | pAfter = pCurrent->pNext; 390 | m_pNodePool->Free(pCurrent); 391 | pCurrent = pAfter; 392 | } 393 | m_pHead = m_pTail = 0; 394 | m_nCount = 0; 395 | } 396 | 397 | }; 398 | 399 | 400 | } /// namespace util 401 | 402 | #endif // __LIST_H__ 403 | -------------------------------------------------------------------------------- /sptrunk/Common/Utility/LogAssert.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/LogAssert.h -------------------------------------------------------------------------------- /sptrunk/Common/Utility/MemBand.h: -------------------------------------------------------------------------------- 1 | // MemBand.h: interface for the CMemBand Abstract class. 2 | // Memory Pool Management Class version 1.0 3 | // source code created by Min-Wook Kim (taiyo@webzen.co.kr) 4 | // 2004-7-26 5 | // 6 | //------------------------------------------------------------------- 7 | // History. 8 | // 2004-3-31 : MemoryPoolTempl class ver 0.1 9 | // 2004-6-18 : MemoryPoolTempl class ver 0.2 10 | // 2004-6-21 : Error Check Byte added ver 0.21 11 | // 2004-7-26 : MemoryPool Framework ver1.0 12 | // 2004-7-27 : Bug Fixed! delete [] m_pQueue; 13 | // Be Done 14 | // - MemoryPool template class of inherited-method and factory-method 15 | // - Multi-thread safety 16 | // - Buffer overflow write check 17 | // To do 18 | // - Analysis of amount used for band 19 | //------------------------------------------------------------------- 20 | // 21 | ////////////////////////////////////////////////////////////////////// 22 | #ifndef __MEMBAND_H__ 23 | #define __MEMBAND_H__ 24 | 25 | 26 | #ifdef _DEBUG 27 | #include 28 | #define TASSERT(a) assert(a) 29 | #define DEBUG_SLICE_SIZE 4 30 | #define DEBUG_SLICE_VALUE 'D' 31 | #else 32 | #define DEBUG_SLICE_SIZE 0 33 | #endif 34 | 35 | 36 | namespace util 37 | { 38 | 39 | 40 | 41 | #if 0 42 | template 43 | class CMemBand 44 | { 45 | 46 | static CMemBand * m_pHeadBand; 47 | static CMemBand * m_pTailBand; 48 | static CMemBand * m_pCurBand; 49 | 50 | static DWORD m_dwObjSize; 51 | static DWORD m_dwPoolBasicSize; 52 | static DWORD m_dwPoolExtendSize; 53 | 54 | char * m_pBandBody; 55 | DWORD * m_pQueue; 56 | DWORD m_dwObjCount; 57 | DWORD m_dwMaxBandObjCount; 58 | CMemBand * m_pPrev; 59 | CMemBand * m_pNext; 60 | 61 | protected: 62 | CMemBand() 63 | : m_pPrev(NULL), 64 | m_pNext(NULL), 65 | m_pBandBody(0), 66 | m_pQueue(0), 67 | m_dwObjCount(0), 68 | m_dwMaxBandObjCount(0) 69 | { 70 | } 71 | 72 | virtual ~CMemBand() 73 | { 74 | } 75 | 76 | static void * AlloObject() 77 | { 78 | if( m_pCurBand->m_dwObjCount > 0 ) 79 | { 80 | return (void *)*(m_pCurBand->m_pQueue + --m_pCurBand->m_dwObjCount); 81 | } 82 | else 83 | { 84 | AllocBand(); 85 | m_pCurBand = m_pCurBand->m_pNext; 86 | return AlloObject(); 87 | } 88 | } 89 | 90 | static bool FreeObject(void * pObj) 91 | { 92 | if( m_pCurBand->m_dwObjCount < m_pCurBand->m_dwMaxBandObjCount ) 93 | { 94 | #ifdef _DEBUG 95 | for( int i = 0 ; i < DEBUG_SLICE_SIZE ; ++i ) 96 | { 97 | if( ((char * )pObj)[m_dwObjSize - DEBUG_SLICE_SIZE + i] != DEBUG_SLICE_VALUE ) 98 | return false; 99 | } 100 | #endif 101 | *(m_pCurBand->m_pQueue + m_pCurBand->m_dwObjCount) = (DWORD)pObj; 102 | m_pCurBand->m_dwObjCount++; 103 | } 104 | else 105 | { 106 | m_pCurBand = m_pCurBand->m_pPrev; 107 | return FreeObject(pObj); 108 | } 109 | 110 | return true; 111 | } 112 | 113 | static void InitBand(DWORD dwObjSize, DWORD dwPoolBasicSize, DWORD dwPoolExtendSize) 114 | { 115 | m_dwObjSize = dwObjSize + DEBUG_SLICE_SIZE; 116 | m_dwPoolBasicSize = dwPoolBasicSize; 117 | m_dwPoolExtendSize = dwPoolExtendSize; 118 | AllocBand(); 119 | } 120 | 121 | static void AllocBand() 122 | { 123 | CMemBand * pBand = new CMemBand; 124 | DWORD dwPoolSize = 0; 125 | if( !m_pHeadBand ) 126 | { 127 | dwPoolSize = m_dwPoolBasicSize; 128 | m_pCurBand = m_pHeadBand = m_pTailBand = pBand; 129 | } 130 | else 131 | { 132 | dwPoolSize = m_dwPoolExtendSize; 133 | m_pTailBand->m_pNext = pBand; 134 | pBand->m_pPrev = m_pTailBand; 135 | m_pTailBand = pBand; 136 | 137 | } 138 | 139 | pBand->m_pBandBody = new char[m_dwObjSize*dwPoolSize]; 140 | #ifdef _DEBUG 141 | DWORD j = 0; 142 | while( j < dwPoolSize ) 143 | { 144 | memset( &pBand->m_pBandBody[ m_dwObjSize * ( j + 1 ) - DEBUG_SLICE_SIZE ], DEBUG_SLICE_VALUE, DEBUG_SLICE_SIZE ); 145 | ++j; 146 | } 147 | #endif 148 | pBand->m_pQueue = new DWORD[dwPoolSize]; 149 | DWORD i = 0; 150 | while( i < dwPoolSize ) 151 | { 152 | *(pBand->m_pQueue + i) = (DWORD)(pBand->m_pBandBody + i * m_dwObjSize); 153 | ++i; 154 | } 155 | 156 | pBand->m_dwObjCount = dwPoolSize; 157 | pBand->m_dwMaxBandObjCount = dwPoolSize; 158 | } 159 | 160 | static void FreeBand() 161 | { 162 | CMemBand * dp = m_pHeadBand; 163 | while(dp) 164 | { 165 | m_pHeadBand = m_pHeadBand->m_pNext; 166 | delete [] dp->m_pBandBody; 167 | delete [] dp->m_pQueue; 168 | delete dp; 169 | dp = m_pHeadBand; 170 | } 171 | m_pHeadBand = NULL; 172 | } 173 | 174 | }; 175 | 176 | template CMemBand * CMemBand::m_pHeadBand = NULL; 177 | template CMemBand * CMemBand::m_pTailBand = NULL; 178 | template CMemBand * CMemBand::m_pCurBand = NULL; 179 | 180 | template DWORD CMemBand::m_dwObjSize = 0; 181 | template DWORD CMemBand::m_dwPoolBasicSize = 0; 182 | template DWORD CMemBand::m_dwPoolExtendSize = 0; 183 | 184 | #endif 185 | 186 | template 187 | class CMemTypeBand 188 | { 189 | DataType ** ppDataType; 190 | DataType * pDeleteArray; 191 | DWORD nMaxBandObjectNum; 192 | DWORD FreeIdx; 193 | 194 | public: 195 | CMemTypeBand * pPrev; 196 | CMemTypeBand * pNext; 197 | 198 | CMemTypeBand():pPrev(NULL),pNext(NULL){} 199 | 200 | virtual ~CMemTypeBand() 201 | { 202 | pPrev=NULL; 203 | pNext=NULL; 204 | delete [] ppDataType; 205 | delete [] pDeleteArray; 206 | } 207 | 208 | inline DWORD GetAvailableNumberOfObjects() 209 | { 210 | return FreeIdx; 211 | } 212 | 213 | inline DWORD GetMaxNumberOfObjects() 214 | { 215 | return nMaxBandObjectNum; 216 | } 217 | 218 | DataType * GetObject( DWORD dwIdx ) 219 | { 220 | return &pDeleteArray[dwIdx]; 221 | } 222 | 223 | static CMemTypeBand * AllocBand( CMemTypeBand *& head, DWORD nMaxObject ) 224 | { 225 | CMemTypeBand* pp = new CMemTypeBand; 226 | pp->ppDataType = new DataType*[nMaxObject]; 227 | memset(pp->ppDataType, 0, sizeof(DataType*)*nMaxObject); 228 | pp->pDeleteArray = new DataType[nMaxObject]; 229 | for(DWORD i = 0 ; i < nMaxObject ; i++) 230 | { 231 | pp->ppDataType[i] = &pp->pDeleteArray[i]; 232 | } 233 | pp->nMaxBandObjectNum = nMaxObject; 234 | pp->FreeIdx = nMaxObject; 235 | pp->pNext = head; 236 | if(head) 237 | head->pPrev = pp; 238 | head = pp; 239 | 240 | return pp; 241 | } 242 | 243 | static void FreeBand( CMemTypeBand * pDelBand ) 244 | { 245 | //head node one call, all delete; 246 | CMemTypeBand * db = pDelBand; 247 | while(db) 248 | { 249 | CMemTypeBand * tmp = db; 250 | db = db->pNext; 251 | delete tmp; 252 | } 253 | } 254 | DataType * AlloObject() 255 | { 256 | // TASSERT(FreeIdx-1 >= 0); 257 | if(--FreeIdx == -1) 258 | { 259 | FreeIdx = 0; 260 | return NULL; 261 | } 262 | else 263 | return ppDataType[FreeIdx]; 264 | } 265 | 266 | bool FreeObject(DataType * data) 267 | { 268 | // TASSERT(FreeIdx+1 < nMaxNum); 269 | if(FreeIdx < nMaxBandObjectNum ) 270 | ppDataType[FreeIdx++] = data; 271 | else 272 | return false; 273 | return true; 274 | } 275 | }; 276 | 277 | 278 | 279 | } /// namespace util 280 | 281 | 282 | #endif // __MEMBAND_H__ 283 | -------------------------------------------------------------------------------- /sptrunk/Common/Utility/MemoryCache.cpp: -------------------------------------------------------------------------------- 1 | #include "UtilityCommon.h" 2 | //#include "stdafx.h" 3 | #include ".\memorycache.h" 4 | -------------------------------------------------------------------------------- /sptrunk/Common/Utility/MemoryCache.h: -------------------------------------------------------------------------------- 1 | #ifndef __MEMORY_CACHE_H__ 2 | #define __MEMORY_CACHE_H__ 3 | 4 | #pragma once 5 | 6 | #include 7 | 8 | // NOT yet 9 | #define tDefaultSize 10 10 | 11 | 12 | template 13 | class CacheSegment 14 | { 15 | CacheSegment():m_pp(NULL),m_pn(NULL),m_iAvailableNum(_size) 16 | { 17 | assert( _size != 0 ); 18 | //int i = 0; 19 | //while( m_pDataCache[i] = new DataType && i++ < ( _size -1 ) ){} 20 | } 21 | ~CacheSegment(){} 22 | 23 | DataType * Alloc() 24 | { 25 | DataType * pData = NULL; 26 | if( --m_iAvailableNum >= 0) 27 | { 28 | pData = m_pDataCache[m_iAvailableNum] = new ; 29 | m_pDataCache[m_iAvailableNum] = NULL; 30 | } 31 | return pData; 32 | } 33 | BOOL Free( DataType * pData ) 34 | { 35 | if( m_iAvailableNum == _size ) return FALSE; 36 | 37 | m_pDataCache[m_iAvailableNum++] = pData; 38 | } 39 | VOID operator << ( CacheSegment * pSeg ) 40 | { 41 | assert( m_pn == NULL ); 42 | m_pp = pSeg; 43 | pSeg >> m_pp; 44 | } 45 | VOID operator >> ( CacheSegment * pSeg ) 46 | { 47 | assert( m_pp == NULL ); 48 | m_pn = pSeg; 49 | pSeg << m_pp; 50 | } 51 | 52 | private: 53 | int m_iAvailableNum; 54 | DataType * m_pDataCache[_size]; 55 | CacheSegment * m_pn; 56 | CacheSegment * m_pp; 57 | }; 58 | 59 | 60 | 61 | template 62 | class MemoryCache 63 | { 64 | friend class CacheSegment; 65 | public: 66 | MemoryCache() 67 | { 68 | assert( _size != 0 ); 69 | m_pSegment = new CacheSegment; 70 | } 71 | ~MemoryCache(); 72 | 73 | DataType * CreateData() 74 | { 75 | DataType * pData = m_pSegment->Alloc(); 76 | if( !pData ) 77 | { 78 | CacheSegment * m_pTmp = ( new CacheSegment ) << m_pSegment; 79 | m_pSegment = m_pTmp; 80 | return CreateData(); 81 | } 82 | return pData; 83 | } 84 | 85 | VOID DestroyData( DataType * pData ) 86 | { 87 | if( !m_pSegment->Free( pData ) ) 88 | { 89 | m_pSegment 90 | DestroyData( pData ); 91 | } 92 | } 93 | 94 | private: 95 | CacheSegment * m_pSegment; 96 | }; 97 | 98 | 99 | #endif // __MEMORY_CACHE_H__ 100 | -------------------------------------------------------------------------------- /sptrunk/Common/Utility/MemoryPool.h: -------------------------------------------------------------------------------- 1 | #ifndef _MEMORYPOOL_H_ 2 | #define _MEMORYPOOL_H_ 3 | 4 | #include 5 | 6 | namespace util 7 | { 8 | 9 | 10 | template 11 | class MemoryPool 12 | { 13 | public: 14 | MemoryPool( DWORD dwSize ) 15 | { 16 | m_dwMaxSize = dwSize; 17 | 18 | vector::iterator it; 19 | 20 | for( DWORD i = 0; i < dwSize; ++i ) 21 | { 22 | m_list.push_back( new T ); 23 | } 24 | 25 | InitializeCriticalSection( &m_cs ); 26 | } 27 | 28 | ~MemoryPool() 29 | { 30 | Clear(); 31 | DeleteCriticalSection( &m_cs ); 32 | } 33 | 34 | T* Alloc() 35 | { 36 | EnterCriticalSection( &m_cs ); 37 | 38 | assert( !m_list.empty() ); 39 | 40 | return m_list.pop_back(); 41 | 42 | LeaveCriticalSection( &m_cs ); 43 | } 44 | 45 | void Restore( T* pItem ) 46 | { 47 | EnterCriticalSection( &m_cs ); 48 | 49 | assert( m_list.size() < m_dwMaxSize ); 50 | 51 | m_list.push_back( pItem ); 52 | 53 | LeaveCriticalSection( &m_cs ); 54 | } 55 | 56 | private: 57 | void Clear() 58 | { 59 | vector::iterator it; 60 | for( it = m_list.begin(); it < m_list.end(); ++it ) 61 | { 62 | delete (*it); 63 | } 64 | m_list.clear(); 65 | } 66 | 67 | private: 68 | CRITICAL_SECTION m_cs; 69 | vector m_list; 70 | DWORD m_dwMaxSize; 71 | }; 72 | 73 | }; //end of namespace util 74 | 75 | #endif // _MEMORYPOOL_H_ -------------------------------------------------------------------------------- /sptrunk/Common/Utility/MemoryPoolBase.h: -------------------------------------------------------------------------------- 1 | // MemoryPoolBase.h: interface for the CMemoryPoolBase class. 2 | // Memory Pool Management Class version 1.0 3 | // source code created by Min-Wook Kim (taiyo@webzen.co.kr) 4 | // 2004-7-26 5 | // 6 | //------------------------------------------------------------------- 7 | // History. 8 | // 2004-3-31 : MemoryPoolTempl class ver 0.1 9 | // 2004-6-18 : MemoryPoolTempl class ver 0.2 10 | // 2004-6-21 : Error Check Byte added ver 0.21 11 | // 2004-7-26 : MemoryPool Framework ver1.0 12 | // Be Done 13 | // - MemoryPool template class of inherited-method and factory-method 14 | // - Multi-thread safety 15 | // - Buffer overflow write check 16 | // To do 17 | // - Analysis of amount used for band 18 | //------------------------------------------------------------------- 19 | // example) 20 | // 21 | // class Money1 : public CMemoryPoolBase { ... }; 22 | // 23 | // void main() 24 | // { 25 | // Money1::Initialize(sizeof(Money1), 3, 2); 26 | // 27 | // Money1 * pmoney1 = new Money1; 28 | // delete pmoney1; 29 | // 30 | // Money1::Release(); 31 | // } 32 | // 33 | ////////////////////////////////////////////////////////////////////// 34 | #ifndef __MEMORYPOOLBAES_H__ 35 | #define __MEMORYPOOLBAES_H__ 36 | 37 | #if _MSC_VER > 1000 38 | #pragma once 39 | #endif // _MSC_VER > 1000 40 | 41 | #include "MemBand.h" 42 | 43 | namespace util 44 | { 45 | 46 | 47 | template 48 | class CMemoryPoolBase : public CMemBand 49 | { 50 | public: 51 | static void Initialize(DWORD dwObjSize, DWORD dwPoolBasicSize, DWORD dwPoolExtendSize) 52 | { 53 | //#ifdef _PSDK_INSTALLED 54 | // InitializeCriticalSectionAndSpinCount(&m_cs, 2000); 55 | //#else 56 | InitializeCriticalSection(&m_cs); 57 | //#endif 58 | InitBand( dwObjSize, dwPoolBasicSize, dwPoolExtendSize ); 59 | } 60 | static void Release() 61 | { 62 | //CMemBand::FreeBand(); 63 | FreeBand(); 64 | DeleteCriticalSection(&m_cs); 65 | } 66 | 67 | void * operator new( size_t size ) 68 | { 69 | Lock(); 70 | void * pn = (void *)AllocObject(); 71 | Unlock(); 72 | return pn; 73 | } 74 | void operator delete( void * p ) 75 | { 76 | if(!p) return; 77 | Lock(); 78 | #ifdef _DEBUG 79 | BOOL rt = FreeObject((void *)p); 80 | TASSERT(rt); 81 | #else 82 | FreeNode((void *)p); 83 | #endif 84 | Unlock(); 85 | } 86 | protected: 87 | static void Lock() { EnterCriticalSection(&m_cs); } 88 | static void Unlock() { LeaveCriticalSection(&m_cs); } 89 | static CRITICAL_SECTION m_cs; 90 | }; 91 | 92 | template CRITICAL_SECTION CMemoryPoolBase::m_cs; 93 | 94 | 95 | 96 | 97 | } /// namespace util 98 | 99 | 100 | #endif //__MEMORYPOOLBAES_H__ -------------------------------------------------------------------------------- /sptrunk/Common/Utility/MemoryPoolFactory.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/MemoryPoolFactory.h -------------------------------------------------------------------------------- /sptrunk/Common/Utility/Narray.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/Narray.h -------------------------------------------------------------------------------- /sptrunk/Common/Utility/Nstring.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/Nstring.h -------------------------------------------------------------------------------- /sptrunk/Common/Utility/SafeMemoryPoolFactory.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/SafeMemoryPoolFactory.h -------------------------------------------------------------------------------- /sptrunk/Common/Utility/Singleton.h: -------------------------------------------------------------------------------- 1 | // Singleton.h: interface for the Singleton class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #ifndef __SINGLETON_H__ 6 | #define __SINGLETON_H__ 7 | 8 | #include 9 | 10 | namespace util 11 | { 12 | template 13 | class Singleton 14 | { 15 | protected: 16 | Singleton() 17 | { 18 | assert( !ms_pInstance ); 19 | ms_pInstance = static_cast< T* >( this ); 20 | } 21 | 22 | ~Singleton() 23 | { 24 | ms_pInstance = 0; 25 | } 26 | public: 27 | static T * Instance() 28 | { 29 | if (0 == ms_pInstance) 30 | { 31 | ms_pInstance = new T; 32 | } 33 | 34 | return ms_pInstance; 35 | } 36 | 37 | static void DestroyInstance() 38 | { 39 | if (ms_pInstance) 40 | { 41 | delete ms_pInstance; 42 | ms_pInstance = 0; 43 | } 44 | } 45 | 46 | private: 47 | static T * ms_pInstance; 48 | }; 49 | 50 | 51 | template< class T > T * Singleton::ms_pInstance = 0; 52 | } 53 | 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /sptrunk/Common/Utility/SolarFileReader.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/SolarFileReader.cpp -------------------------------------------------------------------------------- /sptrunk/Common/Utility/SolarFileReader.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/SolarFileReader.h -------------------------------------------------------------------------------- /sptrunk/Common/Utility/Stackwalker.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/Stackwalker.cpp -------------------------------------------------------------------------------- /sptrunk/Common/Utility/Stackwalker.h: -------------------------------------------------------------------------------- 1 | /*//////////////////////////////////////////////////////////////////////////// 2 | * Project: 3 | * Memory_and_Exception_Trace 4 | * 5 | * /////////////////////////////////////////////////////////////////////////// 6 | * File: 7 | * Stackwalker.h 8 | * 9 | * Remarks: 10 | * 11 | * 12 | * Note: 13 | * 14 | * 15 | * Author: 16 | * Jochen Kalmbach 17 | * 18 | *//////////////////////////////////////////////////////////////////////////// 19 | 20 | #ifndef __STACKWALKER_H__ 21 | #define __STACKWALKER_H__ 22 | 23 | // Only valid in the following environment: Intel platform, MS VC++ 5/6/7/7.1 24 | #ifndef _X86_ 25 | #error Only INTEL envirnoments are supported! 26 | #endif 27 | 28 | // Only MS VC++ 5 to 7 29 | #if (_MSC_VER < 1100) || (_MSC_VER > 1310) 30 | #error Only MS VC++ 5/6/7/7.1 supported. Check if the '_CrtMemBlockHeader' has not changed with this compiler! 31 | #endif 32 | 33 | typedef enum eAllocCheckOutput 34 | { 35 | ACOutput_Simple, 36 | ACOutput_Advanced, 37 | ACOutput_XML 38 | }; 39 | 40 | // Make extern "C", so it will also work with normal C-Programs 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | extern int InitAllocCheckWN(eAllocCheckOutput eOutput, LPCTSTR pszFilename, ULONG ulShowStackAtAlloc = 0); 45 | extern int InitAllocCheck(eAllocCheckOutput eOutput = ACOutput_Simple, BOOL bSetUnhandledExeptionFilter = TRUE, ULONG ulShowStackAtAlloc = 0); // will create the filename by itself 46 | 47 | extern ULONG DeInitAllocCheck(); 48 | 49 | extern DWORD StackwalkFilter( EXCEPTION_POINTERS *ep, DWORD status, LPCTSTR pszLogFile); 50 | 51 | extern void OnlyInstallUnhandeldExceptionFilter(eAllocCheckOutput eOutput = ACOutput_Simple); 52 | 53 | #ifdef __cplusplus 54 | } 55 | #endif 56 | 57 | #endif // __STACKWALKER_H__ 58 | -------------------------------------------------------------------------------- /sptrunk/Common/Utility/Timer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/Timer.h -------------------------------------------------------------------------------- /sptrunk/Common/Utility/UtilityCommon.h: -------------------------------------------------------------------------------- 1 | #ifndef _UTILITY_COMMON_H_ 2 | #define _UTILITY_COMMON_H_ 3 | 4 | #include 5 | #include 6 | 7 | #define DISPMSG printf 8 | #define XY_INLINE inline 9 | #define DEBUG_CODE(c) c 10 | 11 | #define COMPILER_MICROSOFT 0 12 | #define COMPILER_GNU 1 13 | #define COMPILER_BORLAND 2 14 | 15 | #ifdef _MSC_VER 16 | #define COMPILER COMPILER_MICROSOFT 17 | #elif defined( __BORLANDC__ ) 18 | #define COMPILER COMPILER_BORLAND 19 | #elif defined( __GNUC__ ) 20 | #define COMPILER COMPILER_GNU 21 | #else 22 | #pragma error "FATAL ERROR: Unknown compiler." 23 | #endif 24 | 25 | 26 | 27 | 28 | #define random(min, max) ((rand()%(int)(((max) + 1)-(min)))+ (min)) 29 | #define _RAND_MAX 0x7fff 30 | #define dRandom(min, max) ((((double)rand()/(((double)(_RAND_MAX)+(double)(1)))) * (max-min))+(min)) 31 | 32 | 33 | //#if COMPILER != COMPILER_GNU 34 | //typedef signed __int64 int64; 35 | //typedef signed __int32 int32; 36 | //typedef signed __int16 int16; 37 | //typedef signed __int8 int8; 38 | //typedef unsigned __int64 uint64; 39 | //typedef unsigned __int32 uint32; 40 | //typedef unsigned __int16 uint16; 41 | //typedef unsigned __int8 uint8; 42 | //#else 43 | //typedef int64_t int64; 44 | //typedef int32_t int32; 45 | //typedef int16_t int16; 46 | //typedef int8_t int8; 47 | //typedef uint64_t uint64; 48 | //typedef uint32_t uint32; 49 | //typedef uint16_t uint16; 50 | //typedef uint8_t uint8; 51 | //#endif 52 | 53 | typedef long long int64; 54 | typedef int int32; 55 | typedef short int16; 56 | typedef signed char int8; 57 | typedef unsigned long long uint64; 58 | typedef unsigned int uint32; 59 | typedef unsigned short uint16; 60 | typedef unsigned char uint8; 61 | 62 | 63 | 64 | #ifndef _SXF_TYPE_DEFINE 65 | #define _SXF_TYPE_DEFINE 66 | typedef void *LPVOID; 67 | typedef void *HANDLE; 68 | typedef int BOOL; 69 | typedef unsigned char BYTE; 70 | typedef float FLOAT; 71 | typedef char CHAR; 72 | typedef signed char INT8; 73 | typedef unsigned char UCHAR; 74 | typedef unsigned char UINT8; 75 | typedef unsigned char BYTE; 76 | typedef short SHORT; 77 | typedef signed short INT16; 78 | typedef unsigned short USHORT; 79 | typedef unsigned short UINT16; 80 | typedef unsigned short WORD; 81 | typedef int INT; 82 | typedef signed int INT32; 83 | typedef unsigned int UINT; 84 | typedef unsigned int UINT32; 85 | typedef long LONG; 86 | typedef unsigned long ULONG; 87 | typedef unsigned long DWORD; 88 | typedef int64 LONGLONG; 89 | typedef int64 LONG64; 90 | typedef signed long long INT64; 91 | typedef unsigned long long ULONGLONG; 92 | typedef unsigned long long DWORDLONG; 93 | typedef unsigned long long ULONG64; 94 | typedef unsigned long long DWORD64; 95 | typedef unsigned long long UINT64; 96 | #define FALSE 0 97 | #define TRUE 1 98 | #define MAX_PATH 260 99 | #endif 100 | 101 | 102 | #include 103 | #include 104 | #include 105 | #include 106 | #include 107 | #include 108 | #include 109 | 110 | using namespace std; 111 | 112 | 113 | #endif -------------------------------------------------------------------------------- /sptrunk/Common/Utility/Utility_VC10.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Template 14 | Win32 15 | 16 | 17 | 18 | Utility 19 | {C40CA432-21FF-43EA-A604-452AE6C3430B} 20 | 21 | 22 | 23 | StaticLibrary 24 | false 25 | MultiByte 26 | 27 | 28 | StaticLibrary 29 | false 30 | MultiByte 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | <_ProjectFileVersion>10.0.40219.1 46 | ../../Lib/ 47 | ../../_Build10/$(Configuration)/$(ProjectName)\ 48 | ../../_Lib/ 49 | ../../_Build10/$(Configuration)/$(ProjectName)\ 50 | AllRules.ruleset 51 | 52 | 53 | AllRules.ruleset 54 | 55 | 56 | AllRules.ruleset 57 | 58 | 59 | $(ProjectName)_vc10d 60 | $(ProjectName)_vc10 61 | 62 | 63 | 64 | MaxSpeed 65 | OnlyExplicitInline 66 | ..\ProgramCommon;%(AdditionalIncludeDirectories) 67 | _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_LIB;NOT_USE_DEF_NEW;%(PreprocessorDefinitions) 68 | true 69 | MultiThreaded 70 | true 71 | Use 72 | UtilityCommon.h 73 | TurnOffAllWarnings 74 | true 75 | false 76 | 77 | 78 | NDEBUG;%(PreprocessorDefinitions) 79 | 0x0412 80 | 81 | 82 | $(OutDir)$(TargetName)$(TargetExt) 83 | true 84 | 85 | 86 | 87 | 88 | Disabled 89 | ../;%(AdditionalIncludeDirectories) 90 | WIN32;_DEBUG;_LIB;NOT_USE_DEF_NEW;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 91 | EnableFastChecks 92 | MultiThreadedDebug 93 | false 94 | NotUsing 95 | UtilityCommon.h 96 | false 97 | true 98 | ProgramDatabase 99 | Level3 100 | 101 | 102 | _DEBUG;%(PreprocessorDefinitions) 103 | 0x0412 104 | 105 | 106 | %(AdditionalLibraryDirectories) 107 | true 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /sptrunk/Common/Utility/WorldPacket.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/WorldPacket.h -------------------------------------------------------------------------------- /sptrunk/Common/Utility/WzDataType.cpp: -------------------------------------------------------------------------------- 1 | // WzDataType.cpp: Webzen common data type definitions 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #include "stdafx.h" 6 | #include 7 | #include 8 | #include "WzDataType.h" 9 | 10 | 11 | 12 | WzVector* VectorNormalize( WzVector *pwvOut, WzVector *pwvIn) 13 | { 14 | float fLength = VectorLength( pwvIn); 15 | if ( fLength > 0.0f) 16 | { 17 | pwvOut->x = pwvIn->x / fLength; 18 | pwvOut->y = pwvIn->y / fLength; 19 | pwvOut->z = pwvIn->z / fLength; 20 | } 21 | else 22 | { 23 | *pwvOut = *pwvIn; 24 | } 25 | 26 | return ( pwvOut); 27 | } 28 | -------------------------------------------------------------------------------- /sptrunk/Common/Utility/nhashtable.h: -------------------------------------------------------------------------------- 1 | #ifndef N_HASHTABLE_H 2 | #define N_HASHTABLE_H 3 | 4 | #include "nstrlist.h" 5 | 6 | //------------------------------------------------------------------------------ 7 | class nHashTable 8 | { 9 | public: 10 | /// constructor 11 | nHashTable(int size); 12 | /// destructor 13 | ~nHashTable(); 14 | /// add an entry to the hashtable 15 | void Add(nStrNode* n); 16 | /// search hash table for entry 17 | nStrNode* Find(const char* str) const; 18 | 19 | private: 20 | int htable_size; 21 | nStrList *htable; 22 | }; 23 | 24 | //------------------------------------------------------------------------------ 25 | /** 26 | */ 27 | inline 28 | nHashTable::nHashTable(int size) 29 | { 30 | this->htable_size = size; 31 | this->htable = new nStrList[size]; 32 | } 33 | 34 | //------------------------------------------------------------------------------ 35 | /** 36 | */ 37 | inline nHashTable::~nHashTable() 38 | { 39 | delete[] this->htable; 40 | } 41 | 42 | //------------------------------------------------------------------------------ 43 | /** 44 | */ 45 | static 46 | inline 47 | int hash(const char *str, int htable_size) 48 | { 49 | int i = 0; 50 | int j = 1; 51 | char c; 52 | while ((c = *str++)) i += ((uchar)c) * j++; 53 | return (i % htable_size); 54 | } 55 | 56 | //------------------------------------------------------------------------------ 57 | /** 58 | */ 59 | inline 60 | void 61 | nHashTable::Add(nStrNode* n) 62 | { 63 | int h_index = hash(n->GetName(), this->htable_size); 64 | this->htable[h_index].AddHead(n); 65 | } 66 | 67 | //------------------------------------------------------------------------------ 68 | /** 69 | */ 70 | inline 71 | nStrNode* 72 | nHashTable::Find(const char* str) const 73 | { 74 | int h_index = hash(str, this->htable_size); 75 | return this->htable[h_index].Find(str); 76 | } 77 | 78 | //------------------------------------------------------------------------------ 79 | #endif 80 | -------------------------------------------------------------------------------- /sptrunk/Common/Utility/nlinebuffer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/nlinebuffer.h -------------------------------------------------------------------------------- /sptrunk/Common/Utility/nlist.h: -------------------------------------------------------------------------------- 1 | #ifndef N_LIST_H 2 | #define N_LIST_H 3 | 4 | #include "nnode.h" 5 | 6 | //------------------------------------------------------------------------------ 7 | class nList 8 | { 9 | public: 10 | /// constructor 11 | nList(); 12 | /// destructor (list must be empty!) 13 | ~nList(); 14 | /// checks if list is empty 15 | bool IsEmpty() const; 16 | /// returns first node in list, 0 if empty 17 | nNode* GetHead() const; 18 | /// returns last node in list, 0 if empty 19 | nNode* GetTail() const; 20 | /// add node to head of list 21 | void AddHead(nNode* n); 22 | /// add node to end of list 23 | void AddTail(nNode* n); 24 | /// remove node from head of list 25 | nNode* RemHead(); 26 | /// remove node from tail of list 27 | nNode* RemTail(); 28 | 29 | private: 30 | nNode* head; 31 | nNode* tail; 32 | nNode* tailpred; 33 | }; 34 | 35 | //----------------------------------------------------------------------------- 36 | /** 37 | */ 38 | inline 39 | nList::nList() 40 | { 41 | this->head = (nNode *) &(this->tail); 42 | this->tail = 0; 43 | this->tailpred = (nNode *) &(this->head); 44 | } 45 | 46 | //----------------------------------------------------------------------------- 47 | /** 48 | Destroy list object. The list has to be empty, otherwise an assertion 49 | will be thrown. 50 | */ 51 | inline nList::~nList() 52 | { 53 | assert(0 == this->head->succ); 54 | } 55 | 56 | //----------------------------------------------------------------------------- 57 | /** 58 | @return true if list is empty. 59 | */ 60 | inline 61 | bool 62 | nList::IsEmpty() const 63 | { 64 | return (this->head->succ == 0); 65 | } 66 | 67 | //----------------------------------------------------------------------------- 68 | /** 69 | @return return first node in list, or 0 if list is empty 70 | */ 71 | inline 72 | nNode* 73 | nList::GetHead() const 74 | { 75 | if (this->head->succ) 76 | { 77 | return this->head; 78 | } 79 | else 80 | { 81 | return 0; 82 | } 83 | } 84 | 85 | //----------------------------------------------------------------------------- 86 | /** 87 | @return return last node in list, or 0 if list is empty 88 | */ 89 | inline 90 | nNode* 91 | nList::GetTail() const 92 | { 93 | if (this->tailpred->pred) 94 | { 95 | return this->tailpred; 96 | } 97 | else 98 | { 99 | return 0; 100 | } 101 | } 102 | 103 | //----------------------------------------------------------------------------- 104 | /** 105 | @param n the node to be added 106 | */ 107 | inline 108 | void 109 | nList::AddHead(nNode *n) 110 | { 111 | n->InsertAfter((nNode *) &(this->head)); 112 | } 113 | 114 | //----------------------------------------------------------------------------- 115 | /** 116 | @param n the node to be added 117 | */ 118 | inline 119 | void 120 | nList::AddTail(nNode *n) 121 | { 122 | n->InsertBefore((nNode *) &(this->tail)); 123 | } 124 | 125 | //----------------------------------------------------------------------------- 126 | /** 127 | Remove node at head of list, and return pointer to it. Returns 0 if 128 | list is empty. 129 | 130 | @return the removed node or 0 if list is empty 131 | */ 132 | inline nNode *nList::RemHead() 133 | { 134 | nNode *n = this->head; 135 | if (n->succ) 136 | { 137 | n->Remove(); 138 | return n; 139 | } 140 | else 141 | { 142 | return 0; 143 | } 144 | } 145 | 146 | //----------------------------------------------------------------------------- 147 | /** 148 | Remove node at tail of list, and return pointer to it. Returns 0 if 149 | list is empty. 150 | 151 | @return the removed node or 0 if list is empty 152 | */ 153 | inline nNode *nList::RemTail() 154 | { 155 | nNode *n = this->tailpred; 156 | if (n->pred) 157 | { 158 | n->Remove(); 159 | return n; 160 | } 161 | else 162 | { 163 | return 0; 164 | } 165 | } 166 | //-------------------------------------------------------------------- 167 | #endif 168 | -------------------------------------------------------------------------------- /sptrunk/Common/Utility/nmath.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/nmath.h -------------------------------------------------------------------------------- /sptrunk/Common/Utility/nnode.h: -------------------------------------------------------------------------------- 1 | #ifndef N_NODE_H 2 | #define N_NODE_H 3 | 4 | #include 5 | 6 | class nNode 7 | { 8 | public: 9 | /// the default constructor 10 | nNode(); 11 | /// constructor providing user data pointer 12 | nNode(void *ptr); 13 | /// the destructor 14 | ~nNode(); 15 | /// get the next node in the list 16 | nNode *GetSucc() const; 17 | /// get the previous node in the list 18 | nNode *GetPred() const; 19 | /// insert this node before 'succ' node into list 20 | void InsertBefore(nNode *succ); 21 | /// insert this node after 'pred' node into list 22 | void InsertAfter(nNode *pred); 23 | /// remove node from list 24 | void Remove(); 25 | /// set user data pointer 26 | void SetPtr(void *p); 27 | /// get user data pointer 28 | void *GetPtr() const; 29 | /// check if node is currently linked into a list 30 | bool IsLinked() const; 31 | 32 | private: 33 | friend class nList; 34 | nNode *succ; 35 | nNode *pred; 36 | void *ptr; 37 | }; 38 | 39 | //----------------------------------------------------------------------------- 40 | /** 41 | */ 42 | inline 43 | nNode::nNode(void) 44 | : succ(0), 45 | pred(0), 46 | ptr(0) 47 | { 48 | // empty 49 | } 50 | 51 | //----------------------------------------------------------------------------- 52 | /** 53 | */ 54 | inline 55 | nNode::nNode(void *_ptr) 56 | : succ(0), 57 | pred(0), 58 | ptr(_ptr) 59 | { 60 | // empty 61 | } 62 | 63 | //----------------------------------------------------------------------------- 64 | /** 65 | The destructor will throw an assertion if the node is still linked 66 | into a list! 67 | */ 68 | inline 69 | nNode::~nNode(void) 70 | { 71 | assert(!this->succ); 72 | } 73 | 74 | //----------------------------------------------------------------------------- 75 | /** 76 | Get the node after this node in the list, return 0 if there is no 77 | next node. 78 | 79 | @return the next node or 0 80 | */ 81 | inline 82 | nNode* 83 | nNode::GetSucc(void) const 84 | { 85 | assert(this->succ); 86 | if (this->succ->succ) 87 | return this->succ; 88 | else 89 | return 0; 90 | } 91 | 92 | //----------------------------------------------------------------------------- 93 | /** 94 | Get the node before this node in the list, return 0 if there is no 95 | previous node. 96 | 97 | @return the previous node or 0 98 | */ 99 | inline 100 | nNode* 101 | nNode::GetPred(void) const 102 | { 103 | assert(this->pred); 104 | if (this->pred->pred) 105 | return this->pred; 106 | else 107 | return 0; 108 | } 109 | 110 | //----------------------------------------------------------------------------- 111 | /** 112 | @param succ node in front of which this node should be inserted 113 | */ 114 | inline 115 | void 116 | nNode::InsertBefore(nNode *succ) 117 | { 118 | assert(succ->pred); 119 | assert(!this->succ); 120 | nNode *pred = succ->pred; 121 | this->pred = pred; 122 | this->succ = succ; 123 | pred->succ = this; 124 | succ->pred = this; 125 | } 126 | 127 | //----------------------------------------------------------------------------- 128 | /** 129 | @param pred the node after which this node should be inserted 130 | */ 131 | inline 132 | void 133 | nNode::InsertAfter(nNode *pred) 134 | { 135 | assert(pred->succ); 136 | assert(!this->succ); 137 | nNode *succ = pred->succ; 138 | this->pred = pred; 139 | this->succ = succ; 140 | pred->succ = this; 141 | succ->pred = this; 142 | } 143 | 144 | //----------------------------------------------------------------------------- 145 | /** 146 | */ 147 | inline 148 | void 149 | nNode::Remove(void) 150 | { 151 | assert(this->succ); 152 | nNode *succ = this->succ; 153 | nNode *pred = this->pred; 154 | succ->pred = pred; 155 | pred->succ = succ; 156 | this->succ = 0; 157 | this->pred = 0; 158 | } 159 | 160 | //----------------------------------------------------------------------------- 161 | /** 162 | @param p the new user data pointer 163 | */ 164 | inline 165 | void 166 | nNode::SetPtr(void *p) 167 | { 168 | this->ptr = p; 169 | } 170 | 171 | //----------------------------------------------------------------------------- 172 | /** 173 | @return the user data pointer 174 | */ 175 | inline 176 | void* 177 | nNode::GetPtr() const 178 | { 179 | return this->ptr; 180 | } 181 | 182 | //----------------------------------------------------------------------------- 183 | /** 184 | @return true if node is currently linked into a list 185 | */ 186 | inline 187 | bool 188 | nNode::IsLinked(void) const 189 | { 190 | if (this->succ) 191 | { 192 | return true; 193 | } 194 | else 195 | { 196 | return false; 197 | } 198 | }; 199 | 200 | //-------------------------------------------------------------------- 201 | #endif 202 | -------------------------------------------------------------------------------- /sptrunk/Common/Utility/nstrlist.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/nstrlist.h -------------------------------------------------------------------------------- /sptrunk/Common/Utility/nstrnode.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/Common/Utility/nstrnode.h -------------------------------------------------------------------------------- /sptrunk/Makefile: -------------------------------------------------------------------------------- 1 | CC=g++ 2 | 3 | all: UtilityCommon.o Singleton.o nmath.o nnode.o nlist.o Narray.o 4 | 5 | UtilityCommon.o:UtilityCommon.h 6 | $(CC) -o $@ -c $^ 7 | 8 | Singleton.o:Singleton.h 9 | $(CC) -o $@ -c $^ 10 | 11 | nmath.o:nmath.h 12 | $(CC) -o $@ -c $^ 13 | nnode.o:nnode.h 14 | $(CC) -o $@ -c $^ 15 | nlist.o:nnode.h 16 | $(CC) -o $@ -c $^ 17 | 18 | Narray.o:Narray.h 19 | $(CC) -o $@ -c $^ 20 | 21 | 22 | clean: 23 | @echo "清空工程build文件" 24 | rm UtilityCommon.o Singleton.o nmath.o nnode.o nlist.o Nstring.o 25 | -------------------------------------------------------------------------------- /sptrunk/PushServer/ClientAcceptor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/ClientAcceptor.cpp -------------------------------------------------------------------------------- /sptrunk/PushServer/ClientAcceptor.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/ClientAcceptor.h -------------------------------------------------------------------------------- /sptrunk/PushServer/CommonHeader.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/CommonHeader.h -------------------------------------------------------------------------------- /sptrunk/PushServer/DBConnector.cpp: -------------------------------------------------------------------------------- 1 | #include "CommonHeader.h" 2 | #include "DBConnector.h" 3 | 4 | DBConnector::DBConnector() 5 | { 6 | 7 | } 8 | 9 | DBConnector::~DBConnector() 10 | { 11 | 12 | } 13 | -------------------------------------------------------------------------------- /sptrunk/PushServer/DBConnector.h: -------------------------------------------------------------------------------- 1 | #ifndef _DB_CONNECTOR_H_ 2 | #define _DB_CONNECTOR_H_ 3 | 4 | #include 5 | 6 | class DBConnector: public Connector 7 | { 8 | public: 9 | DBConnector(); 10 | ~DBConnector(); 11 | }; 12 | 13 | 14 | #endif -------------------------------------------------------------------------------- /sptrunk/PushServer/GlobalDefine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/GlobalDefine.h -------------------------------------------------------------------------------- /sptrunk/PushServer/Main.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/Main.cpp -------------------------------------------------------------------------------- /sptrunk/PushServer/MsgDefine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/MsgDefine.h -------------------------------------------------------------------------------- /sptrunk/PushServer/MsgHandler.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/MsgHandler.cpp -------------------------------------------------------------------------------- /sptrunk/PushServer/MsgHandler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/MsgHandler.h -------------------------------------------------------------------------------- /sptrunk/PushServer/MsgHandler_CS.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/MsgHandler_CS.cpp -------------------------------------------------------------------------------- /sptrunk/PushServer/MsgHandler_WS.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/MsgHandler_WS.cpp -------------------------------------------------------------------------------- /sptrunk/PushServer/MsgStruct_CS.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/MsgStruct_CS.h -------------------------------------------------------------------------------- /sptrunk/PushServer/MsgStruct_WS.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/MsgStruct_WS.h -------------------------------------------------------------------------------- /sptrunk/PushServer/NetThread.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/NetThread.cpp -------------------------------------------------------------------------------- /sptrunk/PushServer/NetThread.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/NetThread.h -------------------------------------------------------------------------------- /sptrunk/PushServer/PushServer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/PushServer.cpp -------------------------------------------------------------------------------- /sptrunk/PushServer/PushServer.h: -------------------------------------------------------------------------------- 1 | #ifndef _PUSH_SERVER_H_ 2 | #define _PUSH_SERVER_H_ 3 | 4 | 5 | class PushServer 6 | { 7 | public: 8 | PushServer(); 9 | ~PushServer(); 10 | 11 | public: 12 | bool InitServer(); 13 | void RunServer(); 14 | void Release(); 15 | 16 | private: 17 | }; 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /sptrunk/PushServer/PushServer.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {971F6F0D-A57E-4330-A41E-D8D7216F1085} 15 | Win32Proj 16 | PushServer 17 | 18 | 19 | 20 | Application 21 | true 22 | Unicode 23 | 24 | 25 | Application 26 | false 27 | true 28 | Unicode 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | true 42 | $(BOOST_PATH)\include;$(IncludePath) 43 | $(BOOST_PATH)\lib;$(LibraryPath) 44 | ../_Bin/Server/ 45 | ../_Build10/$(Configuration)/$(ProjectName)\ 46 | $(ProjectName)_d 47 | 48 | 49 | false 50 | 51 | 52 | 53 | NotUsing 54 | Level3 55 | Disabled 56 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 57 | ../Common/ 58 | MultiThreadedDebug 59 | 60 | 61 | Console 62 | true 63 | ../_Lib 64 | 65 | 66 | 67 | 68 | Level3 69 | Use 70 | MaxSpeed 71 | true 72 | true 73 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 74 | 75 | 76 | Console 77 | true 78 | true 79 | true 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /sptrunk/PushServer/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | 控制台应用程序:PushServer 项目概述 3 | ======================================================================== 4 | 5 | 应用程序向导已为您创建了此 PushServer 应用程序。 6 | 7 | 本文件概要介绍组成 PushServer 应用程序的每个文件的内容。 8 | 9 | 10 | PushServer.vcxproj 11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件, 12 | 其中包含生成该文件的 Visual C++ 13 | 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。 14 | 15 | PushServer.vcxproj.filters 16 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。 17 | 它包含有关项目文件与筛选器之间的关联信息。 在 IDE 18 | 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。 19 | 例如,“.cpp”文件与“源文件”筛选器关联。 20 | 21 | PushServer.cpp 22 | 这是主应用程序源文件。 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | 其他标准文件: 26 | 27 | StdAfx.h,StdAfx.cpp 28 | 这些文件用于生成名为 PushServer.pch 的预编译头 (PCH) 文件和 29 | 名为 StdAfx.obj 的预编译类型文件。 30 | 31 | ///////////////////////////////////////////////////////////////////////////// 32 | 其他注释: 33 | 34 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。 35 | 36 | ///////////////////////////////////////////////////////////////////////////// 37 | -------------------------------------------------------------------------------- /sptrunk/PushServer/ServerConfig.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/ServerConfig.cpp -------------------------------------------------------------------------------- /sptrunk/PushServer/ServerConfig.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/ServerConfig.h -------------------------------------------------------------------------------- /sptrunk/PushServer/UserManager.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/UserManager.cpp -------------------------------------------------------------------------------- /sptrunk/PushServer/UserManager.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/UserManager.h -------------------------------------------------------------------------------- /sptrunk/PushServer/WebSvrConnector.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/WebSvrConnector.cpp -------------------------------------------------------------------------------- /sptrunk/PushServer/WebSvrConnector.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/PushServer/WebSvrConnector.h -------------------------------------------------------------------------------- /sptrunk/PushServer_VC10.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 11.00 2 | # Visual Studio 2010 3 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "GlobalCommon", "GlobalCommon", "{D34CB779-0F60-4304-9525-9F5B224281F6}" 4 | EndProject 5 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ServerProject", "ServerProject", "{B2DA2499-B5BC-426A-A9C1-723E21BF43C1}" 6 | EndProject 7 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Utility", "Common\Utility\Utility_VC10.vcxproj", "{C40CA432-21FF-43EA-A604-452AE6C3430B}" 8 | EndProject 9 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AdvanceLib", "Common\AdvanceLib\AdvanceLib_VC10.vcxproj", "{9626EE8E-5A74-4CE4-9B17-69C042DF94F2}" 10 | EndProject 11 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PushServer", "PushServer\PushServer.vcxproj", "{971F6F0D-A57E-4330-A41E-D8D7216F1085}" 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug_Tools|Win32 = Debug_Tools|Win32 16 | Debug|Win32 = Debug|Win32 17 | Release_Tools|Win32 = Release_Tools|Win32 18 | Release|Win32 = Release|Win32 19 | Template|Win32 = Template|Win32 20 | WIN32_DEBUG|Win32 = WIN32_DEBUG|Win32 21 | WIN32_RELEASE|Win32 = WIN32_RELEASE|Win32 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {C40CA432-21FF-43EA-A604-452AE6C3430B}.Debug_Tools|Win32.ActiveCfg = Debug|Win32 25 | {C40CA432-21FF-43EA-A604-452AE6C3430B}.Debug_Tools|Win32.Build.0 = Debug|Win32 26 | {C40CA432-21FF-43EA-A604-452AE6C3430B}.Debug|Win32.ActiveCfg = Debug|Win32 27 | {C40CA432-21FF-43EA-A604-452AE6C3430B}.Debug|Win32.Build.0 = Debug|Win32 28 | {C40CA432-21FF-43EA-A604-452AE6C3430B}.Release_Tools|Win32.ActiveCfg = Release|Win32 29 | {C40CA432-21FF-43EA-A604-452AE6C3430B}.Release_Tools|Win32.Build.0 = Release|Win32 30 | {C40CA432-21FF-43EA-A604-452AE6C3430B}.Release|Win32.ActiveCfg = Release|Win32 31 | {C40CA432-21FF-43EA-A604-452AE6C3430B}.Release|Win32.Build.0 = Release|Win32 32 | {C40CA432-21FF-43EA-A604-452AE6C3430B}.Template|Win32.ActiveCfg = Template|Win32 33 | {C40CA432-21FF-43EA-A604-452AE6C3430B}.Template|Win32.Build.0 = Template|Win32 34 | {C40CA432-21FF-43EA-A604-452AE6C3430B}.WIN32_DEBUG|Win32.ActiveCfg = Template|Win32 35 | {C40CA432-21FF-43EA-A604-452AE6C3430B}.WIN32_DEBUG|Win32.Build.0 = Template|Win32 36 | {C40CA432-21FF-43EA-A604-452AE6C3430B}.WIN32_RELEASE|Win32.ActiveCfg = Template|Win32 37 | {C40CA432-21FF-43EA-A604-452AE6C3430B}.WIN32_RELEASE|Win32.Build.0 = Template|Win32 38 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2}.Debug_Tools|Win32.ActiveCfg = Debug|Win32 39 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2}.Debug_Tools|Win32.Build.0 = Debug|Win32 40 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2}.Debug|Win32.ActiveCfg = Debug|Win32 41 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2}.Debug|Win32.Build.0 = Debug|Win32 42 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2}.Release_Tools|Win32.ActiveCfg = Release|Win32 43 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2}.Release_Tools|Win32.Build.0 = Release|Win32 44 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2}.Release|Win32.ActiveCfg = Release|Win32 45 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2}.Release|Win32.Build.0 = Release|Win32 46 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2}.Template|Win32.ActiveCfg = Release|Win32 47 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2}.Template|Win32.Build.0 = Release|Win32 48 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2}.WIN32_DEBUG|Win32.ActiveCfg = Release|Win32 49 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2}.WIN32_DEBUG|Win32.Build.0 = Release|Win32 50 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2}.WIN32_RELEASE|Win32.ActiveCfg = Release|Win32 51 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2}.WIN32_RELEASE|Win32.Build.0 = Release|Win32 52 | {971F6F0D-A57E-4330-A41E-D8D7216F1085}.Debug_Tools|Win32.ActiveCfg = Debug|Win32 53 | {971F6F0D-A57E-4330-A41E-D8D7216F1085}.Debug_Tools|Win32.Build.0 = Debug|Win32 54 | {971F6F0D-A57E-4330-A41E-D8D7216F1085}.Debug|Win32.ActiveCfg = Debug|Win32 55 | {971F6F0D-A57E-4330-A41E-D8D7216F1085}.Debug|Win32.Build.0 = Debug|Win32 56 | {971F6F0D-A57E-4330-A41E-D8D7216F1085}.Release_Tools|Win32.ActiveCfg = Release|Win32 57 | {971F6F0D-A57E-4330-A41E-D8D7216F1085}.Release_Tools|Win32.Build.0 = Release|Win32 58 | {971F6F0D-A57E-4330-A41E-D8D7216F1085}.Release|Win32.ActiveCfg = Release|Win32 59 | {971F6F0D-A57E-4330-A41E-D8D7216F1085}.Release|Win32.Build.0 = Release|Win32 60 | {971F6F0D-A57E-4330-A41E-D8D7216F1085}.Template|Win32.ActiveCfg = Release|Win32 61 | {971F6F0D-A57E-4330-A41E-D8D7216F1085}.Template|Win32.Build.0 = Release|Win32 62 | {971F6F0D-A57E-4330-A41E-D8D7216F1085}.WIN32_DEBUG|Win32.ActiveCfg = Release|Win32 63 | {971F6F0D-A57E-4330-A41E-D8D7216F1085}.WIN32_DEBUG|Win32.Build.0 = Release|Win32 64 | {971F6F0D-A57E-4330-A41E-D8D7216F1085}.WIN32_RELEASE|Win32.ActiveCfg = Release|Win32 65 | {971F6F0D-A57E-4330-A41E-D8D7216F1085}.WIN32_RELEASE|Win32.Build.0 = Release|Win32 66 | EndGlobalSection 67 | GlobalSection(SolutionProperties) = preSolution 68 | HideSolutionNode = FALSE 69 | EndGlobalSection 70 | GlobalSection(NestedProjects) = preSolution 71 | {971F6F0D-A57E-4330-A41E-D8D7216F1085} = {B2DA2499-B5BC-426A-A9C1-723E21BF43C1} 72 | {C40CA432-21FF-43EA-A604-452AE6C3430B} = {D34CB779-0F60-4304-9525-9F5B224281F6} 73 | {9626EE8E-5A74-4CE4-9B17-69C042DF94F2} = {D34CB779-0F60-4304-9525-9F5B224281F6} 74 | EndGlobalSection 75 | GlobalSection(DPCodeReviewSolutionGUID) = preSolution 76 | DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} 77 | EndGlobalSection 78 | EndGlobal 79 | -------------------------------------------------------------------------------- /sptrunk/_Android/AndroidApp/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /sptrunk/_Android/AndroidApp/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | AndroidApp 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /sptrunk/_Android/AndroidApp/bin/AppMain.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Android/AndroidApp/bin/AppMain.class -------------------------------------------------------------------------------- /sptrunk/_Android/AndroidApp/bin/MSG_C2S_USER_AUTH_SYN.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Android/AndroidApp/bin/MSG_C2S_USER_AUTH_SYN.class -------------------------------------------------------------------------------- /sptrunk/_Android/AndroidApp/bin/MSG_S2C_SVR_READY_CMD.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Android/AndroidApp/bin/MSG_S2C_SVR_READY_CMD.class -------------------------------------------------------------------------------- /sptrunk/_Android/AndroidApp/bin/MSG_S2C_USER_AUTH_ACK.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Android/AndroidApp/bin/MSG_S2C_USER_AUTH_ACK.class -------------------------------------------------------------------------------- /sptrunk/_Android/AndroidApp/bin/MsgBase.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Android/AndroidApp/bin/MsgBase.class -------------------------------------------------------------------------------- /sptrunk/_Android/AndroidApp/bin/MsgHandler.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Android/AndroidApp/bin/MsgHandler.class -------------------------------------------------------------------------------- /sptrunk/_Android/AndroidApp/src/AppMain.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Android/AndroidApp/src/AppMain.java -------------------------------------------------------------------------------- /sptrunk/_Android/AndroidApp/src/MsgBase.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Android/AndroidApp/src/MsgBase.java -------------------------------------------------------------------------------- /sptrunk/_Android/AndroidApp/src/MsgHandler.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Android/AndroidApp/src/MsgHandler.java -------------------------------------------------------------------------------- /sptrunk/_Bin/Server/AgentServer.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Bin/Server/AgentServer.ini -------------------------------------------------------------------------------- /sptrunk/_Bin/Server/LoginServer.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Bin/Server/LoginServer.ini -------------------------------------------------------------------------------- /sptrunk/_Bin/Server/Server.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Bin/Server/Server.ini -------------------------------------------------------------------------------- /sptrunk/_Bin/Server/ServerOption.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Bin/Server/ServerOption.ini -------------------------------------------------------------------------------- /sptrunk/_Web/index.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Web/index.php -------------------------------------------------------------------------------- /sptrunk/_Web/msgbase.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Web/msgbase.php -------------------------------------------------------------------------------- /sptrunk/_Web/msghandler.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Web/msghandler.php -------------------------------------------------------------------------------- /sptrunk/_Web/netcommon.php: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fallenbird/SunPush/28a4c97426db67d7ade0a49bfc33c92155d6d3ad/sptrunk/_Web/netcommon.php --------------------------------------------------------------------------------