1 /*
2  * sruid - unique id generator
3  *
4  * Copyright (C) 2012 Daniel-Constantin Mierla (asipto.com)
5  *
6  * This file is part of Kamailio, a free SIP server.
7  *
8  * Kamailio is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version
12  *
13  * Kamailio is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22 /*!
23 * \file
24 * \brief core/utils :: Unique ID generator
25 * \ingroup core/utils
26 * Module: \ref core/utils
27 */
28 
29 #ifndef _SRUID_H_
30 #define _SRUID_H_
31 
32 #include "../../core/str.h"
33 
34 #define SRUID_SIZE	40
35 
36 typedef enum {SRUID_INC=0, SRUID_LFSR=1} sruid_mode_t;
37 
38 typedef struct sruid {
39 	char buf[SRUID_SIZE];
40 	char *out;
41 	str uid;
42 	unsigned int counter;
43 	int pid;
44 	sruid_mode_t mode;
45 } sruid_t;
46 
47 int sruid_init(sruid_t *sid, char sep, char *cid, int mode);
48 int sruid_next(sruid_t *sid);
49 int sruid_next_safe(sruid_t *sid);
50 
51 #endif
52