|
@@ -26,14 +26,30 @@ static int kplugin_sysrepo_init_session(kcontext_t *context);
|
|
static int kplugin_sysrepo_fini_session(kcontext_t *context);
|
|
static int kplugin_sysrepo_fini_session(kcontext_t *context);
|
|
|
|
|
|
|
|
|
|
|
|
+static bool_t free_udata(void *data)
|
|
|
|
+{
|
|
|
|
+ srp_udata_t *udata = (srp_udata_t *)data;
|
|
|
|
+
|
|
|
|
+ assert(udata);
|
|
|
|
+ if (udata->path)
|
|
|
|
+ faux_argv_free(udata->path);
|
|
|
|
+ faux_free(udata);
|
|
|
|
+
|
|
|
|
+ return BOOL_TRUE;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
int kplugin_sysrepo_init(kcontext_t *context)
|
|
int kplugin_sysrepo_init(kcontext_t *context)
|
|
{
|
|
{
|
|
kplugin_t *plugin = NULL;
|
|
kplugin_t *plugin = NULL;
|
|
srp_udata_t *udata = NULL;
|
|
srp_udata_t *udata = NULL;
|
|
|
|
+ kscheme_t *scheme = NULL;
|
|
|
|
|
|
assert(context);
|
|
assert(context);
|
|
plugin = kcontext_plugin(context);
|
|
plugin = kcontext_plugin(context);
|
|
assert(plugin);
|
|
assert(plugin);
|
|
|
|
+ scheme = kcontext_scheme(context);
|
|
|
|
+ assert(scheme);
|
|
|
|
|
|
// Symbols
|
|
// Symbols
|
|
|
|
|
|
@@ -130,7 +146,8 @@ int kplugin_sysrepo_init(kcontext_t *context)
|
|
pline_opts_init(&udata->opts);
|
|
pline_opts_init(&udata->opts);
|
|
pline_opts_parse(kplugin_conf(plugin), &udata->opts);
|
|
pline_opts_parse(kplugin_conf(plugin), &udata->opts);
|
|
|
|
|
|
- kplugin_set_udata(plugin, udata);
|
|
|
|
|
|
+ if (!kscheme_named_udata_new(scheme, SRP_UDATA_NAME, udata, free_udata))
|
|
|
|
+ syslog(LOG_ERR, "Can't create name udata \"%s\"", SRP_UDATA_NAME);
|
|
|
|
|
|
// Logging
|
|
// Logging
|
|
ly_log_options(LY_LOSTORE);
|
|
ly_log_options(LY_LOSTORE);
|
|
@@ -140,19 +157,23 @@ int kplugin_sysrepo_init(kcontext_t *context)
|
|
|
|
|
|
|
|
|
|
int kplugin_sysrepo_fini(kcontext_t *context)
|
|
int kplugin_sysrepo_fini(kcontext_t *context)
|
|
|
|
+{
|
|
|
|
+ context = context;
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+srp_udata_t *srp_udata(kcontext_t *context)
|
|
{
|
|
{
|
|
srp_udata_t *udata = NULL;
|
|
srp_udata_t *udata = NULL;
|
|
|
|
|
|
assert(context);
|
|
assert(context);
|
|
|
|
|
|
- // Free plugin's user-data
|
|
|
|
- udata = (srp_udata_t *)kcontext_udata(context);
|
|
|
|
|
|
+ udata = (srp_udata_t *)kcontext_named_udata(context, SRP_UDATA_NAME);
|
|
assert(udata);
|
|
assert(udata);
|
|
- if (udata->path)
|
|
|
|
- faux_argv_free(udata->path);
|
|
|
|
- faux_free(udata);
|
|
|
|
|
|
|
|
- return 0;
|
|
|
|
|
|
+ return udata;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -162,7 +183,7 @@ pline_opts_t *srp_udata_opts(kcontext_t *context)
|
|
|
|
|
|
assert(context);
|
|
assert(context);
|
|
|
|
|
|
- udata = (srp_udata_t *)kcontext_udata(context);
|
|
|
|
|
|
+ udata = srp_udata(context);
|
|
assert(udata);
|
|
assert(udata);
|
|
|
|
|
|
return &udata->opts;
|
|
return &udata->opts;
|
|
@@ -175,7 +196,7 @@ faux_argv_t *srp_udata_path(kcontext_t *context)
|
|
|
|
|
|
assert(context);
|
|
assert(context);
|
|
|
|
|
|
- udata = (srp_udata_t *)kcontext_udata(context);
|
|
|
|
|
|
+ udata = srp_udata(context);
|
|
assert(udata);
|
|
assert(udata);
|
|
|
|
|
|
return udata->path;
|
|
return udata->path;
|
|
@@ -188,7 +209,7 @@ void srp_udata_set_path(kcontext_t *context, faux_argv_t *path)
|
|
|
|
|
|
assert(context);
|
|
assert(context);
|
|
|
|
|
|
- udata = (srp_udata_t *)kcontext_udata(context);
|
|
|
|
|
|
+ udata = srp_udata(context);
|
|
assert(udata);
|
|
assert(udata);
|
|
if (udata->path)
|
|
if (udata->path)
|
|
faux_argv_free(udata->path);
|
|
faux_argv_free(udata->path);
|
|
@@ -202,7 +223,7 @@ sr_session_ctx_t *srp_udata_sr_sess(kcontext_t *context)
|
|
|
|
|
|
assert(context);
|
|
assert(context);
|
|
|
|
|
|
- udata = (srp_udata_t *)kcontext_udata(context);
|
|
|
|
|
|
+ udata = srp_udata(context);
|
|
assert(udata);
|
|
assert(udata);
|
|
|
|
|
|
return udata->sr_sess;
|
|
return udata->sr_sess;
|
|
@@ -216,7 +237,7 @@ static int kplugin_sysrepo_init_session(kcontext_t *context)
|
|
|
|
|
|
assert(context);
|
|
assert(context);
|
|
|
|
|
|
- udata = (srp_udata_t *)kcontext_udata(context);
|
|
|
|
|
|
+ udata = srp_udata(context);
|
|
assert(udata);
|
|
assert(udata);
|
|
|
|
|
|
// Remote user name
|
|
// Remote user name
|
|
@@ -255,7 +276,7 @@ static int kplugin_sysrepo_fini_session(kcontext_t *context)
|
|
|
|
|
|
assert(context);
|
|
assert(context);
|
|
|
|
|
|
- udata = (srp_udata_t *)kcontext_udata(context);
|
|
|
|
|
|
+ udata = srp_udata(context);
|
|
assert(udata);
|
|
assert(udata);
|
|
|
|
|
|
// Remote user name
|
|
// Remote user name
|