Backend daemon startup modes
This commit is contained in:
parent
23e40384f7
commit
496d676ad3
26 changed files with 769 additions and 280 deletions
|
|
@ -185,7 +185,7 @@ quit:
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*! Make a copy of file src
|
||||
/*! Make a copy of file src. Overwrite existing
|
||||
* @retval 0 OK
|
||||
* @retval -1 Error
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@
|
|||
|
||||
/* clicon */
|
||||
#include "clixon_err.h"
|
||||
#include "clixon_string.h"
|
||||
#include "clixon_queue.h"
|
||||
#include "clixon_hash.h"
|
||||
#include "clixon_handle.h"
|
||||
|
|
@ -69,6 +70,16 @@
|
|||
#include "clixon_xsl.h"
|
||||
#include "clixon_xml_map.h"
|
||||
|
||||
/* Mapping between Clicon startup modes string <--> constants,
|
||||
see clixon-config.yang type startup_mode */
|
||||
static const map_str2int startup_mode_map[] = {
|
||||
{"none", SM_NONE},
|
||||
{"running", SM_RUNNING},
|
||||
{"startup", SM_STARTUP},
|
||||
{"init", SM_INIT},
|
||||
{NULL, -1}
|
||||
};
|
||||
|
||||
/*! Print registry on file. For debugging.
|
||||
*/
|
||||
void
|
||||
|
|
@ -332,7 +343,6 @@ clicon_option_sanity(clicon_hash_t *copt)
|
|||
return retval;
|
||||
}
|
||||
|
||||
|
||||
/*! Initialize option values
|
||||
*
|
||||
* Set default options, Read config-file, Check that all values are set.
|
||||
|
|
@ -387,9 +397,12 @@ clicon_options_main(clicon_handle h)
|
|||
}
|
||||
|
||||
/*! Check if a clicon option has a value
|
||||
* @param[in] h clicon_handle
|
||||
* @param[in] name option name
|
||||
*/
|
||||
int
|
||||
clicon_option_exists(clicon_handle h, const char *name)
|
||||
clicon_option_exists(clicon_handle h,
|
||||
const char *name)
|
||||
{
|
||||
clicon_hash_t *copt = clicon_options(h);
|
||||
|
||||
|
|
@ -449,7 +462,8 @@ clicon_option_str_set(clicon_handle h,
|
|||
* supply a defualt value as shown in the example.
|
||||
*/
|
||||
int
|
||||
clicon_option_int(clicon_handle h, const char *name)
|
||||
clicon_option_int(clicon_handle h,
|
||||
const char *name)
|
||||
{
|
||||
char *s;
|
||||
|
||||
|
|
@ -461,7 +475,9 @@ clicon_option_int(clicon_handle h, const char *name)
|
|||
/*! Set option given as int.
|
||||
*/
|
||||
int
|
||||
clicon_option_int_set(clicon_handle h, const char *name, int val)
|
||||
clicon_option_int_set(clicon_handle h,
|
||||
const char *name,
|
||||
int val)
|
||||
{
|
||||
char s[64];
|
||||
|
||||
|
|
@ -473,7 +489,8 @@ clicon_option_int_set(clicon_handle h, const char *name, int val)
|
|||
/*! Delete option
|
||||
*/
|
||||
int
|
||||
clicon_option_del(clicon_handle h, const char *name)
|
||||
clicon_option_del(clicon_handle h,
|
||||
const char *name)
|
||||
{
|
||||
clicon_hash_t *copt = clicon_options(h);
|
||||
|
||||
|
|
@ -550,6 +567,15 @@ clicon_xmldb_plugin(clicon_handle h)
|
|||
return clicon_option_str(h, "CLICON_XMLDB_PLUGIN");
|
||||
}
|
||||
|
||||
int
|
||||
clicon_startup_mode(clicon_handle h)
|
||||
{
|
||||
char *mode;
|
||||
if ((mode = clicon_option_str(h, "CLICON_STARTUP_MODE")) == NULL)
|
||||
return -1;
|
||||
return clicon_str2int(startup_mode_map, mode);
|
||||
}
|
||||
|
||||
/*! Get family of backend socket: AF_UNIX, AF_INET or AF_INET6 */
|
||||
int
|
||||
clicon_sock_family(clicon_handle h)
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ xmldb_plugin_unload(clicon_handle h)
|
|||
* @retval -1 Failed validate, xret set to error
|
||||
*/
|
||||
int
|
||||
xmldb_validate_db(char *db)
|
||||
xmldb_validate_db(const char *db)
|
||||
{
|
||||
if (strcmp(db, "running") != 0 &&
|
||||
strcmp(db, "candidate") != 0 &&
|
||||
|
|
@ -336,7 +336,7 @@ xmldb_setopt(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_get(clicon_handle h,
|
||||
char *db,
|
||||
const char *db,
|
||||
char *xpath,
|
||||
int config,
|
||||
cxobj **xtop)
|
||||
|
|
@ -393,7 +393,7 @@ xmldb_get(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_put(clicon_handle h,
|
||||
char *db,
|
||||
const char *db,
|
||||
enum operation_type op,
|
||||
cxobj *xt)
|
||||
{
|
||||
|
|
@ -439,8 +439,8 @@ xmldb_put(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_copy(clicon_handle h,
|
||||
char *from,
|
||||
char *to)
|
||||
const char *from,
|
||||
const char *to)
|
||||
{
|
||||
int retval = -1;
|
||||
xmldb_handle xh;
|
||||
|
|
@ -472,7 +472,7 @@ xmldb_copy(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_lock(clicon_handle h,
|
||||
char *db,
|
||||
const char *db,
|
||||
int pid)
|
||||
{
|
||||
int retval = -1;
|
||||
|
|
@ -506,7 +506,7 @@ xmldb_lock(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_unlock(clicon_handle h,
|
||||
char *db)
|
||||
const char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
xmldb_handle xh;
|
||||
|
|
@ -569,7 +569,7 @@ xmldb_unlock_all(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_islocked(clicon_handle h,
|
||||
char *db)
|
||||
const char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
xmldb_handle xh;
|
||||
|
|
@ -601,7 +601,7 @@ xmldb_islocked(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_exists(clicon_handle h,
|
||||
char *db)
|
||||
const char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
xmldb_handle xh;
|
||||
|
|
@ -632,7 +632,7 @@ xmldb_exists(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_delete(clicon_handle h,
|
||||
char *db)
|
||||
const char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
xmldb_handle xh;
|
||||
|
|
@ -663,7 +663,7 @@ xmldb_delete(clicon_handle h,
|
|||
*/
|
||||
int
|
||||
xmldb_create(clicon_handle h,
|
||||
char *db)
|
||||
const char *db)
|
||||
{
|
||||
int retval = -1;
|
||||
xmldb_handle xh;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue