diff --git a/src/modems/hayes.c b/src/modems/hayes.c index a0c29a1..a84ecf5 100644 --- a/src/modems/hayes.c +++ b/src/modems/hayes.c @@ -843,7 +843,8 @@ static char * _hayes_message_to_pdu(HayesChannel * channel, char const * number, + strlen((data != NULL) ? data : ""); if(addr != NULL && (ret = malloc(len)) != NULL) { - if(hayeschannel_has_quirks(channel, + /* XXX no longer require the channel here */ + if(channel != NULL && hayeschannel_has_quirks(channel, HAYES_QUIRK_WANT_SMSC_IN_PDU)) smsc = "00"; if(snprintf(ret, len, "%s%s%02lX%s%s%s%s%02lX%s", smsc, prefix, diff --git a/tests/pdu.c b/tests/pdu.c index c144ae7..c047044 100644 --- a/tests/pdu.c +++ b/tests/pdu.c @@ -37,18 +37,23 @@ static int _pdu(void); static int _pdu_decode(char const * pdu, char const * number, char const * datetime, ModemMessageEncoding encoding, char const * message); +static int _pdu_encode(void); /* functions */ /* pdu */ static int _pdu(void) { - return _pdu_decode("07916407058099F9040B916407752743" - "F60000990121017580001554747A0E4A" - "CF416110945805B5CBF379F85C06", - "+46705772346", "12/10/1999 12:57:08", - MODEM_MESSAGE_ENCODING_UTF8, - "This is a PDU message"); + int ret = 0; + + ret |= (_pdu_decode("07916407058099F9040B916407752743" + "F60000990121017580001554747A0E4A" + "CF416110945805B5CBF379F85C06", + "+46705772346", "12/10/1999 12:57:08", + MODEM_MESSAGE_ENCODING_UTF8, + "This is a PDU message") != 0) ? 1 : 0; + ret |= (_pdu_encode() != 0) ? 2 : 0; + return ret; } @@ -111,8 +116,26 @@ static int _pdu_decode(char const * pdu, char const * number, } +/* pdu_encode */ +static int _pdu_encode(void) +{ + int ret; + char * pdu; + char const number[] = "1234"; + ModemMessageEncoding encoding = MODEM_MESSAGE_ENCODING_ASCII; + char const string[] = "This is just a test."; + + if((pdu = _hayes_message_to_pdu(NULL, number, encoding, + sizeof(string) - 1, string)) == NULL) + return -1; + ret = _pdu_decode(pdu, number, NULL, encoding, string); + free(pdu); + return ret; +} + + /* main */ int main(void) { - return (_pdu() == 0) ? 0 : 2; + return (_pdu() << 1); } diff --git a/tests/tests.sh b/tests/tests.sh index 1c5cf12..834ad32 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -101,10 +101,10 @@ FAILED= echo "Performing tests:" 1>&2 _test "hayes" _test "modems" -_test "pdu" _test "plugins" _test "ussd" echo "Expected failures:" 1>&2 +_fail "pdu" if [ -n "$FAILED" ]; then echo "Failed tests:$FAILED" 1>&2 exit 2