[f3a5a20c] | 1 | /* |
---|
| 2 | * Object Handler - Object ID to Name (String) |
---|
| 3 | * |
---|
| 4 | * |
---|
| 5 | * COPYRIGHT (c) 1989-2008. |
---|
| 6 | * On-Line Applications Research Corporation (OAR). |
---|
| 7 | * |
---|
| 8 | * The license and distribution terms for this file may be |
---|
| 9 | * 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 | |
---|
[47988fb] | 19 | #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES) |
---|
[f3a5a20c] | 20 | #include <string.h> |
---|
| 21 | |
---|
| 22 | #include <rtems/system.h> |
---|
| 23 | #include <rtems/score/address.h> |
---|
| 24 | #include <rtems/score/chain.h> |
---|
| 25 | #include <rtems/score/object.h> |
---|
| 26 | #if defined(RTEMS_MULTIPROCESSING) |
---|
| 27 | #include <rtems/score/objectmp.h> |
---|
| 28 | #endif |
---|
| 29 | #include <rtems/score/thread.h> |
---|
| 30 | #include <rtems/score/wkspace.h> |
---|
| 31 | #include <rtems/score/sysstate.h> |
---|
| 32 | #include <rtems/score/isr.h> |
---|
| 33 | |
---|
| 34 | /*PAGE |
---|
| 35 | * |
---|
| 36 | * _Objects_Name_to_id_string |
---|
| 37 | * |
---|
| 38 | * These kernel routines search the object table(s) for the given |
---|
| 39 | * object name and returns the associated object id. |
---|
| 40 | * |
---|
| 41 | * Input parameters: |
---|
| 42 | * information - object information |
---|
| 43 | * name - user defined object name |
---|
| 44 | * id - address of return ID |
---|
| 45 | * |
---|
| 46 | * Output parameters: |
---|
| 47 | * id - object id |
---|
| 48 | * OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL - if successful |
---|
| 49 | * error code - if unsuccessful |
---|
| 50 | */ |
---|
| 51 | |
---|
| 52 | Objects_Name_or_id_lookup_errors _Objects_Name_to_id_string( |
---|
| 53 | Objects_Information *information, |
---|
| 54 | const char *name, |
---|
| 55 | Objects_Id *id |
---|
| 56 | ) |
---|
| 57 | { |
---|
| 58 | Objects_Control *the_object; |
---|
| 59 | uint32_t index; |
---|
| 60 | uint32_t name_length; |
---|
| 61 | |
---|
[aae7f1a1] | 62 | /* ASSERT: information->is_string == true */ |
---|
[f3a5a20c] | 63 | |
---|
| 64 | if ( !id ) |
---|
| 65 | return OBJECTS_INVALID_ADDRESS; |
---|
| 66 | |
---|
| 67 | if ( !name ) |
---|
| 68 | return OBJECTS_INVALID_NAME; |
---|
| 69 | |
---|
[74d0cb44] | 70 | if ( information->maximum != 0 ) { |
---|
[f3a5a20c] | 71 | name_length = information->name_length; |
---|
| 72 | |
---|
| 73 | for ( index = 1; index <= information->maximum; index++ ) { |
---|
| 74 | the_object = information->local_table[ index ]; |
---|
| 75 | if ( !the_object ) |
---|
| 76 | continue; |
---|
| 77 | |
---|
| 78 | if ( !the_object->name.name_p ) |
---|
| 79 | continue; |
---|
| 80 | |
---|
| 81 | if (!strncmp( name, the_object->name.name_p, information->name_length)) { |
---|
| 82 | *id = the_object->id; |
---|
| 83 | return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL; |
---|
| 84 | } |
---|
| 85 | } |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | return OBJECTS_INVALID_NAME; |
---|
| 89 | } |
---|
[47988fb] | 90 | #endif |
---|