disptmpl.h 12 KB

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