]> git.lyx.org Git - lyx.git/blob - development/Win32/lyxwin32.c
Fix some WorkArea fallouts
[lyx.git] / development / Win32 / lyxwin32.c
1 /* This is the wrapper program for LyX on Win32. Using this
2  * wrapper program no DOS window will be present running LyX.
3  * The bad side of this: no error output could be seen ;-)
4  *
5  * compile this sourec with following options set:
6  *
7  *    gcc lyxwin32.c -O2 -o lyxwin32 -static -Wall -Wno-format \
8  *                   -Wstrict-prototypes -Wmissing-prototypes \
9  *                   -mwindows -e _mainCRTStartup
10  *
11  * Claus Hentschel, 2002-01-17
12  */
13 #include <stdio.h>            /* standard io library */
14 #include <stdlib.h>           /* standard library */
15 #include <unistd.h>           /* sleep , fork & exec */
16 #include <string.h>           /* standard string library */
17 #include <errno.h>
18
19 int main ( int argc, char *argv[] )
20 {
21         char cmd [32000] = "lyx " ;  /* user command */
22         char *nargs [5 ] = {  /* execute with login /bin/bash */
23                 "/bin/bash", "--login",
24                 "-c" , cmd ,
25                 NULL
26         } ;
27         int i = 1; /* just to count */
28
29         /* ensure bash reads my global env changes */
30         putenv ( "BASH_ENV=/etc/lyxprofile" ) ;
31
32         /* do for all "real" args */
33         while ( i < argc )
34         {
35                 strcat ( cmd , "\"" ) ; /* add quote before */
36                 strcat ( cmd , argv [ i ] ) ; /* add the argument */
37                 strcat ( cmd , "\" " ) ; /* add closing quote */
38                 i ++ ;
39         }
40
41         strcat ( cmd, "</dev/null 2>/tmp/lyx.out");
42
43         fprintf ( stderr , "Command is: |%s|\n" , cmd );
44         execv ( "/bin/bash" , nargs ) ;  /* exec sub command */
45
46         /* we should never reach here */
47         perror ( "Execute failed") ;
48         return ( 0 ) ; /* exit with no error */
49 }