/* * Copyright (C) 2013 Red Hat, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * Authors: Roman Rakus */ #include #include #include #include // callback functions typedef bool (*IMInstGather) (CMPIInstance *old, CMPIInstance *new, void *data); typedef bool (*IMFilterChecker) (const CMPISelectExp *filter); typedef bool (*IMEventSpawner) (void *data); // Indication types typedef enum { IM_IND_INST, // for instance indications IM_IND_PROCESS, // for process indications } IMIndType; /* * Definition of IMFilter * Linked list of all filters */ typedef struct _IMFilter { struct _IMFilter *next; CMPISelectExp *select_exp; } IMFilter; typedef struct _IMFilters { IMFilter *first; } IMFilters; /* * Linked list of polled enumeration pairs of instances * enumerations are converted to arrays */ typedef struct _IMEnumerationPair { struct _IMEnumerationPair *next; CMPIObjectPath *op; CMPIArray *prev_enum; CMPIArray *this_enum; } IMEnumerationPair; typedef struct _IMEnumerations { IMEnumerationPair *first; } IMEnumerations; typedef struct _IMManager { // callback functions IMEventSpawner spawner; IMInstGather gather; IMFilterChecker f_checker; // filters container IMFilters *filters; // others IMIndType type; bool running; bool polling; CMPIBroker *broker; CMPIContext *context; // TODO have to move as parameters IMEnumerations *enums; } IMManager; typedef enum { IM_ERR_OK, IM_ERR_GATHER, // bad or null gather callback IM_ERR_FILTER_CHECKER, // bad or null filter checker callback IM_ERR_SPAWNER, // bad or null spawner callback IM_ERR_MALLOC, // memory allocation error IM_ERR_FILTER, // bad or null filter IM_ERR_MANAGER, // bad or null manager IM_ERR_BROKER, // bad or null broker IM_ERR_CONTEXT, // bad or null context IM_ERR_NOT_FOUND, // specified data were not found } IMError; // Create manager with given properties and callbacks. // gather may not be specified if you want to use polling // Return newly created IMManager or NULL and appropiate IMError is set IMManager* im_create_manager(IMInstGather gather, IMFilterChecker f_checker, bool polling, IMEventSpawner spawner, IMIndType type, CMPIBroker *broker, CMPIContext *ctx, IMError *err); // Destroy given manager. // Return true when ok or false and IMError is set bool im_destroy_manager(IMManager *manager, IMError *err); // Call verification callback on given manager and filter. // Return true if filter is verified. False if not. // IMError will be set to to other value than IM_ERR_OK // if verification failed bool im_verify_filter(const IMManager *manager, const CMPISelectExp *filter, IMError *err); // add given filter to manager. // Return true when all is ok, otherwise false and IMError // is as appropriate. bool im_add_filter(IMManager *manager, CMPISelectExp *filter, IMError *err); // Remove given filter from manager. // Return true when removed, false if not and appropriate IMError is set. bool im_remove_filter(IMManager *manager, const CMPISelectExp *filter, IMError *err); // Start indications. // Return true when correctly started, false if not and // appropriate IMError is set, bool im_start_ind(IMManager *manager, IMError *err); // Stop indications. // Return true when correctly stopped, false if not and // appropriate IMError is set, bool im_stop_ind(IMManager *manager, IMError *err);