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

Last change on this file since ac6e5c7 was ac6e5c7, checked in by Joel Sherrill <joel.sherrill@…>, on 05/17/11 at 19:31:16

2011-05-17 Joel Sherrill <joel.sherrill@…>

  • Makefile.am: Merge and update code. Simulators for Deterministic Priority and SMP Simple Schedulers now work.
  • run_scenarios: New file.
  • 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-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#ifdef HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <stdio.h>
19
20#include <rtems.h>
21#include <rtems/stringto.h>
22
23#ifndef METHOD_NAME
24  #define METHOD_NAME lookup_task
25#endif
26#ifndef RTEMS_IDENT_NAME
27  #define RTEMS_IDENT_NAME rtems_task_ident
28#endif
29
30int METHOD_NAME(
31  const char *string,
32  rtems_id   *id
33)
34{
35  char               name[5];
36  rtems_status_code  status;
37  unsigned long      tmp;
38
39  if ( string[0] != '0' ) {
40    if ( !strcmp( string, "SELF" ) ) {
41      *id = _Thread_Executing->Object.id;
42      return 0;
43    }
44    memset( name, '\0', sizeof(name) );
45    strncpy( name, string, 4 );
46    status = RTEMS_IDENT_NAME(
47      rtems_build_name( name[0], name[1], name[2], name[3] ),
48      OBJECTS_SEARCH_ALL_NODES,
49      id
50    );
51    if ( status != RTEMS_SUCCESSFUL )
52      return 1;
53  } else {
54    if ( rtems_string_to_unsigned_long( string, &tmp, NULL, 0) ) {
55      fprintf( stderr, "Argument (%s) is not a number\n", string );
56      return 1;
57    }
58    *id = (rtems_id) tmp;
59  }
60
61  return 0;
62}
Note: See TracBrowser for help on using the repository browser.