Module: sip-router Branch: daniel/pv DELETED Commit: 87f1c343346b40e03ad906369120797ceb198110 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=87f1c343...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Tue Feb 17 16:55:19 2009 +0200
- included int2bstr
---
ut.h | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/ut.h b/ut.h index 013f963..e384737 100644 --- a/ut.h +++ b/ut.h @@ -234,6 +234,24 @@ static inline int btostr( char *p, unsigned char val)
#define INT2STR_MAX_LEN (19+1+1) /* 2^64~= 16*10^18 => 19+1 digits + \0 */
+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]; +} + /* * returns a pointer to a static buffer containing l in asciiz (with base "base") & sets len * left padded with 0 to "size"