source: rtems/cpukit/score/src/objectnametoidstring.c @ 47988fb

4.104.115
Last change on this file since 47988fb was 47988fb, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 11, 2009 at 2:54:29 PM

2009-09-11 Joel Sherrill <joel.sherrill@…>

  • score/include/rtems/score/object.h, score/inline/rtems/score/object.inl, score/src/objectgetnameasstring.c, score/src/objectidtoname.c, score/src/objectinitializeinformation.c, score/src/objectnamespaceremove.c, score/src/objectnametoidstring.c, score/src/objectsetname.c, score/src/thread.c, score/src/threadcreateidle.c: Disable object string name support when POSIX is not enabled.
  • Property mode set to 100644
File size: 2.2 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#if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
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
52Objects_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
62  /* ASSERT: information->is_string == true */
63
64  if ( !id )
65    return OBJECTS_INVALID_ADDRESS;
66
67  if ( !name )
68    return OBJECTS_INVALID_NAME;
69
70  if ( information->maximum != 0 ) {
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}
90#endif
Note: See TracBrowser for help on using the repository browser.