Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 3845 → Rev 3846

/branches/network/uspace/srv/net/measured_strings.h
27,30 → 27,108
*/
 
/** @addtogroup net
* @{
* @{
*/
 
/**
* @file
/** @file
* A character string with measured length header file.
* This structure has been designed for serialization of character strings between modules.
*/
 
#ifndef __MEASURED_STRINGS_H__
#define __MEASURED_STRINGS_H__
 
/** A type definition of a character string with measured length.
* @see measured_string
*/
typedef struct measured_string measured_string_t;
typedef measured_string_t * measured_string_ref;
 
/** A type definition of a character string with measured length pointer.
* @see measured_string
*/
typedef measured_string_t * measured_string_ref;
 
/** A character string with measured length.
* This structure has been designed for serialization of character strings between modules.
*/
struct measured_string{
 
/** The character string data.
*/
char * value;
 
/** The character string length.
*/
size_t length;
};
 
/** Creates a new measured string bundled with a copy of the given string itself as one memory block.
* If the measured string is being freed, whole memory block is freed.
* The measured string should be used only as a constant.
* @param string The initial character string to be stored. Input parameter.
* @param length The length of the given string without the terminating zero ('/0') character. If the length is zero (0), the actual length is computed. The given length is used and appended with the terminating zero ('\0') character otherwise. Input parameter.
* @returns The new bundled charecter string with measured length.
* @returns NULL if there is no memory left.
*/
measured_string_ref measured_string_create_bulk( const char * string, size_t length );
int measured_strings_receive( measured_string_ref * strings, char ** data, size_t count );
int measured_strings_reply( measured_string_ref strings, size_t count );
int measured_strings_return( int phone, measured_string_ref * strings, char ** data, size_t count );
int measured_strings_send( int phone, measured_string_ref strings, size_t count );
 
/** Receives a measured strings array from a calling module.
* Creates the array and the data memory blocks.
* This method should be used only while processing IPC messages as the array size has to be negotiated in advance.
* @param strings The received measured strings array. Output parameter.
* @param data The measured strings data. This memory block stores the actual character strings. Output parameter.
* @param count The size of the measured strings array. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the strings or data parameter is NULL.
* @returns EINVAL if the count parameter is zero (0).
* @returns EINVAL if the sent array differs in size.
* @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur).
* @returns ENOMEM if there is no memory left.
* @returns Other error codes as defined for the ipc_data_write_finalize() function.
*/
int measured_strings_receive( measured_string_ref * strings, char ** data, size_t count );
 
/** Replies the given measured strings array to a calling module.
* This method should be used only while processing IPC messages as the array size has to be negotiated in advance.
* @param strings The measured strings array to be transferred. Input parameter.
* @param count The measured strings array size. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the strings parameter is NULL.
* @returns EINVAL if the count parameter is zero (0).
* @returns EINVAL if the calling module does not accept the given array size.
* @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur).
* @returns Other error codes as defined for the ipc_data_read_finalize() function.
*/
int measured_strings_reply( const measured_string_ref strings, size_t count );
 
/** Receives a measured strings array from another module.
* Creates the array and the data memory blocks.
* This method should be used only following other IPC messages as the array size has to be negotiated in advance.
* @param phone The other module phone. Input parameter.
* @param strings The returned measured strings array. Output parameter.
* @param data The measured strings data. This memory block stores the actual character strings. Output parameter.
* @param count The size of the measured strings array. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the strings or data parameter is NULL.
* @returns EINVAL if the phone or count parameter is not positive (<=0).
* @returns EINVAL if the sent array differs in size.
* @returns ENOMEM if there is no memory left.
* @returns Other error codes as defined for the ipc_data_read_start() function.
*/
int measured_strings_return( int phone, measured_string_ref * strings, char ** data, size_t count );
 
/** Sends the given measured strings array to another module.
* This method should be used only following other IPC messages as the array size has to be negotiated in advance.
* @param phone The other module phone. Input parameter.
* @param strings The measured strings array to be transferred. Input parameter.
* @param count The measured strings array size. Input parameter.
* @returns EOK on success.
* @returns EINVAL if the strings parameter is NULL.
* @returns EINVAL if the phone or count parameter is not positive (<=0).
* @returns Other error codes as defined for the ipc_data_write_start() function.
*/
int measured_strings_send( int phone, const measured_string_ref strings, size_t count );
 
#endif
 
/** @}