High Performance OPC UA Server SDK  1.2.0.193
strtoint

String to integer conversion. More...

Functions

int util_strtoint8 (const char *nptr, char **endptr, int base, int8_t *result)
 This function behaves similar to strtol() with the following differences: More...
 
int util_strtouint8 (const char *nptr, char **endptr, int base, uint8_t *result)
 This function behaves similar to strtoul() with the following differences: More...
 
int util_strtoint16 (const char *nptr, char **endptr, int base, int16_t *result)
 This function behaves similar to strtol() with the following differences: More...
 
int util_strtouint16 (const char *nptr, char **endptr, int base, uint16_t *result)
 This function behaves similar to strtoul() with the following differences: More...
 
int util_strtoint32 (const char *nptr, char **endptr, int base, int32_t *result)
 This function behaves similar to strtol() with the following differences: More...
 
int util_strtouint32 (const char *nptr, char **endptr, int base, uint32_t *result)
 This function behaves similar to strtoul() with the following differences: More...
 
int util_strtoint64 (const char *nptr, char **endptr, int base, int64_t *result)
 This function behaves similar to strtol() with the following differences: More...
 
int util_strtouint64 (const char *nptr, char **endptr, int base, uint64_t *result)
 This function behaves similar to strtoul() with the following differences: More...
 
int util_url_parse (const char *str, struct util_url *elements)
 Parses an URL like 'https://www.example.com:443/path'. More...
 

Detailed Description

String to integer conversion.

Function Documentation

int util_strtoint16 ( const char *  nptr,
char **  endptr,
int  base,
int16_t *  result 
)

This function behaves similar to strtol() with the following differences:

  • this function uses fixed width integer size from stdint.h
  • it does not use errno variable
  • the string must not be prefixed with "0x"
    Parameters
    nptrPointer to string to parse
    endptrIf endptr is not NULL, util_strtouint16() stores the address of the first invalid character in *endptr. If there were no digits at all, util_strtoint16() stores the original value of nptr in *endptr (and returns 0). In particular, if *nptr is not '\0' but **endptr is '\0' on return, the entire string is valid.
    base2-36 (10-36 is represented by A-Z)
    resultIf result is not NULL this variable receives the converted value.
    Returns
    Zero on success, -1 otherwise.
int util_strtoint32 ( const char *  nptr,
char **  endptr,
int  base,
int32_t *  result 
)

This function behaves similar to strtol() with the following differences:

  • this function uses fixed width integer size from stdint.h
  • it does not use errno variable
  • the string must not be prefixed with "0x"
    Parameters
    nptrPointer to string to parse
    endptrIf endptr is not NULL, util_strtouint32() stores the address of the first invalid character in *endptr. If there were no digits at all, util_strtoint32() stores the original value of nptr in *endptr (and returns 0). In particular, if *nptr is not '\0' but **endptr is '\0' on return, the entire string is valid.
    base2-35 (10-35 is represented by A-Z)
    resultIf result is not NULL this variable receives the converted value.
    Returns
    Zero on success, -1 otherwise.
int util_strtoint64 ( const char *  nptr,
char **  endptr,
int  base,
int64_t *  result 
)

This function behaves similar to strtol() with the following differences:

  • this function uses fixed width integer size from stdint.h
  • it does not use errno variable
  • the string must not be prefixed with "0x"
    Parameters
    nptrPointer to string to parse
    endptrIf endptr is not NULL, util_strtouint64() stores the address of the first invalid character in *endptr. If there were no digits at all, util_strtoint64() stores the original value of nptr in *endptr (and returns 0). In particular, if *nptr is not '\0' but **endptr is '\0' on return, the entire string is valid.
    base2-36 (10-36 is represented by A-Z)
    resultIf result is not NULL this variable receives the converted value.
    Returns
    Zero on success, -1 otherwise.
int util_strtoint8 ( const char *  nptr,
char **  endptr,
int  base,
int8_t *  result 
)

