summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--multicat.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/multicat.c b/multicat.c
index 4983a13..3f3f80f 100644
--- a/multicat.c
+++ b/multicat.c
@@ -301,6 +301,7 @@ int main( int i_argc, char **pp_argv )
bool b_append = false;
uint8_t *p_buffer, *p_read_buffer;
size_t i_max_read_size, i_max_write_size;
+ char *p_input = "-", *p_output = "-";
int c;
i_verbose = VERB_WARN;
@@ -373,10 +374,25 @@ int main( int i_argc, char **pp_argv )
break;
}
}
- if ( optind >= i_argc - 1 )
- usage();
+ if ( optind < i_argc )
+ {
+ p_input = pp_argv[optind];
+ optind++;
+ }
+ if ( optind < i_argc )
+ {
+ p_output = pp_argv[optind];
+ optind++;
+ }
- if ( (i_input_fd = OpenSocket( pp_argv[optind], i_ttl, NULL )) >= 0 )
+ if ( strcmp( "-", p_input ) == 0 )
+ {
+ i_input_fd = STDIN_FILENO;
+ pf_Read = stream_Read;
+ pf_Skip = stream_Skip;
+ b_input_udp = true;
+ }
+ else if ( (i_input_fd = OpenSocket( p_input, i_ttl, NULL )) >= 0 )
{
pf_Read = udp_Read;
pf_Skip = udp_Skip;
@@ -384,10 +400,10 @@ int main( int i_argc, char **pp_argv )
else
{
bool b_stream;
- i_input_fd = OpenFile( pp_argv[optind], true, false, &b_stream );
+ i_input_fd = OpenFile( p_input, true, false, &b_stream );
if ( !b_stream )
{
- p_input_aux = OpenAuxFile( pp_argv[optind], true, false );
+ p_input_aux = OpenAuxFile( p_input, true, false );
pf_Read = file_Read;
pf_Skip = file_Skip;
}
@@ -398,25 +414,29 @@ int main( int i_argc, char **pp_argv )
}
b_input_udp = true; /* We don't need no, RTP header */
}
- optind++;
- if ( (i_output_fd = OpenSocket( pp_argv[optind], i_ttl, NULL ))
+ if ( strcmp( "-", p_output ) == 0 )
+ {
+ i_output_fd = STDOUT_FILENO;
+ pf_Write = stream_Write;
+ b_output_udp = true;
+ }
+ else if ( (i_output_fd = OpenSocket( p_output, i_ttl, NULL ))
>= 0 )
pf_Write = udp_Write;
else
{
bool b_stream;
- i_output_fd = OpenFile( pp_argv[optind], false, b_append, &b_stream );
+ i_output_fd = OpenFile( p_output, false, b_append, &b_stream );
if ( !b_stream )
{
- p_output_aux = OpenAuxFile( pp_argv[optind], false, b_append );
+ p_output_aux = OpenAuxFile( p_output, false, b_append );
pf_Write = file_Write;
}
else
pf_Write = stream_Write;
b_output_udp = true; /* We don't need no, RTP header */
}
- optind++;
srand( time(NULL) * getpid() );
i_max_read_size = i_asked_payload_size + (b_input_udp ? 0 :