1 /* 2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup HDF_IPC_ADAPTER 18 * @{ 19 * 20 * @brief Provides capabilities for the user-mode driver to use inter-process communication (IPC). 21 * 22 * The driver is implemented in C, while IPC is implemented in C++. 23 * This module implements IPC APIs in C based on the IPC over C++. 24 * It provides APIs for registering a service object, registering a function for processing 25 * the death notification of a service, and implementing the dump mechanism. 26 * 27 * @since 1.0 28 */ 29 30 /** 31 * @file hdf_sbuf_ipc.h 32 * 33 * @brief Provides APIs for converting between the <b>MessageParcel</b> objects (in C++) 34 * and <b>HdfSBuf</b> objects (in C). 35 * 36 * @since 1.0 37 */ 38 39 #ifndef HDF_SBUF_IPC_IMPL_H 40 #define HDF_SBUF_IPC_IMPL_H 41 42 #include <message_parcel.h> 43 #include "hdf_sbuf.h" 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif /* __cplusplus */ 48 49 /** 50 * @brief Converts a <b>MessageParcel</b> object into an <b>HdfSBuf</b> object. 51 * 52 * @param parcel Indicates the pointer to the <b>MessageParcel</b> object to convert. 53 * @return Returns the <b>HdfSBuf</b> object obtained. 54 */ 55 struct HdfSBuf *ParcelToSbuf(OHOS::MessageParcel *parcel); 56 57 /** 58 * @brief Converts an <b>HdfSBuf</b> object into a <b>MessageParcel</b> object. 59 * 60 * @param sbuf Indicates the pointer to the <b>HdfSBuf</b> object to convert. 61 * @param parcel Indicates the pointer to the <b>MessageParcel</b> object obtained. 62 * @return Returns <b>HDF_SUCCESS</b> if the operation is successful; otherwise, the operation fails. 63 */ 64 int32_t SbufToParcel(struct HdfSBuf *sbuf, OHOS::MessageParcel **parcel); 65 66 #ifdef __cplusplus 67 } 68 #endif /* __cplusplus */ 69 #endif // HDF_SBUF_IPC_IMPL_H 70