-LRN: initialize rd to avoid having garbage in flags
[oweals/gnunet.git] / src / namestore / namestore_common.c
index 5698236c5d416a2b35f41456229030e82edcf08b..eead6e492d8136b274ccef5c797f7da8569520da 100644 (file)
@@ -172,8 +172,8 @@ GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
 {
   if ((a->record_type == b->record_type) &&
       (a->expiration_time == b->expiration_time) &&
-      ((a->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION
-       == (b->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION) ) &&
+      ((a->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS
+       == (b->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS) ) &&
       (a->data_size == b->data_size) &&
       (0 == memcmp (a->data, b->data, a->data_size)))
     return GNUNET_YES;
@@ -614,6 +614,22 @@ GNUNET_NAMESTORE_number_to_typename (uint32_t type)
   return name_map[i].name;  
 }
 
+/**
+ * Test if a given record is expired.
+ * 
+ * @return GNUNET_YES if the record is expired,
+ *         GNUNET_NO if not
+ */
+int
+GNUNET_NAMESTORE_is_expired (const struct GNUNET_NAMESTORE_RecordData *rd)
+{
+  struct GNUNET_TIME_Absolute at;
+
+  if (0 != (rd->flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION))
+    return GNUNET_NO;
+  at.abs_value = rd->expiration_time;
+  return (0 == GNUNET_TIME_absolute_get_remaining (at).rel_value) ? GNUNET_YES : GNUNET_NO;
+}
 
 
 /* end of namestore_common.c */