blob: f9c5db5ebe1b95554586d69035b081650fca0ed1 [file] [log] [blame]
Benny Prijono90cc76e2008-07-11 00:56:07 +00001/* $Id$ */
Benny Prijono9033e312005-11-21 02:08:39 +00002/*
Benny Prijono844653c2008-12-23 17:27:53 +00003 * Copyright (C) 2008-2009 Teluu Inc. (http://www.teluu.com)
4 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
Benny Prijono9033e312005-11-21 02:08:39 +00005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20#ifndef __PJ_GUID_H__
21#define __PJ_GUID_H__
22
23
24/**
25 * @file guid.h
26 * @brief GUID Globally Unique Identifier.
27 */
28#include <pj/types.h>
29
30
31PJ_BEGIN_DECL
32
33
34/**
35 * @defgroup PJ_DS Data Structure.
Benny Prijono9033e312005-11-21 02:08:39 +000036 */
37/**
38 * @defgroup PJ_GUID Globally Unique Identifier
39 * @ingroup PJ_DS
40 * @{
41 *
42 * This module provides API to create string that is globally unique.
43 * If application doesn't require that strong requirement, it can just
44 * use #pj_create_random_string() instead.
45 */
46
47
48/**
49 * PJ_GUID_STRING_LENGTH specifies length of GUID string. The value is
50 * dependent on the algorithm used internally to generate the GUID string.
Benny Prijono4e48b512007-05-16 13:41:00 +000051 * If real GUID generator is used, then the length will be between 32 and
Benny Prijono8389c312008-02-21 21:36:34 +000052 * 36 bytes. Application should not assume which algorithm will
Benny Prijono9033e312005-11-21 02:08:39 +000053 * be used by GUID generator.
Benny Prijono4e48b512007-05-16 13:41:00 +000054 *
55 * Regardless of the actual length of the GUID, it will not exceed
56 * PJ_GUID_MAX_LENGTH characters.
Benny Prijono1f61a8f2007-08-16 10:11:44 +000057 *
58 * @see pj_GUID_STRING_LENGTH()
59 * @see PJ_GUID_MAX_LENGTH
Benny Prijono9033e312005-11-21 02:08:39 +000060 */
Benny Prijono1f61a8f2007-08-16 10:11:44 +000061PJ_DECL_DATA(const unsigned) PJ_GUID_STRING_LENGTH;
62
63/**
64 * Get #PJ_GUID_STRING_LENGTH constant.
65 */
Benny Prijono90cc76e2008-07-11 00:56:07 +000066PJ_DECL(unsigned) pj_GUID_STRING_LENGTH(void);
Benny Prijono9033e312005-11-21 02:08:39 +000067
68/**
69 * PJ_GUID_MAX_LENGTH specifies the maximum length of GUID string,
70 * regardless of which algorithm to use.
71 */
Benny Prijono4e48b512007-05-16 13:41:00 +000072#define PJ_GUID_MAX_LENGTH 36
Benny Prijono9033e312005-11-21 02:08:39 +000073
74/**
75 * Create a globally unique string, which length is PJ_GUID_STRING_LENGTH
76 * characters. Caller is responsible for preallocating the storage used
77 * in the string.
78 *
79 * @param str The string to store the result.
80 *
81 * @return The string.
82 */
83PJ_DECL(pj_str_t*) pj_generate_unique_string(pj_str_t *str);
84
85/**
86 * Generate a unique string.
87 *
88 * @param pool Pool to allocate memory from.
89 * @param str The string.
90 */
91PJ_DECL(void) pj_create_unique_string(pj_pool_t *pool, pj_str_t *str);
92
93
94/**
95 * @}
96 */
97
98PJ_END_DECL
99
100#endif/* __PJ_GUID_H__ */
101