2002-06-26 11:51:59 +00:00
|
|
|
/* This is the wrapper program for LyX on Win32. Using this
|
|
|
|
* wrapper program no DOS window will be present running LyX.
|
|
|
|
* The bad side of this: no error output could be seen ;-)
|
|
|
|
*
|
|
|
|
* compile this sourec with following options set:
|
|
|
|
*
|
|
|
|
* gcc lyxwin32.c -O2 -o lyxwin32 -static -Wall -Wno-format \
|
|
|
|
* -Wstrict-prototypes -Wmissing-prototypes \
|
|
|
|
* -mwindows -e _mainCRTStartup
|
|
|
|
*
|
|
|
|
* Claus Hentschel, 2002-01-17
|
|
|
|
*/
|
2001-10-04 09:57:02 +00:00
|
|
|
#include <stdio.h> /* standard io library */
|
|
|
|
#include <stdlib.h> /* standard library */
|
|
|
|
#include <unistd.h> /* sleep , fork & exec */
|
|
|
|
#include <string.h> /* standard string library */
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
int main ( int argc, char *argv[] )
|
|
|
|
{
|
|
|
|
char cmd [32000] = "lyx " ; /* user command */
|
2002-06-26 11:51:59 +00:00
|
|
|
char *nargs [5 ] = { /* execute with login /bin/bash */
|
|
|
|
"/bin/bash", "--login",
|
2001-10-04 09:57:02 +00:00
|
|
|
"-c" , cmd ,
|
|
|
|
NULL
|
|
|
|
} ;
|
|
|
|
int i = 1; /* just to count */
|
|
|
|
|
|
|
|
/* ensure bash reads my global env changes */
|
|
|
|
putenv ( "BASH_ENV=/etc/lyxprofile" ) ;
|
|
|
|
|
|
|
|
/* do for all "real" args */
|
|
|
|
while ( i < argc )
|
|
|
|
{
|
|
|
|
strcat ( cmd , "\"" ) ; /* add quote before */
|
|
|
|
strcat ( cmd , argv [ i ] ) ; /* add the argument */
|
|
|
|
strcat ( cmd , "\" " ) ; /* add closing quote */
|
|
|
|
i ++ ;
|
|
|
|
}
|
|
|
|
|
2002-06-26 11:51:59 +00:00
|
|
|
strcat ( cmd, "</dev/null 2>/tmp/lyx.out");
|
2001-10-04 09:57:02 +00:00
|
|
|
|
|
|
|
fprintf ( stderr , "Command is: |%s|\n" , cmd );
|
|
|
|
execv ( "/bin/bash" , nargs ) ; /* exec sub command */
|
|
|
|
|
2002-06-26 11:51:59 +00:00
|
|
|
/* we should never reach here */
|
2001-10-04 09:57:02 +00:00
|
|
|
perror ( "Execute failed") ;
|
2002-06-26 11:51:59 +00:00
|
|
|
return ( 0 ) ; /* exit with no error */
|
2001-10-04 09:57:02 +00:00
|
|
|
}
|