openharmony 鸿蒙 capi-ipc-cparcel-h

2026-08-25 浏览 (1)

ipc_cparcel.h

Overview

Provides C APIs for IPC serialization and deserialization.

File to include: <IPCKit/ipc_cparcel.h>

Library: libipc_capi.so

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Related module: OHIPCParcel

Summary

Structs

Nametypedef KeywordDescription
OHIPCParcelOHIPCParcelDefines an IPC serialized object.
OHIPCRemoteProxyOHIPCRemoteProxyDefines an IPC remote proxy object.
OHIPCRemoteStubOHIPCRemoteStubDefines an IPC remote service object.

Function

Nametypedef KeywordDescription
typedef void* (*OH_IPC_MemAllocator)(int32_t len)OH_IPC_MemAllocatorDefines the type of a memory allocation function.
OHIPCParcel* OH_IPCParcel_Create(void)-Creates an OHIPCParcel object, which cannot exceed 204,800 bytes.
void OH_IPCParcel_Destroy(OHIPCParcel *parcel)-Destroys an OHIPCParcel object.
int OH_IPCParcel_GetDataSize(const OHIPCParcel *parcel)-Obtains the size of the data contained in an OHIPCParcel object.
int OH_IPCParcel_GetWritableBytes(const OHIPCParcel *parcel)-Obtains the number of bytes that can be written to an OHIPCParcel object.
int OH_IPCParcel_GetReadableBytes(const OHIPCParcel *parcel)-Obtains the number of bytes that can be read from an OHIPCParcel object.
int OH_IPCParcel_GetReadPosition(const OHIPCParcel *parcel)-Obtains the position where data is read in an OHIPCParcel object.
int OH_IPCParcel_GetWritePosition(const OHIPCParcel *parcel)-Obtains the position where data is written in an OHIPCParcel object.
int OH_IPCParcel_RewindReadPosition(OHIPCParcel *parcel, uint32_t newReadPos)-Resets the position to read data in an OHIPCParcel object.
int OH_IPCParcel_RewindWritePosition(OHIPCParcel *parcel, uint32_t newWritePos)-Resets the position to write data in an OHIPCParcel object.
int OH_IPCParcel_WriteInt8(OHIPCParcel *parcel, int8_t value)-Writes an int8_t value to an OHIPCParcel object.
int OH_IPCParcel_ReadInt8(const OHIPCParcel *parcel, int8_t *value)-Reads an int8_t value from an OHIPCParcel object.
int OH_IPCParcel_WriteInt16(OHIPCParcel *parcel, int16_t value)-Writes an int16_t value to an OHIPCParcel object.
int OH_IPCParcel_ReadInt16(const OHIPCParcel *parcel, int16_t *value)-Reads an int16_t value from an OHIPCParcel object.
int OH_IPCParcel_WriteInt32(OHIPCParcel *parcel, int32_t value)-Writes an int32_t value to an OHIPCParcel object.
int OH_IPCParcel_ReadInt32(const OHIPCParcel *parcel, int32_t *value)-Reads an int32_t value from an OHIPCParcel object.
int OH_IPCParcel_WriteInt64(OHIPCParcel *parcel, int64_t value)-Writes an int64_t value to an OHIPCParcel object.
int OH_IPCParcel_ReadInt64(const OHIPCParcel *parcel, int64_t *value)-Reads an int64_t value from an OHIPCParcel object.
int OH_IPCParcel_WriteUint8(OHIPCParcel *parcel, uint8_t value)-Writes a uint8_t value to an OHIPCParcel object.
int OH_IPCParcel_ReadUint8(const OHIPCParcel *parcel, uint8_t *value)-Reads a uint8_t value from an OHIPCParcel object.
int OH_IPCParcel_WriteUint16(OHIPCParcel *parcel, uint16_t value)-Writes a uint16_t value to an OHIPCParcel object.
int OH_IPCParcel_ReadUint16(const OHIPCParcel *parcel, uint16_t *value)-Reads a uint16_t value from an OHIPCParcel object.
int OH_IPCParcel_WriteUint32(OHIPCParcel *parcel, uint32_t value)-Writes a uint32_t value to an OHIPCParcel object.
int OH_IPCParcel_ReadUint32(const OHIPCParcel *parcel, uint32_t *value)-Reads a uint32_t value from an OHIPCParcel object.
int OH_IPCParcel_WriteUint64(OHIPCParcel *parcel, uint64_t value)-Writes a uint64_t value to an OHIPCParcel object.
int OH_IPCParcel_ReadUint64(const OHIPCParcel *parcel, uint64_t *value)-Reads a uint64_t value from an OHIPCParcel object.
int OH_IPCParcel_WriteFloat(OHIPCParcel *parcel, float value)-Writes a float value to an OHIPCParcel object.
int OH_IPCParcel_ReadFloat(const OHIPCParcel *parcel, float *value)-Reads a float value from an OHIPCParcel object.
int OH_IPCParcel_WriteDouble(OHIPCParcel *parcel, double value)-Writes a double value to an OHIPCParcel object.
int OH_IPCParcel_ReadDouble(const OHIPCParcel *parcel, double *value)-Reads a double value from an OHIPCParcel object.
int OH_IPCParcel_WriteString(OHIPCParcel *parcel, const char *str)-Writes a string including a string terminator to an OHIPCParcel object.
const char* OH_IPCParcel_ReadString(const OHIPCParcel *parcel)-Reads a string from an OHIPCParcel object. You can obtain the length of the string from strlen.
int OH_IPCParcel_Writebuffer(OHIPCParcel *parcel, const uint8_t *buffer, int32_t len)-Writes data of the specified length from the memory to an OHIPCParcel object.
const uint8_t* OH_IPCParcel_ReadBuffer(const OHIPCParcel *parcel, int32_t len)-Reads memory information of the specified length from an OHIPCParcel object.
int OH_IPCParcel_WriteRemoteStub(OHIPCParcel *parcel, const OHIPCRemoteStub *stub)-Writes an OHIPCRemoteStub object to an OHIPCParcel object.
OHIPCRemoteStub* OH_IPCParcel_ReadRemoteStub(const OHIPCParcel *parcel)-Reads the OHIPCRemoteStub object from an OHIPCParcel object.
int OH_IPCParcel_WriteRemoteProxy(OHIPCParcel *parcel, const OHIPCRemoteProxy *proxy)-Writes an OHIPCRemoteProxy object to an OHIPCParcel object.
OHIPCRemoteProxy* OH_IPCParcel_ReadRemoteProxy(const OHIPCParcel *parcel)-Reads the OHIPCRemoteProxy object from an OHIPCParcel object.
int OH_IPCParcel_WriteFileDescriptor(OHIPCParcel *parcel, int32_t fd)-Writes a file descriptor to an OHIPCParcel object.
int OH_IPCParcel_ReadFileDescriptor(const OHIPCParcel *parcel, int32_t *fd)-Reads a file descriptor from an OHIPCParcel object.
int OH_IPCParcel_Append(OHIPCParcel *parcel, const OHIPCParcel *data)-Appends data to an OHIPCParcel object.
int OH_IPCParcel_WriteInterfaceToken(OHIPCParcel *parcel, const char *token)-Writes an interface token to an OHIPCParcel object for interface identity verification.
int OH_IPCParcel_ReadInterfaceToken(const OHIPCParcel *parcel, char **token, int32_t *len, OH_IPC_MemAllocator allocator)-Reads an interface token from an OHIPCParcel object for interface identity verification.

