Exemplo n.º 1
0
/*	erase to the end of current line */
void erase_eol()
{
	if (_isatty(_fileno(stdout))) {
		disp_open();
		disp_eeol();
		disp_close();
	}
}
Exemplo n.º 2
0
/*	move cursor up */
void cursor_up(int rows)
{
	if (_isatty(_fileno(stdout))) {
		disp_open();
		disp_move(disp_cursorrow - rows, 0);
		disp_close();
	}
}
Exemplo n.º 3
0
main()
{
disp_open();

drawbox(10,10,10,10);

disp_close();


}
Exemplo n.º 4
0
Arquivo: test.c Projeto: CPFL/AutoICT
int main(int argc, char *argv[])
{
    Display *dpy;

    disp_init(argc, argv);
    disp_ctrl(dpy, OFF);
    sleep(1);
    disp_ctrl(dpy, ON);
    disp_close(dpy);

    return 0;
}
Exemplo n.º 5
0
void fn_response(char **args)
{
    struct ftp_hist *h;
    FILE *f;

    if (ftp_history == NULL) {
	disp_status(DISP_STATUS, "no exchange available");
	return;
    }
    
    if ((f=disp_open(opt_pager, 1)) == NULL)
	return;

    for (h=ftp_history; h; h=h->next)
	fprintf(f, "%s\n", h->line);

    disp_close(f, 1);
}
Exemplo n.º 6
0
/*
 * Dispose, Free all resources
 */
