Tizen Native API  6.5
RPC Port Parcel

The RPC Port Parcel API provides functions to make parcel data.

Required Header

#include <rpc-port-parcel.h>

Overview

It is container for a data that can be sent via RPCPort.

Functions

int rpc_port_parcel_create (rpc_port_parcel_h *h)
 Creates a rpc port parcel handle.
int rpc_port_parcel_create_from_port (rpc_port_parcel_h *h, rpc_port_h port)
 Creates a rpc port parcel handle from port.
int rpc_port_parcel_send (rpc_port_parcel_h h, rpc_port_h port)
 Sends parcel data through the port.
int rpc_port_parcel_destroy (rpc_port_parcel_h h)
 Destroys a rpc port parcel handle.
int rpc_port_parcel_write_byte (rpc_port_parcel_h h, char b)
 Writes a byte value into rpc port parcel handle.
int rpc_port_parcel_write_int16 (rpc_port_parcel_h h, short i)
 Writes a short value into rpc port parcel handle.
int rpc_port_parcel_write_int32 (rpc_port_parcel_h h, int i)
 Writes a integer value into rpc port parcel handle.
int rpc_port_parcel_write_int64 (rpc_port_parcel_h h, long long i)
 Writes a long long integer value into rpc port parcel handle.
int rpc_port_parcel_write_float (rpc_port_parcel_h h, float f)
 Writes a floating point value into rpc port parcel handle.
int rpc_port_parcel_write_double (rpc_port_parcel_h h, double d)
 Writes a double precision floating point value into rpc port parcel handle.
int rpc_port_parcel_write_string (rpc_port_parcel_h h, const char *str)
 Writes a string value into rpc port parcel handle.
int rpc_port_parcel_write_bool (rpc_port_parcel_h h, bool b)
 Writes a boolean value into rpc port parcel handle.
int rpc_port_parcel_write_bundle (rpc_port_parcel_h h, bundle *b)
 Writes a bundle data into rpc port parcel handle.
int rpc_port_parcel_write_array_count (rpc_port_parcel_h h, int count)
 Writes a count for array into rpc port parcel handle.
int rpc_port_parcel_write (rpc_port_parcel_h h, rpc_port_parcelable_t *parcelable, void *data)
 Writes the data into parcel handle using parcelable.
int rpc_port_parcel_read_byte (rpc_port_parcel_h h, char *b)
 Reads a byte value from rpc port parcel handle.
int rpc_port_parcel_read_int16 (rpc_port_parcel_h h, short *i)
 Reads a short value from rpc port parcel handle.
int rpc_port_parcel_read_int32 (rpc_port_parcel_h h, int *i)
 Reads a integer value from rpc port parcel handle.
int rpc_port_parcel_read_int64 (rpc_port_parcel_h h, long long *i)
 Reads a long long integer value from rpc port parcel handle.
int rpc_port_parcel_read_float (rpc_port_parcel_h h, float *f)
 Reads a floating point value from rpc port parcel handle.
int rpc_port_parcel_read_double (rpc_port_parcel_h h, double *d)
 Reads a double precision floating point value from rpc port parcel handle.
int rpc_port_parcel_read_string (rpc_port_parcel_h h, char **str)
 Reads a string value from rpc port parcel handle.
int rpc_port_parcel_read_bool (rpc_port_parcel_h h, bool *b)
 Reads a boolean value from rpc port parcel handle.
int rpc_port_parcel_read_bundle (rpc_port_parcel_h h, bundle **b)
 Reads a bundle data from rpc port parcel handle.
int rpc_port_parcel_read_array_count (rpc_port_parcel_h h, int *count)
 Reads a count for array from rpc port parcel handle.
int rpc_port_parcel_read (rpc_port_parcel_h h, rpc_port_parcelable_t *parcelable, void *data)
 Reads a parcel from the data using parcelable.
int rpc_port_parcel_burst_read (rpc_port_parcel_h h, unsigned char *buf, unsigned int size)
 Reads bytes from rpc port parcel handle.
int rpc_port_parcel_burst_write (rpc_port_parcel_h h, const unsigned char *buf, unsigned int size)
 Writes bytes to rpc port parcel handle.
int rpc_port_parcel_get_header (rpc_port_parcel_h h, rpc_port_parcel_header_h *header)
 Gets the header handle of the rpc port parcel.
int rpc_port_parcel_header_set_tag (rpc_port_parcel_header_h header, const char *tag)
 Sets the tag to the header handle of the rpc port parcel.
int rpc_port_parcel_header_get_tag (rpc_port_parcel_header_h header, char **tag)
 Gets the tag from the header handle of the rpc port parcel.
int rpc_port_parcel_header_set_seq_num (rpc_port_parcel_header_h header, int seq_num)
 Sets the sequence number to the header handle of the rpc port parcel.
