Browse Source

lib/kcore: cleaned up unused code

- local route and errinfo related code were not used for long time
- also moved some bits of code to more appropriate location
Daniel-Constantin Mierla 13 năm trước cách đây
mục cha
commit
1aedf95f1a
67 tập tin đã thay đổi với 235 bổ sung480 xóa
  1. 28 0
      crc.c
  2. 2 0
      crc.h
  3. 89 0
      hashes.h
  4. 0 75
      lib/kcore/errinfo.c
  5. 0 59
      lib/kcore/errinfo.h
  6. 0 112
      lib/kcore/hash_func.h
  7. 0 30
      lib/kcore/km_crc.c
  8. 0 9
      lib/kcore/km_crc.h
  9. 0 112
      lib/kcore/km_ut.h
  10. 0 3
      lib/kcore/parse_ppi.c
  11. 0 1
      lib/kcore/statistics.c
  12. 0 1
      modules/avpops/avpops_parse.c
  13. 1 1
      modules/carrierroute/prime_hash.c
  14. 1 1
      modules/db_cassandra/dbcassa_table.c
  15. 1 1
      modules/lcr/hash.c
  16. 0 1
      modules/lcr/lcr_mod.c
  17. 0 1
      modules/pipelimit/pipelimit.c
  18. 0 1
      modules/pipelimit/pl_ht.c
  19. 0 1
      modules/ratelimit/ratelimit.c
  20. 0 1
      modules/rtpproxy/rtpproxy.c
  21. 0 1
      modules_k/acc/acc.c
  22. 0 1
      modules_k/acc/acc_extra.c
  23. 0 1
      modules_k/acc/acc_logic.c
  24. 1 2
      modules_k/cfgutils/cfgutils.c
  25. 1 1
      modules_k/cpl-c/cpl_parser.c
  26. 1 1
      modules_k/db_text/dbt_lib.c
  27. 1 1
      modules_k/dialog/dialog.c
  28. 1 1
      modules_k/dialog/dlg_hash.c
  29. 2 2
      modules_k/dialog/dlg_profile.c
  30. 0 1
      modules_k/dialog/dlg_req_within.c
  31. 1 1
      modules_k/dispatcher/ds_ht.c
  32. 1 1
      modules_k/dmq/dmq.c
  33. 1 1
      modules_k/domain/hash.c
  34. 1 1
      modules_k/htable/ht_api.c
  35. 1 1
      modules_k/imc/imc.c
  36. 1 1
      modules_k/imc/imc_mng.c
  37. 0 1
      modules_k/nathelper/nathelper.c
  38. 1 1
      modules_k/p_usrloc/udomain.c
  39. 1 1
      modules_k/p_usrloc/ul_db_handle.c
  40. 1 1
      modules_k/p_usrloc/urecord.c
  41. 1 1
      modules_k/permissions/hash.c
  42. 1 1
      modules_k/presence/hash.c
  43. 1 1
      modules_k/presence/notify.c
  44. 1 1
      modules_k/presence/presence.c
  45. 1 1
      modules_k/presence/presentity.c
  46. 1 1
      modules_k/presence/publish.c
  47. 1 1
      modules_k/presence/subscribe.c
  48. 1 1
      modules_k/pua/hash.c
  49. 1 1
      modules_k/pua/send_publish.c
  50. 1 1
      modules_k/pua/send_subscribe.c
  51. 1 24
      modules_k/pv/pv_core.c
  52. 0 1
      modules_k/pv/pv_trans.c
  53. 0 1
      modules_k/registrar/reg_mod.c
  54. 1 1
      modules_k/rls/notify.c
  55. 1 1
      modules_k/rls/resource_notify.c
  56. 1 1
      modules_k/rls/rls.c
  57. 1 1
      modules_k/rls/subscribe.c
  58. 1 1
      modules_k/seas/event_dispatcher.c
  59. 1 1
      modules_k/seas/statistics.h
  60. 0 1
      modules_k/siputils/ring.c
  61. 1 1
      modules_k/sqlops/sql_api.c
  62. 0 1
      modules_k/sst/sst_handlers.c
  63. 1 1
      modules_k/usrloc/udomain.c
  64. 1 1
      modules_k/usrloc/urecord.c
  65. 0 1
      modules_s/usrloc/ucontact.c
  66. 14 0
      trim.h
  67. 63 0
      ut.h

+ 28 - 0
crc.c

@@ -294,6 +294,34 @@ int crc32file (char *name)
 	fclose(fin); return OK;
 }
 
+/*!
+ * \brief CRC32 value from source string
+ * \param source_string source string
+ * \param hash_ret calulated CRC32
+ */
+void crc32_uint (str *source_string, unsigned int *hash_ret) 
+{	
+	unsigned int hash;	
+	unsigned int len;
+	const char *data;
+	
+	hash = 0xffffffff;
+	data = source_string->s;
+	
+	for (len = source_string->len / 4; len--; data += 4) {
+		hash = crc_32_tab[((unsigned char)hash) ^ data[0]] ^ (hash >> 8);
+		hash = crc_32_tab[((unsigned char)hash) ^ data[1]] ^ (hash >> 8);
+		hash = crc_32_tab[((unsigned char)hash) ^ data[2]] ^ (hash >> 8);
+		hash = crc_32_tab[((unsigned char)hash) ^ data[3]] ^ (hash >> 8);
+	}
+	
+	for (len = source_string->len % 4; len--; data++) {
+		hash = crc_32_tab[((unsigned char)hash) ^ *data] ^ (hash >> 8);
+	}
+	
+	*hash_ret = ~hash;
+}
+
 /*
 
 int main(int argc, char **argv)

+ 2 - 0
crc.h

@@ -16,5 +16,7 @@ unsigned short crcitt_string_ex( char *s, int len, register unsigned short ccitt
 unsigned short crcitt_string( char *s, int len );
 void crcitt_string_array( char *dst, str src[], int size );
 
+void crc32_uint (str *source_string, unsigned int *hash_ret);
+
 #endif /* _CRC_H_ */
 

