source: rtems/cpukit/libmisc/bspcmdline/bspcmdline_getparam.c @ b2bbdb9

4.104.115
Last change on this file since b2bbdb9 was b2bbdb9, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/27/10 at 05:01:30

Add HAVE_CONFIG_H support to let files receive configure defines.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/*
2 *  COPYRIGHT (c) 1989-2009.
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 *  $Id$
10 */
11
12#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/bspcmdline.h>
17
18static void copy_string(
19  const char *start,
20  char       *value,
21  size_t      length
22)
23{
24  int         i;
25  int         quotes;
26  const char *p = start;
27
28  quotes=0;
29  for (i=0 ; *p && i<length-1; ) {
30    if ( *p == '\"' ) {
31      quotes++;
32    } else if ( ((quotes % 2) == 0) && *p == ' ' )
33      break;
34    value[i++] = *p++;
35    value[i] = '\0';
36  }
37
38}
39
40const char *rtems_bsp_cmdline_get_param(
41  const char *name,
42  char       *value,
43  size_t      length
44)
45{
46  const char *p;
47
48  if ( !name )
49    return NULL;
50
51  if ( !value )
52    return NULL;
53
54  if ( !length )
55    return NULL;
56
57  value[0] = '\0';
58
59  p = rtems_bsp_cmdline_get_param_raw( name );
60
61  if ( !p )
62    return NULL;
63
64  copy_string( p, value, length );
65
66  return value;
67}
Note: See TracBrowser for help on using the repository browser.