Browse code

presence: renamed global vars to add common module prefix

- better protection against name conflicts, as this module is used by
other modules and can run in library mode

Daniel-Constantin Mierla authored on 14/04/2020 09:10:55
Showing 12 changed files
... ...
@@ -231,10 +231,10 @@ int add_event(pres_ev_t *event)
231 231
 	ev->default_expires = event->default_expires;
232 232
 
233 233
 	if(not_in_list) {
234
-		ev->next = EvList->events;
235
-		EvList->events = ev;
234
+		ev->next = pres_evlist->events;
235
+		pres_evlist->events = ev;
236 236
 	}
237
-	EvList->ev_count++;
237
+	pres_evlist->ev_count++;
238 238
 
239 239
 	LM_DBG("successfully added event: %.*s - len= %d\n", ev->name.len,
240 240
 			ev->name.s, ev->name.len);
... ...
@@ -319,7 +319,7 @@ void free_event_params(param_t *params, int mem_type)
319 319
 pres_ev_t *search_event(event_t *event)
320 320
 {
321 321
 	pres_ev_t *pres_ev;
322
-	pres_ev = EvList->events;
322
+	pres_ev = pres_evlist->events;
323 323
 
324 324
 	LM_DBG("start event= [%.*s/%d]\n", event->name.len, event->name.s,
325 325
 			event->type);
... ...
@@ -388,13 +388,14 @@ int search_event_params(event_t *ev, event_t *searched_ev)
388 388
 }
389 389
 int get_event_list(str **ev_list)
