Module: kamailio
Branch: master
Commit: 5283bf6288a6b86bdc405883d6995f03cc373256
URL: 
https://github.com/kamailio/kamailio/commit/5283bf6288a6b86bdc405883d6995f03cc373256

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2025-01-31T20:23:11+01:00

core: ut.h - function to split time_t in lower and upper 4 bytes

- lower 4 bytes are returned, upper 4 bytes can be stored in output
  parameter
- if pointer to time value is not give, time(0) is used

---

Modified: src/core/ut.h

---

Diff:  
https://github.com/kamailio/kamailio/commit/5283bf6288a6b86bdc405883d6995f03cc373256.diff
Patch: 
https://github.com/kamailio/kamailio/commit/5283bf6288a6b86bdc405883d6995f03cc373256.patch

---

diff --git a/src/core/ut.h b/src/core/ut.h
index 31b45fe5b4d..29faca83fc2 100644
--- a/src/core/ut.h
+++ b/src/core/ut.h
@@ -1155,6 +1155,27 @@ static inline int strno2int(str *val, unsigned int *mask)
        }
 }
 
+static inline unsigned int ksr_time_uint(time_t *tv, unsigned int *tu)
+{
+       unsigned int tl; /* lower 4 bytes */
+       unsigned long long v64;
+       time_t t;
+
+       if(tv != NULL) {
+               t = *tv;
+       } else {
+               t = time(NULL);
+       }
+       v64 = (unsigned long long)t;
+       tl = (unsigned int)(v64 & 0xFFFFFFFFULL);
+       if(tu != NULL) {
+               /* upper 4 bytes */
+               *tu = (unsigned int)((v64 >> 32) & 0xFFFFFFFFULL);
+       }
+
+       return tl;
+}
+
 /* converts a username into uid:gid,
  * returns -1 on error & 0 on success */
 int user2uid(int *uid, int *gid, char *user);

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to