plist_pvt.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. # include <config.h>
  11. #endif
  12. #ifndef _PLIST_PVT_H
  13. #define _PLIST_PVT_H
  14. /*
  15. * FILE: plist_pvt.h
  16. *
  17. * DESCRIPTION:
  18. *
  19. * This file contains private definitions for the property list
  20. * utility implementation.
  21. */
  22. #include "base/pool.h"
  23. /* Forward declarations */
  24. typedef struct PLValueStruct_s PLValueStruct_t;
  25. typedef struct PLSymbol_s PLSymbol_t;
  26. typedef struct PLSymbolTable_s PLSymbolTable_t;
  27. typedef struct PListStruct_s PListStruct_t;
  28. /*
  29. * TYPE: PLValueStruct_t
  30. *
  31. * DESCRIPTION:
  32. *
  33. * This type represents a property value. It is dynamically
  34. * allocated when a new property is added to a property list.
  35. * It contains a reference to a property list that contains
  36. * information about the property value, and a reference to
  37. * the property value data.
  38. */
  39. #include <stddef.h>
  40. struct PLValueStruct_s {
  41. pb_entry pv_pbentry; /* used for pblock compatibility */
  42. pb_param pv_pbparam; /* property name and value pointers */
  43. PLValueStruct_t *pv_next; /* property name hash collision link */
  44. PListStruct_t *pv_type; /* property value type reference */
  45. int pv_pi; /* property index */
  46. int pv_flags; /* bit flags */
  47. };
  48. #define pv_name pv_pbparam.name
  49. #define pv_value pv_pbparam.value
  50. /* pv_flags definitions */
  51. #define PVF_MALLOC 0x1 /* allocated via MALLOC */
  52. /* Offset to pv_pbparam in PLValueStruct_t */
  53. #define PVPBOFFSET offsetof(struct PLValueStruct_s,pv_pbparam)
  54. /* Convert pb_param pointer to PLValueStruct_t pointer */
  55. #define PATOPV(p) ((PLValueStruct_t *)((char *)(p) - PVPBOFFSET))
  56. /*
  57. * TYPE: PLSymbolTable_t
  58. *
  59. * DESCRIPTION:
  60. *
  61. * This type represents a symbol table that maps property names
  62. * to properties. It is dynamically allocated the first time a
  63. * property is named.
  64. */
  65. #define PLSTSIZES {7, 19, 31, 67, 123, 257, 513}
  66. #define PLMAXSIZENDX (sizeof(plistHashSizes)/sizeof(plistHashSizes[0]))
  67. struct PLSymbolTable_s {
  68. int pt_sizendx; /* pt_hash size, as an index in PLSTSIZES */
  69. int pt_nsyms; /* number of symbols in table */
  70. PLValueStruct_t *pt_hash[1];/* variable-length array */
  71. };
  72. /*
  73. * TYPE: PListStruct_t
  74. *
  75. * DESCRIPTION:
  76. *
  77. * This type represents the top-level of a property list structure.
  78. * It is dynamically allocated when a property list is created, and
  79. * freed when the property list is destroyed. It references a
  80. * dynamically allocated array of pointers to property value
  81. * structures (PLValueStruct_t).
  82. */
  83. #define PLIST_DEFSIZE 8 /* default initial entries in pl_ppval */
  84. #define PLIST_DEFGROW 16 /* default incremental entries for pl_ppval */
  85. struct PListStruct_s {
  86. pblock pl_pb; /* pblock subset of property list head */
  87. PLSymbolTable_t *pl_symtab; /* property name to index symbol table */
  88. pool_handle_t *pl_mempool; /* associated memory pool handle */
  89. int pl_maxprop; /* maximum number of properties */
  90. int pl_resvpi; /* number of reserved property indices */
  91. int pl_lastpi; /* last allocated property index */
  92. int pl_cursize; /* current size of pl_ppval in entries */
  93. };
  94. #define pl_initpi pl_pb.hsize /* number of pl_ppval entries initialized */
  95. #define pl_ppval pl_pb.ht /* pointer to array of value pointers */
  96. /* Convert pblock pointer to PListStruct_t pointer */
  97. #define PBTOPL(p) ((PListStruct_t *)(p))
  98. #define PLSIZENDX(i) (plistHashSizes[i])
  99. #define PLHASHSIZE(i) (sizeof(PLSymbolTable_t) + \
  100. (PLSIZENDX(i) - 1)*sizeof(PLValueStruct_t *))
  101. extern int plistHashSizes[7];
  102. extern int PListHashName(PLSymbolTable_t *symtab, const char *pname);
  103. #endif /* _PLIST_PVT_H */