void CDVDVideoCodecA10::Dispose()
{
  if (m_yuvdata)
  {
    mem_pfree(m_yuvdata);
    m_yuvdata = NULL;
  }
  scaler_close();
  disp_close();
  if (m_hcedarv)
  {
    m_hcedarv->ioctrl(m_hcedarv, CEDARV_COMMAND_STOP, 0);
    m_hcedarv->close(m_hcedarv);
    libcedarv_exit(m_hcedarv);
    m_hcedarv = NULL;
    cas(&g_cedaropen, 1, 0);
    CLog::Log(LOGDEBUG, "A10: cedar dispose.");
  }
}
Exemplo n.º 7
0
int
main(int argc, char **argv)
{
	struct display *disp;
	struct buffer **buffers;
	int ret, i;

	MSG("Opening Display..");
	disp = disp_open(argc, argv);
	if (!disp) {
		usage(argv[0]);
		return 1;
	}

	if (check_args(argc, argv)) {
		/* remaining args.. print usage msg */
		usage(argv[0]);
		return 0;
	}

	buffers = disp_get_buffers(disp, NBUF);
	if (!buffers) {
		return 1;
	}

	for (i = 0; i < CNT; i++) {
		struct buffer *buf = buffers[i % NBUF];
		fill(buf, i * 2);
		ret = disp_post_buffer(disp, buf);
		if (ret) {
			return ret;
		}
	}

	MSG("Ok!");
	disp_close(disp);

	return 0;
}
Exemplo n.º 8
0
static void  _release_res( void )
{
    __here__;
	robin_monitor_delete( );
    __here__;
	cmdQ_delete( );
    __here__;
	robin_feedbackQ_delete( );
    __here__;
	disp_close( );
    __here__;
	willow_close( );
    __here__;
	cedar_close( );
    __here__;
	npl_delete( );
    __here__;
	orchid_close( );
    __here__;
	robin_cmd_mutex_delete( );
    __here__;
	robin_cedar_mutex_delete( );
    __here__;
}
Exemplo n.º 9
0
void close_textmode ()
{
   disp_close () ;
}
Exemplo n.º 10
0
void main(void)
{
        int i;
        FILE *log = stdout, *nulfile;

#ifdef __ZTC__
        disp_open();
#endif
        nulfile = fopen("NUL", "w");
        time1 = *bios_time;
        for(i = 1; i < 1000; i++)
        {
                gotoxy(10,5);
                puts("puts      test.");
                puts("this is the second line.\n");
        }
        time1 = *bios_time - time1;
        time2 = *bios_time;
        for(i = 1; i < 1000; i++)
        {
                gotoxy(10,5);
                printf("printf    test.\n");
                printf("this is the second line.\n");
        }
        time2 = *bios_time - time2;
        time3 = *bios_time;
        for(i = 1; i < 1000; i++)
        {
#ifdef __ZTC__
                disp_move(4,9);
                cputs("d_puts    test.");
#else
                gotoxy(10,5);
 #if defined(M_I86) && !defined(__WATCOMC__)
                cputs("_outtext  test.\r\n");
 #else
                cputs("cputs     test.\r\n");
 #endif
#endif
                cputs("this is the second line.");
        }
        time3 = *bios_time - time3;
        time4 = *bios_time;
        for(i = 1; i < 1000; i++)
        {
#ifdef __ZTC__
                disp_move(4,9);
                cprintf("d_printf  test.");
#else
                gotoxy(10,5);
                cprintf("cprintf   test.\r\n");
#endif
                cprintf("this is the second line.");
        }
        time4 = *bios_time - time4;
        time5 = *bios_time;
        for(i = 1; i < 1000; i++)
        {
                fputs("fputs     test.\n", nulfile);
                fputs("this is the second line.\n", nulfile);
        }
        time5 = *bios_time - time5;
        time6 = *bios_time;
        for(i = 1; i < 1000; i++)
        {
                fprintf(nulfile, "fprintf   test.\n");
                fprintf(nulfile, "this is the second line.\n");
        }
        time6 = *bios_time - time6;

#ifdef __ZTC__
        disp_close();
#endif
        log = fopen(LOGFILE, "w");
        fputs("Times for 1000 iterations:\n\n", log);
        fprintf(log, "puts     %10.3f seconds\n", (double)time1 * .054945);
        fprintf(log, "printf   %10.3f seconds\n", (double)time2 * .054945);
#ifndef __ZTC__
 #if defined(M_I86) && !defined(__WATCOMC__)
        fprintf(log, "_outtext %10.3f seconds\n", (double)time3 * .054945);
 #else
        fprintf(log, "cputs    %10.3f seconds\n", (double)time3 * .054945);
 #endif
        fprintf(log, "cprintf  %10.3f seconds\n", (double)time4 * .054945);
#else
        fprintf(log, "d_puts   %10.3f seconds\n", (double)time3 * .054945);
        fprintf(log, "d_printf %10.3f seconds\n", (double)time4 * .054945);
#endif
        fprintf(log, "fputs    %10.3f seconds\n", (double)time5 * .054945);
        fprintf(log, "fprintf  %10.3f seconds\n", (double)time6 * .054945);
        fclose(log);
}
Exemplo n.º 11
0
/**
* Function fmin contains Quasi-Newton function minimizer with
* inexact line search using Wolfe conditions and
* BFGS correction formula for Hessian update.
*
* The algorithm consists of the following steps (in the order of execution):
* - Initial step with Hessian being an identity matrix (see call1)
* - Line search test for step length satisfying Wolfe conditions (beginning of
*   call2)
* - Line search backtracking and reducing alpha (label40) if the current
*   direction
*   is not a gradient descent one or the function value has increased
* - Hessian update (labels 50-70) once all conditions are satisfied to assure
*   its
*   positive-definiteness
* - Update of a vector of independent variables (label30)
*
* Convergence is detected if the maximal gradient component falls below small
* constant (see label20)
*
* Requires:
*    \param _f Value of function to be minimized.
*    \param _x Vector of independent variables.
*    \param _g Vector containing the partial derivatives of _f with respect to
*    each independent variable. The gradient vector returned by \ref gradcalc.
* Pre:
*    Some class member variables can be initialized by user prior to calling
*    this function.
*    These control variables may change the behavior of fmin, they are:
*        maxfn  (maximal number of function evaluations, after which
*                minimization stops)
*        crit   (convergence criterion constant)
*        imax   (maximal number of function evaluations within one linear search*                before to stop)
*        iprint (flag to allow (=1) or supress (=0) printing intermediate
*                statistics
*        min_improve (stop after 10 iterations with overall function decrease
*                     less than this value)
*    The default values can be found in function set_defaults of class
*    fmm_control
* Modifies:
*    The Hessian matrix (and not its inverse) h
* Returns (via parameter vector x):
*    A vector x after a step of linear search in the direction of gradient
*    descent
\ingroup FMM
*/
void fmm::fmin(const double& _f, const dvector &_x, const dvector& _g)
{
  if (log_values_switch)
  {
    print_values(_f,_x,_g);
  }
  if (pfmintime==0) pfmintime=new adtimer;
  tracing_message(traceflag,"A3");

  /* Remember gradient and function values
     resulted from previous function evaluation */
  dvector& g=(dvector&) _g;
  double& f=(double&) _f;

  /* Create local vector x as a pointer to the argument vector _x */
  independent_variables& x= (independent_variables&) _x;
    #ifdef DIAG
      cout << "On entry to fmin: " << *this << endl;
    #endif
  tracing_message(traceflag,"A4");

#ifdef _MSC_VER
  SetConsoleCtrlHandler((PHANDLER_ROUTINE)CtrlHandler, true);
#else
  /* Check the value of control variable ireturn:
        -1 (exit status)
         0 (initialization of function minimizer)
         1 (call1 - x update and convergence check)
         2 (call2 - line search and Hessian update)
         >=3 (derivative check)
  */
  if (ireturn <= 0 )
  {
    signal(SIGINT, &onintr);
  }
#endif

#ifdef __ZTC__
      if (ireturn <= 0 )
      {
        if (disp_inited == 0)
        {
          disp_open();
          disp_usebios();
        }
      }
#endif
  tracing_message(traceflag,"A5");
      if (ireturn ==1 && dcheck_flag ==0)
      {
        ireturn = 3;
      }
      if (ireturn >= 3)
      {
         /* Entering derivative check */
         derch(f, x, g, n, ireturn);
         return;
      }
      if (ireturn == 1) goto call1;
      if (ireturn == 2) goto call2;

     /* we are here because ireturn=0
        Start initializing function minimizer variables */
      fbest=1.e+100;
  tracing_message(traceflag,"A6");

      /* allocate Hessian
         h - object of class dfsdmat, the memory is allocated
             only for elements of lower triagonal matrix */
      if (!h) h.allocate(n);

      /* initialize w, the dvector of size 4*n:
         w(1,n) contains gradient vector in the point x_new = x_old + alpha*p_k
         w(n+1,2n) contains direction of linear search, i.e. transpose(p_k)
         w(2n+1,4n) are used for Hessian updating terms */
      w.initialize();

      /* alpha - the Newton step size */
      alpha=1.0; /* full Newton step at the beginning */
      ihflag=0;

      /* validity check for dimensions and indexing of
         independent vector and gradient vector
         Note, this function will work correctly only if
         indices start at 1  */
     if (n==0)
     {
       cerr << "Error -- the number of active parameters"
         " fmin must be > 0\n";
       ad_exit(1);
     }
  tracing_message(traceflag,"A7");
     if (x.indexmin() !=1)
     {
       cerr << "Error -- minimum valid index"
         " for independent_variables in fmin must be 1\n"
        << " it is " << x.indexmin() << "\n";
        ad_exit(1);
     }
     if (x.size() <n)
     {
       cerr << "Error -- the size of the independent_variables"
        " which is " << x.size() << " must be >= " << n << "\n"
        << " the number of independent variables in fmin\n";
        ad_exit(1);
     }
  tracing_message(traceflag,"A8");
     if (g.indexmin() !=1)
     {
       cerr << "Error -- minimum valid index"
         " for the gradient vector in fmin must be 1\n"
        << " it is " << g.indexmin() << "\n";
        ad_exit(1);
     }
     if (g.size() <n)
     {
       cerr << "Error -- the size of the gradient vector"
        " which is " << g.size() << " must be >=\n"
        << " the number of independent variables in fmin\n";
        ad_exit(1);
     }
     /* end of validity check */
  tracing_message(traceflag,"A9");

     /* xx is reserved for the updated values of independent variables,
        at the moment put the current values */
     for (i=1; i<=n; i++)
           xx.elem(i)=x.elem(i);
  tracing_message(traceflag,"A10");

      /* itn - iteration counter */
      itn=0;
      /* icc - obsolete calls counter? */
      icc=0;

       /* initialize funval vector,
          it will contain last 10 function values (10-th is the most recent)
          needed to stop minimization in case if f(1)-f(10)<min_improve  */
       for (i=1; i< 11; i++)
          funval.elem(i)=0.;
  tracing_message(traceflag,"A11");
      ihang = 0;  /* flag, =1 when function minimizer is not making progress */
      llog=1;
      np=n+1;
      n1=n-1;
      nn=n*np/2;
      is=n;
      iu=n;
      iv=n+n;
      ib=iv+n;
      iexit=0;    /* exit code */
  tracing_message(traceflag,"A12");

      /* Initialize hessian to the unit matrix */
      h.elem(1,1) = 1;
      for (i=2; i<=n; i++)
      {
        for ( j=1; j<i; j++)
        {
           h.elem(i,j)=0;
        }
        h.elem(i,i)=1;
      }
  tracing_message(traceflag,"A13");

      /* dmin - minimal element of hessian used to
         verify its positive definiteness */
      dmin=h.elem(1,1);
      for ( i=2; i<=n; i++)
      {
         if(h.elem(i,i)<dmin)
            dmin=h.elem(i,i);
      }
      if (dmin <= 0.)    /* hessian is not positive definite? */
         goto label7020; /* exit */
      if(dfn == 0.)
         z = 0.0;
  tracing_message(traceflag,"A14");
      for (i=1; i<=n; i++)
      {
        xsave.elem(i)=x.elem(i);
        x.elem(i)=xx.elem(i);
      }
      ireturn=1; /* upon next entry will go to call1 */
  tracing_message(traceflag,"A15");
      if (h.disk_save())
      {
        cout << "starting hessian save" << endl;
        h.save();
        cout << "finished hessian save" << endl;
      }
  tracing_message(traceflag,"A16");
      return;
      /* End of initialization */
  call1: /* first line search step and x update */
  tracing_message(traceflag,"A17");
      if (h.disk_save())
      {
        cout << "starting hessian restore" << endl;
        h.restore();
        cout << "finished hessian restore" << endl;
      }
  tracing_message(traceflag,"A18");
      for (i=1; i<=n; i++)
      {
        x.elem(i)=xsave.elem(i);
      }
      ireturn=3;
  tracing_message(traceflag,"A19");
      {
      }
      for ( i=1; i<=n; i++)
         gbest.elem(i)=g.elem(i);
  tracing_message(traceflag,"A20");
      funval.elem(10) = f;
      df=dfn;
      if(dfn == 0.0)
         df = f - z;
      if(dfn < 0.0)
         df=fabs(df * f);
      if(df <= 0.0)
         df=1.;
label20: /* check for convergence */
      ic=0; /* counter for number of calls */
      iconv = 1; /* convergence flag: 1 - convergence, 2 - not yet */
      for ( i=1; i<=9; i++)
         funval.elem(i)= funval.elem(i+1);
      funval.elem(10) = f;
      /* check if function value is improving */
      if ( itn>15 && fabs( funval.elem(1)-funval.elem(10))< min_improve )
         ihang = 1;
      gmax = 0;
      /* satisfy convergence criterion? */
      for ( i=1; i<=n; i++)
      {
        if(fabs(g.elem(i)) > crit) iconv = 2;
        if(fabs(g.elem(i)) > fabs(gmax) ) gmax = g.elem(i);
      }
      /* exit if either convergence or no improvement has been achieved
         during last 10 iterations */
      if( iconv == 1 || ihang == 1)
      {
         ireturn=-1;
         goto label92;
      }
      /* otherwise proceed to the Newton step (label21) */
      if(iprint == 0)
         goto label21; /* without printing */
      if(itn == 0)
         goto label7000; /* printing Initial statistics first */
#if defined(USE_DDOUBLE)
#undef double
      if(fmod(double(itn),double(iprint)) != 0)
         goto label21;
#define double dd_real
#else
      if(fmod(double(itn),double(iprint)) != 0)
         goto label21;
#endif
      if (llog) goto label7010;
#if defined (_MSC_VER) && !defined (__WAT32__)
        if (!scroll_flag) clrscr();
#endif
label7003: /* Printing table header */
      if (iprint>0)
      {
        if (ad_printf)
        {
          (*ad_printf)("%d variables; iteration %ld; function evaluation %ld",
           n, itn, ifn);
          if (pointer_to_phase)
          {
            (*ad_printf)("; phase %d", *pointer_to_phase);
          }
          (*ad_printf)(
           "\nFunction value %15.7le; maximum gradient component mag %12.4le\n",
#if defined(USE_DDOUBLE)
  #undef double
              double(f), double(gmax));
  #define double dd_real
#else
              f, gmax);
#endif
        }
      }
