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.

262 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. frsguid.c
  5. Abstract:
  6. These routines temporarily supply guids for replica sets and
  7. servers.
  8. Author:
  9. Billy J. Fuller 06-May-1997
  10. Environment
  11. User mode winnt
  12. --*/
  13. #include <ntreppch.h>
  14. #pragma hdrstop
  15. #define DEBSUB "FRSGNAME:"
  16. #include <frs.h>
  17. PVOID
  18. FrsFreeGName(
  19. IN PVOID Arg
  20. )
  21. /*++
  22. Routine Description:
  23. Free a gname entry in a table
  24. Arguments:
  25. Arg - entry in table points to this value
  26. Return Value:
  27. None.
  28. --*/
  29. {
  30. PGNAME GName = Arg;
  31. if (GName) {
  32. FrsFree(GName->Guid);
  33. FrsFree(GName->Name);
  34. FrsFree(GName);
  35. }
  36. return NULL;
  37. }
  38. PGNAME
  39. FrsBuildGName(
  40. IN OPTIONAL GUID *Guid,
  41. IN OPTIONAL PWCHAR Name
  42. )
  43. /*++
  44. Routine Description:
  45. Build a GName
  46. Arguments:
  47. Guid - address of a binary guid
  48. Name - printable name
  49. Return Value:
  50. Address of a GName that points to Guid and Name.
  51. --*/
  52. {
  53. PGNAME GName;
  54. GName = FrsAlloc(sizeof(GNAME));
  55. GName->Guid = Guid;
  56. GName->Name = Name;
  57. return GName;
  58. }
  59. PGVSN
  60. FrsBuildGVsn(
  61. IN OPTIONAL GUID *Guid,
  62. IN ULONGLONG Vsn
  63. )
  64. /*++
  65. Routine Description:
  66. Build a gusn
  67. Arguments:
  68. Guid
  69. Vsn
  70. Return Value:
  71. Address of a gusn
  72. --*/
  73. {
  74. PGVSN GVsn;
  75. GVsn = FrsAlloc(sizeof(GVSN));
  76. COPY_GUID(&GVsn->Guid, Guid);
  77. GVsn->Vsn = Vsn;
  78. return GVsn;
  79. }
  80. PGNAME
  81. FrsDupGName(
  82. IN PGNAME SrcGName
  83. )
  84. /*++
  85. Routine Description:
  86. Duplicate a gstring
  87. Arguments:
  88. OrigGName
  89. Return Value:
  90. None.
  91. --*/
  92. {
  93. PGNAME GName;
  94. //
  95. // nothing to do
  96. //
  97. if (!SrcGName)
  98. return NULL;
  99. GName = FrsAlloc(sizeof(GNAME));
  100. //
  101. // guid
  102. //
  103. if (SrcGName->Guid) {
  104. GName->Guid = FrsAlloc(sizeof(GUID));
  105. COPY_GUID(GName->Guid, SrcGName->Guid);
  106. }
  107. //
  108. // name
  109. //
  110. if (SrcGName->Name)
  111. GName->Name = FrsWcsDup(SrcGName->Name);
  112. //
  113. // done
  114. //
  115. return GName;
  116. }
  117. GUID *
  118. FrsDupGuid(
  119. IN GUID *Guid
  120. )
  121. /*++
  122. Routine Description:
  123. Duplicate a guid
  124. Arguments:
  125. Guid
  126. Return Value:
  127. None.
  128. --*/
  129. {
  130. GUID *NewGuid;
  131. //
  132. // nothing to do
  133. //
  134. if (!Guid)
  135. return NULL;
  136. NewGuid = FrsAlloc(sizeof(GUID));
  137. COPY_GUID(NewGuid, Guid);
  138. //
  139. // done
  140. //
  141. return NewGuid;
  142. }
  143. PGNAME
  144. FrsCopyGName(
  145. IN GUID *Guid,
  146. IN PWCHAR Name
  147. )
  148. /*++
  149. Routine Description:
  150. Allocate a gname and duplicate the guid and name into it
  151. Arguments:
  152. Guid
  153. Name
  154. Return Value:
  155. None.
  156. --*/
  157. {
  158. PGNAME GName;
  159. GName = FrsAlloc(sizeof(GNAME));
  160. //
  161. // guid
  162. //
  163. if (Guid) {
  164. GName->Guid = FrsAlloc(sizeof(GUID));
  165. COPY_GUID(GName->Guid, Guid);
  166. }
  167. //
  168. // name
  169. //
  170. if (Name)
  171. GName->Name = FrsWcsDup(Name);
  172. //
  173. // done
  174. //
  175. return GName;
  176. }
  177. VOID
  178. FrsPrintGName(
  179. IN PGNAME GName
  180. )
  181. /*++
  182. Routine Description:
  183. Print a gname
  184. Arguments:
  185. GName
  186. Return Value:
  187. None.
  188. --*/
  189. {
  190. CHAR Guid[GUID_CHAR_LEN + 1];
  191. //
  192. // print the GName
  193. //
  194. GuidToStr(GName->Guid, &Guid[0]);
  195. DPRINT2(0, "%ws %s\n", GName->Name, Guid);
  196. }
  197. VOID
  198. FrsPrintGuid(
  199. IN GUID *Guid
  200. )
  201. /*++
  202. Routine Description:
  203. Print a guid
  204. Arguments:
  205. Guid
  206. Return Value:
  207. None.
  208. --*/
  209. {
  210. CHAR PGuid[GUID_CHAR_LEN + 1];
  211. //
  212. // print the GName
  213. //
  214. GuidToStr(Guid, &PGuid[0]);
  215. DPRINT1(0, "%s\n", PGuid);
  216. }