misc.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. EQ2Emulator: Everquest II Server Emulator
  3. Copyright (C) 2007 EQ2EMulator Development Team (http://www.eq2emulator.net)
  4. This file is part of EQ2Emulator.
  5. EQ2Emulator is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. EQ2Emulator is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with EQ2Emulator. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef _MISC_H
  17. #define _MISC_H
  18. #include <stdio.h>
  19. #include <string>
  20. #include <map>
  21. using namespace std;
  22. #define ITEMFIELDCOUNT 116
  23. void Unprotect(string &s, char what);
  24. void Protect(string &s, char what);
  25. bool ItemParse(const char *data, int length, map<int,map<int,string> > &items, int id_pos, int name_pos, int max_field, int level=0);
  26. int Tokenize(string s, map<int,string> & tokens, char delim='|');
  27. void LoadItemDBFieldNames();
  28. void encode_length(unsigned long length, char *out);
  29. unsigned long decode_length(char *in);
  30. unsigned long encode(char *in, unsigned long length, char *out);
  31. void decode(char *in, char *out);
  32. void encode_chunk(char *in, int len, char *out);
  33. void decode_chunk(char *in, char *out);
  34. int Deflate(unsigned char* in_data, int in_length, unsigned char* out_data, int max_out_length);
  35. int Inflate(unsigned char* indata, int indatalen, unsigned char* outdata, int outdatalen, bool iQuiet=true);
  36. #ifndef WIN32
  37. int print_stacktrace();
  38. #endif
  39. bool alpha_check(unsigned char val);
  40. void dump_message_column(unsigned char *buffer, unsigned long length, string leader="", FILE *to = stdout);
  41. string string_from_time(string pattern, time_t now=0);
  42. string timestamp(time_t now=0);
  43. string long2ip(unsigned long ip);
  44. string pop_arg(string &s, string seps, bool obey_quotes);
  45. int EQsprintf(char *buffer, const char *pattern, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5, const char *arg6, const char *arg7, const char *arg8, const char *arg9);
  46. int GetItemNameCrc(string item_name);
  47. #endif