libcfe  0.12.1
some useful C-functions
char_to_int.c File Reference
#include "config.h"
#include "char_to_int.h"
#include <stdio.h>
#include "len.h"
Include dependency graph for char_to_int.c:

Go to the source code of this file.

Functions

short int check_int (const char *s, int len, uint8_t base)
 
unsigned long long char_to_int (const char *s, int i, uint8_t base)
 

Function Documentation

◆ char_to_int()

unsigned long long char_to_int ( const char *  s,
int  i,
uint8_t  base 
)

Return the number this string represents, but only if the contains only (hexadecimal) numbers.

Parameters
[in]sThe string that contains the number.
[in]iThe length of the string that s points to.
[in]baseThe base number (binary -> 2, octal -> 8, decimal -> 10, hexadecimal -> 16), this must not be bigger than 16.
Returns
The number that 's' represents.

Definition at line 24 of file char_to_int.c.

Here is the caller graph for this function:

◆ check_int()

short int check_int ( const char *  s,
int  len,
uint8_t  base 
)

Check if the string represents a decimal value.

Parameters
[in]sThe string that contains the number.
[in]iThe length of the string that s points to.
Returns
result:
  • 0 false, not a number
  • 1 true, this contains a number

Definition at line 8 of file char_to_int.c.

Here is the caller graph for this function: