source: rtems/cpukit/score/src/objectgetnameasstring.c @ 2d7ae960

4.115
Last change on this file since 2d7ae960 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2008.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 */
9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
14#include <rtems/system.h>
15#include <rtems/score/object.h>
16#include <rtems/score/thread.h>
17#include <stdlib.h>
18#include <ctype.h>
19#include <inttypes.h>
20
21/*
22 *  This method objects the name of an object and returns its name
23 *  in the form of a C string.  It attempts to be careful about
24 *  overflowing the user's string and about returning unprintable characters.
25 */
26
27char *_Objects_Get_name_as_string(
28  Objects_Id        id,
29  size_t            length,
30  char             *name
31)
32{
33  Objects_Information   *information;
34  const char            *s;
35  char                  *d;
36  uint32_t               i;
37  char                   lname[5];
38  Objects_Control       *the_object;
39  Objects_Locations      location;
40  Objects_Id             tmpId;
41
42  if ( length == 0 )
43    return NULL;
44
45  if ( name == NULL )
46    return NULL;
47
48  tmpId = (id == OBJECTS_ID_OF_SELF) ? _Thread_Executing->Object.id : id;
49
50  information = _Objects_Get_information_id( tmpId );
51  if ( !information )
52    return NULL;
53
54  the_object = _Objects_Get( information, tmpId, &location );
55  switch ( location ) {
56
57#if defined(RTEMS_MULTIPROCESSING)
58    case OBJECTS_REMOTE:
59      /* not supported */
60#endif
61    case OBJECTS_ERROR:
62      return NULL;
63
64    case OBJECTS_LOCAL:
65
66      #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
67        if ( information->is_string ) {
68          s = the_object->name.name_p;
69        } else
70      #endif
71      {
72        uint32_t  u32_name = (uint32_t) the_object->name.name_u32;
73
74        lname[ 0 ] = (u32_name >> 24) & 0xff;
75        lname[ 1 ] = (u32_name >> 16) & 0xff;
76        lname[ 2 ] = (u32_name >>  8) & 0xff;
77        lname[ 3 ] = (u32_name >>  0) & 0xff;
78        lname[ 4 ] = '\0';
79        s = lname;
80      }
81
82      d = name;
83      if ( s ) {
84        for ( i=0 ; i<(length-1) && *s ; i++, s++, d++ ) {
85          *d = (isprint((unsigned char)*s)) ? *s : '*';
86        }
87      }
88      *d = '\0';
89
90      _Thread_Enable_dispatch();
91      return name;
92  }
93  return NULL;                  /* unreachable path */
94}
Note: See TracBrowser for help on using the repository browser.