From a1d98ef97c98dacf7330098aefdf17932fefacb5 Mon Sep 17 00:00:00 2001 From: Ernesto Alfonso Date: Sun, 8 May 2022 23:31:49 -0400 Subject: [PATCH] Support multiple linphonec instances running under the same OS user. This allows connecting to multiple SIP servers at the same time and provides flexibility for the linphonecsh user to specify which linphone instance to use. --- console/linphonec.c | 9 +++++++-- console/shell.c | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/console/linphonec.c b/console/linphonec.c index 1161c87f20..9037ad119f 100644 --- a/console/linphonec.c +++ b/console/linphonec.c @@ -399,16 +399,21 @@ static void start_prompt_reader(void){ #if !defined(_WIN32_WCE) static bctbx_pipe_t create_server_socket(void){ char path[128]; + { + char* profile_id_env = getenv("LINPHONE_PROFILE_ID"); + if (profile_id_env){ + snprintf(path,sizeof(path)-1,"linphonec-%s",profile_id_env); + }else{ #ifndef _WIN32 snprintf(path,sizeof(path)-1,"linphonec-%i",getuid()); #else - { TCHAR username[128]; DWORD size=sizeof(username)-1; GetUserName(username,&size); snprintf(path,sizeof(path)-1,"linphonec-%s",username); - } #endif + } + } return bctbx_server_pipe_create(path); } diff --git a/console/shell.c b/console/shell.c index 86da875397..927739c8b4 100644 --- a/console/shell.c +++ b/console/shell.c @@ -82,7 +82,12 @@ static int send_command(const char *command, char *reply, int reply_len, int pri int err; char path[128]; #ifndef _WIN32 - snprintf(path,sizeof(path)-1,"linphonec-%i",getuid()); + char* profile_id_env = getenv("LINPHONE_PROFILE_ID"); + if (profile_id_env){ + snprintf(path,sizeof(path)-1,"linphonec-%s", profile_id_env); + }else{ + snprintf(path,sizeof(path)-1,"linphonec-%i", getuid()); + } #else { char username[128];