/*label7002:*/
      /* Printing Statistics table */
      if(iprint>0)
      {
        fmmdisp(x, g, n, this->scroll_flag,noprintx);
      }
label21 : /* Calculating Newton step */
      /* found good search direction, increment iteration number */
      itn=itn+1;
      for (i=1; i<=n; i++)
         x.elem(i)=xx.elem(i);
      w.elem(1)=-g.elem(1);
      pfmintime->get_elapsed_time_and_reset();

      /* solving system of linear equations H_(k+1) * (x_(k+1)-x(k)) = -g_k
         to get next search direction
         p_k = (x_(k+1)-x(k)) = - inv(H_(k+1)) * g_k */
      for (i=2; i<=n; i++)
      {
        i1=i-1;
        z=-g.elem(i);
        double * pd=&(h.elem(i,1));
        double * pw=&(w.elem(1));
        for (j=1; j<=i1; j++)
        {
          z-=*pd++ * *pw++;
        }
        w.elem(i)=z;
      }
      w.elem(is+n)=w.elem(n)/h.elem(n,n);
      {
        dvector tmp(1,n);
        tmp.initialize();
        for (i=1; i<=n1; i++)
        {
          j=i;
          double * pd=&(h.elem(n-j+1,n-1));
          double qd=w.elem(is+np-j);
          double * pt=&(tmp(1));
          for (int ii=1; ii<=n1; ii++)
          {
            *pt++ +=*pd-- * qd;
          }
          w.elem(is+n-i)=w.elem(n-i)/h.elem(n-i,n-i)-tmp(i);
        }
      }/* w(n+1,2n) now contains search direction
          with current Hessian approximation */
      gs=0.0;
      for (i=1; i<=n; i++)
         gs+=w.elem(is+i)*g.elem(i);/* gs = -inv(H_k)*g_k*df(x_k+alpha_k*p_k) */
      iexit=2;
      if(gs >= 0.0)
         goto label92; /* exit with error */
      gso=gs;
      /* compute new step length 0 < alpha <= 1 */
      alpha=-2.0*df/gs;
      if(alpha > 1.0)
        alpha=1.0;
      df=f;
      tot=0.0;
