#ifndef _UTILS_H_
#define _UTILS_H_
#ifndef lint
__RCSID("$NetBSD: utils.h,v 1.1 2025/02/24 13:47:57 christos Exp $");
#endif
#if 0
int uuid_printf(const struct uuid *);
void uuid_dec_be(const void *, struct uuid *);
void uuid_dec_le(const void *, struct uuid *);
void uuid_enc_be(void *, const struct uuid *);
void uuid_enc_le(void *, const struct uuid *);
int uuidgen(struct uuid *, int);
#endif
#include <string.h>
#include <util.h>
struct uuid;
static inline void *
memdup(const void *src, size_t sz)
{
void *dst;
dst = emalloc(sz);
memcpy(dst, src, sz);
return dst;
}
static inline char *
encode_data(const uint8_t *data, size_t len)
{
char *bp;
bp = emalloc(len * 2 + 1);
for (size_t i = 0; i < len; i++)
snprintf(&bp[i * 2], 3, "%02x", data[i]);
bp[len * 2] = '\0';
return bp;
}
static inline size_t
ucs2nlen(const uint16_t *src, size_t maxlen)
{
size_t i;
for (i = 0; i < maxlen; i++) {
if (src[i] == '\0')
break;
}
return i;
}
char *ucs2_to_utf8(const uint16_t *, size_t, char *, size_t *);
uint16_t *utf8_to_ucs2(const char *, size_t, uint16_t *, size_t *);
size_t utf8_to_ucs2_size(const char *);
int uuid_scanf(struct uuid *, const char *);
int uuid_snprintf(char *, size_t, const struct uuid *);
int uuid_printf(const struct uuid *);
void show_data(const uint8_t *, size_t, const char *);
uint16_t strtous(const char *, char **, int);
char *read_file(const char *, size_t *);
#endif