Ignore:
Timestamp:
Mar 14, 2013 7:18:13 AM (12 years ago)
Author:
riza
Message:

Re #1643: add initial support for CLI

File:
1 edited

Legend:

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

    r3664 r4440  
    3030pj_status_t app_init(int argc, char *argv[]); 
    3131pj_status_t app_main(void); 
    32 pj_status_t app_destroy(void); 
    33  
     32pj_status_t app_destroy(); 
     33pj_status_t receive_end_sig; 
     34pj_thread_t *sig_thread; 
    3435 
    3536#if defined(PJ_WIN32) && PJ_WIN32!=0 
     
    3940 
    4041static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType) 
    41 { 
    42     pj_thread_t *thread; 
    43  
     42{    
    4443    switch (fdwCtrlType)  
    4544    {  
     
    5150        case CTRL_LOGOFF_EVENT:  
    5251        case CTRL_SHUTDOWN_EVENT:  
    53             pj_thread_register("ctrlhandler", handler_desc, &thread); 
     52            pj_thread_register("ctrlhandler", handler_desc, &sig_thread); 
    5453            PJ_LOG(3,(THIS_FILE, "Ctrl-C detected, quitting..")); 
    55             app_destroy(); 
     54            receive_end_sig = PJ_TRUE; 
     55            app_destroy();           
    5656            ExitProcess(1); 
    5757            PJ_UNREACHED(return TRUE;) 
     
    8888static int main_func(int argc, char *argv[]) 
    8989{ 
     90    receive_end_sig = PJ_FALSE; 
    9091    setup_socket_signal(); 
    9192 
     
    99100 
    100101        app_main(); 
    101         app_destroy(); 
     102        if (!receive_end_sig) { 
     103            app_destroy(); 
    102104 
    103         /* This is on purpose */ 
    104         app_destroy(); 
     105            /* This is on purpose */ 
     106            app_destroy(); 
     107        } else { 
     108            pj_thread_join(sig_thread); 
     109        } 
    105110    } while (app_restart); 
    106111 
Note: See TracChangeset for help on using the changeset viewer.