syslog-ng source
apphook.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-2012 Balabit
3  * Copyright (c) 1998-2012 Balázs Scheidler
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * As an additional exemption you are allowed to compile & link against the
20  * OpenSSL libraries as published by the OpenSSL project. See the file
21  * COPYING for details.
22  *
23  */
24 
25 #ifndef APPHOOK_H_INCLUDED
26 #define APPHOOK_H_INCLUDED
27 
28 #include "syslog-ng.h"
29 
30 enum
31 {
32  /* these states happen as a sequence and only happen once */
38 
39  /* this item separates state-like hooks from events happening regularly in
40  * the RUNNING state */
42 
43  /* these happen from time to time and don't update the current state of
44  * the process */
45  AH_CONFIG_PRE_PRE_INIT, /* configuration pre_init() is to be called */
46  AH_CONFIG_PRE_INIT, /* configuration init() is to be called */
47  AH_CONFIG_STOPPED, /* configuration is deinitialized, threads have stopped */
48  AH_CONFIG_CHANGED, /* configuration changed, threads are running again */
49  AH_REOPEN_FILES, /* reopen files signal from syslog-ng-ctl */
50 };
51 
52 typedef enum
53 {
57 
58 /* state-like hook entry points */
59 void app_startup(void);
60 void app_post_daemonized(void);
61 void app_running(void);
62 void app_pre_shutdown(void);
63 void app_shutdown(void);
64 
65 /* stateless entry points */
66 void app_config_pre_pre_init(void);
67 void app_config_pre_init(void);
68 void app_config_stopped(void);
69 void app_config_changed(void);
70 void app_reopen_files(void);
71 
72 typedef void (*ApplicationHookFunc)(gint type, gpointer user_data);
73 typedef void (*ApplicationThreadHookFunc)(gpointer user_data);
74 
75 gboolean app_is_starting_up(void);
76 gboolean app_is_shutting_down(void);
77 
78 void register_application_hook(gint type,
79  ApplicationHookFunc func, gpointer user_data,
80  ApplicationHookRunMode run_mode);
81 
84 
85 void app_thread_start(void);
86 void app_thread_stop(void);
87 
88 #endif
void app_shutdown(void)
Definition: apphook.c:268
void register_application_hook(gint type, ApplicationHookFunc func, gpointer user_data, ApplicationHookRunMode run_mode)
Definition: apphook.c:88
void app_startup(void)
Definition: apphook.c:216
void register_application_thread_deinit_hook(ApplicationThreadHookFunc func, gpointer user_data)
Definition: apphook.c:123
void app_thread_stop(void)
Definition: apphook.c:351
gboolean app_is_starting_up(void)
Definition: apphook.c:76
void register_application_thread_init_hook(ApplicationThreadHookFunc func, gpointer user_data)
Definition: apphook.c:112
void(* ApplicationThreadHookFunc)(gpointer user_data)
Definition: apphook.h:73
void app_post_daemonized(void)
Definition: apphook.c:249
void app_pre_shutdown(void)
Definition: apphook.c:262
gboolean app_is_shutting_down(void)
Definition: apphook.c:82
void app_config_pre_pre_init(void)
Definition: apphook.c:312
void app_thread_start(void)
Definition: apphook.c:342
void(* ApplicationHookFunc)(gint type, gpointer user_data)
Definition: apphook.h:72
void app_config_pre_init(void)
Definition: apphook.c:318
void app_reopen_files(void)
Definition: apphook.c:336
void app_running(void)
Definition: apphook.c:255
void app_config_changed(void)
Definition: apphook.c:330
@ AH_CONFIG_PRE_INIT
Definition: apphook.h:46
@ AH_CONFIG_CHANGED
Definition: apphook.h:48
@ AH_PRE_SHUTDOWN
Definition: apphook.h:36
@ AH_SHUTDOWN
Definition: apphook.h:37
@ AH_STARTUP
Definition: apphook.h:33
@ AH_POST_DAEMONIZED
Definition: apphook.h:34
@ AH_CONFIG_STOPPED
Definition: apphook.h:47
@ AH_REOPEN_FILES
Definition: apphook.h:49
@ __AH_STATE_MAX
Definition: apphook.h:41
@ AH_CONFIG_PRE_PRE_INIT
Definition: apphook.h:45
@ AH_RUNNING
Definition: apphook.h:35
void app_config_stopped(void)
Definition: apphook.c:324
ApplicationHookRunMode
Definition: apphook.h:53
@ AHM_RUN_ONCE
Definition: apphook.h:54
@ AHM_RUN_REPEAT
Definition: apphook.h:55