File: core.c

package info (click to toggle)
libsmpp34 1.14.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 672 kB
  • sloc: ansic: 3,381; makefile: 251; sh: 65; xml: 15
file content (107 lines) | stat: -rw-r--r-- 3,968 bytes parent folder | download | duplicates (5)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

/*
 * Copyright (C) 2006 Raul Tremsal
 * File  : core.c
 * Author: Raul Tremsal <ultraismo@yahoo.com>
 *
 * This file is part of libsmpp34 (c-open-smpp3.4 library).
 *
 * The libsmpp34 library is free software; you can redistribute it and/or 
 * modify it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation; either version 2.1 of the 
 * License, or (at your option) any later version.
 *
 * This library 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 Lesser General Public 
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License 
 * along with this library; if not, write to the Free Software Foundation, 
 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
 *
 */

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>

#include <stdint.h>

#include "smpp34.h"
#include "smpp34_structs.h"
#include "smpp34_params.h"

extern int  smpp34_errno;
extern char smpp34_strerror[2048];


int 
doTest( uint32_t id, void* dst, void* src )
{

    int ret = 0;
    uint8_t bufPDU[2048];
    int bufPDULen = 0;
    uint8_t bPrint[2048];

    /* Linealize PDU to buffer ********************************************/
    memset(&bufPDU, 0, sizeof(bufPDU));
    ret = smpp34_pack(id, bufPDU, sizeof(bufPDU), &bufPDULen, (void*)src);
    if( ret != 0 ){
        printf("Error in smpp34_pack():%d:\n%s\n", 
                                             smpp34_errno, smpp34_strerror);
        return( 0 );
    };
    printf("parse smpp34_pack()\n%s\n", smpp34_strerror);

    /* Print PDU **********************************************************/
    memset(&bPrint, 0, sizeof(bPrint));
    ret = smpp34_dumpPdu(id, bPrint, sizeof(bPrint), (void*)src);
    if( ret != 0){
        printf("Error in smpp34_dumpPdu():%d:\n%s\n", 
                                             smpp34_errno, smpp34_strerror);
        return( -1 );
    };
    printf("parse smpp34_dumpPdu()\n%s\n", smpp34_strerror);
    printf("-----------------------------------------------------------\n");
    printf("%s\n", bPrint);
    printf("-----------------------------------------------------------\n");

    /* Print Buffer *******************************************************/
    memset(bPrint, 0, sizeof(bPrint));
    ret = smpp34_dumpBuf(bPrint, sizeof(bPrint), bufPDU, bufPDULen);
    if( ret != 0 ){
        printf("Error in smpp34_dumpBuf():%d:\n%s\n", 
                                            smpp34_errno, smpp34_strerror );
        return( -1 );
    };
    printf("parse smpp34_dumpBuf()\n%s\n", smpp34_strerror);
    printf("-----------------------------------------------------------\n");
    printf("%s", bPrint);
    printf("-----------------------------------------------------------\n");

    /* Copy PDU from Buffer ***********************************************/
    ret = smpp34_unpack(id, (void*)dst, bufPDU, bufPDULen); 
    if( ret != 0 ){
        printf("Error in smpp34_unpack():%d:\n%s\n", 
                                             smpp34_errno, smpp34_strerror);
        return( -1 );
    };
    printf("parse smpp34_unpack()\n%s\n", smpp34_strerror);

    /* Print PDU **********************************************************/
    memset(bPrint, 0, sizeof(bPrint));
    ret = smpp34_dumpPdu(id, bPrint, sizeof(bPrint), (void*)dst );
    if( ret != 0){
        printf("Error in smpp34_dumpPdu():%d:\n%s\n", 
                                             smpp34_errno, smpp34_strerror);
        return( -1 );
    };
    printf("parse smpp34_dumpPdu()\n%s\n", smpp34_strerror);
    printf("-----------------------------------------------------------\n");
    printf("%s\n", bPrint);
    printf("-----------------------------------------------------------\n");
    return( 0 );
};