From f83210c88e7376e12b5cf0e86a073c59e4185efb Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Fri, 27 Mar 2009 15:18:58 +0100 Subject: started to add usefull Windows service documentation, started with wolf_service_start_console --- include/wolf/service/service.h | 53 ++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 18 deletions(-) (limited to 'include') diff --git a/include/wolf/service/service.h b/include/wolf/service/service.h index 1275d0b..2033117 100644 --- a/include/wolf/service/service.h +++ b/include/wolf/service/service.h @@ -67,6 +67,38 @@ typedef struct wolf_service_params_t { */ wolf_error_t wolf_service_install( wolf_service_params_t params ); +/** + * Uninstalls the current binary as a Windows service. + * + * @param service_name the name of the service to remove from the service infrastructure + * + * @return WOLF_OK if the service was removed, or an WOLF_ERR_INTERNAL + * (which also gets logged with wolf_log) + */ +wolf_error_t wolf_service_remove( LPCTSTR service_name ); + +/** + * Start the service + * + * @param service_name the name of the service previously registered with + * wolf_service_install + * @param service_main the main function (which should implement startup/shutdown + * and the main processing loop) + * + * @return When the main thread terminates after a service shutdown. + * You should not do much after this point in the code.. + */ +wolf_error_t wolf_service_start( LPTSTR service_name, + LPSERVICE_MAIN_FUNCTION service_main ); + +wolf_error_t wolf_service_start_console( LPTSTR service_name, + LPSERVICE_MAIN_FUNCTION service_main, + DWORD argc, + LPTSTR *argv ); + +/** + * @brief events which can happen in a service + */ typedef enum wolf_service_event_t { WOLF_SERVICE_NO_EVENT, /**< no event happened */ WOLF_SERVICE_EVENT_TERMINATE /**< terminate the service now */ @@ -77,30 +109,15 @@ typedef enum wolf_service_event_t { * we only get the SERVICE_EVENT_TERMINATE event. * * @param timeout wait at most timeout seconds, then return also - * without an event happening + * without an event happening, error is set to + * WOLF_ERR_TIMEOUT in this case * @param error WOLF_OK if an event occured, WOLF_ERR_TIMEOUT if * no signal happened after timeout seconds + * * @return the event which happened */ wolf_service_event_t wolf_service_events_suspend( int timeout, wolf_error_t *error ); -/** - * The main service function. - * - * @param argc number of arguments as in main() - * @param argv arguments as in main() - * - * Note: Must be exported as it gets called from the SCM in a service thread/process. - */ -void WINAPI wolf_service_main( DWORD argc, LPTSTR *argv ); - -void wolf_service_register_main( LPSERVICE_MAIN_FUNCTION service_main ); - -int wolf_service_run( LPTSTR service_name, - wolf_error_t *error ); - - - #ifdef __cplusplus } #endif -- cgit v1.2.3-54-g00ecf