summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-23 14:32:34 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-23 14:32:34 +0000
commit48751ab095bbbb23489c2e3243f57571cbfa9153 (patch)
tree7a15647c01c3acdb2d1c61142bb13616ad03a2aa /cpukit/libmisc
parent2009-07-23 Santosh G Vattam <vattam.santosh@gmail.com> (diff)
downloadrtems-48751ab095bbbb23489c2e3243f57571cbfa9153.tar.bz2
2009-07-23 Joel Sherrill <joel.sherrill@oarcorp.com>
* libmisc/Makefile.am, libmisc/shell/main_chmod.c, libmisc/shell/main_mdump.c, libmisc/shell/main_medit.c, libmisc/shell/main_mfill.c, libmisc/shell/main_mmove.c, libmisc/shell/main_msdosfmt.c, libmisc/shell/main_mwdump.c, libmisc/shell/main_sleep.c, libmisc/shell/main_umask.c, libmisc/shell/shell_script.c, libmisc/stringto/stringto.h, libmisc/stringto/stringto_template.h: Convert return type from bool to rtems_status_code and add rtems_string_to_pointer. Perform associated clean up and changes for return type change. * libmisc/stringto/stringtopointer.c: New file.
Diffstat (limited to 'cpukit/libmisc')
-rw-r--r--cpukit/libmisc/Makefile.am1
-rw-r--r--cpukit/libmisc/shell/main_chmod.c2
-rw-r--r--cpukit/libmisc/shell/main_mdump.c21
-rw-r--r--cpukit/libmisc/shell/main_medit.c8
-rw-r--r--cpukit/libmisc/shell/main_mfill.c17
-rw-r--r--cpukit/libmisc/shell/main_mmove.c18
-rw-r--r--cpukit/libmisc/shell/main_msdosfmt.c4
-rw-r--r--cpukit/libmisc/shell/main_mwdump.c12
-rw-r--r--cpukit/libmisc/shell/main_sleep.c4
-rw-r--r--cpukit/libmisc/shell/main_umask.c2
-rw-r--r--cpukit/libmisc/shell/shell_script.c4
-rw-r--r--cpukit/libmisc/stringto/stringto.h78
-rw-r--r--cpukit/libmisc/stringto/stringto_template.h41
-rw-r--r--cpukit/libmisc/stringto/stringtopointer.c25
14 files changed, 151 insertions, 86 deletions
diff --git a/cpukit/libmisc/Makefile.am b/cpukit/libmisc/Makefile.am
index 871d9abcb3..8b9f373e41 100644
--- a/cpukit/libmisc/Makefile.am
+++ b/cpukit/libmisc/Makefile.am
@@ -131,6 +131,7 @@ noinst_LIBRARIES += libstringto.a
libstringto_a_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/stringto
libstringto_a_SOURCES = stringto/stringtodouble.c stringto/stringtofloat.c \
stringto/stringtoint.c stringto/stringtolong.c stringto/stringtolonglong.c \
+ stringto/stringtopointer.c stringto/stringtounsignedint.c \
stringto/stringtounsignedchar.c stringto/stringtounsignedint.c \
stringto/stringtounsignedlong.c stringto/stringtounsignedlonglong.c
diff --git a/cpukit/libmisc/shell/main_chmod.c b/cpukit/libmisc/shell/main_chmod.c
index 14e744255c..3c6ae68310 100644
--- a/cpukit/libmisc/shell/main_chmod.c
+++ b/cpukit/libmisc/shell/main_chmod.c
@@ -45,7 +45,7 @@ int rtems_shell_main_chmod(
/*
* Convert arguments into numbers
*/
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
printf( "Mode argument (%s) is not a number\n", argv[1] );
return -1;
}
diff --git a/cpukit/libmisc/shell/main_mdump.c b/cpukit/libmisc/shell/main_mdump.c
index 9d597a9436..297ab6db0e 100644
--- a/cpukit/libmisc/shell/main_mdump.c
+++ b/cpukit/libmisc/shell/main_mdump.c
@@ -31,34 +31,30 @@ int rtems_shell_main_mdump(
char *argv[]
)
{
- unsigned long tmp;
unsigned char n;
unsigned char m;
int max;
int res;
- uintptr_t addr = 0;
+ void *addr = NULL;
unsigned char *pb;
if (argc > 1) {
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_pointer(argv[1], &addr, NULL) ) {
printf( "Address argument (%s) is not a number\n", argv[1] );
return -1;
}
- addr = (uintptr_t) tmp;
}
- if (argc>2) {
- if ( !rtems_string_to_int(argv[1], &max, NULL, 0) ) {
+ if (argc > 2) {
+ if ( rtems_string_to_int(argv[1], &max, NULL, 0) ) {
printf( "Length argument (%s) is not a number\n", argv[1] );
return -1;
}
- addr = (uintptr_t) tmp;
if (max <= 0) {
max = 1; /* print 1 item if 0 or neg. */
res = 0;
- }
- else {
+ } else {
max--;
res = max & 0xf;/* num bytes in last row */
max >>= 4; /* div by 16 */
@@ -68,14 +64,13 @@ int rtems_shell_main_mdump(
res = 0xf; /* 16 bytes print in last row */
}
}
- }
- else {
+ } else {
max = 20;
res = 0xf;
}
+ pb = addr;
for (m=0; m<max; m++) {
- pb = (unsigned char*) addr;
printf("%10p ", pb);
for (n=0;n<=(m==(max-1)?res:0xf);n++)
printf("%02X%c",pb[n],n==7?'-':' ');
@@ -85,7 +80,7 @@ int rtems_shell_main_mdump(
printf("%c", isprint(pb[n]) ? pb[n] : '.');
}
printf("\n");
- addr += 16;
+ pb += 16;
}
return 0;
}
diff --git a/cpukit/libmisc/shell/main_medit.c b/cpukit/libmisc/shell/main_medit.c
index c3f750f234..7905fbe689 100644
--- a/cpukit/libmisc/shell/main_medit.c
+++ b/cpukit/libmisc/shell/main_medit.c
@@ -32,8 +32,8 @@ int rtems_shell_main_medit(
char *argv[]
)
{
- unsigned long tmp;
unsigned char *pb;
+ void *tmpp;
int n;
int i;
@@ -45,11 +45,11 @@ int rtems_shell_main_medit(
/*
* Convert arguments into numbers
*/
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_pointer(argv[1], &tmpp, NULL) ) {
printf( "Address argument (%s) is not a number\n", argv[1] );
return -1;
}
- pb = (unsigned char *) tmp;
+ pb = tmpp;
/*
* Now edit the memory
@@ -58,7 +58,7 @@ int rtems_shell_main_medit(
for (i=2 ; i<=argc ; i++) {
unsigned char tmpc;
- if ( !rtems_string_to_unsigned_char(argv[i], &tmpc, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_char(argv[i], &tmpc, NULL, 0) ) {
printf( "Value (%s) is not a number\n", argv[i] );
continue;
}
diff --git a/cpukit/libmisc/shell/main_mfill.c b/cpukit/libmisc/shell/main_mfill.c
index 1fb027ae4f..ecbaec4878 100644
--- a/cpukit/libmisc/shell/main_mfill.c
+++ b/cpukit/libmisc/shell/main_mfill.c
@@ -30,10 +30,10 @@ int rtems_shell_main_mfill(
char *argv[]
)
{
- unsigned long tmp;
- uintptr_t addr;
- size_t size;
- unsigned char value;
+ unsigned long tmp;
+ void *addr;
+ size_t size;
+ unsigned char value;
if ( argc != 4 ) {
fprintf(stderr,"%s: too few arguments\n", argv[0]);
@@ -43,19 +43,18 @@ int rtems_shell_main_mfill(
/*
* Convert arguments into numbers
*/
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_pointer(argv[1], &addr, NULL) ) {
printf( "Address argument (%s) is not a number\n", argv[1] );
return -1;
}
- addr = (uintptr_t) tmp;
- if ( !rtems_string_to_unsigned_long(argv[2], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[2], &tmp, NULL, 0) ) {
printf( "Size argument (%s) is not a number\n", argv[2] );
return -1;
}
size = (size_t) tmp;
- if ( !rtems_string_to_unsigned_char(argv[3], &value, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_char(argv[3], &value, NULL, 0) ) {
printf( "Value argument (%s) is not a number\n", argv[3] );
return -1;
}
@@ -63,7 +62,7 @@ int rtems_shell_main_mfill(
/*
* Now fill the memory.
*/
- memset((unsigned char*)addr, size, value);
+ memset(addr, size, value);
return 0;
}
diff --git a/cpukit/libmisc/shell/main_mmove.c b/cpukit/libmisc/shell/main_mmove.c
index f68f4a2ab6..30c6629547 100644
--- a/cpukit/libmisc/shell/main_mmove.c
+++ b/cpukit/libmisc/shell/main_mmove.c
@@ -32,10 +32,10 @@ int rtems_shell_main_mmove(
char *argv[]
)
{
- unsigned long tmp;
- uintptr_t src;
- uintptr_t dst;
- size_t length;
+ unsigned long tmp;
+ void *src;
+ void *dst;
+ size_t length;
if ( argc < 4 ) {
fprintf(stderr,"%s: too few arguments\n", argv[0]);
@@ -45,19 +45,17 @@ int rtems_shell_main_mmove(
/*
* Convert arguments into numbers
*/
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_pointer(argv[1], &dst, NULL) ) {
printf( "Destination argument (%s) is not a number\n", argv[1] );
return -1;
}
- dst = (uintptr_t) tmp;
- if ( !rtems_string_to_unsigned_long(argv[2], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_pointer(argv[2], &src, NULL) ) {
printf( "Source argument (%s) is not a number\n", argv[2] );
return -1;
}
- src = (uintptr_t) tmp;
- if ( !rtems_string_to_unsigned_long(argv[3], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[3], &tmp, NULL, 0) ) {
printf( "Length argument (%s) is not a number\n", argv[3] );
return -1;
}
@@ -66,7 +64,7 @@ int rtems_shell_main_mmove(
/*
* Now copy the memory.
*/
- memcpy((unsigned char*)dst, (unsigned char*)src, length);
+ memcpy(dst, src, length);
return 0;
}
diff --git a/cpukit/libmisc/shell/main_msdosfmt.c b/cpukit/libmisc/shell/main_msdosfmt.c
index d682728b9d..493ae25799 100644
--- a/cpukit/libmisc/shell/main_msdosfmt.c
+++ b/cpukit/libmisc/shell/main_msdosfmt.c
@@ -64,7 +64,7 @@ int rtems_shell_main_msdos_format(
return 1;
}
- if ( !rtems_string_to_unsigned_long(argv[arg], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[arg], &tmp, NULL, 0) ) {
printf(
"sector per cluster argument (%s) is not a number\n",
argv[arg]
@@ -82,7 +82,7 @@ int rtems_shell_main_msdos_format(
return 1;
}
- if ( !rtems_string_to_unsigned_long(argv[arg], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[arg], &tmp, NULL, 0) ) {
printf(
"root directory size argument (%s) is not a number\n",
argv[arg]
diff --git a/cpukit/libmisc/shell/main_mwdump.c b/cpukit/libmisc/shell/main_mwdump.c
index 6c6c77dcc0..9520f1e773 100644
--- a/cpukit/libmisc/shell/main_mwdump.c
+++ b/cpukit/libmisc/shell/main_mwdump.c
@@ -31,24 +31,22 @@ int rtems_shell_main_mwdump(
char *argv[]
)
{
- unsigned long tmp;
unsigned char n;
unsigned char m;
int max;
int res;
- uintptr_t addr = 0;
+ void *addr = 0;
unsigned char *pb;
if ( argc > 1 ) {
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_pointer(argv[1], &addr, NULL) ) {
printf( "Address argument (%s) is not a number\n", argv[1] );
return -1;
}
- addr = (uintptr_t) tmp;
}
if ( argc > 2 ) {
- if ( !rtems_string_to_int(argv[2], &max, NULL, 0) ) {
+ if ( rtems_string_to_int(argv[2], &max, NULL, 0) ) {
printf( "Address argument (%s) is not a number\n", argv[1] );
return -1;
}
@@ -71,8 +69,8 @@ int rtems_shell_main_mwdump(
res = 0xf;
}
+ pb = addr;
for (m=0;m<max;m++) {
- pb = (unsigned char *) addr;
printf("%10p ", pb);
for (n=0;n<=(m==(max-1)?res:0xf);n+=2)
printf("%04X%c",*((unsigned short*)(pb+n)),n==6?'-':' ');
@@ -82,7 +80,7 @@ int rtems_shell_main_mwdump(
printf("%c", isprint(pb[n]) ? pb[n] : '.');
}
printf("\n");
- addr += 16;
+ pb += 16;
}
return 0;
}
diff --git a/cpukit/libmisc/shell/main_sleep.c b/cpukit/libmisc/shell/main_sleep.c
index b153f62d37..2dbb66a996 100644
--- a/cpukit/libmisc/shell/main_sleep.c
+++ b/cpukit/libmisc/shell/main_sleep.c
@@ -39,7 +39,7 @@ int rtems_shell_main_sleep(
/*
* Convert the seconds argument to a number
*/
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
printf( "Seconds argument (%s) is not a number\n", argv[1] );
return -1;
}
@@ -50,7 +50,7 @@ int rtems_shell_main_sleep(
*/
delay.tv_nsec = 0;
if (argc == 3) {
- if ( !rtems_string_to_unsigned_long(argv[2], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[2], &tmp, NULL, 0) ) {
printf( "Seconds argument (%s) is not a number\n", argv[1] );
return -1;
}
diff --git a/cpukit/libmisc/shell/main_umask.c b/cpukit/libmisc/shell/main_umask.c
index 30996f187f..8bfbe7e443 100644
--- a/cpukit/libmisc/shell/main_umask.c
+++ b/cpukit/libmisc/shell/main_umask.c
@@ -37,7 +37,7 @@ int rtems_shell_main_umask(
mode_t msk = umask(0);
if (argc == 2) {
- if ( !rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long(argv[1], &tmp, NULL, 0) ) {
printf( "Mask argument (%s) is not a number\n", argv[1] );
return -1;
}
diff --git a/cpukit/libmisc/shell/shell_script.c b/cpukit/libmisc/shell/shell_script.c
index c31ed051d3..95b5abb934 100644
--- a/cpukit/libmisc/shell/shell_script.c
+++ b/cpukit/libmisc/shell/shell_script.c
@@ -129,7 +129,7 @@ int rtems_shell_main_joel(
case 'p': {
const char *s = getopt_reent.optarg;
- if ( !rtems_string_to_unsigned_long( s, &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long( s, &tmp, NULL, 0) ) {
printf( "Task Priority argument (%s) is not a number\n", s );
return -1;
}
@@ -139,7 +139,7 @@ int rtems_shell_main_joel(
case 's': {
const char *s = getopt_reent.optarg;
- if ( !rtems_string_to_unsigned_long( s, &tmp, NULL, 0) ) {
+ if ( rtems_string_to_unsigned_long( s, &tmp, NULL, 0) ) {
printf( "Stack size argument (%s) is not a number\n", s );
return -1;
}
diff --git a/cpukit/libmisc/stringto/stringto.h b/cpukit/libmisc/stringto/stringto.h
index 2e7fe151c6..e0ba24416c 100644
--- a/cpukit/libmisc/stringto/stringto.h
+++ b/cpukit/libmisc/stringto/stringto.h
@@ -12,6 +12,28 @@
#ifndef __STRING_TO_A_TYPE_h__
#define __STRING_TO_A_TYPE_h__
+#include <rtems.h>
+
+/**
+ * @brief Convert String to Pointer (with validation)
+ *
+ * This method converts a string to a pointer (void *) with
+ * basic numeric validation.
+ *
+ * @param[in] s is the string to convert
+ * @param[in] n points to the variable to place the converted output in
+ * @param[in] endptr is used to keep track of the position in the string
+ *
+ * @return This method returns RTEMS_SUCCESSFUL on successful conversion
+ * and *n is filled in. Otherwise, the status indicates the
+ * source of the error.
+ */
+rtems_status_code rtems_string_to_pointer(
+ const char *s,
+ void **n,
+ char **endptr
+);
+
/**
* @brief Convert String to Unsigned Character (with validation)
*
@@ -23,10 +45,11 @@
* @param[in] endptr is used to keep track of the position in the string
* @param[in] base is the expected base of the number
*
- * @return This method returns true on successful conversion and *n is
- * filled in.
+ * @return This method returns RTEMS_SUCCESSFUL on successful conversion
+ * and *n is filled in. Otherwise, the status indicates the
+ * source of the error.
*/
-bool rtems_string_to_unsigned_char(
+rtems_status_code rtems_string_to_unsigned_char(
const char *s,
unsigned char *n,
char **endptr,
@@ -43,10 +66,11 @@ bool rtems_string_to_unsigned_char(
* @param[in] endptr is used to keep track of the position in the string
* @param[in] base is the expected base of the number
*
- * @return This method returns true on successful conversion and *n is
- * filled in.
+ * @return This method returns RTEMS_SUCCESSFUL on successful conversion
+ * and *n is filled in. Otherwise, the status indicates the
+ * source of the error.
*/
-bool rtems_string_to_int(
+rtems_status_code rtems_string_to_int(
const char *s,
int *n,
char **endptr,
@@ -64,10 +88,11 @@ bool rtems_string_to_int(
* @param[in] endptr is used to keep track of the position in the string
* @param[in] base is the expected base of the number
*
- * @return This method returns true on successful conversion and *n is
- * filled in.
+ * @return This method returns RTEMS_SUCCESSFUL on successful conversion
+ * and *n is filled in. Otherwise, the status indicates the
+ * source of the error.
*/
-bool rtems_string_to_long(
+rtems_status_code rtems_string_to_long(
const char *s,
long *n,
char **endptr,
@@ -85,10 +110,11 @@ bool rtems_string_to_long(
* @param[in] endptr is used to keep track of the position in the string
* @param[in] base is the expected base of the number
*
- * @return This method returns true on successful conversion and *n is
- * filled in.
+ * @return This method returns RTEMS_SUCCESSFUL on successful conversion
+ * and *n is filled in. Otherwise, the status indicates the
+ * source of the error.
*/
-bool rtems_string_to_unsigned_long(
+rtems_status_code rtems_string_to_unsigned_long(
const char *s,
unsigned long *n,
char **endptr,
@@ -106,10 +132,11 @@ bool rtems_string_to_unsigned_long(
* @param[in] endptr is used to keep track of the position in the string
* @param[in] base is the expected base of the number
*
- * @return This method returns true on successful conversion and *n is
- * filled in.
+ * @return This method returns RTEMS_SUCCESSFUL on successful conversion
+ * and *n is filled in. Otherwise, the status indicates the
+ * source of the error.
*/
-bool rtems_string_to_long_long(
+rtems_status_code rtems_string_to_long_long(
const char *s,
long long *n,
char **endptr,
@@ -127,10 +154,11 @@ bool rtems_string_to_long_long(
* @param[in] endptr is used to keep track of the position in the string
* @param[in] base is the expected base of the number
*
- * @return This method returns true on successful conversion and *n is
- * filled in.
+ * @return This method returns RTEMS_SUCCESSFUL on successful conversion
+ * and *n is filled in. Otherwise, the status indicates the
+ * source of the error.
*/
-bool rtems_string_to_unsigned_long_long(
+rtems_status_code rtems_string_to_unsigned_long_long(
const char *s,
unsigned long long *n,
char **endptr,
@@ -146,10 +174,11 @@ bool rtems_string_to_unsigned_long_long(
* @param[in] n points to the variable to place the converted output in
* @param[in] endptr is used to keep track of the position in the string
*
- * @return This method returns true on successful conversion and *n is
- * filled in.
+ * @return This method returns RTEMS_SUCCESSFUL on successful conversion
+ * and *n is filled in. Otherwise, the status indicates the
+ * source of the error.
*/
-bool rtems_string_to_float(
+rtems_status_code rtems_string_to_float(
const char *s,
float *n,
char **endptr
@@ -164,10 +193,11 @@ bool rtems_string_to_float(
* @param[in] n points to the variable to place the converted output in
* @param[in] endptr is used to keep track of the position in the string
*
- * @return This method returns true on successful conversion and *n is
- * filled in.
+ * @return This method returns RTEMS_SUCCESSFUL on successful conversion
+ * and *n is filled in. Otherwise, the status indicates the
+ * source of the error.
*/
-bool rtems_string_to_double(
+rtems_status_code rtems_string_to_double(
const char *s,
double *n,
char **endptr
diff --git a/cpukit/libmisc/stringto/stringto_template.h b/cpukit/libmisc/stringto/stringto_template.h
index 501f4393f8..863c98ff81 100644
--- a/cpukit/libmisc/stringto/stringto_template.h
+++ b/cpukit/libmisc/stringto/stringto_template.h
@@ -9,18 +9,31 @@
* $Id$
*/
+#include <rtems/stringto.h>
+
#include <errno.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>
-#include <math.h>
+/*
+ * If we are doing floating point conversion, then we need math.h
+ */
+#if defined(STRING_TO_FLOAT)
+ #include <math.h>
+#endif
+
+#include <rtems.h>
/*
* This file is designed to be included multiple times to instantiate
* it and should NOT be protected against multiple inclusions.
*/
+#if defined(STRING_TO_POINTER)
+ #define STRING_TO_INTEGER
+#endif
+
#if !defined(STRING_TO_FLOAT) && !defined(STRING_TO_INTEGER)
#error "Neither STRING_TO_FLOAT nor STRING_TO_INTEGER defined"
#endif
@@ -52,27 +65,33 @@
#define ZERO 0
#endif
-bool STRING_TO_NAME (
+#if !defined(STRING_TO_INPUT_TYPE)
+ #define STRING_TO_INPUT_TYPE STRING_TO_TYPE
+#endif
+
+rtems_status_code STRING_TO_NAME (
const char *s,
STRING_TO_TYPE *n,
char **endptr
- #if defined(STRING_TO_INTEGER)
+ #if defined(STRING_TO_INTEGER) && !defined(STRING_TO_POINTER)
,
int base
#endif
)
{
- STRING_TO_TYPE result;
- char *end;
+ STRING_TO_INPUT_TYPE result;
+ char *end;
if ( !n )
- return false;
+ return RTEMS_INVALID_ADDRESS;
errno = 0;
*n = 0;
#ifdef STRING_TO_FLOAT
result = STRING_TO_METHOD( s, &end );
+ #elif defined(STRING_TO_POINTER)
+ result = STRING_TO_METHOD( s, &end, 16 );
#elif defined(STRING_TO_INTEGER)
result = STRING_TO_METHOD( s, &end, base );
#endif
@@ -83,25 +102,25 @@ bool STRING_TO_NAME (
/* nothing was converted */
if ( end == s )
- return false;
+ return RTEMS_NOT_DEFINED;
/* there was a conversion error */
if ( (result == ZERO) && errno )
- return false;
+ return RTEMS_INVALID_NUMBER;
#ifdef STRING_TO_MAX
/* there was an overflow */
if ( (result == STRING_TO_MAX) && (errno == ERANGE))
- return false;
+ return RTEMS_INVALID_NUMBER;
#endif
#ifdef STRING_TO_MIN
/* there was an underflow */
if ( (result == STRING_TO_MIN) && (errno == ERANGE))
- return false;
+ return RTEMS_INVALID_NUMBER;
#endif
*n = (STRING_TO_TYPE) result;
- return true;
+ return RTEMS_SUCCESSFUL;
}
diff --git a/cpukit/libmisc/stringto/stringtopointer.c b/cpukit/libmisc/stringto/stringtopointer.c
new file mode 100644
index 0000000000..ca1e480d2d
--- /dev/null
+++ b/cpukit/libmisc/stringto/stringtopointer.c
@@ -0,0 +1,25 @@
+/*
+ * COPYRIGHT (c) 2009.
+ * On-Line Applications Research Corporation (OAR).
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ *
+ * $Id$
+ */
+
+/*
+ * Instantiate an error checking wrapper for strtoul which is
+ * used to input a (void *)
+ *
+ * NOTE: This is only an appropriate implementation when unsigned long
+ * can represent a void *
+ */
+#define STRING_TO_POINTER
+#define STRING_TO_TYPE void *
+#define STRING_TO_INPUT_TYPE unsigned long
+#define STRING_TO_NAME rtems_string_to_pointer
+#define STRING_TO_METHOD strtoul
+#define STRING_TO_MAX ULONG_MAX
+#include "stringto_template.h"