Daily patch: gateway

kannel at kannel.org kannel at kannel.org
Fri Jan 30 06:30:06 CET 2009


File gateway/ChangeLog changed from revision 1.3008 to 1.3010
File gateway/gw/smsc/smsc_smpp.c changed from revision 1.111 to 1.112
File gateway/gwlib/octstr.c changed from revision 1.182 to 1.183
File gateway/test/test_octstr_format.c changed from revision 1.11 to 1.12



Index: gateway/ChangeLog
diff -u gateway/ChangeLog:1.3008 gateway/ChangeLog:1.3010
--- gateway/ChangeLog:1.3008	Mon Jan 26 15:20:16 2009
+++ gateway/ChangeLog	Thu Jan 29 11:38:28 2009
@@ -1,3 +1,13 @@
+2009-01-29 Alexander Malysh <amalysh at kannel.org>
+    * gw/smsc/smsc_smpp.c: this patch should fix #460.
+      Changed %lu -> %llu in octstr_format call when strtoll is used.
+
+2009-01-29 Alexander Malysh <amalysh at kannel.org>
+    * gwlib/octstr.c, test/test_octstr_format.c: applied patch that adds
+      support for %llu, %llx etc. to octstr_format. Also added test.
+      Thanks to Nikos Balkanas <nbalkanas at gmail.com> for patch.
+      [Msg-Id: <7f4386bc0901290255y3f8f44feya6132b138b0b6003 at mail.gmail.com>]
+
 2009-01-26  Stipe Tolj  <stolj at kannel.org>
     * gwlib/http.c: fix the recover_absolute_uri() to handle HTTPS connections
       to port 80 too, via applying the port 80 to the URL scheme if the
Index: gateway/gw/smsc/smsc_smpp.c
diff -u gateway/gw/smsc/smsc_smpp.c:1.111 gateway/gw/smsc/smsc_smpp.c:1.112
--- gateway/gw/smsc/smsc_smpp.c:1.111	Wed Jan 21 15:50:17 2009
+++ gateway/gw/smsc/smsc_smpp.c	Thu Jan 29 11:38:28 2009
@@ -1290,9 +1290,9 @@
         } 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));
             }
         }
 
@@ -1522,10 +1522,10 @@
                     if ((smpp->smpp_msg_id_type & 0x01) || 
                        (!octstr_check_range(pdu->u.submit_sm_resp.message_id, 0, 
                             octstr_len(pdu->u.submit_sm_resp.message_id), gw_isdigit))) {
-                        tmp = octstr_format("%lu", strtoll(  /* hex */
+                        tmp = octstr_format("%llu", strtoll(  /* hex */
                             octstr_get_cstr(pdu->u.submit_sm_resp.message_id), NULL, 16));
                     } else {
-                        tmp = octstr_format("%lu", strtoll(  /* decimal */
+                        tmp = octstr_format("%llu", strtoll(  /* decimal */
                             octstr_get_cstr(pdu->u.submit_sm_resp.message_id), NULL, 10));
                     }
                 }
Index: gateway/gwlib/octstr.c
diff -u gateway/gwlib/octstr.c:1.182 gateway/gwlib/octstr.c:1.183
--- gateway/gwlib/octstr.c:1.182	Mon Jan 12 16:46:53 2009
+++ gateway/gwlib/octstr.c	Thu Jan 29 11:28:55 2009
@@ -2218,13 +2218,18 @@
 
 static void format_type(struct format *format, const char **fmt)
 {
-    switch (**fmt)
-    {
+    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 +2239,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;
@@ -2253,6 +2258,9 @@
     case 'd':
     case 'i':
         switch (format->type) {
+        case 'L':
+            n = va_arg(VALST(args), long long);
+            break;
         case 'l':
             n = va_arg(VALST(args), long);
             break;
@@ -2271,18 +2279,21 @@
     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 = 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 = va_arg(VALST(args), unsigned int);
+      break;
+   }
+   tmpfmt[0] = '%';
 	tmpfmt[1] = 'l';
 	tmpfmt[2] = **fmt;
 	tmpfmt[3] = '\0';
Index: gateway/test/test_octstr_format.c
diff -u gateway/test/test_octstr_format.c:1.11 gateway/test/test_octstr_format.c:1.12
--- gateway/test/test_octstr_format.c:1.11	Mon Jan 12 16:46:51 2009
+++ gateway/test/test_octstr_format.c	Thu Jan 29 11:28:55 2009
@@ -61,7 +61,8 @@
 #include "gwlib/gwlib.h"
 
 int main(void) {
-	Octstr *os, *os2, *os3, *os4;
+	Octstr *os, *os2, *os3, *os4, *os5;
+        unsigned long long n = 78234782386423784267234;
 
 	gwlib_init();
 
@@ -81,9 +82,14 @@
 	os4 = octstr_format("Encode %E and limited %-10.10E", os, os);
 	octstr_dump(os4, 0);
 
+        os5 = octstr_format("Encode %%llu: %llu", n);
+        octstr_dump(os5, 0);
+
 	octstr_destroy(os);
 	octstr_destroy(os2);
 	octstr_destroy(os3);
+        octstr_destroy(os4);
+        octstr_destroy(os5);
 	
 	gwlib_shutdown();
 	



More information about the devel-reports mailing list