一个UUID生成算法的C语言实现 --- WIN32版本 .
} uuid_t;
/**
* Checks whether the given string matches the UUID format.
* params:
* [in] uuid - the potential UUID string
* return
* TRUE if the given string is a UUID, FALSE otherwise
**/
BOOL is_uuid_string(const char *uuid);
/**
* Generates a new UUID. The UUID is a time-based time 1 UUID.
* A random per-process node identifier is used to avoid keeping global
* state and maintaining inter-process synchronization.
**/
void uuid_create(uuid_t* uuid);
/**
* Generates a new UUID string. The returned UUID is a time-based time 1 UUID.
* A random per-process node identifier is used to avoid keeping global
* state and maintaining inter-process synchronization.
* return UUID string (newly allocated)
**/
char *uuid_create_string(void);
/**
* Generates a name-based (type 3) UUID string from the given external
* identifier. The special namespace UUID is used as the namespace of
* the generated UUID.
* params
* [in] external - the external identifier
* return
* UUID string (newly allocated)
**/
void uuid_create_external(const char *external, uuid_t* uuid);
/**
* Translate a uuid_t to a uuid string
* return UUID string
**/
char *uuid_to_string(const uuid_t* uuid);
/**
* Get timestamp from a UUID
**/
void uuid_to_timestamp(const uuid_t* uuid, timestamp_t* time);
/**
* Resurn a description of timestamp NOT including fraction
**/
char* timestamp_to_string(const timestamp_t* time);
/**
* Compare two UUID's lexically
* return
* -1 u1 is lexically before u2
* 0 u1 is equal to u2
* 1 u1 is lexically after u2
*/
int uuid_compare(const uuid_t *u1, const uuid_t *u2);
/**
* Compare two UUID's temporally
* return
* -1 u1 is temporally before u2
* 0 u1 is equal to u2
* 1 u1 is temporally after u2
*/
int uuid_compare_time(const uuid_t *u1, const uuid_t *u2);
#endif /* UUID32_H_INCLUDED */
2008-09-15 Last created by cheungmine.
All rights reserved by cheungmine.
*/
#ifndef CDATATYPE_H__
#define CDATATYPE_H__
/*============================================================================*/
typedef unsigned char uchar, byte, BYTE;
typedef unsigned short uint16, word_t, ushort;
typedef unsigned int uint, uint32, dword_t, size_t;
typedef unsigned long ulong;
typedef __int64 int64;
typedef unsigned __int64 uint64, qword_t;
#ifndef BOOL
#define BOOL int
#define TRUE 1
#define FALSE 0
#endif
#ifndef RESULT
#define RESULT long
#define SUCCESS 0
#define ERROR -1
#endif
#define SIZE_BYTE 1
#define SIZE_SHORT 2
#define SIZE_INT 4
#define SIZE_FLT 4
#define SIZE_DBL 8
#define SIZE_WORD 2
#define SIZE_DWORD 4
#define SIZE_QWORD 8
#define SIZE_LINT 8
#define SIZE_INT64 8
#define SIZE_UUID 16
/*============================================================================*/
#endif /*CDATATYPE_H__*/
MD5算法生成的文件有:md5.h和md5.c,分别罗列如下:
char* MD5_sign (const unsigned char *str, unsigned int len);
#endif /* _MD5_H__ */
}
}
uuid32.c文件如下:
}
好了,到此,所有文件都列出来了,它们是:cdatatype.h、md5.h、uuid32.h、md5.c和uuid32.c。
最后是测试代码:
}
以上代码保证正确。请放心使用!
一个UUID生成算法的C语言实现 --- WIN32版本 .的更多相关文章
- 一个UUID生成算法的C语言实现——WIN32版本
源: 一个UUID生成算法的C语言实现——WIN32版本
- 更短且不失高效的UUID生成算法
Java原生的UUID长度为36位,嫌长 这里自己实现了一套自己的算法,来生成较短的UUID 由雪花算法启发而来, 大致原理是利用时间戳+随机值做值,然后转换成62进制(当然这个进制数你也可以搞成更多 ...
- UUID 生成(源代码编译)
根据定义,UUID(Universally Unique IDentifier,也称GUID)在时间和空间都是唯一的.为保证空间的唯一性,每个UUID使用了一个48位的值来记录,一般是计算机的网卡地址 ...
- roguelike地牢生成算法
文章原地址 上一个地图生成算法,这一次是一个地牢的生成算法,是一个国外的人写的算法,用dart语言写,我把它改成了unity-c#. 原作者博客地址:Rooms and Mazes: A Proced ...
- 开源一个比雪花算法更好用的ID生成算法(雪花漂移)
比雪花算法更好用的ID生成算法(单机或分布式唯一ID) 转载及版权声明 本人从未在博客园之外的网站,发表过本算法长文,其它网站所现文章,均属他人拷贝之作. 所有拷贝之作,均须保留项目开源链接,否则禁止 ...
- ZeroMQ接口函数之 :zmq_z85_decode – 从一个用Z85算法生成的文本中解析出二进制密码
ZeroMQ 官方地址 :http://api.zeromq.org/4-0:zmq_z85_decode zmq_z85_decode(3) ØMQ Manual - ØMQ/4.1 ...
- 一个简单的QQ隐藏图生成算法 通过jQuery和C#分别实现对.NET Core Web Api的访问以及文件上传
一个简单的QQ隐藏图生成算法 隐藏图不是什么新鲜的东西,具体表现在大部分社交软件中,预览图看到的是一张图,而点开后看到的又是另一张图.虽然很早就看到过这类图片,但是一直没有仔细研究过它的原理,今天 ...
- JAVA UUID 生成
UUID是指在一台机器上生成的数字,它保证对在同一时空中的所有机器都是唯一的.通常平台会提供生成UUID的API.UUID按照开放软件基金会(OSF)制定的标准计算,用到了以太网卡地址.纳秒级时间.芯 ...
- 魔方阵算法及C语言实现
1 魔方阵概念 填充的,每一行.每一列.对角线之和均相等的方阵,阶数n = 3,4,5….魔方阵也称为幻方阵. 例如三阶魔方阵为: 魔方阵有什么的规律呢? 魔方阵分为奇幻方和偶幻方.而偶幻方又分为是4 ...
随机推荐
- AutoPoco的使用
官方开发指导https://autopoco.codeplex.com/documentation 初步使用: SimpleUser是自己要批量创建的类 1)创建管理工厂 IGenerationSes ...
- (转)IDG副总裁楼军:顶级VC青睐什么样的创业者
学习能力是创业者的第一能力 创业者首先要有格局观和很强的学习能力. 具体什么意思?比如说去年IDG投了一个做C2C平台的海淘项目,创始人之前其实是帮他爱人做海淘代购.他爱人是一个代购买手,赚得还不错, ...
- [Bootstrap]全局样式(四)
按钮 1.基本类.btn {display/padding/margin-bottom/font-size/border-radius/border} 作用于< a:role:button &g ...
- (POJ 2318)TOYS 向量叉积
题目链接:http://poj.org/problem?id=2318 #include<stdio.h> #include<cstdlib> #include<cstr ...
- vs2008+qt进行开发
第一次接触qt vs,完全小白,网上找资料,各种乱,还大部分是很早以前的,挣扎了好几天终于搞定了, 在此给大家分享. 首先是下载vs2008 (我的项目组项目要求用这个版本),这个比较容易下载:然后是 ...
- C++ 的template
vector的标准模板是:template<template<typename X, class allocator<X> > class T>而普通模板则是tem ...
- iOS 非ARC基本内存管理系列 4-autorelease方法和@autoreleasepool
1.autorelease 基本用法 对象执行autorelease方法时会将对象添加到自动释放池中 当自动释放池销毁时自动释放池中所有对象作release操作 对象执行autorelease方法后自 ...
- DEDECMS中,list标签和pagelist标签
列表数据标签:dede:list {dede:list col='' titlelen='' infolen='' imgwidth='' imgheight='' orderby='' pagesi ...
- js优化 ----js的有序加载
说到有序加载,我们先来说说js的无序加载: <script src="jquery/jquery-1.4.1.js" type="text/javascript&q ...
- 译文:Javascript-function's return
个人理解+google翻译.如有错误,请指正.原文来自MDN:return 概要 由function返回指定值. 版本信息 实现: JavaScript 1.0, NES 2.0(NES:游戏机在欧洲 ...