Skip to content

Instantly share code, notes, and snippets.

@a2gs
Created March 30, 2022 04:10
Show Gist options
  • Save a2gs/387052a033307cbfff36f028adbe9f82 to your computer and use it in GitHub Desktop.
Save a2gs/387052a033307cbfff36f028adbe9f82 to your computer and use it in GitHub Desktop.
UUID sample code // OSF DCE -- Linux
/* Andre Augusto Giannotti Scota (https://sites.google.com/view/a2gs/ andre.scota@gmail.com) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <uuid/uuid.h>
int main(int argc, char *argv[]) {
uuid_t ctx_uuid;
char uuid[37] = {0};
uuid_generate_random(ctx_uuid);
uuid_unparse_lower(ctx_uuid, uuid);
printf("UUID: [%s][%03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d %03d]\n", uuid,
ctx_uuid[0], ctx_uuid[1], ctx_uuid[2], ctx_uuid[3], ctx_uuid[4], ctx_uuid[5], ctx_uuid[6], ctx_uuid[7],
ctx_uuid[8], ctx_uuid[9], ctx_uuid[10], ctx_uuid[11], ctx_uuid[12], ctx_uuid[13], ctx_uuid[14], ctx_uuid[15]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment