index 5748211f4c1d5c78f367eb1fc9672c825f757c2c..a5ea092c425d65f570af2b838f2febbdf9e64611 100644 (file)
extern "C" {
#endif
+/* status codes returned to a client */
+typedef enum {
+ CONNECTION_OK = 0,
+ CONNECTION_ERROR
+} sdb_conn_status_t;
+
+/* accepted commands / state of the connection */
+typedef enum {
+ CONNECTION_IDLE = 0,
+ CONNECTION_PING,
+ CONNECTION_STARTUP,
+} sdb_conn_state_t;
+
/* a generic connection object */
typedef struct {
/* file-descriptor of the open connection */
/* connection / protocol state information */
uint32_t cmd;
uint32_t cmd_len;
+
+ /* user information */
+ char *username; /* NULL if the user has not been authenticated */
} sdb_conn_t;
/*
ssize_t
sdb_connection_read(sdb_conn_t *conn);
+/*
+ * sdb_connection_send:
+ * Send to an open connection.
+ *
+ * Returns:
+ * - the number of bytes written
+ * - a negative value on error
+ */
+ssize_t
+sdb_connection_send(sdb_conn_t *conn, uint32_t code,
+ uint32_t msg_len, char *msg);
+
+/*
+ * sdb_connection_ping:
+ * Send back a backend status indicator to the connected client.
+ *
+ * Returns:
+ * - 0 on success
+ * - a negative value else
+ */
+int
+sdb_connection_ping(sdb_conn_t *conn);
+
+/*
+ * session handling
+ */
+
+/*
+ * sdb_session_start:
+ * Start a new user session on the specified connection.
+ *
+ * Returns:
+ * - 0 on success
+ * - a negative value else
+ */
+int
+sdb_session_start(sdb_conn_t *conn);
+
#ifdef __cplusplus
} /* extern "C" */
#endif