static void init_cstepit_params(SINGLE_QSP_ARG_DECL) { double xmin[MAX_OPT_PARAMS]; double xmax[MAX_OPT_PARAMS]; double deltx[MAX_OPT_PARAMS]; double delmn[MAX_OPT_PARAMS]; double ans[MAX_OPT_PARAMS]; List *lp; Node *np; Opt_Param *opp; int i,n; int nfmax; /* max. # function calls */ #ifdef THREAD_SAFE_QUERY cs_qsp = THIS_QSP; #endif // THREAD_SAFE_QUERY lp = opt_param_list(); if( lp == NULL ) return; n_prms=eltcount(lp); n=reset_n_params(n_prms); if( n != n_prms ) n_prms = n; np=QLIST_HEAD(lp); i=0; while( np!= NULL && i < n_prms ){ opp = (Opt_Param *)(np->n_data); xmin[i]=opp->minv; xmax[i]=opp->maxv; deltx[i]=opp->delta; delmn[i]=opp->mindel; ans[i]=opp->ans; i++; np=np->n_next; } nfmax=100000; /* copy to fortran */ setvals(QSP_ARG ans,n_prms); setminmax(QSP_ARG xmin,xmax,n_prms); setdelta(QSP_ARG deltx,delmn,n_prms); //advise("SETTING ntrace to 1 FOR MAX DEBUG!"); // settrace(1); setmaxcalls(nfmax); }
/***************************************************************** ** parsezonefile () ** parse the BIND zone file 'file' and store the minimum and ** maximum ttl value in the corresponding parameter. ** if keydbfile is set, check if this file is already include. ** if inclfiles is not NULL store a list of included files names ** in it. ** return 0 if keydbfile is not included ** return 1 if keydbfile is included ** return -1 on error *****************************************************************/ int parsezonefile (const char *file, long *pminttl, long *pmaxttl, const char *keydbfile, char *inclfiles, size_t *plen) { FILE *infp; int len; int lnr; long ttl; int multi_line_rr; int keydbfilefound; char buf[1024]; const char *p; assert (file != NULL); assert (pminttl != NULL); assert (pmaxttl != NULL); dbg_val4 ("parsezonefile (\"%s\", %ld, %ld, \"%s\")\n", file, *pminttl, *pmaxttl, keydbfile); if ( (infp = fopen (file, "r")) == NULL ) { error ("parsezonefile: couldn't open file \"%s\" for input\n", file); return -1; } lnr = 0; keydbfilefound = 0; multi_line_rr = 0; while ( fgets (buf, sizeof buf, infp) != NULL ) { len = strlen (buf); if ( buf[len-1] != '\n' ) /* line too long ? */ fprintf (stderr, "line too long\n"); lnr++; p = buf; if ( multi_line_rr ) /* skip line if it's part of a multiline rr */ { is_multiline_rr (&multi_line_rr, p); continue; } if ( *p == '$' ) /* special directive ? */ { if ( strncmp (p+1, "TTL", 3) == 0 ) /* $TTL ? */ { ttl = get_ttl (p+4); dbg_val3 ("%s:%d:ttl %ld\n", file, lnr, ttl); setminmax (pminttl, ttl, pmaxttl); } else if ( strncmp (p+1, "INCLUDE", 7) == 0 ) /* $INCLUDE ? */ { char fname[30+1]; sscanf (p+9, "%30s", fname); dbg_val ("$INCLUDE directive for file \"%s\" found\n", fname); if ( strcmp (fname, keydbfile) == 0 ) keydbfilefound = 1; else { if ( inclfiles && plen ) { len = snprintf (inclfiles, *plen, ",%s", fname); if ( *plen <= len ) /* no space left in include file string */ return keydbfilefound; inclfiles += len; *plen -= len; } int ret = parsezonefile (fname, pminttl, pmaxttl, keydbfile, inclfiles, plen); if ( ret ) /* keydb found or read error ? */ keydbfilefound = ret; } } } else if ( !isspace (*p) ) /* label ? */ p = skiplabel (p); p = skipws (p); if ( *p == ';' ) /* skip line if it's a comment line */ continue; /* skip class (hesiod is not supported now) */ if ( (toupper (*p) == 'I' && toupper (p[1]) == 'N') || (toupper (*p) == 'C' && toupper (p[1]) == 'H') ) p += 2; p = skipws (p); if ( isdigit (*p) ) /* ttl ? */ { ttl = get_ttl (p); dbg_val3 ("%s:%d:ttl %ld\n", file, lnr, ttl); setminmax (pminttl, ttl, pmaxttl); } /* check the rest of the line if it's the beginning of a multi_line_rr */ is_multiline_rr (&multi_line_rr, p); } if ( file ) fclose (infp); dbg_val5 ("parsezonefile (\"%s\", %ld, %ld, \"%s\") ==> %d\n", file, *pminttl, *pmaxttl, keydbfile, keydbfilefound); return keydbfilefound; }