source: rtems-schedsim/schedsim/shell/shared/lookup_task.c @ b38dbcc

Last change on this file since b38dbcc was b38dbcc, checked in by Joel Sherrill <joel.sherrill@…>, on 05/14/14 at 14:55:21

Many files: rm white space at EOL and EOF

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  Given Name or ID String, give Id
3 *
4 *  COPYRIGHT (c) 1989-2013.
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
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <stdio.h>
17
18#include <rtems.h>
19#include <rtems/stringto.h>
20
21#ifndef METHOD_NAME
22  #define METHOD_NAME lookup_task
23#endif
24#ifndef RTEMS_IDENT_NAME
25  #define RTEMS_IDENT_NAME rtems_task_ident
26#endif
27
28int METHOD_NAME(
29  const char *string,
30  rtems_id   *id
31)
32{
33  char               name[5];
34  rtems_status_code  status;
35  unsigned long      tmp;
36
37  if ( string[0] != '0' ) {
38    if ( !strcmp( string, "SELF" ) ) {
39      *id = _Thread_Executing->Object.id;
40      return 0;
41    }
42    memset( name, '\0', sizeof(name) );
43    strncpy( name, string, 4 );
44    status = RTEMS_IDENT_NAME(
45      rtems_build_name( name[0], name[1], name[2], name[3] ),
46      OBJECTS_SEARCH_ALL_NODES,
47      id
48    );
49    if ( status != RTEMS_SUCCESSFUL )
50      return 1;
51  } else {
52    if ( rtems_string_to_unsigned_long( string, &tmp, NULL, 0) ) {
53      fprintf( stderr, "Argument (%s) is not a number\n", string );
54      return 1;
55    }
56    *id = (rtems_id) tmp;
57  }
58
59  return 0;
60}
Note: See TracBrowser for help on using the repository browser.