Code

frontend: Added 'FILTER' support to the 'LOOKUP' command.
[sysdb.git] / src / frontend / connection-private.h
index 82cece90f00cdae17c59557f5f651979fb1c6013..1d4e019a01fe45db4d464c9bd387a2258d04b83d 100644 (file)
@@ -41,6 +41,8 @@
 #include <inttypes.h>
 #include <arpa/inet.h>
 
+#include <stdlib.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -62,6 +64,10 @@ struct sdb_conn {
        uint32_t cmd;
        uint32_t cmd_len;
 
+       /* amount of data to skip, e.g., after receiving invalid commands; if this
+        * is non-zero, the 'skip_len' first bytes of 'buf' are invalid */
+       size_t skip_len;
+
        sdb_strbuf_t *errbuf;
 
        /* user information */
@@ -73,11 +79,50 @@ struct sdb_conn {
  * node types
  */
 
+typedef struct {
+       sdb_conn_node_t super;
+       char *name;
+} conn_fetch_t;
+#define CONN_FETCH(obj) ((conn_fetch_t *)(obj))
+
 typedef struct {
        sdb_conn_node_t super;
        sdb_store_matcher_t *matcher;
-} conn_node_matcher_t;
-#define CONN_MATCHER(obj) ((conn_node_matcher_t *)(obj))
+} conn_matcher_t;
+#define CONN_MATCHER(obj) ((conn_matcher_t *)(obj))
+
+typedef struct {
+       sdb_conn_node_t super;
+       conn_matcher_t *matcher;
+       conn_matcher_t *filter;
+} conn_lookup_t;
+#define CONN_LOOKUP(obj) ((conn_lookup_t *)(obj))
+
+/*
+ * type helper functions
+ */
+static void __attribute__((unused))
+conn_fetch_destroy(sdb_object_t *obj)
+{
+       if (CONN_FETCH(obj)->name)
+               free(CONN_FETCH(obj)->name);
+} /* conn_fetch_destroy */
+
+static void __attribute__((unused))
+conn_matcher_destroy(sdb_object_t *obj)
+{
+       if (CONN_MATCHER(obj)->matcher)
+               sdb_object_deref(SDB_OBJ(CONN_MATCHER(obj)->matcher));
+} /* conn_matcher_destroy */
+
+static void __attribute__((unused))
+conn_lookup_destroy(sdb_object_t *obj)
+{
+       if (CONN_LOOKUP(obj)->matcher)
+               sdb_object_deref(SDB_OBJ(CONN_LOOKUP(obj)->matcher));
+       if (CONN_LOOKUP(obj)->filter)
+               sdb_object_deref(SDB_OBJ(CONN_LOOKUP(obj)->filter));
+} /* conn_lookup_destroy */
 
 #ifdef __cplusplus
 } /* extern "C" */