Esempio n. 1
0
void Client::onRedirect(const string& aRedirectUrl) noexcept {
	if (ClientManager::getInstance()->hasClient(aRedirectUrl)) {
		statusMessage(STRING(REDIRECT_ALREADY_CONNECTED), LogMessage::SEV_INFO);
		return;
	}

	redirectUrl = aRedirectUrl;

	if (SETTING(AUTO_FOLLOW)) {
		doRedirect();
	} else {
		fire(ClientListener::Redirect(), this, redirectUrl);
	}
}
Esempio n. 2
0
static long doExec( const char *std_in, const char *std_out, const char *cmd )
{
    long        st;
    int         save_in, new_in;
    int         save_out, new_out;
#if 0
    char        buffer[MAX_INPUT_LINE];
    char        *argv[MAX_ARGS];
    char        *s;
    int         i;
#endif

    save_in = -1;
    new_in = -1;
    save_out = -1;
    new_out = -1;
    preSpawn();
    if( std_in != NULL ) {
        save_in = dup( STDIN_FILENO );
        new_in = doRedirect( STDIN_FILENO, std_in, O_RDONLY | O_BINARY );
        if( new_in == -1 ) {
            close( save_in );
            return( -1L );
        }
    }
    if( std_out != NULL ) {
        save_out = dup( STDOUT_FILENO );
        new_out = doRedirect( STDOUT_FILENO, std_out,
                              O_WRONLY | O_BINARY | O_CREAT | O_TRUNC );
        if( new_out == -1 ) {
            close( save_out );
            if( std_in != NULL ) {
                close( new_in );
                dup2( save_in, STDIN_FILENO );
                close( save_in );
            }
            return( -1L );
        }
    }

#if 0
    strcpy( buffer, cmd );
    s = buffer;
    for( i = 0; i < MAX_ARGS; i++ ) {
        while( isspace( *s ) )
            s++;
        if( *s == '\0' ) {
            argv[i] = NULL;
            break;
        }
        argv[i] = s;
        while( *s != '\0' && !isspace( *s ) ) {
            s++;
        }
        if( *s != '\0' ) {
            *s++ = '\0';
        } else {
            argv[i + 1] = NULL;
            break;
        }
    }

    st = spawnvp( P_WAIT, argv[0], argv );

#else
#if defined( __NT__ )
    if( cmd == NULL ) {
        st = MySpawn( Comspec );
    } else {
        SetConsoleActiveScreenBuffer( GetStdHandle( STD_OUTPUT_HANDLE ) );
        st = system( cmd );
    }
#elif defined( __UNIX__ ) || defined( __OS2__ )
    st = MySpawn( cmd );
#else
    st = system( cmd );
#endif
#endif

    if( std_in != NULL ) {
        close( new_in );
        dup2( save_in, STDIN_FILENO );
        close( save_in );
    }
    if( std_out != NULL ) {
        close( new_out );
        dup2( save_out, STDOUT_FILENO );
        close( save_out );
    }
    postSpawn( st );
    return( st );
}