label30: /* Taking a step, updating x */
      iexit=3;
      if (ialph) { goto label92; } /* exit if step size too small */
      /* exit if number of function evaluations exceeded maxfn */
      if( ifn >= maxfn)
      {
        maxfn_flag=1;
        goto label92;
      }
      else
      {
        maxfn_flag=0;
        iexit=1;
      }
      if(quit_flag) goto label92;
      for (i=1; i<=n; i++)
      {
        /* w(n+1,2n) has the next direction to go */
        z=alpha*w.elem(is+i);
        /* new independent vector values */
        xx.elem(i)+=z;
      }
      for (i=1; i<=n; i++)
      { /* save previous values and update x return value */
        xsave.elem(i)=x.elem(i);
        gsave.elem(i)=g.elem(i);
        x.elem(i)=xx.elem(i);
        fsave = f;
      }
      fsave = f;
      ireturn=2;
      if (h.disk_save())
      {
        cout << "starting hessian save" << endl;
        h.save();
        cout << "finished hessian save" << endl;
      }
      return; // end of call1
  call2: /* Line search and Hessian update */
      if (h.disk_save())
      {
        cout << "starting hessian restore" << endl;
        h.restore();
        cout << "finished hessian restore" << endl;
      }
      /* restore x_k, g(x_k) and g(x_k+alpha*p_k) */
      for (i=1; i<=n; i++)
      {
        x.elem(i)=xsave.elem(i); //x_k
        w.elem(i)=g.elem(i);     //g(x_k+alpha*p_k)
        g.elem(i)=gsave.elem(i); //g(x_k)
      }
      fy = f;
      f = fsave; /* now fy is a new function value, f is the old one */
      ireturn=-1;
      /* remember current best function value, gradient and parameter values */
      if (fy <= fbest)
      {
        fbest=fy;
        for (i=1; i<=n; i++)
        {
          x.elem(i)=xx.elem(i);
          gbest.elem(i)=w.elem(i);
        }
      }
      /* what to do if CTRL-C keys were pressed */
      if (use_control_c==1)
      {
#if defined(__BORLANDC__)
         if ( kbhit() || ctlc_flag|| ifn == dcheck_flag )
#elif defined(_MSC_VER)
         //if ( kbhit() || ifn == dcheck_flag )
         if ( _kbhit() || ctlc_flag || ifn == dcheck_flag )
#else
         if(ctlc_flag || ifn == dcheck_flag )
#endif
         {
            int c=0;
            if (ifn != dcheck_flag)
            {
            #if defined(__DJGPP__)
              c = toupper(getxkey());
            #else
              c = toupper(getch());
            #endif
            }
            else
              c='C';
            if ( c == 'C')
            {
              for (i=1; i<=n; i++)
              {
                x.elem(i)=xx.elem(i);
              }
              ireturn = 3;
              derch(f, x , w, n, ireturn);
              return;
            }
            else if(c=='S')
            {
              //set convergence criteria to something high to stop now
              crit=100000.0;
              return;
            }
            else
            {
              if ( c == 'Q'|| c == 'N')
              {
                quit_flag=c;
                goto label92;
              }
              else
              {
                quit_flag=0;
              }
            }
         }
       }
       if (quit_flag)
       {
         if (quit_flag==1) quit_flag='Q';
         if (quit_flag==2) quit_flag='N';
         goto label92;
       }
      /* Otherwise, continue */
       /* Note, icc seems to be unused */
       icc+=1;
       if( icc >= 5)
          icc=0;
      /* ic - counter of calls without x update */
      ic++;
      if( ic >imax)
      {
         if (iprint>0)
         {
           if (ad_printf)
             (*ad_printf)("  ic > imax  in fminim is answer attained ?\n");
           fmmdisp(x, g, n, this->scroll_flag,noprintx);
         }
         ihflag=1;
         ihang=1;
         goto label92;
      }
      /* new function value was passed to fmin, will increment ifn */
      ifn++;

      gys=0.0;

      /* gys = transpose(p_k) * df(x_k+alpha_k*p_k) */
      for (i=1; i<= n; i++)
         gys+=w.elem(i)*w.elem(is+i);

      /* bad step; unless modified by the user, fringe default = 0 */
      if(fy>f+fringe)
      {
         goto label40; /* backtrack */
      }
      /* Otherwise verify if the search step length satisfies
         strong Wolfe condition */
      if(fabs(gys/gso)<=.9)
         goto label50; /* proceed to Hessian update */
/* or slightly modified constant in Wolfe condition for the number of
 calls > 4 */
      if(fabs(gys/gso)<=.95 && ic > 4)
         goto label50; /* proceed to Hessian update */
      if(gys>0.0) /* not a descent direction */
         goto label40; /* backtrack */
      tot+=alpha;
      z=10.0;
      if(gs<gys)
         z=gys/(gs-gys);
      if(z>10.0)
         z=10.0;
      /* increase step length */
      alpha=alpha*z;
      if (alpha == 0.)
      {
         ialph=1;
         #ifdef __ZTC__
         if (ireturn <= 0)
         {
           disp_close();
         }
         #endif
         return;
      }
      f=fy;
      gs=gys;
      goto label30; /* update x with new alpha */
label40: /* new step is not acceptable, stepping back and
            start backtracking along the Newton direction
            trying a smaller value of alpha */
      for (i=1;i<=n;i++)
         xx.elem(i)-=alpha*w.elem(is+i);
      if (alpha == 0.)
      {
        ialph=1;
        return;
      }
      /* compute new alpha */
      z=3.0*(f-fy)/alpha+gys+gs;
      zz=dafsqrt(z*z-gs*gys);
      z=1.0-(gys+zz-z)/(2.0*zz+gys-gs);
      if (fabs(fy-1.e+95) < 1.e-66)
      {
        alpha*=.001;
      }
      else
      {
        if (z>10.0)
        {
          cout << "large z" << z << endl;
          z=10.0;
        }
        alpha=alpha*z;
      }
      if (alpha == 0.)
      {
         ialph=1;
        if (ialph)
        {
          if (ad_printf) (*ad_printf)("\nFunction minimizer: Step size"
            "  too small -- ialph=1");
        }
         return;
      }
      goto label30; /* update x with new alpha */
label50: /* compute Hessian updating terms */
      alpha+=tot;
      f=fy;
      df-=f;
      dgs=gys-gso;
      xxlink=1;
      if(dgs+alpha*gso>0.0)
         goto label52;
      for (i=1;i<=n;i++)
         w.elem(iu+i)=w.elem(i)-g.elem(i);
      /* now w(n+1,2n) = df(x_k+alpha_k*p_k)-df(x_k) */
      sig=1.0/(alpha*dgs);
      goto label70;
