source: rtems/cpukit/score/src/objectnametoidstring.c @ e3f6d35

4.10
Last change on this file since e3f6d35 was dea1dc20, checked in by Ralf Corsepius <ralf.corsepius@…>, on 05/25/11 at 14:17:53

Cosmetics from CVS-HEAD.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  Object Handler - Object ID to Name (String)
3 *
4 *  COPYRIGHT (c) 1989-2010.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <string.h>
19
20#include <rtems/system.h>
21#include <rtems/score/address.h>
22#include <rtems/score/chain.h>
23#include <rtems/score/object.h>
24#if defined(RTEMS_MULTIPROCESSING)
25#include <rtems/score/objectmp.h>
26#endif
27#include <rtems/score/thread.h>
28#include <rtems/score/wkspace.h>
29#include <rtems/score/sysstate.h>
30#include <rtems/score/isr.h>
31
32#if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
33/*PAGE
34 *
35 *  _Objects_Name_to_id_string
36 *
37 *  These kernel routines search the object table(s) for the given
38 *  object name and returns the associated object id.
39 *
40 *  Input parameters:
41 *    information - object information
42 *    name        - user defined object name
43 *    id          - address of return ID
44 *
45 *  Output parameters:
46 *    id                                   - object id
47 *    OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL - if successful
48 *    error code                           - if unsuccessful
49 */
50
51Objects_Name_or_id_lookup_errors _Objects_Name_to_id_string(
52  Objects_Information *information,
53  const char          *name,
54  Objects_Id          *id
55)
56{
57  Objects_Control           *the_object;
58  uint32_t                   index;
59  uint32_t                   name_length;
60
61  /* ASSERT: information->is_string == true */
62
63  if ( !id )
64    return OBJECTS_INVALID_ADDRESS;
65
66  if ( !name )
67    return OBJECTS_INVALID_NAME;
68
69  if ( information->maximum != 0 ) {
70    name_length = information->name_length;
71
72    for ( index = 1; index <= information->maximum; index++ ) {
73      the_object = information->local_table[ index ];
74      if ( !the_object )
75        continue;
76
77      if ( !the_object->name.name_p )
78        continue;
79
80      if (!strncmp( name, the_object->name.name_p, information->name_length)) {
81        *id = the_object->id;
82        return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL;
83      }
84    }
85  }
86
87  return OBJECTS_INVALID_NAME;
88}
89#endif
Note: See TracBrowser for help on using the repository browser.