void linphonec_command_finished(void){ #if !defined(_WIN32_WCE) if (client_sock!=ORTP_PIPE_INVALID){ ortp_server_pipe_close_client(client_sock); client_sock=ORTP_PIPE_INVALID; } #endif /*_WIN32_WCE*/ }
static void * server_pipe_thread(void *pointer){ ortp_pipe_t child; do{ child=ortp_server_pipe_accept_client(server_pipe); if (server_pipe_running && child!=(ortp_pipe_t)-1){ char buf[256]={0}; if (ortp_pipe_read(child,(uint8_t*)buf,sizeof(buf))>0){ g_message("Received wakeup command with arg %s",buf); gdk_threads_enter(); g_timeout_add(20,(GSourceFunc)execute_wakeup,g_strdup(buf)); gdk_threads_leave(); } ortp_server_pipe_close_client(child); } }while(server_pipe_running); ortp_server_pipe_close(server_pipe); return NULL; }
static void *pipe_thread(void*p) { char tmp[250]; server_sock=create_server_socket(); if (server_sock==ORTP_PIPE_INVALID) return NULL; while(pipe_reader_run) { while(client_sock!=ORTP_PIPE_INVALID) { /*sleep until the last command is finished*/ #ifndef WIN32 usleep(20000); #else Sleep(20); #endif } client_sock=ortp_server_pipe_accept_client(server_sock); if (client_sock!=ORTP_PIPE_INVALID) { int len; /*now read from the client */ if ((len=ortp_pipe_read(client_sock,(uint8_t*)tmp,sizeof(tmp)-1))>0) { ortp_mutex_lock(&prompt_mutex); tmp[len]='\0'; strcpy(received_prompt,tmp); printf("Receiving command '%s'\n",received_prompt); fflush(stdout); have_prompt=TRUE; ortp_mutex_unlock(&prompt_mutex); } else { printf("read nothing\n"); fflush(stdout); ortp_server_pipe_close_client(client_sock); client_sock=ORTP_PIPE_INVALID; } } else { if (pipe_reader_run) fprintf(stderr,"accept() failed: %s\n",strerror(errno)); } } ms_message("Exiting pipe_reader_thread."); fflush(stdout); return NULL; }