Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
test_msg.c File Reference
#include "gw/msg.h"
#include "gwlib/gwlib.h"

Go to the source code of this file.

Functions

int main (void)
 

Function Documentation

int main ( void  )

Definition at line 70 of file test_msg.c.

References gwlib_init(), info(), msg, msg_create, msg_destroy(), msg_dump(), msg_duplicate(), msg_pack(), msg_unpack, octstr_create, octstr_dump, and octstr_get_cstr.

70  {
71  Msg *msg, *msg2;
72  Octstr *os;
73 
74  gwlib_init();
75 
76  info(0, "Creating msg.");
77  msg = msg_create(heartbeat);
78  msg->heartbeat.load = 42;
79  msg_dump(msg, 0);
80 
81  info(0, "Packing msg.");
82  os = msg_pack(msg);
83  octstr_dump(os, 0);
84 
85  info(0, "Unpacking msg to msg2.");
86  msg2 = msg_unpack(os);
87  info(0, "msg2->heartbeat.load: %ld", (long) msg2->heartbeat.load);
88 
89  info(0, "Destroying msg and msg2.");
90  msg_destroy(msg);
91  msg_destroy(msg2);
92 
93  info(0, "Creating sms.");
94  msg = msg_create(sms);
95  msg->sms.sender = octstr_create("123");
96  msg->sms.receiver = octstr_create("456");
97  msg->sms.msgdata = octstr_create("hello, world");
98 
99  info(0, "Packing sms.");
100  os = msg_pack(msg);
101  octstr_dump(os, 0);
102 
103  info(0, "Duplicating msg.");
104  msg2 = msg_duplicate(msg);
105  msg_dump(msg2, 0);
106  msg_destroy(msg2);
107 
108  info(0, "Unpacking sms.");
109  msg2 = msg_unpack(os);
110  info(0, "msg2:");
111  info(0, " sender: %s", octstr_get_cstr(msg->sms.sender));
112  info(0, " receiv: %s", octstr_get_cstr(msg->sms.receiver));
113  info(0, " msgdata : %s", octstr_get_cstr(msg->sms.msgdata));
114 
115  return 0;
116 }
void msg_dump(Msg *msg, int level)
Definition: msg.c:152
void info(int err, const char *fmt,...)
Definition: log.c:636
Msg * msg_duplicate(Msg *msg)
Definition: msg.c:111
#define msg_unpack(os)
Definition: msg.h:183
#define msg_create(type)
Definition: msg.h:136
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
Definition: msg.h:79
#define octstr_dump(ostr, level,...)
Definition: octstr.h:564
void msg_destroy(Msg *msg)
Definition: msg.c:132
#define octstr_create(cstr)
Definition: octstr.h:125
Definition: octstr.c:118
Octstr * msg_pack(Msg *msg)
Definition: msg.c:181
void gwlib_init(void)
Definition: gwlib.c:78
static XMLRPCDocument * msg
Definition: test_xmlrpc.c:86
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.