aboutsummaryrefslogtreecommitdiffstats
path: root/samsung-ipc/sms.c
blob: a4c785577791a8ed644e1b6ac0d072a1123721d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
 * This file is part of libsamsung-ipc.
 *
 * Copyright (C) 2011 Simon Busch <morphis@gravedo.de>
 *
 * libsamsung-ipc is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * libsamsung-ipc is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with libsamsung-ipc.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#include <samsung-ipc.h>
#include <string.h>
#include <assert.h>

unsigned char* ipc_sms_send_msg_pack(struct ipc_sms_send_msg_request *msg, char *smsc,
                                     unsigned char *pdu, int pdu_length)
{
    unsigned char *data = NULL, *p = NULL;
    unsigned int data_length = 0, smsc_len = 0;

    assert(smsc != NULL);
    assert(pdu != NULL);

    smsc_len = strlen(smsc);
    data_length = smsc_len + pdu_length + sizeof(struct ipc_sms_send_msg_request);
    data = (unsigned char*) malloc(sizeof(unsigned char) * data_length);
    memset(data, 0, data_length);

    p = data;
    memcpy(p, msg, sizeof(struct ipc_sms_send_msg_request));
    p += sizeof(struct ipc_sms_send_msg_request);
    memcpy(p, (char*) (smsc + 1), smsc_len);
    p += smsc_len;
    memcpy(p, pdu, pdu_length);

    return data;
}

// vim:ts=4:sw=4:expandtab