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"
19 #define SCM_NOTIFICATION_INTERVAL 5000
20 #define THIRTY_SECONDS (30 * 1000)
22 #define SERVICE_NAME "OpenLDAP"
24 ldap_pvt_thread_cond_t started_event, stopped_event;
25 ldap_pvt_thread_t start_status_tid, stop_status_tid;
29 void WINAPI ServiceMain( DWORD argc, LPTSTR *argv );
33 char *WSAGetLastErrorString( void );
36 char *GetLastErrorString( void );
39 int srv_install( char* service, char* filename );
40 int srv_remove ( char* service, char* filename );
42 void main( DWORD argc, LPTSTR *argv )
45 char filename[MAX_PATH], *fname_start;
46 extern int is_NT_Service;
48 SERVICE_TABLE_ENTRY DispatchTable[] = {
49 { SERVICE_NAME, (LPSERVICE_MAIN_FUNCTION) ServiceMain },
53 // set the service's current directory to being the installation directory for the service.
54 // this way we don't have to write absolute paths in the configuration files
55 GetModuleFileName( NULL, filename, sizeof( filename ) );
56 fname_start = strrchr( filename, *LDAP_DIRSEP );
58 SetCurrentDirectory( filename );
61 if ( _stricmp( "install", argv[1] ) == 0 )
63 if ( (length = GetModuleFileName(NULL, filename, sizeof( filename ))) == 0 )
65 fputs( "unable to retrieve file name for the service.\n", stderr );
68 if ( !srv_install(SERVICE_NAME, filename) )
70 fputs( "service failed installation ...\n", stderr );
73 fputs( "service has been installed ...\n", stderr );
77 if ( _stricmp( "remove", argv[1] ) == 0 )
79 if ( (length = GetModuleFileName(NULL, filename, sizeof( filename ))) == 0 )
81 fputs( "unable to retrieve file name for the service.\n", stderr );
84 if ( !srv_remove(SERVICE_NAME, filename) )
86 fputs( "failed to remove the service ...\n", stderr );
89 fputs( "service has been removed ...\n", stderr );
94 puts( "starting slapd..." );
95 if ( !StartServiceCtrlDispatcher(DispatchTable) )
98 ServiceMain( argc, argv );