wmiutils: Don't prepend a backslash if WBEMPATH_GET_NAMESPACE_ONLY is specified.
[wine] / programs / winoldap.mod16 / winoldap.c
1 /*
2  * WINOLDAP implementation
3  *
4  * Copyright 2000 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "wownt32.h"
27 #include "wine/winbase16.h"
28 #include "wine/server.h"
29 #include "wine/debug.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(module);
32
33
34 /***********************************************************************
35  *           wait_input_idle
36  *
37  * user32.WaitForInputIdle releases the win16 lock, so here is a replacement.
38  */
39 static DWORD wait_input_idle( HANDLE process, DWORD timeout )
40 {
41     DWORD ret;
42     HANDLE handles[2];
43
44     handles[0] = process;
45     SERVER_START_REQ( get_process_idle_event )
46     {
47         req->handle = wine_server_obj_handle(process);
48         if (!(ret = wine_server_call_err( req ))) handles[1] = wine_server_ptr_handle( reply->event );
49     }
50     SERVER_END_REQ;
51     if (ret) return WAIT_FAILED;  /* error */
52     if (!handles[1]) return 0;  /* no event to wait on */
53
54     return WaitForMultipleObjects( 2, handles, FALSE, timeout );
55 }
56
57
58 /**************************************************************************
59  *           WINOLDAP entry point
60  */
61 WORD WINAPI WinMain16( HINSTANCE16 inst, HINSTANCE16 prev, LPSTR cmdline, WORD show )
62 {
63     PROCESS_INFORMATION info;
64     STARTUPINFOA startup;
65     DWORD count, exit_code = 1;
66
67     WINE_TRACE( "%x %x %s %u\n", inst, prev, wine_dbgstr_a(cmdline), show );
68
69     memset( &startup, 0, sizeof(startup) );
70     startup.cb = sizeof(startup);
71
72     if (CreateProcessA( NULL, cmdline, NULL, NULL, FALSE,
73                         0, NULL, NULL, &startup, &info ))
74     {
75         /* Give 10 seconds to the app to come up */
76         if (wait_input_idle( info.hProcess, 10000 ) == WAIT_FAILED)
77             WINE_WARN("WaitForInputIdle failed: Error %d\n", GetLastError() );
78         ReleaseThunkLock( &count );
79
80         WaitForSingleObject( info.hProcess, INFINITE );
81         GetExitCodeProcess( info.hProcess, &exit_code );
82         CloseHandle( info.hThread );
83         CloseHandle( info.hProcess );
84     }
85     else
86         ReleaseThunkLock( &count );
87
88     HeapFree( GetProcessHeap(), 0, cmdline );
89     ExitThread( exit_code );
90 }