5 //#include <ac/signal.h>
6 //#include <ac/socket.h>
9 //#include <ac/unistd.h>
10 //#include <ac/wait.h>
11 //#include <ac/signal.h>
12 //#include <ac/errno.h>
14 #include "ldap_defaults.h"
17 /* kludge a path for now */
18 #include "../../libraries/liblutil/slapdmsg.h"
20 #define SCM_NOTIFICATION_INTERVAL 5000
21 #define THIRTY_SECONDS (30 * 1000)
23 #define SERVICE_NAME "OpenLDAP"
25 ldap_pvt_thread_cond_t started_event, stopped_event;
26 ldap_pvt_thread_t start_status_tid, stop_status_tid;
30 void WINAPI ServiceMain( DWORD argc, LPTSTR *argv );
34 char *WSAGetLastErrorString( void );
37 char *GetLastErrorString( void );
40 int srv_install( char* service, char* filename );
41 int srv_remove ( char* service, char* filename );
43 void main( DWORD argc, LPTSTR *argv )
46 char filename[MAX_PATH], *fname_start;
47 extern int is_NT_Service;
49 SERVICE_TABLE_ENTRY DispatchTable[] = {
50 { SERVICE_NAME, (LPSERVICE_MAIN_FUNCTION) ServiceMain },
54 // set the service's current directory to being the installation directory for the service.
55 // this way we don't have to write absolute paths in the configuration files
56 GetModuleFileName( NULL, filename, sizeof( filename ) );
57 fname_start = strrchr( filename, *LDAP_DIRSEP );
59 SetCurrentDirectory( filename );
62 if ( _stricmp( "install", argv[1] ) == 0 )
64 if ( (length = GetModuleFileName(NULL, filename, sizeof( filename ))) == 0 )
66 fputs( "unable to retrieve file name for the service.\n", stderr );
69 if ( !srv_install(SERVICE_NAME, filename) )
71 fputs( "service failed installation ...\n", stderr );
74 fputs( "service has been installed ...\n", stderr );
78 if ( _stricmp( "remove", argv[1] ) == 0 )
80 if ( (length = GetModuleFileName(NULL, filename, sizeof( filename ))) == 0 )
82 fputs( "unable to retrieve file name for the service.\n", stderr );
85 if ( !srv_remove(SERVICE_NAME, filename) )
87 fputs( "failed to remove the service ...\n", stderr );
90 fputs( "service has been removed ...\n", stderr );
95 puts( "starting slapd..." );
96 if ( !StartServiceCtrlDispatcher(DispatchTable) )
99 ServiceMain( argc, argv );