# include <stdio.h>

# include MPH_H
# include MUT_H
# include RDS_H
# include RUT_H
# include RTL_H
# include RFM_H
# include RPR_H

 int main( argc, argv )

    int   argc;
    char *argv[];
 {
   rdsfig_list *FigureRds;
   rdsfig_list *HeadRds;
   rdsfig_list *StopRds;
   rdsfig_list *ScanRds;
   phfig_list  *FigureMbk;
   rdsins_list *Instance;
   rdsrec_list *Rec;
   rdsrec_list *DelRec;
   char         Layer;

   if ( argc < 3 ) return( 0 );

   mbkenv();
   rdsenv();
   loadrdsparam();

   if ( !strcmp( argv[1], "-t" ) )
   {
     FigureMbk = getphfig( argv[2], 'A' );
     FigureRds = figmbkrds( FigureMbk, 0, 0 );

     modelmbkrds( FigureRds, 0 );

     rflattenrdsfig( FigureRds, RDS_YES );

     saverdsfig( FigureRds );
   }
   else
   if ( !strcmp( argv[1], "-f" ) )
   {
     FigureMbk = getphfig( argv[2], 'A' );
     FigureRds = figmbkrds( FigureMbk, 0, 0 );

     modelmbkrds( FigureRds, 0 );

     if ( FigureRds->INSTANCE != (rdsins_list *)NULL )
     {
       flattenrdsfig( FigureRds, FigureRds->INSTANCE->INSNAME , RDS_YES );
     }

     saverdsfig( FigureRds );
   }
   else
   if ( !strcmp( argv[1], "-s" ) )
   {
     FigureMbk = getphfig( argv[2], 'A' );
     FigureRds = figmbkrds( FigureMbk, 0, 0 );

     viewrdsfig( FigureRds );

     modelmbkrds( FigureRds, 0 );

     saverdsfig( FigureRds );
   }
   else
   if ( !strcmp( argv[1], "-x" ) )
   {
     FigureRds = getrdsfig( argv[2], 'A', 0  );

     FigureRds->NAME = namealloc( argv[3] );

     viewrdsfig( FigureRds );

     saverdsfig( FigureRds );
   }
   else
   {
     FigureRds = getrdsfig( argv[2], 'V', 0  );

     viewrdsfig( FigureRds );

     for ( FigureRds  = HEAD_RDSFIG;
           FigureRds != (rdsfig_list *)NULL;
           FigureRds  = FigureRds->NEXT )
     {
       viewrdsfig( FigureRds );
     }
   }

   return( 0 );
 }
