9 ldap_pvt_thread_cond_t started_event, stopped_event;
10 ldap_pvt_thread_t start_status_tid, stop_status_tid;
14 void WINAPI ServiceMain( DWORD argc, LPTSTR *argv );
17 int srv_install( char* service, char* filename );
18 int srv_remove ( char* service, char* filename );
20 int main( DWORD argc, LPTSTR *argv )
23 char filename[MAX_PATH], *fname_start;
24 extern int is_NT_Service;
26 SERVICE_TABLE_ENTRY DispatchTable[] = {
27 { SERVICE_NAME, (LPSERVICE_MAIN_FUNCTION) ServiceMain },
32 // set the service's current directory to being the installation directory for the service.
33 // this way we don't have to write absolute paths in the configuration files
35 GetModuleFileName( NULL, filename, sizeof( filename ) );
36 fname_start = strrchr( filename, *LDAP_DIRSEP );
38 SetCurrentDirectory( filename );
41 if ( _stricmp( "install", argv[1] ) == 0 )
43 char *svcName = SERVICE_NAME;
44 if ( (argc > 2) && (argv[2] != NULL) )
46 if ( (length = GetModuleFileName(NULL, filename, sizeof( filename ))) == 0 )
48 fputs( "unable to retrieve file name for the service.\n", stderr );
51 if ( !srv_install(svcName, filename) )
53 fputs( "service failed installation ...\n", stderr );
56 fputs( "service has been installed ...\n", stderr );
60 if ( _stricmp( "remove", 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_remove(svcName, filename) )
72 fputs( "failed to remove the service ...\n", stderr );
75 fputs( "service has been removed ...\n", stderr );
80 puts( "starting slapd..." );
81 if ( !StartServiceCtrlDispatcher(DispatchTable) )
84 ServiceMain( argc, argv );