390 390
 {
391
-	pres_ev_t *ev = EvList->events;
391
+	pres_ev_t *ev = pres_evlist->events;
392 392
 	int i;
393 393
 	str *list;
394 394
 	*ev_list = NULL;
395 395
 
396
-	if(EvList->ev_count == 0)
396
+	if(pres_evlist->ev_count == 0) {
397 397
 		return 0;
398
+	}
398 399
 
399 400
 	list = (str *)pkg_malloc(sizeof(str));
400 401
 	if(list == NULL) {
... ...
@@ -402,7 +403,7 @@ int get_event_list(str **ev_list)
402 403
 		return -1;
403 404
 	}
404 405
 	memset(list, 0, sizeof(str));
405
-	list->s = (char *)pkg_malloc(EvList->ev_count * MAX_EVNAME_SIZE);
406
+	list->s = (char *)pkg_malloc(pres_evlist->ev_count * MAX_EVNAME_SIZE);
406 407
 	if(list->s == NULL) {
407 408
 		LM_ERR("No more memory\n");
408 409
 		pkg_free(list);
... ...
@@ -410,7 +411,7 @@ int get_event_list(str **ev_list)
410 411
 	}
411 412
 	list->s[0] = '\0';
412 413
 
413
-	for(i = 0; i < EvList->ev_count; i++) {
414
+	for(i = 0; i < pres_evlist->ev_count; i++) {
414 415
 		if(i > 0) {
415 416
 			memcpy(list->s + list->len, ", ", 2);
416 417
 			list->len += 2;
... ...
@@ -427,13 +428,14 @@ int get_event_list(str **ev_list)
427 428
 void destroy_evlist(void)
428 429
 {
429 430
 	pres_ev_t *e1, *e2;
430
-	if(EvList) {
431
-		e1 = EvList->events;
431
+	if(pres_evlist) {
432
+		e1 = pres_evlist->events;
432 433
 		while(e1) {
433 434
 			e2 = e1->next;
434 435
 			free_pres_event(e1);
435 436
 			e1 = e2;
436 437
 		}
437
-		shm_free(EvList);
438
+		shm_free(pres_evlist);
439
+		pres_evlist = NULL;
438 440
 	}
439 441
 }
... ...
@@ -150,7 +150,7 @@ typedef int (*get_event_list_t)(str **ev_list);
150 150
 
151 151
 void destroy_evlist(void);
152 152
 
153
-extern evlist_t *EvList;
153
+extern evlist_t *pres_evlist;
154 154
 
155 155
 pres_ev_t *search_event(event_t *event);
156 156
 typedef pres_ev_t *(*search_event_t)(event_t *event);
... ...
@@ -272,16 +272,19 @@ int insert_shtable(shtable_t htable, unsigned int hash_code, subs_t *subs)
272 272
 					subs->pres_uri.len, subs->pres_uri.s, subs->callid.len, subs->callid.s);
273 273
 				/* delete this record */
274 274
 
275
-				if (prev_rec)
275
+				if (prev_rec) {
276 276
 					prev_rec->next = rec->next;
277
-				else
277
+				} else {
278 278
 					htable[hash_code].entries->next = rec->next;
279
+				}
279 280
 
280
-				if (subs_dbmode != NO_DB)
281
+				if (pres_subs_dbmode != NO_DB) {
281 282
 					delete_db_subs(&rec->to_tag, &rec->from_tag, &rec->callid);
283
+				}
282 284
 
283
-				if (rec->contact.s!=NULL)
285
+				if (rec->contact.s!=NULL) {
284 286
 					shm_free(rec->contact.s);
287
+				}
285 288
 
286 289
 				shm_free(rec);
287 290
 				break;
... ...
@@ -120,7 +120,7 @@ typedef struct pres_entry
120 120
 	struct pres_entry *next;
121 121
 } pres_entry_t;
122 122
 
123
-typedef struct pres_htable
123
+typedef struct pres_phtable
124 124
 {
125 125
 	pres_entry_t *entries;
126 126
 	gen_lock_t lock;
... ...
@@ -294,7 +294,7 @@ int get_wi_subs_db(subs_t *subs, watcher_t *watchers)
294 294
 	query_ops[n_query_cols] = OP_GT;
295 295
 	query_vals[n_query_cols].type = DB1_INT;
296 296
 	query_vals[n_query_cols].nul = 0;
297
-	query_vals[n_query_cols].val.int_val = (int)time(NULL) + expires_offset;
297
+	query_vals[n_query_cols].val.int_val = (int)time(NULL) + pres_expires_offset;
298 298
 	n_query_cols++;
299 299
 
300 300
 	result_cols[status_col = n_result_cols++] = &str_status_col;
... ...
@@ -387,7 +387,7 @@ str *get_wi_notify_body(subs_t *subs, subs_t *watcher_subs)
387 387
 		goto done;
388 388
 	}
389 389
 
390
-	if(subs_dbmode == DB_ONLY) {
390
+	if(pres_subs_dbmode == DB_ONLY) {
391 391
 		if(get_wi_subs_db(subs, watchers) < 0) {
392 392
 			LM_ERR("getting watchers from database\n");
393 393
 			goto error;
... ...
@@ -1131,7 +1131,7 @@ int get_subs_db(
1131 1131
 
1132 1132
 		s.event = event;
1133 1133
 		s.local_cseq = row_vals[cseq_col].val.int_val + 1;
1134
-		if(row_vals[expires_col].val.int_val < (int)time(NULL) + expires_offset)
1134
+		if(row_vals[expires_col].val.int_val < (int)time(NULL) + pres_expires_offset)
1135 1135
 			s.expires = 0;
1136 1136
 		else
1137 1137
 			s.expires = row_vals[expires_col].val.int_val - (int)time(NULL);
... ...
@@ -1169,11 +1169,10 @@ subs_t *get_subs_dialog(str *pres_uri, pres_ev_t *event, str *sender)
1169 1169
 	subs_t *s_array = NULL;
1170 1170
 	int n = 0;
1171 1171
 
1172
-	/* if subs_dbmode!=DB_ONLY, should take the subscriptions from the hashtable only
1173
-	   in DB_ONLY mode should take all dialogs from db
1174
-	*/
1172
+	/* if pres_subs_dbmode!=DB_ONLY, should take the subscriptions from the
1173
+		hashtable only in DB_ONLY mode should take all dialogs from db */
1175 1174
 
1176
-	if(subs_dbmode == DB_ONLY) {
1175
+	if(pres_subs_dbmode == DB_ONLY) {
1177 1176
 		if(get_subs_db(pres_uri, event, sender, &s_array, &n) < 0) {
1178 1177
 			LM_ERR("getting dialogs from database\n");
1179 1178
 			goto error;
... ...
@@ -1578,7 +1577,7 @@ int notify(subs_t *subs, subs_t *watcher_subs, str *n_body, int force_null_body,
1578 1577
 				&subs->pres_uri, &subs->event->name, shtable_size);
1579 1578
 
1580 1579
 		/* if subscriptions are held also in memory, update the subscription hashtable */
1581
-		if(subs_dbmode != DB_ONLY) {
1580
+		if(pres_subs_dbmode != DB_ONLY) {
1582 1581
 			if(update_shtable(subs_htable, hash_code, subs, LOCAL_TYPE) < 0) {
1583 1582
 				/* subscriptions are held only in memory, and hashtable update failed */
1584 1583
 				LM_ERR("updating subscription record in hash table\n");
... ...
@@ -1587,8 +1586,8 @@ int notify(subs_t *subs, subs_t *watcher_subs, str *n_body, int force_null_body,
1587 1586
 		}
1588 1587
 		/* if DB_ONLY mode or WRITE_THROUGH update in database */
1589 1588
 		if(subs->recv_event != PRES_SUBSCRIBE_RECV
1590
-				&& ((subs_dbmode == DB_ONLY && pres_notifier_processes == 0)
1591
-						   || subs_dbmode == WRITE_THROUGH)) {
1589
+				&& ((pres_subs_dbmode == DB_ONLY && pres_notifier_processes == 0)
1590
+						   || pres_subs_dbmode == WRITE_THROUGH)) {
1592 1591
 			LM_DBG("updating subscription to database\n");
1593 1592
 			if(update_subs_db(subs, LOCAL_TYPE) < 0) {
1594 1593
 				LM_ERR("updating subscription in database\n");
... ...
@@ -1764,7 +1763,7 @@ void p_tm_callback(struct cell *t, int type, struct tmcb_params *ps)
1764 1763
 	run_notify_reply_event(t, ps);
1765 1764
 
1766 1765
 	if(ps->code == 404 || ps->code == 481
1767
-			|| (ps->code == 408 && timeout_rm_subs
1766
+			|| (ps->code == 408 && pres_timeout_rm_subs
1768 1767
 					   && subs->status != TERMINATED_STATUS)
1769 1768
 			|| pres_get_delete_sub()) {
1770 1769
 		delete_subs(&subs->pres_uri, &subs->event->name, &subs->to_tag,
... ...
@@ -2601,7 +2600,7 @@ static int notifier_notify(subs_t *sub, int *updated, int *end_transaction)
2601 2600
 				goto error;
2602 2601
 			} else if(num_other_watchers == 0)
2603 2602
 				attempt_delete_presentities = 1;
2604
-		} else if(!send_fast_notify)
2603
+		} else if(!pres_send_fast_notify)
2605 2604
 			goto done;
2606 2605
 	}
2607 2606
 
... ...
@@ -2692,7 +2691,7 @@ int process_dialogs(int round, int presence_winfo)
2692 2691
 	}
2693 2692
 
2694 2693
 	if(pa_dbf.start_transaction) {
2695
-		if(pa_dbf.start_transaction(pa_db, db_table_lock) < 0) {
2694
+		if(pa_dbf.start_transaction(pa_db, pres_db_table_lock) < 0) {
2696 2695
 			LM_ERR("in start_transaction\n");
2697 2696
 			goto error;
2698 2697
 		}
... ...
@@ -2796,7 +2795,7 @@ int process_dialogs(int round, int presence_winfo)
2796 2795
 		}
2797 2796
 
2798 2797
 		if(pa_dbf.start_transaction) {
2799
-			if(pa_dbf.start_transaction(pa_db, db_table_lock) < 0) {
2798
+			if(pa_dbf.start_transaction(pa_db, pres_db_table_lock) < 0) {
2800 2799
 				LM_ERR("in start_transaction\n");
2801 2800
 				goto error;
2802 2801
 			}
... ...
@@ -2856,7 +2855,7 @@ int process_dialogs(int round, int presence_winfo)
2856 2855
 		cached_updated_winfo = sub.updated_winfo =
2857 2856
 				VAL_INT(&dvalues[updated_winfo_col]);
2858 2857
 
2859
-		if(VAL_INT(&dvalues[expires_col]) > now + expires_offset)
2858
+		if(VAL_INT(&dvalues[expires_col]) > now + pres_expires_offset)
2860 2859
 			sub.expires = VAL_INT(&dvalues[expires_col]) - now;
2861 2860
 		else
2862 2861
 			sub.expires = 0;
... ...
@@ -81,8 +81,8 @@ MODULE_VERSION
81 81
 #define P_TABLE_VERSION 5
82 82
 #define ACTWATCH_TABLE_VERSION 12
83 83
 
84
-static int clean_period = 100;
85
-static int db_update_period = 100;
84
+static int pres_clean_period = 100;
85
+static int pres_db_update_period = 100;
86 86
 int pres_local_log_level = L_INFO;
87 87
 
88 88
 static char *pres_log_facility_str =
... ...
@@ -97,20 +97,20 @@ str active_watchers_table = str_init("active_watchers");
97 97
 str watchers_table = str_init("watchers");
98 98
 
99 99
 int pres_fetch_rows = 500;
100
-int library_mode = 0;
101
-str server_address = {0, 0};
102
-evlist_t *EvList = NULL;
100
+static int pres_library_mode = 0;
101
+str pres_server_address = {0, 0};
102
+evlist_t *pres_evlist = NULL;
103 103
 int pres_subs_remove_match = 0;
104 104
 int _pres_subs_mode = 1;
105 105
 
106
-/* sip uri match */
106
+int pres_uri_match = 0;
107
+/* sip uri match function pointer */
107 108
 sip_uri_match_f presence_sip_uri_match;
108 109
 static int sip_uri_case_sensitive_match(str *s1, str *s2);
109 110
 static int sip_uri_case_insensitive_match(str *s1, str *s2);
110
-int pres_uri_match = 0;
111 111
 
112 112
 /* to tag prefix */
113
-char *to_tag_pref = "10";
113
+char *pres_totag_pref = "10";
114 114
 
115 115
 /* TM bind */
116 116
 struct tm_binds tmb;
... ...
@@ -142,22 +142,22 @@ static int presence_init_rpc(void);
142 142
 static int w_pres_has_subscribers(struct sip_msg *_msg, char *_sp1, char *_sp2);
143 143
 static int fixup_has_subscribers(void **param, int param_no);
144 144
 
145
-int counter = 0;
146
-int pid = 0;
147
-char prefix = 'a';
148
-int startup_time = 0;
145
+int pres_counter = 0;
146
+int pres_pid = 0;
147
+char pres_prefix = 'a';
148
+int pres_startup_time = 0;
149 149
 str pres_db_url = {0, 0};
150
-int expires_offset = 0;
150
+int pres_expires_offset = 0;
151 151
 int pres_cseq_offset = 0;
152
-uint32_t min_expires = 0;
153
-int min_expires_action = 1;
154
-uint32_t max_expires = 3600;
152
+uint32_t pres_min_expires = 0;
153
+int pres_min_expires_action = 1;
154
+uint32_t pres_max_expires = 3600;
155 155
 int shtable_size = 9;
156 156
 shtable_t subs_htable = NULL;
157
-int subs_dbmode = WRITE_BACK;
158
-int sphere_enable = 0;
159
-int timeout_rm_subs = 1;
160
-int send_fast_notify = 1;
157
+int pres_subs_dbmode = WRITE_BACK;
158
+int pres_sphere_enable = 0;
159
+int pres_timeout_rm_subs = 1;
160
+int pres_send_fast_notify = 1;
161 161
 int publ_cache_enabled = 1;
162 162
 int pres_waitn_time = 5;
163 163
 int pres_notifier_poll_rate = 10;
... ...
@@ -170,8 +170,8 @@ str pres_retrieve_order_by = str_init("priority");
170 170
 int pres_enable_dmq = 0;
171 171
 int pres_delete_same_subs = 0;
172 172
 
173
-int db_table_lock_type = 1;
174
-db_locking_t db_table_lock = DB_LOCKING_WRITE;
173
+int pres_db_table_lock_type = 1;
174
+db_locking_t pres_db_table_lock = DB_LOCKING_WRITE;
175 175
 
176 176
 int *pres_notifier_id = NULL;
177 177
 
... ...
@@ -213,28 +213,28 @@ static param_export_t params[]={
213 213
 	{ "presentity_table",       PARAM_STR, &presentity_table},
214 214
 	{ "active_watchers_table",  PARAM_STR, &active_watchers_table},
215 215
 	{ "watchers_table",         PARAM_STR, &watchers_table},
216
-	{ "clean_period",           INT_PARAM, &clean_period },
217
-	{ "db_update_period",       INT_PARAM, &db_update_period },
216
+	{ "clean_period",           INT_PARAM, &pres_clean_period },
217
+	{ "db_update_period",       INT_PARAM, &pres_db_update_period },
218 218
 	{ "waitn_time",             INT_PARAM, &pres_waitn_time },
219 219
 	{ "notifier_poll_rate",     INT_PARAM, &pres_notifier_poll_rate },
220 220
 	{ "notifier_processes",     INT_PARAM, &pres_notifier_processes },
221 221
 	{ "force_delete",           INT_PARAM, &pres_force_delete },
222 222
 	{ "startup_mode",           INT_PARAM, &pres_startup_mode },
223
-	{ "to_tag_pref",            PARAM_STRING, &to_tag_pref },
224
-	{ "expires_offset",         INT_PARAM, &expires_offset },
225
-	{ "max_expires",            INT_PARAM, &max_expires },
226
-	{ "min_expires",            INT_PARAM, &min_expires },
227
-	{ "min_expires_action",     INT_PARAM, &min_expires_action },
228
-	{ "server_address",         PARAM_STR, &server_address},
223
+	{ "to_tag_pref",            PARAM_STRING, &pres_totag_pref },
224
+	{ "expires_offset",         INT_PARAM, &pres_expires_offset },
225
+	{ "max_expires",            INT_PARAM, &pres_max_expires },
226
+	{ "min_expires",            INT_PARAM, &pres_min_expires },
227
+	{ "min_expires_action",     INT_PARAM, &pres_min_expires_action },
228
+	{ "server_address",         PARAM_STR, &pres_server_address},
229 229
 	{ "subs_htable_size",       INT_PARAM, &shtable_size},
230 230
 	{ "pres_htable_size",       INT_PARAM, &phtable_size},
231
-	{ "subs_db_mode",           INT_PARAM, &subs_dbmode},
231
+	{ "subs_db_mode",           INT_PARAM, &pres_subs_dbmode},
232 232
 	{ "publ_cache",             INT_PARAM, &publ_cache_enabled},
233
-	{ "enable_sphere_check",    INT_PARAM, &sphere_enable},
234
-	{ "timeout_rm_subs",        INT_PARAM, &timeout_rm_subs},
235
-	{ "send_fast_notify",       INT_PARAM, &send_fast_notify},
233
+	{ "enable_sphere_check",    INT_PARAM, &pres_sphere_enable},
234
+	{ "timeout_rm_subs",        INT_PARAM, &pres_timeout_rm_subs},
235
+	{ "send_fast_notify",       INT_PARAM, &pres_send_fast_notify},
236 236
 	{ "fetch_rows",             INT_PARAM, &pres_fetch_rows},
237
-	{ "db_table_lock_type",     INT_PARAM, &db_table_lock_type},
237
+	{ "db_table_lock_type",     INT_PARAM, &pres_db_table_lock_type},
238 238
 	{ "local_log_level",        PARAM_INT, &pres_local_log_level},
239 239
 	{ "local_log_facility",     PARAM_STR, &pres_log_facility_str},
240 240
 	{ "subs_remove_match",      PARAM_INT, &pres_subs_remove_match},
... ...
@@ -295,16 +295,18 @@ static int mod_init(void)
295 295
 	LM_DBG("db_url=%s (len=%d addr=%p)\n", ZSW(pres_db_url.s), pres_db_url.len,
296 296
 			pres_db_url.s);
297 297
 
298
-	if(pres_db_url.s == NULL)
299
-		library_mode = 1;
298
+	if(pres_db_url.s == NULL || pres_db_url.len == 0) {
299
+		LM_DBG("db url is not set - switch to library mode\n");
300
+		pres_library_mode = 1;
301
+	}
300 302
 
301
-	EvList = init_evlist();
302
-	if(!EvList) {
303
+	pres_evlist = init_evlist();
304
+	if(!pres_evlist) {
303 305
 		LM_ERR("unsuccessful initialize event list\n");
304 306
 		return -1;
305 307
 	}
306 308
 
307
-	if(library_mode == 1) {
309
+	if(pres_library_mode == 1) {
308 310
 		LM_DBG("Presence module used for API library purpose only\n");
309 311
 		return 0;
310 312
 	}
... ...
@@ -313,26 +315,31 @@ static int mod_init(void)
313 315
 		return -1;
314 316
 	}
315 317
 
316
-	if(expires_offset < 0)
317
-		expires_offset = 0;
318
+	if(pres_expires_offset < 0) {
319
+		pres_expires_offset = 0;
320
+	}
318 321
 
319
-	if(to_tag_pref == NULL || strlen(to_tag_pref) == 0)
320
-		to_tag_pref = "10";
322
+	if(pres_totag_pref == NULL || strlen(pres_totag_pref) == 0) {
323
+		pres_totag_pref = "10";
324
+	}
321 325
 
322
-	if(max_expires == 0)
323
-		max_expires = 3600;
326
+	if(pres_max_expires <= 0) {
327
+		pres_max_expires = 3600;
328
+	}
324 329
 
325
-	if(min_expires > max_expires)
326
-		min_expires = max_expires;
330
+	if(pres_min_expires > pres_max_expires) {
331
+		pres_min_expires = pres_max_expires;
332
+	}
327 333
 
328
-	if(min_expires_action < 1 || min_expires_action > 2) {
334
+	if(pres_min_expires_action < 1 || pres_min_expires_action > 2) {
329 335
 		LM_ERR("min_expires_action must be 1 = RFC 6665/3261 Reply 423, 2 = "
330 336
 			   "force min_expires value\n");
331 337
 		return -1;
332 338
 	}
333 339
 
334
-	if(server_address.s == NULL)
340
+	if(pres_server_address.s == NULL || pres_server_address.len==0) {
335 341
 		LM_DBG("server_address parameter not set in configuration file\n");
342
+	}
336 343
 
337 344
 	/* bind the SL API */
338 345
 	if(sl_load_api(&slb) != 0) {
... ...
@@ -380,7 +387,7 @@ static int mod_init(void)
380 387
 		goto dberror;
381 388
 	}
382 389
 
383
-	if(subs_dbmode != NO_DB
390
+	if(pres_subs_dbmode != NO_DB
384 391
 			&& db_check_table_version(&pa_dbf, pa_db, &active_watchers_table,
385 392
 					   ACTWATCH_TABLE_VERSION)
386 393
 					   < 0) {
... ...
@@ -388,7 +395,7 @@ static int mod_init(void)
388 395
 		goto dberror;
389 396
 	}
390 397
 
391
-	if(subs_dbmode != DB_ONLY) {
398
+	if(pres_subs_dbmode != DB_ONLY) {
392 399
 		if(shtable_size < 1)
393 400
 			shtable_size = 512;
394 401
 		else
... ...
@@ -423,23 +430,27 @@ static int mod_init(void)
423 430
 		}
424 431
 	}
425 432
 
426
-	startup_time = (int)time(NULL);
427
-	if(clean_period > 0) {
428
-		register_timer(msg_presentity_clean, 0, clean_period);
429
-		register_timer(msg_watchers_clean, 0, clean_period);
433
+	pres_startup_time = (int)time(NULL);
434
+	if(pres_clean_period > 0) {
435
+		register_timer(msg_presentity_clean, 0, pres_clean_period);
436
+		register_timer(msg_watchers_clean, 0, pres_clean_period);
430 437
 	}
431 438
 
432
-	if(db_update_period > 0)
433
-		register_timer(timer_db_update, 0, db_update_period);
439
+	if(pres_db_update_period > 0) {
440
+		register_timer(timer_db_update, 0, pres_db_update_period);
441
+	}
434 442
 
435
-	if(pres_waitn_time <= 0)
443
+	if(pres_waitn_time <= 0) {
436 444
 		pres_waitn_time = 5;
445
+	}
437 446
 
438
-	if(pres_notifier_poll_rate <= 0)
447
+	if(pres_notifier_poll_rate <= 0) {
439 448
 		pres_notifier_poll_rate = 10;
449
+	}
440 450
 
441
-	if(pres_notifier_processes < 0 || subs_dbmode != DB_ONLY)
451
+	if(pres_notifier_processes < 0 || pres_subs_dbmode != DB_ONLY) {
442 452
 		pres_notifier_processes = 0;
453
+	}
443 454
 
444 455
 	if(pres_notifier_processes > 0) {
445 456
 		if((pres_notifier_id =
... ...
@@ -468,8 +479,9 @@ static int mod_init(void)
468 479
 		pres_local_log_facility = cfg_get(core, core_cfg, log_facility);
469 480
 	}
470 481
 
471
-	if(db_table_lock_type != 1)
472
-		db_table_lock = DB_LOCKING_NONE;
482
+	if(pres_db_table_lock_type != 1) {
483
+		pres_db_table_lock = DB_LOCKING_NONE;
484
+	}
473 485
 
474 486
 	pa_dbf.close(pa_db);
475 487
 	pa_db = NULL;
... ...
@@ -496,13 +508,15 @@ dberror:
496 508
  */
497 509
 static int child_init(int rank)
498 510
 {
499
-	if(rank == PROC_INIT || rank == PROC_TCP_MAIN)
511
+	if(rank == PROC_INIT || rank == PROC_TCP_MAIN) {
500 512
 		return 0;
513
+	}
501 514
 
502
-	pid = my_pid();
515
+	pres_pid = my_pid();
503 516
 
504
-	if(library_mode)
517
+	if(pres_library_mode) {
505 518
 		return 0;
519
+	}
506 520
 
507 521
 	if(sruid_init(&pres_sruid, '-', "pres", SRUID_INC) < 0) {
508 522
 		return -1;
... ...
@@ -568,7 +582,7 @@ static int child_init(int rank)
568 582
  */
569 583
 static void destroy(void)
570 584
 {
571
-	if(subs_htable && subs_dbmode == WRITE_BACK) {
585
+	if(subs_htable && pres_subs_dbmode == WRITE_BACK) {
572 586
 		/* open database connection */
573 587
 		pa_db = pa_dbf.init(&pres_db_url);
574 588
 		if(!pa_db) {
... ...
@@ -594,7 +608,7 @@ static void destroy(void)
594 608
 
595 609
 static int fixup_presence(void **param, int param_no)
596 610
 {
597
-	if(library_mode) {
611
+	if(pres_library_mode) {
598 612
 		LM_ERR("Bad config - you can not call 'handle_publish' function"
599 613
 			   " (db_url not set)\n");
600 614
 		return -1;
... ...
@@ -608,7 +622,7 @@ static int fixup_presence(void **param, int param_no)
608 622
 static int fixup_subscribe(void **param, int param_no)
609 623
 {
610 624
 
611
-	if(library_mode) {
625
+	if(pres_library_mode) {
612 626
 		LM_ERR("Bad config - you can not call 'handle_subscribe' function"
613 627
 			   " (db_url not set)\n");
614 628
 		return -1;
... ...
@@ -903,7 +917,7 @@ int update_watchers_status(str pres_uri, pres_ev_t *ev, str *rules_doc)
903 917
 	subs.db_flag = hash_code;
904 918
 
905 919
 	/* must do a copy as sphere_check requires database queries */
906
-	if(sphere_enable) {
920
+	if(pres_sphere_enable) {
907 921
 		n = result->n;
908 922
 		ws_list = (ws_t *)pkg_malloc(n * sizeof(ws_t));
909 923
 		if(ws_list == NULL) {
... ...
@@ -1248,7 +1262,7 @@ static int update_pw_dialogs_dbonlymode(subs_t *subs, subs_t **subs_array)
1248 1262
 
1249 1263
 		s.expires = row_vals[r_expires_col].val.int_val;
1250 1264
 
1251
-		if(s.expires > (int)time(NULL) + expires_offset)
1265
+		if(s.expires > (int)time(NULL) + pres_expires_offset)
1252 1266
 			s.expires -= (int)time(NULL);
1253 1267
 		else
1254 1268
 			s.expires = 0;
... ...
@@ -1335,8 +1349,9 @@ static int update_pw_dialogs(
1335 1349
 
1336 1350
 	LM_DBG("start\n");
1337 1351
 
1338
-	if(subs_dbmode == DB_ONLY)
1352
+	if(pres_subs_dbmode == DB_ONLY) {
1339 1353
 		return (update_pw_dialogs_dbonlymode(subs, subs_array));
1354
+	}
1340 1355
 
1341 1356
 	lock_get(&subs_htable[hash_code].lock);
1342 1357
 
... ...
@@ -67,21 +67,21 @@ extern str presentity_table;
67 67
 extern str active_watchers_table;
68 68
 extern str watchers_table;
69 69
 
70
-extern int counter;
71
-extern int pid;
72
-extern int startup_time;
73
-extern char *to_tag_pref;
74
-extern int expires_offset;
70
+extern int pres_counter;
71
+extern int pres_pid;
72
+extern int pres_startup_time;
73
+extern char *pres_totag_pref;
74
+extern int pres_expires_offset;
75 75
 extern int pres_cseq_offset;
76
-extern str server_address;
77
-extern uint32_t min_expires;
78
-extern int min_expires_action;
79
-extern uint32_t max_expires;
80
-extern int subs_dbmode;
76
+extern str pres_server_address;
77
+extern uint32_t pres_min_expires;
78
+extern int pres_min_expires_action;
79
+extern uint32_t pres_max_expires;
80
+extern int pres_subs_dbmode;
81 81
 extern int publ_cache_enabled;
82
-extern int sphere_enable;
83
-extern int timeout_rm_subs;
84
-extern int send_fast_notify;
82
+extern int pres_sphere_enable;
83
+extern int pres_timeout_rm_subs;
84
+extern int pres_send_fast_notify;
85 85
 extern int shtable_size;
86 86
 extern shtable_t subs_htable;
87 87
 
... ...
@@ -102,7 +102,7 @@ extern phtable_t *pres_htable;
102 102
 
103 103
 extern sruid_t pres_sruid;
104 104
 
105
-extern db_locking_t db_table_lock;
105
+extern db_locking_t pres_db_table_lock;
106 106
 
107 107
 int update_watchers_status(str pres_uri, pres_ev_t *ev, str *rules_doc);
108 108
 int pres_auth_status(struct sip_msg *msg, str watcher_uri, str presentity_uri);
... ...
@@ -69,8 +69,8 @@ char *generate_ETag(int publ_count)
69 69
 		ERR_MEM(PKG_MEM_STR);
70 70
 	}
71 71
 	memset(etag, 0, ETAG_LEN * sizeof(char));
72
-	size = snprintf(etag, ETAG_LEN, "%c.%d.%d.%d.%d", prefix, startup_time, pid,
73
-			counter, publ_count);
72
+	size = snprintf(etag, ETAG_LEN, "%c.%d.%d.%d.%d", pres_prefix,
73
+			pres_startup_time, pres_pid, pres_counter, publ_count);
74 74
 	if(size < 0) {
75 75
 		LM_ERR("unsuccessful snprintf\n ");
76 76
 		pkg_free(etag);
... ...
@@ -105,7 +105,7 @@ int publ_send200ok(struct sip_msg *msg, int lexpire, str etag)
105 105
 	hdr_append.s = buf;
106 106
 	hdr_append.s[0] = '\0';
107 107
 	hdr_append.len = snprintf(hdr_append.s, buf_len, "Expires: %d\r\n",
108
-			((lexpire == 0) ? 0 : (lexpire - expires_offset)));
108
+			((lexpire == 0) ? 0 : (lexpire - pres_expires_offset)));
109 109
 	if(hdr_append.len < 0) {
110 110
 		LM_ERR("unsuccessful snprintf\n");
111 111
 		goto error;
... ...
@@ -703,7 +703,7 @@ int update_presentity(struct sip_msg *msg, presentity_t *presentity, str *body,
703 703
 			}
704 704
 
705 705
 			if(pa_dbf.start_transaction) {
706
-				if(pa_dbf.start_transaction(pa_db, db_table_lock) < 0) {
706
+				if(pa_dbf.start_transaction(pa_db, pres_db_table_lock) < 0) {
707 707
 					LM_ERR("in start_transaction\n");
708 708
 					goto error;
709 709
 				}
... ...
@@ -752,7 +752,7 @@ int update_presentity(struct sip_msg *msg, presentity_t *presentity, str *body,
752 752
 			}
753 753
 
754 754
 			if(pa_dbf.start_transaction) {
755
-				if(pa_dbf.start_transaction(pa_db, db_table_lock) < 0) {
755
+				if(pa_dbf.start_transaction(pa_db, pres_db_table_lock) < 0) {
756 756
 					LM_ERR("in start_transaction\n");
757 757
 					goto error;
758 758
 				}
... ...
@@ -796,7 +796,7 @@ int update_presentity(struct sip_msg *msg, presentity_t *presentity, str *body,
796 796
 		}
797 797
 
798 798
 		if(pa_dbf.start_transaction) {
799
-			if(pa_dbf.start_transaction(pa_db, db_table_lock) < 0) {
799
+			if(pa_dbf.start_transaction(pa_db, pres_db_table_lock) < 0) {
800 800
 				LM_ERR("in start_transaction\n");
801 801
 				goto error;
802 802
 			}
... ...
@@ -1100,7 +1100,7 @@ int update_presentity(struct sip_msg *msg, presentity_t *presentity, str *body,
1100 1100
 			n_update_cols++;
1101 1101
 
1102 1102
 			/* updated stored sphere */
1103
-			if(sphere_enable
1103
+			if(pres_sphere_enable
1104 1104
 					&& presentity->event->evp->type == EVENT_PRESENCE) {
1105 1105
 				if(publ_cache_enabled
1106 1106
 						&& update_phtable(presentity, pres_uri, *body) < 0) {
... ...
@@ -1315,8 +1315,9 @@ int pres_htable_restore(void)
1315 1315
 	result_cols[domain_col = n_result_cols++] = &str_domain_col;
1316 1316
 	result_cols[event_col = n_result_cols++] = &str_event_col;
1317 1317
 	result_cols[expires_col = n_result_cols++] = &str_expires_col;
1318
-	if(sphere_enable)
1318
+	if(pres_sphere_enable) {
1319 1319
 		result_cols[body_col = n_result_cols++] = &str_body_col;
1320
+	}
1320 1321
 
1321 1322
 	if(pa_dbf.use_table(pa_db, &presentity_table) < 0) {
1322 1323
 		LM_ERR("unsuccessful use table sql operation\n");
... ...
@@ -1370,7 +1371,7 @@ int pres_htable_restore(void)
1370 1371
 			}
1371 1372
 			/* insert in hash_table*/
1372 1373
 
1373
-			if(sphere_enable && event == EVENT_PRESENCE) {
1374
+			if(pres_sphere_enable && event == EVENT_PRESENCE) {
1374 1375
 				body.s = (char *)row_vals[body_col].val.string_val;
1375 1376
 				body.len = strlen(body.s);
1376 1377
 				sphere = extract_sphere(body);
... ...
@@ -1483,8 +1484,9 @@ char *get_sphere(str *pres_uri)
1483 1484
 	static str query_str;
1484 1485
 
1485 1486
 
1486
-	if(!sphere_enable)
1487
+	if(!pres_sphere_enable) {
1487 1488
 		return NULL;
1489
+	}
1488 1490
 
1489 1491
 	if(publ_cache_enabled) {
1490 1492
 		/* search in hash table*/
... ...
@@ -1869,7 +1871,7 @@ int _api_update_presentity(str *event, str *realm, str *user, str *etag,
1869 1871
 
1870 1872
 	pres = new_presentity(realm, user, expires, ev, etag, sender);
1871 1873
 
1872
-	if(sphere_enable) {
1874
+	if(pres_sphere_enable) {
1873 1875
 		sphere = extract_sphere(*body);
1874 1876
 	}
1875 1877
 	if(pres) {
... ...
@@ -33,7 +33,7 @@
33 33
 #include "../../core/parser/msg_parser.h"
34 34
 #include "event_list.h"
35 35
 
36
-extern char prefix;
36
+extern char pres_prefix;
37 37
 
38 38
 typedef struct presentity
39 39
 {
... ...
@@ -156,7 +156,7 @@ void msg_presentity_clean(unsigned int ticks, void *param)
156 156
 				}
157 157
 			} else if(pres_notifier_processes > 0) {
158 158
 				if(pa_dbf.start_transaction) {
159
-					if(pa_dbf.start_transaction(pa_db, db_table_lock) < 0) {
159
+					if(pa_dbf.start_transaction(pa_db, pres_db_table_lock) < 0) {
160 160
 						LM_ERR("in start_transaction\n");
161 161
 						goto error;
162 162
 					}
... ...
@@ -274,7 +274,7 @@ int ki_handle_publish_uri(struct sip_msg *msg, str *sender_uri)
274 274
 	reply_code = 500;
275 275
 	reply_str = pu_500_rpl;
276 276
 
277
-	counter++;
277
+	pres_counter++;
278 278
 	if(parse_headers(msg, HDR_EOH_F, 0) == -1) {
279 279
 		LM_ERR("parsing headers\n");
280 280
 		reply_code = 400;
... ...
@@ -345,8 +345,9 @@ int ki_handle_publish_uri(struct sip_msg *msg, str *sender_uri)
345 345
 		LM_DBG("'expires' not found; default=%d\n", event->default_expires);
346 346
 		lexpire = event->default_expires;
347 347
 	}
348
-	if(lexpire > max_expires)
349
-		lexpire = max_expires;
348
+	if(lexpire > pres_max_expires) {
349
+		lexpire = pres_max_expires;
350
+	}
350 351
 
351 352
 	/* get pres_uri from Request-URI*/
352 353
 	if(parse_sip_msg_uri(msg) < 0) {
... ...
@@ -384,7 +385,7 @@ int ki_handle_publish_uri(struct sip_msg *msg, str *sender_uri)
384 385
 		}
385 386
 		body.len = get_content_length(msg);
386 387
 
387
-		if(sphere_enable && event->evp->type == EVENT_PRESENCE
388
+		if(pres_sphere_enable && event->evp->type == EVENT_PRESENCE
388 389
 				&& get_content_type(msg) == SUBTYPE_PIDFXML) {
389 390
 			sphere = extract_sphere(body);
390 391
 		}
... ...
@@ -536,8 +537,9 @@ int update_hard_presentity(
536 537
 		LM_DBG("INSERT/REPLACE\n");
537 538
 		xmlDocPtr doc;
538 539
 
539
-		if(sphere_enable)
540
+		if(pres_sphere_enable) {
540 541
 			sphere = extract_sphere(*pidf_doc);
542
+		}
541 543
 
542 544
 		doc = xmlParseMemory(pidf_doc->s, pidf_doc->len);
543 545
 		if(doc == NULL) {
... ...
@@ -478,7 +478,7 @@ void delete_subs(
478 478
 	subs.callid = *callid;
479 479
 
480 480
 	/* delete record from hash table also if not in dbonly mode */
481
-	if(subs_dbmode != DB_ONLY) {
481
+	if(pres_subs_dbmode != DB_ONLY) {
482 482
 		unsigned int hash_code =
483 483
 				core_case_hash(pres_uri, ev_name, shtable_size);
484 484
 		if(delete_shtable(subs_htable, hash_code, &subs) < 0) {
... ...
@@ -490,7 +490,7 @@ void delete_subs(
490 490
 		}
491 491
 	}
492 492
 
493
-	if(subs_dbmode != NO_DB && delete_db_subs(to_tag, from_tag, callid) < 0)
493
+	if(pres_subs_dbmode != NO_DB && delete_db_subs(to_tag, from_tag, callid) < 0)
494 494
 		LM_ERR("Failed to delete subscription from database\n");
495 495
 }
496 496
 
... ...
@@ -605,7 +605,7 @@ int update_subscription(
605 605
 			return 1;
606 606
 		}
607 607
 		/* if subscriptions are stored in memory, update them */
608
-		if(subs_dbmode != DB_ONLY) {
608
+		if(pres_subs_dbmode != DB_ONLY) {
609 609
 			hash_code = core_case_hash(
610 610
 					&subs->pres_uri, &subs->event->name, shtable_size);
611 611
 			if(update_shtable(subs_htable, hash_code, subs, REMOTE_TYPE) < 0) {
... ...
@@ -614,7 +614,7 @@ int update_subscription(
614 614
 			}
615 615
 		}
616 616
 		/* for modes that update the subscription synchronously in database, write in db */
617
-		if(subs_dbmode == DB_ONLY || subs_dbmode == WRITE_THROUGH) {
617
+		if(pres_subs_dbmode == DB_ONLY || pres_subs_dbmode == WRITE_THROUGH) {
618 618
 			/* update in database table */
619 619
 			if(update_subs_db(subs, REMOTE_TYPE | LOCAL_TYPE) < 0) {
620 620
 				LM_ERR("updating subscription in database table\n");
... ...
@@ -624,9 +624,9 @@ int update_subscription(
624 624
 	} else {
625 625
 		LM_DBG("subscription not in dialog\n");
626 626
 		if(subs->expires != 0) {
627
-			if(subs_dbmode != DB_ONLY) {
627
+			if(pres_subs_dbmode != DB_ONLY) {
628 628
 				LM_DBG("inserting in shtable\n");
629
-				subs->db_flag = (subs_dbmode == WRITE_THROUGH) ? WTHROUGHDB_FLAG
629
+				subs->db_flag = (pres_subs_dbmode == WRITE_THROUGH) ? WTHROUGHDB_FLAG
630 630
 															   : INSERTDB_FLAG;
631 631
 				hash_code = core_case_hash(
632 632
 						&subs->pres_uri, &subs->event->name, shtable_size);
... ...
@@ -637,7 +637,7 @@ int update_subscription(
637 637
 				}
638 638
 			}
639 639
 
640
-			if(subs_dbmode == DB_ONLY || subs_dbmode == WRITE_THROUGH) {
640
+			if(pres_subs_dbmode == DB_ONLY || pres_subs_dbmode == WRITE_THROUGH) {
641 641
 				subs->version = 1;
642 642
 				if(insert_subs_db(subs, REMOTE_TYPE) < 0) {
643 643
 					LM_ERR("failed to insert new record in database\n");
... ...
@@ -676,7 +676,7 @@ int update_subscription(
676 676
 				}
677 677
 			}
678 678
 		} else {
679
-			if(send_fast_notify && (notify(subs, NULL, NULL, 0, 0) < 0)) {
679
+			if(pres_send_fast_notify && (notify(subs, NULL, NULL, 0, 0) < 0)) {
680 680
 				LM_ERR("Could not send notify\n");
681 681
 				goto error;
682 682
 			}
... ...
@@ -689,7 +689,7 @@ int update_subscription(
689 689
 		}
690 690
 		*sent_reply = 1;
691 691
 
692
-		if(send_fast_notify && (notify(subs, NULL, NULL, 0, 0) < 0)) {
692
+		if(pres_send_fast_notify && (notify(subs, NULL, NULL, 0, 0) < 0)) {
693 693
 			LM_ERR("sending notify request\n");
694 694
 			goto error;
695 695
 		}
... ...
@@ -1044,8 +1044,7 @@ int handle_subscribe(struct sip_msg *msg, str watcher_user, str watcher_domain)
1044 1044
 		}
1045 1045
 	}
1046 1046
 
1047
-	/* ??? rename to avoid collisions with other symbols */
1048
-	counter++;
1047
+	pres_counter++;
1049 1048
 
1050 1049
 	memset(&subs, 0, sizeof(subs_t));
1051 1050
 
... ...
@@ -1087,20 +1086,20 @@ int handle_subscribe(struct sip_msg *msg, str watcher_user, str watcher_domain)
1087 1086
 		ev_param = ev_param->next;
1088 1087
 	}
1089 1088
 
1090
-	if(extract_sdialog_info_ex(&subs, msg, min_expires, max_expires,
1091
-			   &to_tag_gen, server_address, watcher_user, watcher_domain,
1089
+	if(extract_sdialog_info_ex(&subs, msg, pres_min_expires, pres_max_expires,
1090
+			   &to_tag_gen, pres_server_address, watcher_user, watcher_domain,
1092 1091
 			   &reply_code, &reply_str)
1093 1092
 			< 0) {
1094 1093
 		goto error;
1095 1094
 	}
1096 1095
 
1097
-	if(pres_notifier_processes > 0 && !send_fast_notify
1096
+	if(pres_notifier_processes > 0 && !pres_send_fast_notify
1098 1097
 			&& pa_dbf.start_transaction) {
1099 1098
 		if(pa_dbf.use_table(pa_db, &active_watchers_table) < 0) {
1100 1099
 			LM_ERR("unsuccessful use_table sql operation\n");
1101 1100
 			goto error;
1102 1101
 		}
1103
-		if(pa_dbf.start_transaction(pa_db, db_table_lock) < 0) {
1102
+		if(pa_dbf.start_transaction(pa_db, pres_db_table_lock) < 0) {
1104 1103
 			LM_ERR("in start_transaction\n");
1105 1104
 			goto error;
1106 1105
 		}
... ...
@@ -1203,7 +1202,7 @@ int handle_subscribe(struct sip_msg *msg, str watcher_user, str watcher_domain)
1203 1202
 	LM_DBG("subscription status= %s - %s\n", get_status_str(subs.status),
1204 1203
 			(found == 0) ? "inserted" : "found in watcher table");
1205 1204
 
1206
-	if(pres_notifier_processes > 0 && !send_fast_notify) {
1205
+	if(pres_notifier_processes > 0 && !pres_send_fast_notify) {
1207 1206
 		if(update_subscription_notifier(msg, &subs, to_tag_gen, &sent_reply)
1208 1207
 				< 0) {
1209 1208
 			LM_ERR("in update_subscription_notifier\n");
... ...
@@ -1214,7 +1213,7 @@ int handle_subscribe(struct sip_msg *msg, str watcher_user, str watcher_domain)
1214 1213
 		goto error;
1215 1214
 	}
1216 1215
 
1217
-	if(pres_notifier_processes > 0 && !send_fast_notify
1216
+	if(pres_notifier_processes > 0 && !pres_send_fast_notify
1218 1217
 			&& pa_dbf.end_transaction) {
1219 1218
 		if(pa_dbf.end_transaction(pa_db) < 0) {
1220 1219
 			LM_ERR("in end_transaction\n");
... ...
@@ -1232,7 +1231,7 @@ int handle_subscribe(struct sip_msg *msg, str watcher_user, str watcher_domain)
1232 1231
 	if(subs.pres_uri.s)
1233 1232
 		pkg_free(subs.pres_uri.s);
1234 1233
 
1235
-	if((!server_address.s) || (server_address.len == 0)) {
1234
+	if((!pres_server_address.s) || (pres_server_address.len == 0)) {
1236 1235
 		pkg_free(subs.local_contact.s);
1237 1236
 	}
1238 1237
 	if(subs.record_route.s)
... ...
@@ -1270,7 +1269,7 @@ error:
1270 1269
 	if(reason.s)
1271 1270
 		pkg_free(reason.s);
1272 1271
 
1273
-	if(((!server_address.s) || (server_address.len == 0))
1272
+	if(((!pres_server_address.s) || (pres_server_address.len == 0))
1274 1273
 			&& subs.local_contact.s) {
1275 1274
 		pkg_free(subs.local_contact.s);
1276 1275
 	}
... ...
@@ -1315,7 +1314,7 @@ int extract_sdialog_info_ex(subs_t *subs, struct sip_msg *msg, uint32_t miexp,
1315 1314
 		lexpire = mexp;
1316 1315
 
1317 1316
 	if(lexpire && miexp && lexpire < miexp) {
1318
-		if(min_expires_action == 1) {
1317
+		if(pres_min_expires_action == 1) {
1319 1318
 			LM_DBG("subscription expiration invalid , requested=%u, minimum=%u,"
1320 1319
 				   " returning error \"423 Interval Too brief\"\n",
1321 1320
 					lexpire, miexp);
... ...
@@ -1512,7 +1511,7 @@ int extract_sdialog_info(subs_t *subs, struct sip_msg *msg, int mexp,
1512 1511
 {
1513 1512
 	int reply_code = 500;
1514 1513
 	str reply_str = pu_500_rpl;
1515
-	return extract_sdialog_info_ex(subs, msg, min_expires, mexp, to_tag_gen,
1514
+	return extract_sdialog_info_ex(subs, msg, pres_min_expires, mexp, to_tag_gen,
1516 1515
 			scontact, watcher_user, watcher_domain, &reply_code, &reply_str);
1517 1516
 }
1518 1517
 
... ...
@@ -1524,8 +1523,9 @@ int get_stored_info(
1524 1523
 	int i;
1525 1524
 	unsigned int hash_code;
1526 1525
 
1527
-	if(subs_dbmode == DB_ONLY)
1526
+	if(pres_subs_dbmode == DB_ONLY) {
1528 1527
 		return get_database_info(msg, subs, reply_code, reply_str);
1528
+	}
1529 1529
 
1530 1530
 	/* first try to_user== pres_user and to_domain== pres_domain */
1531 1531
 	if(subs->pres_uri.s == NULL) {
... ...
@@ -1836,7 +1836,7 @@ void update_db_subs_timer_notifier(void)
1836 1836
 	query_cols[n_query_cols] = &str_expires_col;
1837 1837
 	query_vals[n_query_cols].type = DB1_INT;
1838 1838
 	query_vals[n_query_cols].nul = 0;
1839
-	query_vals[n_query_cols].val.int_val = (int)time(NULL) - expires_offset;
1839
+	query_vals[n_query_cols].val.int_val = (int)time(NULL) - pres_expires_offset;
1840 1840
 	query_ops[n_query_cols] = OP_LT;
1841 1841
 	n_query_cols++;
1842 1842
 
... ...
@@ -1852,7 +1852,7 @@ void update_db_subs_timer_notifier(void)
1852 1852
 	result_cols[r_from_tag_col = n_result_cols++] = &str_from_tag_col;
1853 1853
 
1854 1854
 	if(pa_dbf.start_transaction) {
1855
-		if(pa_dbf.start_transaction(pa_db, db_table_lock) < 0) {
1855
+		if(pa_dbf.start_transaction(pa_db, pres_db_table_lock) < 0) {
1856 1856
 			LM_ERR("in start_transaction\n");
1857 1857
 			goto error;
1858 1858
 		}
... ...
@@ -1936,7 +1936,7 @@ void update_db_subs_timer_dbonly(void)
1936 1936
 	qcols[0] = &str_expires_col;
1937 1937
 	qvals[0].type = DB1_INT;
1938 1938
 	qvals[0].nul = 0;
1939
-	qvals[0].val.int_val = (int)time(NULL) - expires_offset;
1939
+	qvals[0].val.int_val = (int)time(NULL) - pres_expires_offset;
1940 1940
 	qops[0] = OP_LT;
1941 1941
 
1942 1942
 	/* query the expired subscriptions */
... ...
@@ -2083,7 +2083,7 @@ void update_db_subs_timer_dbnone(int no_lock)
2083 2083
 
2084 2084
 		while(s) {
2085 2085
 			printf_subs(s);
2086
-			if(s->expires < now - expires_offset) {
2086
+			if(s->expires < now - pres_expires_offset) {
2087 2087
 				LM_DBG("Found expired record\n");
2088 2088
 				if(!no_lock) {
2089 2089
 					if(handle_expired_subs(s) < 0) {
... ...
@@ -2308,7 +2308,7 @@ void update_db_subs_timer(db1_con_t *db, db_func_t *dbf, shtable_t hash_table,
2308 2308
 
2309 2309
 		while(s) {
2310 2310
 			printf_subs(s);
2311
-			if(s->expires < now - expires_offset) {
2311
+			if(s->expires < now - pres_expires_offset) {
2312 2312
 				LM_DBG("Found expired record\n");
2313 2313
 				if(!no_lock) {
2314 2314
 					if(handle_expired_func(s) < 0)
... ...
@@ -2408,7 +2408,7 @@ void update_db_subs_timer(db1_con_t *db, db_func_t *dbf, shtable_t hash_table,
2408 2408
 			lock_release(&hash_table[i].lock);
2409 2409
 	}
2410 2410
 
2411
-	update_vals[0].val.int_val = (int)time(NULL) - expires_offset;
2411
+	update_vals[0].val.int_val = (int)time(NULL) - pres_expires_offset;
2412 2412
 	update_ops[0] = OP_LT;
2413 2413
 	if(dbf->delete(db, update_cols, update_ops, update_vals, 1) < 0) {
2414 2414
 		LM_ERR("deleting expired information from database\n");
... ...
@@ -2430,7 +2430,7 @@ void timer_db_update(unsigned int ticks, void *param)
2430 2430
 		no_lock = 1;
2431 2431
 
2432 2432
 
2433
-	switch(subs_dbmode) {
2433
+	switch(pres_subs_dbmode) {
2434 2434
 		case DB_ONLY:
2435 2435
 			if(pres_notifier_processes > 0)
2436 2436
 				update_db_subs_timer_notifier();
... ...
@@ -2597,8 +2597,8 @@ int restore_db_subs(void)
2597 2597
 					free_event_params(parsed_event.params.list, PKG_MEM_TYPE);
2598 2598
 					goto error;
2599 2599
 				}
2600
-				event->next = EvList->events;
2601
-				EvList->events = event;
2600
+				event->next = pres_evlist->events;
2601
+				pres_evlist->events = event;
2602 2602
 			}
2603 2603
 
2604 2604
 			free_event_params(parsed_event.params.list, PKG_MEM_TYPE);
... ...
@@ -2634,7 +2634,7 @@ int restore_db_subs(void)
2634 2634
 
2635 2635
 			s.sockinfo_str.s = (char *)row_vals[sockinfo_col].val.string_val;
2636 2636
 			s.sockinfo_str.len = strlen(s.sockinfo_str.s);
2637
-			s.db_flag = (subs_dbmode == WRITE_THROUGH) ? WTHROUGHDB_FLAG
2637
+			s.db_flag = (pres_subs_dbmode == WRITE_THROUGH) ? WTHROUGHDB_FLAG
2638 2638
 													   : NO_UPDATEDB_FLAG;
2639 2639
 			hash_code =
2640 2640
 					core_case_hash(&s.pres_uri, &s.event->name, shtable_size);
... ...
@@ -2650,7 +2650,7 @@ int restore_db_subs(void)
2650 2650
 	pa_dbf.free_result(pa_db, result);
2651 2651
 
2652 2652
 	/* delete all records  only if in memory mode */
2653
-	if(subs_dbmode == NO_DB) {
2653
+	if(pres_subs_dbmode == NO_DB) {
2654 2654
 		if(pa_dbf.delete(pa_db, 0, 0, 0, 0) < 0) {
2655 2655
 			LM_ERR("deleting all records from database table\n");
2656 2656
 			return -1;
... ...
@@ -2894,7 +2894,7 @@ int get_subscribers_count_from_db(struct sip_msg *msg, str pres_uri, str event)
2894 2894
 
2895 2895
 int get_subscribers_count(struct sip_msg *msg, str pres_uri, str event)
2896 2896
 {
2897
-	if(subs_dbmode == DB_ONLY) {
2897
+	if(pres_subs_dbmode == DB_ONLY) {
2898 2898
 		return get_subscribers_count_from_db(msg, pres_uri, event);
2899 2899
 	} else {
2900 2900
 		return get_subscribers_count_from_mem(msg, pres_uri, event);
... ...
@@ -84,7 +84,7 @@ int send_error_reply(struct sip_msg *msg, int reply_code, str reply_str)
84 84
 	str hdr_append;
85 85
 	char buffer[256];
86 86
 	int i;
87
-	pres_ev_t *ev = EvList->events;
87
+	pres_ev_t *ev = pres_evlist->events;
88 88
 
89 89
 	if(reply_code == BAD_EVENT_CODE) {
90 90
 		hdr_append.s = buffer;
... ...
@@ -95,7 +95,7 @@ int send_error_reply(struct sip_msg *msg, int reply_code, str reply_str)
95 95
 			return -1;
96 96
 		}
97 97
 
98
-		for(i = 0; i < EvList->ev_count; i++) {
98
+		for(i = 0; i < pres_evlist->ev_count; i++) {
99 99
 			if(i > 0) {
100 100
 				memcpy(hdr_append.s + hdr_append.len, ", ", 2);
101 101
 				hdr_append.len += 2;
... ...
@@ -116,7 +116,7 @@ int send_error_reply(struct sip_msg *msg, int reply_code, str reply_str)
116 116
 
117 117
 		hdr_append.s = buffer;
118 118
 		hdr_append.s[0] = '\0';
119
-		hdr_append.len = sprintf(hdr_append.s, "Min-Expires: %d", min_expires);
119
+		hdr_append.len = sprintf(hdr_append.s, "Min-Expires: %d", pres_min_expires);
120 120
 		if(hdr_append.len < 0) {
121 121
 			LM_ERR("unsuccessful sprintf\n");
122 122
 			return -1;