source: rtems/cpukit/score/src/objectnametoid.c @ fa6b0f5

4.104.114.84.95
Last change on this file since fa6b0f5 was a8eed23, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/27/05 at 05:57:05

Include config.h.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  Object Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
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
19#include <rtems/system.h>
20#include <rtems/score/address.h>
21#include <rtems/score/chain.h>
22#include <rtems/score/object.h>
23#if defined(RTEMS_MULTIPROCESSING)
24#include <rtems/score/objectmp.h>
25#endif
26#include <rtems/score/thread.h>
27#include <rtems/score/wkspace.h>
28#include <rtems/score/sysstate.h>
29#include <rtems/score/isr.h>
30
31/*PAGE
32 *
33 *  _Objects_Name_to_id
34 *
35 *  These kernel routines search the object table(s) for the given
36 *  object name and returns the associated object id.
37 *
38 *  Input parameters:
39 *    information - object information
40 *    name        - user defined object name
41 *    node        - node indentifier (0 indicates any node)
42 *    id          - address of return ID
43 *
44 *  Output parameters:
45 *    id                                   - object id
46 *    OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL - if successful
47 *    error code                           - if unsuccessful
48 */
49
50Objects_Name_or_id_lookup_errors _Objects_Name_to_id(
51  Objects_Information *information,
52  Objects_Name         name,
53  uint32_t             node,
54  Objects_Id          *id
55)
56{
57  boolean                    search_local_node;
58  Objects_Control           *the_object;
59  uint32_t                   index;
60  uint32_t                   name_length;
61  Objects_Name_comparators   compare_them;
62
63  if ( !id )
64    return OBJECTS_INVALID_ADDRESS;
65
66  if ( name == 0 )
67    return OBJECTS_INVALID_NAME;
68
69  search_local_node = FALSE;
70
71  if ( information->maximum != 0 &&
72      (node == OBJECTS_SEARCH_ALL_NODES || node == OBJECTS_SEARCH_LOCAL_NODE
73#if defined(RTEMS_MULTIPROCESSING)
74       || _Objects_Is_local_node( node )
75#endif
76      ))
77   search_local_node = TRUE;
78
79  if ( search_local_node ) {
80    name_length = information->name_length;
81
82    if ( information->is_string ) compare_them = _Objects_Compare_name_string;
83    else                          compare_them = _Objects_Compare_name_raw;
84
85    for ( index = 1; index <= information->maximum; index++ ) {
86      the_object = information->local_table[ index ];
87      if ( !the_object || !the_object->name )
88        continue;
89
90      if ( (*compare_them)( name, the_object->name, name_length ) ) {
91        *id = the_object->id;
92        return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
93      }
94    }
95  }
96
97#if defined(RTEMS_MULTIPROCESSING)
98  if ( _Objects_Is_local_node( node ) || node == OBJECTS_SEARCH_LOCAL_NODE )
99    return OBJECTS_INVALID_NAME;
100
101  return ( _Objects_MP_Global_name_search( information, name, node, id ) );
102#else
103  return OBJECTS_INVALID_NAME;
104#endif
105}
Note: See TracBrowser for help on using the repository browser.