mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2026-09-21 16:14:29 +08:00
committed by
Joel Sherrill
parent
6b44911f4f
commit
534d5134dd
@@ -60,7 +60,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Obtain Pointer to BSP Boot Command String
|
||||
*
|
||||
@@ -70,7 +69,7 @@ extern "C" {
|
||||
*
|
||||
* @retval This method returns the pointer to the BSP Boot Command String.
|
||||
*/
|
||||
const char *rtems_bsp_cmdline_get(void);
|
||||
const char *rtems_bsp_cmdline_get( void );
|
||||
|
||||
/**
|
||||
* @brief Obtain COPY of the Entire Matching Argument
|
||||
@@ -96,7 +95,6 @@ const char *rtems_bsp_cmdline_get_param(
|
||||
size_t length
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Obtain COPY of the Right Hand Side of the Matching Argument
|
||||
*
|
||||
@@ -139,9 +137,7 @@ const char *rtems_bsp_cmdline_get_param_rhs(
|
||||
* @note The pointer will be to the original BSP Command
|
||||
* Line string. Exercise caution when using this.
|
||||
*/
|
||||
const char *rtems_bsp_cmdline_get_param_raw(
|
||||
const char *name
|
||||
);
|
||||
const char *rtems_bsp_cmdline_get_param_raw( const char *name );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
|
||||
extern const char *bsp_boot_cmdline;
|
||||
|
||||
const char *rtems_bsp_cmdline_get(void)
|
||||
const char *rtems_bsp_cmdline_get( void )
|
||||
{
|
||||
return bsp_boot_cmdline;
|
||||
}
|
||||
|
||||
@@ -40,26 +40,22 @@
|
||||
|
||||
#include <rtems/bspcmdline.h>
|
||||
|
||||
static void copy_string(
|
||||
const char *start,
|
||||
char *value,
|
||||
size_t length
|
||||
)
|
||||
static void copy_string( const char *start, char *value, size_t length )
|
||||
{
|
||||
size_t i;
|
||||
int quotes;
|
||||
const char *p = start;
|
||||
|
||||
quotes=0;
|
||||
for (i=0 ; *p && i<length-1; ) {
|
||||
quotes = 0;
|
||||
for ( i = 0; *p && i < length - 1; ) {
|
||||
if ( *p == '\"' ) {
|
||||
quotes++;
|
||||
} else if ( ((quotes % 2) == 0) && *p == ' ' )
|
||||
} else if ( ( ( quotes % 2 ) == 0 ) && *p == ' ' ) {
|
||||
break;
|
||||
value[i++] = *p++;
|
||||
value[i] = '\0';
|
||||
}
|
||||
value[ i++ ] = *p++;
|
||||
value[ i ] = '\0';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const char *rtems_bsp_cmdline_get_param(
|
||||
@@ -70,21 +66,25 @@ const char *rtems_bsp_cmdline_get_param(
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if ( !name )
|
||||
if ( !name ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( !value )
|
||||
if ( !value ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( !length )
|
||||
if ( !length ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
value[0] = '\0';
|
||||
value[ 0 ] = '\0';
|
||||
|
||||
p = rtems_bsp_cmdline_get_param_raw( name );
|
||||
|
||||
if ( !p )
|
||||
if ( !p ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
copy_string( p, value, length );
|
||||
|
||||
|
||||
@@ -44,19 +44,19 @@
|
||||
|
||||
extern const char *bsp_boot_cmdline;
|
||||
|
||||
const char *rtems_bsp_cmdline_get_param_raw(
|
||||
const char *name
|
||||
)
|
||||
const char *rtems_bsp_cmdline_get_param_raw( const char *name )
|
||||
{
|
||||
const char *p;
|
||||
|
||||
if ( !name )
|
||||
if ( !name ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( !bsp_boot_cmdline )
|
||||
if ( !bsp_boot_cmdline ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p = strstr(bsp_boot_cmdline, name);
|
||||
p = strstr( bsp_boot_cmdline, name );
|
||||
/* printf( "raw: %p (%s)\n", p, p ); */
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -53,20 +53,25 @@ const char *rtems_bsp_cmdline_get_param_rhs(
|
||||
char *d;
|
||||
|
||||
p = rtems_bsp_cmdline_get_param( name, value, length );
|
||||
if ( !p )
|
||||
if ( !p ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rhs = &p[strlen(name)];
|
||||
if ( *rhs != '=' )
|
||||
rhs = &p[ strlen( name ) ];
|
||||
if ( *rhs != '=' ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rhs++;
|
||||
if ( *rhs == '\"' )
|
||||
if ( *rhs == '\"' ) {
|
||||
rhs++;
|
||||
for ( d=value ; *rhs ; )
|
||||
}
|
||||
for ( d = value; *rhs; ) {
|
||||
*d++ = *rhs++;
|
||||
if ( *(d-1) == '\"' )
|
||||
}
|
||||
if ( *( d - 1 ) == '\"' ) {
|
||||
d--;
|
||||
}
|
||||
*d = '\0';
|
||||
|
||||
return value;
|
||||
|
||||
Reference in New Issue
Block a user