Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.4 KiB

  1. #include "stdafx.h"
  2. #pragma hdrstop
  3. #include "allowed.h"
  4. using namespace std;
  5. ModulesAndImports::~ModulesAndImports ()
  6. {
  7. }
  8. BOOL
  9. ModulesAndImports::IsModule (LPCSTR name)
  10. {
  11. CString str;
  12. m_curr_module = name;
  13. return m_imports.Lookup (name, str);
  14. }
  15. BOOL
  16. ModulesAndImports::Lookup (LPCSTR name, CString& msg)
  17. {
  18. msg = "";
  19. return m_imports.Lookup (m_curr_module+CString("!")+CString(name), msg);
  20. }
  21. int __cdecl CompareCString(const void* a, const void* b)
  22. {
  23. CString* A = *(CString**)a;
  24. CString* B = *(CString**)b;
  25. return strcmp((LPCSTR)*A, (LPCSTR)*B);
  26. }
  27. void
  28. ModulesAndImports::Dump(std::ostream& out)
  29. {
  30. size_t imp_num = m_imports.GetCount();
  31. if (imp_num) {
  32. size_t i = 0;
  33. CString** Index = new CString*[imp_num];
  34. POSITION pos = m_imports.GetStartPosition();
  35. while ((pos != NULL) && (i < imp_num)) {
  36. CString Imp, Msg;
  37. m_imports.GetNextAssoc(pos, Imp, Msg);
  38. if (Msg.GetLength()) {
  39. Imp += " - ";
  40. Imp += Msg;
  41. }
  42. Index[i++] = new CString(Imp);
  43. }
  44. imp_num = i;
  45. qsort(Index, imp_num, sizeof(*Index), CompareCString);
  46. for (i = 0; i < imp_num; ++i) {
  47. cout << (LPCSTR)*Index[i] << endl;
  48. delete Index[i];
  49. }
  50. delete[] Index;
  51. }
  52. }