Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
test_store_dump.c File Reference
#include "gwlib/gwlib.h"
#include "shared.h"
#include "bearerbox.h"

Go to the source code of this file.


static void print_msg (Msg *msg)
static int check_args (int i, int argc, char **argv)
int main (int argc, char **argv)


static int counter = 0

Function Documentation

◆ check_args()

static int check_args ( int  i,
int  argc,
char **  argv 

Definition at line 77 of file test_store_dump.c.

Referenced by main().

77  {
78  return -1;
79 }

◆ main()

int main ( int  argc,
char **  argv 

Definition at line 81 of file test_store_dump.c.

References check_args(), counter, get_and_set_debugs(), gwlib_init(), gwlib_shutdown(), info(), msg_pack(), msg_unpack_wrapper(), octstr_create, octstr_imm(), panic, print_msg(), store_init(), store_load, and type.

82 {
83  int cf_index;
84  Octstr *type;
86  gwlib_init();
88  cf_index = get_and_set_debugs(argc, argv, check_args);
90  if (argv[cf_index] == NULL)
91  panic(0, "Usage: %s <store-file>", argv[0]);
93  type = octstr_create("file");
95  /* init store subsystem */
96  store_init(NULL, type, octstr_imm(argv[cf_index]), -1, msg_pack, msg_unpack_wrapper);
98  /* pass every entry in the store to callback print_msg() */
101  info(0, "Store file contains %d msg entries", counter);
102  info(0, "Shutting down.");
104  gwlib_shutdown();
106  return 1;
107 }
void info(int err, const char *fmt,...)
Definition: log.c:672
static int check_args(int i, int argc, char **argv)
Msg * msg_unpack_wrapper(Octstr *os)
Definition: msg.c:256
static int counter
int type
Definition: smsc_cimd2.c:215
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:281
int store_init(Cfg *cfg, const Octstr *type, const Octstr *fname, long dump_freq, void *pack_func, void *unpack_func)
Definition: bb_store.c:82
#define octstr_create(cstr)
Definition: octstr.h:125
Definition: octstr.c:118
static void print_msg(Msg *msg)
#define panic
Definition: log.h:87
int(* store_load)(void(*receive_msg)(Msg *))
Definition: bb_store.c:74
void gwlib_shutdown(void)
Definition: gwlib.c:94
Octstr * msg_pack(Msg *msg)
Definition: msg.c:181
void gwlib_init(void)
Definition: gwlib.c:78
int get_and_set_debugs(int argc, char **argv, int(*find_own)(int index, int argc, char **argv))
Definition: utils.c:626

◆ print_msg()

static void print_msg ( Msg msg)

Definition at line 70 of file test_store_dump.c.

References counter, and msg_dump().

Referenced by main().

71 {
72  counter++;
73  msg_dump(msg, 0);
74 }
void msg_dump(Msg *msg, int level)
Definition: msg.c:152
static int counter

Variable Documentation

◆ counter

int counter = 0

Definition at line 68 of file test_store_dump.c.

Referenced by main(), and print_msg().

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.