diff --git a/apps/restconf/clixon_restconf.h b/apps/restconf/clixon_restconf.h index 2c23f61d..2f7861e2 100644 --- a/apps/restconf/clixon_restconf.h +++ b/apps/restconf/clixon_restconf.h @@ -63,8 +63,8 @@ int restconf_terminate(clicon_handle h); int restconf_insert_attributes(cxobj *xdata, cvec *qvec); int restconf_main_extension_cb(clicon_handle h, yang_stmt *yext, yang_stmt *ys); /* also in restconf_handle.h */ -char *restconf_param_get(clicon_handle h, char *param); -int restconf_param_set(clicon_handle h, char *param, char *val); +char *restconf_param_get(clicon_handle h, const char *param); +int restconf_param_set(clicon_handle h, const char *param, char *val); #endif /* _CLIXON_RESTCONF_H_ */ diff --git a/apps/restconf/restconf_api.h b/apps/restconf/restconf_api.h index 21ab31da..ad23b765 100644 --- a/apps/restconf/restconf_api.h +++ b/apps/restconf/restconf_api.h @@ -42,9 +42,9 @@ * Prototypes */ #if defined(__GNUC__) && __GNUC__ >= 3 -int restconf_reply_header(void *req, char *name, char *vfmt, ...) __attribute__ ((format (printf, 3, 4))); +int restconf_reply_header(void *req, char *name, const char *vfmt, ...) __attribute__ ((format (printf, 3, 4))); #else -int restconf_reply_header(FCGX_Request *req, char *name, char *vfmt, ...); +int restconf_reply_header(FCGX_Request *req, char *name, const char *vfmt, ...); #endif int restconf_reply_send(void *req, int code, cbuf *cb); diff --git a/apps/restconf/restconf_api_fcgi.c b/apps/restconf/restconf_api_fcgi.c index e7369bea..595b3f35 100644 --- a/apps/restconf/restconf_api_fcgi.c +++ b/apps/restconf/restconf_api_fcgi.c @@ -90,7 +90,7 @@ restconf_reply_body_start(void *req0) int restconf_reply_header(void *req0, char *name, - char *vfmt, + const char *vfmt, ...) { FCGX_Request *req = (FCGX_Request *)req0; diff --git a/apps/restconf/restconf_handle.c b/apps/restconf/restconf_handle.c index 53348b67..84474f68 100644 --- a/apps/restconf/restconf_handle.c +++ b/apps/restconf/restconf_handle.c @@ -119,7 +119,7 @@ restconf_handle_exit(clicon_handle h) */ char * restconf_param_get(clicon_handle h, - char *param) + const char *param) { struct restconf_handle *rh = handle(h); @@ -138,7 +138,7 @@ restconf_param_get(clicon_handle h, */ int restconf_param_set(clicon_handle h, - char *param, + const char *param, char *val) { struct restconf_handle *rh = handle(h); diff --git a/apps/restconf/restconf_handle.h b/apps/restconf/restconf_handle.h index 464dd50d..7d286099 100644 --- a/apps/restconf/restconf_handle.h +++ b/apps/restconf/restconf_handle.h @@ -44,8 +44,8 @@ */ clicon_handle restconf_handle_init(void); int restconf_handle_exit(clicon_handle h); -char *restconf_param_get(clicon_handle h, char *param); -int restconf_param_set(clicon_handle h, char *param, char *val); +char *restconf_param_get(clicon_handle h, const char *param); +int restconf_param_set(clicon_handle h, const char *param, char *val); int restconf_param_del_all(clicon_handle h); #endif /* _RESTCONF_HANDLE_H_ */ diff --git a/example/main/example_backend.c b/example/main/example_backend.c index 1f76e373..6d00bf6d 100644 --- a/example/main/example_backend.c +++ b/example/main/example_backend.c @@ -538,7 +538,7 @@ static const map_str2str namespace_map[] = { */ int example_upgrade(clicon_handle h, - char *db, + const char *db, cxobj *xt, modstate_diff_t *msd) { diff --git a/lib/clixon/clixon_data.h b/lib/clixon/clixon_data.h index fe619d24..154af55b 100644 --- a/lib/clixon/clixon_data.h +++ b/lib/clixon/clixon_data.h @@ -55,9 +55,9 @@ typedef struct { /* * Prototypes */ -int clicon_data_get(clicon_handle h, char *id, char **val); -int clicon_data_set(clicon_handle h, char *id, char *val); -int clicon_data_del(clicon_handle h, char *name); +int clicon_data_get(clicon_handle h, const char *name, char **val); +int clicon_data_set(clicon_handle h, const char *name, char *val); +int clicon_data_del(clicon_handle h, const char *name); yang_stmt * clicon_dbspec_yang(clicon_handle h); int clicon_dbspec_yang_set(clicon_handle h, yang_stmt *ys); diff --git a/lib/clixon/clixon_datastore.h b/lib/clixon/clixon_datastore.h index 56515de7..478280b8 100644 --- a/lib/clixon/clixon_datastore.h +++ b/lib/clixon/clixon_datastore.h @@ -52,7 +52,7 @@ int xmldb_disconnect(clicon_handle h); /* in clixon_datastore_read.[ch] */ int xmldb_get(clicon_handle h, const char *db, cvec *nsc, char *xpath, cxobj **xtop); int xmldb_get0(clicon_handle h, const char *db, - cvec *nsc, char *xpath, + cvec *nsc, const char *xpath, int copy, cxobj **xtop, modstate_diff_t *msd); int xmldb_get0_clear(clicon_handle h, cxobj *x); int xmldb_get0_free(clicon_handle h, cxobj **xp); diff --git a/lib/clixon/clixon_err.h b/lib/clixon/clixon_err.h index 16a9a010..4e58eeb7 100644 --- a/lib/clixon/clixon_err.h +++ b/lib/clixon/clixon_err.h @@ -94,9 +94,9 @@ extern char clicon_err_reason[ERR_STRLEN]; */ int clicon_err_reset(void); #if defined(__GNUC__) && __GNUC__ >= 3 -int clicon_err_fn(const char *fn, const int line, int category, int err, char *format, ...) __attribute__ ((format (printf, 5, 6))); +int clicon_err_fn(const char *fn, const int line, int category, int err, const char *format, ...) __attribute__ ((format (printf, 5, 6))); #else -int clicon_err_fn(const char *fn, const int line, int category, int err, char *format, ...); +int clicon_err_fn(const char *fn, const int line, int category, int err, const char *format, ...); #endif char *clicon_strerror(int err); void *clicon_err_save(void); diff --git a/lib/clixon/clixon_log.h b/lib/clixon/clixon_log.h index 21d87b5b..53b2cfe2 100644 --- a/lib/clixon/clixon_log.h +++ b/lib/clixon/clixon_log.h @@ -55,11 +55,11 @@ int clicon_log_opt(char c); int clicon_log_file(char *filename); int clicon_get_logflags(void); #if defined(__GNUC__) && __GNUC__ >= 3 -int clicon_log(int level, char *format, ...) __attribute__ ((format (printf, 2, 3))); -int clicon_debug(int dbglevel, char *format, ...) __attribute__ ((format (printf, 2, 3))); +int clicon_log(int level, const char *format, ...) __attribute__ ((format (printf, 2, 3))); +int clicon_debug(int dbglevel, const char *format, ...) __attribute__ ((format (printf, 2, 3))); #else -int clicon_log(int level, char *format, ...); -int clicon_debug(int dbglevel, char *format, ...); +int clicon_log(int level, const char *format, ...); +int clicon_debug(int dbglevel, const char *format, ...); #endif int clicon_debug_init(int dbglevel, FILE *f); int clicon_debug_get(void); diff --git a/lib/clixon/clixon_options.h b/lib/clixon/clixon_options.h index 9628d9f2..03a5d2c6 100644 --- a/lib/clixon/clixon_options.h +++ b/lib/clixon/clixon_options.h @@ -125,7 +125,7 @@ enum regexp_mode{ int clicon_option_dump(clicon_handle h, int dblevel); /* Add a clicon options overriding file setting */ -int clicon_option_add(clicon_handle h, char *name, char *value); +int clicon_option_add(clicon_handle h, const char *name, char *value); /* Initialize options: set defaults, read config-file, etc */ int clicon_options_main(clicon_handle h); diff --git a/lib/clixon/clixon_path.h b/lib/clixon/clixon_path.h index ea665af2..08b717fc 100644 --- a/lib/clixon/clixon_path.h +++ b/lib/clixon/clixon_path.h @@ -85,13 +85,13 @@ int api_path2xml(char *api_path, yang_stmt *yspec, cxobj *xtop, cxobj **xpathp, yang_stmt **ypathp, cxobj **xerr); int xml2api_path_1(cxobj *x, cbuf *cb); #if defined(__GNUC__) && __GNUC__ >= 3 -int clixon_xml_find_api_path(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, char *format, +int clixon_xml_find_api_path(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, const char *format, ...) __attribute__ ((format (printf, 5, 6)));; -int clixon_xml_find_instance_id(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, char *format, +int clixon_xml_find_instance_id(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, const char *format, ...) __attribute__ ((format (printf, 5, 6)));; #else -int clixon_xml_find_api_path(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, char *format, ...); -int clixon_xml_find_instance_id(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, char *format, ...); +int clixon_xml_find_api_path(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, const char *format, ...); +int clixon_xml_find_instance_id(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, const char *format, ...); #endif #endif /* _CLIXON_PATH_H_ */ diff --git a/lib/clixon/clixon_plugin.h b/lib/clixon/clixon_plugin.h index a3a29412..2873553d 100644 --- a/lib/clixon/clixon_plugin.h +++ b/lib/clixon/clixon_plugin.h @@ -179,7 +179,7 @@ typedef char *(cli_prompthook_t)(clicon_handle, char *mode); * @retval -1 Error * @retval 0 OK */ -typedef int (datastore_upgrade_t)(clicon_handle h, char *db, cxobj *xt, modstate_diff_t *msd); +typedef int (datastore_upgrade_t)(clicon_handle h, const char *db, cxobj *xt, modstate_diff_t *msd); /*! Startup status for use in startup-callback * Note that for STARTUP_ERR and _INVALID, running runs in failsafe mode @@ -284,11 +284,11 @@ clixon_plugin *clixon_plugin_each(clicon_handle h, clixon_plugin *cpprev); clixon_plugin *clixon_plugin_each_revert(clicon_handle h, clixon_plugin *cpprev, int nr); -clixon_plugin *clixon_plugin_find(clicon_handle h, char *name); +clixon_plugin *clixon_plugin_find(clicon_handle h, const char *name); -int clixon_plugins_load(clicon_handle h, char *function, char *dir, char *regexp); +int clixon_plugins_load(clicon_handle h, const char *function, const char *dir, const char *regexp); -int clixon_pseudo_plugin(clicon_handle h, char *name, clixon_plugin **cpp); +int clixon_pseudo_plugin(clicon_handle h, const char *name, clixon_plugin **cpp); int clixon_plugin_start_one(clixon_plugin *cp, clicon_handle h); int clixon_plugin_start_all(clicon_handle h); @@ -302,16 +302,16 @@ int clixon_plugin_auth_all(clicon_handle h, void *arg); int clixon_plugin_extension_one(clixon_plugin *cp, clicon_handle h, yang_stmt *yext, yang_stmt *ys); int clixon_plugin_extension_all(clicon_handle h, yang_stmt *yext, yang_stmt *ys); -int clixon_plugin_datastore_upgrade_one(clixon_plugin *cp, clicon_handle h, char *db, cxobj *xt, modstate_diff_t *msd); -int clixon_plugin_datastore_upgrade_all(clicon_handle h, char *db, cxobj *xt, modstate_diff_t *msd); +int clixon_plugin_datastore_upgrade_one(clixon_plugin *cp, clicon_handle h, const char *db, cxobj *xt, modstate_diff_t *msd); +int clixon_plugin_datastore_upgrade_all(clicon_handle h, const char *db, cxobj *xt, modstate_diff_t *msd); /* rpc callback API */ -int rpc_callback_register(clicon_handle h, clicon_rpc_cb cb, void *arg, char *ns, char *name); +int rpc_callback_register(clicon_handle h, clicon_rpc_cb cb, void *arg, const char *ns, const char *name); int rpc_callback_delete_all(clicon_handle h); int rpc_callback_call(clicon_handle h, cxobj *xe, cbuf *cbret, void *arg); /* upgrade callback API */ -int upgrade_callback_reg_fn(clicon_handle h, clicon_upgrade_cb cb, const char *strfn, char *ns, void *arg); +int upgrade_callback_reg_fn(clicon_handle h, clicon_upgrade_cb cb, const char *strfn, const char *ns, void *arg); int upgrade_callback_delete_all(clicon_handle h); int upgrade_callback_call(clicon_handle h, cxobj *xt, char *ns, uint16_t op, uint32_t from, uint32_t to, cbuf *cbret); diff --git a/lib/clixon/clixon_proto.h b/lib/clixon/clixon_proto.h index bb91f4d3..2d08a7ef 100644 --- a/lib/clixon/clixon_proto.h +++ b/lib/clixon/clixon_proto.h @@ -2,7 +2,9 @@ * ***** BEGIN LICENSE BLOCK ***** - Copyright (C) 2009-2019 Olof Hagsand and Benny Holmgren + Copyright (C) 2009-2016 Olof Hagsand and Benny Holmgren + Copyright (C) 2017-2019 Olof Hagsand + Copyright (C) 2020 Olof Hagsand and Rubicon Communications, LLC(Netgate) This file is part of CLIXON. @@ -63,9 +65,9 @@ char *format_int2str(enum format_enum showas); enum format_enum format_str2int(char *str); #if defined(__GNUC__) && __GNUC__ >= 3 -struct clicon_msg *clicon_msg_encode(uint32_t id, char *format, ...) __attribute__ ((format (printf, 2, 3))); +struct clicon_msg *clicon_msg_encode(uint32_t id, const char *format, ...) __attribute__ ((format (printf, 2, 3))); #else -struct clicon_msg *clicon_msg_encode(uint32_t id, char *format, ...); +struct clicon_msg *clicon_msg_encode(uint32_t id, const char *format, ...); #endif int clicon_msg_decode(struct clicon_msg *msg, yang_stmt *yspec, uint32_t *id, cxobj **xml, cxobj **xerr); diff --git a/lib/clixon/clixon_string.h b/lib/clixon/clixon_string.h index 9613ecf4..c35c2e5a 100644 --- a/lib/clixon/clixon_string.h +++ b/lib/clixon/clixon_string.h @@ -92,11 +92,11 @@ char *clicon_strjoin (int argc, char **argv, char *delim); int clixon_strsplit(char *nodeid, const int delim, char **prefix, char **id); int str2cvec(char *string, char delim1, char delim2, cvec **cvp); #if defined(__GNUC__) && __GNUC__ >= 3 -int uri_percent_encode(char **encp, char *fmt, ...) __attribute__ ((format (printf, 2, 3))); -int xml_chardata_encode(char **escp, char *fmt, ... ) __attribute__ ((format (printf, 2, 3))); +int uri_percent_encode(char **encp, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); +int xml_chardata_encode(char **escp, const char *fmt, ... ) __attribute__ ((format (printf, 2, 3))); #else -int uri_percent_encode(char **encp, char *str, ...); -int xml_chardata_encode(char **escp, char *fmt, ...); +int uri_percent_encode(char **encp, const char *str, ...); +int xml_chardata_encode(char **escp, const char *fmt, ...); #endif int xml_chardata_cbuf_append(cbuf *cb, char *str); int uri_percent_decode(char *enc, char **str); diff --git a/lib/clixon/clixon_xml.h b/lib/clixon/clixon_xml.h index 822a6d35..685b0eb9 100644 --- a/lib/clixon/clixon_xml.h +++ b/lib/clixon/clixon_xml.h @@ -213,12 +213,12 @@ int xml_enumerate_get(cxobj *x); char *xml_body(cxobj *xn); cxobj *xml_body_get(cxobj *xn); -char *xml_find_type_value(cxobj *xn_parent, char *prefix, - char *name, enum cxobj_type type); -cxobj *xml_find_type(cxobj *xn_parent, char *prefix, char *name, enum cxobj_type type); -char *xml_find_value(cxobj *xn_parent, char *name); -char *xml_find_body(cxobj *xn, char *name); -cxobj *xml_find_body_obj(cxobj *xt, char *name, char *val); +char *xml_find_type_value(cxobj *xn_parent, const char *prefix, + const char *name, enum cxobj_type type); +cxobj *xml_find_type(cxobj *xn_parent, const char *prefix, const char *name, enum cxobj_type type); +char *xml_find_value(cxobj *xn_parent, const char *name); +char *xml_find_body(cxobj *xn, const char *name); +cxobj *xml_find_body_obj(cxobj *xt, const char *name, char *val); int xml_free(cxobj *xn); @@ -239,9 +239,9 @@ int xml_operation(char *opstr, enum operation_type *op); char *xml_operation2str(enum operation_type op); int xml_attr_insert2val(char *instr, enum insert_type *ins); #if defined(__GNUC__) && __GNUC__ >= 3 -int clicon_log_xml(int level, cxobj *x, char *format, ...) __attribute__ ((format (printf, 3, 4))); +int clicon_log_xml(int level, cxobj *x, const char *format, ...) __attribute__ ((format (printf, 3, 4))); #else -int clicon_log_xml(int level, cxobj *x, char *format, ...); +int clicon_log_xml(int level, cxobj *x, const char *format, ...); #endif #ifdef XML_EXPLICIT_INDEX int xml_search_index_p(cxobj *x); diff --git a/lib/clixon/clixon_xpath.h b/lib/clixon/clixon_xpath.h index 02594837..f842de4d 100644 --- a/lib/clixon/clixon_xpath.h +++ b/lib/clixon/clixon_xpath.h @@ -129,17 +129,17 @@ int xpath_tree2cbuf(xpath_tree *xs, cbuf *xpathcb); int xpath_tree_eq(xpath_tree *xt1, xpath_tree *xt2, xpath_tree ***vec, size_t *len); xpath_tree *xpath_tree_traverse(xpath_tree *xt, ...); int xpath_tree_free(xpath_tree *xs); -int xpath_parse(char *xpath, xpath_tree **xptree); -int xpath_vec_ctx(cxobj *xcur, cvec *nsc, char *xpath, int localonly, xp_ctx **xrp); +int xpath_parse(const char *xpath, xpath_tree **xptree); +int xpath_vec_ctx(cxobj *xcur, cvec *nsc, const char *xpath, int localonly, xp_ctx **xrp); #if defined(__GNUC__) && __GNUC__ >= 3 -int xpath_vec_bool(cxobj *xcur, cvec *nsc, char *xpformat, ...) __attribute__ ((format (printf, 3, 4))); -int xpath_vec_flag(cxobj *xcur, cvec *nsc, char *xpformat, uint16_t flags, +int xpath_vec_bool(cxobj *xcur, cvec *nsc, const char *xpformat, ...) __attribute__ ((format (printf, 3, 4))); +int xpath_vec_flag(cxobj *xcur, cvec *nsc, const char *xpformat, uint16_t flags, cxobj ***vec, int *veclen, ...) __attribute__ ((format (printf, 3, 7))); #else -int xpath_vec_bool(cxobj *xcur, cvec *nsc, char *xpformat, ...); -int xpath_vec_flag(cxobj *xcur, cvec *nsc, char *xpformat, uint16_t flags, +int xpath_vec_bool(cxobj *xcur, cvec *nsc, const char *xpformat, ...); +int xpath_vec_flag(cxobj *xcur, cvec *nsc, const char *xpformat, uint16_t flags, cxobj ***vec, int *veclen, ...); #endif @@ -149,15 +149,15 @@ int xpath_vec_flag(cxobj *xcur, cvec *nsc, char *xpformat, uint16_t flags, * If you do not know what a namespace context is, see README.md#xml-and-xpath */ #if defined(__GNUC__) && __GNUC__ >= 3 -cxobj *xpath_first(cxobj *xcur, cvec *nsc, char *xpformat, ...) __attribute__ ((format (printf, 3, 4))); -cxobj *xpath_first_localonly(cxobj *xcur, char *xpformat, ...) __attribute__ ((format (printf, 2, 3))); -int xpath_vec(cxobj *xcur, cvec *nsc, char *xpformat, cxobj ***vec, size_t *veclen, ...) __attribute__ ((format (printf, 3, 6))); +cxobj *xpath_first(cxobj *xcur, cvec *nsc, const char *xpformat, ...) __attribute__ ((format (printf, 3, 4))); +cxobj *xpath_first_localonly(cxobj *xcur, const char *xpformat, ...) __attribute__ ((format (printf, 2, 3))); +int xpath_vec(cxobj *xcur, cvec *nsc, const char *xpformat, cxobj ***vec, size_t *veclen, ...) __attribute__ ((format (printf, 3, 6))); #else -cxobj *xpath_first(cxobj *xcur, cvec *nsc, char *xpformat, ...); -cxobj *xpath_first_localonly(cxobj *xcur, char *xpformat, ...); -int xpath_vec(cxobj *xcur, cvec *nsc, char *xpformat, cxobj ***vec, size_t *veclen, ...); +cxobj *xpath_first(cxobj *xcur, cvec *nsc, const char *xpformat, ...); +cxobj *xpath_first_localonly(cxobj *xcur, const char *xpformat, ...); +int xpath_vec(cxobj *xcur, cvec *nsc, const char *xpformat, cxobj ***vec, size_t *veclen, ...); #endif -int xpath2canonical(char *xpath0, cvec *nsc0, yang_stmt *yspec, char **xpath1, cvec **nsc1); +int xpath2canonical(const char *xpath0, cvec *nsc0, yang_stmt *yspec, char **xpath1, cvec **nsc1); #endif /* _CLIXON_XPATH_H */ diff --git a/lib/src/clixon_data.c b/lib/src/clixon_data.c index fe6aaaaf..325079da 100644 --- a/lib/src/clixon_data.c +++ b/lib/src/clixon_data.c @@ -88,7 +88,7 @@ */ int clicon_data_get(clicon_handle h, - char *name, + const char *name, char **val) { clicon_hash_t *cdat = clicon_data(h); @@ -110,7 +110,7 @@ clicon_data_get(clicon_handle h, */ int clicon_data_set(clicon_handle h, - char *name, + const char *name, char *val) { clicon_hash_t *cdat = clicon_data(h); @@ -127,7 +127,7 @@ clicon_data_set(clicon_handle h, */ int clicon_data_del(clicon_handle h, - char *name) + const char *name) { clicon_hash_t *cdat = clicon_data(h); diff --git a/lib/src/clixon_datastore_read.c b/lib/src/clixon_datastore_read.c index 2df896d6..d52752c0 100644 --- a/lib/src/clixon_datastore_read.c +++ b/lib/src/clixon_datastore_read.c @@ -427,7 +427,7 @@ static int xmldb_get_nocache(clicon_handle h, const char *db, cvec *nsc, - char *xpath, + const char *xpath, cxobj **xtop, modstate_diff_t *msdiff) { @@ -511,7 +511,7 @@ static int xmldb_get_cache(clicon_handle h, const char *db, cvec *nsc, - char *xpath, + const char *xpath, cxobj **xtop, modstate_diff_t *msdiff) { @@ -612,7 +612,7 @@ static int xmldb_get_zerocopy(clicon_handle h, const char *db, cvec *nsc, - char *xpath, + const char *xpath, cxobj **xtop, modstate_diff_t *msdiff) { @@ -726,7 +726,7 @@ int xmldb_get0(clicon_handle h, const char *db, cvec *nsc, - char *xpath, + const char *xpath, int copy, cxobj **xret, modstate_diff_t *msdiff) diff --git a/lib/src/clixon_err.c b/lib/src/clixon_err.c index a99bdc0a..d0901900 100644 --- a/lib/src/clixon_err.c +++ b/lib/src/clixon_err.c @@ -149,7 +149,7 @@ int clicon_err_fn(const char *fn, const int line, int category, int suberr, - char *format, ...) + const char *format, ...) { va_list args; int len; diff --git a/lib/src/clixon_log.c b/lib/src/clixon_log.c index c3a752e0..793ac5d7 100644 --- a/lib/src/clixon_log.c +++ b/lib/src/clixon_log.c @@ -257,8 +257,8 @@ clicon_log_str(int level, * @see clicon_log_init and clicon_log_str */ int -clicon_log(int level, - char *format, ...) +clicon_log(int level, + const char *format, ...) { va_list args; int len; @@ -338,8 +338,8 @@ clicon_debug_get(void) * @param[in] format Message to print as argv. */ int -clicon_debug(int dbglevel, - char *format, ...) +clicon_debug(int dbglevel, + const char *format, ...) { va_list args; int len; diff --git a/lib/src/clixon_options.c b/lib/src/clixon_options.c index 8e69ad4a..0380f26b 100644 --- a/lib/src/clixon_options.c +++ b/lib/src/clixon_options.c @@ -327,7 +327,7 @@ parse_configfile(clicon_handle h, */ int clicon_option_add(clicon_handle h, - char *name, + const char *name, char *value) { int retval = -1; diff --git a/lib/src/clixon_path.c b/lib/src/clixon_path.c index ff17384c..b1aaa671 100644 --- a/lib/src/clixon_path.c +++ b/lib/src/clixon_path.c @@ -1529,7 +1529,7 @@ clixon_xml_find_api_path(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, - char *format, + const char *format, ...) { int retval = -1; @@ -1623,7 +1623,7 @@ clixon_xml_find_instance_id(cxobj *xt, yang_stmt *yt, cxobj ***xvec, int *xlen, - char *format, + const char *format, ...) { int retval = -1; diff --git a/lib/src/clixon_plugin.c b/lib/src/clixon_plugin.c index 13d24b83..dabbb935 100644 --- a/lib/src/clixon_plugin.c +++ b/lib/src/clixon_plugin.c @@ -159,7 +159,7 @@ clixon_plugin_each_revert(clicon_handle h, */ clixon_plugin * clixon_plugin_find(clicon_handle h, - char *name) + const char *name) { int i; clixon_plugin *cp = NULL; @@ -185,8 +185,8 @@ clixon_plugin_find(clicon_handle h, */ static int plugin_load_one(clicon_handle h, - char *file, - char *function, + char *file, /* note modified */ + const char *function, int dlflags, clixon_plugin **cpp) { @@ -267,9 +267,9 @@ plugin_load_one(clicon_handle h, */ int clixon_plugins_load(clicon_handle h, - char *function, - char *dir, - char *regexp) + const char *function, + const char *dir, + const char *regexp) { int retval = -1; int ndp; @@ -316,7 +316,7 @@ done: */ int clixon_pseudo_plugin(clicon_handle h, - char *name, + const char *name, clixon_plugin **cpp) { int retval = -1; @@ -595,7 +595,7 @@ clixon_plugin_extension_all(clicon_handle h, int clixon_plugin_datastore_upgrade_one(clixon_plugin *cp, clicon_handle h, - char *db, + const char *db, cxobj *xt, modstate_diff_t *msd) @@ -628,7 +628,7 @@ clixon_plugin_datastore_upgrade_one(clixon_plugin *cp, */ int clixon_plugin_datastore_upgrade_all(clicon_handle h, - char *db, + const char *db, cxobj *xt, modstate_diff_t *msd) { @@ -682,8 +682,8 @@ int rpc_callback_register(clicon_handle h, clicon_rpc_cb cb, void *arg, - char *ns, - char *name) + const char *ns, + const char *name) { rpc_callback_t *rc = NULL; @@ -813,7 +813,7 @@ int upgrade_callback_reg_fn(clicon_handle h, clicon_upgrade_cb cb, const char *fnstr, - char *ns, + const char *ns, void *arg) { upgrade_callback_t *uc; diff --git a/lib/src/clixon_proto.c b/lib/src/clixon_proto.c index 84082877..71aceb63 100644 --- a/lib/src/clixon_proto.c +++ b/lib/src/clixon_proto.c @@ -136,7 +136,7 @@ format_str2int(char *str) */ struct clicon_msg * clicon_msg_encode(uint32_t id, - char *format, ...) + const char *format, ...) { va_list args; uint32_t xmllen; diff --git a/lib/src/clixon_string.c b/lib/src/clixon_string.c index 4bf9b021..66d8d563 100644 --- a/lib/src/clixon_string.c +++ b/lib/src/clixon_string.c @@ -244,7 +244,7 @@ uri_unreserved(unsigned char in) */ int uri_percent_encode(char **encp, - char *fmt, ...) + const char *fmt, ...) { int retval = -1; char *str = NULL; /* Expanded format string w stdarg */ @@ -370,8 +370,8 @@ uri_percent_decode(char *enc, * @see xml_chardata_cbuf_append for a specialized version */ int -xml_chardata_encode(char **escp, - char *fmt,...) +xml_chardata_encode(char **escp, + const char *fmt,...) { int retval = -1; char *str = NULL; /* Expanded format string w stdarg */ diff --git a/lib/src/clixon_xml.c b/lib/src/clixon_xml.c index d7915da0..712b32d0 100644 --- a/lib/src/clixon_xml.c +++ b/lib/src/clixon_xml.c @@ -1661,8 +1661,8 @@ xml_body_get(cxobj *xt) */ char * xml_find_type_value(cxobj *xt, - char *prefix, - char *name, + const char *prefix, + const char *name, enum cxobj_type type) { cxobj *x; @@ -1691,8 +1691,8 @@ xml_find_type_value(cxobj *xt, */ cxobj * xml_find_type(cxobj *xt, - char *prefix, - char *name, + const char *prefix, + const char *name, enum cxobj_type type) { cxobj *x = NULL; @@ -1730,8 +1730,8 @@ xml_find_type(cxobj *xt, * return x_value */ char * -xml_find_value(cxobj *xt, - char *name) +xml_find_value(cxobj *xt, + const char *name) { cxobj *x = NULL; @@ -1755,8 +1755,8 @@ xml_find_value(cxobj *xt, * x_name=name return x_value */ char * -xml_find_body(cxobj *xt, - char *name) +xml_find_body(cxobj *xt, + const char *name) { cxobj *x=NULL; @@ -1783,9 +1783,9 @@ xml_find_body(cxobj *xt, * return x */ cxobj * -xml_find_body_obj(cxobj *xt, - char *name, - char *val) +xml_find_body_obj(cxobj *xt, + const char *name, + char *val) { cxobj *x = NULL; char *bstr; @@ -2315,9 +2315,9 @@ xml_attr_insert2val(char *instr, * @param[in] format Message to print as argv. */ int -clicon_log_xml(int level, - cxobj *x, - char *format, ...) +clicon_log_xml(int level, + cxobj *x, + const char *format, ...) { va_list args; int len; diff --git a/lib/src/clixon_xpath.c b/lib/src/clixon_xpath.c index 70a72361..15bf7260 100644 --- a/lib/src/clixon_xpath.c +++ b/lib/src/clixon_xpath.c @@ -483,7 +483,7 @@ xpath_tree_free(xpath_tree *xs) * @see xpath_tree_free */ int -xpath_parse(char *xpath, +xpath_parse(const char *xpath, xpath_tree **xptree) { int retval = -1; @@ -541,11 +541,11 @@ xpath_parse(char *xpath, * @endcode */ int -xpath_vec_ctx(cxobj *xcur, - cvec *nsc, - char *xpath, - int localonly, - xp_ctx **xrp) +xpath_vec_ctx(cxobj *xcur, + cvec *nsc, + const char *xpath, + int localonly, + xp_ctx **xrp) { int retval = -1; xpath_tree *xptree = NULL; @@ -591,9 +591,9 @@ xpath_vec_ctx(cxobj *xcur, * @see also xpath_vec. */ cxobj * -xpath_first(cxobj *xcur, - cvec *nsc, - char *xpformat, +xpath_first(cxobj *xcur, + cvec *nsc, + const char *xpformat, ...) { cxobj *cx = NULL; @@ -651,8 +651,8 @@ xpath_first(cxobj *xcur, * @see also xpath_first. */ cxobj * -xpath_first_localonly(cxobj *xcur, - char *xpformat, +xpath_first_localonly(cxobj *xcur, + const char *xpformat, ...) { cxobj *cx = NULL; @@ -712,11 +712,11 @@ xpath_first_localonly(cxobj *xcur, * @endcode */ int -xpath_vec(cxobj *xcur, - cvec *nsc, - char *xpformat, - cxobj ***vec, - size_t *veclen, +xpath_vec(cxobj *xcur, + cvec *nsc, + const char *xpformat, + cxobj ***vec, + size_t *veclen, ...) { int retval = -1; @@ -784,12 +784,12 @@ xpath_vec(cxobj *xcur, * @see also xpath_vec This is a specialized version. */ int -xpath_vec_flag(cxobj *xcur, - cvec *nsc, - char *xpformat, - uint16_t flags, - cxobj ***vec, - int *veclen, +xpath_vec_flag(cxobj *xcur, + cvec *nsc, + const char *xpformat, + uint16_t flags, + cxobj ***vec, + int *veclen, ...) { int retval = -1; @@ -847,9 +847,9 @@ xpath_vec_flag(cxobj *xcur, * @retval -1 Error */ int -xpath_vec_bool(cxobj *xcur, - cvec *nsc, - char *xpformat, +xpath_vec_bool(cxobj *xcur, + cvec *nsc, + const char *xpformat, ...) { int retval = -1; @@ -970,7 +970,7 @@ traverse_canonical(xpath_tree *xs, * @endcode */ int -xpath2canonical(char *xpath0, +xpath2canonical(const char *xpath0, cvec *nsc0, yang_stmt *yspec, char **xpath1, diff --git a/lib/src/clixon_xpath_parse.h b/lib/src/clixon_xpath_parse.h index 8fa28d0f..cb29133d 100644 --- a/lib/src/clixon_xpath_parse.h +++ b/lib/src/clixon_xpath_parse.h @@ -43,7 +43,7 @@ struct clixon_xpath_yacc{ const char *xpy_name; /* Name of syntax (for error string) */ int xpy_linenum; /* Number of \n in parsed buffer */ - char *xpy_parse_string; /* original (copy of) parse string */ + const char *xpy_parse_string; /* original (copy of) parse string */ void *xpy_lexbuf; /* internal parse buffer from lex */ xpath_tree *xpy_top; }; diff --git a/test/test_c++.sh b/test/test_c++.sh index df6c141a..248e3a89 100755 --- a/test/test_c++.sh +++ b/test/test_c++.sh @@ -50,7 +50,7 @@ netconf_client_rpc(clicon_handle h, char *ns; /* get namespace from rpc name, return back in each output parameter */ - if ((ns = xml_find_type_value(xe, NULL, (char*)"xmlns", CX_ATTR)) == NULL){ + if ((ns = xml_find_type_value(xe, NULL, "xmlns", CX_ATTR)) == NULL){ clicon_err(OE_XML, ENOENT, "No namespace given in rpc %s", xml_name(xe)); goto done; } @@ -94,10 +94,10 @@ clixon_plugin_init(clicon_handle h) api_initialization(); - clicon_debug(1, (char*)"%s netconf", __FUNCTION__); + clicon_debug(1, "%s netconf", __FUNCTION__); /* Register local netconf rpc client (note not backend rpc client) */ if (rpc_callback_register(h, netconf_client_rpc, NULL, - (char*)"urn:example:clixon", (char*)"client-rpc") < 0) + "urn:example:clixon", "client-rpc") < 0) return NULL; return &api; }