int rpc_port_parcel_header_get_seq_num (rpc_port_parcel_header_h header, int *seq_num)
 Gets the sequence number from the header handle of the rpc port parcel.
int rpc_port_parcel_header_get_timestamp (rpc_port_parcel_header_h header, struct timespec *timestamp)
 Gets the timestamp from the header handle of the rpc port parcel.
int rpc_port_parcel_get_raw (rpc_port_parcel_h h, void **raw, unsigned int *size)
 Gets the raw data of the rpc port parcel handle.
int rpc_port_parcel_create_from_raw (rpc_port_parcel_h *h, const void *raw, unsigned int size)
 Creates the rpc port parcel handle with given the raw data.

Typedefs

typedef void * rpc_port_parcel_h
 The rpc port parcel handle.
typedef void * rpc_port_parcel_header_h
 The header handle of the rpc port parcel.
typedef struct
__rpc_port_parcelable 
rpc_port_parcelable_t
 The interface for converting data to/from a parcel.

Typedef Documentation

typedef void* rpc_port_parcel_h

The rpc port parcel handle.

Since :
4.0
typedef void* rpc_port_parcel_header_h

The header handle of the rpc port parcel.

Since :
6.5

The interface for converting data to/from a parcel.

Since :
4.0

Function Documentation

int rpc_port_parcel_burst_read ( rpc_port_parcel_h  h,
unsigned char *  buf,
unsigned int  size 
)

Reads bytes from rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[out]bufThe array buffer to read
[in]sizeBytes to read
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_write_bool()
int rpc_port_parcel_burst_write ( rpc_port_parcel_h  h,
const unsigned char *  buf,
unsigned int  size 
)

Writes bytes to rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[in]bufThe array buffer to write
[in]sizeBytes to write
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_write_bool()

Creates a rpc port parcel handle.

Since :
4.0
Remarks:
You must release h using rpc_port_parcel_destroy().
Parameters:
[out]hThe rpc port parcel handle that is newly created
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERInvalid parameter
See also:
rpc_port_parcel_destroy()

Creates a rpc port parcel handle from port.

Creates a rpc port parcel handle using read data from the port. It calls rpc_port_read() internally.

Since :
4.0
Remarks:
You must release h using rpc_port_parcel_destroy().
Parameters:
[out]hThe rpc port parcel handle that is newly created
[in]portThe rpc port handle for creating handle
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified port is NULL
RPC_PORT_ERROR_IO_ERRORInternal I/O error
See also:
rpc_port_parcel_destroy()
rpc_port_parcel_send()
int rpc_port_parcel_create_from_raw ( rpc_port_parcel_h h,
const void *  raw,
unsigned int  size 
)

Creates the rpc port parcel handle with given the raw data.

Since :
6.5
Remarks:
You must release h using rpc_port_parcel_destroy().
Parameters:
[out]hThe rpc port parcel handle
[in]rawThe raw data
[in]sizeThe size of the raw data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERInvalid parameter
RPC_PORT_ERROR_OUT_OF_MEMORYOut of memory
See also:
rpc_port_parcel_destroy()

Destroys a rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_create()

Gets the header handle of the rpc port parcel.

Since :
6.5
Remarks:
The header is managed by the platform and will be released when rpc_port_parcel_destroy() is called.
Parameters:
[in]hThe rpc port parcel handle
[out]headerThe header handle of the rpc port parcel
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERInvalid parameter
int rpc_port_parcel_get_raw ( rpc_port_parcel_h  h,
void **  raw,
unsigned int *  size 
)

Gets the raw data of the rpc port parcel handle.

Since :
6.5
Remarks:
You MUST NOT release raw using free(). It's managed by platform.
Parameters:
[in]hThe rpc port parcel handle
[out]rawThe raw data
[out]sizeThe size of the raw data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERInvalid parameter
int rpc_port_parcel_header_get_seq_num ( rpc_port_parcel_header_h  header,
int *  seq_num 
)

Gets the sequence number from the header handle of the rpc port parcel.

Since :
6.5
Parameters:
[in]headerThe header handle of the rpc port parcel
[out]seq_numThe sequence number
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERInvalid parameter
See also:
rpc_port_parcel_header_set_seq_num()
int rpc_port_parcel_header_get_tag ( rpc_port_parcel_header_h  header,
char **  tag 
)

Gets the tag from the header handle of the rpc port parcel.

Since :
6.5
Remarks:
The tag should be released using free().
Parameters:
[in]headerThe header handle of the rpc port parcel
[out]tagThe tag
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERInvalid parameter
RPC_PORT_ERROR_OUT_OF_MEMORYOut of memory
See also:
rpc_port_parcel_header_set_tag()
int rpc_port_parcel_header_get_timestamp ( rpc_port_parcel_header_h  header,
struct timespec *  timestamp 
)

