GModule disabled moved out to the static building package.
[udpgate.git] / src / static-startup.c
1 /* $Id$
2  * UDP Gateway utility startup scripts support
3  * Copyright (C) 2004 Jan Kratochvil <project-udpgate@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program 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.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #include "config.h"
21
22 #include <glib/gmessages.h>
23 #include <string.h>
24
25 #include "static-startup.h"     /* self */
26 #include "startup.h"
27 #include "main.h"       /* for: optarg_verbose */
28
29
30 static UdpgateStartup *static_startup_udpgate;
31
32
33 static gboolean static_startup_udpgate_init(void)
34 {
35 static gboolean first=TRUE;
36
37         if (!static_startup_udpgate && first) {
38                 first=FALSE;
39                 static_startup_udpgate=udpgate_startup_new();
40                 if (!static_startup_udpgate)
41                         g_warning(_("All automatic startup methods failed; automatic startup disabled."));
42                 else {
43                         if (optarg_verbose) {
44                                 const gchar *startup_base_name=g_type_name(UDPGATE_TYPE_STARTUP);
45                                 const gchar *startup_used_name=G_OBJECT_TYPE_NAME(static_startup_udpgate);
46
47                                 if (!strncmp(startup_base_name,startup_used_name,strlen(startup_base_name)))
48                                         startup_used_name+=strlen(startup_base_name);
49
50                                 g_message(_("Using automatic startup type: %s"),startup_used_name);
51                                 }
52                         }
53                 }
54         return !!static_startup_udpgate;
55 }
56
57 gboolean static_startup_supported(void)
58 {
59         return static_startup_udpgate_init();
60 }
61
62 gboolean static_startup_query(gboolean *is_on)
63 {
64         if (!static_startup_udpgate_init())
65                 return FALSE;
66         return udpgate_startup_query(static_startup_udpgate,is_on);
67 }
68
69 gboolean static_startup_on(void)
70 {
71         if (!static_startup_udpgate_init())
72                 return FALSE;
73         return udpgate_startup_on(static_startup_udpgate);
74 }
75
76 gboolean static_startup_off(void)
77 {
78         if (!static_startup_udpgate_init())
79                 return FALSE;
80         return udpgate_startup_off(static_startup_udpgate);
81 }