~ubuntu-core-dev/ubuntu/raring/upstart/raring

« back to all changes in this revision

Viewing changes to init/control.h

  • Committer: Stéphane Graber
  • Date: 2013-03-07 18:43:01 UTC
  • mfrom: (1182.56.54 upstart)
  • Revision ID: stgraber@ubuntu.com-20130307184301-dlmb1c5bwonqagkw
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* upstart
2
2
 *
3
 
 * Copyright © 2009-2011 Canonical Ltd.
 
3
 * Copyright  2009-2011 Canonical Ltd.
4
4
 * Author: Scott James Remnant <scott@netsplit.com>.
5
5
 *
6
6
 * This program is free software; you can redistribute it and/or modify
30
30
 
31
31
#include <json.h>
32
32
 
 
33
#include "event.h"
 
34
#include "quiesce.h"
 
35
 
33
36
/**
34
37
 * USE_SESSION_BUS_ENV:
35
38
 *
42
45
#define USE_SESSION_BUS_ENV "UPSTART_USE_SESSION_BUS"
43
46
#endif
44
47
 
 
48
/**
 
49
 * control_get_job:
 
50
 * 
 
51
 * @session: session,
 
52
 * @job: job that will be set,
 
53
 * @job_name: name of job to search for,
 
54
 * @instance: instance of @job_name to search for.
 
55
 *
 
56
 * Determine the Job associated with @job_name and @instance and set it
 
57
 * to @job.
 
58
 *
 
59
 * Returns: -1 on raised error, or nothing on success.
 
60
 **/
 
61
#define control_get_job(session, job, job_name, instance)            \
 
62
{                                                                    \
 
63
        if (job_name != NULL ) {                                     \
 
64
                JobClass *class;                                     \
 
65
                                                                     \
 
66
                class = job_class_find (session, job_name);          \
 
67
                if (! class) {                                       \
 
68
                        nih_dbus_error_raise_printf (                \
 
69
                                DBUS_INTERFACE_UPSTART               \
 
70
                                ".Error.UnknownJob",                 \
 
71
                                _("Unknown job: %s"),                \
 
72
                                job_name);                           \
 
73
                        return -1;                                   \
 
74
                }                                                    \
 
75
                                                                     \
 
76
                job = job_find (session, class, NULL, instance);     \
 
77
                if (job == NULL) {                                   \
 
78
                        nih_dbus_error_raise_printf (                \
 
79
                                DBUS_INTERFACE_UPSTART               \
 
80
                                ".Error.UnknownJobInstance",         \
 
81
                                _("Unknown instance: %s of job %s"), \
 
82
                                instance, job_name);                 \
 
83
                        return -1;                                   \
 
84
                }                                                    \
 
85
        }                                                            \
 
86
}
45
87
 
46
88
NIH_BEGIN_EXTERN
47
89
 
52
94
 
53
95
 
54
96
void control_init                 (void);
 
97
void control_cleanup              (void);
55
98
 
56
99
int  control_server_open          (void)
57
100
        __attribute__ ((warn_unused_result));
113
156
int  control_restart (void *data, NihDBusMessage *message)
114
157
        __attribute__ ((warn_unused_result));
115
158
 
 
159
void control_notify_event_emitted (Event *event);
 
160
void control_notify_restarted (void);
 
161
 
 
162
int control_set_env (void           *data,
 
163
                 NihDBusMessage *message,
 
164
                 char * const    *job_details,
 
165
                 const char     *var,
 
166
                 int             replace)
 
167
        __attribute__ ((warn_unused_result));
 
168
 
 
169
int control_get_env (void             *data,
 
170
                 NihDBusMessage   *message,
 
171
                 char * const     *job_details,
 
172
                 const char       *name,
 
173
                 char            **value)
 
174
        __attribute__ ((warn_unused_result));
 
175
 
 
176
int
 
177
control_list_env (void             *data,
 
178
                 NihDBusMessage   *message,
 
179
                 char * const     *job_details,
 
180
                 char           ***env)
 
181
        __attribute__ ((warn_unused_result));
 
182
 
 
183
int
 
184
control_reset_env (void           *data,
 
185
                 NihDBusMessage   *message,
 
186
                 char * const    *job_details)
 
187
        __attribute__ ((warn_unused_result));
 
188
 
 
189
int
 
190
control_unset_env (void            *data,
 
191
                   NihDBusMessage  *message,
 
192
                   char * const    *job_details,
 
193
                   const char      *name)
 
194
        __attribute__ ((warn_unused_result));
 
195
 
116
196
NIH_END_EXTERN
117
197
 
118
198
#endif /* INIT_CONTROL_H */