disptmpl.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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. /*
  13. * Copyright (c) 1993, 1994 Regents of the University of Michigan.
  14. * All rights reserved.
  15. *
  16. * Redistribution and use in source and binary forms are permitted
  17. * provided that this notice is preserved and that due credit is given
  18. * to the University of Michigan at Ann Arbor. The name of the University
  19. * may not be used to endorse or promote products derived from this
  20. * software without specific prior written permission. This software
  21. * is provided ``as is'' without express or implied warranty.
  22. *
  23. * disptmpl.h: display template library defines
  24. * 7 March 1994 by Mark C Smith
  25. */
  26. #ifndef _DISPTMPL_H
  27. #define _DISPTMPL_H
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* calling conventions used by library */
  32. #ifndef LDAP_CALL
  33. #define LDAP_C
  34. #define LDAP_CALLBACK
  35. #define LDAP_PASCAL
  36. #define LDAP_CALL
  37. #endif /* LDAP_CALL */
  38. #define LDAP_TEMPLATE_VERSION 1
  39. /*
  40. * general types of items (confined to most significant byte)
  41. */
  42. #define LDAP_SYN_TYPE_TEXT 0x01000000L
  43. #define LDAP_SYN_TYPE_IMAGE 0x02000000L
  44. #define LDAP_SYN_TYPE_BOOLEAN 0x04000000L
  45. #define LDAP_SYN_TYPE_BUTTON 0x08000000L
  46. #define LDAP_SYN_TYPE_ACTION 0x10000000L
  47. /*
  48. * syntax options (confined to second most significant byte)
  49. */
  50. #define LDAP_SYN_OPT_DEFER 0x00010000L
  51. /*
  52. * display template item syntax ids (defined by common agreement)
  53. * these are the valid values for the ti_syntaxid of the tmplitem
  54. * struct (defined below). A general type is encoded in the
  55. * most-significant 8 bits, and some options are encoded in the next
  56. * 8 bits. The lower 16 bits are reserved for the distinct types.
  57. */
  58. #define LDAP_SYN_CASEIGNORESTR (1 | LDAP_SYN_TYPE_TEXT)
  59. #define LDAP_SYN_MULTILINESTR (2 | LDAP_SYN_TYPE_TEXT)
  60. #define LDAP_SYN_DN (3 | LDAP_SYN_TYPE_TEXT)
  61. #define LDAP_SYN_BOOLEAN (4 | LDAP_SYN_TYPE_BOOLEAN)
  62. #define LDAP_SYN_JPEGIMAGE (5 | LDAP_SYN_TYPE_IMAGE)
  63. #define LDAP_SYN_JPEGBUTTON (6 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER)
  64. #define LDAP_SYN_FAXIMAGE (7 | LDAP_SYN_TYPE_IMAGE)
  65. #define LDAP_SYN_FAXBUTTON (8 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER)
  66. #define LDAP_SYN_AUDIOBUTTON (9 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER)
  67. #define LDAP_SYN_TIME (10 | LDAP_SYN_TYPE_TEXT)
  68. #define LDAP_SYN_DATE (11 | LDAP_SYN_TYPE_TEXT)
  69. #define LDAP_SYN_LABELEDURL (12 | LDAP_SYN_TYPE_TEXT)
  70. #define LDAP_SYN_SEARCHACTION (13 | LDAP_SYN_TYPE_ACTION)
  71. #define LDAP_SYN_LINKACTION (14 | LDAP_SYN_TYPE_ACTION)
  72. #define LDAP_SYN_ADDDNACTION (15 | LDAP_SYN_TYPE_ACTION)
  73. #define LDAP_SYN_VERIFYDNACTION (16 | LDAP_SYN_TYPE_ACTION)
  74. #define LDAP_SYN_RFC822ADDR (17 | LDAP_SYN_TYPE_TEXT)
  75. /*
  76. * handy macros
  77. */
  78. #define LDAP_GET_SYN_TYPE(syid) ((syid)&0xFF000000L)
  79. #define LDAP_GET_SYN_OPTIONS(syid) ((syid)&0x00FF0000L)
  80. /*
  81. * display options for output routines (used by entry2text and friends)
  82. */
  83. /*
  84. * use calculated label width (based on length of longest label in
  85. * template) instead of contant width
  86. */
  87. #define LDAP_DISP_OPT_AUTOLABELWIDTH 0x00000001L
  88. #define LDAP_DISP_OPT_HTMLBODYONLY 0x00000002L
  89. /*
  90. * perform search actions (applies to ldap_entry2text_search only)
  91. */
  92. #define LDAP_DISP_OPT_DOSEARCHACTIONS 0x00000002L
  93. /*
  94. * include additional info. relevant to "non leaf" entries only
  95. * used by ldap_entry2html and ldap_entry2html_search to include "Browse"
  96. * and "Move Up" HREFs
  97. */
  98. #define LDAP_DISP_OPT_NONLEAF 0x00000004L
  99. /*
  100. * display template item options (may not apply to all types)
  101. * if this bit is set in ti_options, it applies.
  102. */
  103. #define LDAP_DITEM_OPT_READONLY 0x00000001L
  104. #define LDAP_DITEM_OPT_SORTVALUES 0x00000002L
  105. #define LDAP_DITEM_OPT_SINGLEVALUED 0x00000004L
  106. #define LDAP_DITEM_OPT_HIDEIFEMPTY 0x00000008L
  107. #define LDAP_DITEM_OPT_VALUEREQUIRED 0x00000010L
  108. #define LDAP_DITEM_OPT_HIDEIFFALSE 0x00000020L /* booleans only */
  109. /*
  110. * display template item structure
  111. */
  112. struct ldap_tmplitem
  113. {
  114. unsigned long ti_syntaxid;
  115. unsigned long ti_options;
  116. char *ti_attrname;
  117. char *ti_label;
  118. char **ti_args;
  119. struct ldap_tmplitem *ti_next_in_row;
  120. struct ldap_tmplitem *ti_next_in_col;
  121. void *ti_appdata;
  122. };
  123. #define NULLTMPLITEM ((struct ldap_tmplitem *)0)
  124. #define LDAP_SET_TMPLITEM_APPDATA(ti, datap) \
  125. (ti)->ti_appdata = (void *)(datap)
  126. #define LDAP_GET_TMPLITEM_APPDATA(ti, type) \
  127. (type)((ti)->ti_appdata)
  128. #define LDAP_IS_TMPLITEM_OPTION_SET(ti, option) \
  129. (((ti)->ti_options & option) != 0)
  130. /*
  131. * object class array structure
  132. */
  133. struct ldap_oclist
  134. {
  135. char **oc_objclasses;
  136. struct ldap_oclist *oc_next;
  137. };
  138. #define NULLOCLIST ((struct ldap_oclist *)0)
  139. /*
  140. * add defaults list
  141. */
  142. struct ldap_adddeflist
  143. {
  144. int ad_source;
  145. #define LDAP_ADSRC_CONSTANTVALUE 1
  146. #define LDAP_ADSRC_ADDERSDN 2
  147. char *ad_attrname;
  148. char *ad_value;
  149. struct ldap_adddeflist *ad_next;
  150. };
  151. #define NULLADLIST ((struct ldap_adddeflist *)0)
  152. /*
  153. * display template global options
  154. * if this bit is set in dt_options, it applies.
  155. */
  156. /*
  157. * users should be allowed to try to add objects of these entries
  158. */
  159. #define LDAP_DTMPL_OPT_ADDABLE 0x00000001L
  160. /*
  161. * users should be allowed to do "modify RDN" operation of these entries
  162. */
  163. #define LDAP_DTMPL_OPT_ALLOWMODRDN 0x00000002L
  164. /*
  165. * this template is an alternate view, not a primary view
  166. */
  167. #define LDAP_DTMPL_OPT_ALTVIEW 0x00000004L
  168. /*
  169. * display template structure
  170. */
  171. struct ldap_disptmpl
  172. {
  173. char *dt_name;
  174. char *dt_pluralname;
  175. char *dt_iconname;
  176. unsigned long dt_options;
  177. char *dt_authattrname;
  178. char *dt_defrdnattrname;
  179. char *dt_defaddlocation;
  180. struct ldap_oclist *dt_oclist;
  181. struct ldap_adddeflist *dt_adddeflist;
  182. struct ldap_tmplitem *dt_items;
  183. void *dt_appdata;
  184. struct ldap_disptmpl *dt_next;
  185. };
  186. #define NULLDISPTMPL ((struct ldap_disptmpl *)0)
  187. #define LDAP_SET_DISPTMPL_APPDATA(dt, datap) \
  188. (dt)->dt_appdata = (void *)(datap)
  189. #define LDAP_GET_DISPTMPL_APPDATA(dt, type) \
  190. (type)((dt)->dt_appdata)
  191. #define LDAP_IS_DISPTMPL_OPTION_SET(dt, option) \
  192. (((dt)->dt_options & option) != 0)
  193. #define LDAP_TMPL_ERR_VERSION 1
  194. #define LDAP_TMPL_ERR_MEM 2
  195. #define LDAP_TMPL_ERR_SYNTAX 3
  196. #define LDAP_TMPL_ERR_FILE 4
  197. /*
  198. * buffer size needed for entry2text and vals2text
  199. */
  200. #define LDAP_DTMPL_BUFSIZ 8192
  201. typedef int (*writeptype)(void *writeparm, char *p, int len);
  202. LDAP_API(int)
  203. LDAP_CALL
  204. ldap_init_templates(char *file, struct ldap_disptmpl **tmpllistp);
  205. LDAP_API(int)
  206. LDAP_CALL
  207. ldap_init_templates_buf(char *buf, long buflen, struct ldap_disptmpl **tmpllistp);
  208. LDAP_API(void)
  209. LDAP_CALL
  210. ldap_free_templates(struct ldap_disptmpl *tmpllist);
  211. LDAP_API(struct ldap_disptmpl *)
  212. LDAP_CALL
  213. ldap_first_disptmpl(struct ldap_disptmpl *tmpllist);
  214. LDAP_API(struct ldap_disptmpl *)
  215. LDAP_CALL
  216. ldap_next_disptmpl(struct ldap_disptmpl *tmpllist,
  217. struct ldap_disptmpl *tmpl);
  218. LDAP_API(struct ldap_disptmpl *)
  219. LDAP_CALL
  220. ldap_name2template(char *name, struct ldap_disptmpl *tmpllist);
  221. LDAP_API(struct ldap_disptmpl *)
  222. LDAP_CALL
  223. ldap_oc2template(char **oclist, struct ldap_disptmpl *tmpllist);
  224. LDAP_API(char **)
  225. LDAP_CALL
  226. ldap_tmplattrs(struct ldap_disptmpl *tmpl, char **includeattrs, int exclude, unsigned long syntaxmask);
  227. LDAP_API(struct ldap_tmplitem *)
  228. LDAP_CALL
  229. ldap_first_tmplrow(struct ldap_disptmpl *tmpl);
  230. LDAP_API(struct ldap_tmplitem *)
  231. LDAP_CALL
  232. ldap_next_tmplrow(struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row);
  233. LDAP_API(struct ldap_tmplitem *)
  234. LDAP_CALL
  235. ldap_first_tmplcol(struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row);
  236. LDAP_API(struct ldap_tmplitem *)
  237. LDAP_CALL
  238. ldap_next_tmplcol(struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row, struct ldap_tmplitem *col);
  239. LDAP_API(int)
  240. LDAP_CALL
  241. ldap_entry2text(LDAP *ld, char *buf, LDAPMessage *entry, struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, writeptype writeproc, void *writeparm, char *eol, int rdncount, unsigned long opts);
  242. LDAP_API(int)
  243. LDAP_CALL
  244. ldap_vals2text(LDAP *ld, char *buf, char **vals, char *label, int labelwidth, unsigned long syntaxid, writeptype writeproc, void *writeparm, char *eol, int rdncount);
  245. LDAP_API(int)
  246. LDAP_CALL
  247. ldap_entry2text_search(LDAP *ld, char *dn, char *base, LDAPMessage *entry, struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals, writeptype writeproc, void *writeparm, char *eol, int rdncount, unsigned long opts);
  248. LDAP_API(int)
  249. LDAP_CALL
  250. ldap_entry2html(LDAP *ld, char *buf, LDAPMessage *entry, struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, writeptype writeproc, void *writeparm, char *eol, int rdncount, unsigned long opts, char *urlprefix, char *base);
  251. LDAP_API(int)
  252. LDAP_CALL
  253. ldap_vals2html(LDAP *ld, char *buf, char **vals, char *label, int labelwidth, unsigned long syntaxid, writeptype writeproc, void *writeparm, char *eol, int rdncount, char *urlprefix);
  254. LDAP_API(int)
  255. LDAP_CALL
  256. ldap_entry2html_search(LDAP *ld, char *dn, char *base, LDAPMessage *entry, struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals, writeptype writeproc, void *writeparm, char *eol, int rdncount, unsigned long opts, char *urlprefix);
  257. LDAP_API(char *)
  258. LDAP_CALL
  259. ldap_tmplerr2string(int err);
  260. #ifdef __cplusplus
  261. }
  262. #endif
  263. #endif /* _DISPTMPL_H */