Changeset edba2b6f in mainline for uspace/lib/c/include/adt/measured_strings.h
- Timestamp:
- 2010-09-26T13:03:18Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0402bda5
- Parents:
- 7390870
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/adt/measured_strings.h
r7390870 redba2b6f 27 27 */ 28 28 29 /** @addtogroup net29 /** @addtogroup libc 30 30 * @{ 31 31 */ 32 32 33 33 /** @file 34 * Character string with measured length. 35 * The structure has been designed for serialization of character strings between modules. 34 * Character string with measured length. 35 * The structure has been designed for serialization of character strings 36 * between modules. 36 37 */ 37 38 … … 44 45 * @see measured_string 45 46 */ 46 typedef struct measured_string 47 typedef struct measured_string measured_string_t; 47 48 48 49 /** Type definition of the character string with measured length pointer. 49 50 * @see measured_string 50 51 */ 51 typedef measured_string_t * 52 typedef measured_string_t *measured_string_ref; 52 53 53 54 /** Character string with measured length. 54 * This structure has been designed for serialization of character strings between modules. 55 * 56 * This structure has been designed for serialization of character strings 57 * between modules. 55 58 */ 56 struct measured_string{ 57 /** Character string data. 58 */ 59 struct measured_string { 60 /** Character string data. */ 59 61 char * value; 60 /** Character string length. 61 */ 62 /** Character string length. */ 62 63 size_t length; 63 64 }; 64 65 65 /** Creates a new measured string bundled with a copy of the given string itself as one memory block. 66 * If the measured string is being freed, whole memory block is freed. 67 * The measured string should be used only as a constant. 68 * @param[in] string The initial character string to be stored. 69 * @param[in] 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. 70 * @returns The new bundled character string with measured length. 71 * @returns NULL if there is not enough memory left. 72 */ 73 extern measured_string_ref measured_string_create_bulk(const char * string, size_t length); 74 75 /** Copies the given measured string with separated header and data parts. 76 * @param[in] source The source measured string to be copied. 77 * @returns The copy of the given measured string. 78 * @returns NULL if the source parameter is NULL. 79 * @returns NULL if there is not enough memory left. 80 */ 81 extern measured_string_ref measured_string_copy(measured_string_ref source); 82 83 /** Receives a measured strings array from a calling module. 84 * Creates the array and the data memory blocks. 85 * This method should be used only while processing IPC messages as the array size has to be negotiated in advance. 86 * @param[out] strings The received measured strings array. 87 * @param[out] data The measured strings data. This memory block stores the actual character strings. 88 * @param[in] count The size of the measured strings array. 89 * @returns EOK on success. 90 * @returns EINVAL if the strings or data parameter is NULL. 91 * @returns EINVAL if the count parameter is zero (0). 92 * @returns EINVAL if the sent array differs in size. 93 * @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur). 94 * @returns ENOMEM if there is not enough memory left. 95 * @returns Other error codes as defined for the async_data_write_finalize() function. 96 */ 97 extern int measured_strings_receive(measured_string_ref * strings, char ** data, size_t count); 98 99 /** Replies the given measured strings array to a calling module. 100 * This method should be used only while processing IPC messages as the array size has to be negotiated in advance. 101 * @param[in] strings The measured strings array to be transferred. 102 * @param[in] count The measured strings array size. 103 * @returns EOK on success. 104 * @returns EINVAL if the strings parameter is NULL. 105 * @returns EINVAL if the count parameter is zero (0). 106 * @returns EINVAL if the calling module does not accept the given array size. 107 * @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur). 108 * @returns Other error codes as defined for the async_data_read_finalize() function. 109 */ 110 extern int measured_strings_reply(const measured_string_ref strings, size_t count); 111 112 /** Receives a measured strings array from another module. 113 * Creates the array and the data memory blocks. 114 * This method should be used only following other IPC messages as the array size has to be negotiated in advance. 115 * @param[in] phone The other module phone. 116 * @param[out] strings The returned measured strings array. 117 * @param[out] data The measured strings data. This memory block stores the actual character strings. 118 * @param[in] count The size of the measured strings array. 119 * @returns EOK on success. 120 * @returns EINVAL if the strings or data parameter is NULL. 121 * @returns EINVAL if the phone or count parameter is not positive (<=0). 122 * @returns EINVAL if the sent array differs in size. 123 * @returns ENOMEM if there is not enough memory left. 124 * @returns Other error codes as defined for the async_data_read_start() function. 125 */ 126 extern int measured_strings_return(int phone, measured_string_ref * strings, char ** data, size_t count); 127 128 /** Sends the given measured strings array to another module. 129 * This method should be used only following other IPC messages as the array size has to be negotiated in advance. 130 * @param[in] phone The other module phone. 131 * @param[in] strings The measured strings array to be transferred. 132 * @param[in] count The measured strings array size. 133 * @returns EOK on success. 134 * @returns EINVAL if the strings parameter is NULL. 135 * @returns EINVAL if the phone or count parameter is not positive (<=0). 136 * @returns Other error codes as defined for the async_data_write_start() function. 137 */ 138 extern int measured_strings_send(int phone, const measured_string_ref strings, size_t count); 66 extern measured_string_ref measured_string_create_bulk(const char *, size_t); 67 extern measured_string_ref measured_string_copy(measured_string_ref); 68 extern int measured_strings_receive(measured_string_ref *, char **, size_t); 69 extern int measured_strings_reply(const measured_string_ref, size_t); 70 extern int measured_strings_return(int, measured_string_ref *, char **, size_t); 71 extern int measured_strings_send(int, const measured_string_ref, size_t); 139 72 140 73 #endif … … 142 75 /** @} 143 76 */ 144
Note:
See TracChangeset
for help on using the changeset viewer.