UUID v4 generation in C; Grégory Pakosz (2019).
npm install uuid4.cuuid4.h and uuid4.c into your build and get started. (see also
bash
$ npm i uuid4.c
`
And then include uuid4.h as follows:
`c
#include "node_modules/uuid4.c/src/uuid4.h"
`
You may also want to include uuid4.c as follows:
`c
#ifndef __UUID4_C__
#define __UUID4_C__
#include "node_modules/uuid4.c/src/uuid4.c"
#endif
`
This will include both the function declaration and their definitions into a single file.
--------------------------------------------------------------------------------
Usage
- uuid4_seed() seeds the version 4 UUID generator.
- uuid4_gen() generates a version 4 UUID.
- uuid4_to_s() converts a version 4 UUID into a string.
Example usage:
`c
#include
#include
int main()
{
UUID4_STATE_T state;
UUID4_T uuid;
uuid4_seed(&state);
uuid4_gen(&state, &uuid);
char buffer[UUID4_STR_BUFFER_SIZE];
if (!uuid4_to_s(uuid, buffer, sizeof(buffer)))
exit(EXIT_FAILURE);
printf("%s\n", buffer);
return EXIT_SUCCESS;
}
`
--------------------------------------------------------------------------------
Customizing compilation
You can customize the library's behavior by defining the following macros:
- UUID4_FUNCSPEC
- UUID4_PREFIX
- UUID4_ASSERT
Compiling for Windows
There is a Visual Studio 2015 solution in the _win-vs14/ folder.
Compiling for Linux or Mac
There is a GNU Make 3.81 MakeFile in the _gnu-make/ folder:
$ make -j -C _gnu-make/
Compiling for Mac
See above if you want to compile from command line. Otherwise there is an Xcode
project located in the _mac-xcode/ folder.
Compiling for iOS
There is an Xcode project located in the _ios-xcode/ folder.
If you prefer compiling from command line and deploying to a jailbroken device
through SSH, use:
$ make -j -C _gnu-make/ platform=ios architecture=arm64 CC="$(xcrun --sdk iphoneos --find clang) -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -arch arm64" postbuild="codesign -s 'iPhone Developer'"
Compiling for Android
You will have to install the Android NDK, and point the $NDK_ROOT environment
variable to the NDK path: e.g. export NDK_ROOT=/opt/android-ndk (without a
trailing /` character).