Re: [PATCH] utils/mtbatch.c DLR support patch [revised]

Vincent CHAVANIS <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
yep you're right.
also fix missing headers.
and panic text.




Alexander Malysh a écrit :
> hi,
> 
> you don't need this check for each message:
> +        if (use_dlr == 1) {
> +            msg->sms.dlr_mask = dlr_mask;
> +            msg->sms.dlr_url = octstr_duplicate(dlr_url);
> +        }
> 
> because you already checked that if dlr-mask supplied that dlr_url is 
> also supplied.
> 
> Thanks,
> Alex
> 
> Am 09.04.2009 um 12:34 schrieb Vincent CHAVANIS:
> 
>>
>> here is a revised version
>>
>> Vincent.
>>
>> Alexander Malysh a écrit :
>>> Hi Vincent,
>>> some comments to your patch:
>>> +
>>> +        if (dlr_mask > 0 && dlr_url) {
>>> +            msg->sms.dlr_mask = dlr_mask;
>>> +            msg->sms.dlr_url = octstr_duplicate(dlr_url);
>>> +        }
>>> don't check this for each message, check this once by start and 
>>> please use dlr macros:
>>> DLR_IS_ENABLED(dlr_mask)
>>>             case 'f':
>>>                 from = octstr_create(optarg);
>>>                 break;
>>> +
>>> +            case 'D':
>>> +                dlr_mask = atoi(optarg);
>>> please kill extra line
>>> +    if (dlr_mask && dlr_url == NULL)
>>> +        panic(0,"dlr-url address not specified. Use option -D to 
>>> specify dlr-url address.");
>>> +
>>> should be if ((DLR_IS_ENABLED(dlr_mask) && dlr_url == NULL) || 
>>> (!DLR_IS_ENABLED(dlr_mask) && dlr_url != NULL)
>>> Thanks,
>>> Alex
>>> Am 07.04.2009 um 12:53 schrieb Vincent CHAVANIS:
>>>>
>>>> This patch add a DLR support for mtbatch.
>>>> Will try to provide the charset/udh patch soon
>>>>
>>>> Vincent.
>>>>
>>>>
mtbatch_r2.txt (text/plain, 3.2 KB)
diff -rauw /gateway-cvs/utils/mtbatch.c /gateway/utils/mtbatch.c
--- /gateway-cvs/utils/mtbatch.c        2009-04-03 14:51:29.000000000 +0200
+++ /gateway/utils/mtbatch.c    2009-04-09 17:07:45.000000000 +0200
@@ -63,8 +63,10 @@
  * to bearerbox.
  *
  * Stipe Tolj <[email protected]>
+ * Vincent Chavanis <[email protected]>
  *
- * XXX add udh (etc.) capabilities. Currently we handle only 7-bit.
+ * XXX Add UDH capabilities.
+ * XXX Support more charsets than 7-bit.
  */
 
 #include <string.h>
@@ -75,6 +77,7 @@
 
 #include "msg.h"
 #include "sms.h"
+#include "dlr.h"
 #include "bb.h"
 #include "shared.h"
 #include "heartbeat.h"
@@ -90,6 +93,8 @@
 static Octstr *service = NULL;
 static Octstr *account = NULL;
 static Octstr *from = NULL;
+static int dlr_mask = 0;
+static Octstr *dlr_url = NULL;
 static Octstr *smsc_id = NULL;
 static long sms_max_length = MAX_SMS_OCTETS;
 static double delay = 0;
@@ -251,6 +256,10 @@
     info(0, "    defines the smsbox-id to be used for bearerbox connection (default: none)");
     info(0, "-f sender");
     info(0, "    which sender address should be used");
+    info(0, "-D dlr-mask");
+    info(0, "    defines the dlr-mask");
+    info(0, "-u dlr-url");
+    info(0, "    defines the dlr-url");
     info(0, "-n service");
     info(0, "    defines which service name should be logged (default: none)");
     info(0, "-a account");
@@ -311,6 +320,8 @@
         msg->sms.receiver = octstr_duplicate(no);
         msg->sms.account = account ? octstr_duplicate(account) : NULL;
         msg->sms.msgdata = content ? octstr_duplicate(content) : octstr_create("");
+        msg->sms.dlr_mask = dlr_mask;
+        msg->sms.dlr_url = octstr_duplicate(dlr_url);        
         msg->sms.udhdata = octstr_create("");
         msg->sms.coding = DC_7BIT;
 
@@ -339,7 +350,7 @@
     bb_port = 13001;
     bb_ssl = 0;
         
-    while ((opt = getopt(argc, argv, "hv:b:p:si:n:a:f:d:r:")) != EOF) {
+    while ((opt = getopt(argc, argv, "hv:b:p:si:n:a:f:D:u:d:r:")) != EOF) {
         switch (opt) {
             case 'v':
                 log_set_output_level(atoi(optarg));
@@ -366,6 +377,13 @@
             case 'f':
                 from = octstr_create(optarg);
                 break;
+            case 'D':
+                dlr_mask = atoi(optarg);
+                break;
+            case 'u':
+                dlr_url = octstr_create(optarg);
+                break;
             case 'd':
                 delay = atof(optarg);
                 break;
@@ -389,6 +407,9 @@
     if (from == NULL)
         panic(0,"Sender address not specified. Use option -f to specify sender address.");
 
+    if ((DLR_IS_ENABLED(dlr_mask) && dlr_url == NULL) || (!DLR_IS_ENABLED(dlr_mask) && dlr_url != NULL))
+        panic(0,"dlr-url address OR dlr-mask not specified. Use option -D or -u to specify dlr values");
+
     rf = octstr_create(argv[argc-1]);
     cf = octstr_create(argv[argc-2]);
 
@@ -416,6 +437,7 @@
     octstr_destroy(content);
     octstr_destroy(service);
     octstr_destroy(account);
+    octstr_destroy(dlr_url);
     octstr_destroy(smsc_id);
     counter_destroy(counter);
     gwlist_destroy(lines, octstr_destroy_item);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.