ldap_schema.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. /* $OpenLDAP$ */
  2. /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  3. *
  4. * Copyright 1998-2022 The OpenLDAP Foundation.
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted only as authorized by the OpenLDAP
  9. * Public License.
  10. *
  11. * A copy of this license is available in file LICENSE in the
  12. * top-level directory of the distribution or, alternatively, at
  13. * <http://www.OpenLDAP.org/license.html>.
  14. */
  15. /* ldap-schema.h - Header for basic schema handling functions that can be
  16. * used by both clients and servers.
  17. * these routines should be renamed ldap_x_...
  18. */
  19. #ifndef _LDAP_SCHEMA_H
  20. #define _LDAP_SCHEMA_H 1
  21. #include <ldap_cdefs.h>
  22. LDAP_BEGIN_DECL
  23. /* Codes for parsing errors */
  24. #define LDAP_SCHERR_OUTOFMEM 1
  25. #define LDAP_SCHERR_UNEXPTOKEN 2
  26. #define LDAP_SCHERR_NOLEFTPAREN 3
  27. #define LDAP_SCHERR_NORIGHTPAREN 4
  28. #define LDAP_SCHERR_NODIGIT 5
  29. #define LDAP_SCHERR_BADNAME 6
  30. #define LDAP_SCHERR_BADDESC 7
  31. #define LDAP_SCHERR_BADSUP 8
  32. #define LDAP_SCHERR_DUPOPT 9
  33. #define LDAP_SCHERR_EMPTY 10
  34. #define LDAP_SCHERR_MISSING 11
  35. #define LDAP_SCHERR_OUT_OF_ORDER 12
  36. typedef struct ldap_schema_extension_item {
  37. char *lsei_name;
  38. char **lsei_values;
  39. } LDAPSchemaExtensionItem;
  40. typedef struct ldap_syntax {
  41. char *syn_oid; /* REQUIRED */
  42. char **syn_names; /* OPTIONAL */
  43. char *syn_desc; /* OPTIONAL */
  44. LDAPSchemaExtensionItem **syn_extensions; /* OPTIONAL */
  45. } LDAPSyntax;
  46. typedef struct ldap_matchingrule {
  47. char *mr_oid; /* REQUIRED */
  48. char **mr_names; /* OPTIONAL */
  49. char *mr_desc; /* OPTIONAL */
  50. int mr_obsolete; /* OPTIONAL */
  51. char *mr_syntax_oid; /* REQUIRED */
  52. LDAPSchemaExtensionItem **mr_extensions; /* OPTIONAL */
  53. } LDAPMatchingRule;
  54. typedef struct ldap_matchingruleuse {
  55. char *mru_oid; /* REQUIRED */
  56. char **mru_names; /* OPTIONAL */
  57. char *mru_desc; /* OPTIONAL */
  58. int mru_obsolete; /* OPTIONAL */
  59. char **mru_applies_oids; /* REQUIRED */
  60. LDAPSchemaExtensionItem **mru_extensions; /* OPTIONAL */
  61. } LDAPMatchingRuleUse;
  62. typedef struct ldap_attributetype {
  63. char *at_oid; /* REQUIRED */
  64. char **at_names; /* OPTIONAL */
  65. char *at_desc; /* OPTIONAL */
  66. int at_obsolete; /* 0=no, 1=yes */
  67. char *at_sup_oid; /* OPTIONAL */
  68. char *at_equality_oid; /* OPTIONAL */
  69. char *at_ordering_oid; /* OPTIONAL */
  70. char *at_substr_oid; /* OPTIONAL */
  71. char *at_syntax_oid; /* OPTIONAL */
  72. int at_syntax_len; /* OPTIONAL */
  73. int at_single_value; /* 0=no, 1=yes */
  74. int at_collective; /* 0=no, 1=yes */
  75. int at_no_user_mod; /* 0=no, 1=yes */
  76. int at_usage; /* 0=userApplications, 1=directoryOperation,
  77. 2=distributedOperation, 3=dSAOperation */
  78. LDAPSchemaExtensionItem **at_extensions; /* OPTIONAL */
  79. } LDAPAttributeType;
  80. typedef struct ldap_objectclass {
  81. char *oc_oid; /* REQUIRED */
  82. char **oc_names; /* OPTIONAL */
  83. char *oc_desc; /* OPTIONAL */
  84. int oc_obsolete; /* 0=no, 1=yes */
  85. char **oc_sup_oids; /* OPTIONAL */
  86. int oc_kind; /* 0=ABSTRACT, 1=STRUCTURAL, 2=AUXILIARY */
  87. char **oc_at_oids_must; /* OPTIONAL */
  88. char **oc_at_oids_may; /* OPTIONAL */
  89. LDAPSchemaExtensionItem **oc_extensions; /* OPTIONAL */
  90. } LDAPObjectClass;
  91. typedef struct ldap_contentrule {
  92. char *cr_oid; /* REQUIRED */
  93. char **cr_names; /* OPTIONAL */
  94. char *cr_desc; /* OPTIONAL */
  95. char **cr_sup_oids; /* OPTIONAL */
  96. int cr_obsolete; /* 0=no, 1=yes */
  97. char **cr_oc_oids_aux; /* OPTIONAL */
  98. char **cr_at_oids_must; /* OPTIONAL */
  99. char **cr_at_oids_may; /* OPTIONAL */
  100. char **cr_at_oids_not; /* OPTIONAL */
  101. LDAPSchemaExtensionItem **cr_extensions; /* OPTIONAL */
  102. } LDAPContentRule;
  103. typedef struct ldap_nameform {
  104. char *nf_oid; /* REQUIRED */
  105. char **nf_names; /* OPTIONAL */
  106. char *nf_desc; /* OPTIONAL */
  107. int nf_obsolete; /* 0=no, 1=yes */
  108. char *nf_objectclass; /* REQUIRED */
  109. char **nf_at_oids_must; /* REQUIRED */
  110. char **nf_at_oids_may; /* OPTIONAL */
  111. LDAPSchemaExtensionItem **nf_extensions; /* OPTIONAL */
  112. } LDAPNameForm;
  113. typedef struct ldap_structurerule {
  114. int sr_ruleid; /* REQUIRED */
  115. char **sr_names; /* OPTIONAL */
  116. char *sr_desc; /* OPTIONAL */
  117. int sr_obsolete; /* 0=no, 1=yes */
  118. char *sr_nameform; /* REQUIRED */
  119. int sr_nsup_ruleids;/* number of sr_sup_ruleids */
  120. int *sr_sup_ruleids;/* OPTIONAL */
  121. LDAPSchemaExtensionItem **sr_extensions; /* OPTIONAL */
  122. } LDAPStructureRule;
  123. /*
  124. * Misc macros
  125. */
  126. #define LDAP_SCHEMA_NO 0
  127. #define LDAP_SCHEMA_YES 1
  128. #define LDAP_SCHEMA_USER_APPLICATIONS 0
  129. #define LDAP_SCHEMA_DIRECTORY_OPERATION 1
  130. #define LDAP_SCHEMA_DISTRIBUTED_OPERATION 2
  131. #define LDAP_SCHEMA_DSA_OPERATION 3
  132. #define LDAP_SCHEMA_ABSTRACT 0
  133. #define LDAP_SCHEMA_STRUCTURAL 1
  134. #define LDAP_SCHEMA_AUXILIARY 2
  135. /*
  136. * Flags that control how liberal the parsing routines are.
  137. */
  138. #define LDAP_SCHEMA_ALLOW_NONE 0x00U /* Strict parsing */
  139. #define LDAP_SCHEMA_ALLOW_NO_OID 0x01U /* Allow missing oid */
  140. #define LDAP_SCHEMA_ALLOW_QUOTED 0x02U /* Allow bogus extra quotes */
  141. #define LDAP_SCHEMA_ALLOW_DESCR 0x04U /* Allow descr instead of OID */
  142. #define LDAP_SCHEMA_ALLOW_DESCR_PREFIX 0x08U /* Allow descr as OID prefix */
  143. #define LDAP_SCHEMA_ALLOW_OID_MACRO 0x10U /* Allow OID macros in slapd */
  144. #define LDAP_SCHEMA_ALLOW_OUT_OF_ORDER_FIELDS 0x20U /* Allow fields in most any order */
  145. #define LDAP_SCHEMA_ALLOW_ALL 0x3fU /* Be very liberal in parsing */
  146. #define LDAP_SCHEMA_SKIP 0x80U /* Don't malloc any result */
  147. LDAP_F( LDAP_CONST char * )
  148. ldap_syntax2name LDAP_P((
  149. LDAPSyntax * syn ));
  150. LDAP_F( LDAP_CONST char * )
  151. ldap_matchingrule2name LDAP_P((
  152. LDAPMatchingRule * mr ));
  153. LDAP_F( LDAP_CONST char * )
  154. ldap_matchingruleuse2name LDAP_P((
  155. LDAPMatchingRuleUse * mru ));
  156. LDAP_F( LDAP_CONST char * )
  157. ldap_attributetype2name LDAP_P((
  158. LDAPAttributeType * at ));
  159. LDAP_F( LDAP_CONST char * )
  160. ldap_objectclass2name LDAP_P((
  161. LDAPObjectClass * oc ));
  162. LDAP_F( LDAP_CONST char * )
  163. ldap_contentrule2name LDAP_P((
  164. LDAPContentRule * cr ));
  165. LDAP_F( LDAP_CONST char * )
  166. ldap_nameform2name LDAP_P((
  167. LDAPNameForm * nf ));
  168. LDAP_F( LDAP_CONST char * )
  169. ldap_structurerule2name LDAP_P((
  170. LDAPStructureRule * sr ));
  171. LDAP_F( void )
  172. ldap_syntax_free LDAP_P((
  173. LDAPSyntax * syn ));
  174. LDAP_F( void )
  175. ldap_matchingrule_free LDAP_P((
  176. LDAPMatchingRule * mr ));
  177. LDAP_F( void )
  178. ldap_matchingruleuse_free LDAP_P((
  179. LDAPMatchingRuleUse * mr ));
  180. LDAP_F( void )
  181. ldap_attributetype_free LDAP_P((
  182. LDAPAttributeType * at ));
  183. LDAP_F( void )
  184. ldap_objectclass_free LDAP_P((
  185. LDAPObjectClass * oc ));
  186. LDAP_F( void )
  187. ldap_contentrule_free LDAP_P((
  188. LDAPContentRule * cr ));
  189. LDAP_F( void )
  190. ldap_nameform_free LDAP_P((
  191. LDAPNameForm * nf ));
  192. LDAP_F( void )
  193. ldap_structurerule_free LDAP_P((
  194. LDAPStructureRule * sr ));
  195. LDAP_F( LDAPStructureRule * )
  196. ldap_str2structurerule LDAP_P((
  197. LDAP_CONST char * s,
  198. int * code,
  199. LDAP_CONST char ** errp,
  200. LDAP_CONST unsigned flags ));
  201. LDAP_F( LDAPNameForm * )
  202. ldap_str2nameform LDAP_P((
  203. LDAP_CONST char * s,
  204. int * code,
  205. LDAP_CONST char ** errp,
  206. LDAP_CONST unsigned flags ));
  207. LDAP_F( LDAPContentRule * )
  208. ldap_str2contentrule LDAP_P((
  209. LDAP_CONST char * s,
  210. int * code,
  211. LDAP_CONST char ** errp,
  212. LDAP_CONST unsigned flags ));
  213. LDAP_F( LDAPObjectClass * )
  214. ldap_str2objectclass LDAP_P((
  215. LDAP_CONST char * s,
  216. int * code,
  217. LDAP_CONST char ** errp,
  218. LDAP_CONST unsigned flags ));
  219. LDAP_F( LDAPAttributeType * )
  220. ldap_str2attributetype LDAP_P((
  221. LDAP_CONST char * s,
  222. int * code,
  223. LDAP_CONST char ** errp,
  224. LDAP_CONST unsigned flags ));
  225. LDAP_F( LDAPSyntax * )
  226. ldap_str2syntax LDAP_P((
  227. LDAP_CONST char * s,
  228. int * code,
  229. LDAP_CONST char ** errp,
  230. LDAP_CONST unsigned flags ));
  231. LDAP_F( LDAPMatchingRule * )
  232. ldap_str2matchingrule LDAP_P((
  233. LDAP_CONST char * s,
  234. int * code,
  235. LDAP_CONST char ** errp,
  236. LDAP_CONST unsigned flags ));
  237. LDAP_F( LDAPMatchingRuleUse * )
  238. ldap_str2matchingruleuse LDAP_P((
  239. LDAP_CONST char * s,
  240. int * code,
  241. LDAP_CONST char ** errp,
  242. LDAP_CONST unsigned flags ));
  243. LDAP_F( char * )
  244. ldap_structurerule2str LDAP_P((
  245. LDAPStructureRule * sr ));
  246. LDAP_F( struct berval * )
  247. ldap_structurerule2bv LDAP_P((
  248. LDAPStructureRule * sr, struct berval *bv ));
  249. LDAP_F( char * )
  250. ldap_nameform2str LDAP_P((
  251. LDAPNameForm * nf ));
  252. LDAP_F( struct berval * )
  253. ldap_nameform2bv LDAP_P((
  254. LDAPNameForm * nf, struct berval *bv ));
  255. LDAP_F( char * )
  256. ldap_contentrule2str LDAP_P((
  257. LDAPContentRule * cr ));
  258. LDAP_F( struct berval * )
  259. ldap_contentrule2bv LDAP_P((
  260. LDAPContentRule * cr, struct berval *bv ));
  261. LDAP_F( char * )
  262. ldap_objectclass2str LDAP_P((
  263. LDAPObjectClass * oc ));
  264. LDAP_F( struct berval * )
  265. ldap_objectclass2bv LDAP_P((
  266. LDAPObjectClass * oc, struct berval *bv ));
  267. LDAP_F( char * )
  268. ldap_attributetype2str LDAP_P((
  269. LDAPAttributeType * at ));
  270. LDAP_F( struct berval * )
  271. ldap_attributetype2bv LDAP_P((
  272. LDAPAttributeType * at, struct berval *bv ));
  273. LDAP_F( char * )
  274. ldap_syntax2str LDAP_P((
  275. LDAPSyntax * syn ));
  276. LDAP_F( struct berval * )
  277. ldap_syntax2bv LDAP_P((
  278. LDAPSyntax * syn, struct berval *bv ));
  279. LDAP_F( char * )
  280. ldap_matchingrule2str LDAP_P((
  281. LDAPMatchingRule * mr ));
  282. LDAP_F( struct berval * )
  283. ldap_matchingrule2bv LDAP_P((
  284. LDAPMatchingRule * mr, struct berval *bv ));
  285. LDAP_F( char * )
  286. ldap_matchingruleuse2str LDAP_P((
  287. LDAPMatchingRuleUse * mru ));
  288. LDAP_F( struct berval * )
  289. ldap_matchingruleuse2bv LDAP_P((
  290. LDAPMatchingRuleUse * mru, struct berval *bv ));
  291. LDAP_F( char * )
  292. ldap_scherr2str LDAP_P((
  293. int code )) LDAP_GCCATTR((const));
  294. LDAP_END_DECL
  295. #endif