一个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 ...
随机推荐
- 第三十一篇、iOS 9版本适配
1.网络适配(强制回退HTTP) 为了强制增强数据访问安全, iOS9 默认会把 所有的http请求 所有从NSURLConnection . CFURL . NSURLSession发出的 HTTP ...
- 使用JS调用WebService接口
<script> $(document).ready(function () { var username = "admin"; var password = &quo ...
- The influence of informal governance mechanisms on knowledge integration
Title:The influence of informal governance mechanisms on knowledge integration within cross-function ...
- META 标签的使用
<meta />标记详解 说明: meta是一个单边标签 ,主要功能:是用于设置或显示一些控制信息,告诉浏览器以什么编码显示. <meta>标记有两个主要的属性: http-e ...
- spring aop配置及用例说明(1)
欢迎转载交流,博客地址http://www.cnblogs.com/shizhongtao/p/3469776.html 首先,什么是aop,其实通俗一点讲就是,再方法执行时候我们加入其它业务逻辑.比 ...
- C++编译期判断是否能够转型
#include <iostream> #include <vector> using namespace std; template<class T,class U&g ...
- myeclipse 的 working set
想必大家的myeclipse会有很多工程看的和不方便,那么怎么让它看的简洁一点呢,使用working set 会让你的目录看起来没有那么的多. 首先是怎么创建 working set ,在新建时选择 ...
- js设备判断
判断设备android,weixin,ios var UserAgent=navigator.userAgent.toLowerCase(); var IS_ANDROID=false; var IS ...
- 实验一:点亮led
一.先看原理图:
- 【Winform】锐浪报表使用
在发开报表时,使用了锐浪报表. 需要注意的一些细节: 1.给staticbox设置文本,通过GridppReport的变量,使用ControlByName获取到控件后进行设置文字 _report.Co ...