Commit 083b3400 authored by François Grisez's avatar François Grisez

Makes linphonecsh to handle arguments passed to init

parent 5d191610
......@@ -22,7 +22,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#ifdef WIN32
#include <ws2tcpip.h>
......@@ -125,11 +126,36 @@ static void print_usage(void){
exit(-1);
}
#ifdef WIN32
static char *argv_to_line(int argc, char *argv[]) {
int i;
int line_length;
char *line;
assert( argc>=0 );
if(argc == 0) return NULL;
line_length = strlen(argv[0]);
for(i=1; i<argc; i++) {
line_length += strlen(argv[i]) + 1;
}
line = ortp_malloc0((line_length +1) * sizeof(char));
strcat(line, argv[0]);
for(i=1; i<argc; i++) {
strcat(line, " ");
strcat(line, argv[i]);
}
return line;
}
#endif
#define MAX_ARGS 10
#ifndef WIN32
static void spawn_linphonec(int argc, char *argv[]){
char * args[10];
char * args[MAX_ARGS];
int i,j;
pid_t pid;
j=0;
......@@ -178,13 +204,21 @@ static void spawn_linphonec(int argc, char *argv[]){
PROCESS_INFORMATION pinfo;
STARTUPINFO si;
BOOL ret;
const char *cmd = "linphoned.exe --pipe -c NUL";
char *args_in_line = argv_to_line(argc, argv);
char *cmd_with_args;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pinfo, sizeof(pinfo) );
ret=CreateProcess(NULL,"linphoned.exe --pipe -c NUL",
if(args_in_line) {
cmd_with_args = ortp_strdup_printf("%s %s", cmd, args_in_line);
} else {
cmd_with_args = ortp_strdup(cmd);
}
ret=CreateProcess(NULL, cmd_with_args,
NULL,
NULL,
FALSE,
......@@ -193,8 +227,12 @@ static void spawn_linphonec(int argc, char *argv[]){
NULL,
&si,
&pinfo);
if(args_in_line) ortp_free(args_in_line);
ortp_free(cmd_with_args);
if (!ret){
fprintf(stderr,"Spawning of linphonec.exe failed.\n");
fprintf(stderr,"Spawning of linphoned.exe failed.\n");
}else{
WaitForInputIdle(pinfo.hProcess,1000);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment