]> git.lyx.org Git - lyx.git/blob - development/Win32/lyxwin32.c
win32 port updates
[lyx.git] / development / Win32 / lyxwin32.c
1 #include <stdio.h>            /* standard io library */
2 #include <stdlib.h>           /* standard library */
3 #include <unistd.h>           /* sleep , fork & exec */
4 #include <string.h>           /* standard string library */
5 #include <errno.h>
6
7 int main ( int argc, char *argv[] )
8 {
9         char cmd [32000] = "lyx " ;  /* user command */
10         char *nargs [4 ] = {  /* execute with login /bin/bash */
11                 "/bin/bash",
12                 "-c" , cmd ,
13                 NULL
14         } ;
15         int i = 1; /* just to count */
16
17         /* ensure bash reads my global env changes */
18         putenv ( "BASH_ENV=/etc/lyxprofile" ) ;
19
20         /* do for all "real" args */
21         while ( i < argc )
22         {
23                 strcat ( cmd , "\"" ) ; /* add quote before */
24                 strcat ( cmd , argv [ i ] ) ; /* add the argument */
25                 strcat ( cmd , "\" " ) ; /* add closing quote */
26                 i ++ ;
27         }
28
29         strcat ( cmd, "</dev/null 2>/dev/null");
30
31         fprintf ( stderr , "Command is: |%s|\n" , cmd );
32         execv ( "/bin/bash" , nargs ) ;  /* exec sub command */
33
34         /* Oops: we should never reach here */
35         perror ( "Execute failed") ;
36         return ( 1 ) ; /* exit with an error */
37 }