dsalib_schema.h 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. /** BEGIN COPYRIGHT BLOCK
  2. * This Program is free software; you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation; version 2 of the License.
  5. *
  6. * This Program is distributed in the hope that it will be useful, but WITHOUT
  7. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  9. *
  10. * You should have received a copy of the GNU General Public License along with
  11. * this Program; if not, write to the Free Software Foundation, Inc., 59 Temple
  12. * Place, Suite 330, Boston, MA 02111-1307 USA.
  13. *
  14. * In addition, as a special exception, Red Hat, Inc. gives You the additional
  15. * right to link the code of this Program with code not covered under the GNU
  16. * General Public License ("Non-GPL Code") and to distribute linked combinations
  17. * including the two, subject to the limitations in this paragraph. Non-GPL Code
  18. * permitted under this exception must only link to the code of this Program
  19. * through those well defined interfaces identified in the file named EXCEPTION
  20. * found in the source code files (the "Approved Interfaces"). The files of
  21. * Non-GPL Code may instantiate templates or use macros or inline functions from
  22. * the Approved Interfaces without causing the resulting work to be covered by
  23. * the GNU General Public License. Only Red Hat, Inc. may make changes or
  24. * additions to the list of Approved Interfaces. You must obey the GNU General
  25. * Public License in all respects for all of the Program code and other code used
  26. * in conjunction with the Program except the Non-GPL Code covered by this
  27. * exception. If you modify this file, you may extend this exception to your
  28. * version of the file, but you are not obligated to do so. If you do not wish to
  29. * provide this exception without modification, you must delete this exception
  30. * statement from your version and license this file solely under the GPL without
  31. * exception.
  32. *
  33. *
  34. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  35. * Copyright (C) 2005 Red Hat, Inc.
  36. * All rights reserved.
  37. * END COPYRIGHT BLOCK **/
  38. /*
  39. * Routines to parse schema LDIF
  40. *
  41. * -atom
  42. *
  43. */
  44. #ifndef __DSALIB_SCHEMA_H
  45. #define __DSALIB_SCHEMA_H__
  46. /************************************************************************
  47. BNF for attributes and objectclasses:
  48. AttributeTypeDescription = "(" whsp
  49. numericoid whsp ; AttributeType identifier
  50. [ "NAME" qdescrs ] ; name used in AttributeType
  51. [ "DESC" qdstring ] ; description
  52. [ "OBSOLETE" whsp ]
  53. [ "SUP" woid ] ; derived from this other
  54. ; AttributeType
  55. [ "EQUALITY" woid ; Matching Rule name
  56. [ "ORDERING" woid ; Matching Rule name
  57. [ "SUBSTR" woid ] ; Matching Rule name
  58. [ "SYNTAX" whsp noidlen whsp ] ; see section 4.3
  59. [ "SINGLE-VALUE" whsp ] ; default multi-valued
  60. [ "COLLECTIVE" whsp ] ; default not collective
  61. [ "NO-USER-MODIFICATION" whsp ]; default user modifiable
  62. [ "USAGE" whsp AttributeUsage ]; default user applications
  63. whsp ")"
  64. ObjectClassDescription = "(" whsp
  65. numericoid whsp ; ObjectClass identifier
  66. [ "NAME" qdescrs ]
  67. [ "DESC" qdstring ]
  68. [ "OBSOLETE" whsp ]
  69. [ "SUP" oids ] ; Superior ObjectClasses
  70. [ ( "ABSTRACT" / "STRUCTURAL" / "AUXILIARY" ) whsp ]
  71. ; default structural
  72. [ "MUST" oids ] ; AttributeTypes
  73. [ "MAY" oids ] ; AttributeTypes
  74. whsp ")"
  75. ************************************************************************/
  76. /*
  77. * ds_check_valid_oid: check to see if an oid is valid.
  78. * Oids should only contain digits and dots.
  79. *
  80. * returns 1 if valid, 0 if not
  81. */
  82. DS_EXPORT_SYMBOL int ds_check_valid_oid (char *oid);
  83. /*
  84. * ds_check_valid_name: check to see if an attribute name or an objectclass
  85. * name is valid. A valid name contains only digits, letters, or hyphens
  86. *
  87. * returns 1 if valid, 0 if not
  88. *
  89. */
  90. DS_EXPORT_SYMBOL int ds_check_valid_name (char *name);
  91. /*
  92. * ds_get_oc_desc:
  93. *
  94. * Input : pointer to string containing an ObjectClassDescription
  95. * Returns : pointer to string containing objectclass DESC
  96. *
  97. * The caller must free the return value
  98. *
  99. */
  100. DS_EXPORT_SYMBOL char * ds_get_oc_desc (char *oc);
  101. /*
  102. * ds_get_oc_name:
  103. *
  104. * Input : pointer to string containing an ObjectClassDescription
  105. * Returns: pointer to string containing objectclass name.
  106. *
  107. * The caller must free the return value
  108. *
  109. */
  110. DS_EXPORT_SYMBOL char *ds_get_oc_name (char *o);
  111. /*
  112. * ds_get_attr_name:
  113. *
  114. * Input : pointer to string containing an AttributeTypeDescription
  115. * Returns: pointer to string containing an attribute name.
  116. *
  117. * The caller must free the return value
  118. *
  119. */
  120. DS_EXPORT_SYMBOL char *ds_get_attr_name (char *a);
  121. /*
  122. * ds_get_oc_superior:
  123. *
  124. * Input : pointer to string containing an ObjectClassDescription
  125. * Returns: pointer to string containing the objectclass's SUP (superior/parent)
  126. * objectclass
  127. *
  128. * The caller must free the return value
  129. *
  130. */
  131. DS_EXPORT_SYMBOL char *ds_get_oc_superior (char *o);
  132. /*
  133. * ds_get_attr_desc:
  134. *
  135. * Input : Pointer to string containing an AttributeTypeDescription
  136. * Returns: Pointer to string containing the attribute's description
  137. *
  138. * The caller must free the return value
  139. *
  140. */
  141. DS_EXPORT_SYMBOL char *ds_get_attr_desc (char *a);
  142. /*
  143. * ds_get_attr_syntax:
  144. *
  145. * Input: Pointer to string containing an AttributeTypeDescription
  146. * Returns: Pointer to string containing the attribute's syntax
  147. *
  148. * The caller must free the return value
  149. *
  150. */
  151. DS_EXPORT_SYMBOL char *ds_get_attr_syntax (char *a);
  152. /*
  153. * ds_get_attr_oid:
  154. *
  155. * Input : Pointer to string containing an AttributeTypeDescription
  156. * Returns: Pointer to string containing an attribute's oid
  157. *
  158. * The caller must free the return value
  159. *
  160. */
  161. DS_EXPORT_SYMBOL char *ds_get_attr_oid (char *a);
  162. /*
  163. * ds_get_attr_name:
  164. *
  165. * Input : Pointer to string containing an AttributeTypeDescription
  166. * Returns: Pointer to string containing the attribute's name
  167. *
  168. * The caller must free the return value
  169. *
  170. */
  171. DS_EXPORT_SYMBOL char *ds_get_attr_name (char *a);
  172. /*
  173. * syntax_oid_to_english: convert an attribute syntax oid to something more
  174. * human readable
  175. *
  176. * Input : string containing numeric OID for a attribute syntax
  177. * Returns: Human readable string
  178. */
  179. DS_EXPORT_SYMBOL char *syntax_oid_to_english (char *oid);
  180. /* StripSpaces: Remove all leading and trailing spaces from a string */
  181. DS_EXPORT_SYMBOL char *StripSpaces (char **s);
  182. /* ds_print_required_attrs:
  183. *
  184. * input: pointer to string containing an ObjectClassDescription
  185. *
  186. * prints JavaScript array containing the required attributes of an objectclass
  187. * The array name is oc_<objectclass name>_requires
  188. */
  189. DS_EXPORT_SYMBOL void ds_print_required_attrs (char *o);
  190. /* ds_print_allowed_attrs:
  191. *
  192. * input: pointer to string containing an ObjectClassDescription
  193. *
  194. * prints JavaScript array containing the allowed attributes of an objectclass
  195. * The array name is oc_<objectclass name>_allows
  196. */
  197. DS_EXPORT_SYMBOL void ds_print_allowed_attrs (char *o);
  198. /* ds_print_oc_oid:
  199. *
  200. * input: pointer to string containing an ObjectClassDescription
  201. *
  202. * prints JavaScript string containing an objectclass oid
  203. * The variable name is oc_<objectclass name>_oid
  204. */
  205. DS_EXPORT_SYMBOL void ds_print_oc_oid (char *o);
  206. /* ds_print_oc_superior:
  207. *
  208. * input: pointer to string containing an ObjectClassDescription
  209. *
  210. * prints JavaScript string containing an objectclass superior
  211. * The variable name is oc_<objectclass name>_superior
  212. */
  213. DS_EXPORT_SYMBOL void ds_print_oc_superior (char *o);
  214. /* underscore2hyphen:
  215. * transform underscores to hyphens in a string
  216. */
  217. DS_EXPORT_SYMBOL char *underscore2hyphen (char *src);
  218. /* hyphen2underscore:
  219. * transform hyphens to underscores in a string
  220. */
  221. DS_EXPORT_SYMBOL char *hyphen2underscore (char *src);
  222. #endif /* __DSALIB_SCHEMA_H__ */