mirror of https://github.com/wb2osz/direwolf.git
Add -O option to redirect output to stderr.
This commit is contained in:
parent
ab834f338b
commit
58652df5b9
|
@ -217,7 +217,7 @@ int main (int argc, char *argv[])
|
|||
}
|
||||
#endif
|
||||
|
||||
text_color_init(1);
|
||||
text_color_init(1, 0);
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
|
||||
/*
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
|
||||
int main (void)
|
||||
{
|
||||
text_color_init (0); // Turn off text color.
|
||||
text_color_init (0, 0); // Turn off text color.
|
||||
#if defined(__OpenBSD__) || defined(__FreeBSD__)
|
||||
dw_printf ("CM108 PTT support is not available for this operating system.\n");
|
||||
#else
|
||||
|
@ -340,7 +340,7 @@ int main (int argc, char **argv)
|
|||
int num_things;
|
||||
int i;
|
||||
|
||||
text_color_init (0); // Turn off text color.
|
||||
text_color_init (0, 0); // Turn off text color.
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
|
||||
if (argc >=2) {
|
||||
|
|
|
@ -5330,7 +5330,7 @@ int main (int argc, char *argv[])
|
|||
}
|
||||
|
||||
// If you don't like the text colors, use 0 instead of 1 here.
|
||||
text_color_init(1);
|
||||
text_color_init(1, 0);
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
|
||||
while (fgets(stuff, sizeof(stuff), stdin) != NULL)
|
||||
|
|
|
@ -242,6 +242,8 @@ int main (int argc, char *argv[])
|
|||
char x_opt_mode = ' '; /* "-x N" option for transmitting calibration tones. */
|
||||
int x_opt_chan = 0; /* Split into 2 parts. Mode e.g. m, a, and optional channel. */
|
||||
|
||||
int O_opt = 0; /* Redirect text io to stderr for use with stdout audio */
|
||||
|
||||
strlcpy(l_opt_logdir, "", sizeof(l_opt_logdir));
|
||||
strlcpy(L_opt_logfile, "", sizeof(L_opt_logfile));
|
||||
strlcpy(P_opt, "", sizeof(P_opt));
|
||||
|
@ -270,8 +272,8 @@ int main (int argc, char *argv[])
|
|||
#endif
|
||||
|
||||
/*
|
||||
* Pre-scan the command line options for the text color option.
|
||||
* We need to set this before any text output.
|
||||
* Pre-scan the command line options for the text color and stdout redirect options.
|
||||
* We need to set these before any text output.
|
||||
* Default will be no colors if stdout is not a terminal (i.e. piped into
|
||||
* something else such as "tee") but command line can override this.
|
||||
*/
|
||||
|
@ -286,10 +288,12 @@ int main (int argc, char *argv[])
|
|||
|
||||
// FIXME: consider case of no space between t and number.
|
||||
|
||||
for (j=1; j<argc-1; j++) {
|
||||
for (j=1; j<argc; j++) {
|
||||
if (strcmp(argv[j], "-t") == 0) {
|
||||
t_opt = atoi (argv[j+1]);
|
||||
//dw_printf ("DEBUG: text color option = %d.\n", t_opt);
|
||||
} else if (strcmp(argv[j], "-O") == 0) {
|
||||
O_opt = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -299,7 +303,7 @@ int main (int argc, char *argv[])
|
|||
// Might want to print OS version here. For Windows, see:
|
||||
// https://msdn.microsoft.com/en-us/library/ms724451(v=VS.85).aspx
|
||||
|
||||
text_color_init(t_opt);
|
||||
text_color_init(t_opt, O_opt);
|
||||
text_color_set(DW_COLOR_INFO);
|
||||
dw_printf ("Dire Wolf version %d.%d (%s) BETA TEST 7\n", MAJOR_VERSION, MINOR_VERSION, __DATE__);
|
||||
//dw_printf ("Dire Wolf DEVELOPMENT version %d.%d %s (%s)\n", MAJOR_VERSION, MINOR_VERSION, "G", __DATE__);
|
||||
|
@ -421,7 +425,7 @@ int main (int argc, char *argv[])
|
|||
|
||||
/* ':' following option character means arg is required. */
|
||||
|
||||
c = getopt_long(argc, argv, "hP:B:gjJD:U:c:px:r:b:n:d:q:t:ul:L:Sa:E:T:e:X:AI:i:",
|
||||
c = getopt_long(argc, argv, "hP:B:gjJD:U:c:px:r:b:n:d:q:t:ul:L:Sa:E:T:e:X:AI:i:O",
|
||||
long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
@ -738,6 +742,10 @@ int main (int argc, char *argv[])
|
|||
A_opt_ais_to_obj = 1;
|
||||
break;
|
||||
|
||||
case 'O': /* Was handled earlier. -O Redirects output to stderr. */
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
|
||||
/* Should not be here. */
|
||||
|
|
|
@ -53,7 +53,7 @@ static void decode_bitstream(void);
|
|||
int main ()
|
||||
{
|
||||
int enable_color = 1;
|
||||
text_color_init (enable_color);
|
||||
text_color_init (enable_color, 0);
|
||||
|
||||
int enable_debug_out = 0;
|
||||
il2p_init(enable_debug_out);
|
||||
|
@ -974,4 +974,4 @@ alevel_t demod_get_audio_level (int chan, int subchan)
|
|||
return (alevel);
|
||||
}
|
||||
|
||||
// end il2p_test.c
|
||||
// end il2p_test.c
|
||||
|
|
|
@ -179,7 +179,7 @@ static void trim (char *stuff)
|
|||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
text_color_init (0); // Turn off text color.
|
||||
text_color_init (0, 0); // Turn off text color.
|
||||
// It could interfere with trying to pipe stdout to some other application.
|
||||
|
||||
#if __WIN32__
|
||||
|
|
|
@ -171,14 +171,20 @@ static const char clear_eos[] = "\e[0J";
|
|||
*/
|
||||
|
||||
static int g_enable_color = 1;
|
||||
static FILE *g_dw_printf_dest = 0;
|
||||
|
||||
|
||||
void text_color_init (int enable_color)
|
||||
void text_color_init (int enable_color, int redirect_output)
|
||||
{
|
||||
|
||||
if (redirect_output != 0) {
|
||||
g_dw_printf_dest = stderr;
|
||||
enable_color = 0;
|
||||
} else {
|
||||
g_dw_printf_dest = stdout;
|
||||
}
|
||||
|
||||
#if __WIN32__
|
||||
|
||||
g_enable_color = enable_color;
|
||||
|
||||
if (g_enable_color != 0) {
|
||||
|
||||
|
@ -208,7 +214,7 @@ void text_color_init (int enable_color)
|
|||
if (enable_color < 0 || enable_color > MAX_T) {
|
||||
int t;
|
||||
for (t = 0; t <= MAX_T; t++) {
|
||||
text_color_init (t);
|
||||
text_color_init (t, redirect_output);
|
||||
printf ("-t %d", t);
|
||||
if (t) printf (" [white background] ");
|
||||
printf ("\n");
|
||||
|
@ -377,7 +383,7 @@ int dw_printf (const char *fmt, ...)
|
|||
|
||||
// TODO: other possible destinations...
|
||||
|
||||
fputs (buffer, stdout);
|
||||
fputs (buffer, g_dw_printf_dest);
|
||||
return (len);
|
||||
}
|
||||
|
||||
|
@ -387,7 +393,7 @@ int dw_printf (const char *fmt, ...)
|
|||
main ()
|
||||
{
|
||||
printf ("Initial condition\n");
|
||||
text_color_init (1);
|
||||
text_color_init (1, 0);
|
||||
printf ("After text_color_init\n");
|
||||
text_color_set(DW_COLOR_INFO); printf ("Info\n");
|
||||
text_color_set(DW_COLOR_ERROR); printf ("Error\n");
|
||||
|
|
|
@ -22,7 +22,7 @@ enum dw_color_e { DW_COLOR_INFO, /* black */
|
|||
typedef enum dw_color_e dw_color_t;
|
||||
|
||||
|
||||
void text_color_init (int enable_color);
|
||||
void text_color_init (int enable_color, int redirect_output);
|
||||
void text_color_set (dw_color_t c);
|
||||
void text_color_term (void);
|
||||
|
||||
|
|
Loading…
Reference in New Issue