コード例 #1
0
ファイル: testscrp.c プロジェクト: cookrn/openamq
int main (int argc, char *argv [])
{
    int
        argn;
    char
       *arg;
    Bool
        parallel = FALSE;

    gsl_argc = argc;
    gsl_argv = argv;

    if (gsl_argc <= 1)
      {
        printf ("testscrp [-parallel] <filename> ...\n");
        exit;
      }

    smt_init ();                        /*  Initialise SMT kernel            */
    myqueue = queue_create (NULL, 0);
    if (! myqueue)
      {
        fprintf (stderr, "Error creating queue.\n");
        exit (1);
      }

    if (ggscrp_init (0))                /*  Initialise script handler        */
      {
        fprintf (stderr, "Can't start parser agent...\n");
        exit (1);
      }

    argn = 1;
    while (argn < gsl_argc)
      {
        arg = gsl_argv [argn];
        if (streq (arg, "-parallel"))
            parallel = TRUE;
        else
          {
            if (load_script_file (argv [argn], TRUE, FALSE, TRUE, argn, myqueue))
              {
                fprintf (stderr, "Can't create script loading thread...\n");
                exit (1);
              }

            if (! parallel)
                execute_smt ();
          }
        argn++;
      }

    if (parallel)
        execute_smt ();

    ggscrp_term ();
    queue_destroy (myqueue);
    smt_term ();                        /*  Shut-down SMT kernel             */

    mem_assert ();
    return (EXIT_SUCCESS);
}
コード例 #2
0
ファイル: main.c プロジェクト: AlexS2172/IVRMstandard
int main ( int argc,
	    char *argv[ ] )
/*
Function:   main
Author:     Neil Cossor
Modified:   20000122

Description:

   This function starts the program, gathers the log on data, logs on to the
   system, downloads various data, sets up the exit procedure,
   and kicks off the main loop.

Input Parameters:

    (generic C) The first string (argv[0]) is the program name, and each
    following string is an argument passed to the program from the command
    line. The last pointer (argv[argc]) is NULL.

    (app specific, if supplied.. may be NULLed by specifying "" in command line)
    argv[1] == name of logfile for output. Default LOGFILE.TXT
    argv[2] == name of User file, containing CLICK username, gateway name etc
	defaults to name (in const.h) #defined by USER_DATA_FILENAME
    argv[3] == name of script file to run. No default.
	If supplied, then it is
	- loaded immediately
	- run
	- and then the application exits
	If not supplied, then we run in interactive mode. Note that a script
	file can be LOADed and RUN from interactive mode.
*/
{
    int32   status_i		=   SUCCESSFUL;
    int8    command_line_s[USER_INPUT_BUFFER_LEN];


	click_details_xt z;
	int k = sizeof(z.log_reply_x.trans_reply_x );

    /* code */
    printf("\n\nWelcome to Version %s of the simulator.\n",SIM_VERSION);
    printf("______________________________________________\n\n");
    printf("\nThis session started on " );
    printf_time ();
    printf ("\n");
    printf ("Commandline args are :-\n");
    display_arglist ( argc, &argv[0] );

    // stash the supplied command line params
    // try for 4th param - script filename
    if ( argc > 3)
    {
	// have enough arguments for a script filename
	user_script_filename_ps = argv[3];
    }
    if ( argc > 2)
    {
	// have enough arguments for a user param filename
	strcpy ( user_param_filename_ps, argv[2] );
    }
    if ( argc > 1)
    {
	// have more arguments than just the program name - try for logfile name
	user_log_filename_ps = argv[1];
    }	// test if enuff params for a logfile name to be supplied

    // try to set everything up... including allocation of memory for generic data
    click_px = ISESim_init ( argc, &argv[0] );
    if (click_px == NULL)   // 0
    {
	printf("\nAborting - error starting logger\n");
	exit(0);
    }

    // if the caller supplied a SIM script file, then we just load that,
    // execute it, and exit
    if ( ( user_script_filename_ps != NULL )
	&& ( strlen ( user_script_filename_ps ) != 0 ) )
    {
	// load and run the script
	status_i = load_script_file ( user_script_filename_ps );
	// did the load work OK
	if (status_i == SUCCESSFUL)
	{
	    // attempt to actually run the script
	    // 1 argument, no "parameter", so it makes it default to 1 run
	    status_i = run_script_file ( click_px, 1, NULL );
	}   // test if script load worked OK
    }
    else
    {
	// print out help prompt
	printf("Commands useful at this point are:- \n\tLOAD LOGON HELP EXIT QUIT.\n\n");
	printf("Please Type '?' or Help for Help on Commands\n");

	status_i = SUCCESSFUL;
	while (status_i >= SUCCESSFUL)
	{
	    // zot the input line
	    memset (&command_line_s[0],
		   (char)0,
		    sizeof (command_line_s));

	    // process keyboard input
	    printf("ISESim> ");
	    // get a command from the user
	    read_kbd_input ( &command_line_s[0] );
	    // and process it
	    status_i = process_commands (click_px,
					    &command_line_s[0],
					    FALSE );
	}   // while no errors processing commands, and no exit/quit request
    };	// test if running a script from initial program arguments

    exit (status_i);
}   // main