dsalib_schema.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. * END COPYRIGHT BLOCK **/
  6. /*
  7. * Routines to parse schema LDIF
  8. *
  9. * -atom
  10. *
  11. */
  12. #ifndef __DSALIB_SCHEMA_H
  13. #define __DSALIB_SCHEMA_H__
  14. /************************************************************************
  15. BNF for attributes and objectclasses:
  16. AttributeTypeDescription = "(" whsp
  17. numericoid whsp ; AttributeType identifier
  18. [ "NAME" qdescrs ] ; name used in AttributeType
  19. [ "DESC" qdstring ] ; description
  20. [ "OBSOLETE" whsp ]
  21. [ "SUP" woid ] ; derived from this other
  22. ; AttributeType
  23. [ "EQUALITY" woid ; Matching Rule name
  24. [ "ORDERING" woid ; Matching Rule name
  25. [ "SUBSTR" woid ] ; Matching Rule name
  26. [ "SYNTAX" whsp noidlen whsp ] ; see section 4.3
  27. [ "SINGLE-VALUE" whsp ] ; default multi-valued
  28. [ "COLLECTIVE" whsp ] ; default not collective
  29. [ "NO-USER-MODIFICATION" whsp ]; default user modifiable
  30. [ "USAGE" whsp AttributeUsage ]; default user applications
  31. whsp ")"
  32. ObjectClassDescription = "(" whsp
  33. numericoid whsp ; ObjectClass identifier
  34. [ "NAME" qdescrs ]
  35. [ "DESC" qdstring ]
  36. [ "OBSOLETE" whsp ]
  37. [ "SUP" oids ] ; Superior ObjectClasses
  38. [ ( "ABSTRACT" / "STRUCTURAL" / "AUXILIARY" ) whsp ]
  39. ; default structural
  40. [ "MUST" oids ] ; AttributeTypes
  41. [ "MAY" oids ] ; AttributeTypes
  42. whsp ")"
  43. ************************************************************************/
  44. /*
  45. * ds_check_valid_oid: check to see if an oid is valid.
  46. * Oids should only contain digits and dots.
  47. *
  48. * returns 1 if valid, 0 if not
  49. */
  50. DS_EXPORT_SYMBOL int ds_check_valid_oid (char *oid);
  51. /*
  52. * ds_check_valid_name: check to see if an attribute name or an objectclass
  53. * name is valid. A valid name contains only digits, letters, or hyphens
  54. *
  55. * returns 1 if valid, 0 if not
  56. *
  57. */
  58. DS_EXPORT_SYMBOL int ds_check_valid_name (char *name);
  59. /*
  60. * ds_get_oc_desc:
  61. *
  62. * Input : pointer to string containing an ObjectClassDescription
  63. * Returns : pointer to string containing objectclass DESC
  64. *
  65. * The caller must free the return value
  66. *
  67. */
  68. DS_EXPORT_SYMBOL char * ds_get_oc_desc (char *oc);
  69. /*
  70. * ds_get_oc_name:
  71. *
  72. * Input : pointer to string containing an ObjectClassDescription
  73. * Returns: pointer to string containing objectclass name.
  74. *
  75. * The caller must free the return value
  76. *
  77. */
  78. DS_EXPORT_SYMBOL char *ds_get_oc_name (char *o);
  79. /*
  80. * ds_get_attr_name:
  81. *
  82. * Input : pointer to string containing an AttributeTypeDescription
  83. * Returns: pointer to string containing an attribute name.
  84. *
  85. * The caller must free the return value
  86. *
  87. */
  88. DS_EXPORT_SYMBOL char *ds_get_attr_name (char *a);
  89. /*
  90. * ds_get_oc_superior:
  91. *
  92. * Input : pointer to string containing an ObjectClassDescription
  93. * Returns: pointer to string containing the objectclass's SUP (superior/parent)
  94. * objectclass
  95. *
  96. * The caller must free the return value
  97. *
  98. */
  99. DS_EXPORT_SYMBOL char *ds_get_oc_superior (char *o);
  100. /*
  101. * ds_get_attr_desc:
  102. *
  103. * Input : Pointer to string containing an AttributeTypeDescription
  104. * Returns: Pointer to string containing the attribute's description
  105. *
  106. * The caller must free the return value
  107. *
  108. */
  109. DS_EXPORT_SYMBOL char *ds_get_attr_desc (char *a);
  110. /*
  111. * ds_get_attr_syntax:
  112. *
  113. * Input: Pointer to string containing an AttributeTypeDescription
  114. * Returns: Pointer to string containing the attribute's syntax
  115. *
  116. * The caller must free the return value
  117. *
  118. */
  119. DS_EXPORT_SYMBOL char *ds_get_attr_syntax (char *a);
  120. /*
  121. * ds_get_attr_oid:
  122. *
  123. * Input : Pointer to string containing an AttributeTypeDescription
  124. * Returns: Pointer to string containing an attribute's oid
  125. *
  126. * The caller must free the return value
  127. *
  128. */
  129. DS_EXPORT_SYMBOL char *ds_get_attr_oid (char *a);
  130. /*
  131. * ds_get_attr_name:
  132. *
  133. * Input : Pointer to string containing an AttributeTypeDescription
  134. * Returns: Pointer to string containing the attribute's name
  135. *
  136. * The caller must free the return value
  137. *
  138. */
  139. DS_EXPORT_SYMBOL char *ds_get_attr_name (char *a);
  140. /*
  141. * syntax_oid_to_english: convert an attribute syntax oid to something more
  142. * human readable
  143. *
  144. * Input : string containing numeric OID for a attribute syntax
  145. * Returns: Human readable string
  146. */
  147. DS_EXPORT_SYMBOL char *syntax_oid_to_english (char *oid);
  148. /* StripSpaces: Remove all leading and trailing spaces from a string */
  149. DS_EXPORT_SYMBOL char *StripSpaces (char **s);
  150. /* ds_print_required_attrs:
  151. *
  152. * input: pointer to string containing an ObjectClassDescription
  153. *
  154. * prints JavaScript array containing the required attributes of an objectclass
  155. * The array name is oc_<objectclass name>_requires
  156. */
  157. DS_EXPORT_SYMBOL void ds_print_required_attrs (char *o);
  158. /* ds_print_allowed_attrs:
  159. *
  160. * input: pointer to string containing an ObjectClassDescription
  161. *
  162. * prints JavaScript array containing the allowed attributes of an objectclass
  163. * The array name is oc_<objectclass name>_allows
  164. */
  165. DS_EXPORT_SYMBOL void ds_print_allowed_attrs (char *o);
  166. /* ds_print_oc_oid:
  167. *
  168. * input: pointer to string containing an ObjectClassDescription
  169. *
  170. * prints JavaScript string containing an objectclass oid
  171. * The variable name is oc_<objectclass name>_oid
  172. */
  173. DS_EXPORT_SYMBOL void ds_print_oc_oid (char *o);
  174. /* ds_print_oc_superior:
  175. *
  176. * input: pointer to string containing an ObjectClassDescription
  177. *
  178. * prints JavaScript string containing an objectclass superior
  179. * The variable name is oc_<objectclass name>_superior
  180. */
  181. DS_EXPORT_SYMBOL void ds_print_oc_superior (char *o);
  182. /* underscore2hyphen:
  183. * transform underscores to hyphens in a string
  184. */
  185. DS_EXPORT_SYMBOL char *underscore2hyphen (char *src);
  186. /* hyphen2underscore:
  187. * transform hyphens to underscores in a string
  188. */
  189. DS_EXPORT_SYMBOL char *hyphen2underscore (char *src);
  190. #endif /* __DSALIB_SCHEMA_H__ */