1# OHIPCParcel 2 3 4## Overview 5 6Provides C interfaces for IPC serialization and deserialization. 7 8**System capability**: SystemCapability.Communication.IPC.Core 9 10**Since**: 12 11 12 13## Summary 14 15 16### Files 17 18| Name| Description| 19| -------- | -------- | 20| [ipc_cparcel.h](ipc__cparcel_8h.md) | Provides C interfaces for IPC serialization and deserialization.| 21 22 23### Types 24 25| Name| Description| 26| -------- | -------- | 27| typedef void \*(\* [OH_IPC_MemAllocator](#oh_ipc_memallocator)) (int32_t len) | Defines the type of a memory allocation function.| 28 29 30### Functions 31 32| Name| Description| 33| -------- | -------- | 34| OHIPCParcel \* [OH_IPCParcel_Create](#oh_ipcparcel_create) (void) | Creates an **OHIPCParcel** object, which cannot exceed 204,800 bytes.| 35| void [OH_IPCParcel_Destroy](#oh_ipcparcel_destroy) (OHIPCParcel \*parcel) | Destroys an **OHIPCParcel** object.| 36| int [OH_IPCParcel_GetDataSize](#oh_ipcparcel_getdatasize) (const OHIPCParcel \*parcel) | Obtains the size of the data contained in an **OHIPCParcel** object.| 37| int [OH_IPCParcel_GetWritableBytes](#oh_ipcparcel_getwritablebytes) (const OHIPCParcel \*parcel) | Obtains the number of bytes that can be written to an **OHIPCParcel** object.| 38| int [OH_IPCParcel_GetReadableBytes](#oh_ipcparcel_getreadablebytes) (const OHIPCParcel \*parcel) | Obtains the number of bytes that can be read from an **OHIPCParcel** object.| 39| int [OH_IPCParcel_GetReadPosition](#oh_ipcparcel_getreadposition) (const OHIPCParcel \*parcel) | Obtains the position where data is read in an **OHIPCParcel** object.| 40| int [OH_IPCParcel_GetWritePosition](#oh_ipcparcel_getwriteposition) (const OHIPCParcel \*parcel) | Obtains the position where data is written in an **OHIPCParcel** object.| 41| int [OH_IPCParcel_RewindReadPosition](#oh_ipcparcel_rewindreadposition) (OHIPCParcel \*parcel, uint32_t newReadPos) | Resets the position to read data in an **OHIPCParcel** object.| 42| int [OH_IPCParcel_RewindWritePosition](#oh_ipcparcel_rewindwriteposition) (OHIPCParcel \*parcel, uint32_t newWritePos) | Resets the position to write data in an **OHIPCParcel** object.| 43| int [OH_IPCParcel_WriteInt8](#oh_ipcparcel_writeint8) (OHIPCParcel \*parcel, int8_t value) | Writes an int8_t value to an **OHIPCParcel** object.| 44| int [OH_IPCParcel_ReadInt8](#oh_ipcparcel_readint8) (const OHIPCParcel \*parcel, int8_t \*value) | Reads an int8_t value from an **OHIPCParcel** object.| 45| int [OH_IPCParcel_WriteInt16](#oh_ipcparcel_writeint16) (OHIPCParcel \*parcel, int16_t value) | Writes an int16_t value to an **OHIPCParcel** object.| 46| int [OH_IPCParcel_ReadInt16](#oh_ipcparcel_readint16) (const OHIPCParcel \*parcel, int16_t \*value) | Reads an int16_t value from an **OHIPCParcel** object.| 47| int [OH_IPCParcel_WriteInt32](#oh_ipcparcel_writeint32) (OHIPCParcel \*parcel, int32_t value) | Writes an int32_t value to an **OHIPCParcel** object.| 48| int [OH_IPCParcel_ReadInt32](#oh_ipcparcel_readint32) (const OHIPCParcel \*parcel, int32_t \*value) | Reads an int32_t value from an **OHIPCParcel** object.| 49| int [OH_IPCParcel_WriteInt64](#oh_ipcparcel_writeint64) (OHIPCParcel \*parcel, int64_t value) | Writes an int64_t value to an **OHIPCParcel** object.| 50| int [OH_IPCParcel_ReadInt64](#oh_ipcparcel_readint64) (const OHIPCParcel \*parcel, int64_t \*value) | Reads an int64_t value from an **OHIPCParcel** object.| 51| int [OH_IPCParcel_WriteFloat](#oh_ipcparcel_writefloat) (OHIPCParcel \*parcel, float value) | Writes a float value to an **OHIPCParcel** object.| 52| int [OH_IPCParcel_ReadFloat](#oh_ipcparcel_readfloat) (const OHIPCParcel \*parcel, float \*value) | Reads a float value from an **OHIPCParcel** object.| 53| int [OH_IPCParcel_WriteDouble](#oh_ipcparcel_writedouble) (OHIPCParcel \*parcel, double value) | Writes a double value to an **OHIPCParcel** object.| 54| int [OH_IPCParcel_ReadDouble](#oh_ipcparcel_readdouble) (const OHIPCParcel \*parcel, double \*value) | Reads a double value from an **OHIPCParcel** object.| 55| int [OH_IPCParcel_WriteString](#oh_ipcparcel_writestring) (OHIPCParcel \*parcel, const char \*str) | Writes a string including a string terminator to an **OHIPCParcel** object.| 56| const char \* [OH_IPCParcel_ReadString](#oh_ipcparcel_readstring) (const OHIPCParcel \*parcel) | Reads a string from an **OHIPCParcel** object. You can obtain the length of the string from **strlen**.| 57| int [OH_IPCParcel_WriteBuffer](#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.| 58| const uint8_t \* [OH_IPCParcel_ReadBuffer](#oh_ipcparcel_readbuffer) (const OHIPCParcel \*parcel, int32_t len) | Reads memory information of the specified length from an **OHIPCParcel** object.| 59| int [OH_IPCParcel_WriteRemoteStub](#oh_ipcparcel_writeremotestub) (OHIPCParcel \*parcel, const OHIPCRemoteStub \*stub) | Writes an **OHIPCRemoteStub** object to an **OHIPCParcel** object.| 60| OHIPCRemoteStub \* [OH_IPCParcel_ReadRemoteStub](#oh_ipcparcel_readremotestub) (const OHIPCParcel \*parcel) | Reads the **OHIPCRemoteStub** object from an **OHIPCParcel** object.| 61| int [OH_IPCParcel_WriteRemoteProxy](#oh_ipcparcel_writeremoteproxy) (OHIPCParcel \*parcel, const OHIPCRemoteProxy \*proxy) | Writes an **OHIPCRemoteProxy** object to an **OHIPCParcel** object.| 62| OHIPCRemoteProxy \* [OH_IPCParcel_ReadRemoteProxy](#oh_ipcparcel_readremoteproxy) (const OHIPCParcel \*parcel) | Reads the **OHIPCRemoteProxy** object from an **OHIPCParcel** object.| 63| int [OH_IPCParcel_WriteFileDescriptor](#oh_ipcparcel_writefiledescriptor) (OHIPCParcel \*parcel, int32_t fd) | Writes a file descriptor to an **OHIPCParcel** object.| 64| int [OH_IPCParcel_ReadFileDescriptor](#oh_ipcparcel_readfiledescriptor) (const OHIPCParcel \*parcel, int32_t \*fd) | Reads a file descriptor from an **OHIPCParcel** object.| 65| int [OH_IPCParcel_Append](#oh_ipcparcel_append) (OHIPCParcel \*parcel, const OHIPCParcel \*data) | Appends data to an **OHIPCParcel** object.| 66| int [OH_IPCParcel_WriteInterfaceToken](#oh_ipcparcel_writeinterfacetoken) (OHIPCParcel \*parcel, const char \*token) | Writes an interface token to an **OHIPCParcel** object for interface identity verification.| 67| int [OH_IPCParcel_ReadInterfaceToken](#oh_ipcparcel_readinterfacetoken) (const OHIPCParcel \*parcel, char \*\*token, int32_t \*len, [OH_IPC_MemAllocator](#oh_ipc_memallocator) allocator) | Reads an interface token from an **OHIPCParcel** object for interface identity verification.| 68 69 70## Type Description 71 72 73### OH_IPC_MemAllocator 74 75``` 76typedef void*(* OH_IPC_MemAllocator) (int32_t len) 77``` 78 79**Description** 80 81Defines the type of a memory allocation function. 82 83**System capability**: SystemCapability.Communication.IPC.Core 84 85**Since**: 12 86 87**Parameters** 88 89| Name| Description| 90| -------- | -------- | 91| len | Length of the allocated memory.| 92 93**Returns** 94 95Returns the address of the memory allocated if the operation is successful; returns NULL otherwise. 96 97 98## Function Description 99 100 101### OH_IPCParcel_Append() 102 103``` 104int OH_IPCParcel_Append (OHIPCParcel * parcel, const OHIPCParcel * data ) 105``` 106 107**Description** 108 109Appends data to an **OHIPCParcel** object. 110 111**System capability**: SystemCapability.Communication.IPC.Core 112 113**Since**: 12 114 115**Parameters** 116 117| Name| Description| 118| -------- | -------- | 119| parcel | Pointer to the target **OHIPCParcel** object. It cannot be NULL.| 120| data | Pointer to the data to append. It cannot be NULL.| 121 122**Returns** 123 124Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 125 126Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 127 128Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR](_o_h_i_p_c_error_code.md) if the operation fails. 129 130 131### OH_IPCParcel_Create() 132 133``` 134OHIPCParcel* OH_IPCParcel_Create (void ) 135``` 136 137**Description** 138 139Creates an **OHIPCParcel** object, which cannot exceed 204,800 bytes. 140 141**System capability**: SystemCapability.Communication.IPC.Core 142 143**Since**: 12 144 145**Returns** 146 147Returns the pointer to the **OHIPCParcel** object created if the operation is successful; returns NULL otherwise. 148 149 150### OH_IPCParcel_Destroy() 151 152``` 153void OH_IPCParcel_Destroy (OHIPCParcel * parcel) 154``` 155 156**Description** 157 158Destroys an **OHIPCParcel** object. 159 160**System capability**: SystemCapability.Communication.IPC.Core 161 162**Since**: 12 163 164**Parameters** 165 166| Name| Description| 167| -------- | -------- | 168| parcel | Pointer to the **OHIPCParcel** object to destroy.| 169 170 171### OH_IPCParcel_GetDataSize() 172 173``` 174int OH_IPCParcel_GetDataSize (const OHIPCParcel * parcel) 175``` 176 177**Description** 178 179Obtains the size of the data contained in an **OHIPCParcel** object. 180 181**System capability**: SystemCapability.Communication.IPC.Core 182 183**Since**: 12 184 185**Parameters** 186 187| Name| Description| 188| -------- | -------- | 189| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 190 191**Returns** 192 193Returns the data size obtained if the operation is successful.<br>Returns **-1** if invalid parameters are found. 194 195 196### OH_IPCParcel_GetReadableBytes() 197 198``` 199int OH_IPCParcel_GetReadableBytes (const OHIPCParcel * parcel) 200``` 201 202**Description** 203 204Obtains the number of bytes that can be read from an **OHIPCParcel** object. 205 206**System capability**: SystemCapability.Communication.IPC.Core 207 208**Since**: 12 209 210**Parameters** 211 212| Name| Description| 213| -------- | -------- | 214| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 215 216**Returns** 217 218Returns the number of bytes that can be read from the **OHIPCParcel** object. <br>Returns **-1** if invalid parameters are found. 219 220 221### OH_IPCParcel_GetReadPosition() 222 223``` 224int OH_IPCParcel_GetReadPosition (const OHIPCParcel * parcel) 225``` 226 227**Description** 228 229Obtains the position where data is read in an **OHIPCParcel** object. 230 231**System capability**: SystemCapability.Communication.IPC.Core 232 233**Since**: 12 234 235**Parameters** 236 237| Name| Description| 238| -------- | -------- | 239| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 240 241**Returns** 242 243Returns the current read position obtained if the operation is successful. <br>Returns **-1** if invalid parameters are found. 244 245 246### OH_IPCParcel_GetWritableBytes() 247 248``` 249int OH_IPCParcel_GetWritableBytes (const OHIPCParcel * parcel) 250``` 251 252**Description** 253 254Obtains the number of bytes that can be written to an **OHIPCParcel** object. 255 256**System capability**: SystemCapability.Communication.IPC.Core 257 258**Since**: 12 259 260**Parameters** 261 262| Name| Description| 263| -------- | -------- | 264| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 265 266**Returns** 267 268Returns the number of bytes that can be written to the **OHIPCParcel** object. <br>Returns **-1** if invalid parameters are found. 269 270 271### OH_IPCParcel_GetWritePosition() 272 273``` 274int OH_IPCParcel_GetWritePosition (const OHIPCParcel * parcel) 275``` 276 277**Description** 278 279Obtains the position where data is written in an **OHIPCParcel** object. 280 281**System capability**: SystemCapability.Communication.IPC.Core 282 283**Since**: 12 284 285**Parameters** 286 287| Name| Description| 288| -------- | -------- | 289| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 290 291**Returns** 292 293Returns the current write position obtained if the operation is successful.<br>Returns **-1** if invalid parameters are found. 294 295 296### OH_IPCParcel_ReadBuffer() 297 298``` 299const uint8_t* OH_IPCParcel_ReadBuffer (const OHIPCParcel * parcel, int32_t len ) 300``` 301 302**Description** 303 304Reads memory information of the specified length from an **OHIPCParcel** object. 305 306**System capability**: SystemCapability.Communication.IPC.Core 307 308**Since**: 12 309 310**Parameters** 311 312| Name| Description| 313| -------- | -------- | 314| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 315| len | Length of the memory to be read.| 316 317**Returns** 318 319Returns the memory address read if the operation is successful.<br>Returns NULL if invalid parameters are found or **len** exceeds the readable length of **parcel**. 320 321 322### OH_IPCParcel_ReadDouble() 323 324``` 325int OH_IPCParcel_ReadDouble (const OHIPCParcel * parcel, double * value ) 326``` 327 328**Description** 329 330Reads a double value from an **OHIPCParcel** object. 331 332**System capability**: SystemCapability.Communication.IPC.Core 333 334**Since**: 12 335 336**Parameters** 337 338| Name| Description| 339| -------- | -------- | 340| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 341| value | Pointer to the buffer for storing the read data. It cannot be NULL. | 342 343**Returns** 344 345Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 346 347Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 348 349Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR](_o_h_i_p_c_error_code.md) if the read operation fails. 350 351 352### OH_IPCParcel_ReadFileDescriptor() 353 354``` 355int OH_IPCParcel_ReadFileDescriptor (const OHIPCParcel * parcel, int32_t * fd ) 356``` 357 358**Description** 359 360Reads a file descriptor from an **OHIPCParcel** object. 361 362**System capability**: SystemCapability.Communication.IPC.Core 363 364**Since**: 12 365 366**Parameters** 367 368| Name| Description| 369| -------- | -------- | 370| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 371| fd | Pointer to the file descriptor to read. It cannot be NULL. | 372 373**Returns** 374 375Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 376 377Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 378 379Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR](_o_h_i_p_c_error_code.md) if the read operation fails. 380 381 382### OH_IPCParcel_ReadFloat() 383 384``` 385int OH_IPCParcel_ReadFloat (const OHIPCParcel * parcel, float * value ) 386``` 387 388**Description** 389 390Reads a float value from an **OHIPCParcel** object. 391 392**System capability**: SystemCapability.Communication.IPC.Core 393 394**Since**: 12 395 396**Parameters** 397 398| Name| Description| 399| -------- | -------- | 400| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 401| value | Pointer to the float value to read. It cannot be NULL. | 402 403**Returns** 404 405Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 406 407Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 408 409Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR](_o_h_i_p_c_error_code.md) if the read operation fails. 410 411 412### OH_IPCParcel_ReadInt16() 413 414``` 415int OH_IPCParcel_ReadInt16 (const OHIPCParcel * parcel, int16_t * value ) 416``` 417 418**Description** 419 420Reads an int16_t value from an **OHIPCParcel** object. 421 422**System capability**: SystemCapability.Communication.IPC.Core 423 424**Since**: 12 425 426**Parameters** 427 428| Name| Description| 429| -------- | -------- | 430| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 431| value | Pointer to the int16_t value to read. It cannot be NULL. | 432 433**Returns** 434 435Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 436 437Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 438 439Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR](_o_h_i_p_c_error_code.md) if the read operation fails. 440 441 442### OH_IPCParcel_ReadInt32() 443 444``` 445int OH_IPCParcel_ReadInt32 (const OHIPCParcel * parcel, int32_t * value ) 446``` 447 448**Description** 449 450Reads an int32_t value from an **OHIPCParcel** object. 451 452**System capability**: SystemCapability.Communication.IPC.Core 453 454**Since**: 12 455 456**Parameters** 457 458| Name| Description| 459| -------- | -------- | 460| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 461| value | Pointer to the int32_t value to read. It cannot be NULL. | 462 463**Returns** 464 465Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 466 467Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 468 469Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR](_o_h_i_p_c_error_code.md) if the read operation fails. 470 471 472### OH_IPCParcel_ReadInt64() 473 474``` 475int OH_IPCParcel_ReadInt64 (const OHIPCParcel * parcel, int64_t * value ) 476``` 477 478**Description** 479 480Reads an int64_t value from an **OHIPCParcel** object. 481 482**System capability**: SystemCapability.Communication.IPC.Core 483 484**Since**: 12 485 486**Parameters** 487 488| Name| Description| 489| -------- | -------- | 490| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 491| value | Pointer to the int64_t value to read. It cannot be NULL. | 492 493**Returns** 494 495Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 496 497Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 498 499Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR](_o_h_i_p_c_error_code.md) if the read operation fails. 500 501 502### OH_IPCParcel_ReadInt8() 503 504``` 505int OH_IPCParcel_ReadInt8 (const OHIPCParcel * parcel, int8_t * value ) 506``` 507 508**Description** 509 510Reads an int8_t value from an **OHIPCParcel** object. 511 512**System capability**: SystemCapability.Communication.IPC.Core 513 514**Since**: 12 515 516**Parameters** 517 518| Name| Description| 519| -------- | -------- | 520| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 521| value | Pointer to the int8_t value to read. It cannot be NULL. | 522 523**Returns** 524 525Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 526 527Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 528 529Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR](_o_h_i_p_c_error_code.md) if the read operation fails. 530 531 532### OH_IPCParcel_ReadInterfaceToken() 533 534``` 535int OH_IPCParcel_ReadInterfaceToken (const OHIPCParcel * parcel, char ** token, int32_t * len, OH_IPC_MemAllocator allocator ) 536``` 537 538**Description** 539 540Reads an interface token from an **OHIPCParcel** object for interface identity verification. 541 542**System capability**: SystemCapability.Communication.IPC.Core 543 544**Since**: 12 545 546**Parameters** 547 548| Name| Description| 549| -------- | -------- | 550| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 551| token | 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. | 552| len | Pointer to the length of the interface token read, including the terminator. It cannot be NULL.| 553| allocator | Memory allocator specified by the user for allocating memory. It cannot be NULL.| 554 555**Returns** 556 557Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 558 559Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 560 561Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_READ_ERROR](_o_h_i_p_c_error_code.md) if the read operation fails. 562 563 564### OH_IPCParcel_ReadRemoteProxy() 565 566``` 567OHIPCRemoteProxy* OH_IPCParcel_ReadRemoteProxy (const OHIPCParcel * parcel) 568``` 569 570**Description** 571 572Reads the **OHIPCRemoteProxy** object from an **OHIPCParcel** object. 573 574**System capability**: SystemCapability.Communication.IPC.Core 575 576**Since**: 12 577 578**Parameters** 579 580| Name| Description| 581| -------- | -------- | 582| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 583 584**Returns** 585 586Returns the pointer to the **OHIPCRemoteProxy** object created if the operation is successful; returns NULL otherwise. 587 588 589### OH_IPCParcel_ReadRemoteStub() 590 591``` 592OHIPCRemoteStub* OH_IPCParcel_ReadRemoteStub (const OHIPCParcel * parcel) 593``` 594 595**Description** 596 597Reads the **OHIPCRemoteStub** object from an **OHIPCParcel** object. 598 599**System capability**: SystemCapability.Communication.IPC.Core 600 601**Since**: 12 602 603**Parameters** 604 605| Name| Description| 606| -------- | -------- | 607| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 608 609**Returns** 610 611Returns the pointer to the **OHIPCRemoteStub** object read if the operation is successful; returns NULL otherwise. 612 613 614### OH_IPCParcel_ReadString() 615 616``` 617const char* OH_IPCParcel_ReadString (const OHIPCParcel * parcel) 618``` 619 620**Description** 621 622Reads a string from an **OHIPCParcel** object. You can obtain the length of the string from **strlen**. 623 624**System capability**: SystemCapability.Communication.IPC.Core 625 626**Since**: 12 627 628**Parameters** 629 630| Name| Description| 631| -------- | -------- | 632| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 633 634**Returns** 635 636Returns the address of the string read if the operation is successful; returns NULL if the operation fails or invalid parameters are found. 637 638 639### OH_IPCParcel_RewindReadPosition() 640 641``` 642int OH_IPCParcel_RewindReadPosition (OHIPCParcel * parcel, uint32_t newReadPos ) 643``` 644 645**Description** 646 647Resets the position to read data in an **OHIPCParcel** object. 648 649**System capability**: SystemCapability.Communication.IPC.Core 650 651**Since**: 12 652 653**Parameters** 654 655| Name| Description| 656| -------- | -------- | 657| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 658| newReadPos | New position to read data. The value ranges from **0** to the current data size.| 659 660**Returns** 661 662Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 663 664Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 665 666 667### OH_IPCParcel_RewindWritePosition() 668 669``` 670int OH_IPCParcel_RewindWritePosition (OHIPCParcel * parcel, uint32_t newWritePos ) 671``` 672 673**Description** 674 675Resets the position to write data in an **OHIPCParcel** object. 676 677**System capability**: SystemCapability.Communication.IPC.Core 678 679**Since**: 12 680 681**Parameters** 682 683| Name| Description| 684| -------- | -------- | 685| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 686| newWritePos | New position to write data. The value ranges from **0** to the current data size.| 687 688**Returns** 689 690Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 691 692Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 693 694 695### OH_IPCParcel_WriteBuffer() 696 697``` 698int OH_IPCParcel_WriteBuffer (OHIPCParcel * parcel, const uint8_t * buffer, int32_t len ) 699``` 700 701**Description** 702 703Writes data of the specified length from the memory to an **OHIPCParcel** object. 704 705**System capability**: SystemCapability.Communication.IPC.Core 706 707**Since**: 12 708 709**Parameters** 710 711| Name| Description| 712| -------- | -------- | 713| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 714| buffer | Pointer to the address for writing memory information.| 715| len | Length of the data to write.| 716 717**Returns** 718 719Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 720 721Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 722 723Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR](_o_h_i_p_c_error_code.md) if the operation fails. 724 725 726### OH_IPCParcel_WriteDouble() 727 728``` 729int OH_IPCParcel_WriteDouble (OHIPCParcel * parcel, double value ) 730``` 731 732**Description** 733 734Writes a double value to an **OHIPCParcel** object. 735 736**System capability**: SystemCapability.Communication.IPC.Core 737 738**Since**: 12 739 740**Parameters** 741 742| Name| Description| 743| -------- | -------- | 744| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 745| value | Value to write.| 746 747**Returns** 748 749Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 750 751Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 752 753Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR](_o_h_i_p_c_error_code.md) if the operation fails. 754 755 756### OH_IPCParcel_WriteFileDescriptor() 757 758``` 759int OH_IPCParcel_WriteFileDescriptor (OHIPCParcel * parcel, int32_t fd ) 760``` 761 762**Description** 763 764Writes a file descriptor to an **OHIPCParcel** object. 765 766**System capability**: SystemCapability.Communication.IPC.Core 767 768**Since**: 12 769 770**Parameters** 771 772| Name| Description| 773| -------- | -------- | 774| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 775| fd | Pointer to the file descriptor to write.| 776 777**Returns** 778 779Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 780 781Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 782 783Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR](_o_h_i_p_c_error_code.md) if the operation fails. 784 785 786### OH_IPCParcel_WriteFloat() 787 788``` 789int OH_IPCParcel_WriteFloat (OHIPCParcel * parcel, float value ) 790``` 791 792**Description** 793 794Writes a float value to an **OHIPCParcel** object. 795 796**System capability**: SystemCapability.Communication.IPC.Core 797 798**Since**: 12 799 800**Parameters** 801 802| Name| Description| 803| -------- | -------- | 804| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 805| value | Value to write.| 806 807**Returns** 808 809Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 810 811Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 812 813Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR](_o_h_i_p_c_error_code.md) if the operation fails. 814 815 816### OH_IPCParcel_WriteInt16() 817 818``` 819int OH_IPCParcel_WriteInt16 (OHIPCParcel * parcel, int16_t value ) 820``` 821 822**Description** 823 824Writes an int16_t value to an **OHIPCParcel** object. 825 826**System capability**: SystemCapability.Communication.IPC.Core 827 828**Since**: 12 829 830**Parameters** 831 832| Name| Description| 833| -------- | -------- | 834| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 835| value | Value to write.| 836 837**Returns** 838 839Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 840 841Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 842 843Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR](_o_h_i_p_c_error_code.md) if the operation fails. 844 845 846### OH_IPCParcel_WriteInt32() 847 848``` 849int OH_IPCParcel_WriteInt32 (OHIPCParcel * parcel, int32_t value ) 850``` 851 852**Description** 853 854Writes an int32_t value to an **OHIPCParcel** object. 855 856**System capability**: SystemCapability.Communication.IPC.Core 857 858**Since**: 12 859 860**Parameters** 861 862| Name| Description| 863| -------- | -------- | 864| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 865| value | Value to write.| 866 867**Returns** 868 869Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 870 871Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 872 873Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR](_o_h_i_p_c_error_code.md) if the operation fails. 874 875 876### OH_IPCParcel_WriteInt64() 877 878``` 879int OH_IPCParcel_WriteInt64 (OHIPCParcel * parcel, int64_t value ) 880``` 881 882**Description** 883 884Writes an int64_t value to an **OHIPCParcel** object. 885 886**System capability**: SystemCapability.Communication.IPC.Core 887 888**Since**: 12 889 890**Parameters** 891 892| Name| Description| 893| -------- | -------- | 894| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 895| value | Value to write.| 896 897**Returns** 898 899Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 900 901Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 902 903Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR](_o_h_i_p_c_error_code.md) if the operation fails. 904 905 906### OH_IPCParcel_WriteInt8() 907 908``` 909int OH_IPCParcel_WriteInt8 (OHIPCParcel * parcel, int8_t value ) 910``` 911 912**Description** 913 914Writes an int8_t value to an **OHIPCParcel** object. 915 916**System capability**: SystemCapability.Communication.IPC.Core 917 918**Since**: 12 919 920**Parameters** 921 922| Name| Description| 923| -------- | -------- | 924| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 925| value | Value to write.| 926 927**Returns** 928 929Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 930 931Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 932 933Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR](_o_h_i_p_c_error_code.md) if the operation fails. 934 935 936### OH_IPCParcel_WriteInterfaceToken() 937 938``` 939int OH_IPCParcel_WriteInterfaceToken (OHIPCParcel * parcel, const char * token ) 940``` 941 942**Description** 943 944Writes an interface token to an **OHIPCParcel** object for interface identity verification. 945 946**System capability**: SystemCapability.Communication.IPC.Core 947 948**Since**: 12 949 950**Parameters** 951 952| Name| Description| 953| -------- | -------- | 954| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 955| token | Pointer to the interface token to write. It cannot be NULL.| 956 957**Returns** 958 959Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 960 961Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 962 963Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR](_o_h_i_p_c_error_code.md) if the operation fails. 964 965 966### OH_IPCParcel_WriteRemoteProxy() 967 968``` 969int OH_IPCParcel_WriteRemoteProxy (OHIPCParcel * parcel, const OHIPCRemoteProxy * proxy ) 970``` 971 972**Description** 973 974Writes an **OHIPCRemoteProxy** object to an **OHIPCParcel** object. 975 976**System capability**: SystemCapability.Communication.IPC.Core 977 978**Since**: 12 979 980**Parameters** 981 982| Name| Description| 983| -------- | -------- | 984| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 985| proxy | Pointer to the **OHIPCRemoteProxy** object to write. It cannot be NULL.| 986 987**Returns** 988 989Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 990 991Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 992 993Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR](_o_h_i_p_c_error_code.md) if the operation fails. 994 995 996### OH_IPCParcel_WriteRemoteStub() 997 998``` 999int OH_IPCParcel_WriteRemoteStub (OHIPCParcel * parcel, const OHIPCRemoteStub * stub ) 1000``` 1001 1002**Description** 1003 1004Writes an **OHIPCRemoteStub** object to an **OHIPCParcel** object. 1005 1006**System capability**: SystemCapability.Communication.IPC.Core 1007 1008**Since**: 12 1009 1010**Parameters** 1011 1012| Name| Description| 1013| -------- | -------- | 1014| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 1015| stub | Pointer to the **OHIPCRemoteStub** object to write. It cannot be NULL.| 1016 1017**Returns** 1018 1019Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 1020 1021Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 1022 1023Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR](_o_h_i_p_c_error_code.md) if the operation fails. 1024 1025 1026### OH_IPCParcel_WriteString() 1027 1028``` 1029int OH_IPCParcel_WriteString (OHIPCParcel * parcel, const char * str ) 1030``` 1031 1032**Description** 1033 1034Writes a string including a string terminator to an **OHIPCParcel** object. 1035 1036**System capability**: SystemCapability.Communication.IPC.Core 1037 1038**Since**: 12 1039 1040**Parameters** 1041 1042| Name| Description| 1043| -------- | -------- | 1044| parcel | Pointer to the **OHIPCParcel** object. It cannot be NULL.| 1045| str | Pointer to the string to write. It cannot be NULL.| 1046 1047**Returns** 1048 1049Returns [OH_IPC_ErrorCode#OH_IPC_SUCCESS](_o_h_i_p_c_error_code.md) if the operation is successful. 1050 1051Returns [OH_IPC_ErrorCode#OH_IPC_CHECK_PARAM_ERROR](_o_h_i_p_c_error_code.md) if invalid parameters are found. 1052 1053Returns [OH_IPC_ErrorCode#OH_IPC_PARCEL_WRITE_ERROR](_o_h_i_p_c_error_code.md) if the operation fails. 1054