All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
clixon_options.c File Reference
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <syslog.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <cligen/cligen.h>
#include "clixon_err.h"
#include "clixon_queue.h"
#include "clixon_hash.h"
#include "clixon_handle.h"
#include "clixon_chunk.h"
#include "clixon_log.h"
#include "clixon_yang.h"
#include "clixon_options.h"


void clicon_option_dump (clicon_handle h, int dbglevel)
static int clicon_option_readfile (clicon_hash_t *copt, const char *filename)
static int clicon_option_default (clicon_hash_t *copt)
static int clicon_option_sanity (clicon_hash_t *copt)
int clicon_options_main (clicon_handle h)
int clicon_option_exists (clicon_handle h, const char *name)
char * clicon_option_str (clicon_handle h, const char *name)
int clicon_option_str_set (clicon_handle h, const char *name, char *val)
int clicon_option_int (clicon_handle h, const char *name)
int clicon_option_int_set (clicon_handle h, const char *name, int val)
int clicon_option_del (clicon_handle h, const char *name)
char * clicon_configfile (clicon_handle h)
char * clicon_yang_dir (clicon_handle h)
char * clicon_yang_module_main (clicon_handle h)
char * clicon_yang_module_revision (clicon_handle h)
char * clicon_backend_dir (clicon_handle h)
char * clicon_cli_dir (clicon_handle h)
char * clicon_clispec_dir (clicon_handle h)
char * clicon_netconf_dir (clicon_handle h)
char * clicon_restconf_dir (clicon_handle h)
char * clicon_archive_dir (clicon_handle h)
int clicon_sock_family (clicon_handle h)
char * clicon_sock (clicon_handle h)
int clicon_sock_port (clicon_handle h)
char * clicon_backend_pidfile (clicon_handle h)
char * clicon_sock_group (clicon_handle h)
char * clicon_master_plugin (clicon_handle h)
char * clicon_cli_mode (clicon_handle h)
int clicon_cli_genmodel (clicon_handle h)
enum genmodel_type clicon_cli_genmodel_type (clicon_handle h)
char * clicon_quiet_mode (clicon_handle h)
int clicon_autocommit (clicon_handle h)
int clicon_autocommit_set (clicon_handle h, int val)
int clicon_cli_varonly (clicon_handle h)
int clicon_cli_varonly_set (clicon_handle h, int val)
int clicon_cli_genmodel_completion (clicon_handle h)
char * clicon_xmldb_dir (clicon_handle h)
yang_spec * clicon_dbspec_yang (clicon_handle h)
int clicon_dbspec_yang_set (clicon_handle h, struct yang_spec *ys)
char * clicon_dbspec_name (clicon_handle h)
int clicon_dbspec_name_set (clicon_handle h, char *name)

Function Documentation

char* clicon_archive_dir ( clicon_handle  h)
int clicon_autocommit ( clicon_handle  h)
int clicon_autocommit_set ( clicon_handle  h,
int  val 
char* clicon_backend_dir ( clicon_handle  h)
char* clicon_backend_pidfile ( clicon_handle  h)
char* clicon_cli_dir ( clicon_handle  h)
int clicon_cli_genmodel ( clicon_handle  h)

Whether to generate CLIgen syntax from datamodel or not (0 or 1) Must be used with a previous clicon_option_exists().

int clicon_cli_genmodel_completion ( clicon_handle  h)
enum genmodel_type clicon_cli_genmodel_type ( clicon_handle  h)
char* clicon_cli_mode ( clicon_handle  h)
int clicon_cli_varonly ( clicon_handle  h)

Dont include keys in cvec in cli vars callbacks

int clicon_cli_varonly_set ( clicon_handle  h,
int  val 
char* clicon_clispec_dir ( clicon_handle  h)
char* clicon_configfile ( clicon_handle  h)
char* clicon_dbspec_name ( clicon_handle  h)
int clicon_dbspec_name_set ( clicon_handle  h,
char *  name 
yang_spec* clicon_dbspec_yang ( clicon_handle  h)

Get YANG specification Must use hash functions directly since they are not strings.

int clicon_dbspec_yang_set ( clicon_handle  h,
struct yang_spec *  ys 
char* clicon_master_plugin ( clicon_handle  h)
char* clicon_netconf_dir ( clicon_handle  h)
static int clicon_option_default ( clicon_hash_t *  copt)

Set default values of some options that may not appear in config-file

int clicon_option_del ( clicon_handle  h,
const char *  name 

delete option

void clicon_option_dump ( clicon_handle  h,
int  dbglevel 
int clicon_option_exists ( clicon_handle  h,
const char *  name 

Check if a clicon option has a value

int clicon_option_int ( clicon_handle  h,
const char *  name 

Get options as integer but stored as string

hclicon handle
namename of option
Return values
intAn integer as aresult of atoi
-1If option does not exist
return clicon_option_int(h, "X");
return 0;
Note that -1 can be both error and value. This means that it should be used together with clicon_option_exists() and supply a defualt value as shown in the example.
int clicon_option_int_set ( clicon_handle  h,
const char *  name,
int  val 

set option given as int.

static int clicon_option_readfile ( clicon_hash_t *  copt,
const char *  filename 

Read filename and set values to global options registry

static int clicon_option_sanity ( clicon_hash_t *  copt)

Check that options are set

char* clicon_option_str ( clicon_handle  h,
const char *  name 

Get a single string option string via handle

[in]nameoption name
Return values
NULLIf option not found, or value of option is NULL
stringvalue of option if found clicon options should be strings.
To differentiate the two reasons why NULL may be returned, use function clicon_option_exists() before the call
int clicon_option_str_set ( clicon_handle  h,
const char *  name,
char *  val 

Set a single string option via handle

[in]nameoption name
[in]valoption value, must be null-terminated string
int clicon_options_main ( clicon_handle  h)

Initialize option values

Set default options, Read config-file, Check that all values are set.

[in]hclicon handle
char* clicon_quiet_mode ( clicon_handle  h)
char* clicon_restconf_dir ( clicon_handle  h)
char* clicon_sock ( clicon_handle  h)

Get information about socket: unix domain filepath, or addr:path

int clicon_sock_family ( clicon_handle  h)
char* clicon_sock_group ( clicon_handle  h)
int clicon_sock_port ( clicon_handle  h)

Get port for backend socket in case of AF_INET or AF_INET6

char* clicon_xmldb_dir ( clicon_handle  h)
char* clicon_yang_dir ( clicon_handle  h)

YANG database specification directory

char* clicon_yang_module_main ( clicon_handle  h)

YANG main module

char* clicon_yang_module_revision ( clicon_handle  h)

YANG revision