Gets the timestamp from the header handle of the rpc port parcel.

Since :
6.5
Remarks:
The timestamp represents monotonic time since some unspecified starting point. To get elapsed time properly, you have to get the timestamp using the clock_gettime() with CLOCK_MONITONIC_RAW.
Parameters:
[in]headerThe header handle of the rpc port parcel
[out]timestampThe timestamp
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERInvalid parameter

Sets the sequence number to the header handle of the rpc port parcel.

Since :
6.5
Parameters:
[in]headerThe header handle of the rpc port parcel
[in]seq_numThe sequence number
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERInvalid parameter
See also:
rpc_port_parcel_header_get_seq_num()
int rpc_port_parcel_header_set_tag ( rpc_port_parcel_header_h  header,
const char *  tag 
)

Sets the tag to the header handle of the rpc port parcel.

Since :
6.5
Parameters:
[in]headerThe header handle of the rpc port parcel
[in]tagThe tag
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERInvalid parameter
See also:
rpc_port_parcel_header_get_tag()
int rpc_port_parcel_read ( rpc_port_parcel_h  h,
rpc_port_parcelable_t parcelable,
void *  data 
)

Reads a parcel from the data using parcelable.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[in]parcelableThe interface to get data from parcel handle
[in]dataData which get from parcel
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_write()

Reads a count for array from rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[out]countArray count
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_write_array_count()
int rpc_port_parcel_read_bool ( rpc_port_parcel_h  h,
bool *  b 
)

Reads a boolean value from rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[out]bboolean data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_write_bool()

Reads a bundle data from rpc port parcel handle.

Since :
4.0
Remarks:
The b should be released using bundle_free().
Parameters:
[in]hThe rpc port parcel handle
[out]bBundle data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_write_bundle()
int rpc_port_parcel_read_byte ( rpc_port_parcel_h  h,
char *  b 
)

Reads a byte value from rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[out]bByte data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_write_byte()
int rpc_port_parcel_read_double ( rpc_port_parcel_h  h,
double *  d 
)

Reads a double precision floating point value from rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[out]ddouble data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_write_double()
int rpc_port_parcel_read_float ( rpc_port_parcel_h  h,
float *  f 
)

Reads a floating point value from rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[out]ffloat data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_write_float()
int rpc_port_parcel_read_int16 ( rpc_port_parcel_h  h,
short *  i 
)

Reads a short value from rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[out]ishort data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_write_int16()

Reads a integer value from rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[out]iint data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_write_int32()
int rpc_port_parcel_read_int64 ( rpc_port_parcel_h  h,
long long *  i 
)

Reads a long long integer value from rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[out]ilong long data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_write_int64()
int rpc_port_parcel_read_string ( rpc_port_parcel_h  h,
char **  str 
)

Reads a string value from rpc port parcel handle.

Since :
4.0
Remarks:
The str should be released using free().
Parameters:
[in]hThe rpc port parcel handle
[out]strstring data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_write_string()

Sends parcel data through the port.

Sends parcel data through the port. It calls rpc_port_write() internally.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle that is newly created
[in]portThe rpc port handle for writing data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
RPC_PORT_ERROR_IO_ERRORInternal I/O error
See also:
rpc_port_parcel_create_from_port()
int rpc_port_parcel_write ( rpc_port_parcel_h  h,
rpc_port_parcelable_t parcelable,
void *  data 
)

Writes the data into parcel handle using parcelable.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[in]parcelableThe interface to write the data into parcel handle
[in]dataData which write into parcel
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_read()

Writes a count for array into rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[in]countArray count
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_read_array_count()

Writes a boolean value into rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[in]bboolean data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_read_bool()

Writes a bundle data into rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[in]bBundle data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_read_bundle()

Writes a byte value into rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[in]bByte data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_read_byte()

Writes a double precision floating point value into rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[in]ddouble data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_read_double()

Writes a floating point value into rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[in]ffloat data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_read_float()

Writes a short value into rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[in]ishort data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_read_int16()

Writes a integer value into rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[in]iint data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_read_int32()
int rpc_port_parcel_write_int64 ( rpc_port_parcel_h  h,
long long  i 
)

Writes a long long integer value into rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[in]ilong long data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_read_int64()
int rpc_port_parcel_write_string ( rpc_port_parcel_h  h,
const char *  str 
)

Writes a string value into rpc port parcel handle.

Since :
4.0
Parameters:
[in]hThe rpc port parcel handle
[in]strstring data
Returns:
0 on success, otherwise a negative error value
Return values:
RPC_PORT_ERROR_NONESuccessful
RPC_PORT_ERROR_INVALID_PARAMETERThe specified h is NULL
See also:
rpc_port_parcel_read_string()