123456789101112131415161718192021222324252627282930313233343536 |
- #include <rid.h>
- #include <stdio.h>
- #include <string.h>
- #include "../rid_hex.h"
- /* define the directory we want to generate our Rid paths in */
- #define DAT_DIR "dat/"
- /* define the number of characters in DAT_DIR minus the '\0' */
- #define DAT_DIR_LEN (sizeof(DAT_DIR) - 1)
- /* A type for a string big enough for our path */
- typedef char Dir_path[DAT_DIR_LEN + sizeof(Rid_hex_path)];
- int
- main(int argc, char *argv[])
- {
- Rid id;
- Dir_path dir_path;
- /* create a random rid */
- rid_set(id, NULL);
- /* set the dat/ part of the path */
- strcpy(dir_path, DAT_DIR);
- /* generate the rest of the path */
- rid_hex_path(dir_path + DAT_DIR_LEN, id);
- /* Now we can do anything we want with dir_path, it's just a string
- * that looks something like "dat/41/7ed28b7db28473685f0c1dbf9f453f"
- */
- printf("%s\n", dir_path);
- return 0;
- }
|