40 #include <sys/types.h>
57 const char *format, ...)
62 if (!
function || !format)
66 vsnprintf(str,
sizeof(str), format, ap);
81 void util_hexdump(
const char dir,
const unsigned char *buf,
size_t len,
84 static const char hexdigits[] =
"0123456789abcdef";
88 if (!
function || !len)
93 for (i = 0; i < len; i++) {
94 str[((i % 16) * 3) + 1] =
' ';
95 str[((i % 16) * 3) + 2] = hexdigits[buf[i] >> 4];
96 str[((i % 16) * 3) + 3] = hexdigits[buf[i] & 0xf];
97 str[(i % 16) + 51] = isprint(buf[i]) ? buf[i] :
'.';
99 if ((i + 1) % 16 == 0) {
110 for (j = (i % 16); j < 16; j++) {
111 str[(j * 3) + 1] =
' ';
112 str[(j * 3) + 2] =
' ';
113 str[(j * 3) + 3] =
' ';
132 char filename[PATH_MAX];
135 snprintf(filename,
sizeof(filename),
"%s/%s", parent, name);
136 if (lstat(filename, &st) == 0 && S_ISDIR(st.st_mode))
161 *bitmap |= 1 << (
id - 1);
177 *bitmap &= ~(1 << (
id - 1));
void(* util_debug_func_t)(const char *str, void *user_data)
uint8_t util_get_uid(unsigned int *bitmap, uint8_t max)
void util_hexdump(const char dir, const unsigned char *buf, size_t len, util_debug_func_t function, void *user_data)
void util_clear_uid(unsigned int *bitmap, uint8_t id)
void util_debug(util_debug_func_t function, void *user_data, const char *format,...)
unsigned char util_get_dt(const char *parent, const char *name)