Skip to content

Instantly share code, notes, and snippets.

@tftio
Created March 17, 2014 18:20
Show Gist options
  • Save tftio/9605174 to your computer and use it in GitHub Desktop.
Save tftio/9605174 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <uuid/uuid.h>
#include <stdlib.h>
#include <libgen.h>
// cc -Wall -pedantic -Werror -o uuid uuid.c
// AND!
// ln uuid uuidt
// for uuid_generate_time() based uuids.
int main (int argc, const char ** argv) {
uuid_t uuid;
uuid_string_t uuid_str;
char * bname = basename((char *) argv[0]);
if (strncmp(bname, "uuidt", 5) == 0) {
uuid_generate_time(uuid);
} else {
uuid_generate(uuid);
}
uuid_unparse_lower(uuid, uuid_str);
printf("%s\n", uuid_str);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment