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.

371 lines
11 KiB

  1. /*
  2. * userdata.h
  3. *
  4. * Copyright (c) 1995 by DataBeam Corporation, Lexington, KY
  5. *
  6. * Abstract:
  7. * This is the interface file for the class CUserDataListContainer. CUserDataListContainer
  8. * objects are used to maintain user data elements. A user data element
  9. * consists of an Object Key and an optional octet string. The Object
  10. * Key data is maintained internally by this class by using an
  11. * CObjectKeyContainer container. The optional octet string data is maintained
  12. * internally through the use of a Rogue Wave string container.
  13. *
  14. * Caveats:
  15. * None.
  16. *
  17. * Author:
  18. * blp/jbo
  19. */
  20. #ifndef _USER_DATA_LIST__
  21. #define _USER_DATA_LIST__
  22. #include "objkey.h"
  23. /*
  24. * This is the typedef for the structure used to maintain the list of user
  25. * data internally.
  26. */
  27. typedef struct USER_DATA
  28. {
  29. ~USER_DATA(void);
  30. CObjectKeyContainer *key;
  31. LPOSTR poszOctetString;
  32. }
  33. USER_DATA;
  34. /*
  35. * These are the typedefs for the Rogue Wave list which is used to hold the
  36. * USER_DATA structures and the iterator for the list.
  37. */
  38. class CUserDataList : public CList
  39. {
  40. DEFINE_CLIST(CUserDataList, USER_DATA*)
  41. };
  42. /*
  43. * Class definition:
  44. */
  45. class CUserDataListContainer : public CRefCount
  46. {
  47. public:
  48. CUserDataListContainer(UINT cMembers, PGCCUserData *, PGCCError);
  49. CUserDataListContainer(CUserDataListContainer *, PGCCError);
  50. CUserDataListContainer(PSetOfUserData, PGCCError);
  51. ~CUserDataListContainer(void);
  52. UINT LockUserDataList(void);
  53. void UnLockUserDataList(void);
  54. UINT GetUserDataList(USHORT *pcMembers, PGCCUserData**, LPBYTE pMemory);
  55. UINT GetUserDataList(UINT *pcMembers, PGCCUserData** pppUserData, LPBYTE pMemory)
  56. {
  57. *pcMembers = 0;
  58. return GetUserDataList((USHORT *) pcMembers, pppUserData, pMemory);
  59. }
  60. GCCError GetUserDataPDU(PSetOfUserData *);
  61. void FreeUserDataListPDU(void);
  62. protected:
  63. CUserDataList m_UserDataItemList;
  64. UINT m_cbDataSize;
  65. PSetOfUserData m_pSetOfUserDataPDU;
  66. private:
  67. GCCError CopyUserDataList(UINT cMembers, PGCCUserData *);
  68. GCCError UnPackUserDataFromPDU(PSetOfUserData);
  69. GCCError ConvertPDUDataToInternal(PSetOfUserData);
  70. GCCError ConvertUserDataInfoToPDUUserData(USER_DATA *, PSetOfUserData);
  71. };
  72. /*
  73. * Comments explaining the public and protected class member functions
  74. */
  75. /*
  76. * CUserDataListContainer ( UINT number_of_members,
  77. * PGCCUserData * user_data_list,
  78. * PGCCError return_value);
  79. *
  80. * Public member function of CUserDataListContainer.
  81. *
  82. * Function Description:
  83. * This CUserDataListContainer constructor is used to create a CUserDataListContainer object
  84. * from "API" data. The constructor immediately copies the user data
  85. * passed in as a list of "GCCUserData" structures into it's internal form
  86. * where a Rogue Wave container holds the data in the form of
  87. * USER_DATA structures.
  88. *
  89. * Formal Parameters:
  90. * number_of_members (i) The number of elements in the user data list.
  91. * user_datalist (i) The list holding the user data to store.
  92. * return_value (o) The output parameter used to indicate errors.
  93. *
  94. * Return Value:
  95. * GCC_NO_ERROR - No error.
  96. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  97. * "new" operator.
  98. * GCC_BAD_USER_DATA - The user data passed in contained
  99. * an invalid object key.
  100. *
  101. * Side Effects:
  102. * None.
  103. *
  104. * Caveats:
  105. * None.
  106. */
  107. /*
  108. * CUserDataListContainer ( PSetOfUserData set_of_user_data,
  109. * PGCCError return_value);
  110. *
  111. * Public member function of CUserDataListContainer.
  112. *
  113. * Function Description:
  114. * This CUserDataListContainer constructor is used to create a CUserDataListContainer object
  115. * from data passed in as a "PDU" SetOfUserData structure. The user
  116. * data is copied into it's internal form where a Rogue Wave container
  117. * holds the data in the form of USER_DATA structures.
  118. *
  119. * Formal Parameters:
  120. * set_of_user_data (i) The structure holding the "PDU" user data
  121. * to store.
  122. * return_value (o) The output parameter used to indicate errors.
  123. *
  124. * Return Value:
  125. * GCC_NO_ERROR - No error.
  126. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  127. * "new" operator or else an
  128. * invalid object key PDU was
  129. * received.
  130. *
  131. * Side Effects:
  132. * None.
  133. *
  134. * Caveats:
  135. * None.
  136. */
  137. /*
  138. * CUserDataListContainer(CUserDataListContainer *user_data, PGCCError return_value);
  139. *
  140. * Public member function of CUserDataListContainer.
  141. *
  142. * Function Description:
  143. * This is the copy constructor for the CUserDataListContainer class which takes
  144. * as input another CUserDataListContainer object.
  145. *
  146. * Formal Parameters:
  147. * user_data (i) The CUserDataListContainer object to copy.
  148. * return_value (o) The output parameter used to indicate errors.
  149. *
  150. * Return Value:
  151. * GCC_NO_ERROR - No error.
  152. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  153. * "new" operator.
  154. * GCC_BAD_OBJECT_KEY - An invalid CUserDataListContainer passed in.
  155. *
  156. * Side Effects:
  157. * None.
  158. *
  159. * Caveats:
  160. * None.
  161. */
  162. /*
  163. * ~CUserDataListContainer();
  164. *
  165. * Public member function of CUserDataListContainer.
  166. *
  167. * Function Description:
  168. * This is the destructor for the CUserDataListContainer class. It is used to
  169. * clean up any memory allocated during the life of this object.
  170. *
  171. * Formal Parameters:
  172. * None.
  173. *
  174. * Return Value:
  175. * None.
  176. *
  177. * Side Effects:
  178. * None.
  179. *
  180. * Caveats:
  181. * None.
  182. */
  183. /*
  184. * UINT LockUserDataList ();
  185. *
  186. * Public member function of CUserDataListContainer.
  187. *
  188. * Function Description:
  189. * This routine is used to "lock" the "API" data for this object. This
  190. * results in the lock count for this object being incremented. When the
  191. * lock count transitions from 0 to 1, a calculation is made to determine
  192. * how much memory will be needed to hold any "API" data which will
  193. * be referenced by, but not held in, the GCCUserData structure
  194. * which is filled in on a call to GetUserDataList. This is the
  195. * value returned by this routine in order to allow the calling object to
  196. * allocate that amount of memory in preparation for the call to
  197. * GetUserDataList.
  198. *
  199. * Formal Parameters:
  200. * None.
  201. *
  202. * Return Value:
  203. * The amount of memory which will be needed to hold "API" data
  204. * which is referenced by, but not held in, the GCCUserData structure
  205. * provided as an output parameter to the GetUserDataList call.
  206. *
  207. * Side Effects:
  208. * The internal lock count is incremented.
  209. *
  210. * Caveats:
  211. * The internal lock count is used in conjuction with an internal "free"
  212. * flag as a mechanism for ensuring that this object remains in existance
  213. * until all interested parties are through with it. The object remains
  214. * valid (unless explicity deleted) until the lock count is zero and the
  215. * "free" flag is set through a call to FreeUserDataList. This allows
  216. * other objects to lock this object and be sure that it remains valid
  217. * until they call UnLock which will decrement the internal lock count. A
  218. * typical usage scenerio for this object would be: A CUserDataListContainer
  219. * object is constructed and then passed off to any interested parties
  220. * through a function call. On return from the function call, the
  221. * FreeUserDataList call is made which will set the internal "free"
  222. * flag. If no other parties have locked the object with a Lock call,
  223. * then the CUserDataListContainer object will automatically delete itself when
  224. * the FreeUserDataList call is made. If, however, any number of
  225. * other parties has locked the object, it will remain in existence until
  226. * each of them has unlocked the object through a call to UnLock.
  227. */
  228. /*
  229. * UINT GetUserDataList ( USHORT *number_of_members,
  230. * PGCCUserData ** user_data_list,
  231. * LPSTR memory);
  232. *
  233. * Public member function of CUserDataListContainer.
  234. *
  235. * Function Description:
  236. * This routine is used to retrieve the user data from the
  237. * CUserDataListContainer object in the "API" form of a GCCUserData list.
  238. *
  239. * Formal Parameters:
  240. * number_of_members (o) The number of elements in the user data list.
  241. * user_data (o) The list of GCCUserData structures to fill in.
  242. * memory (o) The memory used to hold any data referenced by,
  243. * but not held in, the output structures.
  244. *
  245. * Return Value:
  246. * The amount of data, if any, written into the bulk memory block provided.
  247. *
  248. * Side Effects:
  249. * None.
  250. *
  251. * Caveats:
  252. * None.
  253. */
  254. /*
  255. * void UnLockUserDataList ();
  256. *
  257. * Public member function of CUserDataListContainer.
  258. *
  259. * Function Description:
  260. * This routine is used to "unlock" the "API" data for this object. This
  261. * results in the lock count for this object being decremented. When the
  262. * lock count transitions from 1 to 0, a check is made to determine
  263. * whether the object has been freed through a call to
  264. * FreeUserDataList. If so, the object will automatically delete
  265. * itself.
  266. *
  267. * Formal Parameters:
  268. * None.
  269. *
  270. * Return Value:
  271. * None.
  272. *
  273. * Side Effects:
  274. * The internal lock count is decremented.
  275. *
  276. * Caveats:
  277. * It is the responsibility of any party which locks a CUserDataListContainer
  278. * object by calling Lock to also unlock the object with a call to UnLock.
  279. * If the party calling UnLock did not construct the CUserDataListContainer
  280. * object, it should assume the object to be invalid thereafter.
  281. */
  282. /*
  283. * void FreeUserDataList ();
  284. *
  285. * Public member function of CUserDataListContainer.
  286. *
  287. * Function Description:
  288. * This routine is used to "free" the "API" data for this object. This
  289. * will result in the automatic deletion of this object if the object is
  290. * not in the "locked" state.
  291. *
  292. * Formal Parameters:
  293. * None.
  294. *
  295. * Return Value:
  296. * None.
  297. *
  298. * Side Effects:
  299. * The internal "free" flag is set.
  300. *
  301. * Caveats:
  302. * This object should be assumed invalid after a call to
  303. * FreeUserDataList has been made.
  304. */
  305. /*
  306. * GCCError GetUserDataPDU ( PSetOfUserData * set_of_user_data);
  307. *
  308. * Public member function of CUserDataListContainer.
  309. *
  310. * Function Description:
  311. * This routine is used to retrieve the user data from the
  312. * CUserDataListContainer object in the "PDU" form of a SetOfUserData.
  313. *
  314. * Formal Parameters:
  315. * set_of_user_data (o) The SetOfUserData structure to fill in.
  316. *
  317. * Return Value:
  318. * GCC_NO_ERROR - No error.
  319. * GCC_ALLOCATION_FAILURE - Error creating an object using the
  320. * "new" operator or else an
  321. * internal pointer has been
  322. * corrupted.
  323. *
  324. * Side Effects:
  325. * None.
  326. *
  327. * Caveats:
  328. * None.
  329. */
  330. /*
  331. * void FreeUserDataListPDU ();
  332. *
  333. * Public member function of CUserDataListContainer.
  334. *
  335. * Function Description:
  336. * This routine is used to "free" the "PDU" data allocated for this object
  337. * which is held internally in a SetOfUserData structure.
  338. *
  339. * Formal Parameters:
  340. * None.
  341. *
  342. * Return Value:
  343. * None.
  344. *
  345. * Side Effects:
  346. * The internal "free" flag is set.
  347. *
  348. * Caveats:
  349. * This object should be assumed invalid after a call to
  350. * FreeUserDataListPDU has been made.
  351. */
  352. #endif