~vorlon/ubuntu/raring/upstart/lp.1199778

« back to all changes in this revision

Viewing changes to init/control.h

* dbus/com.ubuntu.Upstart.xml:
  - Added 'job_details' string array as first parameter for GetEnv,
    SetEnv, UnsetEnv, ListEnv and ResetEnv to allow methods to either
    act globally or on a specific job environment.
* init/control.c:
  - control_set_env():
  - control_unset_env():
  - control_get_env():
  - control_list_env():
  - control_reset_env():
    - Disallow setting for PID 1.
    - Operate globally or on specified job.
* init/control.h: control_get_job(): Macro to simplify extracting job
  from provided job details.
* init/job.c: job_find(): New function.
* init/job_class.c:
  - job_class_environment_set(): Delimiter handling now moved to
    control_set_env() so it can be shared by job and global logic.
  - job_class_find(): New function.
* init/state.c:
  - Removed state_get_job() and replaced calls with job_find().
* util/initctl.c:
  - Updated *_action() functions for new D-Bus parameters and made use
    of new function get_job_details().

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
#define USE_SESSION_BUS_ENV "UPSTART_USE_SESSION_BUS"
45
45
#endif
46
46
 
 
47
/**
 
48
 * control_get_job:
 
49
 * 
 
50
 * @job: Job that will be set,
 
51
 * @job_name: name of job to search for,
 
52
 * @instance: instance of @job_name to search for.
 
53
 *
 
54
 * Determine the Job associated with @job_name and @instance and set it
 
55
 * to @job.
 
56
 *
 
57
 * Returns: -1 on raised error, or nothing on success.
 
58
 **/
 
59
#define control_get_job(job, job_name, instance)                     \
 
60
{                                                                    \
 
61
        if (job_name != NULL ) {                                     \
 
62
                JobClass *class;                                     \
 
63
                                                                     \
 
64
                class = job_class_find (session, job_name);          \
 
65
                if (! class) {                                       \
 
66
                        nih_dbus_error_raise_printf (                \
 
67
                                DBUS_INTERFACE_UPSTART               \
 
68
                                ".Error.UnknownJob",                 \
 
69
                                _("Unknown job: %s"),                \
 
70
                                job_name);                           \
 
71
                        return -1;                                   \
 
72
                }                                                    \
 
73
                                                                     \
 
74
                job = job_find (session, class, NULL, instance);     \
 
75
                if (! job) {                                         \
 
76
                        nih_dbus_error_raise_printf (                \
 
77
                                DBUS_INTERFACE_UPSTART               \
 
78
                                ".Error.UnknownJobInstance",         \
 
79
                                _("Unknown instance: %s of job %s"), \
 
80
                                job_name, instance);                 \
 
81
                        return -1;                                   \
 
82
                }                                                    \
 
83
        }                                                            \
 
84
}
 
85
 
47
86
NIH_BEGIN_EXTERN
48
87
 
49
88
extern DBusServer     *control_server;