Changeset 61bfc370 in mainline for uspace/lib
- Timestamp:
- 2011-01-07T18:57:55Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e08a733
- Parents:
- 7c34b28f
- Location:
- uspace/lib
- Files:
-
- 18 edited
-
c/generic/adt/char_map.c (modified) (6 diffs)
-
c/generic/adt/measured_strings.c (modified) (6 diffs)
-
c/generic/mem.c (modified) (1 diff)
-
c/include/adt/char_map.h (modified) (3 diffs)
-
c/include/adt/generic_char_map.h (modified) (4 diffs)
-
c/include/adt/measured_strings.h (modified) (1 diff)
-
c/include/mem.h (modified) (1 diff)
-
net/adt/module_map.c (modified) (4 diffs)
-
net/generic/generic.c (modified) (2 diffs)
-
net/generic/net_remote.c (modified) (3 diffs)
-
net/il/arp_remote.c (modified) (1 diff)
-
net/include/adt/module_map.h (modified) (1 diff)
-
net/include/arp_interface.h (modified) (1 diff)
-
net/include/generic.h (modified) (1 diff)
-
net/include/net_interface.h (modified) (1 diff)
-
net/include/socket_core.h (modified) (2 diffs)
-
net/netif/netif_local.c (modified) (1 diff)
-
net/tl/socket_core.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/adt/char_map.c
r7c34b28f r61bfc370 65 65 */ 66 66 static int 67 char_map_add_item(char_map_t *map, const char*identifier, size_t length,67 char_map_add_item(char_map_t *map, const uint8_t *identifier, size_t length, 68 68 const int value) 69 69 { … … 139 139 */ 140 140 int 141 char_map_add(char_map_t *map, const char*identifier, size_t length,141 char_map_add(char_map_t *map, const uint8_t *identifier, size_t length, 142 142 const int value) 143 143 { … … 200 200 */ 201 201 static char_map_t * 202 char_map_find_node(const char_map_t *map, const char*identifier,202 char_map_find_node(const char_map_t *map, const uint8_t *identifier, 203 203 size_t length) 204 204 { … … 241 241 * @return CHAR_MAP_NULL if the key is not assigned a value. 242 242 */ 243 int char_map_exclude(char_map_t *map, const char*identifier, size_t length)243 int char_map_exclude(char_map_t *map, const uint8_t *identifier, size_t length) 244 244 { 245 245 char_map_t *node; … … 269 269 * @return CHAR_MAP_NULL if the key is not assigned a value. 270 270 */ 271 int char_map_find(const char_map_t *map, const char*identifier, size_t length)271 int char_map_find(const char_map_t *map, const uint8_t *identifier, size_t length) 272 272 { 273 273 char_map_t *node; … … 329 329 */ 330 330 int 331 char_map_update(char_map_t *map, const char*identifier, const size_t length,331 char_map_update(char_map_t *map, const uint8_t *identifier, const size_t length, 332 332 const int value) 333 333 { -
uspace/lib/c/generic/adt/measured_strings.c
r7c34b28f r61bfc370 59 59 */ 60 60 measured_string_t * 61 measured_string_create_bulk(const char*string, size_t length)61 measured_string_create_bulk(const uint8_t *string, size_t length) 62 62 { 63 63 measured_string_t *new; … … 68 68 } 69 69 new = (measured_string_t *) malloc(sizeof(measured_string_t) + 70 (sizeof( char) * (length + 1)));70 (sizeof(uint8_t) * (length + 1))); 71 71 if (!new) 72 72 return NULL; 73 73 74 74 new->length = length; 75 new->value = (( char*) new) + sizeof(measured_string_t);75 new->value = ((uint8_t *) new) + sizeof(measured_string_t); 76 76 // append terminating zero explicitly - to be safe 77 77 memcpy(new->value, string, new->length); … … 97 97 new = (measured_string_t *) malloc(sizeof(measured_string_t)); 98 98 if (new) { 99 new->value = ( char*) malloc(source->length + 1);99 new->value = (uint8_t *) malloc(source->length + 1); 100 100 if (new->value) { 101 101 new->length = source->length; … … 131 131 */ 132 132 int 133 measured_strings_receive(measured_string_t **strings, char**data,133 measured_strings_receive(measured_string_t **strings, uint8_t **data, 134 134 size_t count) 135 135 { … … 137 137 size_t index; 138 138 size_t length; 139 char*next;139 uint8_t *next; 140 140 ipc_callid_t callid; 141 141 int rc; … … 311 311 */ 312 312 int 313 measured_strings_return(int phone, measured_string_t **strings, char**data,313 measured_strings_return(int phone, measured_string_t **strings, uint8_t **data, 314 314 size_t count) 315 315 { 316 316 size_t *lengths; 317 317 size_t index; 318 char*next;318 uint8_t *next; 319 319 int rc; 320 320 -
uspace/lib/c/generic/mem.c
r7c34b28f r61bfc370 222 222 /** Compare two memory areas. 223 223 * 224 * @param s1 Pointer to the first area to compare. 225 * @param s2 Pointer to the second area to compare. 226 * @param len Size of the first area in bytes. Both areas must have 227 * the same length. 228 * @return If len is 0, return zero. If the areas match, return 229 * zero. Otherwise return non-zero. 230 */ 231 int bcmp(const char *s1, const char *s2, size_t len) 232 { 233 for (; len && *s1++ == *s2++; len--) 234 ; 224 * @param s1 Pointer to the first area to compare. 225 * @param s2 Pointer to the second area to compare. 226 * @param len Size of the first area in bytes. Both areas must have 227 * the same length. 228 * 229 * @return If len is 0, return zero. If the areas match, return 230 * zero. Otherwise return non-zero. 231 * 232 */ 233 int bcmp(const void *s1, const void *s2, size_t len) 234 { 235 uint8_t *u1 = (uint8_t *) s1; 236 uint8_t *u2 = (uint8_t *) s2; 237 238 for (; (len != 0) && (*u1++ == *u2++); len--); 239 235 240 return len; 236 241 } -
uspace/lib/c/include/adt/char_map.h
r7c34b28f r61bfc370 41 41 42 42 /** Invalid assigned value used also if an entry does not exist. */ 43 #define CHAR_MAP_NULL (-1)43 #define CHAR_MAP_NULL (-1) 44 44 45 45 /** Type definition of the character string to integer map. 46 46 * @see char_map 47 47 */ 48 typedef struct char_map char_map_t;48 typedef struct char_map char_map_t; 49 49 50 50 /** Character string to integer map item. … … 56 56 struct char_map { 57 57 /** Actually mapped character. */ 58 charc;58 uint8_t c; 59 59 /** Stored integral value. */ 60 60 int value; … … 71 71 extern int char_map_initialize(char_map_t *); 72 72 extern void char_map_destroy(char_map_t *); 73 extern int char_map_exclude(char_map_t *, const char*, size_t);74 extern int char_map_add(char_map_t *, const char*, size_t, const int);75 extern int char_map_find(const char_map_t *, const char*, size_t);76 extern int char_map_update(char_map_t *, const char*, size_t, const int);73 extern int char_map_exclude(char_map_t *, const uint8_t *, size_t); 74 extern int char_map_add(char_map_t *, const uint8_t *, size_t, const int); 75 extern int char_map_find(const char_map_t *, const uint8_t *, size_t); 76 extern int char_map_update(char_map_t *, const uint8_t *, size_t, const int); 77 77 78 78 #endif -
uspace/lib/c/include/adt/generic_char_map.h
r7c34b28f r61bfc370 62 62 }; \ 63 63 \ 64 int name##_add(name##_t *, const char*, const size_t, type *); \64 int name##_add(name##_t *, const uint8_t *, const size_t, type *); \ 65 65 int name##_count(name##_t *); \ 66 66 void name##_destroy(name##_t *); \ 67 void name##_exclude(name##_t *, const char*, const size_t); \68 type *name##_find(name##_t *, const char*, const size_t); \67 void name##_exclude(name##_t *, const uint8_t *, const size_t); \ 68 type *name##_find(name##_t *, const uint8_t *, const size_t); \ 69 69 int name##_initialize(name##_t *); \ 70 70 int name##_is_valid(name##_t *); … … 74 74 * Should follow declaration with the same parameters. 75 75 * 76 * @param[in] name Name of the map. 77 * @param[in] type Inner object type. 76 * @param[in] name Name of the map. 77 * @param[in] type Inner object type. 78 * 78 79 */ 79 80 #define GENERIC_CHAR_MAP_IMPLEMENT(name, type) \ 80 81 GENERIC_FIELD_IMPLEMENT(name##_items, type) \ 81 82 \ 82 int name##_add(name##_t *map, const char*name, const size_t length, \83 int name##_add(name##_t *map, const uint8_t *name, const size_t length, \ 83 84 type *value) \ 84 85 { \ … … 112 113 } \ 113 114 \ 114 void name##_exclude(name##_t *map, const char*name, \115 void name##_exclude(name##_t *map, const uint8_t *name, \ 115 116 const size_t length) \ 116 117 { \ … … 124 125 } \ 125 126 \ 126 type *name##_find(name##_t *map, const char*name, \127 type *name##_find(name##_t *map, const uint8_t *name, \ 127 128 const size_t length) \ 128 129 { \ -
uspace/lib/c/include/adt/measured_strings.h
r7c34b28f r61bfc370 54 54 struct measured_string { 55 55 /** Character string data. */ 56 char*value;56 uint8_t *value; 57 57 /** Character string length. */ 58 58 size_t length; 59 59 }; 60 60 61 extern measured_string_t *measured_string_create_bulk(const char*, size_t);61 extern measured_string_t *measured_string_create_bulk(const uint8_t *, size_t); 62 62 extern measured_string_t *measured_string_copy(measured_string_t *); 63 extern int measured_strings_receive(measured_string_t **, char**, size_t);63 extern int measured_strings_receive(measured_string_t **, uint8_t **, size_t); 64 64 extern int measured_strings_reply(const measured_string_t *, size_t); 65 extern int measured_strings_return(int, measured_string_t **, char**, size_t);65 extern int measured_strings_return(int, measured_string_t **, uint8_t **, size_t); 66 66 extern int measured_strings_send(int, const measured_string_t *, size_t); 67 67 -
uspace/lib/c/include/mem.h
r7c34b28f r61bfc370 44 44 extern void *memmove(void *, const void *, size_t); 45 45 46 extern int bcmp(const char *, const char*, size_t);46 extern int bcmp(const void *, const void *, size_t); 47 47 48 48 #endif -
uspace/lib/net/adt/module_map.c
r7c34b28f r61bfc370 63 63 */ 64 64 int 65 add_module(module_t **module, modules_t *modules, const char*name,66 const char*filename, services_t service, task_id_t task_id,65 add_module(module_t **module, modules_t *modules, const uint8_t *name, 66 const uint8_t *filename, services_t service, task_id_t task_id, 67 67 connect_module_t connect_module) 68 68 { … … 104 104 * @return NULL if there is no such module. 105 105 */ 106 module_t *get_running_module(modules_t *modules, char*name)106 module_t *get_running_module(modules_t *modules, uint8_t *name) 107 107 { 108 108 module_t *module; … … 113 113 114 114 if (!module->task_id) { 115 module->task_id = spawn(module->filename);115 module->task_id = net_spawn(module->filename); 116 116 if (!module->task_id) 117 117 return NULL; … … 123 123 } 124 124 125 /** Start sthe given module.125 /** Start the given module. 126 126 * 127 * @param[in] fname The module full or relative path filename. 128 * @return The new module task identifier on success. 129 * @return Zero if there is no such module. 127 * @param[in] fname The module full or relative path filename. 128 * 129 * @return The new module task identifier on success. 130 * @return Zero if there is no such module. 131 * 130 132 */ 131 task_id_t spawn(const char*fname)133 task_id_t net_spawn(const uint8_t *fname) 132 134 { 133 135 task_id_t id; 134 136 int rc; 135 137 136 rc = task_spawnl(&id, fname,fname, NULL);138 rc = task_spawnl(&id, (const char *) fname, (const char *) fname, NULL); 137 139 if (rc != EOK) 138 140 return 0; -
uspace/lib/net/generic/generic.c
r7c34b28f r61bfc370 112 112 message_id = async_send_1(phone, (sysarg_t) message, 113 113 (sysarg_t) device_id, NULL); 114 string = measured_strings_return(phone, address, (char **)data, 1);114 string = measured_strings_return(phone, address, data, 1); 115 115 async_wait_for(message_id, &result); 116 116 … … 234 234 generic_translate_req(int phone, int message, device_id_t device_id, 235 235 services_t service, measured_string_t *configuration, size_t count, 236 measured_string_t **translation, char**data)236 measured_string_t **translation, uint8_t **data) 237 237 { 238 238 aid_t message_id; -
uspace/lib/net/generic/net_remote.c
r7c34b28f r61bfc370 63 63 * @see net_get_conf_req() 64 64 */ 65 void net_free_settings(measured_string_t *settings, char*data)65 void net_free_settings(measured_string_t *settings, uint8_t *data) 66 66 { 67 67 if (settings) … … 91 91 int 92 92 net_get_conf_req(int net_phone, measured_string_t **configuration, 93 size_t count, char**data)93 size_t count, uint8_t **data) 94 94 { 95 95 return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, 0, 0, … … 118 118 int 119 119 net_get_device_conf_req(int net_phone, device_id_t device_id, 120 measured_string_t **configuration, size_t count, char**data)120 measured_string_t **configuration, size_t count, uint8_t **data) 121 121 { 122 122 return generic_translate_req(net_phone, NET_NET_GET_DEVICE_CONF, -
uspace/lib/net/il/arp_remote.c
r7c34b28f r61bfc370 165 165 int 166 166 arp_translate_req(int arp_phone, device_id_t device_id, services_t protocol, 167 measured_string_t *address, measured_string_t **translation, char**data)167 measured_string_t *address, measured_string_t **translation, uint8_t **data) 168 168 { 169 169 return generic_translate_req(arp_phone, NET_ARP_TRANSLATE, device_id, -
uspace/lib/net/include/adt/module_map.h
r7c34b28f r61bfc370 65 65 int usage; 66 66 /** Module name. */ 67 const char*name;67 const uint8_t *name; 68 68 /** Module full path filename. */ 69 const char*filename;69 const uint8_t *filename; 70 70 /** Connecting function. */ 71 71 connect_module_t *connect_module; 72 72 }; 73 73 74 extern int add_module(module_t **, modules_t *, const char *, const char*,75 services_t, task_id_t, connect_module_t *);76 extern module_t *get_running_module(modules_t *, char*);77 extern task_id_t spawn(const char*);74 extern int add_module(module_t **, modules_t *, const uint8_t *, 75 const uint8_t *, services_t, task_id_t, connect_module_t *); 76 extern module_t *get_running_module(modules_t *, uint8_t *); 77 extern task_id_t net_spawn(const uint8_t *); 78 78 79 79 #endif -
uspace/lib/net/include/arp_interface.h
r7c34b28f r61bfc370 50 50 measured_string_t *); 51 51 extern int arp_translate_req(int, device_id_t, services_t, measured_string_t *, 52 measured_string_t **, char**);52 measured_string_t **, uint8_t **); 53 53 extern int arp_clear_device_req(int, device_id_t); 54 54 extern int arp_clear_address_req(int, device_id_t, services_t, -
uspace/lib/net/include/generic.h
r7c34b28f r61bfc370 58 58 services_t, services_t); 59 59 extern int generic_translate_req(int, int, device_id_t, services_t, 60 measured_string_t *, size_t, measured_string_t **, char**);60 measured_string_t *, size_t, measured_string_t **, uint8_t **); 61 61 62 62 #endif -
uspace/lib/net/include/net_interface.h
r7c34b28f r61bfc370 45 45 46 46 extern int net_get_device_conf_req(int, device_id_t, measured_string_t **, 47 size_t, char**);48 extern int net_get_conf_req(int, measured_string_t **, size_t, char**);49 extern void net_free_settings(measured_string_t *, char*);47 size_t, uint8_t **); 48 extern int net_get_conf_req(int, measured_string_t **, size_t, uint8_t **); 49 extern void net_free_settings(measured_string_t *, uint8_t *); 50 50 extern int net_connect_module(void); 51 51 -
uspace/lib/net/include/socket_core.h
r7c34b28f r61bfc370 86 86 void *specific_data; 87 87 /** Socket ports map key. */ 88 const char*key;88 const uint8_t *key; 89 89 /** Length of the Socket ports map key. */ 90 90 size_t key_length; … … 118 118 void (*)(socket_core_t *)); 119 119 extern int socket_reply_packets(packet_t *, size_t *); 120 extern socket_core_t *socket_port_find(socket_ports_t *, int, const char*,120 extern socket_core_t *socket_port_find(socket_ports_t *, int, const uint8_t *, 121 121 size_t); 122 122 extern void socket_port_release(socket_ports_t *, socket_core_t *); 123 123 extern int socket_port_add(socket_ports_t *, int, socket_core_t *, 124 const char*, size_t);124 const uint8_t *, size_t); 125 125 126 126 #endif -
uspace/lib/net/netif/netif_local.c
r7c34b28f r61bfc370 221 221 fibril_rwlock_read_unlock(&netif_globals.lock); 222 222 223 *data = ( uint8_t *) (**address).value;223 *data = (**address).value; 224 224 225 225 return rc; -
uspace/lib/net/tl/socket_core.c
r7c34b28f r61bfc370 161 161 static int 162 162 socket_port_add_core(socket_port_t *socket_port, socket_core_t *socket, 163 const char*key, size_t key_length)163 const uint8_t *key, size_t key_length) 164 164 { 165 165 socket_core_t **socket_ref; … … 216 216 goto fail; 217 217 218 rc = socket_port_add_core(socket_port, socket, SOCKET_MAP_KEY_LISTENING,219 0);218 rc = socket_port_add_core(socket_port, socket, 219 (const uint8_t *) SOCKET_MAP_KEY_LISTENING, 0); 220 220 if (rc != EOK) 221 221 goto fail; … … 602 602 */ 603 603 socket_core_t * 604 socket_port_find(socket_ports_t *global_sockets, int port, const char*key,604 socket_port_find(socket_ports_t *global_sockets, int port, const uint8_t *key, 605 605 size_t key_length) 606 606 { … … 680 680 int 681 681 socket_port_add(socket_ports_t *global_sockets, int port, 682 socket_core_t *socket, const char*key, size_t key_length)682 socket_core_t *socket, const uint8_t *key, size_t key_length) 683 683 { 684 684 socket_port_t *socket_port;
Note:
See TracChangeset
for help on using the changeset viewer.
