source: rtems/cpukit/score/src/objectnametoidstring.c @ 6dad79f

4.104.115
Last change on this file since 6dad79f was aae7f1a1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 12/22/08 at 05:52:32

Eliminate TRUE/FALSE.

  • Property mode set to 100644
File size: 2.1 KB
Line 
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
19#include <string.h>
20
21#include <rtems/system.h>
22#include <rtems/score/address.h>
23#include <rtems/score/chain.h>
24#include <rtems/score/object.h>
25#if defined(RTEMS_MULTIPROCESSING)
26#include <rtems/score/objectmp.h>
27#endif
28#include <rtems/score/thread.h>
29#include <rtems/score/wkspace.h>
30#include <rtems/score/sysstate.h>
31#include <rtems/score/isr.h>
32
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}
Note: See TracBrowser for help on using the repository browser.