Added ssl status responses
[jimb.git] / src / services.c
blobff60983c4fd19b8d294b851f949aa5a07f871f95
1 /**
2 * JIMCI (Jabber Instant Messaging Connection Interface)
3 * This file is part of JIMB.
5 * JIMCI is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License Version 3
7 * as published by the Free Software Foundation.
9 * JIMCI is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License Version 3
15 * along with JIMCI; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 * File: Services
19 * Package: JIMCI
20 * Author: Martin Kelm <martinkelm@idxsolutions.de>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <glib.h>
26 #include "main.h"
27 #include "services.h"
29 gchar *services_actions_exec;
30 gchar *services_actions_script;
31 gchar *services_updates_exec;
32 gchar *services_updates_script;
33 extern gchar *services_queue_message;
35 gboolean services_actions_perform(gpointer data) {
36 gchar *command = g_strdup_printf("%s%s", services_actions_exec, services_actions_script);
37 system(command);
38 debug("Services actions execution: %s", command);
39 return TRUE;
42 gboolean services_updates_perform(gpointer data) {
43 gchar *command = g_strdup_printf("%s%s", services_updates_exec, services_updates_script);
44 system(command);
45 debug("Services updates execution: %s", command);
46 return TRUE;
49 int services_init(
50 char *actions_exec, char *actions_script, int actions_interval,
51 char *updates_exec, char *updates_script, int updates_interval, char *queue_message
52 ) {
53 if (strlen(queue_message) > 0) {
54 services_queue_message = queue_message;
55 } else {
56 services_queue_message = "";
58 if (strlen(actions_exec) > 0 && actions_interval > 0) {
59 if (strlen(actions_script) > 0) {
60 services_actions_script = g_strdup_printf(" %s", actions_script);
61 } else {
62 services_actions_script = "";
64 services_actions_exec = actions_exec;
65 gint func_ref_actions = g_timeout_add(actions_interval * 1000, services_actions_perform, NULL);
67 if (strlen(updates_exec) > 0 && updates_interval > 0) {
68 if (strlen(updates_script) > 0) {
69 services_updates_script = g_strdup_printf(" %s", updates_script);
70 } else {
71 services_updates_script = "";
73 services_updates_exec = updates_exec;
74 gint func_ref_updates = g_timeout_add(updates_interval * 1000, services_updates_perform, NULL);
77 debug("Services initialized");