~ubuntu-branches/debian/sid/upstart/sid

« back to all changes in this revision

Viewing changes to nih-dbus/dbus_error.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2009-07-23 00:24:02 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 19.
  • Revision ID: james.westby@ubuntu.com-20090723002402-pm5tq3kkipr18q00
Tags: 0.6.2-1
* New major upstream release. Closes: #530348
* Remove patches that have been merged upstream or are obsolete
  - debian/patches/01-limits.patch
  - debian/patches/02-telinit-u.patch
  - debian/patches/03-static-convenience-libs.patch
* Add Build-Depends on pkg-config (>= 0.22), libdbus-1-dev (>= 1.2.16) and
  libexpat1-dev (>= 2.0.0). D-Bus has replaced the home-grown IPC.
* Bump Standards-Version to 3.8.2. No further changes.
* debian/copyright
  - Update copyright years.
  - Clarify license text, Upstart is GPL-2 only.
  - Refer to the versioned GPL-2 document.
* Drop upstart-logd package. The logd daemon has been buggy for quite a
  while and thus removed completely upstream.
* debian/upstart.postinst
  - Use "telinit u" to tell init to re-exec itself.
* debian/rules
  - Remove obsolete configure flag.
  - Use dh_install instead of copying the job files around manually.
* Merge the upstart-compat-sysv, startup-tasks and system-services package
  into a single upstart package to avoid any unnecessary diversion between
  the Debian and Ubuntu packaging.
* The location of the job files has changed from /etc/event.d to /etc/init,
  in addition a *.conf suffix is now mandatory.
* Install rc.conf, rc-sysinit.conf, rcS.conf and control-alt-delete.conf as
  provided by upstream.
* debian/conf/*.conf
  - Update tty job files for the new job syntax. Add a description and
    author field.
  - Add dbus-reconnect.conf which tells Upstart to reconnect to the D-Bus
    system bus when runlevel 2345 has been reached.
* Update debian/upstart.install to reflect the changes above.
* Drop debian/upstart.dirs, obsolete.
* debian/README.Debian
  - Sync relevant changes from the latest Ubuntu package.
  - Remove outdated information.
* Add initial support for upstart-job.
  upstart-job is both a virtual package and also small helper utility which
  allows to execute native upstart jobs while preserving the legacy sysv
  "/etc/init.d/<service> <action>" interface.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* libnih
 
2
 *
 
3
 * Copyright © 2009 Scott James Remnant <scott@netsplit.com>.
 
4
 * Copyright © 2009 Canonical Ltd.
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License version 2, as
 
8
 * published by the Free Software Foundation.
 
9
 *
 
10
 * This program 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
 
13
 * GNU General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU General Public License along
 
16
 * with this program; if not, write to the Free Software Foundation, Inc.,
 
17
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
18
 */
 
19
 
 
20
#ifndef NIH_DBUS_ERROR_H
 
21
#define NIH_DBUS_ERROR_H
 
22
 
 
23
/**
 
24
 * Errors in libnih are raised by placing an NihError object in a local
 
25
 * variable that can be retrieved using nih_error_get().  Errors in libdbus
 
26
 * are returned on the stack by passing the address of a DBusError object
 
27
 * when calling functions.
 
28
 *
 
29
 * This module allows the two techniques to be bridged.
 
30
 *
 
31
 * When calling a libnih function, or writing a handler called by such
 
32
 * a function, you may use nih_dbus_error_raise() or
 
33
 * nih_dbus_error_raise_printf().  This may be retrieved by nih_error_get(),
 
34
 * and the handler poll function will do so and convert this into a D-Bus
 
35
 * error message if appropriate.
 
36
 *
 
37
 * For example:
 
38
 *
 
39
 *   nih_dbus_error_raise (DBUS_ERROR_INVALID_ARGS, "Expected Int32");
 
40
 *   return -1;
 
41
 *
 
42
 * When calling a libdbus function you should initialise a DBusError with
 
43
 * dbus_error_init() and pass its address to your function call.  Should
 
44
 * an error be returned, you can raise that so it can be retrieved by
 
45
 * nih_error_get() by passing the name and message members to
 
46
 * nih_dbus_error_raise().
 
47
 *
 
48
 * For example:
 
49
 *
 
50
 *   dbus_error_init (&dbus_err);
 
51
 *   if (! dbus_connection_open (address, &dbus_err)) {
 
52
 *     nih_dbus_error_raise (dbus_err.name, dbus_err.message);
 
53
 *     dbus_error_free (&dbus_err);
 
54
 *
 
55
 *     return -1;
 
56
 *   }
 
57
 *
 
58
 * In both cases, the error variable returned by nih_error_get() is not
 
59
 * actually NihError but NihDBusError.  This extends the original structure
 
60
 * to add a "name" member containing the D-Bus error name.  The error
 
61
 * number for all such errors is NIH_DBUS_ERROR.
 
62
 *
 
63
 * The nih_dbus_message_error() function defined in nih-dbus/dbus_message.h
 
64
 * allows you to send either type of error as a D-Bus error message.
 
65
 **/
 
66
 
 
67
#include <nih/macros.h>
 
68
#include <nih/error.h>
 
69
 
 
70
 
 
71
/**
 
72
 * NihDBusError:
 
73
 * @name: D-Bus name.
 
74
 *
 
75
 * This structure builds on NihError to include an additional @name field
 
76
 * required for transport across D-Bus.
 
77
 *
 
78
 * If you receive a NIH_DBUS_ERROR, the returned NihError structure is
 
79
 * actually this structure and can be cast to get the additional fields.
 
80
 **/
 
81
typedef struct nih_dbus_error {
 
82
        NIH_ERROR_MEMBERS
 
83
        char *   name;
 
84
} NihDBusError;
 
85
 
 
86
 
 
87
NIH_BEGIN_EXTERN
 
88
 
 
89
void nih_dbus_error_raise        (const char *name, const char *message);
 
90
 
 
91
void nih_dbus_error_raise_printf (const char *name, const char *format, ...)
 
92
        __attribute__ ((format (printf, 2, 3)));
 
93
 
 
94
NIH_END_EXTERN
 
95
 
 
96
#endif /* NIH_DBUS_ERROR_H */