Function Description

OH_IPC_MemAllocator()

typedef void* (*OH_IPC_MemAllocator)(int32_t len)

Description

Defines the type of a memory allocation function.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
int32_t lenLength of the memory to be allocated.

Returns

TypeDescription
void*Returns the address of the memory allocated if the operation is successful; returns NULL otherwise.

OH_IPCParcel_Create()

OHIPCParcel* OH_IPCParcel_Create(void)

Description

Creates an OHIPCParcel object, which cannot exceed 204,800 bytes.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Returns

TypeDescription
OHIPCParcel*Returns the pointer to the OHIPCParcel object created if the operation is successful; returns NULL otherwise.

OH_IPCParcel_Destroy()

void OH_IPCParcel_Destroy(OHIPCParcel *parcel)

Description

Destroys an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object to destroy.

OH_IPCParcel_GetDataSize()

int OH_IPCParcel_GetDataSize(const OHIPCParcel *parcel)

Description

Obtains the size of the data contained in an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.

Returns

TypeDescription
intReturns the data size obtained if the operation is successful; returns -1 if invalid parameters are found.

OH_IPCParcel_GetWritableBytes()

int OH_IPCParcel_GetWritableBytes(const OHIPCParcel *parcel)

Description

Obtains the number of bytes that can be written to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.

