7 #include "ldap_defaults.h"
10 ldap_pvt_thread_cond_t started_event, stopped_event;
11 ldap_pvt_thread_t start_status_tid, stop_status_tid;
15 void WINAPI ServiceMain( DWORD argc, LPTSTR *argv );
18 int srv_install( char* service, char* filename );
19 int srv_remove ( char* service, char* filename );
21 int main( DWORD argc, LPTSTR *argv )
24 char filename[MAX_PATH], *fname_start;
25 extern int is_NT_Service;
27 SERVICE_TABLE_ENTRY DispatchTable[] = {
28 { SERVICE_NAME, (LPSERVICE_MAIN_FUNCTION) ServiceMain },
33 // set the service's current directory to being the installation directory for the service.
34 // this way we don't have to write absolute paths in the configuration files
36 GetModuleFileName( NULL, filename, sizeof( filename ) );
37 fname_start = strrchr( filename, *LDAP_DIRSEP );
39 SetCurrentDirectory( filename );
42 if ( _stricmp( "install", argv[1] ) == 0 )
44 char *svcName = SERVICE_NAME;
45 if ( (argc > 2) && (argv[2] != NULL) )
47 if ( (length = GetModuleFileName(NULL, filename, sizeof( filename ))) == 0 )
49 fputs( "unable to retrieve file name for the service.\n", stderr );
52 if ( !srv_install(svcName, filename) )
54 fputs( "service failed installation ...\n", stderr );
57 fputs( "service has been installed ...\n", stderr );
61 if ( _stricmp( "remove", argv[1] ) == 0 )
63 char *svcName = SERVICE_NAME;
64 if ( (argc > 2) && (argv[2] != NULL) )
66 if ( (length = GetModuleFileName(NULL, filename, sizeof( filename ))) == 0 )
68 fputs( "unable to retrieve file name for the service.\n", stderr );
71 if ( !srv_remove(svcName, filename) )
73 fputs( "failed to remove the service ...\n", stderr );
76 fputs( "service has been removed ...\n", stderr );
81 puts( "starting slapd..." );
82 if ( !StartServiceCtrlDispatcher(DispatchTable) )
85 ServiceMain( argc, argv );