1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: osl_process_child.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sal.hxx"
34 //########################################
37 #if ( defined WNT ) // Windows
38 #include <tools/prewin.h>
41 # define WIN32_LEAN_AND_MEAN
42 // # include <windows.h>
44 #include <tools/postwin.h>
54 #include <rtl/ustring.hxx>
56 //########################################
60 # define SLEEP(t) (Sleep((t)*1000))
62 # define SLEEP(t) (sleep((t)))
65 //########################################
66 void wait_for_seconds(char* time
)
71 //########################################
74 //########################################
75 void w_to_a(LPCTSTR _strW
, LPSTR strA
, DWORD size
)
77 LPCWSTR strW
= reinterpret_cast<LPCWSTR
>(_strW
);
78 WideCharToMultiByte(CP_ACP
, 0, strW
, -1, strA
, size
, NULL
, NULL
);
80 //########################################
81 void dump_env(char* file_path
)
83 LPTSTR env
= reinterpret_cast<LPTSTR
>(
84 GetEnvironmentStrings());
87 std::ofstream
file(file_path
);
90 while (size_t l
= _tcslen(reinterpret_cast<wchar_t*>(p
)))
92 w_to_a(p
, buffer
, sizeof(buffer
));
93 file
<< buffer
<< std::endl
;
96 FreeEnvironmentStrings(env
);
99 extern char** environ
;
101 void dump_env(char* file_path
)
103 std::ofstream
file(file_path
);
104 for (int i
= 0; NULL
!= environ
[i
]; i
++)
105 file
<< environ
[i
] << std::endl
;
109 //########################################
110 int main(int argc
, char* argv
[])
114 //t_print("Parameter: ");
115 printf("child process Parameter: ");
116 for (int i
= 1; i
< argc
; i
++)
117 printf("%s ", argv
[i
]);
122 if (0 == strcmp("-join", argv
[1]))
124 wait_for_seconds(argv
[2]);
126 else if (0 == strcmp("-env", argv
[1]))