Returns

TypeDescription
intReturns the number of bytes that can be written to the OHIPCParcel object; returns -1 if invalid parameters are found.

OH_IPCParcel_GetReadableBytes()

int OH_IPCParcel_GetReadableBytes(const OHIPCParcel *parcel)

Description

Obtains the number of bytes that can be read from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.

Returns

TypeDescription
intReturns the number of bytes that can be read from the OHIPCParcel object.
Returns -1 if invalid parameters are found.

OH_IPCParcel_GetReadPosition()

int OH_IPCParcel_GetReadPosition(const OHIPCParcel *parcel)

Description

Obtains the position where data is read in an OHIPCParcel object.

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.

Returns

TypeDescription
intReturns the current read position obtained if the operation is successful; returns -1 if invalid parameters are found.

OH_IPCParcel_GetWritePosition()

int OH_IPCParcel_GetWritePosition(const OHIPCParcel *parcel)

Description

Obtains the position where data is written in an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.

Returns

TypeDescription
intReturns the current write position obtained if the operation is successful; returns -1 if invalid parameters are found.

OH_IPCParcel_RewindReadPosition()

int OH_IPCParcel_RewindReadPosition(OHIPCParcel *parcel, uint32_t newReadPos)

Description

Resets the position to read data in an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
uint32_t newReadPosNew position to read data. The value ranges from 0 to the current data size.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.

OH_IPCParcel_RewindWritePosition()

int OH_IPCParcel_RewindWritePosition(OHIPCParcel *parcel, uint32_t newWritePos)

Description

Resets the position to write data in an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
uint32_t newWritePosNew position to write data. The value ranges from 0 to the current data size.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.

OH_IPCParcel_WriteInt8()

int OH_IPCParcel_WriteInt8(OHIPCParcel *parcel, int8_t value)

Description

Writes an int8_t value to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
int8_t valueValue to write.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadInt8()

int OH_IPCParcel_ReadInt8(const OHIPCParcel *parcel, int8_t *value)

Description

Reads an int8_t value from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
int8_t *valuePointer to the buffer for holding the read data. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR if the read operation fails.

OH_IPCParcel_WriteInt16()

int OH_IPCParcel_WriteInt16(OHIPCParcel *parcel, int16_t value)

Description

Writes an int16_t value to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
int16_t valueValue to write.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadInt16()

int OH_IPCParcel_ReadInt16(const OHIPCParcel *parcel, int16_t *value)

Description

Reads an int16_t value from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
int16_t *valuePointer to the buffer for holding the read data. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR if the read operation fails.

OH_IPCParcel_WriteInt32()

int OH_IPCParcel_WriteInt32(OHIPCParcel *parcel, int32_t value)

Description

Writes an int32_t value to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
int32_t valueValue to write.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadInt32()

int OH_IPCParcel_ReadInt32(const OHIPCParcel *parcel, int32_t *value)

Description

Reads an int32_t value from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
int32_t *valuePointer to the buffer for holding the read data. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR if the read operation fails.

OH_IPCParcel_WriteInt64()

int OH_IPCParcel_WriteInt64(OHIPCParcel *parcel, int64_t value)

Description

Writes an int64_t value to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
int64_t valueValue to write.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadInt64()

int OH_IPCParcel_ReadInt64(const OHIPCParcel *parcel, int64_t *value)

Description

Reads an int64_t value from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
int64_t *valuePointer to the buffer for holding the read data. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR if the read operation fails.

OH_IPCParcel_WriteUint8()

int OH_IPCParcel_WriteUint8(OHIPCParcel *parcel, uint8_t value)

