return 0;
return 1;
}
+
+/* Init uuid set */
+void
+uuid_set_init( tvh_uuid_set_t *us, uint32_t alloc_chunk )
+{
+ memset(us, 0, sizeof(*us));
+ us->us_alloc_chunk = alloc_chunk ?: 10;
+}
+
+/* Add an uuid to set */
+tvh_uuid_t *
+uuid_set_add ( tvh_uuid_set_t *us, const tvh_uuid_t *u )
+{
+ tvh_uuid_t *nu;
+
+ if (us->us_count >= us->us_size) {
+ nu = realloc(us->us_array, sizeof(*u) * (us->us_size + us->us_alloc_chunk));
+ if (nu == NULL)
+ return NULL;
+ us->us_size += us->us_alloc_chunk;
+ }
+ nu = &us->us_array[us->us_count++];
+ *nu = *u;
+ return nu;
+}
+
+/* Free uuid set */
+void
+uuid_set_free ( tvh_uuid_set_t *us )
+{
+ if (us) {
+ free(us->us_array);
+ }
+}
+
+/* Destroy uuid set */
+void
+uuid_set_destroy ( tvh_uuid_set_t *us )
+{
+ if (us) {
+ uuid_set_free(us);
+ free(us);
+ }
+}
uint8_t bin[UUID_BIN_SIZE];
} tvh_uuid_t;
+/* Structure for the uuid set */
+typedef struct uuid_set {
+ tvh_uuid_t *us_array;
+ uint32_t us_count;
+ uint32_t us_size;
+ uint32_t us_alloc_chunk;
+} tvh_uuid_set_t;
+
/* Initialise subsystem */
void uuid_init ( void );
*/
int uuid_hexvalid ( const char *uuid );
+/**
+ *
+ */
+void uuid_set_init( tvh_uuid_set_t *us, uint32_t alloc_chunk );
+
+/**
+ *
+ */
+tvh_uuid_t *uuid_set_add( tvh_uuid_set_t *us, const tvh_uuid_t *u );
+
+/**
+ *
+ */
+void uuid_set_free( tvh_uuid_set_t *us );
+
+/**
+ *
+ */
+void uuid_set_destroy( tvh_uuid_set_t *us );
+
+/**
+ *
+ */
+static inline int uuid_set_empty( tvh_uuid_set_t *us )
+ { return us->us_count == 0; }
+
+/**
+ *
+ */
+#define UUID_SET_FOREACH(u, us, u32) \
+ if ((us)->us_count > 0) \
+ for ((u32) = 0, (u) = (us)->us_array; \
+ (u32) < (us)->us_count; (u32)++, (u)++)
+
/**
* Hex string to binary
*/