/*    TEST.C   */

#include stdio
#include ssdef
#include descrip
#include lib$routines
#include hlpdef

#define  CLI$_PRESENT  261401
#define  CLI$_NEGATED  229880

int main( )
{
        long int TEST_COMMANDS(  );
        long int     status;
        static char  prompt[ ] = "TEST> ";

        $DESCRIPTOR( prompt_desc, prompt );

        for( ; ; )
          {
             status = cli$dcl_parse( 0
                                    ,TEST_COMMANDS
                                    ,lib$get_input
                                    ,lib$get_input
                                    ,&prompt_desc );
             if( (status & 1) == 1 )
                {
                   CLI$DISPATCH(  ) ;
                }
          }

}

test_routine(  )
{
        long int     status;
        char         string[ 80 ];
        static char  parameter[ 80 ];
        unsigned short int    len_param;

        $DESCRIPTOR( parameter_desc, parameter );
        $DESCRIPTOR( string_desc, string );

        strcpy( string, "P1" );
        string_desc.dsc$w_length = 2;
        status = CLI$PRESENT( &string_desc );
        if( status == CLI$_PRESENT )
           {
              status = cli$get_value( &string_desc
                                     ,&parameter_desc
                                     ,&len_param );
              if( (status & 1) != 1 )  lib$signal( status );
              parameter_desc.dsc$w_length = len_param;
           }
        else                                                     
           {
              strcpy( string,"Enter parameter: " );
              string_desc.dsc$w_length = strlen( string );
              status = lib$get_input( &parameter_desc
                                     ,&string_desc
                                     ,&len_param );
              if( (status & 1) != 1 )  lib$signal( status );
              parameter_desc.dsc$w_length = len_param;
           }

        strcpy( string,"FULL" );
        string_desc.dsc$w_length = 4;
        status = CLI$PRESENT( &string_desc );
        if( (status & 1) == 1 )
           {
              printf("FULL qualifier is present\n");
           }

        strcpy( string,"DATE" );
        string_desc.dsc$w_length = 4;
        status = CLI$PRESENT( &string_desc );
        if( status == CLI$_PRESENT )
           {
              printf("DATE qualifier is present\n");
           }
        else if( status == CLI$_NEGATED )
           {
              printf("DATE qualifier is negated\n");
           }
        else
           {
              printf("DATE qualifier is NOT present\n");
           }
}

show_routine(  )
{
        printf( " Routine SHOW\n" );
}



help_routine(  )
{ 
        long int     status;
        long int     mask;
        char         help_topic[ 33 ];
        short int    len_topic;
        char         string[ 80 ];
        static char  parameter[ 80 ];
        static char  help_library[ 256 ] = "SYS$HELP:MAILHELP.HLB";
        $DESCRIPTOR( string_desc, string );
        $DESCRIPTOR( help_topic_desc, help_topic );
        $DESCRIPTOR( help_library_desc, help_library );

        printf( " Routine HELP" );

        strcpy( string,"HELP_TOPIC" );
        string_desc.dsc$w_length = 10;
        status = cli$get_value( &string_desc
                               ,&help_topic_desc
                               ,&len_topic );
        help_topic_desc.dsc$w_length = len_topic;

        mask = HLP$M_HELP + HLP$M_PROMPT;
        status = lbr$output_help( lib$put_output, 0
                                 ,&help_topic_desc 
                                 ,&help_library_desc
                                 ,&mask
                                 ,lib$get_input);
}

exit_routine(  )
{
       exit( SS$_NORMAL );
}
