wizapp-stdlib/src/uuid/uuid.h
2025-03-22 02:27:59 +00:00

35 lines
773 B
C

#ifndef UUID_H
#define UUID_H
#include "../common/aliases/aliases.h"
#include "../core/strings/str8/str8.h"
#ifdef __cplusplus
BEGIN_C_LINKAGE
#endif // __cplusplus
#define UUID_BUF_LENGTH 48
#define WAPP_UUID_SPEC WAPP_STR8_SPEC
#define wapp_uuid_varg(UUID) wapp_str8_varg((UUID).uuid)
typedef struct uuid UUID;
struct uuid {
Str8 uuid;
};
#define wapp_uuid_gen_uuid4() *(wapp_uuid_init_uuid4(&wapp_uuid_create()))
/* Low level UUID API */
#define wapp_uuid_create() ((UUID){.uuid = wapp_str8_buf(UUID_BUF_LENGTH)})
// Just returns the same pointer that was passed in with the UUID initialised.
// If the pointer is NULL, it skips initialisation.
UUID *wapp_uuid_init_uuid4(UUID *uuid);
#ifdef __cplusplus
END_C_LINKAGE
#endif // __cplusplus
#endif // !UUID_H