Skip to content

Commit

Permalink
Resolves #10, #7
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebaggett committed Aug 5, 2017
1 parent 3dd15a5 commit 4f23c3a
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions powercat.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ Examples:

Write-Verbose "Setting up Stream 1... (ESC/CTRL to exit)"
try{$Stream1Vars = Stream1_Setup $Stream1SetupVars}
catch{Write-Verbose "Stream 1 Setup Failure" ; break}
catch{Write-Verbose "Stream 1 Setup Failure" ; return}

Write-Verbose "Setting up Stream 2... (ESC/CTRL to exit)"
try
Expand All @@ -618,17 +618,17 @@ Examples:
}
catch
{
Write-Verbose "Stream 2 Setup Failure" ; break
Write-Verbose "Stream 2 Setup Failure" ; return
}

if($InputToWrite -ne @())
{
Write-Verbose "Writing input to Stream 1..."
try{$Stream1Vars = Stream1_WriteData $InputToWrite $Stream1Vars}
catch{Write-Host "Failed to write input to Stream 1" ; break}
catch{Write-Host "Failed to write input to Stream 1" ; return}
}

if($d){Write-Verbose "-d (disconnect) Activated. Disconnecting..." ; break}
if($d){Write-Verbose "-d (disconnect) Activated. Disconnecting..." ; return}

Write-Verbose "Both Communication Streams Established. Redirecting Data Between Streams..."
while($True)
Expand Down Expand Up @@ -656,7 +656,7 @@ Examples:
}
catch
{
Write-Verbose "Failed to redirect data from Stream 2 to Stream 1" ; break
Write-Verbose "Failed to redirect data from Stream 2 to Stream 1" ; return
}

try
Expand All @@ -668,7 +668,7 @@ Examples:
}
catch
{
Write-Verbose "Failed to redirect data from Stream 1 to Stream 2" ; break
Write-Verbose "Failed to redirect data from Stream 1 to Stream 2" ; return
}
}
}
Expand Down Expand Up @@ -747,48 +747,48 @@ Examples:

Write-Verbose "Setting up Stream 1..."
try{$Stream1Vars = Stream1_Setup $Stream1SetupVars}
catch{Write-Verbose "Stream 1 Setup Failure" ; break}
catch{Write-Verbose "Stream 1 Setup Failure" ; return}

Write-Verbose "Setting up Stream 2..."
try{$Stream2Vars = Stream2_Setup $Stream2SetupVars}
catch{Write-Verbose "Stream 2 Setup Failure" ; break}
catch{Write-Verbose "Stream 2 Setup Failure" ; return}

$Data = $null

if($InputToWrite -ne @())
{
Write-Verbose "Writing input to Stream 1..."
try{$Stream1Vars = Stream1_WriteData $InputToWrite $Stream1Vars}
catch{Write-Host "Failed to write input to Stream 1" ; break}
catch{Write-Host "Failed to write input to Stream 1" ; return}
}

if($d){Write-Verbose "-d (disconnect) Activated. Disconnecting..." ; break}
if($d){Write-Verbose "-d (disconnect) Activated. Disconnecting..." ; return}

Write-Verbose "Both Communication Streams Established. Redirecting Data Between Streams..."
while($True)
{
try
{
$Data,$Stream2Vars = Stream2_ReadData $Stream2Vars
if($Data.Length -eq 0){Start-Sleep -Milliseconds 100}
if(($Data.Length -eq 0) -or ($Data -eq $null)){Start-Sleep -Milliseconds 100}
if($Data -ne $null){$Stream1Vars = Stream1_WriteData $Data $Stream1Vars}
$Data = $null
}
catch
{
Write-Verbose "Failed to redirect data from Stream 2 to Stream 1" ; break
Write-Verbose "Failed to redirect data from Stream 2 to Stream 1" ; return
}

try
{
$Data,$Stream1Vars = Stream1_ReadData $Stream1Vars
if($Data.Length -eq 0){Start-Sleep -Milliseconds 100}
if(($Data.Length -eq 0) -or ($Data -eq $null)){Start-Sleep -Milliseconds 100}
if($Data -ne $null){$Stream2Vars = Stream2_WriteData $Data $Stream2Vars}
$Data = $null
}
catch
{
Write-Verbose "Failed to redirect data from Stream 1 to Stream 2" ; break
Write-Verbose "Failed to redirect data from Stream 1 to Stream 2" ; return
}
}
}
Expand Down

0 comments on commit 4f23c3a

Please sign in to comment.