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.

403 lines
11 KiB

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