summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2005-02-12 11:33:42 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:09:45 -0500
commite199f4cef2bac3b244d08d445421975313229283 (patch)
treeacc368908e18aef24c8093cf7a28044e61754ee3 /source4/lib
parentff4797a9e4b01fe8cc9421e911371677433d070c (diff)
downloadsamba-e199f4cef2bac3b244d08d445421975313229283.tar.gz
samba-e199f4cef2bac3b244d08d445421975313229283.tar.bz2
samba-e199f4cef2bac3b244d08d445421975313229283.zip
r5358: - added initial WINS server code. It passes most of the NBT-WINS test, but doesn't yet
do secure server WACK responses - added a ldap_string_to_time() function, for converting a LDAP formatted time to a time_t (This used to be commit 9aa3313b3f93e47e3f93028e072f6a23b3c22385)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/time.c28
1 files changed, 25 insertions, 3 deletions
diff --git a/source4/lib/time.c b/source4/lib/time.c
index 7a4059f646..67397e953a 100644
--- a/source4/lib/time.c
+++ b/source4/lib/time.c
@@ -292,9 +292,9 @@ char *http_timestring(TALLOC_CTX *mem_ctx, time_t t)
return buf;
}
-/***************************************************************************
-return a LDAP time string
- ***************************************************************************/
+/*
+ return a LDAP time string
+*/
char *ldap_timestring(TALLOC_CTX *mem_ctx, time_t t)
{
struct tm *tm = gmtime(&t);
@@ -311,6 +311,28 @@ char *ldap_timestring(TALLOC_CTX *mem_ctx, time_t t)
tm->tm_sec);
}
+
+/*
+ convert a LDAP time string to a time_t. Return 0 if unable to convert
+*/
+time_t ldap_string_to_time(const char *s)
+{
+ struct tm tm;
+
+ if (s == NULL) return 0;
+
+ ZERO_STRUCT(tm);
+ if (sscanf(s, "%04u%02u%02u%02u%02u%02u.0Z",
+ &tm.tm_year, &tm.tm_mon, &tm.tm_mday,
+ &tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 6) {
+ return 0;
+ }
+ tm.tm_year -= 1900;
+ tm.tm_mon -= 1;
+
+ return timegm(&tm);
+}
+
/****************************************************************************
Return the date and time as a string
****************************************************************************/