Re: Patch removed from CVS
"Nikos Balkanas" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <004f01c9819b$fa2a25f0$02b2a8c0@tardis> |
Hi all, Attached patch to gwlib/octstr.c provides support for %ll and %llu in octstr_format. To do that I introduced a new format->type: 'L' for long long variables. This is a prerequisite patch for #460. Please vote, and if possible test (I have tested it only with my demo program, not kannel). BR, Nikos ----- Original Message ----- From: Alexander Malysh To: Nikos Balkanas Cc: [email protected] Sent: Wednesday, January 28, 2009 1:15 PM Subject: Re: Patch removed from CVS the issue is that we always paniced when %llu was used because octstr_format doesn't implement %llu format. Thanks, Alex P.S. You are free to implement %llu for octstr_format then I will reapply my smpp patch ;) Am 28.01.2009 um 12:09 schrieb Nikos Balkanas: Interesting. This is just correct C for printing strtoll. Seems that in this case 2 wrongs make it right. Any chance that SMPP dlr handling can be corrected? I imagine that all 32bit machines with smpp connections would have this problem. BR, Nikos ----- Original Message ----- From: Alexander Malysh To: Nikos Balkanas Cc: [email protected] Sent: Wednesday, January 28, 2009 10:13 AM Subject: Re: Patch removed from CVS Hi, this is OK, I have dropped this patch because it break SMPP dlr handling. Am 28.01.2009 um 01:10 schrieb Nikos Balkanas: Hi, I just tried to update from CVS. A lot of work has been introduced for meta-data recently. Unfortunately, in the case of gw/smsc/smsc_smpp.c it seems old sources were used, with the result that the llu patch commited by Alex for bug #460 has disappeared. Alex, can you recommit please? From: "Alexander Malysh" <[email protected]> To: <[email protected]> Sent: Friday, January 09, 2009 5:05 PM Subject: [PATCH] Bug 460 > Hi All, > > here is proposed patch to fix #460. > > any objections to commit it? > > Thanks, > Alex > -------------------------------------------------------------------------------- > diff --git a/gw/smsc/smsc_smpp.c b/gw/smsc/smsc_smpp.c > index d81132c..b6f8cb0 100644 > --- a/gw/smsc/smsc_smpp.c > +++ b/gw/smsc/smsc_smpp.c > @@ -1278,9 +1278,9 @@ static Msg *handle_dlr(SMPP *smpp, Octstr > *destination_addr, Octstr *short_messa > } else { > if ((smpp->smpp_msg_id_type & 0x02) || > (!octstr_check_range(msgid, 0, octstr_len(msgid), > gw_isdigit))) { > - tmp = octstr_format("%lu", > strtoll(octstr_get_cstr(msgid), NULL, 16)); > + tmp = octstr_format("%llu", > strtoll(octstr_get_cstr(msgid), NULL, 16)); > } else { > - tmp = octstr_format("%lu", > strtoll(octstr_get_cstr(msgid), NULL, 10)); > + tmp = octstr_format("%llu", > strtoll(octstr_get_cstr(msgid), NULL, 10)); > } > } > >
patch.diff
(application/octet-stream, 2.9 KB)
Index: gwlib/octstr.c
===================================================================
RCS file: /home/cvs/gateway/gwlib/octstr.c,v
retrieving revision 1.182
diff -u -r1.182 octstr.c
--- gwlib/octstr.c 12 Jan 2009 16:46:53 -0000 1.182
+++ gwlib/octstr.c 28 Jan 2009 22:49:41 -0000
@@ -2221,10 +2221,18 @@
switch (**fmt)
{
case 'h':
- case 'l':
format->type = **fmt;
++(*fmt);
break;
+ case 'l':
+ if (*(*fmt + 1) == 'l')
+ {
+ format->type = 'L';
+ ++(*fmt);
+ }
+ else format->type = **fmt;
+ ++(*fmt);
+ break;
}
}
@@ -2234,8 +2242,8 @@
{
Octstr *new;
char *s, *pad;
- long n;
- unsigned long u;
+ long long n;
+ unsigned long long u;
char tmpfmt[1024];
char tmpbuf[1024];
char c;
@@ -2252,16 +2260,20 @@
case 'd':
case 'i':
- switch (format->type) {
- case 'l':
- n = va_arg(VALST(args), long);
- break;
- case 'h':
- n = (short) va_arg(VALST(args), int);
- break;
- default:
- n = va_arg(VALST(args), int);
- break;
+ switch (format->type)
+ {
+ case 'L':
+ n = va_arg(VALST(args), long long);
+ break;
+ case 'l':
+ n = (long) va_arg(VALST(args), long);
+ break;
+ case 'h':
+ n = (short) va_arg(VALST(args), int);
+ break;
+ default:
+ n = (short) va_arg(VALST(args), int);
+ break;
}
new = octstr_create("");
octstr_append_decimal(new, n);
@@ -2271,18 +2283,22 @@
case 'u':
case 'x':
case 'X':
- switch (format->type) {
- case 'l':
- u = va_arg(VALST(args), unsigned long);
- break;
- case 'h':
- u = (unsigned short) va_arg(VALST(args), unsigned int);
- break;
- default:
- u = va_arg(VALST(args), unsigned int);
- break;
- }
- tmpfmt[0] = '%';
+ switch (format->type)
+ {
+ case 'l':
+ u = (unsigned long) va_arg(VALST(args), unsigned long);
+ break;
+ case 'L':
+ u = va_arg(VALST(args), unsigned long long);
+ break;
+ case 'h':
+ u = (unsigned short) va_arg(VALST(args), unsigned int);
+ break;
+ default:
+ u = (unsigned short) va_arg(VALST(args), unsigned int);
+ break;
+ }
+ tmpfmt[0] = '%';
tmpfmt[1] = 'l';
tmpfmt[2] = **fmt;
tmpfmt[3] = '\0';
@@ -2316,7 +2332,7 @@
case 's':
s = va_arg(VALST(args), char *);
if (format->has_prec && format->prec < (long) strlen(s))
- n = format->prec;
+ n = (long) format->prec;
else
n = (long) strlen(s);
new = octstr_create_from_data(s, n);