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.

265 lines
5.2 KiB

  1. #include "precomp.h"
  2. #include "fsdiag.h"
  3. DEBUG_FILEZONE(ZONE_T120_GCCNC);
  4. /*
  5. * privlist.cpp
  6. *
  7. * Copyright (c) 1994 by DataBeam Corporation, Lexington, KY
  8. *
  9. * Abstract:
  10. * This is the imlpementation file for the class PrivilegeListData.
  11. *
  12. * Caveats:
  13. * None.
  14. *
  15. * Author:
  16. * blp/jbo
  17. */
  18. #include "privlist.h"
  19. /*
  20. * PrivilegeListData ()
  21. *
  22. * Public Function Description
  23. */
  24. PrivilegeListData::PrivilegeListData(
  25. PGCCConferencePrivileges privilege_list)
  26. {
  27. Privilege_List = *privilege_list;
  28. }
  29. /*
  30. * GetPrivilegeListPDU ()
  31. *
  32. * Public Function Description
  33. */
  34. PrivilegeListData::PrivilegeListData( PSetOfPrivileges set_of_privileges)
  35. {
  36. PSetOfPrivileges privilege_set;
  37. Privilege privilege_value;
  38. Privilege_List.terminate_is_allowed = FALSE;
  39. Privilege_List.eject_user_is_allowed = FALSE;
  40. Privilege_List.add_is_allowed = FALSE;
  41. Privilege_List.lock_unlock_is_allowed = FALSE;
  42. Privilege_List.transfer_is_allowed = FALSE;
  43. privilege_set = set_of_privileges;
  44. while (privilege_set != NULL)
  45. {
  46. privilege_value = privilege_set->value;
  47. switch (privilege_value)
  48. {
  49. case TERMINATE:
  50. Privilege_List.terminate_is_allowed = TRUE;
  51. break;
  52. case EJECT_USER:
  53. Privilege_List.eject_user_is_allowed = TRUE;
  54. break;
  55. case ADD:
  56. Privilege_List.add_is_allowed = TRUE;
  57. break;
  58. case LOCK_UNLOCK:
  59. Privilege_List.lock_unlock_is_allowed = TRUE;
  60. break;
  61. case TRANSFER:
  62. Privilege_List.transfer_is_allowed = TRUE;
  63. break;
  64. default:
  65. ERROR_OUT(("PrivilegeListData::PrivilegeListData: Bad privilege value=%d", (UINT) privilege_value));
  66. break;
  67. }
  68. privilege_set = privilege_set->next;
  69. }
  70. }
  71. /*
  72. * ~PrivilegeListData ()
  73. *
  74. * Public Function Description
  75. */
  76. PrivilegeListData::~PrivilegeListData()
  77. {
  78. }
  79. /*
  80. * GetPrivilegeListData ()
  81. *
  82. * Public Function Description
  83. */
  84. /*
  85. * GetPrivilegeListPDU ()
  86. *
  87. * Public Function Description
  88. */
  89. GCCError PrivilegeListData::GetPrivilegeListPDU(
  90. PSetOfPrivileges * set_of_privileges)
  91. {
  92. GCCError return_value = GCC_NO_ERROR;
  93. PSetOfPrivileges current_privilege = NULL;
  94. PSetOfPrivileges next_privilege = NULL;
  95. Privilege privilege_value;
  96. Int i;
  97. *set_of_privileges = NULL;
  98. for (i = 0; i < NUMBER_OF_PRIVILEGES; i++)
  99. {
  100. privilege_value = (Privilege)NUMBER_OF_PRIVILEGES;
  101. switch (i)
  102. {
  103. case TERMINATE_IS_ALLOWED:
  104. if (Privilege_List.terminate_is_allowed )
  105. privilege_value = TERMINATE;
  106. break;
  107. case EJECT_USER_IS_ALLOWED:
  108. if (Privilege_List.eject_user_is_allowed )
  109. privilege_value = EJECT_USER;
  110. break;
  111. case ADD_IS_ALLOWED:
  112. if (Privilege_List.add_is_allowed )
  113. privilege_value = ADD;
  114. break;
  115. case LOCK_UNLOCK_IS_ALLOWED:
  116. if (Privilege_List.lock_unlock_is_allowed )
  117. privilege_value = LOCK_UNLOCK;
  118. break;
  119. case TRANSFER_IS_ALLOWED:
  120. if (Privilege_List.transfer_is_allowed )
  121. privilege_value = TRANSFER;
  122. break;
  123. default:
  124. ERROR_OUT(("PrivilegeListData::GetPrivilegeListPDU: Bad value"));
  125. break;
  126. }
  127. if (privilege_value != NUMBER_OF_PRIVILEGES)
  128. {
  129. DBG_SAVE_FILE_LINE
  130. next_privilege = new SetOfPrivileges;
  131. if (next_privilege != NULL)
  132. {
  133. next_privilege->value = privilege_value;
  134. next_privilege->next = NULL;
  135. if (*set_of_privileges == NULL)
  136. {
  137. *set_of_privileges = next_privilege;
  138. current_privilege = next_privilege;
  139. }
  140. else
  141. {
  142. if(current_privilege != NULL)
  143. {
  144. current_privilege->next = next_privilege;
  145. current_privilege = next_privilege;
  146. }
  147. else
  148. {
  149. delete next_privilege;
  150. return_value = GCC_ALLOCATION_FAILURE;
  151. break;
  152. }
  153. }
  154. }
  155. else
  156. {
  157. return_value = GCC_ALLOCATION_FAILURE;
  158. break;
  159. }
  160. }
  161. }
  162. return (return_value);
  163. }
  164. /*
  165. * FreePrivilegeListPDU ()
  166. *
  167. * Public Function Description
  168. */
  169. Void PrivilegeListData::FreePrivilegeListPDU(
  170. PSetOfPrivileges set_of_privileges)
  171. {
  172. PSetOfPrivileges current_privilege = NULL;
  173. PSetOfPrivileges next_privilege = NULL;
  174. current_privilege = set_of_privileges;
  175. while (current_privilege != NULL)
  176. {
  177. next_privilege = current_privilege->next;
  178. delete current_privilege;
  179. current_privilege = next_privilege;
  180. }
  181. }
  182. /*
  183. * IsPrivilegeAvailable ()
  184. *
  185. * Public Function Description
  186. */
  187. BOOL PrivilegeListData::IsPrivilegeAvailable (
  188. ConferencePrivilegeType privilege_type)
  189. {
  190. BOOL return_value = FALSE;
  191. switch (privilege_type)
  192. {
  193. case TERMINATE_PRIVILEGE:
  194. if (Privilege_List.terminate_is_allowed )
  195. return_value = TRUE;
  196. break;
  197. case EJECT_USER_PRIVILEGE:
  198. if (Privilege_List.eject_user_is_allowed )
  199. return_value = TRUE;
  200. break;
  201. case ADD_PRIVILEGE:
  202. if (Privilege_List.add_is_allowed )
  203. return_value = TRUE;
  204. break;
  205. case LOCK_UNLOCK_PRIVILEGE:
  206. if (Privilege_List.lock_unlock_is_allowed )
  207. return_value = TRUE;
  208. break;
  209. case TRANSFER_PRIVILEGE:
  210. if (Privilege_List.transfer_is_allowed )
  211. return_value = TRUE;
  212. break;
  213. }
  214. return (return_value);
  215. }