summaryrefslogtreecommitdiff
path: root/lib/ldb/common/attrib_handlers.c
diff options
context:
space:
mode:
authorMatthieu Patou <mat@matws.net>2012-05-17 23:57:55 -0700
committerMatthieu Patou <mat@matws.net>2012-06-22 23:22:03 -0700
commit1c850b2f173678b0df7a2619024baf2d94011a7b (patch)
tree0817beac84234110e08d3d0edca0052aa7a8a4de /lib/ldb/common/attrib_handlers.c
parent884d66d959e2eaa384bf9af6230ffb589a581b13 (diff)
downloadsamba-1c850b2f173678b0df7a2619024baf2d94011a7b.tar.gz
samba-1c850b2f173678b0df7a2619024baf2d94011a7b.tar.bz2
samba-1c850b2f173678b0df7a2619024baf2d94011a7b.zip
ldb: lay foundation for proper utc/generalized time handling
We use to handle UTCtime and generalized time the same way. The thing is that it's not the case, they are different in the way they are set (most of the time) with different format and also stored and return in different format too.
Diffstat (limited to 'lib/ldb/common/attrib_handlers.c')
-rw-r--r--lib/ldb/common/attrib_handlers.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/ldb/common/attrib_handlers.c b/lib/ldb/common/attrib_handlers.c
index 73e1705593..daeb422aca 100644
--- a/lib/ldb/common/attrib_handlers.c
+++ b/lib/ldb/common/attrib_handlers.c
@@ -387,6 +387,27 @@ static int ldb_canonicalise_utctime(struct ldb_context *ldb, void *mem_ctx,
if (ret != LDB_SUCCESS) {
return ret;
}
+ out->data = (uint8_t *)ldb_timestring_utc(mem_ctx, t);
+ if (out->data == NULL) {
+ ldb_oom(ldb);
+ return LDB_ERR_OPERATIONS_ERROR;
+ }
+ out->length = strlen((char *)out->data);
+ return 0;
+}
+
+/*
+ canonicalise a generalized time
+*/
+static int ldb_canonicalise_generalizedtime(struct ldb_context *ldb, void *mem_ctx,
+ const struct ldb_val *in, struct ldb_val *out)
+{
+ time_t t;
+ int ret;
+ ret = ldb_val_to_time(in, &t);
+ if (ret != LDB_SUCCESS) {
+ return ret;
+ }
out->data = (uint8_t *)ldb_timestring(mem_ctx, t);
if (out->data == NULL) {
ldb_oom(ldb);
@@ -443,6 +464,13 @@ static const struct ldb_schema_syntax ldb_standard_syntaxes[] = {
.comparison_fn = ldb_comparison_utctime
},
{
+ .name = LDB_SYNTAX_GENERALIZED_TIME,
+ .ldif_read_fn = ldb_handler_copy,
+ .ldif_write_fn = ldb_handler_copy,
+ .canonicalise_fn = ldb_canonicalise_generalizedtime,
+ .comparison_fn = ldb_comparison_utctime
+ },
+ {
.name = LDB_SYNTAX_BOOLEAN,
.ldif_read_fn = ldb_handler_copy,
.ldif_write_fn = ldb_handler_copy,