+ 89 - 0
hashes.h

@@ -251,5 +251,94 @@ inline static unsigned int get_hash2_case_raw2(const str* key1,
 }
 
 
+/*
+ * generic hashing - from the intial origins of ser
+ */
+#define ch_h_inc h+=v^(v>>3)
+#define ch_icase(_c) (((_c)>='A'&&(_c)<='Z')?((_c)|0x20):(_c))
+
+/*
+ * case sensitive hashing
+ * - s1 - str to hash
+ * - s2 - optional - continue hashing over s2
+ * - size - optional - size of hash table (must be power of 1); if set (!=0),
+ *   instead of hash id, returned value is slot index
+ * return computed hash id or hash table slot index
+ */
+static inline unsigned int core_hash(const str *s1, const str *s2,
+		const unsigned int size)
+{
+	char *p, *end;
+	register unsigned v;
+	register unsigned h;
+
+	h=0;
+
+	end=s1->s+s1->len;
+	for ( p=s1->s ; p<=(end-4) ; p+=4 ){
+		v=(*p<<24)+(p[1]<<16)+(p[2]<<8)+p[3];
+		ch_h_inc;
+	}
+	v=0;
+	for (; p<end ; p++){ v<<=8; v+=*p;}
+	ch_h_inc;
+
+	if (s2) {
+		end=s2->s+s2->len;
+		for (p=s2->s; p<=(end-4); p+=4){
+			v=(*p<<24)+(p[1]<<16)+(p[2]<<8)+p[3];
+			ch_h_inc;
+		}
+		v=0;
+		for (; p<end ; p++){ v<<=8; v+=*p;}
+		ch_h_inc;
+	}
+	h=((h)+(h>>11))+((h>>13)+(h>>23));
+	return size?((h)&(size-1)):h;
+}
+
+
+/*
+ * case insensitive hashing
+ * - s1 - str to hash
+ * - s2 - optional - continue hashing over s2
+ * - size - optional - size of hash table (must be power of 1); if set (!=0),
+ *   instead of hash id, returned value is slot index
+ * return computed hash id or hash table slot index
+ */
+static inline unsigned int core_case_hash( str *s1, str *s2,
+		unsigned int size)
+{
+	char *p, *end;
+	register unsigned v;
+	register unsigned h;
+
+	h=0;
+
+	end=s1->s+s1->len;
+	for ( p=s1->s ; p<=(end-4) ; p+=4 ){
+		v=(ch_icase(*p)<<24)+(ch_icase(p[1])<<16)+(ch_icase(p[2])<<8)
+			+ ch_icase(p[3]);
+		ch_h_inc;
+	}
+	v=0;
+	for (; p<end ; p++){ v<<=8; v+=ch_icase(*p);}
+	ch_h_inc;
+
+	if (s2) {
+		end=s2->s+s2->len;
+		for (p=s2->s; p<=(end-4); p+=4){
+			v=(ch_icase(*p)<<24)+(ch_icase(p[1])<<16)+(ch_icase(p[2])<<8)
+				+ ch_icase(p[3]);
+			ch_h_inc;
+		}
+		v=0;
+		for (; p<end ; p++){ v<<=8; v+=ch_icase(*p);}
+		ch_h_inc;
+	}
+	h=((h)+(h>>11))+((h>>13)+(h>>23));
+	return size?((h)&(size-1)):h;
+}
+
 
 #endif

+ 0 - 75
lib/kcore/errinfo.c

@@ -1,75 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2006 Voice Sistem SRL
- *
- * This file is part of Kamailio, a free SIP server.
- *
- * Kamailio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * Kamailio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/*!
- * \file errinfo.c
- * \brief Kamailio Error info functions
- */
-
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "../../dprint.h"
-#include "errinfo.h"
-
-/*! global error info */
-err_info_t _oser_err_info;
-
-/*! \brief Get global error state
- */
-err_info_t* get_err_info(void) { return &_oser_err_info; }
-
-/*! \brief Initialize global error state
- */
-void init_err_info(void)
-{
-	memset(&_oser_err_info, 0, sizeof(err_info_t));
-}
-
-/*! \brief Set suggested error info message
- */
-void set_err_info(int ec, int el, char *info)
-{
-	LM_DBG("ec: %d, el: %d, ei: '%s'\n", ec, el,
-			(info)?info:"");
-	_oser_err_info.eclass = ec;
-	_oser_err_info.level = el;
-	if(info)
-	{
-		_oser_err_info.info.s   = info;
-		_oser_err_info.info.len = strlen(info);
-	}
-}
-
-/*! \brief Set suggested error reply
- */
-void set_err_reply(int rc, char *rr)
-{
-	_oser_err_info.rcode = rc;
-	if(rr)
-	{
-		_oser_err_info.rreason.s   = rr;
-		_oser_err_info.rreason.len = strlen(rr);
-	}
-}
-

+ 0 - 59
lib/kcore/errinfo.h

