MPHELL
4.0.0
|
Definition of miscellaneous function. More...
#include "mphell-util.h"
Go to the source code of this file.
Macros | |
#define | MAX_MARKER_LEN 50 |
Functions | |
uint8_t | bits_to_nblock (const uint16_t nbits) |
Return the number of blocks required to store a nbits number. More... | |
uint8_t | max_size (uint8_t a, uint8_t b) |
Return the max of a and b. More... | |
time_t | get_s (struct timespec *start, struct timespec *end) |
Return the elapsed time in second between "start" and "end". More... | |
unsigned int | get_ns (struct timespec *start, struct timespec *end) |
Return the elapsed time in nano second to add to the result of get_s(). More... | |
void | print_bytes_string_hex (const uint8_t *bytes_string, uint16_t length) |
Print the byte string "bytes_string" under hexadecimal form. More... | |
void | bytes_string2hex (char *hex_string, const uint8_t *bytes_string, uint16_t length) |
Convert the byte string "bytes_string" under hexadecimal form. More... | |
void | hex_string2bytes (uint8_t *bytes_string, const char *hex_string, uint16_t length) |
Convert the hexadecimal string "hex_string" under bytes string form. More... | |
void | bin2hex (const unsigned char *old, const uint32_t oldlen, unsigned char *result) |
uint32_t | hex2bin (const char *in, unsigned char *out) |
Convert an hexadecimal string into a binary string. More... | |
int | FindMarker (FILE *infile, const char *marker) |
Find a marker in a file. More... | |
int | ReadHex (FILE *infile, char *A, const int Length, char *str) |
Read an hexadecimal string in file "infile". More... | |
void | char2bin (char c, uint8_t *b) |
Convert a character into a byte (according to its ascii value) More... | |
void | printchar2bin (uint8_t b) |
print a byte More... | |
void | string2bin (char *s, uint8_t *output) |
Convert a string into a byte array. More... | |
void | printstring2bin (uint8_t *s, uint32_t len) |
Print a byte array. More... | |
Definition of miscellaneous function.
Definition in file mphell-util.c.
uint8_t bits_to_nblock | ( | const uint16_t | nbits | ) |
Return the number of blocks required to store a nbits number.
nbits | Number of bits |
Definition at line 29 of file mphell-util.c.
void bytes_string2hex | ( | char * | hex_string, |
const uint8_t * | bytes_string, | ||
uint16_t | length | ||
) |
Convert the byte string "bytes_string" under hexadecimal form.
hex_string | Resulting hexadecimal string, must be allocated of size length*2 |
bytes_string | Byte string to convert |
length | Length of bytes_string (in byte) |
Definition at line 67 of file mphell-util.c.
void char2bin | ( | char | c, |
uint8_t * | b | ||
) |
Convert a character into a byte (according to its ascii value)
c | character to convert |
b | destination byte |
Definition at line 242 of file mphell-util.c.
int FindMarker | ( | FILE * | infile, |
const char * | marker | ||
) |
Find a marker in a file.
infile | Filename |
marker | Marker to find |
Definition at line 167 of file mphell-util.c.
long get_ns | ( | struct timespec * | start, |
struct timespec * | end | ||
) |
Return the elapsed time in nano second to add to the result of get_s().
start | Begin of chrono |
end | End of chrono |
Definition at line 48 of file mphell-util.c.
time_t get_s | ( | struct timespec * | start, |
struct timespec * | end | ||
) |
Return the elapsed time in second between "start" and "end".
start | Begin of chrono |
end | End of chrono |
Definition at line 39 of file mphell-util.c.
uint32_t hex2bin | ( | const char * | in, |
unsigned char * | out | ||
) |
Convert an hexadecimal string into a binary string.
in | Hexadecimal string |
out | Binary string |
Definition at line 111 of file mphell-util.c.
void hex_string2bytes | ( | uint8_t * | bytes_string, |
const char * | hex_string, | ||
uint16_t | length | ||
) |
Convert the hexadecimal string "hex_string" under bytes string form.
bytes_string | Resulting byte string, must be allocated of size length/2 |
hex_string | Hexadecimal string to convert |
length | Length of resulting byte string |
Definition at line 78 of file mphell-util.c.
int max_size | ( | uint8_t | a, |
uint8_t | b | ||
) |
Return the max of a and b.
a | size of an element in number blocks (< 256) |
b | size of an element in number blocks (< 256) |
Definition at line 34 of file mphell-util.c.
void print_bytes_string_hex | ( | const uint8_t * | bytes_string, |
uint16_t | length | ||
) |
Print the byte string "bytes_string" under hexadecimal form.
bytes_string | Byte string to print |
length | Length of bytes_string (in byte) |
Definition at line 58 of file mphell-util.c.
void printchar2bin | ( | uint8_t | b | ) |
void printstring2bin | ( | uint8_t * | s, |
uint32_t | len | ||
) |
Print a byte array.
s | byte array |
len | length of "s" |
Definition at line 281 of file mphell-util.c.
int ReadHex | ( | FILE * | infile, |
char * | A, | ||
const int | Length, | ||
char * | str | ||
) |
Read an hexadecimal string in file "infile".
infile | Filename |
A | Destination string |
Length | Size in bytes of the string to read |
str | Marker used to detect the string |
Definition at line 196 of file mphell-util.c.
void string2bin | ( | char * | s, |
uint8_t * | output | ||
) |
Convert a string into a byte array.
s | string to convert |
output | destination byte array |
Definition at line 271 of file mphell-util.c.