C-API: changed formatstr conversion to int to handle -1
Misc formatting
This commit is contained in:
parent
63f048115e
commit
74958d9114
11 changed files with 116 additions and 102 deletions
|
|
@ -98,7 +98,7 @@ enum regexp_mode{
|
|||
* Prototypes
|
||||
*/
|
||||
char *format_int2str(enum format_enum showas);
|
||||
enum format_enum format_str2int(char *str);
|
||||
int format_str2int(char *str);
|
||||
|
||||
/* Debug dump config options */
|
||||
int clicon_option_dump(clixon_handle h, int dblevel);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ typedef int (proc_cb_t)(clixon_handle h,
|
|||
int clixon_proc_socket(clixon_handle h, char **argv, int sock_flags, pid_t *pid, int *sock, int *sockerr);
|
||||
int clixon_proc_socket_close(pid_t pid, int sock);
|
||||
int clixon_process_pid(clixon_handle h, const char *name, pid_t *pid);
|
||||
proc_operation clixon_process_op_str2int(char *opstr);
|
||||
int clixon_process_op_str2int(char *opstr);
|
||||
int clixon_process_argv_get(clixon_handle h, const char *name, char ***argv, int *argc);
|
||||
int clixon_process_register(clixon_handle h, const char *name, const char *descr, const char *netns, uid_t uid, gid_t gid, int fdkeep, proc_cb_t *callback, char **argv, int argc);
|
||||
int clixon_process_delete_all(clixon_handle h);
|
||||
|
|
|
|||
|
|
@ -584,10 +584,11 @@ xmldb_readfile(clixon_handle h,
|
|||
clixon_err(OE_CFG, ENOENT, "No CLICON_XMLDB_FORMAT");
|
||||
goto done;
|
||||
}
|
||||
if ((format = format_str2int(formatstr)) < 0){
|
||||
if ((ret = format_str2int(formatstr)) < 0){
|
||||
clixon_err(OE_XML, 0, "format not found %s", formatstr);
|
||||
goto done;
|
||||
}
|
||||
format = ret;
|
||||
clixon_debug(CLIXON_DBG_DATASTORE, "Reading datastore %s using %s", dbfile, formatstr);
|
||||
/* Parse file into internal XML tree from different formats */
|
||||
if ((fp = fopen(dbfile, "r")) == NULL) {
|
||||
|
|
|
|||
|
|
@ -1703,6 +1703,7 @@ xmldb_write_cache2file(clixon_handle h,
|
|||
int multi;
|
||||
FILE *f = NULL;
|
||||
char *dbfile = NULL;
|
||||
int ret;
|
||||
|
||||
if ((xt = xmldb_cache_get(h, db)) == NULL){
|
||||
clixon_err(OE_XML, 0, "XML cache not found");
|
||||
|
|
@ -1711,10 +1712,11 @@ xmldb_write_cache2file(clixon_handle h,
|
|||
pretty = clicon_option_bool(h, "CLICON_XMLDB_PRETTY");
|
||||
multi = clicon_option_bool(h, "CLICON_XMLDB_MULTI");
|
||||
if ((formatstr = clicon_option_str(h, "CLICON_XMLDB_FORMAT")) != NULL){
|
||||
if ((format = format_str2int(formatstr)) < 0){
|
||||
if ((ret = format_str2int(formatstr)) < 0){
|
||||
clixon_err(OE_XML, 0, "Format %s invalid", formatstr);
|
||||
goto done;
|
||||
}
|
||||
format = ret;
|
||||
}
|
||||
if (xmldb_db2file(h, db, &dbfile) < 0)
|
||||
goto done;
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ format_int2str(enum format_enum showas)
|
|||
* @param[in] str String value
|
||||
* @retval enum Format value (see enum format_enum)
|
||||
*/
|
||||
enum format_enum
|
||||
int
|
||||
format_str2int(char *str)
|
||||
{
|
||||
return clicon_str2int(_FORMATS, str);
|
||||
|
|
|
|||
|
|
@ -477,7 +477,7 @@ static const map_str2int proc_operation_map[] = {
|
|||
/* List of process callback entries XXX move to handle */
|
||||
static process_entry_t *_proc_entry_list = NULL;
|
||||
|
||||
proc_operation
|
||||
int
|
||||
clixon_process_op_str2int(char *opstr)
|
||||
{
|
||||
return clicon_str2int(proc_operation_map, opstr);
|
||||
|
|
|
|||
|
|
@ -571,7 +571,7 @@ clixon_msg_rcv11(int s,
|
|||
int eom = 0;
|
||||
cxobj *xtop = NULL;
|
||||
cxobj *xerr = NULL;
|
||||
sigset_t oldsigset = {0,};
|
||||
sigset_t oldsigset = {{0,},};
|
||||
struct sigaction oldsigaction[32] = {{{0,},},};
|
||||
|
||||
eom = 0;
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ struct xml{
|
|||
#endif
|
||||
int _x_vector_i; /* internal use: xml_child_each */
|
||||
int _x_i; /* internal use for stable sorting:
|
||||
see xml_enumerate and xml_cmp */
|
||||
see xml_enumerate_children and xml_cmp */
|
||||
/*----- next is body/attribute only */
|
||||
cbuf *x_value_cb; /* attribute and body nodes have values (XXX: this consumes
|
||||
memory) cv? */
|
||||
|
|
@ -1152,7 +1152,7 @@ clixon_child_xvec_append(cxobj *xn,
|
|||
return retval;
|
||||
}
|
||||
|
||||
/*! Create new xml node given a name and parent. Free with xml_free().
|
||||
/*! Create new xml node given a name and append it to parent if given. Free with xml_free().
|
||||
*
|
||||
* @param[in] name Name of XML node
|
||||
* @param[in] xp The parent where the new xml node will be appended
|
||||
|
|
@ -1228,6 +1228,7 @@ xml_new_body(char *name,
|
|||
cxobj *body_node;
|
||||
|
||||
if (!name || !parent || !val) {
|
||||
clixon_err(OE_XML, EINVAL, "name, parent or val is NULL");
|
||||
return NULL;
|
||||
}
|
||||
if ((new_node = xml_new(name, parent, CX_ELMNT)) == NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue