1 | /* |
---|
2 | * Obtain Object Name Given ID |
---|
3 | * |
---|
4 | * |
---|
5 | * COPYRIGHT (c) 1989-2003. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.com/license/LICENSE. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #if HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include <rtems/system.h> |
---|
20 | #include <rtems/score/object.h> |
---|
21 | #include <rtems/score/thread.h> |
---|
22 | |
---|
23 | /*PAGE |
---|
24 | * |
---|
25 | * _Objects_Id_to_name |
---|
26 | * |
---|
27 | * DESCRIPTION: |
---|
28 | * |
---|
29 | * This routine returns the name associated with the given ID. |
---|
30 | * |
---|
31 | * INPUT: |
---|
32 | * |
---|
33 | * id - id of object to lookup name |
---|
34 | * name - pointer to location in which to store name |
---|
35 | * |
---|
36 | */ |
---|
37 | |
---|
38 | |
---|
39 | Objects_Name_or_id_lookup_errors _Objects_Id_to_name ( |
---|
40 | Objects_Id id, |
---|
41 | Objects_Name *name |
---|
42 | ) |
---|
43 | { |
---|
44 | uint32_t the_api; |
---|
45 | uint32_t the_class; |
---|
46 | Objects_Id tmpId; |
---|
47 | Objects_Information *information; |
---|
48 | Objects_Control *the_object = (Objects_Control *) 0; |
---|
49 | Objects_Locations ignored_location; |
---|
50 | |
---|
51 | if ( !name ) |
---|
52 | return OBJECTS_INVALID_NAME; |
---|
53 | |
---|
54 | tmpId = (id == OBJECTS_ID_OF_SELF) ? _Thread_Executing->Object.id : id; |
---|
55 | |
---|
56 | the_api = _Objects_Get_API( tmpId ); |
---|
57 | if ( !_Objects_Is_api_valid( the_api ) ) |
---|
58 | return OBJECTS_INVALID_ID; |
---|
59 | |
---|
60 | if ( !_Objects_Information_table[ the_api ] ) |
---|
61 | return OBJECTS_INVALID_ID; |
---|
62 | |
---|
63 | the_class = _Objects_Get_class( tmpId ); |
---|
64 | |
---|
65 | information = _Objects_Information_table[ the_api ][ the_class ]; |
---|
66 | if ( !information ) |
---|
67 | return OBJECTS_INVALID_ID; |
---|
68 | |
---|
69 | if ( information->is_string ) |
---|
70 | return OBJECTS_INVALID_ID; |
---|
71 | |
---|
72 | the_object = _Objects_Get( information, tmpId, &ignored_location ); |
---|
73 | if ( !the_object ) |
---|
74 | return OBJECTS_INVALID_ID; |
---|
75 | |
---|
76 | *name = the_object->name; |
---|
77 | _Thread_Enable_dispatch(); |
---|
78 | return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL; |
---|
79 | } |
---|