Metropoli BBS
VIEWER: bcommand.c MODE: TEXT (ASCII)
/***************************************************************************
 *		  Copyright (C) 1994  Charles P. Peterson                  *
 *	     4007 Enchanted Sun, San Antonio, Texas 78244-1254             *
 *              Email: Charles_P_Peterson@fcircus.sat.tx.us                *
 *                                                                         *
 *		  This is free software with NO WARRANTY.                  *
 *	      See gfft.c, or run program itself, for details.              *
 *		      Support is available for a fee.                      *
 ***************************************************************************
 *
 * Program:     gfft--General FFT analysis
 * File:        bcommand.c
 * Purpose:     process batch (i.e. shell) commands (noninteractively)
 * Author:      Charles Peterson (CPP)
 * History:     4-November-1993 CPP; Created.
 * Comment:     error not caught here; must be caught by caller
 *              Special logic: If a READ command is given for which there
 *               is no following OK, GO, or WORKBENCH command, an OK command
 *               is executed before return by default.  (Thus, OK is not
 *               required in batch mode.)
 */

#include <string.h>
#include "gfft.h"

extern Name_Info_St Gfft_Command[];

void batch_command (int argc, char *argv[])
{
    int ntoken;
    BOOLEAN ok_before_exit = FALSE;
    Name_Info_St *command_invoked;

    for (ntoken = 1; ntoken < argc; ntoken++)
    {
    /*
     * Filter out 'set' commands
     */
	Name_Info_St *name = identify_name (argv[ntoken], Gfft_Command, 
					   FALSE);
	if (!strcmp (name->full_string, "Set"))
	{
	    continue;
	}
    /*
     * Now see if the FOLLOWING
     * token is a command too.  If not, it must be an argument to this one.
     */
	if (ntoken+1 < argc)
	{
	    if (!identify_name (argv[ntoken+1], Gfft_Command, FALSE))
	    {
	    /*
	     * This command has one argument
	     */
		strcpy (Command, argv[ntoken]);
		strcat (Command," ");
		strcat (Command, argv[ntoken+1]);
		ntoken++;
	    }
	    else
	    {
		strcpy (Command, argv[ntoken]);
	    }
	}
	else
	{
	    strcpy (Command, argv[ntoken]);
	}
	command_invoked = invoke_method (Command, Gfft_Command);
	if ( !strcmp (command_invoked->full_string, "Read"))
	{
	    ok_before_exit = TRUE;
	}
	else if ( !strcmp (command_invoked->full_string, "Write"))
	{
	    ok_before_exit = TRUE;
	}
	else if ( !strcmp (command_invoked->full_string, "Append"))
	{
	    ok_before_exit = TRUE;
	}
	else if ( !strcmp (command_invoked->full_string, "OK"))
	{
	    ok_before_exit = FALSE;
	}
	else if ( !strcmp (command_invoked->full_string, "Go"))
	{
	    ok_before_exit = FALSE;
	}
#ifdef AMIGA
	else if ( !strcmp (command_invoked->full_string, "Workbench"))
	{
	    ok_before_exit = FALSE;
	}
#endif
    }
    if (ok_before_exit)
    {
	ok (NullString);
    }
}
[ RETURN TO DIRECTORY ]