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

Go to the source code of this file.

Functions

static int my_cmp (const void *a, const void *b)
 
static void my_dump (const void *a, long index)
 
int main ()
 

Function Documentation

int main ( void  )

Definition at line 77 of file test_prioqueue.c.

References debug(), gw_prioqueue_create(), gw_prioqueue_foreach(), gw_prioqueue_insert(), gw_prioqueue_len(), gw_prioqueue_remove(), gwlib_init(), gwlib_shutdown(), my_cmp(), my_dump(), octstr_create, octstr_destroy(), octstr_get_char(), octstr_get_cstr, octstr_imm(), octstr_len(), and queue.

78 {
79  Octstr *os;
80  long i;
82 
83  gwlib_init();
84 
85  /* os = octstr_imm("iareanmsgotx"); */
86  os = octstr_imm("123456789");
87 
88  queue = gw_prioqueue_create(my_cmp);
89 
90  for (i=0; i < octstr_len(os); i++) {
91  char a[2];
92  a[0] = octstr_get_char(os, i);
93  a[1] = '\0';
95  }
96 
98  while ((os = gw_prioqueue_remove(queue))) {
99  debug("", 0, "%s", octstr_get_cstr(os));
100  octstr_destroy(os);
101  }
102 
103  debug("", 0, "gw_prioqueue_len=%ld", gw_prioqueue_len(queue));
104 
105  gwlib_shutdown();
106  return 0;
107 }
void gw_prioqueue_foreach(gw_prioqueue_t *queue, void(*fn)(const void *, long))
Definition: gw-prioqueue.c:252
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
void gw_prioqueue_insert(gw_prioqueue_t *queue, void *item)
Definition: gw-prioqueue.c:235
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:281
void * gw_prioqueue_remove(gw_prioqueue_t *queue)
Definition: gw-prioqueue.c:265
long gw_prioqueue_len(gw_prioqueue_t *queue)
Definition: gw-prioqueue.c:220
void octstr_destroy(Octstr *ostr)
Definition: octstr.c:322
#define octstr_create(cstr)
Definition: octstr.h:125
gw_prioqueue_t * gw_prioqueue_create(int(*cmp)(const void *, const void *))
Definition: gw-prioqueue.c:174
long octstr_len(const Octstr *ostr)
Definition: octstr.c:340
Definition: octstr.c:118
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:690
void gwlib_shutdown(void)
Definition: gwlib.c:94
void gwlib_init(void)
Definition: gwlib.c:78
static List * queue
Definition: wap-appl.c:123
int octstr_get_char(const Octstr *ostr, long pos)
Definition: octstr.c:404
static void my_dump(const void *a, long index)
static int my_cmp(const void *a, const void *b)
static int my_cmp ( const void *  a,
const void *  b 
)
static

Definition at line 66 of file test_prioqueue.c.

References octstr_compare().

Referenced by main().

67 {
68  return octstr_compare((Octstr*) a, (Octstr*) b);
69 }
Definition: octstr.c:118
int octstr_compare(const Octstr *ostr1, const Octstr *ostr2)
Definition: octstr.c:869
static void my_dump ( const void *  a,
long  index 
)
static

Definition at line 71 of file test_prioqueue.c.

References debug(), and octstr_get_cstr.

Referenced by main().

72 {
73  debug("", 0, "dump(%p, %ld) called", a, index);
74  debug("", 0, "value=%s", octstr_get_cstr((Octstr*) a));
75 }
#define octstr_get_cstr(ostr)
Definition: octstr.h:233
Definition: octstr.c:118
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:690
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.