This function behaves similar to strtol() with the following differences:

  • this function uses fixed width integer size from stdint.h
  • it does not use errno variable
  • the string must not be prefixed with "0x"
    Parameters
    nptrPointer to string to parse
    endptrIf endptr is not NULL, util_strtouint8() stores the address of the first invalid character in *endptr. If there were no digits at all, util_strtoint8() stores the original value of nptr in *endptr (and returns 0). In particular, if *nptr is not '\0' but **endptr is '\0' on return, the entire string is valid.
    base2-36 (10-36 is represented by A-Z)
    resultIf result is not NULL this variable receives the converted value.
    Returns
    Zero on success, -1 otherwise.
int util_strtouint16 ( const char *  nptr,
char **  endptr,
int  base,
uint16_t *  result 
)

This function behaves similar to strtoul() with the following differences:

  • this function uses fixed width integer size from stdint.h
  • it does not use errno variable
  • the string must not be prefixed with "0x"
  • negative values produce an error
    Parameters
    nptrPointer to string to parse
    endptrIf endptr is not NULL, util_strtouint16() stores the address of the first invalid character in *endptr. If there were no digits at all, util_strtoint16() stores the original value of nptr in *endptr (and returns 0). In particular, if *nptr is not '\0' but **endptr is '\0' on return, the entire string is valid.
    base2-36 (10-36 is represented by A-Z)
    resultIf result is not NULL this variable receives the converted value.
    Returns
    Zero on success, -1 otherwise.
int util_strtouint32 ( const char *  nptr,
char **  endptr,
int  base,
uint32_t *  result 
)

This function behaves similar to strtoul() with the following differences:

  • this function uses fixed width integer size from stdint.h
  • it does not use errno variable
  • the string must not be prefixed with "0x"
  • negative values produce an error
    Parameters
    nptrPointer to string to parse
    endptrIf endptr is not NULL, util_strtouint32() stores the address of the first invalid character in *endptr. If there were no digits at all, util_strtoint32() stores the original value of nptr in *endptr (and returns 0). In particular, if *nptr is not '\0' but **endptr is '\0' on return, the entire string is valid.
    base2-35 (10-35 is represented by A-Z)
    resultIf result is not NULL this variable receives the converted value.
    Returns
    Zero on success, -1 otherwise.
int util_strtouint64 ( const char *  nptr,
char **  endptr,
int  base,
uint64_t *  result 
)

This function behaves similar to strtoul() with the following differences:

  • this function uses fixed width integer size from stdint.h
  • it does not use errno variable
  • the string must not be prefixed with "0x"
  • negative values produce an error
    Parameters
    nptrPointer to string to parse
    endptrIf endptr is not NULL, util_strtouint64() stores the address of the first invalid character in *endptr. If there were no digits at all, util_strtoint64() stores the original value of nptr in *endptr (and returns 0). In particular, if *nptr is not '\0' but **endptr is '\0' on return, the entire string is valid.
    base2-36 (10-36 is represented by A-Z)
    resultIf result is not NULL this variable receives the converted value.
    Returns
    Zero on success, -1 otherwise.
int util_strtouint8 ( const char *  nptr,
char **  endptr,
int  base,
uint8_t *  result 
)

This function behaves similar to strtoul() with the following differences:

  • this function uses fixed width integer size from stdint.h
  • it does not use errno variable
  • the string must not be prefixed with "0x"
  • negative values produce an error
    Parameters
    nptrPointer to string to parse
    endptrIf endptr is not NULL, util_strtouint8() stores the address of the first invalid character in *endptr. If there were no digits at all, util_strtoint8() stores the original value of nptr in *endptr (and returns 0). In particular, if *nptr is not '\0' but **endptr is '\0' on return, the entire string is valid.
    base2-36 (10-36 is represented by A-Z)
    resultIf result is not NULL this variable receives the converted value.
    Returns
    Zero on success, -1 otherwise.
int util_url_parse ( const char *  str,
struct util_url elements 
)

Parses an URL like 'https://www.example.com:443/path'.

https://www.example.com:443/path ___/ _____________/ _/___/ | | | | scheme host port path (optional) (optional)

The parts of the URL are parsed into the provided struct. The pointers in the struct point to the respective position of the provided URL. So these are only valid as long as the URL is valid and do not need to be freed. The URL is not modified, so the pointers are not zero terminated and the length field of the struct must be respected.

The port in the result is zero if omitted in the URL string.

Parameters
strThe URL to parse.
elementsThe parsed parts of the URL.
Returns
Zero on success or errorcode on failure.