]> git.sur5r.net Git - openldap/blob - contrib/tweb/init.c
Update man page date.
[openldap] / contrib / tweb / init.c
1 /*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
2 *                                                                          *
3 * init.c.....                                                              *
4 *                                                                          *
5 * Function:..Initialisation-Routine 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 *            July 21 1995                 Z    D   D   V V                 *
16 *            Last modification:          Z     D  D    V V                 *
17 *            May 11 1999                ZZZZZ  DDD      V                  *
18 *                                                                          *
19 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
20
21 /*
22  * $Id: init.c,v 1.6 1999/09/10 15:01:17 zrnsk01 Exp $
23  *
24  */
25
26 #include "tgeneral.h"
27 #include "tglobal.h"
28 #include "init.h"
29
30
31 PUBLIC void getopts (argc, argv, glob)
32 int argc;
33 char **argv;
34 GLOB_STRUCT *glob;
35 {
36     int            i;
37     extern char        *optarg;
38     char hname[BUFSIZ];
39     struct hostent *hstruct;
40
41     while ( (i = getopt( argc, argv, "P:ad:f:l:p:x:b:L:" )) != EOF ) {
42         switch( i ) {
43         case 'a':
44             searchaliases = 0;
45             break;
46         case 'b':
47             if(glob->basedn && glob->basedn->dn)
48                 free(glob->basedn->dn);
49             glob->basedn->dn = strdup( optarg );
50             break;
51         case 'd':
52             debug = atoi( optarg );
53 #ifdef LDAP_DEBUG
54             ldap_debug = debug;
55 #else
56             fprintf( stderr, 
57                              "warning: ldap debugging requires LDAP_DEBUG\n" );
58 #endif
59             break;
60
61         case 'f':
62             glob->filterfile = strdup( optarg );
63             break;
64
65         case 'l':
66             dosyslog = cnvt_str2int( optarg, syslog_types, LOG_LOCAL3 );
67             break;
68
69         case 'p':
70             glob->webport = atoi( optarg );
71             break;
72
73         case 'P':
74             glob->ldapport = atoi( optarg );
75             break;
76
77         case 'x':
78             if(glob->ldapd)
79                 free(glob->ldapd);
80             glob->ldapd = str_tolower( strdup( optarg ));
81             break;
82         case 'L':
83             break;
84         default:
85             usage(argv[0]);
86         }
87     }
88     if ( (glob->myname = strrchr( argv[0], '/' )) == NULL )
89         glob->myname = argv[0];
90     else
91         glob->myname++;
92
93     if(!glob->hostname) {
94         gethostname(hname, BUFSIZ);
95         hstruct = gethostbyname(hname);
96         glob->hostname = str_tolower( strdup( hstruct->h_name ));
97     }
98
99 }
100 /* end of function: getopts */
101
102 PRIVATE void usage(name)
103 char    *name;
104 {
105         fprintf(stderr, USAGE, name);
106         exit( 1 );
107 }
108 /* end of function: usage */
109
110 PUBLIC void check (glob)
111 GLOB_STRUCT *glob;
112 {
113     if(!glob->webport || !glob->ldapd || !glob->ldapport ||
114                         !glob->basedn || !glob->sort) {
115         fprintf(stderr,
116 "\nMissing must-attribute: webport || ldapd || ldapport || basedn->dn || sort\n!\n\n");
117         exit(1);
118     }
119
120     if(glob->grant){
121         trim(glob->grant, "|");
122         glob->comp_grant = tweb_regcomp(glob->grant);
123     }
124
125     if(glob->refuse){
126         trim(glob->refuse, "|");
127         glob->comp_refuse = tweb_regcomp(glob->refuse);
128     }
129
130     if(glob->allow_string){
131         trim(glob->allow_string, "|");
132         glob->comp_allow = tweb_regcomp(glob->allow_string);
133     }
134
135     if(glob->deny_string){
136         trim(glob->deny_string, "|");
137         glob->comp_deny = tweb_regcomp(glob->deny_string);
138     }
139
140     if(!glob->webdn){
141         glob->webdn   = "c=DE";
142         if(glob->webpw) free(glob->webpw);
143         glob->webpw   = NULL;
144     }
145     if(!glob->webdn2){
146         glob->webdn2   = "c=BR";
147         if(glob->webpw2) free(glob->webpw2);
148         glob->webpw2   = NULL;
149     }
150
151     if(!glob->timeout)
152         glob->timeout = DEFAULT_TIMEOUT;
153     if(!glob->maxcount)
154         glob->maxcount = DEFAULT_MAXCOUNT;
155
156     if(!glob->subtree_search)
157         glob->subtree_search =
158                 str2charray( "organization:organizationalUnit", ":");
159
160     glob->cache_expire = glob->cache_expire % MAX_EXPIRE;
161
162     f_test(glob);
163     if(glob->sort) {
164         pSORT_LINE s_ptr;
165         pDISPLAY d_ptr;
166
167         for(s_ptr = glob->sort; s_ptr; s_ptr = s_ptr->next)
168             for(d_ptr = glob->display; d_ptr; d_ptr = d_ptr->next) {
169                 if(!strcmp(d_ptr->ocs, s_ptr->display_class)) {
170                     s_ptr->display_class_ptr = d_ptr;
171                     break;
172                 }
173                 if(!strcmp(d_ptr->ocs, "default"))
174                     s_ptr->display_class_ptr = d_ptr;
175             }
176     }
177
178     if( glob->ldapd && !strcmp(glob->ldapd, "x500-relay.uni-tuebingen.de") 
179             && !strcmp(glob->lang, "0")) {
180        fprintf( stderr,
181             "\n\n\tYou missed to set LDAP-HOST and LDAP-PORT to\n\
182              a machine of your own.\n\n\tPlease change as soon as \
183              possible to avoid\n\
184              overload of host x500-relay.uni-tuebingen.de !\n\n");
185     }
186
187 }
188 /* end of function: check */
189
190 PUBLIC void init(argv, lang, glob)
191 char **argv;
192 char *lang;
193 GLOB_STRUCT *glob;
194 {
195 FILE *fp;
196 static char file[BUFSIZ];
197
198     glob->argv0 = strdup(argv[0]);
199     glob->gw_switch = (pGW_SWITCH) ch_calloc(1, sizeof(GW_SWITCH));
200     glob->basedn = (BASEDN_LINE *) ch_calloc(1, sizeof(BASEDN_LINE));
201     glob->basedn->dn = strdup("");
202     glob->menu_filter = strdup("(& (objectClass=top)(!(objectClass=dSA)) )");
203
204 #ifdef RCINIT
205     strcpy(file, RCINIT);
206 #else
207     sprintf( file, "%s.rc", argv[0] );
208 #endif
209     glob->acfilename = file;
210     if(!(fp = fopen(file, "r"))) {
211         fprintf(stderr, "\n\nATTENTION!!!\n\nCould not open file %s !\n", file);
212         exit(1);
213     }
214     main_loop(fp, glob);
215     fclose(fp);
216
217 #ifdef CONFINIT
218     strcpy(file, CONFINIT);
219 #else
220     sprintf( file, "%s.conf.%s", argv[0], glob->lang );
221 #endif
222     glob->acfilename = file;
223     if(!(fp = fopen(file, "r"))) {
224         fprintf(stderr, "\n\nATTENTION!!!\n\nCould not open file %s !\n", file);
225         exit(1);
226     }
227     main_loop(fp, glob);
228     fclose(fp);
229     return;
230 }
231 /* end of function: init */
232
233 #define  STRINGP(x)   ((x) ? (x) : "(NULL)")
234
235 PUBLIC void output(fp, glob, html_flag)
236 FILE *fp;
237 GLOB_STRUCT *glob;
238 int html_flag;
239 {
240     pDISPLAY d_ptr;
241     pSEARCH_ONLY_LINE so_ptr;
242     pGW_SWITCH_LINE gw_ptr;
243     pSORT_LINE s_ptr;
244     pDISPLAY_LINE dis_ptr;
245     pMODIFY_LINE mod_ptr;
246     pMODIF m_ptr;
247     pCACHING_TERMS_LINE ca_ptr;
248     pIND_ATTRS i_ptr;
249     IND_ATTR_ARR *idx;
250     pTABLE_DISPLAY ta_ptr;
251     pFORM_BUTTON fo_ptr;
252     int i;
253     char hb[BUFSIZ], he[BUFSIZ], li[BUFSIZ], lb[BUFSIZ], le[BUFSIZ];
254
255     strcpy(lb, html_flag ? "<UL>" : "");
256     strcpy(le, html_flag ? "</UL>" : "");
257     strcpy(li, html_flag ? "<LI>" : "");
258     strcpy(hb, html_flag ? "</UL><B>" : "");
259     strcpy(he, html_flag ? "</B><UL>" : "");
260
261 /*for(i=0; glob->sort_attribs[i]; i++)
262     fprintf(fp,"%s<p>\n", glob->sort_attribs[i]);
263 */
264
265     fprintf(fp,
266         "%s\n\n\n###############CONFIGURATION-DISPLAY###############\n\n%s",
267         html_flag ? "<B>" : "", he);
268     fprintf(fp, "\n%s\n\n%s", version, html_flag ? "<p>" : "");
269 /*    fprintf(fp, "%s\n%s\n\n%s", html_flag ? "<B>" : "", version, he);
270 */
271
272     fprintf(fp, "%sWEBDN%s%s %s\n", hb, he, li, STRINGP( glob->webdn ));
273     fprintf(fp, "%sWEBDN2%s%s %s\n", hb, he, li, STRINGP( glob->webdn2 ));
274     if(!html_flag){
275         fprintf(fp, "WEBPW: %s\n", STRINGP( glob->webpw ));
276         fprintf(fp, "WEBPW2: %s\n", STRINGP( glob->webpw2 ));
277     }
278     fprintf(fp, "%sTWEBHOST%s%s %s:%d\n", hb, he, li, STRINGP( glob->hostname ),
279             glob->virtualport ? glob->virtualport : glob->webport);
280     fprintf(fp, "%sWEBPORT%s%s %d\n", hb, he, li, glob->webport);
281     fprintf(fp, "%sTIMEOUT%s%s %d\n", hb, he, li, glob->timeout);
282     fprintf(fp, "%sLDAPD%s%s %s\n", hb, he, li, STRINGP( glob->ldapd ));
283     fprintf(fp, "%sLDAPPORT%s%s %d\n\n", hb, he, li, glob->ldapport);
284     fprintf(fp, "%sETCDIR%s%s %s\n", hb, he, li, STRINGP( glob->etcdir ));
285     fprintf(fp, "%sHELPFILE%s%s %s\n", hb, he, li, STRINGP( glob->helpfile ));
286     fprintf(fp, "%sFILTERFILE%s%s %s\n", hb, he, li,
287         STRINGP( glob->filterfile ));
288     fprintf(fp, "%sFRIENDLYFILE%s%s %s\n", hb, he, li,
289         STRINGP( glob->friendlyfile ));
290     fprintf(fp, "%sHEADER%s%s %s\n", hb, he, li, STRINGP( glob->header ));
291     fprintf(fp, "%sFOOTER%s%s %s\n", hb, he, li, STRINGP( glob->footer ));
292     fprintf(fp, "%sGRANT%s%s %s\n", hb, he, li, STRINGP( glob->grant ));
293     fprintf(fp, "%sREFUSE%s%s %s\n", hb, he, li, STRINGP( glob->refuse ));
294
295     fprintf(fp, "%s\nPULL-DOWN-MENUS%s%s %s\n",
296         hb, he, li, glob->pull_down_menus?"YES":"NO");
297     fprintf(fp, "%s\nDISP-SEA-RDN%s%s %s\n",
298          hb, he, li, glob->disp_sea_rdn?"YES":"NO");
299     fprintf(fp, "%s\nNO-PROXY%s%s %s\n", hb, he, li, glob->no_proxy?"YES":"NO");
300     fprintf(fp, "%s\nALLOW-PROXY%s\n%s", hb, he, li);
301     for(i = 0; glob->allow_proxy && glob->allow_proxy[i]; i++) 
302         fprintf(fp, "%s:", glob->allow_proxy[i]);
303
304     fprintf(fp, "%sALLOW-STRING%s%s %s\n", hb, he, li,
305         STRINGP( glob->allow_string ));
306     fprintf(fp, "%sDENY-STRING%s%s %s\n", hb, he, li,
307         STRINGP( glob->deny_string ));
308     fprintf(fp, "%sALLOW-MSG%s%s %s\n", hb, he, li, STRINGP( glob->allow_msg ));
309     fprintf(fp, "%s\nBASEDN%s%s \t%s\t%s\t%s\n", hb, he, li,
310          STRINGP( glob->basedn->dn ), STRINGP( glob->basedn->head ),
311         STRINGP( glob->basedn->foot ));
312 /*    fprintf(fp, "%s\nBASEDNARRAY%s%s \t%s\t%s\n", hb, he, li, glob->basedn->dnarray[0], glob->basedn->dnarray[1]); */
313     fprintf(fp, "%s\nMAXCOUNT%s%s %d\n", hb, he, li, glob->maxcount);
314     if (glob->comrefuse)
315         fprintf(fp, "%s\nCOMREFUSE%s%s %d\t%d\t%d\t%d\t%lu\t%s\n",
316                     hb, he, li, glob->comrefuse->tmin, glob->comrefuse->tdiff,
317                     glob->comrefuse->maxAccept, glob->comrefuse->suspendCycle,
318                     glob->comrefuse->statCycle,
319                     STRINGP( glob->comrefuse->statFile ));
320     fprintf(fp, "%s\nMAX-PERSON%s%s %d\t%s\t%s\n", hb, he, li,
321          glob->max_person, glob->strict?"STRICT":"",
322          glob->no_browse?"NO-BROWSE":"");
323     fprintf(fp, "%s\nLEGAL%s%s %s %s\n", hb, he, li, glob->legal?"YES":"NO",
324                  glob->legal_top ? "ON-TOP" : "");
325 /*    fprintf(fp, "%s\nSHOW-DEFOC%s%s %s\n", hb, he, li, glob->show_defoc?"YES":"NO");
326 */
327
328 #ifdef AMBIXGW
329     fprintf(fp, "%s\nSELBSTEINTRAG%s\n", hb, he);
330     for(i = 0; i<9; i++) 
331         if (glob->selbsteintrag[i])
332             fprintf(fp, "%s\t%s\n", li, glob->selbsteintrag[i]);
333 #endif
334
335     fprintf(fp, "%s\nSTRIP-PIN%s%s %s\n", hb, he, li,
336         STRINGP( glob->strip_pin ));
337     fprintf(fp, "%s\nPREFER-REF-URIS%s%s %s\n", hb, he, li,
338          glob->prefer_ref_uris?"YES":"NO");
339     fprintf(fp, "%s\nSTRICT-BASEDN%s%s %s\n", hb, he, li,
340          glob->strict_basedn?"YES":"NO");
341     fprintf(fp, "%s\nNO-SHOW-RDN%s%s %s\n\n", hb, he, li,
342         STRINGP( glob->no_show_rdn ));
343     fprintf(fp, "%s\nNO-MODIFY%s%s %s\n\n", hb, he, li,
344         STRINGP( glob->no_modify ));
345
346 #ifdef TUE_TEL
347     fprintf(fp, "%sPHONEWORLD%s%s %s\n", hb, he, li,
348         STRINGP( glob->phoneworld ));
349 #endif
350
351     fprintf(fp, "%s\nLANGUAGE%s\n", hb, he);
352     for(i = 0; glob->language[i]; i++) 
353         fprintf(fp, "%s\t%s\n", li, glob->language[i]);
354
355     fprintf(fp, "%s\nCACHE-EXPIRE-DEFAULT%s%s %d\n", hb, he, li,
356          glob->cache_expire);
357     fprintf(fp, "%s\nCACHING-TERMS%s\n", hb, he);
358     for(ca_ptr = glob->caching_terms; ca_ptr; ca_ptr = ca_ptr->next) {
359         fprintf(fp, "%s\t%d\t%s\t%s\t%s\n", li, ca_ptr->time,
360          STRINGP( ca_ptr->access_type ), ca_ptr->rdn_oc ? "RDN" : "OC",
361         STRINGP( ca_ptr->pattern ));
362     }
363
364 #ifdef TUE_TEL
365     if(glob->ton_urls) {
366         fprintf(fp, "%s\nTON-URLS%s\n", hb, he);
367         fprintf(fp, "%s\t%s\t%s\t%s\t%s\t%s\t%s\n",li,
368        STRINGP( glob->ton_urls->attribute ),
369                  STRINGP( glob->ton_urls->rdn_attr ),
370         STRINGP( glob->ton_urls->redirect ),
371                  STRINGP( glob->ton_urls->x_disp ),
372         STRINGP( glob->ton_urls->base ),
373                  glob->ton_urls->admin?"ADMIN":
374                        glob->ton_urls->pass_oc? glob->ton_urls->pass_oc : "");
375     }
376 #endif
377     if(glob->ip_refuse) {
378         fprintf(fp, "%s\nIP-REFUSE%s\n", hb, he);
379         fprintf(fp, "%s\t%s\t%d\n",li,
380        STRINGP( glob->ip_refuse->dat_file ), glob->ip_refuse->rereadcycle);
381     }
382
383     fprintf(fp, "%s\nSEARCH-ONLY%s\n", hb, he);
384     for(so_ptr = glob->search_only; so_ptr; so_ptr = so_ptr->next) {
385         fprintf(fp, "%s\t%s\t%s\t%s\n", li, STRINGP( so_ptr->dn ),
386          STRINGP( so_ptr->head ), STRINGP( so_ptr->foot ));
387     }
388
389     fprintf(fp, "%s\nSUBTREE-SEARCH%s\n%s", hb, he, li);
390     for(i = 0; glob->subtree_search && glob->subtree_search[i]; i++) 
391         fprintf(fp, "%s:", glob->subtree_search[i]);
392
393     if(glob->index_url) {
394         fprintf(fp, "%s\nINDEX-URL%s\n", hb, he);
395         fprintf(fp, "%s\t%s\t%d\n", li, STRINGP( glob->index_url->dat_file ),
396                 glob->index_url->rereadcycle );
397     }
398
399 #ifdef TUE_TEL
400     if(glob->dit_config) {
401         fprintf(fp, "%s\nDIT-CONFIG%s\n", hb, he);
402         fprintf(fp, "%s\t%s\t%s\t%s\n", li, STRINGP( glob->dit_config->attr ),
403                 STRINGP( glob->dit_config->fetch_dn ),
404                 glob->dit_config->not_browse ? "NOT-BROWSE" : "");
405     }
406 #endif
407
408     fprintf(fp, "%s\nDYNAMIC-GW%s%s %s\n", hb, he, li,
409          glob->gw_switch->dynamic?"YES":"NO");
410     fprintf(fp, "%s\nGW-SWITCH%s\n", hb, he);
411     for(gw_ptr = glob->gw_switch->list; gw_ptr; gw_ptr = gw_ptr->next) {
412         fprintf(fp, "%s\t%s\t%s\n", li, STRINGP( gw_ptr->dn ),
413         STRINGP( gw_ptr->url ));
414     }
415
416     fprintf(fp, "%s\nSORT%s\n", hb, he);
417     for(s_ptr = glob->sort; s_ptr; s_ptr = s_ptr->next) {
418         fprintf(fp, "%s\t%s\t%s\t%d\t%s\t%s\n", li,
419         STRINGP( s_ptr->object_class ),
420          STRINGP( s_ptr->label ), s_ptr->priority,
421         STRINGP( s_ptr->display_class ), STRINGP( s_ptr->sort_attr ));
422     }
423
424     fprintf(fp, "%s\nTABLES%s\n", hb, he);
425     for(ta_ptr = glob->tables; ta_ptr; ta_ptr = ta_ptr->next) {
426         fprintf(fp, "%s\t%s\t%s\t%s\t%s\n", li, ta_ptr->allow ? "ALLOW" : "ALL",
427          STRINGP( ta_ptr->select_oc ), STRINGP( ta_ptr->button_label ),
428         STRINGP( ta_ptr->dn_extension ));
429     }
430
431     fprintf(fp, "%s\nFORM-BUTTON%s\n", hb, he);
432     for(fo_ptr = glob->form_button; fo_ptr; fo_ptr = fo_ptr->next) {
433         fprintf(fp, "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n", li,
434             fo_ptr->read_menu ? "READ" : "MENU",
435             STRINGP( fo_ptr->object_class ), STRINGP( fo_ptr->method ),
436             STRINGP( fo_ptr->script_url ), STRINGP( fo_ptr->text ),
437             STRINGP( fo_ptr->dn_name ), STRINGP( fo_ptr->form_name ),
438             STRINGP( fo_ptr->button_label ));
439     }
440
441     fprintf(fp, "%s\nINDIRECT-ATTRS%s", hb, he);
442     for(i_ptr = glob->ind_attrs; i_ptr; i_ptr = i_ptr->next) {
443         fprintf(fp, "%s %s\n%s", li, STRINGP( i_ptr->ref_attr ), lb );
444         for(idx = i_ptr->ia_arr, i=0; idx[i].key; i++)
445             fprintf(fp, "%s\t%s\t%s\t%s\t%s\t%d\t%s\n", li, idx[i].key,
446              idx[i].replace == 2 ? "FUNCTION" : idx[i].replace ? "REPLACE" :
447              "APPEND", STRINGP( idx[i].attr ), STRINGP( idx[i].host ),
448         idx[i].port, STRINGP( idx[i].base ));
449         fprintf(fp, le);
450     }
451     fprintf(fp, le);
452
453     fprintf(fp, "%s\nMODIFY%s", hb, he);
454     for(m_ptr = glob->modify; m_ptr; m_ptr = m_ptr->next) {
455         fprintf(fp, "%s %s\n%s", li, STRINGP( m_ptr->ocs ), lb );
456         for(mod_ptr = m_ptr->modattr; mod_ptr; mod_ptr = mod_ptr->next)
457             fprintf(fp, "%s\t%s\t%s\t%d\n", li, STRINGP( mod_ptr->attribute ),
458          STRINGP( mod_ptr->label ), mod_ptr->count);
459     }
460     fprintf(fp, le);
461
462     fprintf(fp, "%s\nDISPLAY-OBJECT%s", hb, he);
463     for(d_ptr = glob->display; d_ptr; d_ptr = d_ptr->next) {
464         fprintf(fp, "%s\n\n %s\n%s", li, STRINGP( d_ptr->ocs) , lb );
465         fprintf(fp, "%sFIRST-PAGE:\n%s", li, lb);
466         for(dis_ptr = d_ptr->first_page; dis_ptr; dis_ptr = dis_ptr->next)
467             fprintf(fp, "%s\t%s\t%s\t%s\n", li, STRINGP( dis_ptr->attribute ),
468          STRINGP( dis_ptr->label ), STRINGP( dis_ptr->type ));
469         fprintf(fp, "%s%sSECOND-PAGE:\n%s", le, li, lb);
470         for(dis_ptr = d_ptr->second_page; dis_ptr; dis_ptr = dis_ptr->next)
471             fprintf(fp, "%s\t%s\t%s\t%s\n", li, STRINGP( dis_ptr->attribute ),
472          STRINGP( dis_ptr->label ), STRINGP( dis_ptr->type ));
473         fprintf(fp, "%s%s", le, le);
474     }
475     fprintf(fp, le);
476 }
477 /* end of function: output */
478
479 PRIVATE void main_loop(fp,glob)
480 FILE *fp;
481 GLOB_STRUCT *glob;
482 {
483 FILELINE inLine;
484 extern PARSE_ENTRY parse_table[];
485
486     while(do_readf(&inLine, fp)){
487         parse(&inLine, parse_table, glob, 0);
488     }
489 }
490 /* end of function: main_loop */
491
492 PUBLIC int do_readf(inLine, fp)
493 FILE *fp;
494 FILELINE *inLine;
495 {
496 static FILE *fo;
497 static int lineCount = 0;
498
499     if(fp)
500         fo = fp;
501
502     do {
503         char *comment;
504
505         if(!fgets(inLine->value, BUFSIZ-1, fo)){
506             lineCount = 0;
507             return(0);
508         }
509         lineCount++;
510         if( (comment = strchr(inLine->value, '#')) )
511             *comment = '\0';
512         trim(inLine->value, " \t\n");
513     } while(!*inLine->value);
514
515     inLine->count = lineCount;
516 /*    printf("%d: %s\n", inLine->count, inLine->value);
517 */
518     return (inLine->count);
519 }
520 /* end of function: do_readf */
521
522 PRIVATE int parse(inLine, p_table, glob, level)
523 FILELINE *inLine;
524 PARSE_ENTRY *p_table;
525 GLOB_STRUCT *glob;
526 int level;
527 {
528 int lineCount = inLine->count;
529
530     while(1){
531         switch(parse2(inLine, p_table, glob, level)){
532             case NOTOK:
533                 printf("Error in init-file line %d:\n%s\n ", inLine->count, inLine->value);
534                 exit(1);
535             case DONE:
536                 if(lineCount == inLine->count)
537                     return (DONE);
538                 else
539                     lineCount = inLine->count;
540                 break;
541             default:
542                 return (OK);
543         }
544     }
545 }
546 /* end of function: parse */
547
548 PRIVATE int parse2(inLine, p_table, glob, level)
549 FILELINE *inLine;
550 PARSE_ENTRY *p_table;
551 GLOB_STRUCT *glob;
552 int level;
553 {
554 PARSE_ENTRY *disp;
555 char keyWord[BUFSIZ];
556
557     sscanf(inLine->value, "%s", keyWord);
558     str_toupper( keyWord );
559     for(disp=p_table; disp->keyWord; disp++) {
560         if(!strcmp(keyWord, disp->keyWord)){
561             return ((*disp->keyFunc)(inLine, disp, glob, level));
562         }
563     }
564     return (level?DONE:NOTOK);
565 }
566 /* end of function: parse2 */
567
568 PUBLIC int get_str_param(inLine, str, glob, lower)
569 FILELINE *inLine;
570 char **str;
571 GLOB_STRUCT *glob;
572 int          lower;
573 {
574 char tmp[4*BUFSIZ];
575
576     if(strchr(inLine->value, '"')) {
577         if (sscanf(inLine->value, "%*[^\"]\"%[^\"]", tmp) < 1)
578             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
579     }else
580         if (sscanf(inLine->value, "%*s%s", tmp) < 1)
581             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
582
583     do {
584         if(*str) {
585             *str = realloc(*str, strlen(*str) + strlen(tmp) +1 );
586             strcat(*str, lower ? str_tolower( tmp ) : tmp );
587         } else {
588             *str = strdup( lower ? str_tolower( tmp ) : tmp );
589         }
590             
591         if(!do_readf(inLine, NULL))
592             return (OK);
593
594         if(strchr(inLine->value, '"')) {
595             if (sscanf(inLine->value, "%*[^\"]\"%[^\"]", tmp) < 1)
596                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
597         }else
598             if (sscanf(inLine->value, "%s", tmp) < 1)
599                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
600
601      } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
602
603     return (DONE);
604 }
605 /* end of function: get_str_param */
606
607 PRIVATE int get_int_param(inLine, integer, glob)
608 FILELINE *inLine;
609 int *integer;
610 GLOB_STRUCT *glob;
611 {
612 char tmp[BUFSIZ];
613
614     if (sscanf(inLine->value, "%*s%s", tmp) < 1)
615         fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
616     *integer = atoi(tmp);
617     return (OK);
618 }
619 /* end of function: get_int_param */
620
621
622 PRIVATE int webdn(inLine, disp, glob, level)
623 FILELINE *inLine;
624 PARSE_ENTRY *disp;
625 GLOB_STRUCT *glob;
626 int level;
627 {
628     return(get_str_param(inLine, &glob->webdn, glob, 0));
629 }
630 /* end of function: webdn */
631
632 PRIVATE int webpw(inLine, disp, glob, level)
633 FILELINE *inLine;
634 PARSE_ENTRY *disp;
635 GLOB_STRUCT *glob;
636 int level;
637 {
638     return(get_str_param(inLine, &glob->webpw, glob, 0));
639 }
640 /* end of function: webpw */
641
642 PRIVATE int webdn2(inLine, disp, glob, level)
643 FILELINE *inLine;
644 PARSE_ENTRY *disp;
645 GLOB_STRUCT *glob;
646 int level;
647 {
648     return(get_str_param(inLine, &glob->webdn2, glob, 0));
649 }
650 /* end of function: webdn2 */
651
652 PRIVATE int webpw2(inLine, disp, glob, level)
653 FILELINE *inLine;
654 PARSE_ENTRY *disp;
655 GLOB_STRUCT *glob;
656 int level;
657 {
658     return(get_str_param(inLine, &glob->webpw2, glob, 0));
659 }
660 /* end of function: webpw2 */
661
662
663 PRIVATE int webport(inLine, disp, glob, level)
664 FILELINE *inLine;
665 PARSE_ENTRY *disp;
666 GLOB_STRUCT *glob;
667 int level;
668 {
669     return(get_int_param(inLine, &glob->webport, glob));
670 }
671 /* end of function: webport */
672
673 PRIVATE int timeout(inLine, disp, glob, level)
674 FILELINE *inLine;
675 PARSE_ENTRY *disp;
676 GLOB_STRUCT *glob;
677 int level;
678 {
679     return(get_int_param(inLine, &glob->timeout, glob));
680 }
681 /* end of function: timeout */
682
683 PRIVATE int hostname(inLine, disp, glob, level)
684 FILELINE *inLine;
685 PARSE_ENTRY *disp;
686 GLOB_STRUCT *glob;
687 int level;
688 {
689 char hostname[BUFSIZ];
690 char *virtualport;
691
692     if (sscanf(inLine->value, "%*s%s", hostname) < 1)
693             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
694
695     if( ( virtualport = strchr(hostname, ':')) ) {
696         *virtualport++ = '\0';
697         glob->virtualport = atoi( virtualport );
698     }
699     glob->hostname = strdup( hostname );
700     return (OK);
701 }
702 /* end of function: hostname */
703
704 PRIVATE int ldapd(inLine, disp, glob, level)
705 FILELINE *inLine;
706 PARSE_ENTRY *disp;
707 GLOB_STRUCT *glob;
708 int level;
709 {
710     return(get_str_param(inLine, &glob->ldapd, glob, 1));
711 }
712 /* end of function: ldapd */
713
714 PRIVATE int ldapportf(inLine, disp, glob, level)
715 FILELINE *inLine;
716 PARSE_ENTRY *disp;
717 GLOB_STRUCT *glob;
718 int level;
719 {
720     return(get_int_param(inLine, &glob->ldapport, glob));
721 }
722 /* end of function: ldapportf */
723
724 PRIVATE int etcdir(inLine, disp, glob, level)
725 FILELINE *inLine;
726 PARSE_ENTRY *disp;
727 GLOB_STRUCT *glob;
728 int level;
729 {
730     return(get_str_param(inLine, &glob->etcdir, glob, 0));
731 }
732 /* end of function: etcdir */
733
734 PRIVATE int filterfilef(inLine, disp, glob, level)
735 FILELINE *inLine;
736 PARSE_ENTRY *disp;
737 GLOB_STRUCT *glob;
738 int level;
739 {
740     return(get_str_param(inLine, &glob->filterfile, glob, 0));
741 }
742 /* end of function: filterfile */
743
744 PRIVATE int helpfilef(inLine, disp, glob, level)
745 FILELINE *inLine;
746 PARSE_ENTRY *disp;
747 GLOB_STRUCT *glob;
748 int level;
749 {
750     return(get_str_param(inLine, &glob->helpfile, glob, 0));
751 }
752 /* end of function: helpfile */
753
754 PRIVATE int friendlyfilef(inLine, disp, glob, level)
755 FILELINE *inLine;
756 PARSE_ENTRY *disp;
757 GLOB_STRUCT *glob;
758 int level;
759 {
760     return(get_str_param(inLine, &glob->friendlyfile, glob, 0));
761 }
762 /* end of function: friendlyfile */
763
764 PRIVATE int index_url(inLine, disp, glob, level)
765 FILELINE *inLine;
766 PARSE_ENTRY *disp;
767 GLOB_STRUCT *glob;
768 int level;
769 {
770     char dat_file[BUFSIZ];
771     char rereadcycle[BUFSIZ];
772
773     if (sscanf(inLine->value, "%*s%s%s", dat_file, rereadcycle) < 1)
774         fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n",
775                 glob->acfilename, inLine->count, inLine->value);
776
777     glob->index_url  = (INDEX_URL *) ch_calloc(1, sizeof(INDEX_URL));
778     glob->index_url->dat_file = strdup( dat_file );
779     glob->index_url->rereadcycle = atoi(rereadcycle);
780
781     get_index_url_rules(glob);
782
783     return (OK);
784 }  /*  index_url  */
785
786 PUBLIC void get_index_url_rules(glob)
787 GLOB_STRUCT *glob;
788 {
789 char index[BUFSIZ];
790 char rule[BUFSIZ];
791 char dit_dn[BUFSIZ];
792 FILE *dfp;
793 char  inLine[BUFSIZ];
794 int idx;
795
796     if ( !glob->index_url || !glob->index_url->dat_file )
797         return;
798     if(!(dfp = fopen(glob->index_url->dat_file, "r")))
799         return;
800
801     for ( idx = 0; idx < INDEX_RULE_SIZE; idx++ ) {
802         free( glob->index_url->rarr[idx].rule );
803         free( glob->index_url->rarr[idx].dit_dn );
804     }
805
806     while(fgets(inLine, BUFSIZ-1, dfp)) {
807
808         if(strchr(inLine, '"')) {
809             if (sscanf(inLine, "%s%s%*[^\"]\"%[^\"]\"",
810                                     index, rule, dit_dn) < 1)
811                 syslog (LOG_INFO, "Error in index_url-file");
812         } else {
813             if (sscanf(inLine, "%s%s%s",
814                                    index, rule, dit_dn) < 1)
815                 syslog (LOG_INFO, "Error in index_url-file");
816         }
817         idx = atoi(index);
818         if ( idx < 0 || idx >= INDEX_RULE_SIZE )
819             continue;
820         glob->index_url->rarr[idx].rule = str_tolower( strdup( rule ));
821         glob->index_url->rarr[idx].dit_dn = strdup( dit_dn );
822     }
823     fclose( dfp );
824 }
825 /* end of function: get_index_url_rules */
826
827 PUBLIC void re_read_index_url_rules( glob )
828 GLOB_STRUCT   *glob;
829 {
830         static int index_url_rules_reload = 0;
831
832         if ( glob->index_url && glob->index_url->rereadcycle && !( ++index_url_rules_reload % glob->index_url->rereadcycle )) {
833                 get_index_url_rules( glob );
834         }
835
836 }  /*  re_read_index_url_rules  */
837
838
839 PRIVATE int allow_proxy(inLine, disp, glob, level)
840 FILELINE *inLine;
841 PARSE_ENTRY *disp;
842 GLOB_STRUCT *glob;
843 int level;
844 {
845 char tmp[BUFSIZ];
846
847     if(strchr(inLine->value, '"')) {
848         if (sscanf(inLine->value, "%*[^\"]\"%[^\"]", tmp) < 1)
849             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
850     }else
851         if (sscanf(inLine->value, "%*s%s", tmp) < 1)
852             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
853
854     glob->allow_proxy = str2charray( str_tolower(tmp), ":");
855     return (OK);
856 }
857 /* end of function: allow_proxy */
858
859 PRIVATE int subtree_search(inLine, disp, glob, level)
860 FILELINE *inLine;
861 PARSE_ENTRY *disp;
862 GLOB_STRUCT *glob;
863 int level;
864 {
865 char tmp[BUFSIZ];
866
867     if(strchr(inLine->value, '"')) {
868         if (sscanf(inLine->value, "%*[^\"]\"%[^\"]", tmp) < 1)
869             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
870     }else
871         if (sscanf(inLine->value, "%*s%s", tmp) < 1)
872             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
873
874     glob->subtree_search = str2charray( tmp, ":");
875     return (OK);
876 }
877 /* end of function: subtree_search */
878
879 PRIVATE int grant(inLine, disp, glob, level)
880 FILELINE *inLine;
881 PARSE_ENTRY *disp;
882 GLOB_STRUCT *glob;
883 int level;
884 {
885     return(get_str_param(inLine, &glob->grant, glob, 1));
886 }
887 /* end of function: grant */
888
889 PRIVATE int refuse(inLine, disp, glob, level)
890 FILELINE *inLine;
891 PARSE_ENTRY *disp;
892 GLOB_STRUCT *glob;
893 int level;
894 {
895     return(get_str_param(inLine, &glob->refuse, glob, 1));
896 }
897 /* end of function: refuse */
898
899 PRIVATE int allow_string(inLine, disp, glob, level)
900 FILELINE *inLine;
901 PARSE_ENTRY *disp;
902 GLOB_STRUCT *glob;
903 int level;
904 {
905     return(get_str_param(inLine, &glob->allow_string, glob, 1));
906 }
907 /* end of function: allow_string */
908
909 PRIVATE int deny_string(inLine, disp, glob, level)
910 FILELINE *inLine;
911 PARSE_ENTRY *disp;
912 GLOB_STRUCT *glob;
913 int level;
914 {
915     return(get_str_param(inLine, &glob->deny_string, glob, 1));
916 }
917 /* end of function: deny_string */
918
919
920 PRIVATE int show_defoc(inLine, disp, glob, level)
921 FILELINE *inLine;
922 PARSE_ENTRY *disp;
923 GLOB_STRUCT *glob;
924 int level;
925 {
926
927     glob->show_defoc = 1;
928     return (OK);
929 }
930 /* end of function: show_defoc */
931
932 PRIVATE int max_person(inLine, disp, glob, level)
933 FILELINE *inLine;
934 PARSE_ENTRY *disp;
935 GLOB_STRUCT *glob;
936 int level;
937 {
938 char tmp[BUFSIZ];
939 char tmp2[BUFSIZ];
940 char tmp3[BUFSIZ];
941
942     if (sscanf(inLine->value, "%*s%s%s%s", tmp, tmp2, tmp3) < 1)
943         fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
944     glob->max_person = atoi(tmp);
945     glob->strict = (!strcasecmp (tmp2, "strict") || !strcasecmp (tmp3, "strict")) ? TRUE : FALSE;
946     glob->no_browse = (!strcasecmp (tmp2, "no-browse") || !strcasecmp (tmp3, "no-browse")) ? TRUE : FALSE;
947
948     return (OK);
949 }
950 /* end of function: max_person */
951
952 PRIVATE int comrefuse(inLine, disp, glob, level)
953 FILELINE *inLine;
954 PARSE_ENTRY *disp;
955 GLOB_STRUCT *glob;
956 int level;
957 {
958     char tmp[BUFSIZ];
959     char tmp2[BUFSIZ];
960     char tmp3[BUFSIZ];
961     char tmp4[BUFSIZ];
962     char tmp5[BUFSIZ];
963     char tmp6[BUFSIZ];
964
965     if (sscanf(inLine->value, "%*s%s%s%s%s%s%s",
966                       tmp, tmp2, tmp3, tmp4, tmp5, tmp6) < 1)
967         fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
968     comRefuseP = glob->comrefuse = 
969                            (COMREFUSE *) ch_calloc(1, sizeof(COMREFUSE));
970     glob->comrefuse->tmin = atoi(tmp);
971     glob->comrefuse->tdiff = atoi(tmp2) - glob->comrefuse->tmin;
972     glob->comrefuse->maxAccept = atoi(tmp3);
973     glob->comrefuse->suspendCycle = -1 * atoi(tmp4);
974     glob->comrefuse->statCycle = (time_t) atol (tmp5);
975     sprintf (tmp6, "%s.%s-%d", tmp6, glob->lang, (int) getpid());
976     glob->comrefuse->statFile = strdup (tmp6);
977
978     return (OK);
979 }
980 /* end of function: comrefuse */
981
982 PRIVATE int display(inLine, disp, glob, level)
983 FILELINE *inLine;
984 PARSE_ENTRY *disp;
985 GLOB_STRUCT *glob;
986 int level;
987 {
988 char tmp[BUFSIZ];
989 pDISPLAY *d_ptr;
990
991     for(d_ptr = &glob->display; *d_ptr; d_ptr = &(*d_ptr)->next)
992         ;
993     if(strchr(inLine->value, '"')) {
994         if (sscanf(inLine->value, "%*[^\"]\"%[^\"]", tmp) < 1)
995             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
996     } else
997         if (sscanf(inLine->value, "%*s%s", tmp) < 1)
998             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
999     *d_ptr = (pDISPLAY) ch_calloc(1, sizeof(DISPLAY));
1000     (*d_ptr)->ocs = str_tolower( strdup( tmp ));
1001     if(strcmp(tmp, "default"))
1002         glob->default_display_type = *d_ptr;
1003     if(!do_readf(inLine, NULL))
1004                         return (OK);
1005     return (parse(inLine,disp->subTable, glob, ++level));
1006 }
1007 /* end of function: display */
1008
1009 PRIVATE int basednf(inLine, disp, glob, level)
1010 FILELINE *inLine;
1011 PARSE_ENTRY *disp;
1012 GLOB_STRUCT *glob;
1013 int level;
1014 {
1015 char dn[BUFSIZ];
1016 char head[BUFSIZ];
1017 char foot[BUFSIZ];
1018
1019     if(strchr(inLine->value, '"')) {
1020         if (sscanf(inLine->value, "%*[^\"]\"%[^\"]\"%s%s", dn, head, foot) < 1)
1021             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1022      } else
1023         if (sscanf(inLine->value, "%*s%s%s%s", dn, head, foot) < 1)
1024             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1025         if ( !strcasecmp( dn, "ROOT" )) *dn = '\0';
1026     glob->basedn->dn = strdup( dn );
1027     glob->basedn->dnarray = dn2charray( dn );
1028     glob->basedn->head = strdup(head);
1029     glob->basedn->foot = strdup(foot);
1030     return (OK);
1031 }
1032 /* end of function: basednf */
1033
1034 PRIVATE int search_only(inLine, disp, glob, level)
1035 FILELINE *inLine;
1036 PARSE_ENTRY *disp;
1037 GLOB_STRUCT *glob;
1038 int level;
1039 {
1040 char dn[BUFSIZ];
1041 char head[BUFSIZ];
1042 char foot[BUFSIZ];
1043 pSEARCH_ONLY_LINE *so_ptr;
1044
1045     so_ptr = &glob->search_only;
1046     if(strchr(inLine->value, '"')) {
1047         if (sscanf(inLine->value, "%*[^\"]\"%[^\"]\"%s%s", dn, head, foot) < 1)
1048             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1049     } else
1050         if (sscanf(inLine->value, "%*s%s%s%s", dn, head, foot) < 1)
1051             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1052     do {
1053         *so_ptr = (pSEARCH_ONLY_LINE) ch_calloc(1, sizeof(SEARCH_ONLY_LINE));
1054         (*so_ptr)->dn = str_tolower( strdup( dn ));
1055         (*so_ptr)->head = strdup(head);
1056         (*so_ptr)->foot = strdup(foot);
1057         so_ptr = &(*so_ptr)->next;
1058         if(!do_readf(inLine, NULL))
1059                         return (OK);
1060         if(strchr(inLine->value, '"')) {
1061             if (sscanf(inLine->value, "%*[^\"]\"%[^\"]\"%s%s", dn, head, foot) < 1)
1062                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1063         } else
1064             if (sscanf(inLine->value, "%s%s%s", dn, head, foot) < 1)
1065                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1066     } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1067     return (DONE);
1068 }
1069 /* end of function: search_only */
1070
1071 PRIVATE int dynamic_gw(inLine, disp, glob, level)
1072 FILELINE *inLine;
1073 PARSE_ENTRY *disp;
1074 GLOB_STRUCT *glob;
1075 int level;
1076 {
1077
1078     glob->gw_switch->dynamic = 1;
1079     return (OK);
1080 }
1081 /* end of function: dynamic_gw */
1082
1083 PRIVATE int caching_terms(inLine, disp, glob, level)
1084 FILELINE *inLine;
1085 PARSE_ENTRY *disp;
1086 GLOB_STRUCT *glob;
1087 int level;
1088 {
1089 char time[BUFSIZ];
1090 char access_type[BUFSIZ];
1091 char rdn_oc[BUFSIZ];
1092 char pattern[BUFSIZ];
1093 pCACHING_TERMS_LINE *ca_ptr;
1094
1095     ca_ptr = &glob->caching_terms;
1096
1097     if (sscanf(inLine->value, "%*s%s%s%s%s", 
1098                time, access_type, rdn_oc, pattern) < 1)
1099         fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", 
1100                 glob->acfilename, inLine->count, inLine->value);
1101     do {
1102         *ca_ptr = (pCACHING_TERMS_LINE) ch_calloc(1, sizeof(CACHING_TERMS_LINE));
1103         (*ca_ptr)->time = atoi(time);
1104         (*ca_ptr)->access_type = str_toupper(strdup(trim (access_type,WSPACE)));
1105         (*ca_ptr)->rdn_oc = !strncasecmp(rdn_oc, "RDN", 3) ? 1 : 0;
1106         (*ca_ptr)->pattern = str_tolower(strdup(trim (pattern, WSPACE)));
1107         ca_ptr = &(*ca_ptr)->next;
1108         if(!do_readf(inLine, NULL))
1109                         return (OK);
1110         if (sscanf(inLine->value, "%s%s%s%s", 
1111                    time, access_type, rdn_oc, pattern) < 1)
1112             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n",
1113                     glob->acfilename, inLine->count, inLine->value);
1114     } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1115     return (DONE);
1116 }
1117 /* end of function: caching_terms */
1118
1119 PRIVATE int gw_switch(inLine, disp, glob, level)
1120 FILELINE *inLine;
1121 PARSE_ENTRY *disp;
1122 GLOB_STRUCT *glob;
1123 int level;
1124 {
1125 char dn[BUFSIZ];
1126 char url[BUFSIZ];
1127 pGW_SWITCH_LINE *gw_ptr;
1128
1129         for(gw_ptr = &glob->gw_switch->list; *gw_ptr; gw_ptr = &(*gw_ptr)->next)
1130                 ;
1131     if(strchr(inLine->value, '"')) {
1132         if (sscanf(inLine->value, "%*[^\"]\"%[^\"]\"%[\40-\177]", dn, url) < 1)
1133             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1134     } else
1135         if (sscanf(inLine->value, "%*s%s%[\40-\177]", dn, url) < 1)
1136             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1137     do {
1138         *gw_ptr = (pGW_SWITCH_LINE) ch_calloc(1, sizeof(GW_SWITCH_LINE));
1139         (*gw_ptr)->dn = str_tolower( strdup( dn ));
1140         (*gw_ptr)->url = strdup(trim (url, WSPACE));
1141         gw_ptr = &(*gw_ptr)->next;
1142         if(!do_readf(inLine, NULL))
1143                         return (OK);
1144         if(strchr(inLine->value, '"')) {
1145             if (sscanf(inLine->value, "%*[^\"]\"%[^\"]\"%[\40-\177]", dn, url) < 1)
1146                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1147         } else
1148             if (sscanf(inLine->value, "%s%[\40-\177]", dn, url) < 1)
1149                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1150     } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1151     return (DONE);
1152 }
1153 /* end of function: gw_switch */
1154
1155 PRIVATE int table_disp(inLine, disp, glob, level)
1156 FILELINE *inLine;
1157 PARSE_ENTRY *disp;
1158 GLOB_STRUCT *glob;
1159 int level;
1160 {
1161     char allow[BUFSIZ];
1162     char select_oc[BUFSIZ];
1163     char button_label[BUFSIZ];
1164     char dn_extension[BUFSIZ];
1165     pTABLE_DISPLAY *ta_ptr;
1166
1167         for(ta_ptr = &glob->tables; *ta_ptr; ta_ptr = &(*ta_ptr)->next)
1168                 ;
1169         if (sscanf(inLine->value, "%*s%s%s%s%s", allow, select_oc, button_label, dn_extension) < 1)
1170             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1171     do {
1172         *ta_ptr = (pTABLE_DISPLAY) ch_calloc(1, sizeof(TABLE_DISPLAY));
1173         (*ta_ptr)->allow = !strcasecmp(allow, "ALLOW") ? 1 : 0;
1174         (*ta_ptr)->select_oc = str_tolower( strdup( select_oc ));
1175         (*ta_ptr)->button_label = strdup( button_label );
1176         (*ta_ptr)->dn_extension = str_tolower( strdup( dn_extension ));
1177         ta_ptr = &(*ta_ptr)->next;
1178         if(!do_readf(inLine, NULL))
1179                         return (OK);
1180         if (sscanf(inLine->value, "%s%s%s%s", allow, select_oc, button_label, dn_extension) < 1)
1181             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1182     } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1183     return (DONE);
1184 }
1185 /* end of function: table_disp */
1186
1187 PRIVATE int modify(inLine, disp, glob, level)
1188 FILELINE *inLine;
1189 PARSE_ENTRY *disp;
1190 GLOB_STRUCT *glob;
1191 int level;
1192 {
1193     char tmp[BUFSIZ];
1194     pMODIF *m_ptr;
1195
1196     sprintf (tmp, "|");
1197     for(m_ptr = &glob->modify; *m_ptr; m_ptr = &(*m_ptr)->next)
1198                 ;
1199     if(strchr(inLine->value, '"')) {
1200         if (sscanf(inLine->value, "%*[^\"]\"%[^\"]", tmp+1) < 1)
1201             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1202     } else
1203         if (sscanf(inLine->value, "%*s%s", tmp+1) < 1)
1204             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1205
1206     *m_ptr = (pMODIF) ch_calloc(1, sizeof(MODIF));
1207     strcat (tmp, "|");
1208     (*m_ptr)->ocs = str_tolower (tr1 (strdup(tmp), ' ', '|'));
1209
1210     if(!do_readf(inLine, NULL)) return (NOTOK);
1211     return (parse(inLine,disp->subTable, glob, ++level));
1212 }
1213 /* end of function: modify */
1214
1215 PRIVATE int ind_attrs(inLine, disp, glob, level)
1216 FILELINE *inLine;
1217 PARSE_ENTRY *disp;
1218 GLOB_STRUCT *glob;
1219 int level;
1220 {
1221     char tmp[BUFSIZ];
1222     pIND_ATTRS *i_ptr;
1223
1224     for(i_ptr = &glob->ind_attrs; *i_ptr; i_ptr = &(*i_ptr)->next)
1225                 ;
1226     if (sscanf(inLine->value, "%*s%s", tmp) < 1)
1227         fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1228
1229     *i_ptr = (pIND_ATTRS) ch_calloc(1, sizeof(IND_ATTRS));
1230     (*i_ptr)->ref_attr = str_tolower(strdup(tmp));
1231
1232     if(!do_readf(inLine, NULL)) return (NOTOK);
1233     return (parse(inLine,disp->subTable, glob, ++level));
1234 }
1235 /* end of function: ind_attrs */
1236
1237 PRIVATE int cache_expire(inLine, disp, glob, level)
1238 FILELINE *inLine;
1239 PARSE_ENTRY *disp;
1240 GLOB_STRUCT *glob;
1241 int level;
1242 {
1243     return(get_int_param(inLine, &glob->cache_expire, glob));
1244 }
1245 /* end of function: cache_expire */
1246
1247 PRIVATE int maxcount(inLine, disp, glob, level)
1248 FILELINE *inLine;
1249 PARSE_ENTRY *disp;
1250 GLOB_STRUCT *glob;
1251 int level;
1252 {
1253     return(get_int_param(inLine, &glob->maxcount, glob));
1254 }
1255 /* end of function: maxcount */
1256
1257 PRIVATE int language(inLine, disp, glob, level)
1258 FILELINE *inLine;
1259 PARSE_ENTRY *disp;
1260 GLOB_STRUCT *glob;
1261 int level;
1262 {
1263 char tmp[BUFSIZ];
1264 int slots = 2, i = 0;
1265
1266     glob->language = (char **) ch_calloc(slots+1, sizeof(char **));
1267     if (sscanf(inLine->value, "%*s%s", tmp) < 1)
1268         fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1269     do {
1270         if(i == slots){
1271             slots *= 2;
1272             glob->language =  (char **) ch_realloc((char *)glob->language, (slots+1)*sizeof(char **));
1273         }
1274         glob->language[i++] = strdup(tmp);
1275         if(!do_readf(inLine, NULL))
1276                         return (OK);
1277         if (sscanf(inLine->value, "%s", tmp) < 1)
1278             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1279     } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1280     return (DONE);
1281 }
1282 /* end of function: language */
1283
1284 PRIVATE int strict_basedn(inLine, disp, glob, level)
1285 FILELINE *inLine;
1286 PARSE_ENTRY *disp;
1287 GLOB_STRUCT *glob;
1288 int level;
1289 {
1290
1291     glob->strict_basedn = 1;
1292     return (OK);
1293 }
1294 /* end of function: strict_basedn */
1295
1296 PRIVATE int pull_down_menus(inLine, disp, glob, level)
1297 FILELINE *inLine;
1298 PARSE_ENTRY *disp;
1299 GLOB_STRUCT *glob;
1300 int level;
1301 {
1302
1303     glob->pull_down_menus = 1;
1304     return (OK);
1305 }
1306 /* end of function: pull_down_menus */
1307
1308 PRIVATE int no_proxy(inLine, disp, glob, level)
1309 FILELINE *inLine;
1310 PARSE_ENTRY *disp;
1311 GLOB_STRUCT *glob;
1312 int level;
1313 {
1314
1315     glob->no_proxy = 1;
1316     return (OK);
1317 }
1318 /* end of function: no_proxy */
1319
1320 PRIVATE int disp_sea_rdn(inLine, disp, glob, level)
1321 FILELINE *inLine;
1322 PARSE_ENTRY *disp;
1323 GLOB_STRUCT *glob;
1324 int level;
1325 {
1326
1327     glob->disp_sea_rdn = 1;
1328     return (OK);
1329 }
1330 /* end of function: disp_sea_rdn */
1331
1332 PRIVATE int prefer_ref_uris(inLine, disp, glob, level)
1333 FILELINE *inLine;
1334 PARSE_ENTRY *disp;
1335 GLOB_STRUCT *glob;
1336 int level;
1337 {
1338
1339     glob->prefer_ref_uris = 1;
1340     return (OK);
1341 }
1342 /* end of function: prefer_ref_uris */
1343
1344 PRIVATE int strip_pin(inLine, disp, glob, level)
1345 FILELINE *inLine;
1346 PARSE_ENTRY *disp;
1347 GLOB_STRUCT *glob;
1348 int level;
1349 {
1350
1351     return(get_str_param(inLine, &glob->strip_pin, glob, 1));
1352 }
1353 /* end of function: strip_pin */
1354
1355 PRIVATE int legal(inLine, disp, glob, level)
1356 FILELINE *inLine;
1357 PARSE_ENTRY *disp;
1358 GLOB_STRUCT *glob;
1359 int level;
1360 {
1361 char tmp[BUFSIZ];
1362
1363     sscanf(inLine->value, "%*s%s", tmp);
1364     glob->legal = 1;
1365     glob->legal_top = tmp && !strcasecmp(tmp, "ON-TOP");
1366     return (OK);
1367 }
1368 /* end of function: legal */
1369
1370 PRIVATE int no_modify(inLine, disp, glob, level)
1371 FILELINE *inLine;
1372 PARSE_ENTRY *disp;
1373 GLOB_STRUCT *glob;
1374 int level;
1375 {
1376     return(get_str_param(inLine, &glob->no_modify, glob, 1));
1377 }
1378 /* end of function: no_modify */
1379
1380 PRIVATE int no_show_rdn(inLine, disp, glob, level)
1381 FILELINE *inLine;
1382 PARSE_ENTRY *disp;
1383 GLOB_STRUCT *glob;
1384 int level;
1385 {
1386     return(get_str_param(inLine, &glob->no_show_rdn, glob, 1));
1387 }
1388 /* end of function: no_show_rdn */
1389
1390 PRIVATE int sort(inLine, disp, glob, level)
1391 FILELINE *inLine;
1392 PARSE_ENTRY *disp;
1393 GLOB_STRUCT *glob;
1394 int level;
1395 {
1396     char object_class[BUFSIZ];
1397     char label[BUFSIZ];
1398     char priority[BUFSIZ];
1399     char display_class[BUFSIZ];
1400     char sort_attr[BUFSIZ];
1401     pSORT_LINE *s_ptr;
1402
1403     s_ptr = &glob->sort;
1404     strcpy(sort_attr, "sn");
1405     strcpy( display_class, "default" );
1406
1407     if(strchr(inLine->value, '"')) {
1408         if (sscanf(inLine->value, "%*s%s%*[^\"]\"%[^\"]\"%s%s%s", object_class, label, priority, display_class, sort_attr) < 1)
1409             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1410
1411     } else
1412         if (sscanf(inLine->value, "%*s%s%s%s%s%s", object_class, label, priority, display_class, sort_attr) < 1)
1413             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1414     do {
1415         char tmpBuf[BUFSIZ];
1416
1417         *s_ptr = (pSORT_LINE) ch_calloc(1, sizeof(SORT_LINE));
1418         sprintf (tmpBuf, "|%s|", object_class);
1419         (*s_ptr)->object_class = str_tolower (strdup(tmpBuf));
1420         (*s_ptr)->label = strdup(label);
1421         (*s_ptr)->priority = atoi(priority);
1422         (*s_ptr)->display_class = str_tolower( strdup( display_class ));
1423         (*s_ptr)->sort_attr = strdup( str_tolower( sort_attr ));
1424         s_ptr = &(*s_ptr)->next;
1425
1426         if(!charray_inlist(glob->sort_attribs, sort_attr))
1427             charray_add(&glob->sort_attribs, sort_attr );
1428
1429         if(!do_readf(inLine, NULL))
1430             return (OK);
1431
1432         strcpy(sort_attr, "sn");
1433         strcpy( display_class, "default" );
1434
1435         if(strchr(inLine->value, '"')) {
1436             if (sscanf(inLine->value, "%s%*[^\"]\"%[^\"]\"%s%s%s", object_class, label, priority, display_class, sort_attr) < 1)
1437                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1438         } else
1439             if (sscanf(inLine->value, "%s%s%s%s%s", object_class, label, priority, display_class, sort_attr) < 1)
1440                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1441
1442     } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1443
1444     return (DONE);
1445 }
1446 /* end of function: sort */
1447
1448 PRIVATE int form_button(inLine, disp, glob, level)
1449 FILELINE *inLine;
1450 PARSE_ENTRY *disp;
1451 GLOB_STRUCT *glob;
1452 int level;
1453 {
1454     char read_menu[BUFSIZ];
1455     char object_class[BUFSIZ];
1456     char method[BUFSIZ];
1457     char script_url[BUFSIZ];
1458     char text[BUFSIZ];
1459     char dn_name[BUFSIZ];
1460     char form_name[BUFSIZ];
1461     char button_label[BUFSIZ];
1462     pFORM_BUTTON *f_ptr;
1463
1464     f_ptr = &glob->form_button;
1465 /*    for(f_ptr = &glob->form_button; (*f_ptr)->next; f_ptr = &(*f_ptr)->next)
1466             ;
1467 */
1468
1469     if(strchr(inLine->value, '"')) {
1470         if (sscanf(inLine->value, "%*s%s%s%s%s%*[^\"]\"%[^\"]\"%s%s%s", read_menu, object_class, method, script_url, text, dn_name, form_name, button_label) < 1)
1471             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1472
1473     } else
1474         if (sscanf(inLine->value, "%*s%s%s%s%s%s%s%s%s", read_menu, object_class, method, script_url, text, dn_name, form_name, button_label) < 1)
1475             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1476
1477     do {
1478
1479         *f_ptr = (pFORM_BUTTON) ch_calloc(1, sizeof(FORM_BUTTON));
1480         (*f_ptr)->read_menu = strcasecmp(read_menu, "READ") ? 0 : 1;
1481         (*f_ptr)->object_class = strdup(object_class);
1482         (*f_ptr)->method = strdup(method);
1483         (*f_ptr)->script_url = strdup(script_url);
1484         (*f_ptr)->text = strdup(text);
1485         (*f_ptr)->dn_name = strdup(dn_name);
1486         (*f_ptr)->form_name = strdup(form_name);
1487         (*f_ptr)->button_label = strdup(button_label);
1488         f_ptr = &(*f_ptr)->next;
1489
1490         if(!do_readf(inLine, NULL))
1491             return (OK);
1492
1493         if(strchr(inLine->value, '"')) {
1494             if (sscanf(inLine->value, "%s%s%s%s%*[^\"]\"%[^\"]\"%s%s%s", read_menu, object_class, method, script_url, text, dn_name, form_name, button_label) < 1)
1495                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1496         } else
1497             if (sscanf(inLine->value, "%s%s%s%s%s%s%s%s", read_menu, object_class, method, script_url, text, dn_name, form_name, button_label) < 1)
1498                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1499
1500     } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1501
1502     return (DONE);
1503 }
1504 /* end of function: form_button */
1505
1506 PRIVATE int firstPage(inLine, disp, glob, level)
1507 FILELINE *inLine;
1508 PARSE_ENTRY *disp;
1509 GLOB_STRUCT *glob;
1510 int level;
1511 {
1512 char attribute[BUFSIZ];
1513 char label[BUFSIZ];
1514 char type[BUFSIZ];
1515 pDISPLAY_LINE *dis_ptr;
1516 pDISPLAY d_ptr;
1517
1518     if(strchr(inLine->value, '"')) {
1519         if (sscanf(inLine->value, "%*s%s%*[^\"]\"%[^\"]\"%s", attribute, label, type) < 1)
1520             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1521     } else
1522         if (sscanf(inLine->value, "%*s%s%s%s", attribute, label, type) < 1)
1523             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1524     for(d_ptr = glob->display; d_ptr->next; d_ptr = d_ptr->next)
1525         ;
1526     dis_ptr = &d_ptr->first_page;
1527     do {
1528         *dis_ptr = (pDISPLAY_LINE) ch_calloc(1, sizeof(DISPLAY_LINE));
1529         (*dis_ptr)->attribute = str_tolower( strdup( attribute ));
1530         (*dis_ptr)->label = strdup(label);
1531         (*dis_ptr)->type = strdup( str_toupper( type ));
1532         (*dis_ptr)->ty = cnvt_str2int (type, disp_types, "DEFAULT");
1533         if(!do_readf(inLine, NULL))
1534                         return (OK);
1535         if(strchr(inLine->value, '"')) {
1536             if (sscanf(inLine->value, "%s%*[^\"]\"%[^\"]\"%s", attribute, label, type) < 1)
1537                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1538         } else
1539             if (sscanf(inLine->value, "%s%s%s", attribute, label, type) < 1)
1540                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1541         dis_ptr = &(*dis_ptr)->next;
1542
1543     } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1544
1545     return (parse(inLine,disp->subTable, glob, ++level));
1546 }
1547 /* end of function: firstPage */
1548
1549 PRIVATE int secondPage(inLine, disp, glob, level)
1550 FILELINE *inLine;
1551 PARSE_ENTRY *disp;
1552 GLOB_STRUCT *glob;
1553 int level;
1554 {
1555 char attribute[BUFSIZ];
1556 char label[BUFSIZ];
1557 char type[BUFSIZ];
1558 pDISPLAY_LINE *dis_ptr;
1559 pDISPLAY d_ptr;
1560
1561     if(strchr(inLine->value, '"')) {
1562         if (sscanf(inLine->value, "%*s%s%*[^\"]\"%[^\"]\"%s", attribute, label, type) < 1)
1563             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1564     } else
1565         if (sscanf(inLine->value, "%*s%s%s%s", attribute, label, type) < 1)
1566             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1567     for(d_ptr = glob->display; d_ptr->next; d_ptr = d_ptr->next)
1568         ;
1569     dis_ptr = &d_ptr->second_page;
1570     do {
1571         *dis_ptr = (pDISPLAY_LINE) ch_calloc(1, sizeof(DISPLAY_LINE));
1572         (*dis_ptr)->attribute = str_tolower( strdup( attribute ));
1573         (*dis_ptr)->label = strdup(label);
1574         (*dis_ptr)->type = strdup( str_toupper( type ));
1575         (*dis_ptr)->ty = cnvt_str2int (type, disp_types, "DEFAULT");
1576         if(!do_readf(inLine, NULL))
1577                         return (OK);
1578         if(strchr(inLine->value, '"')) {
1579             if (sscanf(inLine->value, "%s%*[^\"]\"%[^\"]\"%s", attribute, label, type) < 1)
1580                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1581         } else
1582             if (sscanf(inLine->value, "%s%s%s", attribute, label, type) < 1)
1583                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1584         dis_ptr = &(*dis_ptr)->next;
1585
1586     } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1587 /*puts("leaving secondpage!");
1588 */
1589
1590     return (DONE);
1591 }
1592 /* end of function: secondPage */
1593
1594 PRIVATE int modattr(inLine, disp, glob, level)
1595 FILELINE *inLine;
1596 PARSE_ENTRY *disp;
1597 GLOB_STRUCT *glob;
1598 int level;
1599 {
1600 char attribute[BUFSIZ];
1601 char label[BUFSIZ];
1602 char count[BUFSIZ];
1603 pMODIFY_LINE *mod_ptr;
1604 pMODIF m_ptr;
1605
1606     if(strchr(inLine->value, '"')) {
1607         if (sscanf(inLine->value, "%*s%s%*[^\"]\"%[^\"]\"%s", attribute, label, count) < 1)
1608             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1609     } else
1610         if (sscanf(inLine->value, "%*s%s%s%s", attribute, label, count) < 1)
1611             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1612
1613         for(m_ptr = glob->modify; m_ptr->next; m_ptr = m_ptr->next)
1614                 ;
1615     mod_ptr = &m_ptr->modattr;
1616     do {
1617         *mod_ptr = (pMODIFY_LINE) ch_calloc(1, sizeof(MODIFY_LINE));
1618         (*mod_ptr)->attribute = str_tolower( strdup( attribute ));
1619         (*mod_ptr)->label = strdup(label);
1620         (*mod_ptr)->count = atoi(count);
1621         if(!do_readf(inLine, NULL))
1622                         return (OK);
1623         if(strchr(inLine->value, '"')) {
1624             if (sscanf(inLine->value, "%s%*[^\"]\"%[^\"]\"%s", attribute, label, count) < 1)
1625                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1626         } else
1627             if (sscanf(inLine->value, "%s%s%s", attribute, label, count) < 1)
1628                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1629         mod_ptr = &(*mod_ptr)->next;
1630
1631     } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1632 /*puts("leaving secondpage!");
1633 */
1634
1635     return (DONE);
1636 }
1637 /* end of function: modattr */
1638
1639 PRIVATE int ind_attribute(inLine, disp, glob, level)
1640 FILELINE *inLine;
1641 PARSE_ENTRY *disp;
1642 GLOB_STRUCT *glob;
1643 int level;
1644 {
1645 char key[BUFSIZ];
1646 char replace[BUFSIZ];
1647 char attribute[BUFSIZ];
1648 char host[BUFSIZ];
1649 char port[BUFSIZ];
1650 char base[BUFSIZ];
1651 pIND_ATTRS i_ptr;
1652 IND_ATTR_ARR **idx;
1653 int i;
1654
1655     if(strchr(inLine->value, '"')) {
1656         if (sscanf(inLine->value, "%*s%s%s%s%s%s%*[^\"]\"%[^\"]\"", key,
1657                               replace, attribute, host, port, base) < 1)
1658             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1659     } else
1660         if (sscanf(inLine->value, "%*s%s%s%s%s%s%s", key, replace, attribute,
1661                                    host, port, base) < 1)
1662             fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1663
1664     for(i_ptr = glob->ind_attrs; i_ptr->next; i_ptr = i_ptr->next)
1665         ;
1666     
1667     idx = &i_ptr->ia_arr;
1668
1669     *idx = (IND_ATTR_ARR *) ch_malloc( 100 * sizeof(IND_ATTR_ARR) );
1670     i = 0;
1671
1672     do {
1673         (*idx)[i].key = strdup(key);
1674         (*idx)[i].replace = !strcasecmp(replace, "function") ? 2 :
1675                             !strcasecmp(replace, "replace") ? 1 : 0;
1676         (*idx)[i].attr = strdup(attribute);
1677         (*idx)[i].host = strdup(host);
1678         (*idx)[i].port = atoi(port);
1679         (*idx)[i].base = strdup(base);
1680         (*idx)[++i].key = NULL;
1681         
1682         if(!do_readf(inLine, NULL))
1683                         return (OK);
1684         if(strchr(inLine->value, '"')) {
1685             if (sscanf(inLine->value, "%s%s%s%s%s%*[^\"]\"%[^\"]\"", key, replace, attribute, host, port, base) < 1)
1686                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1687         } else
1688             if (sscanf(inLine->value, "%s%s%s%s%s%s", key, replace, attribute, host, port, base) < 1)
1689                 fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n", glob->acfilename, inLine->count, inLine->value);
1690
1691     } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1692
1693     return (DONE);
1694 }
1695 /* end of function: ind_attribute */
1696
1697
1698 PUBLIC void langinit(glob)
1699 GLOB_STRUCT *glob;
1700 {
1701     FILE *fp;
1702     char inLine[BUFSIZ], lCountS[BUFSIZ], phrase[BUFSIZ], file[BUFSIZ];
1703
1704     sprintf( file, "%s.lang.%s", glob->argv0, glob->lang );
1705     if(!(fp = fopen(file, "r"))) {
1706         fprintf(stderr, "\n\nATTENTION!!!\n\nCould not open file %s !\n", file);
1707         exit(0);
1708     }
1709     while(fgets(inLine, BUFSIZ-1, fp)) {
1710
1711         /* Comment-sign is accepted in the first column only */
1712         if(*inLine == '#')
1713             *inLine = '\0';
1714         if(*inLine == '\t') {
1715             strcat(strcat(glob->la[atoi(lCountS)], " "), trim(inLine, " \t\n"));
1716             continue;
1717         }
1718         if(!*(trim(inLine, " \t\n"))) continue;
1719         sscanf(trim(inLine, " \t\n"), "%s %[^\n]", lCountS, phrase);
1720         if(*glob->la[atoi(lCountS)])
1721             fprintf(stderr, "\nWarning: glob->la[%s] existed already with value <%s> and was overwritten with value <%s> !\n\n", lCountS, glob->la[atoi(lCountS)], phrase );
1722         strcpy(glob->la[atoi(lCountS)], phrase);
1723     }
1724
1725 }
1726 /* end of function: langinit */
1727
1728 PUBLIC void langoutput(fp, glob, html_flag)
1729 FILE *fp;
1730 GLOB_STRUCT *glob;
1731 int html_flag;
1732 {
1733     int i;
1734
1735     fprintf(fp, "%s\n\n\nLanguage Settings\n\n%s",html_flag ? "<H2>" : "", html_flag ? "</H2>" : "\n");
1736     for(i=0 ; i<LANG_ARR_SIZE; i++)
1737         if(*glob->la[i]) fprintf(fp, "%s%d%s\t%s%s", html_flag ? "<H2>" : "", i, html_flag ? "</H2>" : "", glob->la[i], html_flag ? "<br>" : "\n");
1738 }
1739 /* end of function: langoutput */
1740
1741 PUBLIC void get_lang(argc, argv, lang)
1742 int argc;
1743 char **argv;
1744 char *lang;
1745 {
1746     int    i;
1747
1748     for(i=1;i<argc;i++)
1749         if (strstr(argv[i] , "-L")){
1750             strcpy(lang, argv[i]+2);
1751         }
1752     if(!*lang){
1753         usage(argv[0]);
1754         exit(0);
1755     }
1756 }
1757 /* end of function: get_lang */
1758
1759 PRIVATE int header(inLine, disp, glob, level)
1760 FILELINE *inLine;
1761 PARSE_ENTRY *disp;
1762 GLOB_STRUCT *glob;
1763 int level;
1764 {
1765     return(get_str_param(inLine, &glob->header, glob, 0));
1766 }
1767 /* end of function: header */
1768
1769 PRIVATE int footer(inLine, disp, glob, level)
1770 FILELINE *inLine;
1771 PARSE_ENTRY *disp;
1772 GLOB_STRUCT *glob;
1773 int level;
1774 {
1775     return(get_str_param(inLine, &glob->footer, glob, 0));
1776 }
1777 /* end of function: footer */
1778
1779 PRIVATE int allow_msg(inLine, disp, glob, level)
1780 FILELINE *inLine;
1781 PARSE_ENTRY *disp;
1782 GLOB_STRUCT *glob;
1783 int level;
1784 {
1785     return(get_str_param(inLine, &glob->allow_msg, glob, 0));
1786 }
1787 /* end of function: allow_msg */
1788
1789 PRIVATE int ip_refuse(inLine, disp, glob, level)
1790 FILELINE *inLine;
1791 PARSE_ENTRY *disp;
1792 GLOB_STRUCT *glob;
1793 int level;
1794 {
1795     char dat_file[BUFSIZ];
1796     char rereadcycle[BUFSIZ];
1797
1798     if (sscanf(inLine->value, "%*s%s%s", dat_file, rereadcycle) < 1)
1799         fprintf(stderr, "\nWarning: Error in init-file %s, line %d:\n%s\n",
1800                 glob->acfilename, inLine->count, inLine->value);
1801
1802     glob->ip_refuse  = (IP_REFUSE *) ch_calloc(1, sizeof(IP_REFUSE));
1803     glob->ip_refuse->dat_file = strdup( dat_file );
1804     glob->ip_refuse->rereadcycle = atoi(rereadcycle);
1805
1806     return (OK);
1807 }  /*  ip_refuse  */
1808
1809 PUBLIC void file_test(filename, etcdir)
1810 char **filename;
1811 char *etcdir;
1812 {
1813     FILE *fp;
1814     char newfname[BUFSIZ];
1815
1816     if(*filename){
1817         if(!(fp = fopen(*filename, "r"))) {
1818             sprintf(newfname, "%s%s", etcdir, *filename);
1819             if(!(fp = fopen(newfname, "r"))) {
1820                 sprintf(newfname, "%s.%s", newfname, globP->lang);
1821                 fp = fopen(newfname, "r");
1822             }
1823         }
1824         if(fp) {
1825             free(*filename);
1826             *filename = strdup(newfname);
1827             fclose(fp);
1828         } else {
1829             fprintf(stderr, "\n\nCould not open file %s !\n\n",
1830                             *filename);
1831         }
1832     }
1833 }
1834 /* end of function: file_test */
1835
1836 PRIVATE void f_test(glob)
1837 GLOB_STRUCT *glob;
1838 {
1839     pSEARCH_ONLY_LINE so_ptr;
1840
1841     file_test(&glob->helpfile, glob->etcdir);
1842     file_test(&glob->filterfile, glob->etcdir);
1843     file_test(&glob->friendlyfile, glob->etcdir);
1844     file_test(&glob->header, glob->etcdir);
1845     file_test(&glob->footer, glob->etcdir);
1846     file_test(&glob->allow_msg, glob->etcdir);
1847     if(glob->basedn) {
1848         file_test(&glob->basedn->head, glob->etcdir);
1849         file_test(&glob->basedn->foot, glob->etcdir);
1850     }
1851     for(so_ptr = glob->search_only; so_ptr; so_ptr = so_ptr->next) {
1852         file_test(&so_ptr->head, glob->etcdir);
1853         file_test(&so_ptr->foot, glob->etcdir);
1854     }
1855 }
1856 /* end of function: f_test */
1857
1858