@@ -1,59 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2006 Voice Sistem SRL
- *
- * This file is part of Kamailio, a free SIP server.
- *
- * Kamailio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * Kamailio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-/*!
- * \file errinfo.h
- * \brief Error handling
- */
-
-
-#ifndef _errinfo_h_
-#define _errinfo_h_
-
-#include "../../str.h"
-
-/*! \name ErrorClasses  error clases */
-#define OSER_EC_PARSER	1 /*!< parse error */
-#define OSER_EC_PMEMORY	2 /*!< private memory error */
-#define OSER_EC_SMEMORY	3 /*!< share memory error */
-
-#define OSER_EL_CRITIC	1
-#define OSER_EL_HIGH	2
-#define OSER_EL_MEDIUM	3 /*!< severity level normal - used by parsing errors */
-#define OSER_EL_NORMAL	4
-#define OSER_EL_LOW	5
-
-typedef struct err_info_
-{
-	int eclass;		/*!< error class */
-	int level;		/*!< severity level (lower is higher) */
-	str info;		/*!< error details */
-	int rcode;		/*!< recommended reply code */
-	str rreason;	/*!< recommended reply reason phrase */
-} err_info_t;
-
-void init_err_info(void);
-void set_err_info(int ec, int el, char *info);
-void set_err_reply(int rc, char *rr);
-err_info_t* get_err_info(void);
-
-#endif

+ 0 - 112
lib/kcore/hash_func.h

@@ -1,112 +0,0 @@
-/*
- * $Id$
- *
- * Copyright (C) 2001-2003 FhG Fokus
- *
- * This file is part of Kamailio, a free SIP server.
- *
- * Kamailio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * Kamailio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * History:
- *---------
- *
- * 2006-01-20 - new_hash1() added; support for configurable hash size
- *              added (bogdan)
- * 2006-03-13 - new_hash1() and new_hash2() merged into core_hash();
- *              added core_case_hash() for case insensitive hashes;
- *              all TM dependet stuff moved to TM config file (bogdan)
- */
-
-/*!
- * \file
- * \brief Hash functions
- */
-
-
-#ifndef _HASH_FUNC_H_
-#define _HASH_FUNC_H_
-
-#include "../../str.h"
-
-
-#define ch_h_inc h+=v^(v>>3)
-#define ch_icase(_c) (((_c)>='A'&&(_c)<='Z')?((_c)|0x20):(_c))
-static inline unsigned int core_hash(const str *s1, const str *s2, const unsigned int size)
-{
-	char *p, *end;
-	register unsigned v;
-	register unsigned h;
-
-	h=0;
-
-	end=s1->s+s1->len;
-	for ( p=s1->s ; p<=(end-4) ; p+=4 ){
-		v=(*p<<24)+(p[1]<<16)+(p[2]<<8)+p[3];
-		ch_h_inc;
-	}
-	v=0;
-	for (; p<end ; p++){ v<<=8; v+=*p;}
-	ch_h_inc;
-
-	if (s2) {
-		end=s2->s+s2->len;
-		for (p=s2->s; p<=(end-4); p+=4){
-			v=(*p<<24)+(p[1]<<16)+(p[2]<<8)+p[3];
-			ch_h_inc;
-		}
-		v=0;
-		for (; p<end ; p++){ v<<=8; v+=*p;}
-		ch_h_inc;
-	}
-	h=((h)+(h>>11))+((h>>13)+(h>>23));
-	return size?((h)&(size-1)):h;
-}
-
-
-static inline unsigned int core_case_hash( str *s1, str *s2, unsigned int size)
-{
-	char *p, *end;
-	register unsigned v;
-	register unsigned h;
-
-	h=0;
-
-	end=s1->s+s1->len;
-	for ( p=s1->s ; p<=(end-4) ; p+=4 ){
-		v=(ch_icase(*p)<<24)+(ch_icase(p[1])<<16)+(ch_icase(p[2])<<8)
-			+ ch_icase(p[3]);
-		ch_h_inc;
-	}
-	v=0;
-	for (; p<end ; p++){ v<<=8; v+=ch_icase(*p);}
-	ch_h_inc;
-
-	if (s2) {
-		end=s2->s+s2->len;
-		for (p=s2->s; p<=(end-4); p+=4){
-			v=(ch_icase(*p)<<24)+(ch_icase(p[1])<<16)+(ch_icase(p[2])<<8)
-				+ ch_icase(p[3]);
-			ch_h_inc;
-		}
-		v=0;
-		for (; p<end ; p++){ v<<=8; v+=ch_icase(*p);}
-		ch_h_inc;
-	}
-	h=((h)+(h>>11))+((h>>13)+(h>>23));
-	return size?((h)&(size-1)):h;
-}
-
-
-#endif

+ 0 - 30
lib/kcore/km_crc.c

@@ -1,30 +0,0 @@
-#include "km_crc.h"
-
-/*!
- * \brief CRC32 value from source string
- * \param source_string source string
- * \param hash_ret calulated CRC32
- */
-void crc32_uint (str *source_string, unsigned int *hash_ret) 
-{	
-	unsigned int hash;	
-	unsigned int len;
-	const char *data;
-	
-	hash = 0xffffffff;
-	data = source_string->s;
-	
-	for (len = source_string->len / 4; len--; data += 4) {
-		hash = crc_32_tab[((unsigned char)hash) ^ data[0]] ^ (hash >> 8);
-		hash = crc_32_tab[((unsigned char)hash) ^ data[1]] ^ (hash >> 8);
-		hash = crc_32_tab[((unsigned char)hash) ^ data[2]] ^ (hash >> 8);
-		hash = crc_32_tab[((unsigned char)hash) ^ data[3]] ^ (hash >> 8);
-	}
-	
-	for (len = source_string->len % 4; len--; data++) {
-		hash = crc_32_tab[((unsigned char)hash) ^ *data] ^ (hash >> 8);
-	}
-	
-	*hash_ret = ~hash;
-}
-

+ 0 - 9
lib/kcore/km_crc.h

@@ -1,9 +0,0 @@
-#ifndef _KM_CRC_H
-#define _KM_CRC_H
-
-#include "../../crc.h"
-#include "../../str.h"
-
-void crc32_uint (str *source_string, unsigned int *hash_ret);
-
-#endif /* _KM_CRC_H */

+ 0 - 112
lib/kcore/km_ut.h

@@ -1,112 +0,0 @@
-/*
- *$Id$
- *
- * - various general purpose functions
- *
- * Copyright (C) 2001-2003 FhG Fokus
- *
- * This file is part of Kamailio, a free SIP server.
- *
- * Kamailio is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version
- *
- * Kamailio is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License 
- * along with this program; if not, write to the Free Software 
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-/*!
- * \file
- * \brief Various utility functions, mostly related to string handling
- */
-
-#ifndef _KM_UT_H
-#define _KM_UT_H
-
-#include "../../ut.h"
-
-#ifndef MIN
-#define MIN(a, b) (a<b?a:b)
-#endif
-#ifndef MAX
-#define MAX(a, b) (a>b?a:b)
-#endif
-
-
-/* INTeger-TO-Buffer-STRing : convers an unsigned long to a string 
- * IMPORTANT: the provided buffer must be at least INT2STR_MAX_LEN size !! */
-static inline char* int2bstr(unsigned long l, char *s, int* len)
-{
-	int i;
-	i=INT2STR_MAX_LEN-2;
-	s[INT2STR_MAX_LEN-1]=0;
-	/* null terminate */
-	do{
-		s[i]=l%10+'0';
-		i--;
-		l/=10;
-	}while(l && (i>=0));
-	if (l && (i<0)){
-		LM_CRIT("overflow error\n");
-	}
-	if (len) *len=(INT2STR_MAX_LEN-2)-i;
-	return &s[i+1];
-}
-
-
-inline static int hexstr2int(char *c, int len, unsigned int *val)
-{
-	char *pc;
-	int r;
-	char mychar;
-
-	r=0;
-	for (pc=c; pc<c+len; pc++) {
-		r <<= 4 ;
-		mychar=*pc;
-		if ( mychar >='0' && mychar <='9') r+=mychar -'0';
-		else if (mychar >='a' && mychar <='f') r+=mychar -'a'+10;
-		else if (mychar  >='A' && mychar <='F') r+=mychar -'A'+10;
-		else return -1;
-	}
-	*val = r;
-	return 0;
-}
-
-
-
-/*
- * Convert a str (base 10 or 16) into integer
- */
-static inline int strno2int( str *val, unsigned int *mask )
-{
-	/* hexa or decimal*/
-	if (val->len>2 && val->s[0]=='0' && val->s[1]=='x') {
-		return hexstr2int( val->s+2, val->len-2, mask);
-	} else {
-		return str2int( val, mask);
-	}
-}
-
-
-
-/*! right and left space trimming */
-#define trim_spaces_lr(_s_)												\
-	do{																	\
-		for(;(_s_).s[(_s_).len-1]==' ';(_s_).s[--(_s_).len]=0);			\
-		for(;(_s_).s[0]==' ';(_s_).s=(_s_).s+1,(_s_).len--);			\
-																		\
-	}																	\
-	while(0);															\
-	
-
-
-#endif /* _KM_UT_H */

+ 0 - 3
lib/kcore/parse_ppi.c

@@ -34,7 +34,6 @@
 #include "../../dprint.h"
 #include "../../parser/msg_parser.h"
 #include "../../ut.h"
-#include "errinfo.h"
 #include "../../mem/mem.h"
 
 
@@ -113,8 +112,6 @@ struct sip_uri *parse_ppi_uri(struct sip_msg *msg)
 	{
 		LM_ERR("failed to parse P-P-I URI\n");
 		memset(&tb->parsed_uri, 0, sizeof(struct sip_uri));
-		set_err_info(OSER_EC_PARSER, OSER_EL_MEDIUM, "error parsing P-P-I URI");
-		set_err_reply(400, "bad P-Preferred-Identity uri");
 		return NULL;
 	}
 

+ 0 - 1
lib/kcore/statistics.c

@@ -41,7 +41,6 @@
 #include "../../ut.h"
 #include "../../dprint.h"
 #include "../../socket_info.h"
-#include "km_ut.h"
 #include "statistics.h"
 
 #ifdef STATISTICS

+ 0 - 1
modules/avpops/avpops_parse.c

@@ -35,7 +35,6 @@
 #include "../../dprint.h"
 #include "../../usr_avp.h"
 #include "../../mem/mem.h"
-#include "../../lib/kcore/km_ut.h"
 #include "avpops_parse.h"
 
 

+ 1 - 1
modules/carrierroute/prime_hash.c

@@ -31,7 +31,7 @@
 #include "../../parser/parse_uri.h"
 #include "../../parser/parse_to.h"
 #include "../../parser/parse_from.h"
-#include "../../lib/kcore/km_crc.h"
+#include "../../crc.h"
 
 #include <ctype.h>
 #include <stdio.h> /* for snprintf */

+ 1 - 1
modules/db_cassandra/dbcassa_table.c

