コード例 #1
0
ファイル: sysdep.c プロジェクト: moecake/uuid
/* system dependent call to get IEEE node ID.
   This sample implementation generates a random node ID. */
void get_ieee_node_identifier(uuid_node_t *node)
{
    static inited = 0;
    static uuid_node_t saved_node;
    char seed[16];
    FILE *fp;

    if (!inited) {
        fp = fopen("nodeid", "rb");
        if (fp) {
            fread(&saved_node, sizeof(saved_node), 1, fp);
            fclose(fp);
        } else {
            get_random_info(seed);
            seed[0] |= 0x01;
            memcpy(&saved_node, seed, sizeof(saved_node));
            fp = fopen("nodeid", "wb");
            if (fp) {
                fwrite(&saved_node, sizeof(saved_node), 1, fp);
                fclose(fp);
            }
        }
        inited = 1;
    }

    *node = saved_node;
}
コード例 #2
0
ファイル: sysdep.c プロジェクト: Michael-Lfx/vrjuggler
/* system dependent call to get IEEE node ID.
   This sample implementation generates a random node ID
   */
void get_ieee_node_identifier(uuid_node_t *node) {
  char seed[16];
  FILE * fd;
  static inited = 0;
  static uuid_node_t saved_node;

  if (!inited) {
      fd = fopen("nodeid", "rb");
      if (fd) {
           fread(&saved_node, sizeof(uuid_node_t), 1, fd);
           fclose(fd);
      }
      else {
           get_random_info(seed);
           seed[0] |= 0x80;
           memcpy(&saved_node, seed, sizeof(uuid_node_t));
           fd = fopen("nodeid", "wb");
           if (fd) {
                  fwrite(&saved_node, sizeof(uuid_node_t), 1, fd);
                  fclose(fd);
           };
      };
      inited = 1;
  };

  *node = saved_node;
};
コード例 #3
0
/* This sample implementation generates a random node ID   *
 * in lieu of a system dependent call to get IEEE node ID. */
static void get_pseudo_node_identifier(uuid_node_t *node)
{
    unsigned char seed[16];

    get_random_info(seed);
    seed[0] |= 0x80;
    memcpy(node, seed, sizeof(uuid_node_t));
}
コード例 #4
0
boost::uint64_t true_random() {
    boost::uint64_t result;
    adobe::md5_t::digest_t seed(get_random_info());

    std::memcpy(&result, &seed[0], sizeof(result));

    return result;
}
コード例 #5
0
ファイル: sysdep.c プロジェクト: benjaminopy5bo/pupnp-code
/*!
 * \brief System dependent call to get IEEE node ID.
 *
 * This sample implementation generates a random node ID.
 */
void get_ieee_node_identifier(uuid_node_t *node)
{
	unsigned char seed[16];
	static int inited = 0;
	static uuid_node_t saved_node;

	if (!inited) {
		get_random_info(seed);
		seed[0] |= 0x80;
		memcpy(&saved_node, seed, sizeof(uuid_node_t));
		inited = 1;
	};
	*node = saved_node;
};