1 /*
2 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3 *
4 * HDF is dual licensed: you can use it either under the terms of
5 * the GPL, or the BSD license, at your option.
6 * See the LICENSE file in the root of this repository for complete details.
7 */
8
9 #include "hdf_io_service.h"
10
HdfIoServiceBind(const char * serviceName)11 struct HdfIoService *HdfIoServiceBind(const char *serviceName)
12 {
13 return HdfIoServiceAdapterObtain(serviceName);
14 }
15
HdfIoServiceRecycle(struct HdfIoService * service)16 void HdfIoServiceRecycle(struct HdfIoService *service)
17 {
18 HdfIoServiceAdapterRecycle(service);
19 }
20
HdfIoServicePublish(const char * serviceName,uint32_t mode)21 struct HdfIoService *HdfIoServicePublish(const char *serviceName, uint32_t mode)
22 {
23 if (HdfIoServiceAdapterPublish != NULL) {
24 return HdfIoServiceAdapterPublish(serviceName, mode);
25 }
26
27 return NULL;
28 }
29
HdfIoServiceRemove(struct HdfIoService * service)30 void HdfIoServiceRemove(struct HdfIoService *service)
31 {
32 if (HdfIoServiceAdapterRemove != NULL) {
33 HdfIoServiceAdapterRemove(service);
34 }
35 }
36
HdfIoServiceDispatch(struct HdfIoService * ioService,int cmdId,struct HdfSBuf * data,struct HdfSBuf * reply)37 int32_t HdfIoServiceDispatch(struct HdfIoService *ioService, int cmdId, struct HdfSBuf *data, struct HdfSBuf *reply)
38 {
39 if (ioService == NULL || ioService->dispatcher == NULL || ioService->dispatcher->Dispatch == NULL) {
40 return HDF_ERR_INVALID_OBJECT;
41 }
42
43 return ioService->dispatcher->Dispatch(&ioService->object, cmdId, data, reply);
44 }
45