Remove console line before printing debugging and on exit
This commit is contained in:
parent
123979a0f3
commit
c273bbc5ff
|
@ -472,6 +472,10 @@ void call_cleanup(void)
|
|||
}
|
||||
}
|
||||
|
||||
static char console_text[256];
|
||||
static char console_clear[256];
|
||||
static int console_len = 0;
|
||||
|
||||
static void process_ui(int c)
|
||||
{
|
||||
switch (call.state) {
|
||||
|
@ -501,7 +505,7 @@ dial_after_hangup:
|
|||
}
|
||||
}
|
||||
}
|
||||
printf("on-hook: %s%s (enter 0..9 or d=dial)\r", call.station_id, "..............." + 15 - call.dial_digits + strlen(call.station_id));
|
||||
sprintf(console_text, "on-hook: %s%s (enter 0..9 or d=dial)\r", call.station_id, "..............." + 15 - call.dial_digits + strlen(call.station_id));
|
||||
break;
|
||||
case CALL_SETUP_MO:
|
||||
case CALL_SETUP_MT:
|
||||
|
@ -521,22 +525,36 @@ dial_after_hangup:
|
|||
}
|
||||
}
|
||||
if (call.state == CALL_SETUP_MT)
|
||||
printf("call setup: %s (enter h=hangup)\r", call.station_id);
|
||||
sprintf(console_text, "call setup: %s (enter h=hangup)\r", call.station_id);
|
||||
if (call.state == CALL_ALERTING)
|
||||
printf("call ringing: %s (enter h=hangup)\r", call.station_id);
|
||||
sprintf(console_text, "call ringing: %s (enter h=hangup)\r", call.station_id);
|
||||
if (call.state == CALL_CONNECT) {
|
||||
if (call.dialing[0])
|
||||
printf("call active: %s->%s (enter h=hangup)\r", call.station_id, call.dialing);
|
||||
sprintf(console_text, "call active: %s->%s (enter h=hangup)\r", call.station_id, call.dialing);
|
||||
else
|
||||
printf("call active: %s (enter h=hangup)\r", call.station_id);
|
||||
sprintf(console_text, "call active: %s (enter h=hangup)\r", call.station_id);
|
||||
}
|
||||
if (call.state == CALL_DISCONNECTED)
|
||||
printf("call disconnected: %s (enter h=hangup)\r", cause_name(call.disc_cause));
|
||||
sprintf(console_text, "call disconnected: %s (enter h=hangup)\r", cause_name(call.disc_cause));
|
||||
break;
|
||||
}
|
||||
console_len = strlen(console_text);
|
||||
memset(console_clear, ' ', console_len - 1);
|
||||
console_clear[console_len - 1] = '\r';
|
||||
fwrite(console_text, console_len, 1, stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
void clear_console_text(void)
|
||||
{
|
||||
if (!console_len)
|
||||
return;
|
||||
|
||||
fwrite(console_clear, console_len, 1, stdout);
|
||||
// note: fflused by user of this function
|
||||
}
|
||||
|
||||
|
||||
/* get keys from keyboad to control call via console
|
||||
* returns 1 on exit (ctrl+c) */
|
||||
void process_call(int c)
|
||||
|
|
|
@ -12,6 +12,7 @@ enum number_type {
|
|||
int call_init(const char *station_id, const char *sounddev, int samplerate, int latency, int dial_digits, int loopback);
|
||||
void call_cleanup(void);
|
||||
void process_call(int c);
|
||||
void clear_console_text(void);
|
||||
|
||||
/* received messages */
|
||||
int call_in_setup(int callref, const char *callerid, const char *dialing);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include "debug.h"
|
||||
#include "call.h"
|
||||
|
||||
const char *debug_level[] = {
|
||||
"debug ",
|
||||
|
@ -78,6 +79,7 @@ void _printdebug(const char *file, const char *function, int line, int cat, int
|
|||
while ((p = strchr(file, '/')))
|
||||
file = p + 1;
|
||||
|
||||
clear_console_text();
|
||||
// printf("%s%s:%d %s() %s: %s\033[0;39m", debug_cat[cat].color, file, line, function, debug_level[level], buffer);
|
||||
printf("%s%s:%d %s: %s\033[0;39m", debug_cat[cat].color, file, line, debug_level[level], buffer);
|
||||
fflush(stdout);
|
||||
|
|
|
@ -341,6 +341,8 @@ next_char:
|
|||
usleep(interval * 1000);
|
||||
}
|
||||
|
||||
clear_console_text();
|
||||
|
||||
/* reset terminal */
|
||||
tcsetattr(0, TCSANOW, &term_orig);
|
||||
}
|
||||
|
|
|
@ -14,28 +14,33 @@ test_compandor_LDADD = \
|
|||
$(top_builddir)/src/common/libcommon.a \
|
||||
-lm
|
||||
|
||||
test_emphasis_SOURCES = test_emphasis.c
|
||||
test_emphasis_SOURCES = test_emphasis.c dummy.c
|
||||
|
||||
test_emphasis_LDADD = \
|
||||
$(COMMON_LA) \
|
||||
$(top_builddir)/src/common/libcommon.a \
|
||||
$(ALSA_LIBS) \
|
||||
-lm
|
||||
|
||||
test_dms_SOURCES = \
|
||||
$(top_builddir)/src/nmt/dms.c \
|
||||
test_dms.c
|
||||
test_dms.c \
|
||||
dummy.c
|
||||
|
||||
test_dms_LDADD = \
|
||||
$(COMMON_LA) \
|
||||
$(top_builddir)/src/common/libcommon.a \
|
||||
$(ALSA_LIBS) \
|
||||
-lm
|
||||
|
||||
test_sms_SOURCES = \
|
||||
$(top_builddir)/src/nmt/sms.c \
|
||||
dummy.c \
|
||||
test_sms.c
|
||||
|
||||
test_sms_LDADD = \
|
||||
$(COMMON_LA) \
|
||||
$(top_builddir)/src/common/libcommon.a \
|
||||
$(ALSA_LIBS) \
|
||||
-lm
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
void call_rx_audio() { }
|
||||
void call_out_setup() { }
|
||||
void call_out_release() { }
|
||||
void call_out_disconnect() { }
|
||||
void print_help() { }
|
||||
void sender_send() { }
|
||||
void sender_receive() { }
|
||||
|
Loading…
Reference in New Issue