Browse code

Merge 214f53c2052071c7a37ae8d009cba895eccea193 into 77bc4c6c96cfb2ce5b7086ccfffd19750b085d74

micmac1 authored on 27/10/2021 21:50:21 • GitHub committed on 27/10/2021 21:50:21
Showing 14 changed files
... ...
@@ -31,10 +31,18 @@
31 31
 #include <assert.h>
32 32
 #include <syslog.h>
33 33
 #include <stdio.h> /* stderr, fprintf() */
34
+#include <sys/time.h> /* __USE_TIME_BITS64 */
34 35
 
35 36
 #include "compiler_opt.h"
36 37
 #include "cfg_core.h"
37 38
 
39
+#ifndef TIME_T_INT_FMT
40
+#ifdef __USE_TIME_BITS64
41
+#define TIME_T_INT_FMT PRId64
42
+#else
43
+#define TIME_T_INT_FMT "ld"
44
+#endif
45
+#endif
38 46
 
39 47
 /** dicover the function name */
40 48
 /* C >= 99 has __func__, older gcc versions have __FUNCTION__ */
... ...
@@ -591,7 +591,7 @@ static int check_date(struct sip_msg* msg, char* srt1, char* str2)
591 591
 	}
592 592
 
593 593
 	if (tnow > tmsg + glb_iauthval) {
594
-		LOG(L_INFO, "AUTH_IDENTITY VERIFIER: Outdated date header value (%ld sec)\n", tnow - tmsg + glb_iauthval);
594
+		LOG(L_INFO, "AUTH_IDENTITY VERIFIER: Outdated date header value (%" TIME_T_INT_FMT " sec)\n", tnow - tmsg + glb_iauthval);
595 595
 		return -4;
596 596
 	} else
597 597
 		LOG(AUTH_DBG_LEVEL, "AUTH_IDENTITY VERIFIER: Date header value OK\n");
... ...
@@ -121,10 +121,10 @@ peer* get_first_connected_route(cdp_session_t* cdp_session, routing_entry *r, in
121 121
 	}
122 122
 
123 123
 	least_recent_time = peers[0]->last_selected;
124
-	LM_DBG("peer [%.*s] was last used @ %ld\n", peers[0]->fqdn.len, peers[0]->fqdn.s, peers[0]->last_selected);
124
+	LM_DBG("peer [%.*s] was last used @ %" TIME_T_INT_FMT "\n", peers[0]->fqdn.len, peers[0]->fqdn.s, peers[0]->last_selected);
125 125
 	p = peers[0];
