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 ldap_pvt_thread_cond_t started_event, stopped_event;
24 ldap_pvt_thread_t start_status_tid, stop_status_tid;
28 void WINAPI ServiceMain( DWORD argc, LPTSTR *argv );
32 char *WSAGetLastErrorString( void );
35 char *GetLastErrorString( void );
38 int srv_install( char* service, char* filename );
39 int srv_remove ( char* service, char* filename );
41 void main( DWORD argc, LPTSTR *argv )
44 char filename[MAX_PATH], *fname_start;
45 extern int is_NT_Service;
47 SERVICE_TABLE_ENTRY DispatchTable[] = {
48 { SERVICE_NAME, (LPSERVICE_MAIN_FUNCTION) ServiceMain },
52 // set the service's current directory to being the installation directory for the service.
53 // this way we don't have to write absolute paths in the configuration files
54 GetModuleFileName( NULL, filename, sizeof( filename ) );
55 fname_start = strrchr( filename, *LDAP_DIRSEP );
57 SetCurrentDirectory( filename );
60 if ( _stricmp( "install", argv[1] ) == 0 )
62 char *svcName = SERVICE_NAME;
63 if ( (argc > 2) && (argv[2] != NULL) )
65 if ( (length = GetModuleFileName(NULL, filename, sizeof( filename ))) == 0 )
67 fputs( "unable to retrieve file name for the service.\n", stderr );
70 if ( !srv_install(svcName, filename) )
72 fputs( "service failed installation ...\n", stderr );
75 fputs( "service has been installed ...\n", stderr );
79 if ( _stricmp( "remove", argv[1] ) == 0 )
81 char *svcName = SERVICE_NAME;
82 if ( (argc > 2) && (argv[2] != NULL) )
84 if ( (length = GetModuleFileName(NULL, filename, sizeof( filename ))) == 0 )
86 fputs( "unable to retrieve file name for the service.\n", stderr );
89 if ( !srv_remove(svcName, filename) )
91 fputs( "failed to remove the service ...\n", stderr );
94 fputs( "service has been removed ...\n", stderr );
99 puts( "starting slapd..." );
100 if ( !StartServiceCtrlDispatcher(DispatchTable) )
103 ServiceMain( argc, argv );