]> git.sur5r.net Git - openldap/blob - contrib/tweb/tgeneral.h
fixed test on "" (empty) parent dn
[openldap] / contrib / tweb / tgeneral.h
1 /*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
2 *                                                                          *
3 * tgeneral.h.                                                              *
4 *                                                                          *
5 * Function:..General-Headerfile for TWEB                                   *
6 *                                                                          *
7 *                                                                          *
8 *                                                                          *
9 * Authors:...Dr. Kurt Spanier & Bernhard Winkler,                          *
10 *            Zentrum fuer Datenverarbeitung, Bereich Entwicklung           *
11 *            neuer Dienste, Universitaet Tuebingen, GERMANY                *
12 *                                                                          *
13 *                                       ZZZZZ  DDD    V   V                *
14 *            Creation date:                Z   D  D   V   V                *
15 *            August 16 1995               Z    D   D   V V                 *
16 *            Last modification:          Z     D  D    V V                 *
17 *            September 13 1999          ZZZZ   DDD      V                  *
18 *                                                                          *
19 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
20
21 /*
22  * $Id: tgeneral.h,v 1.8 1999/09/13 13:47:47 zrnsk01 Exp $
23  *
24  */
25
26
27 #ifndef _TGENERAL_
28 #define _TGENERAL_
29
30 #define PUBLIC
31 #define PRIVATE static
32
33 /* For changes see file CHANGES */
34 #ifdef __hpux
35 #define _INCLUDE_POSIX_SOURCE
36 #define _INCLUDE_XOPEN_SOURCE
37 #define _INCLUDE_HPUX_SOURCE
38 #define TIOCNOTTY   _IO('t', 113)
39 #define getdtablesize() _NFILE
40 #endif
41
42 #if defined( __linux__ ) && !defined( _BSD_SOURCE )
43 #define  _BSD_SOURCE
44 #define  _SVID_SOURCE
45 #define  _GNU_SOURCE
46 #define  _POSIX_SOURCE
47 #endif
48
49 #include <string.h>
50 #include <strings.h>
51 #include <sys/time.h>
52 #include <time.h>
53 #include "lber.h"
54 #include "ldap.h"
55 #include <stdio.h>
56 #include <ctype.h>
57 #include <sys/types.h>
58 #include <sys/param.h>
59 #include <sys/stat.h>
60 #include <sys/socket.h>
61 #include <netinet/in.h>
62 #include <arpa/inet.h>
63 #include <netdb.h>
64 #include <syslog.h>
65 #include <sys/wait.h>
66 #include <signal.h>
67 #include <errno.h>
68 #include <stdlib.h>
69 #include <unistd.h>
70
71 /*  Support of LDAP API versions */
72 #if LDAP_API_VERSION >= 2003 && LDAP_API_VERSION <= 2010
73 #define OL_LDAPV                3
74 #else
75 #  if LDAP_API_VERSION >= 2001 && LDAP_API_VERSION <= 2010
76 #  define OL_LDAPV              2
77 #  else
78 #    define OL_LDAPV    0
79 #  endif
80 #endif
81
82 #  define ldap_debug debug
83
84 #if OL_LDAPV > 2
85 #  include "portable.h"
86 #  include "ldap_log.h"
87 #endif
88
89 extern   int   errno;
90
91
92 #include "strng_exp.h"
93
94 #ifndef TRUE
95 #define TRUE   1
96 #endif
97 #ifndef FALSE
98 #define FALSE  0
99 #endif
100 #define OK     1
101 #define NOTOK  0
102 #define DONE -1
103 #define  _TIMEOUT_LEN   31
104 #define  _LOG_TIME     "%a, %d.%m.%y, %H:%M:%S"
105
106 #include "init_exp.h"
107 extern GLOB_STRUCT *globP;
108
109 /*
110  ***************************************************************************
111  * If you are not a University of Tuebingen site, 
112  * you probably want to tailor the following:
113  ***************************************************************************
114  */
115
116 /* Special code for DFN-Project AMBIX-D */
117 #ifdef AMBIXGW
118
119 #  define SELBST_CN          glob->selbsteintrag[0]
120 #  define SELBST_CN_NAME     glob->selbsteintrag[1]
121 #  define SELBST_STUDIE_ATTR glob->selbsteintrag[2]
122 #  define SELBST_INSERT_MODE glob->selbsteintrag[3]
123 #  define SELBST_INSERT_WHO  glob->selbsteintrag[4]
124 #  define SELBST_INSERT_NO   glob->selbsteintrag[5]
125 #  define SELBST_INSERT_WORK glob->selbsteintrag[6]
126 #  define SELBST_INSERT_ALL  glob->selbsteintrag[7]
127 #  define SELBST_INSERT_STUD glob->selbsteintrag[8]
128
129 #  define MAXDN_LEN 2048
130
131 extern void self_insert();
132
133 #endif
134
135
136
137 /* Flags for print_attr */
138 #define DEFAULT        0
139 #define MULTILINE      1
140 #define HREF           2
141 #define FINGER         3
142 #define DATE           4
143 #define URL            5
144 #define MAILTO         6
145 #define MOVETO         7
146 #define BMP            8
147 #define JPEG           9
148 #define JPEG2GIF      10
149 #define BOOLEAN       11
150 #define URI           12
151 #define PGPKEY        13
152 #define INDEXURL      14
153 #define DYNAMICDN     15
154 #define REFERRAL      20
155 #define PRE           21
156 #define HEADER        22
157
158 #ifdef TUE_TEL
159 #define PHONREFSHORT  16
160 #define PHONREFLONG   17
161 #define TFUNCPERS     18
162 #define FAXTABLE      19
163 #endif
164
165
166 /* Patch for hpux from ksp: */
167 #ifdef __hpux
168 #  define rewind(a) fflush(a)
169 #endif
170
171 #define G3TOXBM "cat"
172 #define JPEGTOGIF "/soft/bin/djpeg -gif"
173
174 /*
175  *************************************************************************
176  * The rest of this stuff probably does not need to be changed
177  *************************************************************************
178  */
179
180 #define TIMEOUT        240
181 #define WEB500PORT    8889
182
183 #ifndef FD_SET
184 #define NFDBITS         32
185 #define FD_SETSIZE      32
186 #define FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
187 #define FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
188 #define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
189 #define FD_ZERO(p)      bzero((char *)(p), sizeof(*(p)))
190 #endif
191
192 #define from_hex(c)    ((c>='0')&&(c<='9') ? c-'0' : (c>='A')&&(c<='F') ?\
193             c-'A'+10 : (c>='a')&&(c<='f') ? c-'a'+10 : 0)
194
195 /*
196  * HTTP request we are implementing
197  */
198
199 #define    UNKNOWN    0
200 #define    GET        1
201 #define    HEAD       2
202
203 /*
204  * HTTP response status
205  */
206 #define DOCUMENT_FOLLOWS  200
207 #define REDIRECT          302
208 #define BAD_REQUEST       400
209 #define AUTH_REQUIRED     401
210 #define FORBIDDEN         403
211 #define NOT_FOUND         404
212 #define SERVER_ERROR      500
213 #define NOT_IMPLEMENTED   501
214
215 #define PRINT_HTML_HEADER     (fprintf(fp, \
216 "HTTP/1.0 %d Document follows\n\
217 MIME-Version: 1.0\n\
218 Server: %s\n\
219 Date: %s\n\
220 Content-Type: text/html\n\
221 Last-Modified: %s\n\
222 %s\n",\
223 DOCUMENT_FOLLOWS, version, glob->nowtimestr, glob->nowtimestr,\
224  glob->caching ? glob->expiretimestr : "Pragma: no-cache\n" ))
225
226 #define PRINT_PLAIN_HEADER     (fprintf(fp, \
227 "HTTP/1.0 %d Document follows\n\
228 MIME-Version: 1.0\n\
229 Server: %s\n\
230 Date: %s\n\
231 Content-Type: text/plain\n\
232 Last-Modified: %s\n\
233 %s\n",\
234 DOCUMENT_FOLLOWS, version, glob->nowtimestr, glob->nowtimestr,\
235  glob->caching ? glob->expiretimestr : "Pragma: no-cache\n" ))
236
237 #define PRINT_REDIRECT_HEADER     (fprintf(fp, \
238 "HTTP/1.0 302 Found\n\
239 MIME-Version: 1.0\n\
240 Server: %s\n\
241 Date: %s\n\
242 Location: %s\n\
243 Content-Type: text/html\n\
244 Last-Modified: %s\n\
245 %s\n",\
246 version, glob->nowtimestr, query, glob->nowtimestr,\
247  glob->caching ? glob->expiretimestr : "Pragma: no-cache\n" ))
248
249 #define HTML_HEAD_TITLE "<HTML><HEAD><TITLE>%s</TITLE></HEAD><%s>"
250
251 #define PRINT_HTML_FOOTER     (fprintf(fp, "</BODY></HTML>"))
252
253 /* Meta-Syntax of Gateway-Switching feature */
254 #define GWS        "(gw)"
255 #define GWS_FORMAT "(gw-%s)"
256
257
258 #define OUT_TIME 900
259
260 /* Separator in UFNs */
261 #define UFNSEP ","
262
263 #endif /* _TGENERAL_ */
264