Rev 3846 | Rev 3912 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3846 | Rev 3886 | ||
---|---|---|---|
1 | /* |
1 | /* |
2 | * Copyright (c) 2008 Lukas Mejdrech |
2 | * Copyright (c) 2008 Lukas Mejdrech |
3 | * All rights reserved. |
3 | * All rights reserved. |
4 | * |
4 | * |
5 | * Redistribution and use in source and binary forms, with or without |
5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions |
6 | * modification, are permitted provided that the following conditions |
7 | * are met: |
7 | * are met: |
8 | * |
8 | * |
9 | * - Redistributions of source code must retain the above copyright |
9 | * - Redistributions of source code must retain the above copyright |
10 | * notice, this list of conditions and the following disclaimer. |
10 | * notice, this list of conditions and the following disclaimer. |
11 | * - Redistributions in binary form must reproduce the above copyright |
11 | * - Redistributions in binary form must reproduce the above copyright |
12 | * notice, this list of conditions and the following disclaimer in the |
12 | * notice, this list of conditions and the following disclaimer in the |
13 | * documentation and/or other materials provided with the distribution. |
13 | * documentation and/or other materials provided with the distribution. |
14 | * - The name of the author may not be used to endorse or promote products |
14 | * - The name of the author may not be used to endorse or promote products |
15 | * derived from this software without specific prior written permission. |
15 | * derived from this software without specific prior written permission. |
16 | * |
16 | * |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | */ |
27 | */ |
28 | 28 | ||
29 | /** @addtogroup net |
29 | /** @addtogroup net |
30 | * @{ |
30 | * @{ |
31 | */ |
31 | */ |
32 | 32 | ||
33 | /** @file |
33 | /** @file |
34 | * A character string with measured length header file. |
34 | * A character string with measured length header file. |
35 | * This structure has been designed for serialization of character strings between modules. |
35 | * This structure has been designed for serialization of character strings between modules. |
36 | */ |
36 | */ |
37 | 37 | ||
38 | #ifndef __MEASURED_STRINGS_H__ |
38 | #ifndef __MEASURED_STRINGS_H__ |
39 | #define __MEASURED_STRINGS_H__ |
39 | #define __MEASURED_STRINGS_H__ |
40 | 40 | ||
41 | /** A type definition of a character string with measured length. |
41 | /** A type definition of a character string with measured length. |
42 | * @see measured_string |
42 | * @see measured_string |
43 | */ |
43 | */ |
44 | typedef struct measured_string measured_string_t; |
44 | typedef struct measured_string measured_string_t; |
45 | 45 | ||
46 | /** A type definition of a character string with measured length pointer. |
46 | /** A type definition of a character string with measured length pointer. |
47 | * @see measured_string |
47 | * @see measured_string |
48 | */ |
48 | */ |
49 | typedef measured_string_t * measured_string_ref; |
49 | typedef measured_string_t * measured_string_ref; |
50 | 50 | ||
51 | /** A character string with measured length. |
51 | /** A character string with measured length. |
52 | * This structure has been designed for serialization of character strings between modules. |
52 | * This structure has been designed for serialization of character strings between modules. |
53 | */ |
53 | */ |
54 | struct measured_string{ |
54 | struct measured_string{ |
55 | 55 | ||
56 | /** The character string data. |
56 | /** The character string data. |
57 | */ |
57 | */ |
58 | char * value; |
58 | char * value; |
59 | 59 | ||
60 | /** The character string length. |
60 | /** The character string length. |
61 | */ |
61 | */ |
62 | size_t length; |
62 | size_t length; |
63 | }; |
63 | }; |
64 | 64 | ||
65 | /** Creates a new measured string bundled with a copy of the given string itself as one memory block. |
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. |
66 | * If the measured string is being freed, whole memory block is freed. |
67 | * The measured string should be used only as a constant. |
67 | * The measured string should be used only as a constant. |
68 | * @param string The initial character string to be stored. Input parameter. |
68 | * @param string The initial character string to be stored. Input parameter. |
69 | * @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. |
69 | * @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. |
70 | * @returns The new bundled charecter string with measured length. |
70 | * @returns The new bundled charecter string with measured length. |
71 | * @returns NULL if there is no memory left. |
71 | * @returns NULL if there is no memory left. |
72 | */ |
72 | */ |
73 | measured_string_ref measured_string_create_bulk( const char * string, size_t length ); |
73 | measured_string_ref measured_string_create_bulk( const char * string, size_t length ); |
74 | 74 | ||
75 | /** Receives a measured strings array from a calling module. |
75 | /** Receives a measured strings array from a calling module. |
76 | * Creates the array and the data memory blocks. |
76 | * Creates the array and the data memory blocks. |
77 | * This method should be used only while processing IPC messages as the array size has to be negotiated in advance. |
77 | * This method should be used only while processing IPC messages as the array size has to be negotiated in advance. |
78 | * @param strings The received measured strings array. Output parameter. |
78 | * @param strings The received measured strings array. Output parameter. |
79 | * @param data The measured strings data. This memory block stores the actual character strings. Output parameter. |
79 | * @param data The measured strings data. This memory block stores the actual character strings. Output parameter. |
80 | * @param count The size of the measured strings array. Input parameter. |
80 | * @param count The size of the measured strings array. Input parameter. |
81 | * @returns EOK on success. |
81 | * @returns EOK on success. |
82 | * @returns EINVAL if the strings or data parameter is NULL. |
82 | * @returns EINVAL if the strings or data parameter is NULL. |
83 | * @returns EINVAL if the count parameter is zero (0). |
83 | * @returns EINVAL if the count parameter is zero (0). |
84 | * @returns EINVAL if the sent array differs in size. |
84 | * @returns EINVAL if the sent array differs in size. |
85 | * @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur). |
85 | * @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur). |
86 | * @returns ENOMEM if there is no memory left. |
86 | * @returns ENOMEM if there is no memory left. |
87 | * @returns Other error codes as defined for the ipc_data_write_finalize() function. |
87 | * @returns Other error codes as defined for the ipc_data_write_finalize() function. |
88 | */ |
88 | */ |
89 | int measured_strings_receive( measured_string_ref * strings, char ** data, size_t count ); |
89 | int measured_strings_receive( measured_string_ref * strings, char ** data, size_t count ); |
90 | 90 | ||
91 | /** Replies the given measured strings array to a calling module. |
91 | /** Replies the given measured strings array to a calling module. |
92 | * This method should be used only while processing IPC messages as the array size has to be negotiated in advance. |
92 | * This method should be used only while processing IPC messages as the array size has to be negotiated in advance. |
93 | * @param strings The measured strings array to be transferred. Input parameter. |
93 | * @param strings The measured strings array to be transferred. Input parameter. |
94 | * @param count The measured strings array size. Input parameter. |
94 | * @param count The measured strings array size. Input parameter. |
95 | * @returns EOK on success. |
95 | * @returns EOK on success. |
96 | * @returns EINVAL if the strings parameter is NULL. |
96 | * @returns EINVAL if the strings parameter is NULL. |
97 | * @returns EINVAL if the count parameter is zero (0). |
97 | * @returns EINVAL if the count parameter is zero (0). |
98 | * @returns EINVAL if the calling module does not accept the given array size. |
98 | * @returns EINVAL if the calling module does not accept the given array size. |
99 | * @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur). |
99 | * @returns EINVAL if there is inconsistency in sent measured strings' lengths (should not occur). |
100 | * @returns Other error codes as defined for the ipc_data_read_finalize() function. |
100 | * @returns Other error codes as defined for the ipc_data_read_finalize() function. |
101 | */ |
101 | */ |
102 | int measured_strings_reply( const measured_string_ref strings, size_t count ); |
102 | int measured_strings_reply( const measured_string_ref strings, size_t count ); |
103 | 103 | ||
104 | /** Receives a measured strings array from another module. |
104 | /** Receives a measured strings array from another module. |
105 | * Creates the array and the data memory blocks. |
105 | * Creates the array and the data memory blocks. |
106 | * This method should be used only following other IPC messages as the array size has to be negotiated in advance. |
106 | * This method should be used only following other IPC messages as the array size has to be negotiated in advance. |
107 | * @param phone The other module phone. Input parameter. |
107 | * @param phone The other module phone. Input parameter. |
108 | * @param strings The returned measured strings array. Output parameter. |
108 | * @param strings The returned measured strings array. Output parameter. |
109 | * @param data The measured strings data. This memory block stores the actual character strings. Output parameter. |
109 | * @param data The measured strings data. This memory block stores the actual character strings. Output parameter. |
110 | * @param count The size of the measured strings array. Input parameter. |
110 | * @param count The size of the measured strings array. Input parameter. |
111 | * @returns EOK on success. |
111 | * @returns EOK on success. |
112 | * @returns EINVAL if the strings or data parameter is NULL. |
112 | * @returns EINVAL if the strings or data parameter is NULL. |
113 | * @returns EINVAL if the phone or count parameter is not positive (<=0). |
113 | * @returns EINVAL if the phone or count parameter is not positive (<=0). |
114 | * @returns EINVAL if the sent array differs in size. |
114 | * @returns EINVAL if the sent array differs in size. |
115 | * @returns ENOMEM if there is no memory left. |
115 | * @returns ENOMEM if there is no memory left. |
116 | * @returns Other error codes as defined for the ipc_data_read_start() function. |
116 | * @returns Other error codes as defined for the ipc_data_read_start() function. |
117 | */ |
117 | */ |
118 | int measured_strings_return( int phone, measured_string_ref * strings, char ** data, size_t count ); |
118 | int measured_strings_return( int phone, measured_string_ref * strings, char ** data, size_t count ); |
119 | 119 | ||
120 | /** Sends the given measured strings array to another module. |
120 | /** Sends the given measured strings array to another module. |
121 | * This method should be used only following other IPC messages as the array size has to be negotiated in advance. |
121 | * This method should be used only following other IPC messages as the array size has to be negotiated in advance. |
122 | * @param phone The other module phone. Input parameter. |
122 | * @param phone The other module phone. Input parameter. |
123 | * @param strings The measured strings array to be transferred. Input parameter. |
123 | * @param strings The measured strings array to be transferred. Input parameter. |
124 | * @param count The measured strings array size. Input parameter. |
124 | * @param count The measured strings array size. Input parameter. |
125 | * @returns EOK on success. |
125 | * @returns EOK on success. |
126 | * @returns EINVAL if the strings parameter is NULL. |
126 | * @returns EINVAL if the strings parameter is NULL. |
127 | * @returns EINVAL if the phone or count parameter is not positive (<=0). |
127 | * @returns EINVAL if the phone or count parameter is not positive (<=0). |
128 | * @returns Other error codes as defined for the ipc_data_write_start() function. |
128 | * @returns Other error codes as defined for the ipc_data_write_start() function. |
129 | */ |
129 | */ |
130 | int measured_strings_send( int phone, const measured_string_ref strings, size_t count ); |
130 | int measured_strings_send( int phone, const measured_string_ref strings, size_t count ); |
131 | 131 | ||
132 | #endif |
132 | #endif |
133 | 133 | ||
134 | /** @} |
134 | /** @} |
135 | */ |
135 | */ |
136 | 136 | ||
137 | 137 |