1 /*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
5 * Function:..Initialisation-Routine for TWEB *
9 * Authors:...Dr. Kurt Spanier & Bernhard Winkler, *
10 * Zentrum fuer Datenverarbeitung, Bereich Entwicklung *
11 * neuer Dienste, Universitaet Tuebingen, GERMANY *
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 *
19 _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/
22 * $Id: init.c,v 1.6 1999/09/10 15:01:17 zrnsk01 Exp $
31 PUBLIC void getopts (argc, argv, glob)
39 struct hostent *hstruct;
41 while ( (i = getopt( argc, argv, "P:ad:f:l:p:x:b:L:" )) != EOF ) {
47 if(glob->basedn && glob->basedn->dn)
48 free(glob->basedn->dn);
49 glob->basedn->dn = strdup( optarg );
52 debug = atoi( optarg );
57 "warning: ldap debugging requires LDAP_DEBUG\n" );
62 glob->filterfile = strdup( optarg );
66 dosyslog = cnvt_str2int( optarg, syslog_types, LOG_LOCAL3 );
70 glob->webport = atoi( optarg );
74 glob->ldapport = atoi( optarg );
80 glob->ldapd = str_tolower( strdup( optarg ));
88 if ( (glob->myname = strrchr( argv[0], '/' )) == NULL )
89 glob->myname = argv[0];
94 gethostname(hname, BUFSIZ);
95 hstruct = gethostbyname(hname);
96 glob->hostname = str_tolower( strdup( hstruct->h_name ));
100 /* end of function: getopts */
102 PRIVATE void usage(name)
105 fprintf(stderr, USAGE, name);
108 /* end of function: usage */
110 PUBLIC void check (glob)
113 if(!glob->webport || !glob->ldapd || !glob->ldapport ||
114 !glob->basedn || !glob->sort) {
116 "\nMissing must-attribute: webport || ldapd || ldapport || basedn->dn || sort\n!\n\n");
121 trim(glob->grant, "|");
122 glob->comp_grant = tweb_regcomp(glob->grant);
126 trim(glob->refuse, "|");
127 glob->comp_refuse = tweb_regcomp(glob->refuse);
130 if(glob->allow_string){
131 trim(glob->allow_string, "|");
132 glob->comp_allow = tweb_regcomp(glob->allow_string);
135 if(glob->deny_string){
136 trim(glob->deny_string, "|");
137 glob->comp_deny = tweb_regcomp(glob->deny_string);
141 glob->webdn = "c=DE";
142 if(glob->webpw) free(glob->webpw);
146 glob->webdn2 = "c=BR";
147 if(glob->webpw2) free(glob->webpw2);
152 glob->timeout = DEFAULT_TIMEOUT;
154 glob->maxcount = DEFAULT_MAXCOUNT;
156 if(!glob->subtree_search)
157 glob->subtree_search =
158 str2charray( "organization:organizationalUnit", ":");
160 glob->cache_expire = glob->cache_expire % MAX_EXPIRE;
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;
173 if(!strcmp(d_ptr->ocs, "default"))
174 s_ptr->display_class_ptr = d_ptr;
178 if( glob->ldapd && !strcmp(glob->ldapd, "x500-relay.uni-tuebingen.de")
179 && !strcmp(glob->lang, "0")) {
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 \
184 overload of host x500-relay.uni-tuebingen.de !\n\n");
188 /* end of function: check */
190 PUBLIC void init(argv, lang, glob)
196 static char file[BUFSIZ];
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)) )");
205 strcpy(file, RCINIT);
207 sprintf( file, "%s.rc", argv[0] );
209 glob->acfilename = file;
210 if(!(fp = fopen(file, "r"))) {
211 fprintf(stderr, "\n\nATTENTION!!!\n\nCould not open file %s !\n", file);
218 strcpy(file, CONFINIT);
220 sprintf( file, "%s.conf.%s", argv[0], glob->lang );
222 glob->acfilename = file;
223 if(!(fp = fopen(file, "r"))) {
224 fprintf(stderr, "\n\nATTENTION!!!\n\nCould not open file %s !\n", file);
231 /* end of function: init */
233 #define STRINGP(x) ((x) ? (x) : "(NULL)")
235 PUBLIC void output(fp, glob, html_flag)
241 pSEARCH_ONLY_LINE so_ptr;
242 pGW_SWITCH_LINE gw_ptr;
244 pDISPLAY_LINE dis_ptr;
245 pMODIFY_LINE mod_ptr;
247 pCACHING_TERMS_LINE ca_ptr;
250 pTABLE_DISPLAY ta_ptr;
253 char hb[BUFSIZ], he[BUFSIZ], li[BUFSIZ], lb[BUFSIZ], le[BUFSIZ];
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>" : "");
261 /*for(i=0; glob->sort_attribs[i]; i++)
262 fprintf(fp,"%s<p>\n", glob->sort_attribs[i]);
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);
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 ));
275 fprintf(fp, "WEBPW: %s\n", STRINGP( glob->webpw ));
276 fprintf(fp, "WEBPW2: %s\n", STRINGP( glob->webpw2 ));
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 ));
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]);
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);
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");
329 fprintf(fp, "%s\nSELBSTEINTRAG%s\n", hb, he);
331 if (glob->selbsteintrag[i])
332 fprintf(fp, "%s\t%s\n", li, glob->selbsteintrag[i]);
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 ));
347 fprintf(fp, "%sPHONEWORLD%s%s %s\n", hb, he, li,
348 STRINGP( glob->phoneworld ));
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]);
355 fprintf(fp, "%s\nCACHE-EXPIRE-DEFAULT%s%s %d\n", hb, he, li,
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 ));
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 : "");
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);
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 ));
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]);
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 );
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" : "");
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 ));
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 ));
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 ));
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 ));
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 ));
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);
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);
477 /* end of function: output */
479 PRIVATE void main_loop(fp,glob)
484 extern PARSE_ENTRY parse_table[];
486 while(do_readf(&inLine, fp)){
487 parse(&inLine, parse_table, glob, 0);
490 /* end of function: main_loop */
492 PUBLIC int do_readf(inLine, fp)
497 static int lineCount = 0;
505 if(!fgets(inLine->value, BUFSIZ-1, fo)){
510 if( (comment = strchr(inLine->value, '#')) )
512 trim(inLine->value, " \t\n");
513 } while(!*inLine->value);
515 inLine->count = lineCount;
516 /* printf("%d: %s\n", inLine->count, inLine->value);
518 return (inLine->count);
520 /* end of function: do_readf */
522 PRIVATE int parse(inLine, p_table, glob, level)
524 PARSE_ENTRY *p_table;
528 int lineCount = inLine->count;
531 switch(parse2(inLine, p_table, glob, level)){
533 printf("Error in init-file line %d:\n%s\n ", inLine->count, inLine->value);
536 if(lineCount == inLine->count)
539 lineCount = inLine->count;
546 /* end of function: parse */
548 PRIVATE int parse2(inLine, p_table, glob, level)
550 PARSE_ENTRY *p_table;
555 char keyWord[BUFSIZ];
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));
564 return (level?DONE:NOTOK);
566 /* end of function: parse2 */
568 PUBLIC int get_str_param(inLine, str, glob, lower)
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);
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);
585 *str = realloc(*str, strlen(*str) + strlen(tmp) +1 );
586 strcat(*str, lower ? str_tolower( tmp ) : tmp );
588 *str = strdup( lower ? str_tolower( tmp ) : tmp );
591 if(!do_readf(inLine, NULL))
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);
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);
601 } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
605 /* end of function: get_str_param */
607 PRIVATE int get_int_param(inLine, integer, glob)
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);
619 /* end of function: get_int_param */
622 PRIVATE int webdn(inLine, disp, glob, level)
628 return(get_str_param(inLine, &glob->webdn, glob, 0));
630 /* end of function: webdn */
632 PRIVATE int webpw(inLine, disp, glob, level)
638 return(get_str_param(inLine, &glob->webpw, glob, 0));
640 /* end of function: webpw */
642 PRIVATE int webdn2(inLine, disp, glob, level)
648 return(get_str_param(inLine, &glob->webdn2, glob, 0));
650 /* end of function: webdn2 */
652 PRIVATE int webpw2(inLine, disp, glob, level)
658 return(get_str_param(inLine, &glob->webpw2, glob, 0));
660 /* end of function: webpw2 */
663 PRIVATE int webport(inLine, disp, glob, level)
669 return(get_int_param(inLine, &glob->webport, glob));
671 /* end of function: webport */
673 PRIVATE int timeout(inLine, disp, glob, level)
679 return(get_int_param(inLine, &glob->timeout, glob));
681 /* end of function: timeout */
683 PRIVATE int hostname(inLine, disp, glob, level)
689 char hostname[BUFSIZ];
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);
695 if( ( virtualport = strchr(hostname, ':')) ) {
696 *virtualport++ = '\0';
697 glob->virtualport = atoi( virtualport );
699 glob->hostname = strdup( hostname );
702 /* end of function: hostname */
704 PRIVATE int ldapd(inLine, disp, glob, level)
710 return(get_str_param(inLine, &glob->ldapd, glob, 1));
712 /* end of function: ldapd */
714 PRIVATE int ldapportf(inLine, disp, glob, level)
720 return(get_int_param(inLine, &glob->ldapport, glob));
722 /* end of function: ldapportf */
724 PRIVATE int etcdir(inLine, disp, glob, level)
730 return(get_str_param(inLine, &glob->etcdir, glob, 0));
732 /* end of function: etcdir */
734 PRIVATE int filterfilef(inLine, disp, glob, level)
740 return(get_str_param(inLine, &glob->filterfile, glob, 0));
742 /* end of function: filterfile */
744 PRIVATE int helpfilef(inLine, disp, glob, level)
750 return(get_str_param(inLine, &glob->helpfile, glob, 0));
752 /* end of function: helpfile */
754 PRIVATE int friendlyfilef(inLine, disp, glob, level)
760 return(get_str_param(inLine, &glob->friendlyfile, glob, 0));
762 /* end of function: friendlyfile */
764 PRIVATE int index_url(inLine, disp, glob, level)
770 char dat_file[BUFSIZ];
771 char rereadcycle[BUFSIZ];
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);
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);
781 get_index_url_rules(glob);
786 PUBLIC void get_index_url_rules(glob)
796 if ( !glob->index_url || !glob->index_url->dat_file )
798 if(!(dfp = fopen(glob->index_url->dat_file, "r")))
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 );
806 while(fgets(inLine, BUFSIZ-1, dfp)) {
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");
813 if (sscanf(inLine, "%s%s%s",
814 index, rule, dit_dn) < 1)
815 syslog (LOG_INFO, "Error in index_url-file");
818 if ( idx < 0 || idx >= INDEX_RULE_SIZE )
820 glob->index_url->rarr[idx].rule = str_tolower( strdup( rule ));
821 glob->index_url->rarr[idx].dit_dn = strdup( dit_dn );
825 /* end of function: get_index_url_rules */
827 PUBLIC void re_read_index_url_rules( glob )
830 static int index_url_rules_reload = 0;
832 if ( glob->index_url && glob->index_url->rereadcycle && !( ++index_url_rules_reload % glob->index_url->rereadcycle )) {
833 get_index_url_rules( glob );
836 } /* re_read_index_url_rules */
839 PRIVATE int allow_proxy(inLine, disp, glob, level)
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);
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);
854 glob->allow_proxy = str2charray( str_tolower(tmp), ":");
857 /* end of function: allow_proxy */
859 PRIVATE int subtree_search(inLine, disp, glob, level)
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);
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);
874 glob->subtree_search = str2charray( tmp, ":");
877 /* end of function: subtree_search */
879 PRIVATE int grant(inLine, disp, glob, level)
885 return(get_str_param(inLine, &glob->grant, glob, 1));
887 /* end of function: grant */
889 PRIVATE int refuse(inLine, disp, glob, level)
895 return(get_str_param(inLine, &glob->refuse, glob, 1));
897 /* end of function: refuse */
899 PRIVATE int allow_string(inLine, disp, glob, level)
905 return(get_str_param(inLine, &glob->allow_string, glob, 1));
907 /* end of function: allow_string */
909 PRIVATE int deny_string(inLine, disp, glob, level)
915 return(get_str_param(inLine, &glob->deny_string, glob, 1));
917 /* end of function: deny_string */
920 PRIVATE int show_defoc(inLine, disp, glob, level)
927 glob->show_defoc = 1;
930 /* end of function: show_defoc */
932 PRIVATE int max_person(inLine, disp, glob, level)
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;
950 /* end of function: max_person */
952 PRIVATE int comrefuse(inLine, disp, glob, level)
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);
980 /* end of function: comrefuse */
982 PRIVATE int display(inLine, disp, glob, level)
991 for(d_ptr = &glob->display; *d_ptr; d_ptr = &(*d_ptr)->next)
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);
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))
1005 return (parse(inLine,disp->subTable, glob, ++level));
1007 /* end of function: display */
1009 PRIVATE int basednf(inLine, disp, glob, level)
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);
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);
1032 /* end of function: basednf */
1034 PRIVATE int search_only(inLine, disp, glob, level)
1043 pSEARCH_ONLY_LINE *so_ptr;
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);
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);
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))
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);
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');
1069 /* end of function: search_only */
1071 PRIVATE int dynamic_gw(inLine, disp, glob, level)
1078 glob->gw_switch->dynamic = 1;
1081 /* end of function: dynamic_gw */
1083 PRIVATE int caching_terms(inLine, disp, glob, level)
1090 char access_type[BUFSIZ];
1091 char rdn_oc[BUFSIZ];
1092 char pattern[BUFSIZ];
1093 pCACHING_TERMS_LINE *ca_ptr;
1095 ca_ptr = &glob->caching_terms;
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);
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))
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');
1117 /* end of function: caching_terms */
1119 PRIVATE int gw_switch(inLine, disp, glob, level)
1127 pGW_SWITCH_LINE *gw_ptr;
1129 for(gw_ptr = &glob->gw_switch->list; *gw_ptr; gw_ptr = &(*gw_ptr)->next)
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);
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);
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))
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);
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');
1153 /* end of function: gw_switch */
1155 PRIVATE int table_disp(inLine, disp, glob, level)
1162 char select_oc[BUFSIZ];
1163 char button_label[BUFSIZ];
1164 char dn_extension[BUFSIZ];
1165 pTABLE_DISPLAY *ta_ptr;
1167 for(ta_ptr = &glob->tables; *ta_ptr; ta_ptr = &(*ta_ptr)->next)
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);
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))
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');
1185 /* end of function: table_disp */
1187 PRIVATE int modify(inLine, disp, glob, level)
1197 for(m_ptr = &glob->modify; *m_ptr; m_ptr = &(*m_ptr)->next)
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);
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);
1206 *m_ptr = (pMODIF) ch_calloc(1, sizeof(MODIF));
1208 (*m_ptr)->ocs = str_tolower (tr1 (strdup(tmp), ' ', '|'));
1210 if(!do_readf(inLine, NULL)) return (NOTOK);
1211 return (parse(inLine,disp->subTable, glob, ++level));
1213 /* end of function: modify */
1215 PRIVATE int ind_attrs(inLine, disp, glob, level)
1224 for(i_ptr = &glob->ind_attrs; *i_ptr; i_ptr = &(*i_ptr)->next)
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);
1229 *i_ptr = (pIND_ATTRS) ch_calloc(1, sizeof(IND_ATTRS));
1230 (*i_ptr)->ref_attr = str_tolower(strdup(tmp));
1232 if(!do_readf(inLine, NULL)) return (NOTOK);
1233 return (parse(inLine,disp->subTable, glob, ++level));
1235 /* end of function: ind_attrs */
1237 PRIVATE int cache_expire(inLine, disp, glob, level)
1243 return(get_int_param(inLine, &glob->cache_expire, glob));
1245 /* end of function: cache_expire */
1247 PRIVATE int maxcount(inLine, disp, glob, level)
1253 return(get_int_param(inLine, &glob->maxcount, glob));
1255 /* end of function: maxcount */
1257 PRIVATE int language(inLine, disp, glob, level)
1264 int slots = 2, i = 0;
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);
1272 glob->language = (char **) ch_realloc((char *)glob->language, (slots+1)*sizeof(char **));
1274 glob->language[i++] = strdup(tmp);
1275 if(!do_readf(inLine, NULL))
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');
1282 /* end of function: language */
1284 PRIVATE int strict_basedn(inLine, disp, glob, level)
1291 glob->strict_basedn = 1;
1294 /* end of function: strict_basedn */
1296 PRIVATE int pull_down_menus(inLine, disp, glob, level)
1303 glob->pull_down_menus = 1;
1306 /* end of function: pull_down_menus */
1308 PRIVATE int no_proxy(inLine, disp, glob, level)
1318 /* end of function: no_proxy */
1320 PRIVATE int disp_sea_rdn(inLine, disp, glob, level)
1327 glob->disp_sea_rdn = 1;
1330 /* end of function: disp_sea_rdn */
1332 PRIVATE int prefer_ref_uris(inLine, disp, glob, level)
1339 glob->prefer_ref_uris = 1;
1342 /* end of function: prefer_ref_uris */
1344 PRIVATE int strip_pin(inLine, disp, glob, level)
1351 return(get_str_param(inLine, &glob->strip_pin, glob, 1));
1353 /* end of function: strip_pin */
1355 PRIVATE int legal(inLine, disp, glob, level)
1363 sscanf(inLine->value, "%*s%s", tmp);
1365 glob->legal_top = tmp && !strcasecmp(tmp, "ON-TOP");
1368 /* end of function: legal */
1370 PRIVATE int no_modify(inLine, disp, glob, level)
1376 return(get_str_param(inLine, &glob->no_modify, glob, 1));
1378 /* end of function: no_modify */
1380 PRIVATE int no_show_rdn(inLine, disp, glob, level)
1386 return(get_str_param(inLine, &glob->no_show_rdn, glob, 1));
1388 /* end of function: no_show_rdn */
1390 PRIVATE int sort(inLine, disp, glob, level)
1396 char object_class[BUFSIZ];
1398 char priority[BUFSIZ];
1399 char display_class[BUFSIZ];
1400 char sort_attr[BUFSIZ];
1403 s_ptr = &glob->sort;
1404 strcpy(sort_attr, "sn");
1405 strcpy( display_class, "default" );
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);
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);
1415 char tmpBuf[BUFSIZ];
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;
1426 if(!charray_inlist(glob->sort_attribs, sort_attr))
1427 charray_add(&glob->sort_attribs, sort_attr );
1429 if(!do_readf(inLine, NULL))
1432 strcpy(sort_attr, "sn");
1433 strcpy( display_class, "default" );
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);
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);
1442 } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1446 /* end of function: sort */
1448 PRIVATE int form_button(inLine, disp, glob, level)
1454 char read_menu[BUFSIZ];
1455 char object_class[BUFSIZ];
1456 char method[BUFSIZ];
1457 char script_url[BUFSIZ];
1459 char dn_name[BUFSIZ];
1460 char form_name[BUFSIZ];
1461 char button_label[BUFSIZ];
1462 pFORM_BUTTON *f_ptr;
1464 f_ptr = &glob->form_button;
1465 /* for(f_ptr = &glob->form_button; (*f_ptr)->next; f_ptr = &(*f_ptr)->next)
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);
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);
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;
1490 if(!do_readf(inLine, NULL))
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);
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);
1500 } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1504 /* end of function: form_button */
1506 PRIVATE int firstPage(inLine, disp, glob, level)
1512 char attribute[BUFSIZ];
1515 pDISPLAY_LINE *dis_ptr;
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);
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)
1526 dis_ptr = &d_ptr->first_page;
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))
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);
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;
1543 } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1545 return (parse(inLine,disp->subTable, glob, ++level));
1547 /* end of function: firstPage */
1549 PRIVATE int secondPage(inLine, disp, glob, level)
1555 char attribute[BUFSIZ];
1558 pDISPLAY_LINE *dis_ptr;
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);
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)
1569 dis_ptr = &d_ptr->second_page;
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))
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);
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;
1586 } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1587 /*puts("leaving secondpage!");
1592 /* end of function: secondPage */
1594 PRIVATE int modattr(inLine, disp, glob, level)
1600 char attribute[BUFSIZ];
1603 pMODIFY_LINE *mod_ptr;
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);
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);
1613 for(m_ptr = glob->modify; m_ptr->next; m_ptr = m_ptr->next)
1615 mod_ptr = &m_ptr->modattr;
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))
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);
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;
1631 } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1632 /*puts("leaving secondpage!");
1637 /* end of function: modattr */
1639 PRIVATE int ind_attribute(inLine, disp, glob, level)
1646 char replace[BUFSIZ];
1647 char attribute[BUFSIZ];
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);
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);
1664 for(i_ptr = glob->ind_attrs; i_ptr->next; i_ptr = i_ptr->next)
1667 idx = &i_ptr->ia_arr;
1669 *idx = (IND_ATTR_ARR *) ch_malloc( 100 * sizeof(IND_ATTR_ARR) );
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;
1682 if(!do_readf(inLine, NULL))
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);
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);
1691 } while(inLine->value[0] == ' ' || inLine->value[0] == '\t');
1695 /* end of function: ind_attribute */
1698 PUBLIC void langinit(glob)
1702 char inLine[BUFSIZ], lCountS[BUFSIZ], phrase[BUFSIZ], file[BUFSIZ];
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);
1709 while(fgets(inLine, BUFSIZ-1, fp)) {
1711 /* Comment-sign is accepted in the first column only */
1714 if(*inLine == '\t') {
1715 strcat(strcat(glob->la[atoi(lCountS)], " "), trim(inLine, " \t\n"));
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);
1726 /* end of function: langinit */
1728 PUBLIC void langoutput(fp, glob, html_flag)
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");
1739 /* end of function: langoutput */
1741 PUBLIC void get_lang(argc, argv, lang)
1749 if (strstr(argv[i] , "-L")){
1750 strcpy(lang, argv[i]+2);
1757 /* end of function: get_lang */
1759 PRIVATE int header(inLine, disp, glob, level)
1765 return(get_str_param(inLine, &glob->header, glob, 0));
1767 /* end of function: header */
1769 PRIVATE int footer(inLine, disp, glob, level)
1775 return(get_str_param(inLine, &glob->footer, glob, 0));
1777 /* end of function: footer */
1779 PRIVATE int allow_msg(inLine, disp, glob, level)
1785 return(get_str_param(inLine, &glob->allow_msg, glob, 0));
1787 /* end of function: allow_msg */
1789 PRIVATE int ip_refuse(inLine, disp, glob, level)
1795 char dat_file[BUFSIZ];
1796 char rereadcycle[BUFSIZ];
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);
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);
1809 PUBLIC void file_test(filename, etcdir)
1814 char newfname[BUFSIZ];
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");
1826 *filename = strdup(newfname);
1829 fprintf(stderr, "\n\nCould not open file %s !\n\n",
1834 /* end of function: file_test */
1836 PRIVATE void f_test(glob)
1839 pSEARCH_ONLY_LINE so_ptr;
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);
1848 file_test(&glob->basedn->head, glob->etcdir);
1849 file_test(&glob->basedn->foot, glob->etcdir);
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);
1856 /* end of function: f_test */