label52: /* compute Hessian updating terms */
      zz=alpha/(dgs-alpha*gso);
      z=dgs*zz-1.0;
      for (i=1;i<=n;i++)
         w.elem(iu+i)=z*g.elem(i)+w.elem(i);
      sig=1.0/(zz*dgs*dgs);
      goto label70;
label60: /* compute Hessian updating terms */
      xxlink=2;
      for (i=1;i<=n;i++)
         w.elem(iu+i)=g.elem(i);
      if(dgs+alpha*gso>0.0)
         goto label62;
      sig=1.0/gso;
      goto  label70;
label62: /* compute Hessian updating terms */
      sig=-zz;
      goto label70;
label65: /* save in g the gradient df(x_k+alpha*p_k) */
      for (i=1;i<=n;i++)
         g.elem(i)=w.elem(i);
      goto  label20; //convergence check
label70:  // Hessian update
      w.elem(iv+1)=w.elem(iu+1);
      pfmintime->get_elapsed_time_and_reset();
      for (i=2;i<=n;i++)
      {
         i1=i-1;
         z=w.elem(iu+i);
         double * pd=&(h.elem(i,1));
         double * pw=&(w.elem(iv+1));
         for (j=1;j<=i1;j++)
         {
           z-=*pd++ * *pw++;
         }
         w.elem(iv+i)=z;
      }
      pfmintime->get_elapsed_time_and_reset();
      for (i=1;i<=n;i++)
      {  /* BFGS updating formula */
         z=h.elem(i,i)+sig*w.elem(iv+i)*w.elem(iv+i);
         if(z <= 0.0)
            z=dmin;
         if(z<dmin)
            dmin=z;
         h.elem(i,i)=z;
         w.elem(ib+i)=w.elem(iv+i)*sig/z;
         sig-=w.elem(ib+i)*w.elem(ib+i)*z;
       }
      for (j=2;j<=n;j++)
      {
         double * pd=&(h.elem(j,1));
         double * qd=&(w.elem(iu+j));
         double * rd=&(w.elem(iv+1));
         for (i=1;i<j;i++)
         {
            *qd-=*pd * *rd++;
            *pd++ +=w.elem(ib+i)* *qd;
         }
      }
      if (xxlink == 1) goto label60;
      if (xxlink == 2) goto label65;
/*label90:*/
      for (i=1;i<=n;i++)
         g.elem(i)=w.elem(i);
label92: /* Exit with error */
      if (iprint>0)
      {
        if (ialph)
        {
          if (ad_printf)
           (*ad_printf)("\nFunction minimizer: Step size too small -- ialph=1");
        }
        if (ihang == 1)
        {
          if (ad_printf)
            (*ad_printf)(
           "Function minimizer not making progress ... is minimum attained?\n");
#if defined(USE_DDOUBLE)
#undef double
           if (ad_printf)
           (*ad_printf)("Minimprove criterion = %12.4le\n",double(min_improve));
#define double dd_real
#else
           if (ad_printf)
             (*ad_printf)("Minimprove criterion = %12.4le\n",min_improve);
#endif
        }
      }
      if(iexit == 2)
      {
        if (iprint>0)
        {
          if (ad_printf)
            (*ad_printf)("*** grad transpose times delta x greater >= 0\n"
           " --- convergence critera may be too strict\n");
          ireturn=-1;
        }
      }
#if defined (_MSC_VER) && !defined (__WAT32__)
        if (scroll_flag == 0) clrscr();
#endif
      if (maxfn_flag == 1)
      {
        if (iprint>0)
        {
          if (ad_printf)
            (*ad_printf)("Maximum number of function evaluations exceeded");
        }
      }
      if (iprint>0)
      {
        if (quit_flag == 'Q')
          if (ad_printf) (*ad_printf)("User initiated interrupt");
      }
      if(iprint == 0) goto label777;
      if (ad_printf) (*ad_printf)("\n - final statistics:\n");
      if (ad_printf)
        (*ad_printf)("%d variables; iteration %ld; function evaluation %ld\n",
                       n, itn, ifn);
#if defined(USE_DDOUBLE)
#undef double
      if (ad_printf)
        (*ad_printf)(
             "Function value %12.4le; maximum gradient component mag %12.4le\n",
             double(f), double(gmax));
      if (ad_printf)
        (*ad_printf)(
          "Exit code = %ld;  converg criter %12.4le\n",iexit,double(crit));
#define double dd_real
#else
      if (ad_printf)
        (*ad_printf)(
          "Function value %12.4le; maximum gradient component mag %12.4le\n",
          f, gmax);
      if (ad_printf)
        (*ad_printf)(
          "Exit code = %ld;  converg criter %12.4le\n",iexit,crit);
#endif
      fmmdisp(x, g, n, this->scroll_flag,noprintx);
label777: /* Printing final Hessian approximation */
         if (ireturn <= 0)
         #ifdef DIAG
           if (ad_printf) (*ad_printf)("Final values of h in fmin:\n");
           cout << h << "\n";
         #endif
         #ifdef __ZTC__
         {
           disp_close();
         }
         #endif
         return;
label7000:/* Printing Initial statistics */
      if (iprint>0)
      {
#if defined (_MSC_VER) && !defined (__WAT32__)
        if (!scroll_flag) clrscr();
#endif
        if (ad_printf) (*ad_printf)("\nInitial statistics: ");
      }
      goto label7003;
label7010:/* Printing Intermediate statistics */
   if (iprint>0)
   {
#if defined (_MSC_VER) && !defined (__WAT32__)
     if (!scroll_flag) clrscr();
#endif
     if (ad_printf) (*ad_printf)("\nIntermediate statistics: ");
   }
   llog=0;
   goto label7003;
label7020:/* Exis because Hessian is not positive definite */
  if (iprint > 0)
  {
    if (ad_printf) (*ad_printf)("*** hessian not positive definite\n");
  }
#ifdef __ZTC__
  if (ireturn <= 0)
  {
    disp_close();
  }
