2 * UDP Gateway utility startup scripts support
3 * Copyright (C) 2004 Jan Kratochvil <project-udpgate@jankratochvil.net>
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
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.
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
22 #include <glib/gmessages.h>
24 #include "startup.h" /* self */
25 #include "startup-lsb.h"
26 #include "startup-chkconfig.h"
27 #include "startup-debian.h"
30 gboolean udpgate_startup_query(UdpgateStartup *udpgate_startup,gboolean *is_on)
32 g_return_val_if_fail(UDPGATE_IS_STARTUP(udpgate_startup),FALSE);
34 return (*UDPGATE_STARTUP_GET_CLASS(udpgate_startup)->query)(udpgate_startup,is_on);
37 gboolean udpgate_startup_on(UdpgateStartup *udpgate_startup)
41 g_return_val_if_fail(UDPGATE_IS_STARTUP(udpgate_startup),FALSE);
43 if (!udpgate_startup_query(udpgate_startup,&is_on))
48 return (*UDPGATE_STARTUP_GET_CLASS(udpgate_startup)->on)(udpgate_startup);
51 gboolean udpgate_startup_off(UdpgateStartup *udpgate_startup)
55 g_return_val_if_fail(UDPGATE_IS_STARTUP(udpgate_startup),FALSE);
57 if (!udpgate_startup_query(udpgate_startup,&is_on))
62 return (*UDPGATE_STARTUP_GET_CLASS(udpgate_startup)->off)(udpgate_startup);
65 UdpgateStartup *udpgate_startup_new(void)
67 const GType impl_type_array[]={
68 UDPGATE_TYPE_STARTUP_LSB,
69 UDPGATE_TYPE_STARTUP_CHKCONFIG,
70 UDPGATE_TYPE_STARTUP_DEBIAN,
72 const GType *impl_type_pointer;
74 for (impl_type_pointer = impl_type_array;
75 impl_type_pointer < impl_type_array + G_N_ELEMENTS(impl_type_array);
76 impl_type_pointer++) {
77 UdpgateStartup *udpgate_startup;
79 udpgate_startup=g_object_new(*impl_type_pointer,NULL);
80 g_assert(UDPGATE_IS_STARTUP(udpgate_startup));
81 if (UDPGATE_STARTUP_GET_CLASS(udpgate_startup)->init(udpgate_startup))
82 return udpgate_startup;
83 g_object_unref(udpgate_startup);
90 udpgate_startup_class_init (UdpgateStartupClass *class)
95 udpgate_startup_get_type(void)
97 static GType startup_type=0;
100 static const GTypeInfo startup_info={
101 sizeof(UdpgateStartupClass),
102 NULL, /* base_init */
103 NULL, /* base_finalize */
104 (GClassInitFunc)udpgate_startup_class_init,
105 NULL, /* class_finalize */
106 NULL, /* class_data */
107 sizeof(UdpgateStartup),
109 NULL, /* instance_init */
110 NULL, /* value_table */
113 startup_type=g_type_register_static(G_TYPE_OBJECT,"UdpgateStartup",
114 &startup_info,G_TYPE_FLAG_ABSTRACT);