modManage.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include "precompile.h"
  2. #include "modManage.h"
  3. #include <map>
  4. #include <string>
  5. #include <windows.h>
  6. using namespace std;
  7. map<string, mod_runInfo*> modManage;
  8. int paramSplit(char* srcStr, char dstParam[10][MAX_PATH])
  9. {
  10. char *split = " ", *p = NULL;
  11. int i = 0;
  12. if (NULL == srcStr || NULL == dstParam)
  13. return -1;
  14. p = strtok(srcStr, split);
  15. for (i = 0; p != NULL; i++)
  16. {
  17. strcpy(&(dstParam[i][0]), p);
  18. p = strtok(NULL,split);
  19. }
  20. return i;
  21. }
  22. const mod_runInfo* queryModInfo(const char *modName)
  23. {
  24. if(NULL == modName)
  25. return NULL;
  26. map<string, mod_runInfo*>::iterator iter = modManage.find(string(modName));
  27. if (iter != modManage.end())
  28. return iter->second;
  29. else
  30. return NULL;
  31. }
  32. int AddmodInfo(mod_runInfo* threadInfo, const char *modName)
  33. {
  34. if (NULL == queryModInfo(modName))
  35. modManage.insert(pair<string,mod_runInfo*>(string(modName), threadInfo));
  36. return 0;
  37. }
  38. int removeModInfo(const char *modName)
  39. {
  40. if (NULL == modName)
  41. return -1;
  42. map<string, mod_runInfo*>::iterator iter = modManage.find(string(modName));
  43. if (iter != modManage.end())
  44. {
  45. free(iter->second);
  46. modManage.erase(iter);
  47. }
  48. return 0;
  49. }