#endif
}
Exemplo n.º 12
0
void decode_jpeg(struct jpeg_t *jpeg)
{
	if (!ve_open())
		err(EXIT_FAILURE, "Can't open VE");

	int input_size =(jpeg->data_len + 65535) & ~65535;
	uint8_t *input_buffer = ve_malloc(input_size);
	int output_size = ((jpeg->width + 31) & ~31) * ((jpeg->height + 31) & ~31);
	uint8_t *luma_output = ve_malloc(output_size);
	uint8_t *chroma_output = ve_malloc(output_size);
	memcpy(input_buffer, jpeg->data, jpeg->data_len);
	ve_flush_cache(input_buffer, jpeg->data_len);

	// activate MPEG engine
	void *ve_regs = ve_get(VE_ENGINE_MPEG, 0);

	// set restart interval
	writel(jpeg->restart_interval, ve_regs + VE_MPEG_JPEG_RES_INT);

	// set JPEG format
	set_format(jpeg, ve_regs);

	// set output buffers (Luma / Croma)
	writel(ve_virt2phys(luma_output), ve_regs + VE_MPEG_ROT_LUMA);
	writel(ve_virt2phys(chroma_output), ve_regs + VE_MPEG_ROT_CHROMA);

	// set size
	set_size(jpeg, ve_regs);

	// ??
	writel(0x00000000, ve_regs + VE_MPEG_SDROT_CTRL);

	// input end
	writel(ve_virt2phys(input_buffer) + input_size - 1, ve_regs + VE_MPEG_VLD_END);

	// ??
	writel(0x0000007c, ve_regs + VE_MPEG_CTRL);

	// set input offset in bits
	writel(0 * 8, ve_regs + VE_MPEG_VLD_OFFSET);

	// set input length in bits
	writel(jpeg->data_len * 8, ve_regs + VE_MPEG_VLD_LEN);

	// set input buffer
	writel(ve_virt2phys(input_buffer) | 0x70000000, ve_regs + VE_MPEG_VLD_ADDR);

	// set Quantisation Table
	set_quantization_tables(jpeg, ve_regs);

	// set Huffman Table
	writel(0x00000000, ve_regs + VE_MPEG_RAM_WRITE_PTR);
	set_huffman_tables(jpeg, ve_regs);

	// start
	writeb(0x0e, ve_regs + VE_MPEG_TRIGGER);

	// wait for interrupt
	ve_wait(1);

	// clean interrupt flag (??)
	writel(0x0000c00f, ve_regs + VE_MPEG_STATUS);

	// stop MPEG engine
	ve_put();

	//output_ppm(stdout, jpeg, output, output + (output_buf_size / 2));

	if (!disp_open())
	{
		fprintf(stderr, "Can't open /dev/disp\n");
		return;
	}

	int color;
	switch ((jpeg->comp[0].samp_h << 4) | jpeg->comp[0].samp_v)
	{
	case 0x11:
	case 0x21:
		color = COLOR_YUV422;
		break;
	case 0x12:
	case 0x22:
	default:
		color = COLOR_YUV420;
		break;
	}

	disp_set_para(ve_virt2phys(luma_output), ve_virt2phys(chroma_output),
			color, jpeg->width, jpeg->height,
			0, 0, 800, 600);

	getchar();

	disp_close();

	ve_free(input_buffer);
	ve_free(luma_output);
	ve_free(chroma_output);
	ve_close();
}
Exemplo n.º 13
0
int main(int argc, char** argv)
{
	AVFormatContext* avfmt_ctx = NULL;
	int video_stream;
	enum AVCodecID video_codec;

	if (argc < 2)
	{
		fprintf(stderr, "Usage: %s filename\n", argv[0]);
		exit(EXIT_FAILURE);
	}

	char *filename = argv[1];

	av_register_all();

	if (avformat_open_input(&avfmt_ctx, filename, NULL, NULL) < 0)
	{
		fprintf(stderr, "Could not open source file %s\n", filename);
		exit(1);
	}

	if (avformat_find_stream_info(avfmt_ctx, NULL) < 0)
	{
		fprintf(stderr, "Could not find stream information\n");
		avformat_close_input(&avfmt_ctx);
		exit(1);
	}

	video_stream = av_find_best_stream(avfmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);
	if (video_stream < 0)
	{
		fprintf(stderr, "Could not find video stream in input file\n");
		avformat_close_input(&avfmt_ctx);
		exit(1);
	}

	video_codec = avfmt_ctx->streams[video_stream]->codec->codec_id;

	if (video_codec != AV_CODEC_ID_MPEG1VIDEO && video_codec != AV_CODEC_ID_MPEG2VIDEO)
	{
		fprintf(stderr, "Can't handle codec %s\n", avcodec_get_name(video_codec));
		avformat_close_input(&avfmt_ctx);
		exit(1);
	}

	AVPacket pkt;
	av_init_packet(&pkt);
	pkt.data = NULL;
	pkt.size = 0;

	struct mpeg_t mpeg;
	memset(&mpeg, 0, sizeof(mpeg));
	if (video_codec == AV_CODEC_ID_MPEG1VIDEO)
		mpeg.type = MPEG1;
	else
		mpeg.type = MPEG2;

	if (!ve_open())
		err(EXIT_FAILURE, "Can't open VE");

	struct frame_buffers_t frame_buffers = { NULL, NULL, NULL };

	unsigned int disp_frame = 0, gop_offset = 0, gop_frames = 0, last_gop = 0;
	struct frame_t *frames[RING_BUFFER_SIZE];
	memset(frames, 0, sizeof(frames));

	// activate MPEG engine
	writel(ve_get_regs() + 0x00, 0x00130000);

	printf("Playing now... press Enter for next frame!\n");

	while (av_read_frame(avfmt_ctx, &pkt) >= 0)
	{
		mpeg.data = pkt.data;
		mpeg.len = pkt.size;
		mpeg.pos = 0;

		if (pkt.stream_index == video_stream && parse_mpeg(&mpeg))
		{
			// create output buffer
			frame_buffers.output = frame_new(mpeg.width, mpeg.height, COLOR_YUV420);
			if (!frame_buffers.backward)
				frame_buffers.backward = frame_ref(frame_buffers.output);
			if (!frame_buffers.forward)
				frame_buffers.forward = frame_ref(frame_buffers.output);

			// decode frame
			decode_mpeg(&frame_buffers, &mpeg);

			// simple frame reordering (not safe, only for testing)
			// count frames
			if (mpeg.gop > last_gop)
			{
				last_gop = mpeg.gop;
				gop_offset += gop_frames;
				gop_frames = 0;
			}
			gop_frames++;

			// save frame in ringbuffer
			if (frames[(gop_offset + mpeg.temporal_reference) % RING_BUFFER_SIZE] != NULL)
			{
				printf("Buffer overrun!\n");
				frame_unref(frames[(gop_offset + mpeg.temporal_reference) % RING_BUFFER_SIZE]);
			}
			frames[(gop_offset + mpeg.temporal_reference) % RING_BUFFER_SIZE] = frame_buffers.output;

			// if we decoded a displayable frame, show it
			if (frames[disp_frame % RING_BUFFER_SIZE] != NULL)
			{
				frame_show(frames[disp_frame % RING_BUFFER_SIZE]);
				frame_unref(frames[(disp_frame - 2) % RING_BUFFER_SIZE]);
				frames[(disp_frame - 2) % RING_BUFFER_SIZE] = NULL;
				disp_frame++;
				getchar();
			}

		}
		av_free_packet(&pkt);
	}

	// stop MPEG engine
	writel(ve_get_regs() + 0x0, 0x00130007);

	// show left over frames
	while (disp_frame < gop_offset + gop_frames && frames[disp_frame % RING_BUFFER_SIZE] != NULL)
	{
		frame_show(frames[disp_frame % RING_BUFFER_SIZE]);
		frame_unref(frames[(disp_frame - 2) % RING_BUFFER_SIZE]);
		frames[(disp_frame - 2) % RING_BUFFER_SIZE] = NULL;
		disp_frame++;
		getchar();
	}

	disp_close();

	frame_unref(frames[(disp_frame - 2) % RING_BUFFER_SIZE]);
	frame_unref(frames[(disp_frame - 1) % RING_BUFFER_SIZE]);

	frame_unref(frame_buffers.forward);
	frame_unref(frame_buffers.backward);

	ve_close();

	avformat_close_input(&avfmt_ctx);

	return 0;
}
Exemplo n.º 14
0
/***************************************************************************************************
*Name        : robin_set_mode
*Prototype   : __s32  robin_set_mode( robin_mode_e robin_mode )
*Arguments   : robin_mode    input. the work mode of the robin module.
*Return      : ==0    succeed
*              !=0    fail
*Description : set the work mode of the robin module.
*Other       :
***************************************************************************************************/
__s32  robin_set_mode( robin_mode_e robin_mode, robin_open_arg_t *arg_p )
{
    if(arg_p)
    {
        if(0 == arg_p->reserve_mem_size)
        {
            arg_p->reserve_mem_size = 512*1024;
        }
    }
    
	switch( robin_mode )
	{
		case ROBIN_MODE_AUDIO_MIN :
			disp_close( );
			willow_close( );
			npl_delete( );
			
			if( orchid_open( ) )
				goto error;
				
			if( npl_create( RAT_MEDIA_TYPE_AUDIO ) )
				goto error;
				
			if( cedar_open(arg_p ) )
				goto error;
				
			if( get_feedback_msgQ( ) )
				goto error;
				
			if( cmdQ_create( ) )
				goto error;
				
			if( robin_feedbackQ_create( ) )
				goto error;
				
			if( robin_monitor_create( ROBIN_MONITOR_PRIO ) )
				goto error;
				
			if( robin_cedar_mutex_create( ) )
				goto error;

			if( robin_cmd_mutex_create( ) )
				goto error;
				
			break;
		case ROBIN_MODE_AUDIO_MAX :
			npl_delete( );

			if( orchid_open( ) )
				goto error;
				
			if( npl_create( RAT_MEDIA_TYPE_AUDIO ) )
				goto error;
				
			if( cedar_open(arg_p ) )
				goto error;
				
			if( willow_open( ) )
				goto error;
				
			if( get_feedback_msgQ( ) )
				goto error;
				
			if( disp_open( ) )
				goto error;
		
			if( cmdQ_create( ) )
				goto error;
				
			if( robin_feedbackQ_create( ) )
				goto error;
				
			if( robin_monitor_create( ROBIN_MONITOR_PRIO ) )
				goto error;
				
			if( robin_cedar_mutex_create( ) )
				goto error;

			if( robin_cmd_mutex_create( ) )
				goto error;
				
			break;
		case ROBIN_MODE_VIDEO_MIN :
		case ROBIN_MODE_VIDEO_MAX :
			willow_close( );

			if( orchid_open( ) )
				goto error;
				
			if( npl_create( RAT_MEDIA_TYPE_VIDEO ) )
				goto error;
				
			if( cedar_open(arg_p ) )
				goto error;
				
			if( get_feedback_msgQ( ) )
				goto error;
				
			if( disp_open( ) )
				goto error;
		
			if( cmdQ_create( ) )
				goto error;
				
			if( robin_feedbackQ_create( ) )
				goto error;
				
			if( robin_monitor_create( ROBIN_MONITOR_PRIO ) )
				goto error;
				
			if( robin_cedar_mutex_create( ) )
				goto error;

			if( robin_cmd_mutex_create( ) )
				goto error;
				
			break;
		default :
			goto error;
	}
	
	cur_robin_mode = robin_mode;	
	return 0;
	
error:
	_release_res( );
	cur_robin_mode = ROBIN_MODE_UNKNOWN;
	return -1;
}
Exemplo n.º 15
0
int
main(int argc, char **argv)
{
	struct display *disp;
	struct v4l2 *v4l2;
	pthread_t threads[MAX_CAP];
	struct thr_data tdata[MAX_CAP];
	void *result = NULL;
	int ret = 0, i, multi = 1, idx = 0;
	char c;

	MSG("Opening Display..");
	disp = disp_open(argc, argv);
	if (!disp) {
		usage(argv[0]);
		return 1;
	}

	for (i = 1; i < argc; i++) {
		if (!argv[i])
			continue;

		if (!strcmp("--multi", argv[i])) {
			argv[i++] = NULL;
			sscanf(argv[i], "%d", &multi);
			argv[i] = NULL;
			if(multi < 1 || multi > MAX_CAP) {
				usage(argv[i]);
				return 1;
			}
		}
	}

	for (i = 0; i < multi; i++) {
		MSG("Opening V4L2..");
		v4l2 = v4l2_open(argc, argv, &tdata[i].fourcc,
			&tdata[i].width, &tdata[i].height);
		if (!v4l2) {
			usage(argv[0]);
			return 1;
		}
		tdata[i].disp = disp;
		tdata[i].v4l2 = v4l2;
	}

	if (check_args(argc, argv)) {
		/* remaining args.. print usage msg */
		usage(argv[0]);
		return 0;
	}

	for (i = 0; i < multi; i++) {
		ret = pthread_create(&threads[i], NULL, capture_loop, &tdata[i]);
		if(ret) {
			MSG("Failed creating thread");
		}
	}

	for (i = 0; i < multi; i++) {
		pthread_join(threads[i], &result);
	}

	disp_close(disp);

	return ret;
}
Exemplo n.º 16
0
void fn_help(char **args)
{
    static char spaces[] = "                ";

    struct binding *b;
    FILE *f;
    int what, c, i, j, l;
    char *s, *t;

    what = read_char("Help on <f>unction, <k>ey, or <o>ption "
		     "(shift for list)? ");

    switch (what) {
    case 'f':
	s = read_string("Function: ", 1);
	if (s == NULL || s[0] == '\0') {
	    free(s);
	    disp_status(DISP_STATUS, "");
	    return;
	}
	    
	if ((i=find_function(s)) == -1)
	    disp_status(DISP_STATUS, "no such function: %s", s);
	else
	    disp_status(DISP_STATUS, "%s: %s",
			functions[i].name, functions[i].help);

	free(s);
	break;

    case 'F':
	if ((f=disp_open(opt_pager, 1)) == NULL)
	    return;

	for (i=0; functions[i].name; i++) {
	    fprintf(f, "%-16.16s %s\n", functions[i].name, functions[i].help);
	}

	disp_close(f, 1);
	disp_status(DISP_STATUS, "");
	break;

    case 'k':
	c = read_char("Key: ");

	b = get_function(c, bs_none);
	if ((i=b->fn) == -1)
	    disp_status(DISP_STATUS, "[%s%s] key is unbound",
			(binding_state != bs_none ?
			 binding_statename[binding_state] : ""),
			print_key(c, 0));
	else {
	    char *buf;
	    int cols;

	    cols = tty_cols;
	    
	    if ((buf=(char *)malloc(cols+5)) == NULL)
		break;

	    sprintf(buf, "[%s%s] %s",
			(b->state != bs_none ?
			 binding_statename[b->state] : ""),
			print_key(c, 0),
			functions[i].name);
	    if (b->args) {
		int i, l;

		l = strlen(buf);
		for (i=0; b->args[i]; i++)
		    if (strlen(b->args[i])+l+2 > cols) {
			strcpy(buf+l, " ...");
			break;
		    }
		    else {
			sprintf(buf+l, " %s", b->args[i]);
			l += strlen(b->args[i])+1;
		    }
	    }

	    disp_status(DISP_STATUS, "%s", buf);
	    free(buf);
	}
	break;

    case 'K':
	if ((f=disp_open(opt_pager, 1)) == NULL)
	    return;

	for (i=0; i<max_fnkey+256; i++) {
	    for (b=&binding[i]; b; b=b->next) {
		if (b->fn != -1) {
		    s = (b->state != bs_none ?
			 binding_statename[b->state] : "");
		    t = print_key(i, 0);
		    l = strlen(s)+strlen(t);
		    fprintf(f, "%s%s%s%s",
			    s, t, spaces+((l>16) ? 16 : l),
			    functions[b->fn].name);
		    if (b->args) {
			for (j=0; b->args[j]; j++)
			    fprintf(f, " %s", b->args[j]);
		    }
		    fputc('\n', f);
		}
	    }
	}

	disp_close(f, 1);
	disp_status(DISP_STATUS, "");
	break;

    case 'o':
	s = read_string("Option: ", 1);
	if (s == NULL || s[0] == '\0') {
	    free(s);
	    disp_status(DISP_STATUS, "");
	    return;
	}
	    
	for (i=0; option[i].name; i++)
	    if (strcasecmp(option[i].name, s) == 0
		|| strcasecmp(option[i].shrt, s) == 0)
		break;
	
	if (option[i].name == NULL)
	    disp_status(DISP_STATUS, "no such option: %s", s);
	else {
	    char *buf;
	    
	    switch(option[i].type) {
	    case OPT_INT:
		if ((buf=(char *)malloc(30)) == NULL)
		    break;
		sprintf(buf, "(int) %d", *(option[i].var.i));
		break;
		
	    case OPT_CHR:
		if ((buf=(char *)malloc(30)) == NULL)
		    break;
		sprintf(buf, "(char) `%c'", *(option[i].var.i));
		break;

	    case OPT_STR:
		if ((buf=(char *)malloc(strlen(*(option[i].var.s))+10))
		    == NULL)
		    break;
		sprintf(buf, "(str) ``%s''", *(option[i].var.s));
		break;

	    case OPT_BOOL:
		if ((buf=(char *)malloc(30)) == NULL)
		    break;
		sprintf(buf, "(bool) %s",
			(*(option[i].var.i) ? "on" : "off"));
		break;

	    case OPT_ENUM:
		if ((buf=(char *)malloc(strlen(option[i].values[*(option[i].var.i)])+10))
		    == NULL)
		    break;
		sprintf(buf, "(enum) %s",
			option[i].values[*(option[i].var.i)]);
		break;
	    default:
		buf = NULL;
	    }

	    if (buf == NULL)
		break;

	    disp_status(DISP_STATUS, "%s (%s) [%s]: %s", 
			option[i].name, option[i].shrt,
			buf, option[i].help);
	}
	free(s);
	break;
	
    case 'O':
	if ((f=disp_open(opt_pager, 1)) == NULL)
	    return;
	
	for (i=0; option[i].name; i++) {
	    if (i > 0)
		fputc('\n', f);
	    
	    fprintf(f, "%s %-15.15s",
		     option[i].shrt, option[i].name);

	    switch(option[i].type) {
	    case OPT_INT:
		fprintf(f, "(int) %d\n", *(option[i].var.i));
		break;
		
	    case OPT_CHR:
		fprintf(f, "(char) `%c'\n", *(option[i].var.i));
		break;

	    case OPT_STR:
		fprintf(f, "(str) ``%s''\n", *(option[i].var.s));
		break;
		
	    case OPT_BOOL:
		fprintf(f, "(bool) %s\n",
			(*(option[i].var.i) ? "on" : "off"));
		break;
		
	    case OPT_ENUM:
		fprintf(f, "(enum) %s\n",
			option[i].values[*(option[i].var.i)]);
		break;
	    }
	    fprintf(f, "        %s\n", option[i].help);
	}

	disp_close(f, 1);
	disp_status(DISP_STATUS, "");
	
    default:
	disp_status(DISP_STATUS, "");
    }
}