libgslutil
1.2.3
|
Macros | |
#define | GSL_MACHINE_ID_LEN (33) |
Length for null-terminated machine ID string. | |
#define | GSL_MACHINE_UUID_LEN (16) |
Length for raw machine ID bytes. | |
Functions | |
void | gsl_get_machine_id (char *strbuf, uint8_t *uuid, int *was_generated) |
Read machine ID. More... | |
dbus
and, more latterly, systemd
define a useful concept: a machine ID. Underneath the hood this is a UUID.
void gsl_get_machine_id | ( | char * | strbuf, |
uint8_t * | uuid, | ||
int * | was_generated | ||
) |
Read machine ID.
[out] | strbuf | String buffer, containing ASCII machine ID. |
[out] | uuid | Raw hex digits of UUID. |
[out] | was_generated | True if result generated by this function. |
Reads the machine ID from /etc/machine-id
(if present). If not present, or the contents of the file are invalid, generates a machine ID locally. Such local generation will result in a different UUID on each call, and will result in *was_generated being set to a non-zero value (if not null), and the UUID will be a v4 (random) UUID.
If strbuf is not null, it must point to a buffer of at least GSL_MACHINE_ID_LEN bytes (which includes space for a terminating null). If uuid is not null, it must point to a buffer of GSL_MACHINE_UUID_LEN bytes.