/*_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ * * * init.c..... * * * * Function:..Initialisation-Routine for TWEB * * * * * * * * Authors:...Dr. Kurt Spanier & Bernhard Winkler, * * Zentrum fuer Datenverarbeitung, Bereich Entwicklung * * neuer Dienste, Universitaet Tuebingen, GERMANY * * * * ZZZZZ DDD V V * * Creation date: Z D D V V * * July 21 1995 Z D D V V * * Last modification: Z D D V V * * May 11 1999 ZZZZZ DDD V * * * _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_*/ /* * $Id: init.c,v 1.6 1999/09/10 15:01:17 zrnsk01 Exp $ * */ #include "tgeneral.h" #include "tglobal.h" #include "init.h" PUBLIC void getopts (argc, argv, glob) int argc; char **argv; GLOB_STRUCT *glob; { int i; extern char *optarg; char hname[BUFSIZ]; struct hostent *hstruct; while ( (i = getopt( argc, argv, "P:ad:f:l:p:x:b:L:" )) != EOF ) { switch( i ) { case 'a': searchaliases = 0; break; case 'b': if(glob->basedn && glob->basedn->dn) free(glob->basedn->dn); glob->basedn->dn = strdup( optarg ); break; case 'd': debug = atoi( optarg ); #ifdef LDAP_DEBUG ldap_debug = debug; #else fprintf( stderr, "warning: ldap debugging requires LDAP_DEBUG\n" ); #endif break; case 'f': glob->filterfile = strdup( optarg ); break; case 'l': dosyslog = cnvt_str2int( optarg, syslog_types, LOG_LOCAL3 ); break; case 'p': glob->webport = atoi( optarg ); break; case 'P': glob->ldapport = atoi( optarg ); break; case 'x': if(glob->ldapd) free(glob->ldapd); glob->ldapd = str_tolower( strdup( optarg )); break; case 'L': break; default: usage(argv[0]); } } if ( (glob->myname = strrchr( argv[0], '/' )) == NULL ) glob->myname = argv[0]; else glob->myname++; if(!glob->hostname) { gethostname(hname, BUFSIZ); hstruct = gethostbyname(hname); glob->hostname = str_tolower( strdup( hstruct->h_name )); } } /* end of function: getopts */ PRIVATE void usage(name) char *name; { fprintf(stderr, USAGE, name); exit( 1 ); } /* end of function: usage */ PUBLIC void check (glob) GLOB_STRUCT *glob; { if(!glob->webport || !glob->ldapd || !glob->ldapport || !glob->basedn || !glob->sort) { fprintf(stderr, "\nMissing must-attribute: webport || ldapd || ldapport || basedn->dn || sort\n!\n\n"); exit(1); } if(glob->grant){ trim(glob->grant, "|"); glob->comp_grant = tweb_regcomp(glob->grant); } if(glob->refuse){ trim(glob->refuse, "|"); glob->comp_refuse = tweb_regcomp(glob->refuse); } if(glob->allow_string){ trim(glob->allow_string, "|"); glob->comp_allow = tweb_regcomp(glob->allow_string); } if(glob->deny_string){ trim(glob->deny_string, "|"); glob->comp_deny = tweb_regcomp(glob->deny_string); } if(!glob->webdn){ glob->webdn = "c=DE"; if(glob->webpw) free(glob->webpw); glob->webpw = NULL; } if(!glob->webdn2){ glob->webdn2 = "c=BR"; if(glob->webpw2) free(glob->webpw2); glob->webpw2 = NULL; } if(!glob->timeout) glob->timeout = DEFAULT_TIMEOUT; if(!glob->maxcount) glob->maxcount = DEFAULT_MAXCOUNT; if(!glob->subtree_search) glob->subtree_search = str2charray( "organization:organizationalUnit", ":"); glob->cache_expire = glob->cache_expire % MAX_EXPIRE; f_test(glob); if(glob->sort) { pSORT_LINE s_ptr; pDISPLAY d_ptr; for(s_ptr = glob->sort; s_ptr; s_ptr = s_ptr->next) for(d_ptr = glob->display; d_ptr; d_ptr = d_ptr->next) { if(!strcmp(d_ptr->ocs, s_ptr->display_class)) { s_ptr->display_class_ptr = d_ptr; break; } if(!strcmp(d_ptr->ocs, "default")) s_ptr->display_class_ptr = d_ptr; } } if( glob->ldapd && !strcmp(glob->ldapd, "x500-relay.uni-tuebingen.de") && !strcmp(glob->lang, "0")) { fprintf( stderr, "\n\n\tYou missed to set LDAP-HOST and LDAP-PORT to\n\ a machine of your own.\n\n\tPlease change as soon as \ possible to avoid\n\ overload of host x500-relay.uni-tuebingen.de !\n\n"); } } /* end of function: check */ PUBLIC void init(argv, lang, glob) char **argv; char *lang; GLOB_STRUCT *glob; { FILE *fp; static char file[BUFSIZ]; glob->argv0 = strdup(argv[0]); glob->gw_switch = (pGW_SWITCH) ch_calloc(1, sizeof(GW_SWITCH)); glob->basedn = (BASEDN_LINE *) ch_calloc(1, sizeof(BASEDN_LINE)); glob->basedn->dn = strdup(""); glob->menu_filter = strdup("(& (objectClass=top)(!(objectClass=dSA)) )"); #ifdef RCINIT strcpy(file, RCINIT); #else sprintf( file, "%s.rc", argv[0] ); #endif glob->acfilename = file; if(!(fp = fopen(file, "r"))) { fprintf(stderr, "\n\nATTENTION!!!\n\nCould not open file %s !\n", file); exit(1); } main_loop(fp, glob); fclose(fp); #ifdef CONFINIT strcpy(file, CONFINIT); #else sprintf( file, "%s.conf.%s", argv[0], glob->lang ); #endif glob->acfilename = file; if(!(fp = fopen(file, "r"))) { fprintf(stderr, "\n\nATTENTION!!!\n\nCould not open file %s !\n", file); exit(1); } main_loop(fp, glob); fclose(fp); return; } /* end of function: init */ #define STRINGP(x) ((x) ? (x) : "(NULL)") PUBLIC void output(fp, glob, html_flag) FILE *fp; GLOB_STRUCT *glob; int html_flag; { pDISPLAY d_ptr; pSEARCH_ONLY_LINE so_ptr; pGW_SWITCH_LINE gw_ptr; pSORT_LINE s_ptr; pDISPLAY_LINE dis_ptr; pMODIFY_LINE mod_ptr; pMODIF m_ptr; pCACHING_TERMS_LINE ca_ptr; pIND_ATTRS i_ptr; IND_ATTR_ARR *idx; pTABLE_DISPLAY ta_ptr; pFORM_BUTTON fo_ptr; int i; char hb[BUFSIZ], he[BUFSIZ], li[BUFSIZ], lb[BUFSIZ], le[BUFSIZ]; strcpy(lb, html_flag ? "" : ""); strcpy(li, html_flag ? "
  • " : ""); strcpy(hb, html_flag ? "" : ""); strcpy(he, html_flag ? "