@@ -35,7 +35,7 @@
 #include "../../mem/shm_mem.h"
 #include "../../mem/mem.h"
 #include "../../dprint.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../lock_ops.h"
 
 #include "dbcassa_table.h"

+ 1 - 1
modules/lcr/hash.c

@@ -28,7 +28,7 @@
  */
 
 #include "../../mem/shm_mem.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "lcr_mod.h"
 
 #define rule_hash(_s) core_hash(_s, 0, lcr_rule_hash_size_param)

+ 0 - 1
modules/lcr/lcr_mod.c

@@ -68,7 +68,6 @@
 #include "../../mem/mem.h"
 #include "../../mem/shm_mem.h"
 #include "../../lib/srdb1/db.h"
-#include "../../lib/kcore/km_ut.h"
 #include "../../usr_avp.h"
 #include "../../parser/parse_from.h"
 #include "../../parser/msg_parser.h"

+ 0 - 1
modules/pipelimit/pipelimit.c

@@ -49,7 +49,6 @@
 #include "../../data_lump_rpl.h"
 #include "../../lib/kcore/statistics.h"
 #include "../../modules/sl/sl.h"
-#include "../../lib/kcore/km_ut.h"
 #include "../../lib/kmi/mi.h"
 
 #include "pl_ht.h"

+ 0 - 1
modules/pipelimit/pl_ht.c

@@ -39,7 +39,6 @@
 #include "../../hashes.h"
 #include "../../mem/shm_mem.h"
 #include "../../lib/kmi/mi.h"
-#include "../../lib/kcore/km_ut.h"
 
 #include "pl_ht.h"
 

+ 0 - 1
modules/ratelimit/ratelimit.c

@@ -49,7 +49,6 @@
 #include "../../data_lump.h"
 #include "../../data_lump_rpl.h"
 #include "../../lib/kcore/statistics.h"
-#include "../../lib/kcore/km_ut.h"
 #include "../../rpc_lookup.h"
 
 

+ 0 - 1
modules/rtpproxy/rtpproxy.c

@@ -210,7 +210,6 @@
 #include "../../pt.h"
 #include "../../timer_proc.h"
 #include "../../lib/kmi/mi.h"
-#include "../../lib/kcore/km_ut.h"
 #include "../../pvar.h"
 #include "../../lvalue.h"
 #include "../../msg_translator.h"

+ 0 - 1
modules_k/acc/acc.c

@@ -51,7 +51,6 @@
 #include "../../mem/mem.h"
 #include "../../usr_avp.h"
 #include "../../lib/srdb1/db.h"
-#include "../../lib/kcore/km_ut.h"
 #include "../../parser/hf.h"
 #include "../../parser/msg_parser.h"
 #include "../../parser/parse_from.h"

+ 0 - 1
modules_k/acc/acc_extra.c

@@ -48,7 +48,6 @@
 #include "../../ut.h"
 #include "../../usr_avp.h"
 #include "../../mem/mem.h"
-#include "../../lib/kcore/km_ut.h"
 #include "acc_api.h"
 #include "acc_extra.h"
 

+ 0 - 1
modules_k/acc/acc_logic.c

@@ -43,7 +43,6 @@
 #include "../../parser/parse_content.h"
 #include "../../modules/tm/tm_load.h"
 #include "../rr/api.h"
-#include "../../lib/kcore/km_ut.h"
 #include "../../flags.h"
 #include "acc.h"
 #include "acc_api.h"

+ 1 - 2
modules_k/cfgutils/cfgutils.c

@@ -68,8 +68,7 @@
 #include "../../md5.h"
 #include "../../md5utils.h"
 #include "../../globals.h"
-#include "../../lib/kcore/hash_func.h"
-#include "../../lib/kcore/km_ut.h"
+#include "../../hashes.h"
 #include "../../locking.h"
 #include <stdio.h>
 #include <stdlib.h>

+ 1 - 1
modules_k/cpl-c/cpl_parser.c

@@ -32,7 +32,7 @@
 #include <libxml/parser.h>
 
 #include "../../parser/parse_uri.h"
-#include "../../lib/kcore/km_ut.h"
+#include "../../trim.h"
 #include "../../dprint.h"
 #include "../../str.h"
 #include "../../ut.h"

+ 1 - 1
modules_k/db_text/dbt_lib.c

@@ -36,7 +36,7 @@
 #include "../../mem/shm_mem.h"
 #include "../../mem/mem.h"
 #include "../../dprint.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 
 #include "dbt_util.h"
 #include "dbt_lib.h"

+ 1 - 1
modules_k/dialog/dialog.c

@@ -66,7 +66,7 @@
 #include "../../mod_fix.h"
 #include "../../script_cb.h"
 #include "../../lib/kcore/faked_msg.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../lib/kcore/kstats_wrapper.h"
 #include "../../mem/mem.h"
 #include "../../lib/kmi/mi.h"

+ 1 - 1
modules_k/dialog/dlg_hash.c

@@ -54,7 +54,7 @@
 
 #include "../../dprint.h"
 #include "../../ut.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../lib/kmi/mi.h"
 #include "dlg_timer.h"
 #include "dlg_var.h"

+ 2 - 2
modules_k/dialog/dlg_profile.c

@@ -33,8 +33,8 @@
 
 
 #include "../../mem/shm_mem.h"
-#include "../../lib/kcore/hash_func.h"
-#include "../../lib/kcore/km_ut.h"
+#include "../../hashes.h"
+#include "../../trim.h"
 #include "../../dprint.h"
 #include "../../ut.h"
 #include "../../route.h"

+ 0 - 1
modules_k/dialog/dlg_req_within.c

@@ -37,7 +37,6 @@
 #include "../../modules/tm/dlg.h"
 #include "../../modules/tm/tm_load.h"
 #include "../../lib/kmi/tree.h"
-#include "../../lib/kcore/km_ut.h"
 #include "../../lib/kcore/kstats_wrapper.h"
 #include "dlg_timer.h"
 #include "dlg_hash.h"

+ 1 - 1
modules_k/dispatcher/ds_ht.c

@@ -26,7 +26,7 @@
 #include "../../mem/shm_mem.h"
 #include "../../mem/mem.h"
 #include "../../dprint.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../ut.h"
 
 #include "ds_ht.h"

+ 1 - 1
modules_k/dmq/dmq.c

@@ -46,7 +46,7 @@
 #include "../../modules/sl/sl.h"
 #include "../../pt.h"
 #include "../../lib/kmi/mi.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "dmq.h"
 #include "dmq_funcs.h"
 #include "peer.h"

+ 1 - 1
modules_k/domain/hash.c

@@ -25,7 +25,7 @@
 
 #include "../../dprint.h"
 #include "../../ut.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../mem/shm_mem.h"
 #include "../../lib/kmi/mi.h"
 #include "domain_mod.h"

+ 1 - 1
modules_k/htable/ht_api.c

@@ -28,7 +28,7 @@
 #include "../../shm_init.h"
 #include "../../dprint.h"
 #include "../../parser/parse_param.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../ut.h"
 #include "../../re.h"
 

+ 1 - 1
modules_k/imc/imc.c

@@ -47,7 +47,7 @@
 #include "../../parser/parse_content.h"
 #include "../../parser/contact/parse_contact.h"
 #include "../../resolve.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../lib/kmi/mi.h"
 
 #include "../../modules/tm/tm_load.h"

+ 1 - 1
modules_k/imc/imc_mng.c

@@ -34,7 +34,7 @@
 #include "../../mem/mem.h"
 #include "../../mem/shm_mem.h"
 #include "../../dprint.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 
 #include "imc_mng.h"
 /* imc hash table */

+ 0 - 1
modules_k/nathelper/nathelper.c

@@ -212,7 +212,6 @@
 #include "../../timer_proc.h"
 #include "../../lib/kmi/attr.h"
 #include "../../lib/kmi/mi.h"
-#include "../../lib/kcore/km_ut.h"
 #include "../../pvar.h"
 #include "../../lvalue.h"
 #include "../../msg_translator.h"

+ 1 - 1
modules_k/p_usrloc/udomain.c

@@ -43,7 +43,7 @@
 #include "../../lib/srdb1/db.h"
 #include "../../socket_info.h"
 #include "../../ut.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "p_usrloc_mod.h"            /* usrloc module parameters */
 #include "utime.h"
 #include "ul_db_layer.h"

+ 1 - 1
modules_k/p_usrloc/ul_db_handle.c

@@ -23,7 +23,7 @@
 #include "p_usrloc_mod.h"
 #include "ul_db.h"
 #include "ul_db_watch.h"
-#include "../../lib/kcore/km_crc.h"
+#include "../../crc.h"
 
 static ul_db_handle_list_t * db_handles = NULL;
 

+ 1 - 1
modules_k/p_usrloc/urecord.c

@@ -39,7 +39,7 @@
 #include "../../mem/shm_mem.h"
 #include "../../dprint.h"
 #include "../../ut.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "p_usrloc_mod.h"
 #include "utime.h"
 #include "../usrloc/ul_callback.h"

+ 1 - 1
modules_k/permissions/hash.c

@@ -25,7 +25,7 @@
 #include "../../mem/shm_mem.h"
 #include "../../parser/parse_from.h"
 #include "../../ut.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../usr_avp.h"
 #include "../../ip_addr.h"
 #include "../../pvar.h"

+ 1 - 1
modules_k/presence/hash.c

@@ -34,7 +34,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include "../../mem/shm_mem.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../dprint.h"
 #include "../../str.h"
 #include "../pua/hash.h"

+ 1 - 1
modules_k/presence/notify.c

@@ -43,7 +43,7 @@
 #include "../../str.h"
 #include "../../lib/srdb1/db.h"
 #include "../../lib/srdb1/db_val.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../socket_info.h"
 #include "../../modules/tm/tm_load.h"
 #include "../pua/hash.h"

+ 1 - 1
modules_k/presence/presence.c

@@ -63,7 +63,7 @@
 #include "../../modules/sl/sl.h"
 #include "../../pt.h"
 #include "../../lib/kmi/mi.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../pua/hash.h"
 #include "presence.h"
 #include "publish.h"

+ 1 - 1
modules_k/presence/presentity.c

@@ -35,7 +35,7 @@
 #include <time.h>
 
 #include "../../lib/srdb1/db.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../dprint.h"
 #include "../../mem/shm_mem.h"
 #include "../../str.h"

+ 1 - 1
modules_k/presence/publish.c

@@ -39,7 +39,7 @@
 #include "../../parser/parse_event.h" 
 #include "../../parser/parse_content.h" 
 #include "../../lock_ops.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../lib/kcore/cmpapi.h"
 #include "../../lib/srdb1/db.h"
 #include "presence.h"

+ 1 - 1
modules_k/presence/subscribe.c

@@ -38,7 +38,7 @@
 #include "../../parser/parse_expires.h"
 #include "../../parser/parse_event.h"
 #include "../../parser/contact/parse_contact.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "presence.h"
 #include "subscribe.h"
 #include "utils_func.h"

