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>
57 #define ARG_COUNT 2 /* Number of ReadArgs() arguments */
64 /* Array filled by ReadArgs() call */
65 IPTR args
[ARG_COUNT
] = {0, 0};
67 struct RDArgs
*rda
; /* ReadArgs standard struct */
69 if((rda
= ReadArgs("RANDOM/S,AMOUNT/N", args
, NULL
)) != NULL
)
71 BOOL random
= (BOOL
)args
[0]; /* Random-based UUID? */
74 amount
= *(ULONG
*)args
[1]; /* Amount of uuid's was given. use it */
76 struct Library
*UUIDBase
= OpenLibrary("uuid.library", 0);
80 char uuidstr
[UUID_STRLEN
+1];
82 uuidstr
[UUID_STRLEN
] = 0;
86 /* Generate the uuid identifier */
88 UUID_Generate(UUID_TYPE_DCE_RANDOM
, &uuid
);
90 UUID_Generate(UUID_TYPE_DCE_TIME
, &uuid
);
92 /* unparse it into human-readable format */
93 UUID_Unparse(&uuid
, uuidstr
);
95 Printf("%s\n", uuidstr
);
98 CloseLibrary(UUIDBase
);