Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
  2. // Windows Header Files:
  3. #include <windows.h>
  4.  
  5. #include <iostream>
  6. #include <vector>
  7. #include <string>
  8. #include <sstream>
  9. #include <fstream>
  10. #include <algorithm>
  11. #include <iterator>
  12. #include <ctime>
  13.  
  14. #define MISS_CREATE 0
  15. #define MISS_BRIEF_END 1
  16. #define MISS_END 2
  17. #define UNIT_CONNECT 3
  18. #define UNIT_KILLED 4
  19. #define UNIT_REFRESH 5
  20. #define PATH "C:\\Stat\\logs\\"
  21. #define BUFF 256
  22.  
  23. BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
  24. {
  25. switch (ul_reason_for_call)
  26. {
  27. case DLL_PROCESS_ATTACH:
  28. case DLL_THREAD_ATTACH:
  29. case DLL_THREAD_DETACH:
  30. case DLL_PROCESS_DETACH:
  31. break;
  32. }
  33. return TRUE;
  34. }
  35.  
  36. extern "C"
  37. {
  38. __declspec (dllexport) void __stdcall RVExtension(char *output, int outputSize, const char *function);
  39. }
  40.  
  41. // Global vars
  42. std::string outfile_name;
  43.  
  44. using namespace std;
  45.  
  46. vector<string> split(const string& s, const string& delim, const bool keep_empty = true) {
  47. vector<string> result;
  48. if (delim.empty()) {
  49. result.push_back(s);
  50. return result;
  51. }
  52. string::const_iterator substart = s.begin(), subend;
  53. while (true) {
  54. subend = search(substart, s.end(), delim.begin(), delim.end());
  55. string temp(substart, subend);
  56. if (keep_empty || !temp.empty()) {
  57. result.push_back(temp);
  58. }
  59. if (subend == s.end()) {
  60. break;
  61. }
  62. substart = subend + delim.size();
  63. }
  64. return result;
  65. }
  66.  
  67.  
  68. void __stdcall RVExtension(char *output, int outputSize, const char *function)
  69. {
  70. string data(function);
  71. const vector<string> params = split(function, "#@");
  72. string event = params[0];
  73.  
  74. // Time
  75. time_t rawtime;
  76. struct tm *timeinfo;
  77. time(&rawtime);
  78. timeinfo = localtime(&rawtime);
  79. char buffer[BUFF];
  80. strftime(buffer, BUFF, "%F_%H-%M-%S", timeinfo);
  81. string time_str(buffer);
  82.  
  83. // Creating mission file
  84. if (stoi(event) == MISS_CREATE) {
  85. outfile_name = PATH + time_str + "_" + params[1];
  86. string out = "NEW FILE: " + outfile_name;
  87. strncpy(output, out.c_str(), sizeof(out.c_str()));
  88. } else {
  89. strncpy(output, "WORKS", 5);
  90. }
  91.  
  92. // Write data
  93. std::ofstream outfile;
  94. outfile.open(outfile_name.c_str(), ios_base::app);
  95. outfile << time_str + "#@" + data << endl;
  96. outfile.close();
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement