xreq: export a function to get req
[src/app-framework-binder.git] / include / afb / afb-req.h
index 71dd31d..1533985 100644 (file)
 
 #pragma once
 
-#include "afb-request-itf.h"
-
+#include "afb-req-itf.h"
 #include "afb-event.h"
 
 /*
- * Describes the request by bindings from afb-daemon
+ * Converts the 'req' to an afb_request.
  */
-struct afb_req
+static inline struct afb_request *afb_req_to_request(struct afb_req req)
 {
-       const struct afb_request_itf *itf;      /* the interface to use */
-       struct afb_request *closure;            /* the closure argument for functions of 'itf' */
-};
+       return req.closure;
+}
 
 /*
  * Checks whether the request 'req' is valid or not.
@@ -412,3 +410,14 @@ static inline char *afb_req_get_application_id(struct afb_req req)
        return req.itf->get_application_id(req.closure);
 }
 
+/*
+ * Get the user identifier (UID) of the client application for the
+ * request 'req'.
+ *
+ * Returns -1 when the application can not be identified.
+ */
+static inline int afb_req_get_uid(struct afb_req req)
+{
+       return req.itf->get_uid(req.closure);
+}
+