rc_t CC KMain( int argc, char * argv[] ) { Args * args; rc_t rc = ArgsMakeAndHandle ( &args, argc, argv, 1, MyOptions, sizeof MyOptions / sizeof ( OptDef ) ); if ( rc != 0 ) LogErr( klogInt, rc, "ArgsMakeAndHandle() failed\n" ); else { context *ctx; KLogHandlerSetStdErr(); rc = context_init( &ctx ); if ( rc != 0 ) LogErr( klogInt, rc, "context_init() failed\n" ); else { rc = context_capture_arguments_and_options( args, ctx ); if ( rc != 0 ) LogErr( klogInt, rc, "context_capture_arguments_and_options() failed\n" ); else { if ( ctx->usage_requested ) MiniUsage( args ); else { switch( ctx->output_mode[ 0 ] ) { case 'd' : case 't' : if ( context_schema_count( ctx ) == 0 ) { OUTMSG(( "cannot write, schema-file is missing:\n" )); Usage( args ); rc = RC( rcApp, rcNoTarg, rcConstructing, rcSelf, rcNull ); } } if ( rc == 0 ) { /* ************************* */ rc = gater_and_write( ctx ); /* ************************* */ } } } context_destroy ( ctx ); } ArgsWhack ( args ); } return rc; }
/*************************************************************************** Main: * create the copy-context * parse the commandline for arguments and options * react to help/usage - requests ( no dump in this case ) these functions are in vdb-copy-context.c * call copy_main() to execute the copy-operation * destroy the copy-context ***************************************************************************/ rc_t CC KMain ( int argc, char *argv [] ) { Args * args; rc_t rc = ArgsMakeAndHandle ( &args, argc, argv, 1, MyOptions, sizeof MyOptions / sizeof ( OptDef ) ); if ( rc != 0 ) { LOGERR( klogErr, rc, "ArgsMakeAndHandle() failed" ); } else { context *ctx; KLogHandlerSetStdErr(); rc = context_init( &ctx ); if ( rc != 0 ) { LOGERR( klogInt, rc, "KMain:context_init() failed" ); } else { rc = context_capture_arguments_and_options( args, ctx ); if ( rc != 0 ) { MiniUsage( args ); if ( argc < 2 ) rc = 0; } else { if ( ctx->usage_requested ) MiniUsage( args ); else rc = ref_seq_load_main( ctx ); /* <====================== */ } context_destroy( ctx ); } ArgsWhack ( args ); } return rc; }