Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
dlr_p.h File Reference

Go to the source code of this file.

Data Structures

struct  dlr_entry
 
struct  dlr_storage
 
struct  dlr_db_fields
 

Macros

#define DLR_TRACE   1
 
#define MIN_DST_LEN   7
 

Functions

struct dlr_entrydlr_entry_create (void)
 
void dlr_entry_destroy (struct dlr_entry *dlr)
 
struct dlr_entrydlr_entry_duplicate (const struct dlr_entry *dlr)
 
struct dlr_db_fieldsdlr_db_fields_create (CfgGroup *grp)
 
void dlr_db_fields_destroy (struct dlr_db_fields *fields)
 
struct dlr_storagedlr_init_mem (Cfg *cfg)
 
struct dlr_storagedlr_init_spool (Cfg *cfg)
 
struct dlr_storagedlr_init_mysql (Cfg *cfg)
 
struct dlr_storagedlr_init_sdb (Cfg *cfg)
 
struct dlr_storagedlr_init_oracle (Cfg *cfg)
 
struct dlr_storagedlr_init_pgsql (Cfg *cfg)
 
struct dlr_storagedlr_init_mssql (Cfg *cfg)
 
struct dlr_storagedlr_init_sqlite3 (Cfg *cfg)
 
struct dlr_storagedlr_init_redis (Cfg *cfg)
 
struct dlr_storagedlr_init_cass (Cfg *cfg)
 

Macro Definition Documentation

#define DLR_TRACE   1

Definition at line 71 of file dlr_p.h.

#define MIN_DST_LEN   7

Definition at line 74 of file dlr_p.h.

Referenced by dlr_find().

Function Documentation

struct dlr_db_fields* dlr_db_fields_create ( CfgGroup grp)

Definition at line 169 of file dlr.c.

References cfg_get, cfg_get_integer(), dlr_db_fields::field_boxc, dlr_db_fields::field_dst, dlr_db_fields::field_mask, dlr_db_fields::field_serv, dlr_db_fields::field_smsc, dlr_db_fields::field_src, dlr_db_fields::field_status, dlr_db_fields::field_ts, dlr_db_fields::field_url, gw_assert(), octstr_imm(), panic, dlr_db_fields::table, and dlr_db_fields::ttl.

170 {
171  struct dlr_db_fields *ret = NULL;
172 
173  ret = gw_malloc(sizeof(*ret));
174  gw_assert(ret != NULL);
175  memset(ret, 0, sizeof(*ret));
176 
177  if (!(ret->table = cfg_get(grp, octstr_imm("table"))))
178  panic(0, "DLR: DB: directive 'table' is not specified!");
179  ret->ttl = 0;
180  if (cfg_get_integer(&ret->ttl, grp, octstr_imm("ttl")) == -1 || ret->ttl < 0)
181  ret->ttl = 0;
182  if (!(ret->field_smsc = cfg_get(grp, octstr_imm("field-smsc"))))
183  panic(0, "DLR: DB: directive 'field-smsc' is not specified!");
184  if (!(ret->field_ts = cfg_get(grp, octstr_imm("field-timestamp"))))
185  panic(0, "DLR: DB: directive 'field-timestamp' is not specified!");
186  if (!(ret->field_src = cfg_get(grp, octstr_imm("field-source"))))
187  panic(0, "DLR: DB: directive 'field-source' is not specified!");
188  if (!(ret->field_dst = cfg_get(grp, octstr_imm("field-destination"))))
189  panic(0, "DLR: DB: directive 'field-destination' is not specified!");
190  if (!(ret->field_serv = cfg_get(grp, octstr_imm("field-service"))))
191  panic(0, "DLR: DB: directive 'field-service' is not specified!");
192  if (!(ret->field_url = cfg_get(grp, octstr_imm("field-url"))))
193  panic(0, "DLR: DB: directive 'field-url' is not specified!");
194  if (!(ret->field_mask = cfg_get(grp, octstr_imm("field-mask"))))
195  panic(0, "DLR: DB: directive 'field-mask' is not specified!");
196  if (!(ret->field_status = cfg_get(grp, octstr_imm("field-status"))))
197  panic(0, "DLR: DB: directive 'field-status' is not specified!");
198  if (!(ret->field_boxc = cfg_get(grp, octstr_imm("field-boxc-id"))))
199  panic(0, "DLR: DB: directive 'field-boxc-id' is not specified!");
200 
201  return ret;
202 }
Octstr * field_boxc
Definition: dlr_p.h:160
#define cfg_get(grp, varname)
Definition: cfg.h:86
Octstr * field_src
Definition: dlr_p.h:154
Octstr * field_url
Definition: dlr_p.h:157
Octstr * field_status
Definition: dlr_p.h:159
Octstr * table
Definition: dlr_p.h:150
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:281
Octstr * field_serv
Definition: dlr_p.h:156
gw_assert(wtls_machine->packet_to_send!=NULL)
Octstr * field_smsc
Definition: dlr_p.h:152
int cfg_get_integer(long *n, CfgGroup *grp, Octstr *varname)
Definition: cfg.c:739
#define panic
Definition: log.h:87
Octstr * field_ts
Definition: dlr_p.h:153
Octstr * field_dst
Definition: dlr_p.h:155
Octstr * field_mask
Definition: dlr_p.h:158
long ttl
Definition: dlr_p.h:151
void dlr_db_fields_destroy ( struct dlr_db_fields fields)

