source: rtems/c/src/exec/score/src/objectnametoid.c @ 317a5b5

4.104.114.84.95
Last change on this file since 317a5b5 was 317a5b5, checked in by Joel Sherrill <joel.sherrill@…>, on 11/02/99 at 19:43:52

Split object.c into multiple files.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  Object Handler
3 *
4 *
5 *  COPYRIGHT (c) 1989-1998.
6 *  On-Line Applications Research Corporation (OAR).
7 *  Copyright assigned to U.S. Government, 1994.
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#include <rtems/system.h>
17#include <rtems/score/address.h>
18#include <rtems/score/chain.h>
19#include <rtems/score/object.h>
20#if defined(RTEMS_MULTIPROCESSING)
21#include <rtems/score/objectmp.h>
22#endif
23#include <rtems/score/thread.h>
24#include <rtems/score/wkspace.h>
25#include <rtems/score/sysstate.h>
26#include <rtems/score/isr.h>
27
28/*PAGE
29 *
30 *  _Objects_Name_to_id
31 *
32 *  These kernel routines search the object table(s) for the given
33 *  object name and returns the associated object id.
34 *
35 *  Input parameters:
36 *    information - object information
37 *    name        - user defined object name
38 *    node        - node indentifier (0 indicates any node)
39 *    id          - address of return ID
40 *
41 *  Output parameters:
42 *    id                 - object id
43 *    OBJECTS_SUCCESSFUL - if successful
44 *    error code         - if unsuccessful
45 */
46
47Objects_Name_to_id_errors _Objects_Name_to_id(
48  Objects_Information *information,
49  Objects_Name         name,
50  unsigned32           node,
51  Objects_Id          *id
52)
53{
54  boolean                    search_local_node;
55  Objects_Control           *the_object;
56  unsigned32                 index;
57  unsigned32                 name_length;
58  Objects_Name_comparators   compare_them;
59
60  if ( name == 0 )
61    return OBJECTS_INVALID_NAME;
62
63  search_local_node = FALSE;
64
65  if ( information->maximum != 0 &&
66      (node == OBJECTS_SEARCH_ALL_NODES || node == OBJECTS_SEARCH_LOCAL_NODE ||
67      _Objects_Is_local_node( node ) ) )
68   search_local_node = TRUE;
69
70  if ( search_local_node ) {
71    name_length = information->name_length;
72
73    if ( information->is_string ) compare_them = _Objects_Compare_name_string;
74    else                          compare_them = _Objects_Compare_name_raw;
75
76    for ( index = 1; index <= information->maximum; index++ ) {
77
78      the_object = information->local_table[ index ];
79
80      if ( !the_object || !the_object->name )
81        continue;
82
83      if ( (*compare_them)( name, the_object->name, name_length ) ) {
84        *id = the_object->id;
85        return OBJECTS_SUCCESSFUL;
86      }
87    }
88  }
89
90  if ( _Objects_Is_local_node( node ) || node == OBJECTS_SEARCH_LOCAL_NODE )
91    return OBJECTS_INVALID_NAME;
92
93#if defined(RTEMS_MULTIPROCESSING)
94  return ( _Objects_MP_Global_name_search( information, name, node, id ) );
95#else
96  return OBJECTS_INVALID_NAME;
97#endif
98}
Note: See TracBrowser for help on using the repository browser.