what about this approach?!
This should work ok, but I think it's an performance impact, because
we copy octstr arround and this should be avoided.
Comments?!
Stipe
[EMAIL PROTECTED]
-------------------------------------------------------------------
Wapme Systems AG
Vogelsanger Weg 80
40470 D�sseldorf
Tel: +49-211-74845-0
Fax: +49-211-74845-299
E-Mail: [EMAIL PROTECTED]
Internet: http://www.wapme-systems.de
-------------------------------------------------------------------
wapme.net - wherever you are
--- smsc_smpp.c 2003-03-06 10:41:05.000000000 +0100
+++ smsc_smpp.c.new 2003-03-06 10:39:27.000000000 +0100
@@ -319,7 +319,7 @@
static SMPP_PDU *msg_to_pdu(SMPP *smpp, Msg *msg)
{
SMPP_PDU *pdu;
- Octstr *buffer;
+ Octstr *buffer = NULL;
Octstr *relation_UTC_time = NULL;
struct tm gmtime, localtime, tm;
int gwqdiff;
@@ -409,35 +409,36 @@
pdu->u.submit_sm.esm_class = pdu->u.submit_sm.esm_class |
ESM_CLASS_SUBMIT_RPI;
+ /*
+ * only re-encoding if using default smsc charset that is defined via
+ * alt-charset in smsc group and if MT is not binary
+ */
+ if (pdu->u.submit_sm.data_coding == 0) {
+ buffer = octstr_duplicate(msg->sms.msgdata);
+ /*
+ * convert to the given alternative charset
+ * otherwise assume to convert to GSM 03.38 7-bit alphabet
+ */
+ if (smpp->alt_charset) {
+ if (charset_convert(buffer, "ISO-8859-1",
+ octstr_get_cstr(smpp->alt_charset)) != 0)
+ error(0, "Failed to convert msgdata from charset <%s> to <%s>, will
send as is.",
+ "ISO-8859-1", octstr_get_cstr(smpp->alt_charset));
+ } else {
+ charset_latin1_to_gsm(buffer);
+ }
+ }
+
/*
* set data segments and length
*/
if (octstr_len(msg->sms.udhdata)) {
pdu->u.submit_sm.short_message =
- octstr_format("%S%S", msg->sms.udhdata, msg->sms.msgdata);
+ octstr_format("%S%S", msg->sms.udhdata, (buffer ? buffer :
msg->sms.msgdata));
} else {
- pdu->u.submit_sm.short_message = octstr_duplicate(msg->sms.msgdata);
-
- /*
- * only re-encoding if using default smsc charset that is defined via
- * alt-charset in smsc group and if MT is not binary
- */
- if (pdu->u.submit_sm.data_coding == 0) {
-
- /*
- * convert to the given alternative charset
- * otherwise assume to convert to GSM 03.38 7-bit alphabet
- */
- if (smpp->alt_charset) {
- if (charset_convert(pdu->u.submit_sm.short_message, "ISO-8859-1",
- octstr_get_cstr(smpp->alt_charset)) != 0)
- error(0, "Failed to convert msgdata from charset <%s> to <%s>,
will send as is.",
- "ISO-8859-1", octstr_get_cstr(smpp->alt_charset));
- } else {
- charset_latin1_to_gsm(pdu->u.submit_sm.short_message);
- }
- }
+ pdu->u.submit_sm.short_message = octstr_duplicate((buffer ? buffer :
msg->sms.msgdata));
}
+ octstr_destroy(buffer);
pdu->u.submit_sm.sm_length = octstr_len(pdu->u.submit_sm.short_message);
/*