+ 1 - 1
modules_k/pua/hash.c

@@ -30,7 +30,7 @@
 #include "../../mem/mem.h"
 #include "../../mem/shm_mem.h"
 #include "../../dprint.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../parser/msg_parser.h"
 #include "../../parser/parse_from.h"
 #include "hash.h" 

+ 1 - 1
modules_k/pua/send_publish.c

@@ -40,7 +40,7 @@
 #include "../../mem/shm_mem.h"
 #include "../../parser/msg_parser.h"
 #include "../../lib/kcore/cmpapi.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../modules/tm/tm_load.h"
 #include "pua.h"
 #include "hash.h"

+ 1 - 1
modules_k/pua/send_subscribe.c

@@ -39,7 +39,7 @@
 #include "../../parser/parse_from.h"
 #include "../../parser/parse_expires.h"
 #include "../presence/hash.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "hash.h"
 #include "pua.h"
 #include "send_subscribe.h"

+ 1 - 24
modules_k/pv/pv_core.c

@@ -24,7 +24,6 @@
 
 
 #include "../../qvalue.h"
-#include "../../lib/kcore/errinfo.h"
 #include "../../ut.h" 
 #include "../../route_struct.h"
 #include "../../dset.h"
@@ -322,32 +321,10 @@ int pv_get_ouri_attr(struct sip_msg *msg, pv_param_t *param,
 	return pv_get_xuri_attr(msg, &(msg->parsed_orig_ruri), param, res);
 }
 
-extern err_info_t _oser_err_info;
 int pv_get_errinfo_attr(struct sip_msg *msg, pv_param_t *param,
 		pv_value_t *res)
 {
-	if(msg==NULL)
-		return -1;
-
-	if(param->pvn.u.isname.name.n==0) /* class */ {
-		return pv_get_sintval(msg, param, res, _oser_err_info.eclass);
-	} else if(param->pvn.u.isname.name.n==1) /* level */ {
-		return pv_get_sintval(msg, param, res, _oser_err_info.level);
-	} else if(param->pvn.u.isname.name.n==2) /* info */ {
-		if(_oser_err_info.info.s==NULL)
-			pv_get_null(msg, param, res);
-		return pv_get_strval(msg, param, res, &_oser_err_info.info);
-	} else if(param->pvn.u.isname.name.n==3) /* rcode */ {
-		return pv_get_sintval(msg, param, res, _oser_err_info.rcode);
-	} else if(param->pvn.u.isname.name.n==4) /* rreason */ {
-		if(_oser_err_info.rreason.s==NULL)
-			pv_get_null(msg, param, res);
-		return pv_get_strval(msg, param, res, &_oser_err_info.rreason);
-	} else {
-		LM_DBG("invalid attribute!\n");
-		return pv_get_null(msg, param, res);
-	}
-	return 0;
+	return pv_get_null(msg, param, res);
 }
 
 int pv_get_contact(struct sip_msg *msg, pv_param_t *param,

+ 0 - 1
modules_k/pv/pv_trans.c

@@ -39,7 +39,6 @@
 #include "../../trim.h" 
 #include "../../pvapi.h"
 #include "../../dset.h"
-#include "../../lib/kcore/errinfo.h"
 
 #include "../../parser/parse_param.h"
 #include "../../parser/parse_uri.h"

+ 0 - 1
modules_k/registrar/reg_mod.c

@@ -66,7 +66,6 @@
 #include "../../error.h"
 #include "../../socket_info.h"
 #include "../../pvar.h"
-#include "../../lib/kcore/km_ut.h"
 #include "../../modules_k/usrloc/usrloc.h"
 #include "../../lib/kcore/statistics.h"
 #include "../../modules/sl/sl.h"

+ 1 - 1
modules_k/rls/notify.c

@@ -45,7 +45,7 @@
 #include "../../modules/tm/dlg.h"
 #include "../presence/utils_func.h"
 #include "../presence/hash.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "rls.h"
 #include "notify.h"
 #include <libxml/xpath.h>

+ 1 - 1
modules_k/rls/resource_notify.c

@@ -32,7 +32,7 @@
 #include "../../parser/parse_content.h"
 #include "../../parser/parse_from.h"
 #include "../../lib/kcore/cmpapi.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../trim.h"
 #include "../pua/hash.h"
 #include "rls.h"

+ 1 - 1
modules_k/rls/rls.c

@@ -41,7 +41,7 @@
 #include "../../dprint.h"
 #include "../../error.h"
 #include "../../ut.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../mem/mem.h"
 #include "../../mem/shm_mem.h"
 #include "../../modules/tm/tm_load.h"

+ 1 - 1
modules_k/rls/subscribe.c

@@ -34,7 +34,7 @@
 #include "../../dprint.h"
 #include "../../data_lump_rpl.h"
 #include "../../lib/kcore/cmpapi.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../lib/kcore/parse_supported.h"
 #include "../../parser/msg_parser.h"
 #include "../../parser/parse_event.h"

+ 1 - 1
modules_k/seas/event_dispatcher.c

@@ -33,7 +33,7 @@
 #include <sys/wait.h>/*waitpid*/
 
 #include "../../ip_addr.h" /*sockaddr_union, ip_addr*/
-#include "../../lib/kcore/hash_func.h" /*T_TABLE_POWER*/
+#include "../../hashes.h" /*T_TABLE_POWER*/
 #include "../../mem/mem.h" /*pkg_malloc*/
 #include "../../mem/shm_mem.h" /*shm_malloc*/
 #include "../../dprint.h" /*LM_**/

+ 1 - 1
modules_k/seas/statistics.h

@@ -21,7 +21,7 @@
 
 #include <sys/time.h>
 #include <time.h>
-#include "../../lib/kcore/hash_func.h"/* for TABLE_ENTRIES define*/
+#include "../../hashes.h"/* for TABLE_ENTRIES define*/
 #include "../../locking.h"/* for TABLE_ENTRIES define*/
 #include "../../modules/tm/h_table.h"/* for struct cell*/
 #define STATS_CELLS 50

+ 0 - 1
modules_k/siputils/ring.c

@@ -43,7 +43,6 @@
 #include "../../dprint.h"
 #include "../../error.h"
 #include "../../ut.h"
-#include "../../lib/kcore/km_ut.h"
 #include "../../mem/mem.h"
 #include "../../mem/shm_mem.h"
 #include "../../timer.h"

+ 1 - 1
modules_k/sqlops/sql_api.c

@@ -30,7 +30,7 @@
 
 #include "../../mem/mem.h"
 #include "../../dprint.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "../../ut.h"
 #include "../../lib/srdb1/db_ut.h"
 #ifdef WITH_XAVP

+ 0 - 1
modules_k/sst/sst_handlers.c

@@ -56,7 +56,6 @@
 #include "../../pvar.h"
 #include "../../lib/kcore/parse_sst.h"
 #include "../../lib/kcore/parse_supported.h"
-#include "../../lib/kcore/km_ut.h"
 #include "../../mem/mem.h"
 #include "../../mem/shm_mem.h"
 #include "../../data_lump.h"

+ 1 - 1
modules_k/usrloc/udomain.c

@@ -43,7 +43,7 @@
 #include "../../lib/srdb1/db.h"
 #include "../../socket_info.h"
 #include "../../ut.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "ul_mod.h"            /* usrloc module parameters */
 #include "usrloc.h"
 #include "utime.h"

+ 1 - 1
modules_k/usrloc/urecord.c

@@ -39,7 +39,7 @@
 #include "../../mem/shm_mem.h"
 #include "../../dprint.h"
 #include "../../ut.h"
-#include "../../lib/kcore/hash_func.h"
+#include "../../hashes.h"
 #include "ul_mod.h"
 #include "usrloc.h"
 #include "utime.h"

+ 0 - 1
modules_s/usrloc/ucontact.c

@@ -50,7 +50,6 @@
 #include "reg_avps.h"
 #include "reg_avps_db.h"
 
-#define	MIN(x, y)	((x) < (y) ? (x) : (y))
 
 /*
  * Create a new contact structure

+ 14 - 0
trim.h

@@ -100,4 +100,18 @@ static inline void trim(str* _s)
 }
 
 
+/*
+ * right and left space trimming
+ *
+ * WARNING: String structure will be modified !
+ *          Make a copy otherwise you might be
+ *          unable to free _s_->s for example !
+ */
+#define trim_spaces_lr(_s_)												\
+	do{																	\
+		for(;(_s_).s[(_s_).len-1]==' ';(_s_).s[--(_s_).len]=0);			\
+		for(;(_s_).s[0]==' ';(_s_).s=(_s_).s+1,(_s_).len--);			\
+																		\
+	} while(0);
+	
 #endif /* TRIM_H */

+ 63 - 0
ut.h

@@ -772,6 +772,69 @@ static inline int str_strcasecmp(const str *str1, const str *str2)
 		return strncasecmp(str1->s, str2->s, str1->len);
 }
 
