epicsStdlib.h

Functions to convert strings to primitive types.

These routines convert a string into an integer of the indicated type and number base, or into a floating point type. The units pointer argument may be NULL, but if not it will be left pointing to the first non-whitespace character following the numeric string, or to the terminating zero byte.

The return value from these routines is a status code, zero meaning OK. For the macro functions beginning with epicsScan the return code is 0 or 1 (0=failure or 1=success, similar to the sscanf() function).

Defines

S_stdlib_noConversion

Return code for No digits to convert

S_stdlib_extraneous

Return code for Extraneous characters

S_stdlib_underflow

Return code for Too small to represent

S_stdlib_overflow

Return code for Too large to represent

S_stdlib_badBase

Return code for Number base not supported

epicsParseFloat32(str, to, units)

Macro utilizing epicsParseFloat to convert

epicsParseFloat64(str, to, units)

Macro utilizing epicsParseDouble to convert

epicsScanLong(str, to, base)

Macro utilizing epicsParseLong to convert

Returns:

0=failure, 1=success

epicsScanULong(str, to, base)

Macro utilizing epicsParseULong to convert

Returns:

0=failure, 1=success

epicsScanLLong(str, to, base)

Macro utilizing epicsParseLLong to convert

Returns:

0=failure, 1=success

epicsScanULLong(str, to, base)

Macro utilizing epicsParseULLong to convert

Returns:

0=failure, 1=success

epicsScanFloat(str, to)

Macro utilizing epicsParseFloat to convert

Returns:

0=failure, 1=success

epicsScanDouble(str, to)

Macro utilizing epicsParseDouble to convert

Returns:

0=failure, 1=success

Functions

int epicsParseLong(const char *str, long *to, int base, char **units)

Convert a string to a long type.

Parameters:
  • str – Pointer to a constant character array

  • to – Pointer to the specified type (this will be set during the conversion)

  • base – The number base to use

  • units – Pointer to a char * (this will be set with the units string)

Returns:

Status code (0=OK, see macro definitions for possible errors)

int epicsParseULong(const char *str, unsigned long *to, int base, char **units)

Convert a string to a unsigned long type.

Parameters:
  • str – Pointer to a constant character array

  • to – Pointer to the specified type (this will be set during the conversion)

  • base – The number base to use

  • units – Pointer to a char * (this will be set with the units string)

Returns:

Status code (0=OK, see macro definitions for possible errors)

int epicsParseLLong(const char *str, long long *to, int base, char **units)

Convert a string to a long long type.

Parameters:
  • str – Pointer to a constant character array

  • to – Pointer to the specified type (this will be set during the conversion)

  • base – The number base to use

  • units – Pointer to a char * (this will be set with the units string)

Returns:

Status code (0=OK, see macro definitions for possible errors)

int epicsParseULLong(const char *str, unsigned long long *to, int base, char **units)

Convert a string to a unsigned long long type.

Parameters:
  • str – Pointer to a constant character array

  • to – Pointer to the specified type (this will be set during the conversion)

  • base – The number base to use

  • units – Pointer to a char * (this will be set with the units string)

Returns:

Status code (0=OK, see macro definitions for possible errors)

int epicsParseDouble(const char *str, double *to, char **units)

Convert a string to a double type.

Parameters:
  • str – Pointer to a constant character array

  • to – Pointer to the specified type (this will be set only upon successful conversion)

  • units – Pointer to a char * (this will be set with the units string only upon successful conversion)

Returns:

Status code (0=OK, see macro definitions for possible errors)

int epicsParseFloat(const char *str, float *to, char **units)

Convert a string to a float type.

Parameters:
  • str – Pointer to a constant character array

  • to – Pointer to the specified type (this will be set only upon successful conversion)

  • units – Pointer to a char * (this will be set with the units string only upon successful conversion)

Returns:

Status code (0=OK, see macro definitions for possible errors)

int epicsParseInt8(const char *str, epicsInt8 *to, int base, char **units)

Convert a string to an epicsInt8 type.

Parameters:
  • str – Pointer to a constant character array

  • to – Pointer to the specified type (this will be set during the conversion)

  • base – The number base to use

  • units – Pointer to a char * (this will be set with the units string)

Returns:

Status code (0=OK, see macro definitions for possible errors)

int epicsParseUInt8(const char *str, epicsUInt8 *to, int base, char **units)

Convert a string to an epicsUInt8 type.

Parameters:
  • str – Pointer to a constant character array

  • to – Pointer to the specified type (this will be set during the conversion)

  • base – The number base to use

  • units – Pointer to a char * (this will be set with the units string)

Returns:

Status code (0=OK, see macro definitions for possible errors)

int epicsParseInt16(const char *str, epicsInt16 *to, int base, char **units)

Convert a string to an epicsInt16 type.

Parameters:
  • str – Pointer to a constant character array

  • to – Pointer to the specified type (this will be set during the conversion)

  • base – The number base to use

  • units – Pointer to a char * (this will be set with the units string)

Returns:

Status code (0=OK, see macro definitions for possible errors)

int epicsParseUInt16(const char *str, epicsUInt16 *to, int base, char **units)

Convert a string to an epicsUInt16 type.

Parameters:
  • str – Pointer to a constant character array

  • to – Pointer to the specified type (this will be set during the conversion)

  • base – The number base to use

  • units – Pointer to a char * (this will be set with the units string)

Returns:

Status code (0=OK, see macro definitions for possible errors)

int epicsParseInt32(const char *str, epicsInt32 *to, int base, char **units)

Convert a string to an epicsInt32 type.

Parameters:
  • str – Pointer to a constant character array

  • to – Pointer to the specified type (this will be set during the conversion)

  • base – The number base to use

  • units – Pointer to a char * (this will be set with the units string)

Returns:

Status code (0=OK, see macro definitions for possible errors)

int epicsParseUInt32(const char *str, epicsUInt32 *to, int base, char **units)

Convert a string to an epicsUInt32 type.

Parameters:
  • str – Pointer to a constant character array

  • to – Pointer to the specified type (this will be set during the conversion)

  • base – The number base to use

  • units – Pointer to a char * (this will be set with the units string)

Returns:

Status code (0=OK, see macro definitions for possible errors)

int epicsParseInt64(const char *str, epicsInt64 *to, int base, char **units)

Convert a string to an epicsInt64 type.

Parameters:
  • str – Pointer to a constant character array

  • to – Pointer to the specified type (this will be set during the conversion)

  • base – The number base to use

  • units – Pointer to a char * (this will be set with the units string)

Returns:

Status code (0=OK, see macro definitions for possible errors)

int epicsParseUInt64(const char *str, epicsUInt64 *to, int base, char **units)

Convert a string to an epicsUInt64 type.

Parameters:
  • str – Pointer to a constant character array

  • to – Pointer to the specified type (this will be set during the conversion)

  • base – The number base to use

  • units – Pointer to a char * (this will be set with the units string)

Returns:

Status code (0=OK, see macro definitions for possible errors)