Source code of Windows XP (NT5)
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.

239 lines
4.5 KiB

  1. /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. NAMEDICT.cxx
  5. Abstract:
  6. This file stores the indexes of all class assocation entries based on IID.
  7. Notes:
  8. History:
  9. VibhasC Sep-29-1996 Created.
  10. ----------------------------------------------------------------------------*/
  11. /****************************************************************************
  12. * include files
  13. ***************************************************************************/
  14. #include "precomp.hxx"
  15. void
  16. NAMEDICT::Clear()
  17. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  18. Routine Description:
  19. Clear the dictionary of all ITF_ENTRY indexes allocated.
  20. NOTE: tHIS FUNCTION DOES NOT DELETE THE ITF_ENTRY, BUT ONLY THE INDEX
  21. OF THE CLASS ENTRY
  22. Arguments:
  23. None.
  24. Return Value:
  25. None.
  26. Notes:
  27. ----------------------------------------------------------------------------*/
  28. {
  29. Dict_Status Status;
  30. char * pClassEntry;
  31. //
  32. // The way to delete all elements is to get to the top and then
  33. // do a get next, delete each one.
  34. //
  35. //
  36. // Note: Dict_Next() has a default parameter of null. This returns the
  37. // first record in the dictionary.
  38. //
  39. Status = Dict_Next();
  40. while( SUCCESS == Status )
  41. {
  42. pClassEntry = (char *)Dict_Curr_Item();
  43. Status = Dict_Delete( (pUserType *) &pClassEntry );
  44. }
  45. }
  46. char *
  47. NAMEDICT::GetFirst()
  48. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  49. Routine Description:
  50. Get the first item in the dictionary
  51. Arguments:
  52. None.
  53. Return Value:
  54. None.
  55. Notes:
  56. ----------------------------------------------------------------------------*/
  57. {
  58. Dict_Status Status;
  59. char * pClassEntry;
  60. //
  61. // Dict_Next() has a default parameter of null. This returns the
  62. // first record in the dictionary.
  63. //
  64. Status = Dict_Next();
  65. if( SUCCESS == Status )
  66. return pClassEntry = (char *)Dict_Curr_Item();
  67. else
  68. return 0;
  69. }
  70. char *
  71. NAMEDICT::GetNext( char * pLastClassEntry)
  72. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  73. Routine Description:
  74. Get the next item in the dictionary
  75. Arguments:
  76. pLastClassEntry.
  77. Return Value:
  78. None.
  79. Notes:
  80. pLastClassEntry is the entry returned by the previous call to GetFirst
  81. or GetNext. This is the seed for this search.
  82. This function returns a zero if there are no more entries in the
  83. dictionary.
  84. ----------------------------------------------------------------------------*/
  85. {
  86. Dict_Status Status;
  87. //
  88. // Dict_Next() has a default parameter of null. This returns the
  89. // first record in the dictionary. But if we supply the last searched
  90. // item, we get the next in the dictionary.
  91. //
  92. if( (Status = Dict_Next( pLastClassEntry) ) == SUCCESS )
  93. return pLastClassEntry = (char *)Dict_Curr_Item();
  94. else
  95. return 0;
  96. }
  97. char *
  98. NAMEDICT::Insert(
  99. char * pClassEntry )
  100. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  101. Routine Description:
  102. Insert a class entry in the index.
  103. Arguments:
  104. Return Value:
  105. A pointer to the char entry which was created and inserted.
  106. Notes:
  107. Search for the class association entry and if it exists, return that,
  108. do not create a new one.
  109. ----------------------------------------------------------------------------*/
  110. {
  111. Dict_Status Status = Dict_Find( pClassEntry );
  112. switch( Status )
  113. {
  114. case EMPTY_DICTIONARY:
  115. case ITEM_NOT_FOUND:
  116. Dict_Insert( (pUserType) pClassEntry );
  117. return pClassEntry;
  118. default:
  119. return (char *)Dict_Curr_Item();
  120. }
  121. }
  122. char *
  123. NAMEDICT::Search(
  124. char * Name, DWORD Context )
  125. /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  126. Routine Description:
  127. Search for a class entry in the dictionary.
  128. Arguments:
  129. pClassEntry - Name of the char being searched for.
  130. Return Value:
  131. A pointer to the char expression if found.
  132. NULL otherwise.
  133. Notes:
  134. ----------------------------------------------------------------------------*/
  135. {
  136. Dict_Status Status = Dict_Find( Name );
  137. switch( Status )
  138. {
  139. case EMPTY_DICTIONARY:
  140. case ITEM_NOT_FOUND:
  141. return (char *)0;
  142. default:
  143. return (char *)Dict_Curr_Item();
  144. }
  145. }
  146. int
  147. NAMEDICT::Compare(
  148. void * p1,
  149. void * p2 )
  150. {
  151. char * pRes1 = (char *)p1;
  152. char * pRes2 = (char *)p2;
  153. int Result;
  154. Result = _stricmp( pRes1, pRes2 );
  155. Result = (Result < 0) ? -1 : (Result > 0) ? 1 : 0;
  156. return Result;
  157. }
  158. void
  159. PrintcharKey( void * p )
  160. {
  161. ((void)(p));
  162. }