Commit 1896a794 authored by Jehan Monnier's avatar Jehan Monnier

prepare wince port

parent 798b8e72
...@@ -36,7 +36,7 @@ AM_PROG_CC_C_O ...@@ -36,7 +36,7 @@ AM_PROG_CC_C_O
case $target_os in case $target_os in
*mingw32ce) *mingw32ce)
CFLAGS="$CFLAGS -D_WIN32_WCE -DORTP_STATIC -D_WIN32_WINNT=0x0501 -Dstrerror=" CFLAGS="$CFLAGS -D_WIN32_WCE -DORTP_STATIC -D_WIN32_WINNT=0x0501"
CXXFLAGS="$CXXFLAGS -DORTP_STATIC -D_WIN32_WINNT=0x0501" CXXFLAGS="$CXXFLAGS -DORTP_STATIC -D_WIN32_WINNT=0x0501"
LIBS="$LIBS -lws2 -liphlpapi" LIBS="$LIBS -lws2 -liphlpapi"
mingw_found=yes mingw_found=yes
......
...@@ -26,10 +26,12 @@ ...@@ -26,10 +26,12 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#ifndef _WIN32_WCE
#include <errno.h> #include <errno.h>
#include <unistd.h>
#endif /*_WIN32_WCE*/
#include <limits.h> #include <limits.h>
#include <ctype.h> #include <ctype.h>
#include <unistd.h>
#include <linphonecore.h> #include <linphonecore.h>
#include "linphonec.h" #include "linphonec.h"
...@@ -282,7 +284,7 @@ linphonec_command_generator(const char *text, int state) ...@@ -282,7 +284,7 @@ linphonec_command_generator(const char *text, int state)
if (strncmp(name, text, len) == 0) if (strncmp(name, text, len) == 0)
{ {
return strdup(name); return ortp_strdup(name);
} }
} }
...@@ -577,10 +579,12 @@ lpc_cmd_friend(LinphoneCore *lc, char *args) ...@@ -577,10 +579,12 @@ lpc_cmd_friend(LinphoneCore *lc, char *args)
args+=4; args+=4;
if ( ! *args ) return 0; if ( ! *args ) return 0;
friend_num = strtol(args, NULL, 10); friend_num = strtol(args, NULL, 10);
#ifndef _WIN32_WCE
if ( errno == ERANGE ) { if ( errno == ERANGE ) {
linphonec_out("Invalid friend number\n"); linphonec_out("Invalid friend number\n");
return 0; return 0;
} }
#endif /*_WIN32_WCE*/
linphonec_friend_call(lc, friend_num); linphonec_friend_call(lc, friend_num);
return 1; return 1;
} }
...@@ -597,10 +601,12 @@ lpc_cmd_friend(LinphoneCore *lc, char *args) ...@@ -597,10 +601,12 @@ lpc_cmd_friend(LinphoneCore *lc, char *args)
else else
{ {
friend_num = strtol(args, NULL, 10); friend_num = strtol(args, NULL, 10);
#ifndef _WIN32_WCE
if ( errno == ERANGE ) { if ( errno == ERANGE ) {
linphonec_out("Invalid friend number\n"); linphonec_out("Invalid friend number\n");
return 0; return 0;
} }
#endif /*_WIN32_WCE*/
} }
linphonec_friend_delete(lc, friend_num); linphonec_friend_delete(lc, friend_num);
return 1; return 1;
...@@ -1401,9 +1407,9 @@ static int lpc_cmd_duration(LinphoneCore *lc, char *args){ ...@@ -1401,9 +1407,9 @@ static int lpc_cmd_duration(LinphoneCore *lc, char *args){
static int lpc_cmd_status(LinphoneCore *lc, char *args) static int lpc_cmd_status(LinphoneCore *lc, char *args)
{ {
if ( ! args ) return 0;
LinphoneProxyConfig *cfg; LinphoneProxyConfig *cfg;
if ( ! args ) return 0;
linphone_core_get_default_proxy(lc,&cfg); linphone_core_get_default_proxy(lc,&cfg);
if (strstr(args,"register")) if (strstr(args,"register"))
{ {
......
...@@ -23,24 +23,28 @@ ...@@ -23,24 +23,28 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* *
****************************************************************************/ ****************************************************************************/
#include <string.h>
#include <errno.h> #ifndef _WIN32_WCE
#include <sys/time.h> #include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <string.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include "private.h" /*coreapi/private.h, needed for LINPHONE_VERSION */
#endif /*_WIN32_WCE*/
#include <limits.h> #include <limits.h>
#include <ctype.h> #include <ctype.h>
#include <linphonecore.h> #include <linphonecore.h>
#include "private.h" /*coreapi/private.h, needed for LINPHONE_VERSION */
#include "linphonec.h" #include "linphonec.h"
#ifdef WIN32 #ifdef WIN32
#include <ws2tcpip.h> #include <ws2tcpip.h>
#include <ctype.h> #include <ctype.h>
#ifndef _WIN32_WCE
#include <conio.h> #include <conio.h>
#endif /*_WIN32_WCE*/
#else #else
#include <sys/socket.h> #include <sys/socket.h>
#include <netdb.h> #include <netdb.h>
...@@ -48,6 +52,21 @@ ...@@ -48,6 +52,21 @@
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif
#if defined(_WIN32_WCE)
#if !defined(PATH_MAX)
#define PATH_MAX 256
#endif /*PATH_MAX*/
#if !defined(strdup)
#define strdup _strdup
#endif /*strdup*/
/*
#if !defined(access)
#define access _access
#endif*/ /*access*/
#endif /*_WIN32_WCE*/
#ifdef HAVE_GETTEXT #ifdef HAVE_GETTEXT
#include <libintl.h> #include <libintl.h>
...@@ -78,7 +97,9 @@ typedef struct { ...@@ -78,7 +97,9 @@ typedef struct {
char *lpc_strip_blanks(char *input); char *lpc_strip_blanks(char *input);
static int handle_configfile_migration(void); static int handle_configfile_migration(void);
#if !defined(_WIN32_WCE)
static int copy_file(const char *from, const char *to); static int copy_file(const char *from, const char *to);
#endif /*_WIN32_WCE*/
static int linphonec_parse_cmdline(int argc, char **argv); static int linphonec_parse_cmdline(int argc, char **argv);
static int linphonec_init(int argc, char **argv); static int linphonec_init(int argc, char **argv);
static int linphonec_main_loop (LinphoneCore * opm, char * sipAddr); static int linphonec_main_loop (LinphoneCore * opm, char * sipAddr);
...@@ -135,15 +156,22 @@ static int trace_level = 0; ...@@ -135,15 +156,22 @@ static int trace_level = 0;
static char *logfile_name = NULL; static char *logfile_name = NULL;
static char configfile_name[PATH_MAX]; static char configfile_name[PATH_MAX];
static char *sipAddr = NULL; /* for autocall */ static char *sipAddr = NULL; /* for autocall */
#if !defined(_WIN32_WCE)
static ortp_pipe_t client_sock=ORTP_PIPE_INVALID; static ortp_pipe_t client_sock=ORTP_PIPE_INVALID;
#endif /*_WIN32_WCE*/
char prompt[PROMPT_MAX_LEN]; char prompt[PROMPT_MAX_LEN];
#if !defined(_WIN32_WCE)
static ortp_thread_t pipe_reader_th; static ortp_thread_t pipe_reader_th;
static bool_t pipe_reader_run=FALSE; static bool_t pipe_reader_run=FALSE;
#endif /*_WIN32_WCE*/
#if !defined(_WIN32_WCE)
static ortp_pipe_t server_sock; static ortp_pipe_t server_sock;
#endif /*_WIN32_WCE*/
LinphoneCoreVTable linphonec_vtable = { LinphoneCoreVTable linphonec_vtable
#if !defined (_MSC_VER)
= {
.show =(ShowInterfaceCb) stub, .show =(ShowInterfaceCb) stub,
.inv_recv = linphonec_call_received, .inv_recv = linphonec_call_received,
.bye_recv = linphonec_bye_received, .bye_recv = linphonec_bye_received,
...@@ -162,7 +190,9 @@ LinphoneCoreVTable linphonec_vtable = { ...@@ -162,7 +190,9 @@ LinphoneCoreVTable linphonec_vtable = {
.text_received=linphonec_text_received, .text_received=linphonec_text_received,
.general_state=linphonec_general_state, .general_state=linphonec_general_state,
.dtmf_received=linphonec_dtmf_received .dtmf_received=linphonec_dtmf_received
}; }
#endif /*_WIN32_WCE*/
;
...@@ -380,14 +410,14 @@ static void start_prompt_reader(void){ ...@@ -380,14 +410,14 @@ static void start_prompt_reader(void){
ms_mutex_init(&prompt_mutex,NULL); ms_mutex_init(&prompt_mutex,NULL);
ortp_thread_create(&th,NULL,prompt_reader_thread,NULL); ortp_thread_create(&th,NULL,prompt_reader_thread,NULL);
} }
#if !defined(_WIN32_WCE)
static ortp_pipe_t create_server_socket(void){ static ortp_pipe_t create_server_socket(void){
char path[128]; char path[128];
#ifndef WIN32 #ifndef WIN32
snprintf(path,sizeof(path)-1,"linphonec-%i",getuid()); snprintf(path,sizeof(path)-1,"linphonec-%i",getuid());
#else #else
{ {
char username[128]; TCHAR username[128];
DWORD size=sizeof(username)-1; DWORD size=sizeof(username)-1;
GetUserName(username,&size); GetUserName(username,&size);
snprintf(path,sizeof(path)-1,"linphonec-%s",username); snprintf(path,sizeof(path)-1,"linphonec-%s",username);
...@@ -396,6 +426,7 @@ static ortp_pipe_t create_server_socket(void){ ...@@ -396,6 +426,7 @@ static ortp_pipe_t create_server_socket(void){
return ortp_server_pipe_create(path); return ortp_server_pipe_create(path);
} }
static void *pipe_thread(void*p){ static void *pipe_thread(void*p){
char tmp[250]; char tmp[250];
server_sock=create_server_socket(); server_sock=create_server_socket();
...@@ -446,6 +477,7 @@ static void stop_pipe_reader(void){ ...@@ -446,6 +477,7 @@ static void stop_pipe_reader(void){
ortp_server_pipe_close(server_sock); ortp_server_pipe_close(server_sock);
ortp_thread_join(pipe_reader_th,NULL); ortp_thread_join(pipe_reader_th,NULL);
} }
#endif /*_WIN32_WCE*/
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
#define BOOL_HAVE_READLINE 1 #define BOOL_HAVE_READLINE 1
...@@ -462,8 +494,10 @@ char *linphonec_readline(char *prompt){ ...@@ -462,8 +494,10 @@ char *linphonec_readline(char *prompt){
prompt_reader_started=TRUE; prompt_reader_started=TRUE;
} }
if (unix_socket && !pipe_reader_started){ if (unix_socket && !pipe_reader_started){
#if !defined(_WIN32_WCE)
start_pipe_reader(); start_pipe_reader();
pipe_reader_started=TRUE; pipe_reader_started=TRUE;
#endif /*_WIN32_WCE*/
} }
fprintf(stdout,"%s",prompt); fprintf(stdout,"%s",prompt);
fflush(stdout); fflush(stdout);
...@@ -498,19 +532,23 @@ void linphonec_out(const char *fmt,...){ ...@@ -498,19 +532,23 @@ void linphonec_out(const char *fmt,...){
va_end (args); va_end (args);
printf("%s",res); printf("%s",res);
fflush(stdout); fflush(stdout);
#if !defined(_WIN32_WCE)
if (client_sock!=ORTP_PIPE_INVALID){ if (client_sock!=ORTP_PIPE_INVALID){
if (ortp_pipe_write(client_sock,(uint8_t*)res,strlen(res))==-1){ if (ortp_pipe_write(client_sock,(uint8_t*)res,strlen(res))==-1){
fprintf(stderr,"Fail to send output via pipe: %s",strerror(errno)); fprintf(stderr,"Fail to send output via pipe: %s",strerror(errno));
} }
} }
#endif /*_WIN32_WCE*/
ortp_free(res); ortp_free(res);
} }
void linphonec_command_finished(void){ void linphonec_command_finished(void){
#if !defined(_WIN32_WCE)
if (client_sock!=ORTP_PIPE_INVALID){ if (client_sock!=ORTP_PIPE_INVALID){
ortp_server_pipe_close_client(client_sock); ortp_server_pipe_close_client(client_sock);
client_sock=ORTP_PIPE_INVALID; client_sock=ORTP_PIPE_INVALID;
} }
#endif /*_WIN32_WCE*/
} }
void linphonec_set_autoanswer(bool_t enabled){ void linphonec_set_autoanswer(bool_t enabled){
...@@ -530,9 +568,35 @@ bool_t linphonec_get_autoanswer(){ ...@@ -530,9 +568,35 @@ bool_t linphonec_get_autoanswer(){
* - char *histfile_name * - char *histfile_name
* - FILE *mylogfile * - FILE *mylogfile
*/ */
#if defined (_MSC_VER)
int _tmain(int argc, _TCHAR* argv[]) {
trace_level=1;
linphonec_vtable.show =(ShowInterfaceCb) stub;
linphonec_vtable.inv_recv = linphonec_call_received;
linphonec_vtable.bye_recv = linphonec_bye_received;
linphonec_vtable.notify_recv = linphonec_notify_received;
linphonec_vtable.new_unknown_subscriber = linphonec_new_unknown_subscriber;
linphonec_vtable.auth_info_requested = linphonec_prompt_for_auth;
linphonec_vtable.display_status = linphonec_display_status;
linphonec_vtable.display_message=linphonec_display_something;
#ifdef VINCENT_MAURY_RSVP
/* the yes/no dialog box */
linphonec_vtable.display_yes_no= (DisplayMessageCb) stub;
#endif
linphonec_vtable.display_warning=linphonec_display_warning;
linphonec_vtable.display_url=linphonec_display_url;
linphonec_vtable.display_question=(DisplayQuestionCb)stub;
linphonec_vtable.text_received=linphonec_text_received;
linphonec_vtable.general_state=linphonec_general_state;
linphonec_vtable.dtmf_received=linphonec_dtmf_received;
#else
int int
main (int argc, char *argv[]) main (int argc, char *argv[]) {
{ #endif
if (! linphonec_init(argc, argv) ) exit(EXIT_FAILURE); if (! linphonec_init(argc, argv) ) exit(EXIT_FAILURE);
...@@ -556,9 +620,13 @@ linphonec_init(int argc, char **argv) ...@@ -556,9 +620,13 @@ linphonec_init(int argc, char **argv)
* Set initial values for global variables * Set initial values for global variables
*/ */
mylogfile = NULL; mylogfile = NULL;
snprintf(configfile_name, PATH_MAX, "%s/.linphonerc", snprintf(configfile_name, PATH_MAX, "%s/.linphonerc",
#if !defined(_WIN32_WCE)
getenv("HOME")); getenv("HOME"));
#else
".");
#endif /*_WIN32_WCE*/
/* Handle configuration filename changes */ /* Handle configuration filename changes */
switch (handle_configfile_migration()) switch (handle_configfile_migration())
...@@ -623,12 +691,13 @@ linphonec_init(int argc, char **argv) ...@@ -623,12 +691,13 @@ linphonec_init(int argc, char **argv)
*/ */
linphonec_initialize_readline(); linphonec_initialize_readline();
#endif #endif
#if !defined(_WIN32_WCE)
/* /*
* Initialize signal handlers * Initialize signal handlers
*/ */
signal(SIGTERM, linphonec_finish); signal(SIGTERM, linphonec_finish);
signal(SIGINT, linphonec_finish); signal(SIGINT, linphonec_finish);
#endif /*_WIN32_WCE*/
return 1; return 1;
} }
...@@ -652,9 +721,10 @@ linphonec_finish(int exit_status) ...@@ -652,9 +721,10 @@ linphonec_finish(int exit_status)
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
linphonec_finish_readline(); linphonec_finish_readline();
#endif #endif
#if !defined(_WIN32_WCE)
if (pipe_reader_run) if (pipe_reader_run)
stop_pipe_reader(); stop_pipe_reader();
#endif /*_WIN32_WCE*/
linphone_core_uninit (&linphonec); linphone_core_uninit (&linphonec);
...@@ -976,7 +1046,7 @@ linphonec_parse_cmdline(int argc, char **argv) ...@@ -976,7 +1046,7 @@ linphonec_parse_cmdline(int argc, char **argv)
else if (strncmp ("-c", argv[arg_num], 2) == 0) else if (strncmp ("-c", argv[arg_num], 2) == 0)
{ {
if ( ++arg_num >= argc ) print_usage(EXIT_FAILURE); if ( ++arg_num >= argc ) print_usage(EXIT_FAILURE);
#if !defined(_WIN32_WCE)
if (access(argv[arg_num],F_OK)!=0 ) if (access(argv[arg_num],F_OK)!=0 )
{ {
fprintf (stderr, fprintf (stderr,
...@@ -984,6 +1054,7 @@ linphonec_parse_cmdline(int argc, char **argv) ...@@ -984,6 +1054,7 @@ linphonec_parse_cmdline(int argc, char **argv)
argv[arg_num]); argv[arg_num]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#endif /*_WIN32_WCE*/
snprintf(configfile_name, PATH_MAX, "%s", argv[arg_num]); snprintf(configfile_name, PATH_MAX, "%s", argv[arg_num]);
} }
else if (strncmp ("-s", argv[arg_num], 2) == 0) else if (strncmp ("-s", argv[arg_num], 2) == 0)
...@@ -1016,7 +1087,9 @@ linphonec_parse_cmdline(int argc, char **argv) ...@@ -1016,7 +1087,9 @@ linphonec_parse_cmdline(int argc, char **argv)
("--version", argv[arg_num], ("--version", argv[arg_num],
strlen ("--version")) == 0)) strlen ("--version")) == 0))
{ {
#if !defined(_WIN32_WCE)
printf ("version: " LINPHONE_VERSION "\n"); printf ("version: " LINPHONE_VERSION "\n");
#endif
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
} }
else if (strncmp ("-S", argv[arg_num], 2) == 0) else if (strncmp ("-S", argv[arg_num], 2) == 0)
...@@ -1058,11 +1131,15 @@ linphonec_parse_cmdline(int argc, char **argv) ...@@ -1058,11 +1131,15 @@ linphonec_parse_cmdline(int argc, char **argv)
static int static int
handle_configfile_migration() handle_configfile_migration()
{ {
#if !defined(_WIN32_WCE)
char *old_cfg_gui; char *old_cfg_gui;
char *old_cfg_cli; char *old_cfg_cli;
char *new_cfg; char *new_cfg;
#if !defined(_WIN32_WCE)
const char *home = getenv("HOME"); const char *home = getenv("HOME");
#else
const char *home = ".";
#endif /*_WIN32_WCE*/
new_cfg = ms_strdup_printf("%s/.linphonerc", home); new_cfg = ms_strdup_printf("%s/.linphonerc", home);
/* /*
...@@ -1119,9 +1196,10 @@ handle_configfile_migration() ...@@ -1119,9 +1196,10 @@ handle_configfile_migration()
free(old_cfg_gui); free(old_cfg_gui);
free(new_cfg); free(new_cfg);
#endif /*_WIN32_WCE*/
return 0; return 0;
} }
#if !defined(_WIN32_WCE)
/* /*
* Copy file "from" to file "to". * Copy file "from" to file "to".
* Destination file is truncated if existing. * Destination file is truncated if existing.
...@@ -1169,6 +1247,7 @@ copy_file(const char *from, const char *to) ...@@ -1169,6 +1247,7 @@ copy_file(const char *from, const char *to)
return 1; return 1;
} }
#endif /*_WIN32_WCE*/
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
static char ** static char **
...@@ -1332,3 +1411,4 @@ lpc_strip_blanks(char *input) ...@@ -1332,3 +1411,4 @@ lpc_strip_blanks(char *input)
* *
* *
****************************************************************************/ ****************************************************************************/
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#endif #endif
#endif #endif
/************************************************************************** /**************************************************************************
* *
* Compile-time defines * Compile-time defines
......
...@@ -42,9 +42,9 @@ endif ...@@ -42,9 +42,9 @@ endif
AM_CFLAGS=$(STRICT_OPTIONS) -DIN_LINPHONE \ AM_CFLAGS=$(STRICT_OPTIONS) -DIN_LINPHONE \
$(ORTP_CFLAGS) \
$(OSIP_CFLAGS) \ $(OSIP_CFLAGS) \
$(EXOSIP_CFLAGS) \ $(EXOSIP_CFLAGS) \
$(ORTP_CFLAGS) \
-DENABLE_TRACE \ -DENABLE_TRACE \
-DLOG_DOMAIN=\"LinphoneCore\" \ -DLOG_DOMAIN=\"LinphoneCore\" \
$(IPV6_CFLAGS) \ $(IPV6_CFLAGS) \
......
...@@ -692,7 +692,9 @@ int linphone_accept_audio_offer(sdp_context_t *ctx,sdp_payload_t *payload) ...@@ -692,7 +692,9 @@ int linphone_accept_audio_offer(sdp_context_t *ctx,sdp_payload_t *payload)
/* refuse all other audio lines*/ /* refuse all other audio lines*/
if(params->line!=payload->line) { if(params->line!=payload->line) {
ms_message("Only one audio line can be accepted."); ms_message("Only one audio line can be accepted.");
#if !defined(_WIN32_WCE)
abort(); abort();
#endif /*_WIN32_WCE*/
return -1; return -1;
} }
} }
......
...@@ -163,7 +163,12 @@ void linphone_call_destroy(LinphoneCall *obj) ...@@ -163,7 +163,12 @@ void linphone_call_destroy(LinphoneCall *obj)
/*prevent a gcc bug with %c*/ /*prevent a gcc bug with %c*/
static size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm){ static size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm){
#if !defined(_WIN32_WCE)
return strftime(s, max, fmt, tm); return strftime(s, max, fmt, tm);
#else
return 0;
/*FIXME*/
#endif /*_WIN32_WCE*/
} }
LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, char *from, char *to){ LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, char *from, char *to){
...@@ -171,7 +176,10 @@ LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, char *from, char *to ...@@ -171,7 +176,10 @@ LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, char *from, char *to
struct tm loctime; struct tm loctime;
cl->dir=call->dir; cl->dir=call->dir;
#ifdef WIN32 #ifdef WIN32
#if !defined(_WIN32_WCE)
loctime=*localtime(&call->start_time); loctime=*localtime(&call->start_time);
/*FIXME*/
#endif /*_WIN32_WCE*/
#else #else
localtime_r(&call->start_time,&loctime); localtime_r(&call->start_time,&loctime);
#endif #endif
...@@ -396,7 +404,7 @@ void sound_config_read(LinphoneCore *lc) ...@@ -396,7 +404,7 @@ void sound_config_read(LinphoneCore *lc)
tmpbuf=PACKAGE_SOUND_DIR "/" LOCAL_RING; tmpbuf=PACKAGE_SOUND_DIR "/" LOCAL_RING;
tmpbuf=lp_config_get_string(lc->config,"sound","local_ring",tmpbuf); tmpbuf=lp_config_get_string(lc->config,"sound","local_ring",tmpbuf);
if (access(tmpbuf,F_OK)==-1) { if (ortp_file_exist(tmpbuf)==-1) {
tmpbuf=PACKAGE_SOUND_DIR "/" LOCAL_RING; tmpbuf=PACKAGE_SOUND_DIR "/" LOCAL_RING;
} }
if (strstr(tmpbuf,".wav")==NULL){ if (strstr(tmpbuf,".wav")==NULL){
...@@ -408,7 +416,7 @@ void sound_config_read(LinphoneCore *lc) ...@@ -408,7 +416,7 @@ void sound_config_read(LinphoneCore *lc)
tmpbuf=PACKAGE_SOUND_DIR "/" REMOTE_RING; tmpbuf=PACKAGE_SOUND_DIR "/" REMOTE_RING;
tmpbuf=lp_config_get_string(lc->config,"sound","remote_ring",tmpbuf); tmpbuf=lp_config_get_string(lc->config,"sound","remote_ring",tmpbuf);
if (access(tmpbuf,F_OK)==-1){ if (ortp_file_exist(tmpbuf)==-1){
tmpbuf=PACKAGE_SOUND_DIR "/" REMOTE_RING; tmpbuf=PACKAGE_SOUND_DIR "/" REMOTE_RING;
} }
if (strstr(tmpbuf,".wav")==NULL){ if (strstr(tmpbuf,".wav")==NULL){
......
...@@ -30,7 +30,9 @@ ...@@ -30,7 +30,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#if !defined(_WIN32_WCE)
#include <errno.h> #include <errno.h>
#endif /*_WIN32_WCE*/
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
...@@ -102,14 +104,14 @@ struct _LpConfig{ ...@@ -102,14 +104,14 @@ struct _LpConfig{
LpItem * lp_item_new(const char *key, const char *value){ LpItem * lp_item_new(const char *key, const char *value){
LpItem *item=lp_new0(LpItem,1); LpItem *item=lp_new0(LpItem,1);
item->key=strdup(key); item->key=ortp_strdup(key);
item->value=strdup(value); item->value=ortp_strdup(value);
return item; return item;
} }
LpSection *lp_section_new(const char *name){ LpSection *lp_section_new(const char *name){
LpSection *sec=lp_new0(LpSection,1); LpSection *sec=lp_new0(LpSection,1);
sec->name=strdup(name); sec->name=ortp_strdup(name);
return sec; return sec;
} }
...@@ -211,16 +213,18 @@ void lp_config_parse(LpConfig *lpconfig){ ...@@ -211,16 +213,18 @@ void lp_config_parse(LpConfig *lpconfig){
LpConfig * lp_config_new(const char *filename){ LpConfig * lp_config_new(const char *filename){
LpConfig *lpconfig=lp_new0(LpConfig,1); LpConfig *lpconfig=lp_new0(LpConfig,1);
if (filename!=NULL){ if (filename!=NULL){
lpconfig->filename=strdup(filename); lpconfig->filename=ortp_strdup(filename);
lpconfig->file=fopen(filename,"rw"); lpconfig->file=fopen(filename,"rw");
if (lpconfig->file!=NULL){ if (lpconfig->file!=NULL){
lp_config_parse(lpconfig); lp_config_parse(lpconfig);
fclose(lpconfig->file); fclose(lpconfig->file);
#if !defined(_WIN32_WCE)
/* make existing configuration files non-group/world-accessible */ /* make existing configuration files non-group/world-accessible */
if (chmod(filename, S_IRUSR | S_IWUSR) == -1) if (chmod(filename, S_IRUSR | S_IWUSR) == -1)
ms_warning("unable to correct permissions on " ms_warning("unable to correct permissions on "
"configuration file: %s", "configuration file: %s",
strerror(errno)); strerror(errno));
#endif /*_WIN32_WCE*/
lpconfig->file=NULL; lpconfig->file=NULL;
lpconfig->modified=0; lpconfig->modified=0;
} }
...@@ -230,7 +234,7 @@ LpConfig * lp_config_new(const char *filename){ ...@@ -230,7 +234,7 @@ LpConfig * lp_config_new(const char *filename){
void lp_item_set_value(LpItem *item, const char *value){ void lp_item_set_value(LpItem *item, const char *value){
free(item->value); free(item->value);