summaryrefslogtreecommitdiff
path: root/extensions/source
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2008-06-09 11:32:46 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2008-06-09 11:32:46 +0000
commitd29cf7aff29953ee33c5cf58a538fe7a163a1558 (patch)
treec1b1ee803e28f615eb6943f48c0f364f1be996dd /extensions/source
parent45f4560e37598ed9e3d8cf8f0e7ead059d2f0239 (diff)
INTEGRATION: CWS sb87 (1.7.52); FILE MERGED
2008/05/26 12:48:26 mav 1.7.52.3: #i87548# let the soffice script be always found 2008/04/24 13:13:01 sb 1.7.52.2: RESYNC: (1.7-1.8); FILE MERGED 2008/04/04 11:53:50 sb 1.7.52.1: #i87548# moved npsoplugin dynamic library to brand layer, kept nsplugin executable (called from plugin, in turn calling soffice) in basis layer
Diffstat (limited to 'extensions/source')
-rw-r--r--extensions/source/nsplugin/source/so_main.cxx39
1 files changed, 23 insertions, 16 deletions
diff --git a/extensions/source/nsplugin/source/so_main.cxx b/extensions/source/nsplugin/source/so_main.cxx
index 7dc5bff50198..fc45311e8623 100644
--- a/extensions/source/nsplugin/source/so_main.cxx
+++ b/extensions/source/nsplugin/source/so_main.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: so_main.cxx,v $
- * $Revision: 1.8 $
+ * $Revision: 1.9 $
*
* This file is part of OpenOffice.org.
*
@@ -58,6 +58,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
+#include "boost/scoped_array.hpp"
#include "ns_debug.hxx"
#include "so_msg.hxx"
@@ -66,11 +67,15 @@
#include "nsp_func.hxx"
-
+#include "sal/main.h"
#define MAX_NODE_NUM 1024
+
SoPluginInstance* lpInstance[MAX_NODE_NUM];
+static NSP_PIPE_FD la_read_fd = 0;
+static char const * progdir = NULL;
+
long int NSP_ReadFromPipe(NSP_PIPE_FD fp, void* buf, unsigned long int len)
{
@@ -273,14 +278,22 @@ sal_Bool start_office(NSP_PIPE_FD read_fd)
char para[128] = {0};
sprintf(para, "-accept=socket,host=0,port=%d;urp", SO_SERVER_PORT);
#ifdef UNIX
+
+ boost::scoped_array< char > exepath(
+ new char[( progdir ? strlen( progdir ) : 0 ) + RTL_CONSTASCII_LENGTH( "/soffice" ) + 1] );
+ if ( progdir )
+ sprintf( exepath.get(), "%s/soffice", progdir );
+ else
+ sprintf( exepath.get(), "soffice" );
+
int nChildPID = fork();
if( ! nChildPID ) // child process
{
NSP_CloseSocket(my_sock);
NSP_Close_Pipe(read_fd);
- sprintf(sCommand, "/bin/sh soffice -nologo -nodefault %s", para);
+ sprintf(sCommand, "/bin/sh %s -nologo -nodefault %s", exepath.get(), para);
debug_fprintf(NSP_LOG_APPEND,"StarOffice will be started by command: %s\n",sCommand);
- execl("/bin/sh", "/bin/sh", "soffice", "-nologo", "-nodefault", para, NULL);
+ execl("/bin/sh", "/bin/sh", exepath.get(), "-nologo", "-nodefault", para, NULL);
_exit(255);
}
#endif //end of UNIX
@@ -328,9 +341,7 @@ sal_Bool start_office(NSP_PIPE_FD read_fd)
}
-static NSP_PIPE_FD la_read_fd = 0;
-
-int main(int argc, char** argv)
+SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
{
// Sleep(20*1000);
debug_fprintf(NSP_LOG_APPEND, "start of main\n");
@@ -338,21 +349,13 @@ int main(int argc, char** argv)
NSP_PIPE_FD fd_pipe[2];
int iPipe[2];
-#ifdef UNIX
if(argc < 3)
{
debug_fprintf(NSP_LOG_APPEND, "print by nsplugin, command error; too little argument to start plugin exec\n");
- return sal_False;
+ return EXIT_FAILURE;
}
iPipe[0] = atoi(argv[1]);
iPipe[1] = atoi(argv[2]);
-#endif //end of UNIX
-#ifdef WNT
- (void)argc;
- //sscanf( GetCommandLine(), "%d %d", &iPipe[0], &iPipe[1] );
- iPipe[0] = atoi(argv[0]);
- iPipe[1] = atoi(argv[1]);
-#endif //end of WNT
// fd_pipe[0]: read, fd_pipe[0]: write
fd_pipe[0] = (NSP_PIPE_FD) iPipe[0] ;
@@ -366,6 +369,9 @@ int main(int argc, char** argv)
return 0;
}
+ // the program path is provided only on unix, on windows the registry entry is used
+ if ( argc > 4 )
+ progdir = argv[4];
if(!start_office(la_read_fd))
{
NSP_Close_Pipe(la_read_fd);
@@ -389,6 +395,7 @@ int main(int argc, char** argv)
}
NSP_Close_Pipe(la_read_fd);
_exit(0);
+ return EXIT_SUCCESS; // avoid warnings
}
extern "C"{