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

4.104.115
Last change on this file since 0893220 was 0893220, checked in by Ralf Corsepius <ralf.corsepius@…>, on 11/29/09 at 12:12:39

Whitespace removal.

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