Definition at line 204 of file dlr.c.

References dlr_db_fields::field_boxc, dlr_db_fields::field_dst, dlr_db_fields::field_mask, dlr_db_fields::field_serv, dlr_db_fields::field_smsc, dlr_db_fields::field_src, dlr_db_fields::field_status, dlr_db_fields::field_ts, dlr_db_fields::field_url, O_DELETE, and dlr_db_fields::table.

205 {
206  /* sanity check */
207  if (fields == NULL)
208  return;
209 
210 #define O_DELETE(a) { if (a) octstr_destroy(a); a = NULL; }
211 
212  O_DELETE(fields->table);
213  O_DELETE(fields->field_smsc);
214  O_DELETE(fields->field_ts);
215  O_DELETE(fields->field_src);
216  O_DELETE(fields->field_dst);
217  O_DELETE(fields->field_serv);
218  O_DELETE(fields->field_url);
219  O_DELETE(fields->field_mask);
220  O_DELETE(fields->field_status);
221  O_DELETE(fields->field_boxc);
222 
223 #undef O_DELETE
224 
225  gw_free(fields);
226 }
Octstr * field_boxc
Definition: dlr_p.h:160
Octstr * field_src
Definition: dlr_p.h:154
Octstr * field_url
Definition: dlr_p.h:157
Octstr * field_status
Definition: dlr_p.h:159
Octstr * table
Definition: dlr_p.h:150
Octstr * field_serv
Definition: dlr_p.h:156
Octstr * field_smsc
Definition: dlr_p.h:152
#define O_DELETE(a)
Octstr * field_ts
Definition: dlr_p.h:153
Octstr * field_dst
Definition: dlr_p.h:155
Octstr * field_mask
Definition: dlr_p.h:158
struct dlr_entry* dlr_entry_create ( void  )

Definition at line 103 of file dlr.c.

References gw_assert().

Referenced by dlr_add(), dlr_entry_duplicate(), and dlr_spool_get().

104 {
105  struct dlr_entry *dlr;
106 
107  dlr = gw_malloc(sizeof(*dlr));
108  gw_assert(dlr != NULL);
109 
110  /* set all values to NULL */
111  memset(dlr, 0, sizeof(*dlr));
112 
113  return dlr;
114 }
gw_assert(wtls_machine->packet_to_send!=NULL)
Definition: dlr_p.h:78
void dlr_entry_destroy ( struct dlr_entry dlr)

Definition at line 142 of file dlr.c.

References dlr_entry::boxc_id, dlr_entry::destination, dlr_entry::mask, O_DELETE, dlr_entry::service, dlr_entry::smsc, dlr_entry::source, dlr_entry::timestamp, and dlr_entry::url.

Referenced by dlr_find(), dlr_mem_flush(), dlr_mem_remove(), dlr_mem_shutdown(), and dlr_spool_add().

143 {
144  /* sanity check */
145  if (dlr == NULL)
146  return;
147 
148 #define O_DELETE(a) { if (a) octstr_destroy(a); a = NULL; }
149 
150  O_DELETE(dlr->smsc);
151  O_DELETE(dlr->timestamp);
152  O_DELETE(dlr->source);
153  O_DELETE(dlr->destination);
154  O_DELETE(dlr->service);
155  O_DELETE(dlr->url);
156  O_DELETE(dlr->boxc_id);
157 
158 #undef O_DELETE
159 
160  dlr->mask = 0;
161  gw_free(dlr);
162 }
Octstr * url
Definition: dlr_p.h:84
Octstr * service
Definition: dlr_p.h:83
Octstr * boxc_id
Definition: dlr_p.h:85
Octstr * source
Definition: dlr_p.h:81
Octstr * timestamp
Definition: dlr_p.h:80
Octstr * destination
Definition: dlr_p.h:82
#define O_DELETE(a)
Octstr * smsc
Definition: dlr_p.h:79
int mask
Definition: dlr_p.h:86
struct dlr_entry* dlr_entry_duplicate ( const struct dlr_entry dlr)

Definition at line 119 of file dlr.c.

References dlr_entry::boxc_id, dlr_entry::destination, dlr_entry_create(), dlr_entry::mask, octstr_duplicate, dlr_entry::service, dlr_entry::smsc, dlr_entry::source, dlr_entry::timestamp, and dlr_entry::url.

Referenced by dlr_mem_get().

