disptmpl.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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. unsigned long ti_syntaxid;
  114. unsigned long ti_options;
  115. char *ti_attrname;
  116. char *ti_label;
  117. char **ti_args;
  118. struct ldap_tmplitem *ti_next_in_row;
  119. struct ldap_tmplitem *ti_next_in_col;
  120. void *ti_appdata;
  121. };
  122. #define NULLTMPLITEM ((struct ldap_tmplitem *)0)
  123. #define LDAP_SET_TMPLITEM_APPDATA( ti, datap ) \
  124. (ti)->ti_appdata = (void *)(datap)
  125. #define LDAP_GET_TMPLITEM_APPDATA( ti, type ) \
  126. (type)((ti)->ti_appdata)
  127. #define LDAP_IS_TMPLITEM_OPTION_SET( ti, option ) \
  128. (((ti)->ti_options & option ) != 0 )
  129. /*
  130. * object class array structure
  131. */
  132. struct ldap_oclist {
  133. char **oc_objclasses;
  134. struct ldap_oclist *oc_next;
  135. };
  136. #define NULLOCLIST ((struct ldap_oclist *)0)
  137. /*
  138. * add defaults list
  139. */
  140. struct ldap_adddeflist {
  141. int ad_source;
  142. #define LDAP_ADSRC_CONSTANTVALUE 1
  143. #define LDAP_ADSRC_ADDERSDN 2
  144. char *ad_attrname;
  145. char *ad_value;
  146. struct ldap_adddeflist *ad_next;
  147. };
  148. #define NULLADLIST ((struct ldap_adddeflist *)0)
  149. /*
  150. * display template global options
  151. * if this bit is set in dt_options, it applies.
  152. */
  153. /*
  154. * users should be allowed to try to add objects of these entries
  155. */
  156. #define LDAP_DTMPL_OPT_ADDABLE 0x00000001L
  157. /*
  158. * users should be allowed to do "modify RDN" operation of these entries
  159. */
  160. #define LDAP_DTMPL_OPT_ALLOWMODRDN 0x00000002L
  161. /*
  162. * this template is an alternate view, not a primary view
  163. */
  164. #define LDAP_DTMPL_OPT_ALTVIEW 0x00000004L
  165. /*
  166. * display template structure
  167. */
  168. struct ldap_disptmpl {
  169. char *dt_name;
  170. char *dt_pluralname;
  171. char *dt_iconname;
  172. unsigned long dt_options;
  173. char *dt_authattrname;
  174. char *dt_defrdnattrname;
  175. char *dt_defaddlocation;
  176. struct ldap_oclist *dt_oclist;
  177. struct ldap_adddeflist *dt_adddeflist;
  178. struct ldap_tmplitem *dt_items;
  179. void *dt_appdata;
  180. struct ldap_disptmpl *dt_next;
  181. };
  182. #define NULLDISPTMPL ((struct ldap_disptmpl *)0)
  183. #define LDAP_SET_DISPTMPL_APPDATA( dt, datap ) \
  184. (dt)->dt_appdata = (void *)(datap)
  185. #define LDAP_GET_DISPTMPL_APPDATA( dt, type ) \
  186. (type)((dt)->dt_appdata)
  187. #define LDAP_IS_DISPTMPL_OPTION_SET( dt, option ) \
  188. (((dt)->dt_options & option ) != 0 )
  189. #define LDAP_TMPL_ERR_VERSION 1
  190. #define LDAP_TMPL_ERR_MEM 2
  191. #define LDAP_TMPL_ERR_SYNTAX 3
  192. #define LDAP_TMPL_ERR_FILE 4
  193. /*
  194. * buffer size needed for entry2text and vals2text
  195. */
  196. #define LDAP_DTMPL_BUFSIZ 8192
  197. typedef int (*writeptype)( void *writeparm, char *p, int len );
  198. LDAP_API(int)
  199. LDAP_CALL
  200. ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp );
  201. LDAP_API(int)
  202. LDAP_CALL
  203. ldap_init_templates_buf( char *buf, long buflen,
  204. struct ldap_disptmpl **tmpllistp );
  205. LDAP_API(void)
  206. LDAP_CALL
  207. ldap_free_templates( struct ldap_disptmpl *tmpllist );
  208. LDAP_API(struct ldap_disptmpl *)
  209. LDAP_CALL
  210. ldap_first_disptmpl( struct ldap_disptmpl *tmpllist );
  211. LDAP_API(struct ldap_disptmpl *)
  212. LDAP_CALL
  213. ldap_next_disptmpl( struct ldap_disptmpl *tmpllist,
  214. struct ldap_disptmpl *tmpl );
  215. LDAP_API(struct ldap_disptmpl *)
  216. LDAP_CALL
  217. ldap_name2template( char *name, struct ldap_disptmpl *tmpllist );
  218. LDAP_API(struct ldap_disptmpl *)
  219. LDAP_CALL
  220. ldap_oc2template( char **oclist, struct ldap_disptmpl *tmpllist );
  221. LDAP_API(char **)
  222. LDAP_CALL
  223. ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs, int exclude,
  224. unsigned long syntaxmask );
  225. LDAP_API(struct ldap_tmplitem *)
  226. LDAP_CALL
  227. ldap_first_tmplrow( struct ldap_disptmpl *tmpl );
  228. LDAP_API(struct ldap_tmplitem *)
  229. LDAP_CALL
  230. ldap_next_tmplrow( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row );
  231. LDAP_API(struct ldap_tmplitem *)
  232. LDAP_CALL
  233. ldap_first_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row );
  234. LDAP_API(struct ldap_tmplitem *)
  235. LDAP_CALL
  236. ldap_next_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row,
  237. struct ldap_tmplitem *col );
  238. LDAP_API(int)
  239. LDAP_CALL
  240. ldap_entry2text( LDAP *ld, char *buf, LDAPMessage *entry,
  241. struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
  242. writeptype writeproc, void *writeparm, char *eol, int rdncount,
  243. unsigned long opts );
  244. LDAP_API(int)
  245. LDAP_CALL
  246. ldap_vals2text( LDAP *ld, char *buf, char **vals, char *label, int labelwidth,
  247. unsigned long syntaxid, writeptype writeproc, void *writeparm,
  248. char *eol, int rdncount );
  249. LDAP_API(int)
  250. LDAP_CALL
  251. ldap_entry2text_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry,
  252. struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
  253. writeptype writeproc, void *writeparm, char *eol, int rdncount,
  254. unsigned long opts );
  255. LDAP_API(int)
  256. LDAP_CALL
  257. ldap_entry2html( LDAP *ld, char *buf, LDAPMessage *entry,
  258. struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
  259. writeptype writeproc, void *writeparm, char *eol, int rdncount,
  260. unsigned long opts, char *urlprefix, char *base );
  261. LDAP_API(int)
  262. LDAP_CALL
  263. ldap_vals2html( LDAP *ld, char *buf, char **vals, char *label, int labelwidth,
  264. unsigned long syntaxid, writeptype writeproc, void *writeparm,
  265. char *eol, int rdncount, char *urlprefix );
  266. LDAP_API(int)
  267. LDAP_CALL
  268. ldap_entry2html_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry,
  269. struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals,
  270. writeptype writeproc, void *writeparm, char *eol, int rdncount,
  271. unsigned long opts, char *urlprefix );
  272. LDAP_API(char *)
  273. LDAP_CALL
  274. ldap_tmplerr2string( int err );
  275. #ifdef __cplusplus
  276. }
  277. #endif
  278. #endif /* _DISPTMPL_H */