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.

93 lines
1.9 KiB

  1. /*
  2. * REVISIONS:
  3. * pcy04Dec92: Added string.h
  4. * ane16Dec92: Added destructor
  5. * rct19Jan93: modified constructors & destructors
  6. * mwh01Jun94: port for INTERACTIVE
  7. * mwh07Jun94: port for NCR
  8. * jps13Jul94: os2 needs stdlib
  9. * daf17May95: port for ALPHA/OSF
  10. * djs02Sep95: port for AIX 4.1
  11. */
  12. //
  13. // This is the implementation for item codes (held by the config mgr)
  14. //
  15. // R. Thurston
  16. //
  17. //
  18. #define INCL_BASE
  19. #define INCL_NOPM
  20. #include "cdefine.h"
  21. extern "C" {
  22. #include <string.h>
  23. #if (C_OS & (C_INTERACTIVE | C_OS2 | C_ALPHAOSF)) || ((C_OS & C_AIX) && (C_AIX_VERSION & C_AIX4))
  24. # include <stdlib.h>
  25. #else
  26. # include <malloc.h>
  27. #endif
  28. }
  29. #include "itemcode.h"
  30. #if (C_OS & C_NCR)
  31. # include "incfix.h"
  32. #endif
  33. //-------------------------------------------------------------------
  34. ItemCode::ItemCode( INT aCode, PCHAR aComponent, PCHAR anItem, PCHAR aDefault )
  35. : theComponent(aComponent), theItem(anItem), theCode(aCode)
  36. {
  37. if(aComponent)
  38. theComponent = _strdup(aComponent);
  39. if(anItem)
  40. theItem = _strdup(anItem);
  41. if(aDefault)
  42. theDefaultValue = _strdup(aDefault);
  43. }
  44. //-------------------------------------------------------------------
  45. ItemCode::~ItemCode()
  46. {
  47. if(theComponent)
  48. free(theComponent);
  49. if(theItem)
  50. free(theItem);
  51. if (theDefaultValue != NULL)
  52. free(theDefaultValue);
  53. }
  54. //-------------------------------------------------------------------
  55. //
  56. // Equals method
  57. //
  58. INT ItemCode::Equal( RObj anObject ) const
  59. {
  60. if (anObject.IsA() != IsA())
  61. return FALSE;
  62. INT code = ((RItemCode) anObject).GetCode();
  63. PCHAR comp = ((RItemCode) anObject).GetComponent();
  64. PCHAR item = ((RItemCode) anObject).GetItem();
  65. if ((theCode == code) &&
  66. (strcmp(theComponent, comp) == 0) &&
  67. (strcmp(theItem, item) == 0)) {
  68. return TRUE;
  69. }
  70. else {
  71. return FALSE;
  72. }
  73. }