]> git.sur5r.net Git - openldap/blob - contrib/tweb/tweb.c
Merge in all devel changes since 2.0-alpha2.
[openldap] / contrib / tweb / tweb.c
1 /*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
2 *                                                                          *
3 * tweb.c.....                                                              *
4 *                                                                          *
5 * Function:..WorldWideWeb-X.500-Gateway  MAIN-Routine                      *
6 *            Based on web500gw.c 1.3 written by Frank Richter, TU Chemmniz *
7 *            which is based on go500gw by Tim Howes, University of         *
8 *            Michigan  - All rights reserved                               *
9 *                                                                          *
10 * Authors:...Dr. Kurt Spanier & Bernhard Winkler,                          *
11 *            Zentrum fuer Datenverarbeitung, Bereich Entwicklung           *
12 *            neuer Dienste, Universitaet Tuebingen, GERMANY                *
13 *                                                                          *
14 *                                       ZZZZZ  DDD    V   V                *
15 *            Creation date:                Z   D  D   V   V                *
16 *            August 16 1995               Z    D   D   V V                 *
17 *            Last modification:          Z     D  D    V V                 *
18 *            December 31 1996           ZZZZ   DDD      V                  *
19 *                                                                          *
20 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
21
22 /*
23  * $Id: tweb.c,v 1.6 1999/09/10 15:01:20 zrnsk01 Exp $
24  *
25  */
26
27
28 /*
29  * redesign BW 94/08/16 
30  * patched for HPUX 9.x by /KSp, 94/04/28
31  * patched for AMBIX-D and use at University of Tuebingen by /KSp,
32  * patched for always-assume-nonleaf-behaviour-and-reread-on-demand; /KSp
33  * patched for restricted listing of Tuebinger students; /KSp
34  * patched for mailto HREF in mail attribute; /KSp
35  * patched for automatic referral to Chemnitz in case of ROOT access
36  *             (AMBIX version only); /KSp
37  * patched for correct response in case of not found error; /MCl
38  * neg patched: subtree search below locality removed; /KSp
39  * patched for automatic referral to AMBIX in case of l=DFN access
40  *             (non-AMBIX version only); /KSp
41  * patched for lower case compare during access control; /KSp
42  * patched for menu-'seeAlso' in AMBIXGW; /KSp
43  * patched for pgpPubKey formatting as MULTILINE; /KSP
44  * correction of MULTILINE handling; /KSp
45  * objectClass deleted from menu list entry in html-code; /KSp
46  * patched for "Selbsteintrag" needed by AMBIX-Project /mc
47  *             last update: 95/07/07
48  *
49  * 95/07/17 changed to ANSI-C, deleted lots of compiletime-options. /mc
50  *         
51  *
52  * Redistribution and use in source and binary forms are permitted
53  * provided that this notice is preserved and that due credit is given
54  * to the University of Tuebingen. The name of the University
55  * may not be used to endorse or promote products derived from this
56  * software without specific prior written permission. This software
57  * is provided ``as is'' without express or implied warranty.
58  *
59  * ----------------------------------------------------------------------
60  */
61
62 #include "tweb.h"
63
64 PUBLIC int main (argc, argv)
65 int argc;
66 char **argv;
67
68 {
69     /* The Glob-structure is NOT a global variable, but is stored here for
70        all other functions !!! */
71     GLOB_STRUCT glob;
72     char lang[BUFSIZ];
73     int pid, i;
74
75     /* make glob global available */
76     globP = &glob;
77
78     /* first of all the language-parameter is scanned from the command-line
79        and is written as first value to the Glob-structure */
80     get_lang(argc, argv, lang);
81     bzero((char *) &glob, sizeof(GLOB_STRUCT));
82     glob.olang = strdup(lang);
83
84     /* Now start a process for each language and terminate the super-process */
85     for(i=0; i<strlen(lang); i++){
86
87         /* memorize the sub-process-language */
88         *glob.lang = lang[i];
89
90         switch( pid = fork() ) {
91
92         /* the Sub-Process */
93         case  0:
94             do_child(argc, argv,lang, &glob);
95             break;
96
97         /* A Sub-Process could not be created !!! */
98         case -1:
99             perror( "fork" );
100             break;
101
102         /* the Parent-Process */
103         default:
104             if ( debug )
105                 fprintf( stderr, "forked child %d\n", pid );
106             break;
107         }
108     }
109
110         return( 0 );
111 }
112 /* end of function: main */
113     
114
115 /**
116  **  do_child()
117  **
118  **    Main-Function for the working-processes; until now only the
119  **    language is initialized. The rest of the configuration 
120  **    must be scanned now.
121  **/
122
123 PRIVATE void do_child(argc, argv,lang, glob)
124 int argc;
125 char **argv;
126 char *lang;
127 GLOB_STRUCT *glob;
128
129 {
130     FILE *fp = NULL;
131     char filename[BUFSIZ];
132
133     /*  read language-independent (.rc) and -dependent (.conf) configuration */
134     init(argv, lang, glob);
135
136     /*  read commandline-parameter (they overwrite conf) */
137     getopts (argc, argv, glob);
138
139     /*  If debug-Mode: Configuration Output */
140     if (debug) {
141
142         sprintf(filename, "%s.debug", glob->myname);
143         fp =fopen(filename, "a");
144         fprintf(fp, "\n\n\n#####%s.%s-log Date: %s\n\n",
145                            glob->myname, glob->lang, format_time(NULL));
146         output(fp, glob, FALSE);
147
148     }
149
150     /*  read language-strings (from .lang) and write out if desired */
151     langinit(glob);
152
153     if (debug) {
154
155         langoutput(fp, glob, FALSE);
156         fclose(fp);
157
158     }
159
160     /*  Final Configuration-Test */
161     check(glob);
162
163     /*  If dynamic Gateway-Switching is enabled the language-dependent
164         recognition-string for the meta-Syntax must be fixed
165         (language-independent recognition-string is given in Macro GWS ) */
166     if(glob->gw_switch->dynamic) {
167         char strbuf[BUFSIZ];
168
169         sprintf(strbuf, GWS_FORMAT, glob->la[0]);
170         glob->gw_switch->lagws = strdup(strbuf);
171     }
172
173     /*  and now start the Gateway ... */
174     start_server(glob);
175
176 }
177 /* end of function: do_child */
178
179