120 {
121  struct dlr_entry *ret;
122 
123  if (dlr == NULL)
124  return NULL;
125 
126  ret = dlr_entry_create();
127  ret->smsc = octstr_duplicate(dlr->smsc);
128  ret->timestamp = octstr_duplicate(dlr->timestamp);
129  ret->source = octstr_duplicate(dlr->source);
131  ret->service = octstr_duplicate(dlr->service);
132  ret->url = octstr_duplicate(dlr->url);
133  ret->boxc_id = octstr_duplicate(dlr->boxc_id);
134  ret->mask = dlr->mask;
135 
136  return ret;
137 }
Octstr * url
Definition: dlr_p.h:84
Octstr * service
Definition: dlr_p.h:83
struct dlr_entry * dlr_entry_create(void)
Definition: dlr.c:103
Octstr * boxc_id
Definition: dlr_p.h:85
Octstr * source
Definition: dlr_p.h:81
#define octstr_duplicate(ostr)
Definition: octstr.h:187
Octstr * timestamp
Definition: dlr_p.h:80
Octstr * destination
Definition: dlr_p.h:82
Definition: dlr_p.h:78
Octstr * smsc
Definition: dlr_p.h:79
int mask
Definition: dlr_p.h:86
struct dlr_storage* dlr_init_cass ( Cfg cfg)

Definition at line 427 of file dlr_cass.c.

Referenced by dlr_init().

428 {
429  return NULL;
430 }
struct dlr_storage* dlr_init_mem ( Cfg cfg)

Definition at line 206 of file dlr_mem.c.

References gw_rwlock_init_static(), gwlist_create, and handles.

Referenced by dlr_init().

207 {
210 
211  return &handles;
212 }
static struct dlr_storage handles
Definition: dlr_mem.c:193
#define gwlist_create()
Definition: list.h:136
static RWLock rwlock
Definition: dlr_mem.c:76
void gw_rwlock_init_static(RWLock *lock)
Definition: gw-rwlock.c:96
static List * dlr_waiting_list
Definition: dlr_mem.c:75
struct dlr_storage* dlr_init_mssql ( Cfg cfg)

Definition at line 394 of file dlr_mssql.c.

Referenced by dlr_init().

395 {
396  return NULL;
397 }
struct dlr_storage* dlr_init_mysql ( Cfg cfg)

Definition at line 470 of file dlr_mysql.c.

Referenced by dlr_init().

471 {
472  return NULL;
473 }
struct dlr_storage* dlr_init_oracle ( Cfg cfg)

Definition at line 428 of file dlr_oracle.c.

Referenced by dlr_init().

429 {
430  return NULL;
431 }
struct dlr_storage* dlr_init_pgsql ( Cfg cfg)

Definition at line 420 of file dlr_pgsql.c.

Referenced by dlr_init().

421 {
422  return NULL;
423 }
struct dlr_storage* dlr_init_redis ( Cfg cfg)

Definition at line 569 of file dlr_redis.c.

Referenced by dlr_init().

570 {
571  return NULL;
572 }
struct dlr_storage* dlr_init_sdb ( Cfg cfg)

Definition at line 477 of file dlr_sdb.c.

Referenced by dlr_init().

478 {
479  return NULL;
480 }
struct dlr_storage* dlr_init_spool ( Cfg cfg)

Definition at line 607 of file dlr_spool.c.

References cfg_get, cfg_get_single_group(), counter_create(), for_each_file(), handles, non_verified_file(), octstr_imm(), and panic.

Referenced by dlr_init().

608 {
609  CfgGroup *grp;
610 
611  if (!(grp = cfg_get_single_group(cfg, octstr_imm("core"))))
612  panic(0, "DLR: spool: group 'core' is not specified!");
613 
614  if (!(spool_dir = cfg_get(grp, octstr_imm("dlr-spool"))))
615  panic(0, "DLR: spool: directive 'dlr-spool' is not specified!");
616 
617 #ifdef HAVE_LIBSSL
618  OpenSSL_add_all_digests();
619 #endif
620 
622 
623  /* we need to traverse the DLR spool to determine how
624  * many entries we have. */
625 #ifdef VERIFIED
626  for_each_file(spool_dir, 1, verified_file);
627 #else
629 #endif
630 
631  return &handles;
632 }
static Octstr * spool_dir
Definition: dlr_spool.c:107
static Counter * counter
Definition: dlr_spool.c:112
#define cfg_get(grp, varname)
Definition: cfg.h:86
static int for_each_file(const Octstr *dir_s, int ignore_err, int(*cb)(const char *, const struct stat *, int, void *))
Definition: dlr_spool.c:259
static struct dlr_storage handles
Definition: dlr_spool.c:593
Octstr * octstr_imm(const char *cstr)
Definition: octstr.c:281
Counter * counter_create(void)
Definition: counter.c:94
#define panic
Definition: log.h:87
Definition: cfg.c:73
CfgGroup * cfg_get_single_group(Cfg *cfg, Octstr *name)
Definition: cfg.c:636
static int non_verified_file(const char *filename, const struct stat *sb, int tflag, void *ftwbuf)
Definition: dlr_spool.c:211
struct dlr_storage* dlr_init_sqlite3 ( Cfg cfg)

Definition at line 421 of file dlr_sqlite3.c.

Referenced by dlr_init().

422 {
423  return NULL;
424 }
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.