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.

69 lines
1.9 KiB

  1. /*
  2. * $Id: handle.hpp,v 1.5 1995/10/24 14:06:26 sjl Exp $
  3. *
  4. * Copyright (c) Microsoft Corp. 1993-1997
  5. * Version 1.1
  6. *
  7. * All rights reserved.
  8. *
  9. * This file contains private, unpublished information and may not be
  10. * copied in part or in whole without express permission of
  11. * Microsoft Corp.
  12. *
  13. */
  14. #ifndef _HANDLE_H_
  15. #define _HANDLE_H_
  16. #include "lists.hpp"
  17. typedef DWORD RLDDIHandle;
  18. typedef void (*RLDDIHandleCallback)(void* lpArg);
  19. typedef struct _RLDDIHandleEntry
  20. {
  21. LIST_MEMBER(_RLDDIHandleEntry) link;
  22. DWORD hArg;
  23. RLDDIHandleCallback lpFunc;
  24. void* lpArg;
  25. } RLDDIHandleEntry;
  26. typedef struct _handle_chunk
  27. {
  28. LIST_MEMBER(_handle_chunk) link;
  29. } handle_chunk;
  30. typedef struct _handle_pool
  31. {
  32. LIST_ROOT(_h, _RLDDIHandleEntry) free;
  33. RLDDIHandleEntry* unallocated;
  34. int num_unallocated;
  35. LIST_ROOT(_ch, _handle_chunk) chunks;
  36. } handle_pool;
  37. #define HANDLE_MAX ((1 << 16) - 1)
  38. #define HANDLE_HASHNUM 251
  39. #define HANDLE_HASH(x) (x % HANDLE_HASHNUM)
  40. typedef struct _RLDDIHandleTable
  41. {
  42. LIST_ROOT(_rthe, _RLDDIHandleEntry) hash[HANDLE_HASHNUM];
  43. handle_pool pool;
  44. int next;
  45. } RLDDIHandleTable;
  46. RLDDIHandleTable* RLDDICreateHandleTable(void);
  47. void RLDDIDestroyHandleTable(RLDDIHandleTable*);
  48. RLDDIHandle RLDDIHandleTableCreateHandle(RLDDIHandleTable* table,
  49. void* lpArg,
  50. RLDDIHandleCallback lpFunc);
  51. void* RLDDIHandleTableFindHandle(RLDDIHandleTable* table,
  52. RLDDIHandle hArg);
  53. BOOL RLDDIHandleTableReplaceHandle(RLDDIHandleTable* table,
  54. RLDDIHandle hArg,
  55. LPVOID lpArg);
  56. void RLDDIHandleTableDeleteHandle(RLDDIHandleTable* table,
  57. RLDDIHandle hArg);
  58. #endif /* _HANDLE_H_ */