summaryrefslogtreecommitdiffstats
path: root/src/service/Service.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/service/Service.c')
-rw-r--r--src/service/Service.c343
1 files changed, 0 insertions, 343 deletions
diff --git a/src/service/Service.c b/src/service/Service.c
deleted file mode 100644
index 8ab8591..0000000
--- a/src/service/Service.c
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Service.c
- *
- * Copyright (C) 2012 Red Hat, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- * Based on Syslog_Service.c from sblim-cmpi-syslog written by
- * R Sharada <sharada@in.ibm.com>, Copyright (c) IBM Corp. 2003, 2009
- *
- * Red Hat Author(s): Vitezslav Crhonek <vcrhonek@redhat.com>
- *
- */
-
-#include <cmpidt.h>
-#include <cmpift.h>
-#include <cmpimacs.h>
-#include <string.h>
-
-#include "ServiceUtils.h"
-#include "util/serviceutil.h"
-#define LOCALCLASSNAME "Linux_Service"
-
-static const CMPIBroker *_broker;
-
-#ifdef CMPI_VER_100
-#define ServiceSetInstance ServiceModifyInstance
-#endif
-
-
-
-/* Instance MI Cleanup */
-CMPIStatus
-ServiceCleanup(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- CMPIBoolean terminate)
-{
- CMReturn(CMPI_RC_OK);
-}
-
-
-
-/* Instance MI Functions */
-CMPIStatus
-ServiceEnumInstanceNames(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *ref)
-{
- CMPIObjectPath *op = NULL;
- CMPIStatus st = {CMPI_RC_OK,NULL};
- void *enumhdl = NULL;
- Service servicebuf;
- int i = 0;
- SList *slist = NULL;
-
- service_debug(stderr,"ServiceEnumInstanceNames() called, ctx %p, result %p, op %p", ctx, rslt, ref);
-
- memset(&servicebuf, '\0', sizeof(Service));
-
- slist = Service_Find_All();
-
- for(i = 0; i < slist->cnt; i++)
- {
- enumhdl = Service_Begin_Enum(slist->name[i]);
- if (enumhdl == NULL)
- {
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not begin service names enumeration");
- Service_Free_SList(slist);
- return st;
- }
- else
- {
- if (Service_Next_Enum(enumhdl, &servicebuf, slist->name[i]))
- {
- // build object path from buffer
- op = makeServicePath(_broker,
- LOCALCLASSNAME,
- CMGetCharPtr(CMGetNameSpace(ref, NULL)),
- &servicebuf);
- if (CMIsNullObject(op))
- {
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not construct object path");
- goto label;
- }
- CMReturnObjectPath(rslt, op);
- }
-label:
- CMReturnDone(rslt);
- Service_End_Enum(enumhdl);
- }
- }
-
- Service_Free_SList(slist);
- return st;
-}
-
-
-
-CMPIStatus
-ServiceEnumInstances(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *ref,
- const char **properties)
-{
- CMPIInstance *in = NULL;
- CMPIStatus st = {CMPI_RC_OK,NULL};
- void *enumhdl = NULL;
- Service servicebuf;
- int i = 0;
- SList *slist = NULL;
-
- service_debug(stderr,"ServiceEnumInstances() called, ctx %p, result %p, op %p", ctx, rslt, ref);
-
- memset(&servicebuf, '\0', sizeof(Service));
-
- slist = Service_Find_All();
-
- for(i = 0; i < slist->cnt; i++)
- {
- enumhdl = Service_Begin_Enum(slist->name[i]);
- if (enumhdl == NULL)
- {
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not begin service instances enumeration");
- Service_Free_SList(slist);
- return st;
- }
- else
- {
- if (Service_Next_Enum(enumhdl, &servicebuf, slist->name[i]))
- {
- // build object instance from buffer
- in = makeServiceInstance(_broker,
- LOCALCLASSNAME,
- CMGetCharPtr(CMGetNameSpace(ref, NULL)),
- &servicebuf);
- if (CMIsNullObject(in))
- {
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not construct instance");
- goto label;
- }
- CMReturnInstance(rslt, in);
- }
-label:
- CMReturnDone(rslt);
- Service_End_Enum(enumhdl);
- }
- }
-
- Service_Free_SList(slist);
- return st;
-}
-
-
-
-CMPIStatus
-ServiceGetInstance(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *cop,
- const char **properties)
-{
- CMPIInstance *in = NULL;
- CMPIStatus st = {CMPI_RC_OK,NULL};
- CMPIData nd;
- void *enumhdl = NULL;
- Service servicebuf;
- char *name = NULL;
- int i = 0;
-
- memset(&servicebuf, '\0', sizeof(Service));
-
- service_debug(stderr,"ServiceGetInstance() called, ctx %p, result %p, op %p", ctx, rslt, cop);
-
- nd = CMGetKey(cop, "Name", &st);
- name = CMGetCharPtr(nd.value.string);
-
- service_debug(stderr,"Name = %s", name);
-
- enumhdl = Service_Begin_Enum(name);
- if (enumhdl == NULL) {
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not begin service instances enumeration");
- return st;
- } else {
- if (Service_Next_Enum(enumhdl,&servicebuf, name)) {
- if (strncmp(name, servicebuf.svName, 6)==0) {
- // build object instance from buffer
- in = makeServiceInstance(_broker,
- LOCALCLASSNAME,
- CMGetCharPtr(CMGetNameSpace(cop,NULL)),
- &servicebuf);
- if (CMIsNullObject(in)) {
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not construct instance");
- goto label;
- }
- CMReturnInstance(rslt,in);
- }
- }
-label:
- CMReturnDone(rslt);
- Service_End_Enum(enumhdl);
- }
-
- return st;
-}
-
-
-
-/* Instance MI functions - not supported */
-CMPIStatus
-ServiceCreateInstance(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *cop,
- const CMPIInstance *ci)
-{
- CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
-}
-
-
-
-CMPIStatus
-ServiceSetInstance(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *cop,
- const CMPIInstance *ci,
- const char **properties)
-{
- CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
-}
-
-
-
-CMPIStatus
-ServiceDeleteInstance(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *cop)
-{
- CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
-}
-
-CMPIStatus
-ServiceExecQuery(CMPIInstanceMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *cop,
- const char *lang,
- const char *query)
-{
- CMReturn(CMPI_RC_ERR_NOT_SUPPORTED);
-}
-
-
-
-/* Method MI Cleanup */
-CMPIStatus
-ServiceMethodCleanup(CMPIMethodMI *mi,
- const CMPIContext *ctx,
- CMPIBoolean terminate)
-{
- CMReturn(CMPI_RC_OK);
-}
-
-
-
-/* Method MI Functions */
-CMPIStatus
-ServiceInvokeMethod(CMPIMethodMI *mi,
- const CMPIContext *ctx,
- const CMPIResult *rslt,
- const CMPIObjectPath *cop,
- const char *method,
- const CMPIArgs *in,
- CMPIArgs *out)
-{
- CMPIStatus st = {CMPI_RC_OK,NULL};
- CMPIData dt;
- char typebuf[1000];
- char *name = NULL;
-
- memset(&typebuf, '\0', sizeof(typebuf));
-
- dt = CMGetKey(cop, "Name", &st);
- if (st.rc != CMPI_RC_OK)
- {
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not get instance name");
-
- }
- else
- {
- name = CMGetCharPtr(dt.value.string);
- if (Service_Operation(name, method, typebuf, sizeof(typebuf)))
- {
- /* If the function returns 1, then failure */
- CMSetStatusWithChars(_broker, &st, CMPI_RC_ERR_FAILED,
- "Could not get instance type");
- }
- else
- {
- CMReturnData(rslt, typebuf, CMPI_chars);
- CMReturnDone(rslt);
- }
- }
-
- return st;
-}
-
-
-
-/* Instance MI Factory */
-CMInstanceMIStub(Service,
- Service,
- _broker,
- CMNoHook);
-
-
-
-/* Method MI Factory */
-CMMethodMIStub(Service,
- Service,
- _broker,
- CMNoHook);