Description

Writes a uint8_t value to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 26.0.0

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
uint8_t valueValue to write.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadUint8()

int OH_IPCParcel_ReadUint8(const OHIPCParcel *parcel, uint8_t *value)

Description

Reads a uint8_t value from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 26.0.0

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
uint8_t *valuePointer to the buffer for holding the read data. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR if the read operation fails.

OH_IPCParcel_WriteUint16()

int OH_IPCParcel_WriteUint16(OHIPCParcel *parcel, uint16_t value)

Description

Writes a uint16_t value to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 26.0.0

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
uint16_t valueValue to write.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadUint16()

int OH_IPCParcel_ReadUint16(const OHIPCParcel *parcel, uint16_t *value)

Description

Reads a uint16_t value from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 26.0.0

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
uint16_t *valuePointer to the buffer for holding the read data. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR if the read operation fails.

OH_IPCParcel_WriteUint32()

int OH_IPCParcel_WriteUint32(OHIPCParcel *parcel, uint32_t value)

Description

Writes a uint32_t value to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 26.0.0

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
uint32_t valueValue to write.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadUint32()

int OH_IPCParcel_ReadUint32(const OHIPCParcel *parcel, uint32_t *value)

Description

Reads a uint32_t value from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 26.0.0

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
uint32_t *valuePointer to the buffer for holding the read data. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR if the read operation fails.

OH_IPCParcel_WriteUint64()

int OH_IPCParcel_WriteUint64(OHIPCParcel *parcel, uint64_t value)

Description

Writes a uint64_t value to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 26.0.0

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
uint64_t valueValue to write.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadUint64()

int OH_IPCParcel_ReadUint64(const OHIPCParcel *parcel, uint64_t *value)

Description

Reads a uint64_t value from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 26.0.0

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
uint64_t *valuePointer to the buffer for holding the read data. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR if the read operation fails.

OH_IPCParcel_WriteFloat()

int OH_IPCParcel_WriteFloat(OHIPCParcel *parcel, float value)

Description

Writes a float value to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
float valueValue to write.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadFloat()

int OH_IPCParcel_ReadFloat(const OHIPCParcel *parcel, float *value)

Description

Reads a float value from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
float *valuePointer to the buffer for holding the read data. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR if the read operation fails.

OH_IPCParcel_WriteDouble()

int OH_IPCParcel_WriteDouble(OHIPCParcel *parcel, double value)

Description

Writes a double value to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
double valueValue to write.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadDouble()

int OH_IPCParcel_ReadDouble(const OHIPCParcel *parcel, double *value)

Description

Reads a double value from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
double *valuePointer to the buffer for holding the read data. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR if the read operation fails.

OH_IPCParcel_WriteString()

int OH_IPCParcel_WriteString(OHIPCParcel *parcel, const char *str)

Description

Writes a string including a string terminator to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
const char *strPointer to the string to write. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadString()

const char* OH_IPCParcel_ReadString(const OHIPCParcel *parcel)

Description

Reads a string from an OHIPCParcel object. You can obtain the length of the string from strlen.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.

Returns

TypeDescription
const char*Returns the address of the string read if the operation is successful; returns NULL if the operation fails or invalid parameters are found.

OH_IPCParcel_WriteBuffer()

int OH_IPCParcel_WriteBuffer(OHIPCParcel *parcel, const uint8_t *buffer, int32_t len)

Description

Writes data of the specified length from the memory to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
const uint8_t *bufferPointer to the address of the memory information to write.
int32_t lenLength of the data to write.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadBuffer()

const uint8_t* OH_IPCParcel_ReadBuffer(const OHIPCParcel *parcel, int32_t len)

Description

Reads memory information of the specified length from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
int32_t lenLength of the memory to be read.

Returns

TypeDescription
const uint8_t*Returns the memory address read if the operation is successful; returns NULL if invalid parameters are found or len exceeds the readable length of parcel.

OH_IPCParcel_WriteRemoteStub()

int OH_IPCParcel_WriteRemoteStub(OHIPCParcel *parcel, const OHIPCRemoteStub *stub)

Description

