Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

330 lines
9.4 KiB

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