2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /******************************************************************************
25 Generates one or more universally unique identifiers. They may be either
26 time-based or random. Please note that the quality of random generated
27 uuid's may be poor, due to the lack of high-quality noise generators on AROS.
31 RANDOM -- Generate randob-based UUID instead of time based
32 AMOUNT -- Amount of UUID's to generate. Defaults to 1.
48 ******************************************************************************/
50 #include <aros/debug.h>
51 #include <proto/exec.h>
52 #include <proto/dos.h>
53 #include <proto/uuid.h>
54 #include <libraries/uuid.h>
56 #define ARG_COUNT 2 /* Number of ReadArgs() arguments */
63 /* Array filled by ReadArgs() call */
64 IPTR args
[ARG_COUNT
] = {0, 0};
66 struct RDArgs
*rda
; /* ReadArgs standard struct */
68 if((rda
= ReadArgs("RANDOM/S,AMOUNT/N", args
, NULL
)) != NULL
)
70 BOOL random
= (BOOL
)args
[0]; /* Random-based UUID? */
73 amount
= *(ULONG
*)args
[1]; /* Amount of uuid's was given. use it */
75 struct Library
*UUIDBase
= OpenLibrary("uuid.library", 0);
79 char uuidstr
[UUID_STRLEN
+1];
81 uuidstr
[UUID_STRLEN
] = 0;
85 /* Generate the uuid identifier */
87 UUID_Generate(UUID_TYPE_DCE_RANDOM
, &uuid
);
89 UUID_Generate(UUID_TYPE_DCE_TIME
, &uuid
);
91 /* unparse it into human-readable format */
92 UUID_Unparse(&uuid
, uuidstr
);
94 Printf("%s\n", uuidstr
);
97 CloseLibrary(UUIDBase
);