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 */
33   AH_STARTUP,
34   AH_POST_DAEMONIZED,
35   AH_RUNNING,
36   AH_PRE_SHUTDOWN,
37   AH_SHUTDOWN,
38 
39   /* this item separates state-like hooks from events happening regularly in
40    * the RUNNING state */
41   __AH_STATE_MAX,
42 
43   /* these happen from time to time and don't update the current state of
44    * the process */
45   AH_CONFIG_STOPPED,   /* configuration is deinitialized, threads have stopped */
46   AH_CONFIG_CHANGED,   /* configuration changed, threads are running again */
47   AH_REOPEN_FILES,     /* reopen files signal from syslog-ng-ctl */
48 };
49 
50 typedef enum
51 {
52   AHM_RUN_ONCE,
53   AHM_RUN_REPEAT,
54 } ApplicationHookRunMode;
55 
56 /* state-like hook entry points */
57 void app_startup(void);
58 void app_post_daemonized(void);
59 void app_running(void);
60 void app_pre_shutdown(void);
61 void app_shutdown(void);
62 
63 /* stateless entry points */
64 void app_config_stopped(void);
65 void app_config_changed(void);
66 void app_reopen_files(void);
67 
68 typedef void (*ApplicationHookFunc)(gint type, gpointer user_data);
69 
70 gboolean app_is_starting_up(void);
71 gboolean app_is_shutting_down(void);
72 
73 void register_application_hook(gint type,
74                                ApplicationHookFunc func, gpointer user_data,
75                                ApplicationHookRunMode run_mode);
76 
77 void app_thread_start(void);
78 void app_thread_stop(void);
79 
80 #endif
81