Writes an OHIPCRemoteStub object to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
const OHIPCRemoteStub *stubPointer to the OHIPCRemoteStub object to write. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadRemoteStub()

OHIPCRemoteStub* OH_IPCParcel_ReadRemoteStub(const OHIPCParcel *parcel)

Description

Reads the OHIPCRemoteStub object from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.

Returns

TypeDescription
OHIPCRemoteStub*Returns the pointer to the OHIPCRemoteStub object read if the operation is successful; returns NULL otherwise.

OH_IPCParcel_WriteRemoteProxy()

int OH_IPCParcel_WriteRemoteProxy(OHIPCParcel *parcel, const OHIPCRemoteProxy *proxy)

Description

Writes an OHIPCRemoteProxy object to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
const OHIPCRemoteProxy *proxyPointer to the OHIPCRemoteProxy object to write. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadRemoteProxy()

OHIPCRemoteProxy* OH_IPCParcel_ReadRemoteProxy(const OHIPCParcel *parcel)

Description

Reads the OHIPCRemoteProxy object from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.

Returns

TypeDescription
OHIPCRemoteProxy*Returns the pointer to the OHIPCRemoteProxy object created if the operation is successful; returns NULL otherwise.

OH_IPCParcel_WriteFileDescriptor()

int OH_IPCParcel_WriteFileDescriptor(OHIPCParcel *parcel, int32_t fd)

Description

Writes a file descriptor to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
int32_t fdPointer to the file descriptor to write.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadFileDescriptor()

int OH_IPCParcel_ReadFileDescriptor(const OHIPCParcel *parcel, int32_t *fd)

Description

Reads a file descriptor from an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
int32_t *fdPointer to the file descriptor to read. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR if the read operation fails.

OH_IPCParcel_Append()

int OH_IPCParcel_Append(OHIPCParcel *parcel, const OHIPCParcel *data)

Description

Appends data to an OHIPCParcel object.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
const OHIPCParcel *dataPointer to the data to append. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the concatenation fails.

OH_IPCParcel_WriteInterfaceToken()

int OH_IPCParcel_WriteInterfaceToken(OHIPCParcel *parcel, const char *token)

Description

Writes an interface token to an OHIPCParcel object for interface identity verification.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
const char *tokenPointer to the interface token to write. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found.
Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR if the write operation fails.

OH_IPCParcel_ReadInterfaceToken()

int OH_IPCParcel_ReadInterfaceToken(const OHIPCParcel *parcel, char **token, int32_t *len, OH_IPC_MemAllocator allocator)

Description

Reads an interface token from an OHIPCParcel object for interface identity verification.

System capability: SystemCapability.Communication.IPC.Core

Since: 12

Parameters

NameDescription
const OHIPCParcel *parcelPointer to the OHIPCParcel object. It cannot be NULL.
char **tokenDouble pointer to the interface token to read. The memory is allocated by the allocator provided by the user and needs to be released. This pointer cannot be NULL. If an error code is returned, you still need to check whether the memory is empty and release the memory. Otherwise, memory leaks may occur.
int32_t *lenPointer to the length of the interface token read, including the terminator. It cannot be NULL.
OH_IPC_MemAllocator allocatorMemory allocator specified by the user for allocating memory for token. It cannot be NULL.

Returns

TypeDescription
intReturns OH_IPC_ErrorCode#OH_IPC_SUCCESS if the operation is successful.
Returns OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR if invalid parameters are found. Returns OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR if the read operation fails.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-ohipcremoteobject-oh-ipc-messageoption

openharmony 鸿蒙 capi-ipc-error-code-h

openharmony 鸿蒙 capi-ohipcremoteobject-ohipcdeathrecipient

openharmony 鸿蒙 capi-ohipcparcel

openharmony 鸿蒙 errorcode-rpc

openharmony 鸿蒙 capi-ohipcremoteobject

openharmony 鸿蒙 capi-ipc-cskeleton-h

openharmony 鸿蒙 capi-ohipcskeleton

openharmony 鸿蒙 capi-ohipcparcel-ohipcremotestub

openharmony 鸿蒙 capi-ohipcparcel-ohipcremoteproxy

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/q92t2ROU