Beispiel #1
0
/*-------------------------------------------------------------------*/
int cpu_cmd(int argc, char *argv[], char *cmdline)
{
    BYTE    c;
    int     rc      =  0;
    int     cpu     = -1;
    int     currcpu = sysblk.pcpu;
    char    cmd[32768];

    memset(cmd,0,sizeof(cmd));

    if (argc < 2)
    {
        WRMSG(HHC02202, "E", argv[0] );
        return -1;
    }

    if (sscanf(argv[1], "%x%c", &cpu, &c) != 1
     || cpu < 0 || cpu >= sysblk.maxcpu)
    {
        WRMSG(HHC02205, "E", argv[1], ": target processor is invalid" );
        return -1;
    }

    sysblk.dummyregs.cpuad = cpu;
    sysblk.pcpu = cpu;

    strlcpy(cmd,cmdline,sizeof(cmd));

    if ( argc > 2 )
    {
         u_int i = 0;
         u_int j = 0;
         u_int n = (u_int)strlen(cmd);

         /* Skip leading blanks, if any */
         for ( ; i < n && cmd[i] == ' '; i++ );

         /* Skip two words */
         for ( ; j < 2; j++ )
         {
           for ( ; i < n && cmd[i] != ' '; i++ );
           for ( ; i < n && cmd[i] == ' '; i++ );
         }

         /* Issue command to temporary target cpu */
         if (i < n)
         {
             rc = HercCmdLine(cmd+i);
             sysblk.pcpu = currcpu;
             sysblk.dummyregs.cpuad = currcpu;
         }
    }

    return rc;
}
Beispiel #2
0
void *panel_command (void *cmdline)
#endif
{
#define MAX_CMD_LEN (32768)
    char  cmd[ MAX_CMD_LEN ];           /* Copy of panel command     */
    char *pCmdLine;
    unsigned i;
    int hercecho = 1;                   /* Default echo to console   */

    pCmdLine = cmdline;
    ASSERT( pCmdLine );
    /* Every command will be stored in history list,
       EXCEPT: null commands, script commands, scp input,
       and "silent" commands (prefixed with '-') */
    if (*pCmdLine != 0 && !FindSCRCTL(thread_id()))
    {
        if (!(*pCmdLine == '-'))    /* (normal command?) */
        {
#if defined( _FEATURE_SYSTEM_CONSOLE )
            if (*pCmdLine == '.' || *pCmdLine == '!')
            {
                if (sysblk.scpecho)
                    history_add( cmdline );
            }
            else
#endif /* defined( _FEATURE_SYSTEM_CONSOLE ) */
                history_add( cmdline );
        }
    }

    /* Copy panel command to work area, skipping leading blanks */

    /* If the command starts with a -, then strip it and indicate
     * that we do NOT want the command echoed to the console. */
    hercecho = 1; /* (default) */
    while (*pCmdLine && isspace( *pCmdLine ))
        pCmdLine++;
    i = 0;
    while (*pCmdLine && i < (MAX_CMD_LEN-1))
    {
        if (i == 0 && (0            /* (1st character?) */
                       || *pCmdLine == '-'     /* (silent command) */
                       || *pCmdLine == '#'     /* (silent comment) */
                      ))
        {
            hercecho = 0;           /* (silence please) */
            if (*pCmdLine == '-')   /* (silent command) */
            {
                pCmdLine++;         /* (skip past the '-' ... */
                /* ... and remove blanks) */
                while (*pCmdLine && isspace(*pCmdLine))
                    pCmdLine++;     /* (get past blank) */
            }
        }
        cmd[i] = *pCmdLine;
        i++;
        pCmdLine++;
    }
    cmd[i] = 0;

    /* (just pressing the enter key shouldn't be echoed) */
    if (0 == cmd[0])
        hercecho = 0;               /* (silence please) */

#if defined( OPTION_CMDTGT )
    /* Check for herc, scp or pscp command... */

    /* Please note: 'cmdtgt' is a hercules command, but will be
       passed to the scp if scp target is set! This means that
       once the scp target has been set, to change the target
       back to herc, you must use: "herc cmdtgt herc". This is
       because the 'herc' command is ALWAYS a Hercules command
       (regardless of command target mode), whereas the 'cmdtgt'
       is passed to the scp whenever scp target mode is set.
       Thus you must explicitly request 'cmdtgt' be processed
       by Hercules and not the scp, by using the 'herc' prefix.
    */
    if (0
            || !strncasecmp( cmd, "herc ", 5 )   /* Hercules     */
            || !strncasecmp( cmd, "scp ",  4 )   /* Guest O/S    */
            || !strncasecmp( cmd, "pscp ", 5 )   /* Priority SCP */
       )
    {
        if (hercecho)
            EchoHercCmdLine( cmd );
        HercCmdLine( cmd );
        return NULL;
    }

    /* Send the command to the currently active command target */
    switch (sysblk.cmdtgt)
    {
    case CMDTGT_HERC:           /* Hercules */
    {
        /* (stay compatible) */
#endif /* defined( OPTION_CMDTGT ) */

#if defined( _FEATURE_SYSTEM_CONSOLE )
        if(cmd[0] == '.' || cmd[0] == '!')
        {
            int priomsg = cmd[0] == '!'  ? TRUE : FALSE;
            int scpecho = sysblk.scpecho ? TRUE : FALSE;
            if (!cmd[1]) {      /* (empty command given?) */
                cmd[1] = ' ';   /* (must send something!) */
                cmd[2] = 0;
            }
            scp_command( cmd+1, priomsg, scpecho );
        }
        else
#endif /* defined( _FEATURE_SYSTEM_CONSOLE ) */
        {
            if (hercecho && *cmd)
                EchoHercCmdLine( cmd );
#if defined( OPTION_CONFIG_SYMBOLS )
            /* Perform variable substitution */
            /* First, set some 'dynamic' symbols
               to their own values */
            set_symbol( "CUU",  "$(CUU)"  );
            set_symbol( "CCUU", "$(CCUU)" );
            set_symbol( "DEVN", "$(DEVN)" );
            {
                char *cl = resolve_symbol_string( cmd );
                HercCmdLine( cl );
                free( cl );
            }
#else /* !defined( OPTION_CONFIG_SYMBOLS ) */
            HercCmdLine( cmd );
#endif /* defined( OPTION_CONFIG_SYMBOLS ) */
        }
#if defined( OPTION_CMDTGT )
        break;
    }
    case CMDTGT_SCP:        /* Guest O/S */
    {
        int priomsg = FALSE;    /* normal scp command     */
        int scpecho = TRUE;     /* (always echo to hmc)   */
        if (!cmd[0]) {      /* (empty command given?) */
            cmd[0] = ' ';   /* (MUST send something!) */
            cmd[1] = 0;
        }
        scp_command( cmd, priomsg, scpecho );
        break;
    }
    case CMDTGT_PSCP:       /* Priority SCP */
    {
        int priomsg = TRUE;     /* Priority scp command   */
        int scpecho = TRUE;     /* (always echo to hmc)   */
        if (!cmd[0]) {      /* (empty command given?) */
            cmd[0] = ' ';   /* (MUST send something!) */
            cmd[1] = 0;
        }
        scp_command( cmd, priomsg, scpecho );
        break;
    }
    }
#endif /* defined( OPTION_CMDTGT ) */

    return NULL;
}