libc8
CHIP-8 utility library
util.h File Reference

Go to the source code of this file.

Functions

int hex_to_int (char)
 Get the integer value of hexadecimal ASCII representation. More...
 
int parse_int (const char *)
 Parse decimal or hexadecimal integer from s More...
 
char * trim (char *)
 Trim leading and trailing whitespace from s More...
 

Detailed Description

Note
NOT EXPORTED

Miscellaneous useful functions.

Function Documentation

◆ hex_to_int()

int hex_to_int ( char  c)

Get the integer value of hexadecimal ASCII representation.

Parameters
cthe char to convert
Returns
-1 if failed, otherwise 0-15

◆ parse_int()

int parse_int ( const char *  s)

Parse decimal or hexadecimal integer from s

Converts string s to an integer. Assumes decimal unless the first character is ‘’$'or'x'`.

Parameters
sThe string to convert.
Returns
-1 if failed, otherwise whatever the value is

◆ trim()

char * trim ( char *  s)

Trim leading and trailing whitespace from s

Puts a NULL character after the last non-whitespace character and returns a pointer to the first non-whitespace character.

Parameters
sstring to trim
Returns
pointer to first non-whitespace character after s.