[PATCH] test/decode_emimsg.c - fixes segfaults - new features

"Vincent CHAVANIS" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <0d3f01c801bd$07a8f860$9600a8c0@vince>
Hi all,

This is a new version of the decode_emimsg
- It fixes a segfault when we are decoding 52 operation response (eg 
./decode_emimsg 03/00020/R/52/A///98)
- Operation 31 Ack/Nack is now supported.
- Operation 5x Ack/Nack is now supported
- Fixes segfault when decoding 52 when xMSG is NULL

Vincent.

--
Telemaque - 06560 SOPHIA-ANTIPOLIS - (FR)
Service Technique/Reseau - NOC
Developpement SMS/MMS/Kiosques
http://www.telemaque.fr/
[email protected]
Tel : +33 4 92 90 99 84 (fax 9142)
decode_emimsg.txt (text/plain, 2.8 KB)
--- /gateway-cvs/test/decode_emimsg.c   2007-01-09 15:39:21.000000000 +0100
+++ /gateway/test/decode_emimsg.c    2007-09-28 12:32:25.000000000 +0200
@@ -133,16 +133,33 @@
                     octstr_get_cstr(emimsg->fields[E01_ADC]));
             printf("E01_MT   \t%s\n",
                     octstr_get_cstr(emimsg->fields[E01_MT]));
-
             if (octstr_get_char(emimsg->fields[E01_MT], 0) == '3') {
                 charset_gsm_to_latin1(emimsg->fields[E01_AMSG]);
             }
-
             printf("E01_AMSG \t%s\n",
                     octstr_get_cstr(emimsg->fields[E01_AMSG]));
         }
 
-        if (emimsg->ot >= 50 && emimsg->ot <= 59) {
+        if ((emimsg->ot == 31 || (emimsg->ot >= 50 && emimsg->ot <= 59)) &&
+                emimsg->or == 'R' && 
+                (octstr_get_char(emimsg->fields[E50_ADC], 0) == 'A' ||
+                octstr_get_char(emimsg->fields[E50_ADC], 0) == 'N')) {
+            printf("E50_ACK  \t%s\n",
+                    octstr_get_cstr(emimsg->fields[E50_ADC]));
+            printf("E50_SM   \t%s\n",  
+                    octstr_get_cstr(emimsg->fields[E50_OADC]));
+        }
+
+        if (emimsg->ot == 31 && emimsg->or == 'O') {
+            printf("E50_ADC  \t%s\n",
+                    octstr_get_cstr(emimsg->fields[E50_ADC]));
+            printf("E50_PID  \t%s\n",
+                    octstr_get_cstr(emimsg->fields[E50_OADC]));
+        }
+
+        if (emimsg->ot >= 50 && emimsg->ot <= 59 && 
+                octstr_get_char(emimsg->fields[E50_ADC], 0) != 'A' &&
+                octstr_get_char(emimsg->fields[E50_ADC], 0) != 'N') {
             printf("E50_ADC  \t%s\n",
                     octstr_get_cstr(emimsg->fields[E50_ADC]));
             printf("E50_OADC \t%s\n",
@@ -185,9 +202,8 @@
                     octstr_get_cstr(emimsg->fields[E50_NB]));
             printf("E50_NMSG \t%s\n",
                     octstr_get_cstr(emimsg->fields[E50_NMSG]));
-
+            if (emimsg->fields[E50_AMSG])
             octstr_hex_to_binary (emimsg->fields[E50_AMSG]);
-
             if (octstr_get_char(emimsg->fields[E50_MT], 0) == '3') {
                 charset_gsm_to_latin1(emimsg->fields[E50_AMSG]);
             }
@@ -221,6 +237,7 @@
             printf("E50_RES5 \t%s\n",
                     octstr_get_cstr(emimsg->fields[E50_RES5]));
         }
+
         if (emimsg->ot == 60 || emimsg->ot == 61 || emimsg->ot == 62) {
             printf("E60_OADC  \t%s\n",
                     octstr_get_cstr(emimsg->fields[E60_OADC]));
@@ -230,6 +247,7 @@
                     octstr_get_cstr(emimsg->fields[E60_ONPI]));
             printf("E60_STYP  \t%s\n",
                     octstr_get_cstr(emimsg->fields[E60_STYP]));
+            if (emimsg->fields[E60_PWD])
             octstr_hex_to_binary (emimsg->fields[E60_PWD]);
             printf("E60_PWD   \t%s\n",
                     octstr_get_cstr(emimsg->fields[E60_PWD]));
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.