chiark / gitweb /
gcc: make a couple of gcc warnings go away
[elogind.git] / cgroups-agent.c
1 /*-*- Mode: C; c-basic-offset: 8 -*-*/
2
3 /***
4   This file is part of systemd.
5
6   Copyright 2010 Lennart Poettering
7
8   systemd is free software; you can redistribute it and/or modify it
9   under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2 of the License, or
11   (at your option) any later version.
12
13   systemd is distributed in the hope that it will be useful, but
14   WITHOUT ANY WARRANTY; without even the implied warranty of
15   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16   General Public License for more details.
17
18   You should have received a copy of the GNU General Public License
19   along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <dbus/dbus.h>
23
24 #include "log.h"
25
26 int main(int argc, char *argv[]) {
27         DBusError error;
28         DBusConnection *bus = NULL;
29         DBusMessage *m = NULL;
30         int r = 1;
31
32         dbus_error_init(&error);
33
34         if (argc != 2) {
35                 log_error("Incorrect number of arguments.");
36                 goto finish;
37         }
38
39         if (!(bus = dbus_bus_get(DBUS_BUS_SYSTEM, &error))) {
40                 log_error("Failed to get D-Bus connection: %s", error.message);
41                 goto finish;
42         }
43
44         if (!(m = dbus_message_new_signal("/org/freedesktop/systemd1/agent", "org.freedesktop.systemd1.Agent", "Released"))) {
45                 log_error("Could not allocate signal message.");
46                 goto finish;
47         }
48
49         if (!dbus_message_append_args(m,
50                                       DBUS_TYPE_STRING, &argv[1],
51                                       DBUS_TYPE_INVALID)) {
52                 log_error("Could not attach group information to signal message.");
53                 goto finish;
54         }
55
56         if (!dbus_connection_send(bus, m, NULL)) {
57                 log_error("Failed to send signal message.");
58                 goto finish;
59         }
60
61         r = 0;
62
63 finish:
64         if (bus)
65                 dbus_connection_unref(bus);
66
67         if (m)
68                 dbus_message_unref(m);
69
70         dbus_error_free(&error);
71         return r;
72 }