~lnykryn/upstart/global-configuration

« back to all changes in this revision

Viewing changes to init/parse_conf.c

  • Committer: Lukáš Nykrýn
  • Date: 2012-02-09 08:41:23 UTC
  • Revision ID: lnykryn@redhat.com-20120209084123-hah55v3np0egpa1o
basic implementation of init.conf

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
 *
64
64
 * Returns: zero on success, negative value on raised error.
65
65
 **/
66
 
int
67
 
parse_conf (ConfFile   *conffile,
68
 
            const char *file,
69
 
            size_t      len,
70
 
            size_t     *pos,
71
 
            size_t     *lineno)
 
66
JobClass *
 
67
parse_conf (const void *parent,
 
68
           Session    *session,
 
69
           JobClass   *update,
 
70
           const char *file,
 
71
           size_t      len,
 
72
           size_t     *pos,
 
73
           size_t     *lineno)
72
74
{
73
 
        nih_assert (conffile != NULL);
 
75
        JobClass *class;
 
76
 
74
77
        nih_assert (file != NULL);
75
78
        nih_assert (pos != NULL);
76
79
 
77
 
        /* If we update 'stanzas' to allow content in init.conf, this
78
 
         * function must be updated in a similar manner to parse_job()
79
 
         * to handle overrides files.
80
 
         */
81
 
        nih_assert (sizeof(stanzas) / sizeof(stanzas[0]) == 1);
 
80
        if (update) {
 
81
                class = update;
 
82
                nih_debug ("Reusing template JobClass");
 
83
        } else {
 
84
                nih_debug ("Creating new template JobClass");
 
85
                class = job_class_new (parent, "GLOBAL", NULL, session);
 
86
                if (! class)
 
87
                        nih_return_system_error (NULL);
 
88
        }
82
89
 
83
90
        if (nih_config_parse_file (file, len, pos, lineno,
84
 
                                   stanzas, conffile) < 0)
85
 
                return -1;
 
91
                                stanzas, class) < 0) {
 
92
                if (!update)
 
93
                        nih_free (class);
 
94
                return NULL;
 
95
        }
86
96
 
87
 
        return 0;
 
97
        return class;
88
98
}