+#ifndef MIN
+#define	MIN(x, y)	((x) < (y) ? (x) : (y))
+#endif
+#ifndef MAX
+#define	MAX(x, y)	((x) > (y) ? (x) : (y))
+#endif
+
+
+/* INTeger-TO-Buffer-STRing : convers an unsigned long to a string 
+ * IMPORTANT: the provided buffer must be at least INT2STR_MAX_LEN size !! */
+static inline char* int2bstr(unsigned long l, char *s, int* len)
+{
+	int i;
+	i=INT2STR_MAX_LEN-2;
+	s[INT2STR_MAX_LEN-1]=0;
+	/* null terminate */
+	do{
+		s[i]=l%10+'0';
+		i--;
+		l/=10;
+	}while(l && (i>=0));
+	if (l && (i<0)){
+		LM_CRIT("overflow error\n");
+	}
+	if (len) *len=(INT2STR_MAX_LEN-2)-i;
+	return &s[i+1];
+}
+
+
+inline static int hexstr2int(char *c, int len, unsigned int *val)
+{
+	char *pc;
+	int r;
+	char mychar;
+
+	r=0;
+	for (pc=c; pc<c+len; pc++) {
+		r <<= 4 ;
+		mychar=*pc;
+		if ( mychar >='0' && mychar <='9') r+=mychar -'0';
+		else if (mychar >='a' && mychar <='f') r+=mychar -'a'+10;
+		else if (mychar  >='A' && mychar <='F') r+=mychar -'A'+10;
+		else return -1;
+	}
+	*val = r;
+	return 0;
+}
+
+
+
+/*
+ * Convert a str (base 10 or 16) into integer
+ */
+static inline int strno2int( str *val, unsigned int *mask )
+{
+	/* hexa or decimal*/
+	if (val->len>2 && val->s[0]=='0' && val->s[1]=='x') {
+		return hexstr2int( val->s+2, val->len-2, mask);
+	} else {
+		return str2int( val, mask);
+	}
+}
+
 /* converts a username into uid:gid,
  * returns -1 on error & 0 on success */
 int user2uid(int* uid, int* gid, char* user);