Ignore:
Timestamp:
Apr 13, 2015 12:14:02 PM (10 years ago)
Author:
nanang
Message:

Re #1842: Updated pjsua app to avoid stdout buffering, and also adjusted python tests accordingly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app_legacy.c

    r4851 r5065  
    2424#define THIS_FILE       "pjsua_app_legacy.c" 
    2525 
     26 
     27/* An attempt to avoid stdout buffering for python tests: 
     28 * - call 'fflush(stdout)' after each call to 'printf()/puts()' 
     29 * - apply 'setbuf(stdout, 0)', but it is not guaranteed by the standard: 
     30 *   http://stackoverflow.com/questions/1716296 
     31 */ 
     32#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ 
     33    (defined (_MSC_VER) && _MSC_VER >= 1400) 
     34/* Variadic macro is introduced in C99; MSVC supports it in since 2005. */ 
     35#  define printf(...) {printf(__VA_ARGS__);fflush(stdout);} 
     36#  define puts(s) {puts(s);fflush(stdout);} 
     37#endif 
     38 
     39 
    2640static pj_bool_t        cmd_echo; 
    2741 
     
    3953    pjsua_enum_buddies(ids, &count); 
    4054 
    41     if (count == 0) 
     55    if (count == 0) { 
    4256        puts(" -none-"); 
    43     else { 
     57    } else { 
    4458        for (i=0; i<(int)count; ++i) { 
    4559            pjsua_buddy_info info; 
     
    10891103        } 
    10901104        if (result.nb_result != PJSUA_APP_NO_NB) { 
    1091             if (result.nb_result == -1 || result.nb_result == 0) 
     1105            if (result.nb_result == -1 || result.nb_result == 0) { 
    10921106                puts("You can't do that with transfer call!"); 
    1093             else { 
     1107            } else { 
    10941108                pjsua_buddy_info binfo; 
    10951109                pjsua_buddy_get_info(result.nb_result-1, &binfo); 
     
    16701684} 
    16711685 
     1686 
    16721687/* 
    16731688 * Main "user interface" loop. 
Note: See TracChangeset for help on using the changeset viewer.