diff options
author | jackiechen1985 <xiaobo.chen@tieto.com> | 2019-05-19 12:35:28 +0800 |
---|---|---|
committer | Junfeng Wang <drenfong.wang@intel.com> | 2019-05-22 04:37:38 +0000 |
commit | ce1a0daa15be4c3b7a3df64ea57ad231664e700f (patch) | |
tree | fdb1fac57156ebc6e12e8ce9cd7942a8f4023c03 /src/plugins/sc_model.c | |
parent | aeb421c7219178ac464e8a2e62b35772a08a2c1c (diff) |
Introduce a new registration mechanism to sweetcomb.
Sweetcomb plugins register for various [initialization] events
by placing structures and __attribute__((constructor)) functions
into the library. When sysrepo plugin is initializing, the framework
walks constructor-generated singly-linked structure lists, calls the
indicated functions.
Change-Id: I0cb078391f2662e4f6dd08c1a383173f203adf2a
Signed-off-by: jackiechen1985 <xiaobo.chen@tieto.com>
Diffstat (limited to 'src/plugins/sc_model.c')
-rw-r--r-- | src/plugins/sc_model.c | 82 |
1 files changed, 0 insertions, 82 deletions
diff --git a/src/plugins/sc_model.c b/src/plugins/sc_model.c deleted file mode 100644 index d9bf92b..0000000 --- a/src/plugins/sc_model.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2018 PANTHEON.tech. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "sc_model.h" - -#include <sysrepo/plugins.h> - -static int -subscribe(sr_session_ctx_t *ds, sr_subscription_ctx_t **sub, - const xpath_t *xpath) -{ - int rc; - - switch (xpath->method) { - case MODULE: - rc = sr_module_change_subscribe(ds, xpath->xpath, xpath->cb.mcb, - xpath->private_ctx, xpath->priority, - xpath->opts, sub); - break; - - case XPATH: - rc = sr_subtree_change_subscribe(ds, xpath->xpath, xpath->cb.scb, - xpath->private_ctx, - xpath->priority, xpath->opts, sub); - break; - - case GETITEM: - rc = sr_dp_get_items_subscribe(ds, xpath->xpath, xpath->cb.gcb, - xpath->private_ctx, xpath->opts, - sub); - break; - - case RPC: - rc = sr_rpc_subscribe(ds, xpath->xpath, xpath->cb.rcb, - xpath->private_ctx, xpath->opts, sub); - break; - - default: - SRP_LOG_ERR("Unknown method %d", xpath->method); - return SR_ERR_NOT_FOUND; - } - - if (SR_ERR_OK != rc) { - SRP_LOG_ERR("Error subscribing to %s", xpath->xpath); - return rc; - } - - SRP_LOG_INF("Subscribed to xpath: %s", xpath->xpath); - - return SR_ERR_OK; -} - -int -model_register(plugin_main_t* plugin_main, const xpath_t *xpaths, size_t size) -{ - int rc = 0; - uint32_t i = 0; - - ARG_CHECK(-1, plugin_main); - - for (i = 0; i < size; i++) { - rc = subscribe(plugin_main->session, &plugin_main->subscription, - &xpaths[i]); - if (SR_ERR_OK != rc) - SRP_LOG_ERR("Subscription failed for xpath: %s", xpaths[i].xpath); - } - - return 0; -} |