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.

76 lines
1.7 KiB

  1. #include "stdafx.h"
  2. #include "mon.h"
  3. CCommonAlias gCommonAlias;
  4. int compareCommonAlias(LPCOMMON_ALIAS p1, LPCOMMON_ALIAS p2)
  5. {
  6. return (stricmp(p1->lpAlias, p2->lpAlias));
  7. }
  8. CCommonAlias::CCommonAlias()
  9. {
  10. m_Alias.RemoveAll();
  11. }
  12. CCommonAlias::~CCommonAlias()
  13. {
  14. ClearAll();
  15. }
  16. VOID CCommonAlias::ClearAll(VOID)
  17. {
  18. for (int i = 0; i < m_Alias.GetSize(); i++)
  19. free (m_Alias[i]);
  20. m_Alias.RemoveAll();
  21. }
  22. LPCOMMON_ALIAS CCommonAlias::AddOneAlias(LPSTR lpAlias, LPSTR lpContents)
  23. {
  24. LPCOMMON_ALIAS pNewAlias = (PCOMMON_ALIAS)malloc(sizeof(COMMON_ALIAS)
  25. + lstrlen(lpAlias)
  26. + lstrlen(lpContents) + 2);
  27. if (pNewAlias == NULL)
  28. {
  29. ASSERT(FALSE);
  30. return NULL;
  31. }
  32. pNewAlias->lpAlias = (LPSTR)(pNewAlias + 1);
  33. pNewAlias->lpContents = pNewAlias->lpAlias + lstrlen(lpAlias)+1;
  34. strcpy(pNewAlias->lpAlias, lpAlias);
  35. strcpy(pNewAlias->lpContents, lpContents);
  36. int comp = 1;
  37. for (int i = 0; i < m_Alias.GetSize(); i++)
  38. {
  39. LPCOMMON_ALIAS pAlias = (LPCOMMON_ALIAS)m_Alias[i];
  40. comp = compareCommonAlias(pNewAlias, pAlias);
  41. if (comp > 0)
  42. continue;
  43. else if (comp < 0)
  44. break;
  45. if (strcmp(pNewAlias->lpContents, pAlias->lpContents))
  46. {
  47. sprintf(gszMsg, "Alias %%%s%% has conflicting contents:\n\n%s\n%s",
  48. lpAlias, pNewAlias->lpContents, pAlias->lpContents);
  49. MessageBox(NULL, gszMsg, gszInputFileName, MB_OK);
  50. ASSERT(FALSE);
  51. }
  52. break;
  53. }
  54. if (comp == 0)
  55. {
  56. free(pNewAlias);
  57. }
  58. else
  59. {
  60. m_Alias.InsertAt(i, (LPVOID)pNewAlias);
  61. }
  62. return (LPCOMMON_ALIAS)m_Alias[i];
  63. }