1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Object ID to Name |
---|
5 | * @ingroup ScoreObject |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2010. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #include <string.h> |
---|
22 | |
---|
23 | #include <rtems/system.h> |
---|
24 | #include <rtems/score/address.h> |
---|
25 | #include <rtems/score/chain.h> |
---|
26 | #include <rtems/score/object.h> |
---|
27 | #if defined(RTEMS_MULTIPROCESSING) |
---|
28 | #include <rtems/score/objectmp.h> |
---|
29 | #endif |
---|
30 | #include <rtems/score/thread.h> |
---|
31 | #include <rtems/score/wkspace.h> |
---|
32 | #include <rtems/score/sysstate.h> |
---|
33 | #include <rtems/score/isr.h> |
---|
34 | |
---|
35 | #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES) |
---|
36 | Objects_Name_or_id_lookup_errors _Objects_Name_to_id_string( |
---|
37 | Objects_Information *information, |
---|
38 | const char *name, |
---|
39 | Objects_Id *id |
---|
40 | ) |
---|
41 | { |
---|
42 | Objects_Control *the_object; |
---|
43 | uint32_t index; |
---|
44 | |
---|
45 | /* ASSERT: information->is_string == true */ |
---|
46 | |
---|
47 | if ( !id ) |
---|
48 | return OBJECTS_INVALID_ADDRESS; |
---|
49 | |
---|
50 | if ( !name ) |
---|
51 | return OBJECTS_INVALID_NAME; |
---|
52 | |
---|
53 | if ( information->maximum != 0 ) { |
---|
54 | |
---|
55 | for ( index = 1; index <= information->maximum; index++ ) { |
---|
56 | the_object = information->local_table[ index ]; |
---|
57 | if ( !the_object ) |
---|
58 | continue; |
---|
59 | |
---|
60 | if ( !the_object->name.name_p ) |
---|
61 | continue; |
---|
62 | |
---|
63 | if (!strncmp( name, the_object->name.name_p, information->name_length)) { |
---|
64 | *id = the_object->id; |
---|
65 | return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL; |
---|
66 | } |
---|
67 | } |
---|
68 | } |
---|
69 | |
---|
70 | return OBJECTS_INVALID_NAME; |
---|
71 | } |
---|
72 | #endif |
---|