summaryrefslogtreecommitdiff
path: root/pjsip-apps/src
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2015-04-13 12:14:02 +0000
committerNanang Izzuddin <nanang@teluu.com>2015-04-13 12:14:02 +0000
commit1823322ac0a440303c65f21de535724f213f480d (patch)
tree6f39caba554406e2d8d29a259097b42d3c5ecfc1 /pjsip-apps/src
parentd73d8cef462aa2e6f4476b53175bcb55b130b021 (diff)
Re #1842: Updated pjsua app to avoid stdout buffering, and also adjusted python tests accordingly.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5065 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps/src')
-rw-r--r--pjsip-apps/src/pjsua/pjsua_app_config.c7
-rw-r--r--pjsip-apps/src/pjsua/pjsua_app_legacy.c23
2 files changed, 26 insertions, 4 deletions
diff --git a/pjsip-apps/src/pjsua/pjsua_app_config.c b/pjsip-apps/src/pjsua/pjsua_app_config.c
index 4256de95..740be6f2 100644
--- a/pjsip-apps/src/pjsua/pjsua_app_config.c
+++ b/pjsip-apps/src/pjsua/pjsua_app_config.c
@@ -214,6 +214,12 @@ static void usage(void)
fflush(stdout);
}
+static void log_writer_nobuf(int level, const char *buffer, int len)
+{
+ pj_log_write(level, buffer, len);
+ fflush(stdout);
+}
+
/*
* Read command arguments from config file.
*/
@@ -1251,6 +1257,7 @@ static pj_status_t parse_args(int argc, char *argv[],
#ifdef _IONBF
case OPT_STDOUT_NO_BUF:
setvbuf(stdout, NULL, _IONBF, 0);
+ cfg->log_cfg.cb = &log_writer_nobuf;
break;
#endif
diff --git a/pjsip-apps/src/pjsua/pjsua_app_legacy.c b/pjsip-apps/src/pjsua/pjsua_app_legacy.c
index ed960e30..d687aded 100644
--- a/pjsip-apps/src/pjsua/pjsua_app_legacy.c
+++ b/pjsip-apps/src/pjsua/pjsua_app_legacy.c
@@ -23,6 +23,20 @@
#define THIS_FILE "pjsua_app_legacy.c"
+
+/* An attempt to avoid stdout buffering for python tests:
+ * - call 'fflush(stdout)' after each call to 'printf()/puts()'
+ * - apply 'setbuf(stdout, 0)', but it is not guaranteed by the standard:
+ * http://stackoverflow.com/questions/1716296
+ */
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \
+ (defined (_MSC_VER) && _MSC_VER >= 1400)
+/* Variadic macro is introduced in C99; MSVC supports it in since 2005. */
+# define printf(...) {printf(__VA_ARGS__);fflush(stdout);}
+# define puts(s) {puts(s);fflush(stdout);}
+#endif
+
+
static pj_bool_t cmd_echo;
/*
@@ -38,9 +52,9 @@ static void print_buddy_list()
pjsua_enum_buddies(ids, &count);
- if (count == 0)
+ if (count == 0) {
puts(" -none-");
- else {
+ } else {
for (i=0; i<(int)count; ++i) {
pjsua_buddy_info info;
@@ -1088,9 +1102,9 @@ static void ui_call_transfer(pj_bool_t no_refersub)
pj_list_push_back(&msg_data.hdr_list, &refer_sub);
}
if (result.nb_result != PJSUA_APP_NO_NB) {
- if (result.nb_result == -1 || result.nb_result == 0)
+ if (result.nb_result == -1 || result.nb_result == 0) {
puts("You can't do that with transfer call!");
- else {
+ } else {
pjsua_buddy_info binfo;
pjsua_buddy_get_info(result.nb_result-1, &binfo);
pjsua_call_xfer( current_call, &binfo.uri, &msg_data);
@@ -1669,6 +1683,7 @@ static void ui_call_redirect(char menuin[])
}
}
+
/*
* Main "user interface" loop.
*/