Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 1 | /* $Id */ |
| 2 | /* |
Benny Prijono | a771a51 | 2007-02-19 01:13:53 +0000 | [diff] [blame] | 3 | * Copyright (C)2003-2007 Benny Prijono <benny@prijono.org> |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | #ifndef __PJ_GUID_H__ |
| 20 | #define __PJ_GUID_H__ |
| 21 | |
| 22 | |
| 23 | /** |
| 24 | * @file guid.h |
| 25 | * @brief GUID Globally Unique Identifier. |
| 26 | */ |
| 27 | #include <pj/types.h> |
| 28 | |
| 29 | |
| 30 | PJ_BEGIN_DECL |
| 31 | |
| 32 | |
| 33 | /** |
| 34 | * @defgroup PJ_DS Data Structure. |
| 35 | * @ingroup PJ |
| 36 | */ |
| 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 Prijono | 4e48b51 | 2007-05-16 13:41:00 +0000 | [diff] [blame] | 51 | * If real GUID generator is used, then the length will be between 32 and |
| 52 | * 36 bytes. If shadow GUID generator is used, then the length |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 53 | * will be 20 bytes. Application should not assume which algorithm will |
| 54 | * be used by GUID generator. |
Benny Prijono | 4e48b51 | 2007-05-16 13:41:00 +0000 | [diff] [blame] | 55 | * |
| 56 | * Regardless of the actual length of the GUID, it will not exceed |
| 57 | * PJ_GUID_MAX_LENGTH characters. |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 58 | * |
| 59 | * @see pj_GUID_STRING_LENGTH() |
| 60 | * @see PJ_GUID_MAX_LENGTH |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 61 | */ |
Benny Prijono | 1f61a8f | 2007-08-16 10:11:44 +0000 | [diff] [blame] | 62 | PJ_DECL_DATA(const unsigned) PJ_GUID_STRING_LENGTH; |
| 63 | |
| 64 | /** |
| 65 | * Get #PJ_GUID_STRING_LENGTH constant. |
| 66 | */ |
| 67 | PJ_DECL(unsigned) pj_GUID_STRING_LENGTH(); |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 68 | |
| 69 | /** |
| 70 | * PJ_GUID_MAX_LENGTH specifies the maximum length of GUID string, |
| 71 | * regardless of which algorithm to use. |
| 72 | */ |
Benny Prijono | 4e48b51 | 2007-05-16 13:41:00 +0000 | [diff] [blame] | 73 | #define PJ_GUID_MAX_LENGTH 36 |
Benny Prijono | 9033e31 | 2005-11-21 02:08:39 +0000 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * Create a globally unique string, which length is PJ_GUID_STRING_LENGTH |
| 77 | * characters. Caller is responsible for preallocating the storage used |
| 78 | * in the string. |
| 79 | * |
| 80 | * @param str The string to store the result. |
| 81 | * |
| 82 | * @return The string. |
| 83 | */ |
| 84 | PJ_DECL(pj_str_t*) pj_generate_unique_string(pj_str_t *str); |
| 85 | |
| 86 | /** |
| 87 | * Generate a unique string. |
| 88 | * |
| 89 | * @param pool Pool to allocate memory from. |
| 90 | * @param str The string. |
| 91 | */ |
| 92 | PJ_DECL(void) pj_create_unique_string(pj_pool_t *pool, pj_str_t *str); |
| 93 | |
| 94 | |
| 95 | /** |
| 96 | * @} |
| 97 | */ |
| 98 | |
| 99 | PJ_END_DECL |
| 100 | |
| 101 | #endif/* __PJ_GUID_H__ */ |
| 102 | |