126 126
 	for (j = 1; j < peer_count; j++) {
127
-		LM_DBG("Peer [%.*s] was last used at [%ld]\n", peers[j]->fqdn.len, peers[j]->fqdn.s, peers[j]->last_selected);
127
+		LM_DBG("Peer [%.*s] was last used at [%" TIME_T_INT_FMT "]\n", peers[j]->fqdn.len, peers[j]->fqdn.s, peers[j]->last_selected);
128 128
 		if (peers[j]->last_selected < least_recent_time) {
129 129
 			least_recent_time = peers[j]->last_selected;
130 130
 			p = peers[j];
... ...
@@ -142,7 +142,7 @@ static int db_redis_val2str(const db_val_t *v, str *_str) {
142 142
             _str->s[_str->len] = '\0';
143 143
             break;
144 144
         case DB1_DATETIME:
145
-            LM_DBG("converting datetime value %ld to str\n", VAL_TIME(v));
145
+            LM_DBG("converting datetime value %" TIME_T_INT_FMT " to str\n", VAL_TIME(v));
146 146
             _str->s = (char*)pkg_malloc(_str->len);
147 147
             if (!_str->s) goto memerr;
148 148
             localtime_r(&(VAL_TIME(v)), &_time);
... ...
@@ -857,7 +857,7 @@ void send_ccr_stop_with_param(struct ro_session *ro_session, unsigned int code,
857 857
         LM_DBG("Final used number of seconds for session is %ld\n", used);
858 858
     }
859 859
 
860
-    LM_DBG("Call started at %ld and ended at %ld and lasted %d seconds and so far we have billed for %ld seconds\n", ro_session->start_time, stop_time,
860
+    LM_DBG("Call started at %" TIME_T_INT_FMT " and ended at %" TIME_T_INT_FMT " and lasted %d seconds and so far we have billed for %ld seconds\n", ro_session->start_time, stop_time,
861 861
             actual_time_seconds, ro_session->billed + used);
862 862
     if (ro_session->billed + used < actual_time_seconds) {
863 863
         LM_DBG("Making adjustment by adding %ld seconds\n", actual_time_seconds - (ro_session->billed + used));
... ...
@@ -1867,7 +1867,7 @@ void internal_print_all_dlg(struct dlg_cell *dlg) {
1867 1867
 
1868 1868
     LM_DBG("----------------------------");
1869 1869
     LM_DBG("Dialog h_entry:h_id = [%u : %u]\n", dlg->h_entry, dlg->h_id);
1870
-	LM_DBG("Dialog age: %ld\n", act_time - dlg->init_ts);
1870
+	LM_DBG("Dialog age: %" TIME_T_INT_FMT "\n", act_time - dlg->init_ts);
1871 1871
     LM_DBG("Dialog call-id: %.*s\n", dlg->callid.len, dlg->callid.s);
1872 1872
     LM_DBG("Dialog state: %d\n", dlg->state);
1873 1873
     LM_DBG("Dialog ref counter: %d\n", dlg->ref);
... ...
@@ -586,7 +586,7 @@ void ims_icscf_timer_routine() {
586 586
             sl = l->list;
587 587
             while (sl) {
588 588
 
589
-                LM_DBG("INF: Score:[%4d] Start_time [%ld] S-CSCF: <%.*s> \n",
589
+                LM_DBG("INF: Score:[%4d] Start_time [%" TIME_T_INT_FMT "] S-CSCF: <%.*s> \n",
590 590
                         sl->score,
591 591
                         sl->start_time,
592 592
                         sl->scscf_name.len, sl->scscf_name.s);
... ...
@@ -594,7 +594,7 @@ void ims_icscf_timer_routine() {
594 594
                 time_t time_elapsed = now - sl->start_time;
595 595
                 if (time_elapsed > scscf_entry_expiry) {
596 596
 
597
-                    LM_DBG("Scscf entry expired: Time now %ld Start time %ld - elapsed %ld\n", now, sl->start_time, time_elapsed);
597
+                    LM_DBG("Scscf entry expired: Time now %" TIME_T_INT_FMT " Start time %" TIME_T_INT_FMT " - elapsed %" TIME_T_INT_FMT "\n", now, sl->start_time, time_elapsed);
598 598
                     delete_list = 1; //if any of the entries in this list have expired remove the whole list!
599 599
 
600 600
                 }
... ...
@@ -209,7 +209,7 @@ int process_contact(udomain_t * _d, int expires, str contact_uri, int contact_st
209 209
             /*TODO_LATEST - put this back */
210 210
         } else {//state is active
211 211
             //update this contact
212
-            LM_DBG("This contact: <%.*s> is in state active and is in usrloc so just updating - old expires: %li, new expires: %i which is in %i seconds\n", contact_uri.len, contact_uri.s,
212
+            LM_DBG("This contact: <%.*s> is in state active and is in usrloc so just updating - old expires: %" TIME_T_INT_FMT ", new expires: %i which is in %i seconds\n", contact_uri.len, contact_uri.s,
213 213
                     pcontact->expires,
214 214
                     expires,
215 215
                     expires - local_time_now);
... ...
@@ -223,7 +223,7 @@ static inline int update_contacts(struct sip_msg *req,struct sip_msg *rpl, udoma
223 223
 						}
224 224
                                                 //TODO_LATEST replace above
225 225
 					} else { //update contact
226
-						LM_DBG("Updating contact: <%.*s>, old expires: %li, new expires: %i which is in %i seconds\n", c->uri.len, c->uri.s,
226
+						LM_DBG("Updating contact: <%.*s>, old expires: %" TIME_T_INT_FMT ", new expires: %i which is in %i seconds\n", c->uri.len, c->uri.s,
227 227
 								pcontact->expires-local_time_now,
228 228
 								expires,
229 229
 								expires-local_time_now);
... ...
@@ -54,6 +54,7 @@
54 54
 #include "../../core/parser/parse_from.h"
55 55
 #include "../../core/parser/parse_content.h"
56 56
 #include "../../core/parser/parse_uri.h"
57
+#include "../../core/dprint.h" /* TIME_T_INT_FMT */
57 58
 #include <libxml/parser.h>
58 59
 
59 60
 #include "../../lib/ims/useful_defs.h"
... ...
@@ -1517,7 +1518,7 @@ void create_notifications(udomain_t* _t, impurecord_t* r_passed, ucontact_t* c_p
1517 1518
             subscription_state.len = 0;
1518 1519
             if (subscription_state.s) {
1519 1520
 
1520
-                sprintf(subscription_state.s, "%.*s%ld", subs_active.len,
1521
+                sprintf(subscription_state.s, "%.*s%" TIME_T_INT_FMT, subs_active.len,
1521 1522
                         subs_active.s, s->expires - act_time);
1522 1523
                 subscription_state.len = strlen(subscription_state.s);
1523 1524
             }
... ...
@@ -545,7 +545,7 @@ static inline int update_contacts_helper(struct sip_msg* msg, impurecord_t* impu
545 545
                         LM_DBG("Need to update contact: <%.*s>: "
546 546
                                 "q_value [%d],"
547 547
                                 "sos: [%d],"
548
-                                "expires [%ld]\n", chi->uri.len, chi->uri.s, qvalue, sos, expires - time(NULL));
548
+                                "expires [%" TIME_T_INT_FMT "]\n", chi->uri.len, chi->uri.s, qvalue, sos, expires - time(NULL));
549 549
 
550 550
                         LM_DBG("packing contact information\n");
551 551
                         if ((ci = pack_ci(msg, chi, expires, 0)) == 0) {
... ...
@@ -244,7 +244,7 @@ void print_impurecord(FILE* _f, impurecord_t* _r) {
244 244
             header = 1;
245 245
         }
246 246
         fprintf(_f, "\t\twatcher uri: <%.*s> and presentity uri: <%.*s>\n", subscriber->watcher_uri.len, subscriber->watcher_uri.s, subscriber->presentity_uri.len, subscriber->presentity_uri.s);
247
-        fprintf(_f, "\t\tExpires: %ld\n", subscriber->expires);
247
+        fprintf(_f, "\t\tExpires: %" TIME_T_INT_FMT "\n", subscriber->expires);
248 248
         subscriber = subscriber->next;
249 249
     }
250 250
 
... ...
@@ -405,7 +405,7 @@ static inline void process_impurecord(impurecord_t* _r) {
405 405
 				hascontacts = 1;
406 406
 			}
407 407
 		} else {
408
-			LM_DBG("\t\tContact #%i - %.*s, Ref [%d] (expires in %ld seconds) (State: %d)\n", 
408
+			LM_DBG("\t\tContact #%i - %.*s, Ref [%d] (expires in %" TIME_T_INT_FMT " seconds) (State: %d)\n",
409 409
 					k, ptr->c.len, ptr->c.s, ptr->ref_count, ptr->expires - act_time, ptr->state);
410 410
 			mustdeleteimpu = 0;
411 411
 			hascontacts = 1;
... ...
@@ -1724,7 +1724,7 @@ static void restore_keepalive_state(void)
1724 1724
 	res = fscanf(f, STATE_FILE_HEADER); // skip header
1725 1725
 
1726 1726
 	while(true) {
1727
-		res = fscanf(f, "%63s %63s %ld %ld", uri, socket, &rtime, &stime);
1727
+		res = fscanf(f, "%63s %63s %" TIME_T_INT_FMT " %" TIME_T_INT_FMT, uri, socket, &rtime, &stime);
1728 1728
 		if(res == EOF) {
1729 1729
 			if(ferror(f))
1730 1730
 				LM_ERR("error while reading keepalive state file: %s\n",
... ...
@@ -3186,7 +3186,7 @@ int ph_run_pi_cmd(pi_ctx_t* ctx)
3186 3186
 						val_str.len = max_page_len - ctx->reply.body.len;
3187 3187
 						if(db_time2str(values[j].val.time_val,
3188 3188
 									val_str.s, &val_str.len)!=0){
3189
-							LM_ERR("Unable to convert double [%ld]\n",
3189
+							LM_ERR("Unable to convert double [%" TIME_T_INT_FMT "]\n",
3190 3190
 								values[j].val.time_val);
3191 3191
 							goto error;
3192 3192
 						}
... ...
@@ -3194,7 +3194,7 @@ int ph_run_pi_cmd(pi_ctx_t* ctx)
3194 3194
 						ctx->reply.body.len += val_str.len;
3195 3195
 						if(link_on) XHTTP_PI_COPY_2(p,XHTTP_PI_SQUOT_GT,val_str);
3196 3196
 						LM_DBG("   got %.*s[%d]=>"
3197
-							"[%ld][%.*s]\n",
3197
+							"[%" TIME_T_INT_FMT "][%.*s]\n",
3198 3198
 							command->q_keys[j]->len,
3199 3199
 							command->q_keys[j]->s, i,
3200 3200
 							values[j].val.time_val,