Removed argc/argv parameters from ca_start plugin API function. You may need to change signatures of your startup in your plugins
This commit is contained in:
parent
cdbce7645e
commit
60cb87f998
12 changed files with 72 additions and 96 deletions
|
|
@ -98,12 +98,9 @@ typedef int (*clicon_upgrade_cb)(
|
|||
* Backend see config_plugin.c
|
||||
*/
|
||||
|
||||
/* Called when backend started with cmd-line arguments from daemon call.
|
||||
* Call plugin start functions with argc/argv multiple arguments.
|
||||
* Typically the argc/argv are the ones appearing after "--", eg
|
||||
* clicon_cli -f /etc/clicon.xml -- -a myopt
|
||||
/* Called when application started (eg after daemon call).
|
||||
*/
|
||||
typedef int (plgstart_t)(clicon_handle, int, char **); /* Plugin start */
|
||||
typedef int (plgstart_t)(clicon_handle); /* Plugin start */
|
||||
|
||||
/* Called just before plugin unloaded.
|
||||
*/
|
||||
|
|
@ -141,7 +138,7 @@ typedef char *(cli_prompthook_t)(clicon_handle, char *mode);
|
|||
* Note that for STARTUP_ERR and _INVALID, running runs in failsafe mode
|
||||
* and startup contains the erroneous or invalid database.
|
||||
* The user should repair the startup and
|
||||
* (1) restart he backend
|
||||
* (1) restart the backend
|
||||
* (2) copy startup to candidate and commit.
|
||||
*/
|
||||
enum startup_status{
|
||||
|
|
@ -237,7 +234,7 @@ clixon_plugin *clixon_plugin_find(clicon_handle h, char *name);
|
|||
|
||||
int clixon_plugins_load(clicon_handle h, char *function, char *dir, char *regexp);
|
||||
|
||||
int clixon_plugin_start(clicon_handle h, int argc, char **argv);
|
||||
int clixon_plugin_start(clicon_handle h);
|
||||
|
||||
int clixon_plugin_exit(clicon_handle h);
|
||||
|
||||
|
|
|
|||
|
|
@ -1076,7 +1076,7 @@ clicon_argv_get(clicon_handle h,
|
|||
if (argv){
|
||||
if ((p = hash_value(cdat, "argv", NULL)) == NULL)
|
||||
return -1;
|
||||
*argv = *(char***)p;
|
||||
*argv = (char**)p;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1099,15 +1099,18 @@ clicon_argv_set(clicon_handle h,
|
|||
int retval = -1;
|
||||
clicon_hash_t *cdat = clicon_data(h);
|
||||
char **argvv = NULL;
|
||||
|
||||
size_t len;
|
||||
|
||||
/* add space for null-termination and argv[0] program name */
|
||||
if ((argvv = calloc(argc+2, sizeof(char*))) == NULL){
|
||||
len = argc+2;
|
||||
if ((argvv = calloc(len, sizeof(char*))) == NULL){
|
||||
clicon_err(OE_UNIX, errno, "calloc");
|
||||
goto done;
|
||||
}
|
||||
memcpy(argvv+1, argv, argc*sizeof(char*));
|
||||
argvv[0] = prgm;
|
||||
if (hash_add(cdat, "argv", &argvv, sizeof(argvv))==NULL)
|
||||
/* Note the value is the argv vector (which is copied) */
|
||||
if (hash_add(cdat, "argv", argvv, len*sizeof(char*))==NULL)
|
||||
goto done;
|
||||
argc += 1;
|
||||
if (hash_add(cdat, "argc", &argc, sizeof(argc))==NULL)
|
||||
|
|
|
|||
|
|
@ -295,21 +295,11 @@ done:
|
|||
|
||||
/*! Call plugin_start in all plugins
|
||||
* @param[in] h Clicon handle
|
||||
* @param[in] argc
|
||||
* @param[in] argv
|
||||
* Call plugin start functions (if defined) with argc/argv multiple
|
||||
* arguments.
|
||||
* Typically the argc/argv are the ones appearing after "--", eg
|
||||
* clicon_cli -f /etc/clicon.xml -- -a myopt
|
||||
* In the example above argc=3 and
|
||||
* argv[0]: clicon_cli
|
||||
* argv[1]: -a
|
||||
* argv[2]: myopt
|
||||
* Call plugin start functions (if defined)
|
||||
* @note Start functions used to have argc/argv. Use clicon_argv_get() instead
|
||||
*/
|
||||
int
|
||||
clixon_plugin_start(clicon_handle h,
|
||||
int argc,
|
||||
char **argv)
|
||||
clixon_plugin_start(clicon_handle h)
|
||||
{
|
||||
clixon_plugin *cp;
|
||||
int i;
|
||||
|
|
@ -319,8 +309,7 @@ clixon_plugin_start(clicon_handle h,
|
|||
cp = &_clixon_plugins[i];
|
||||
if ((startfn = cp->cp_api.ca_start) == NULL)
|
||||
continue;
|
||||
// optind = 0;
|
||||
if (startfn(h, argc, argv) < 0) {
|
||||
if (startfn(h) < 0) {
|
||||
clicon_debug(1, "plugin_start() failed");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue