Fix: automatic enum value overwrites existing error code value
[lttng-tools.git] / include / lttng / tracker.h
index 2d952a6e3f23488e5ca7253dcd14d821d96ad0fd..7427cf157fa4c076c5181ed76e45d81337c0c56c 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <lttng/constant.h>
 #include <common/macros.h>
+#include <lttng/session.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -49,9 +50,16 @@ enum lttng_tracker_id_status {
        LTTNG_TRACKER_ID_STATUS_UNSET = 1,
 };
 
-struct lttng_handle;
+/*
+ * A tracker id.
+ */
 struct lttng_tracker_id;
 
+/*
+ * A collection of tracker id.
+ */
+struct lttng_tracker_ids;
+
 /*
  * Create a tracker id for the passed tracker type.
  * Users must set the tracker id using the matching API call.
@@ -100,18 +108,18 @@ extern enum lttng_tracker_id_status lttng_tracker_id_set_all(
                struct lttng_tracker_id *id);
 
 /*
- * Destroys (frees) a tracker id.
+ * Destroy a tracker id.
  */
 extern void lttng_tracker_id_destroy(struct lttng_tracker_id *id);
 
 /*
- * Returns the type of the tracker id.
+ * Get the type of a tracker id.
  */
 extern enum lttng_tracker_id_type lttng_tracker_id_get_type(
                const struct lttng_tracker_id *id);
 
 /*
- * Returns the value of the tracker id.
+ * Get the value of a tracker id.
  *
  * Returns LTTNG_TRACKER_ID_OK on success,
  * LTTNG_TRACKER_ID_STATUS_INVALID when the tracker is not of type
@@ -122,7 +130,7 @@ extern enum lttng_tracker_id_status lttng_tracker_id_get_value(
                const struct lttng_tracker_id *id, int *value);
 
 /*
- * Returns the string representation of the tracker id.
+ * Get the string representation of the tracker id.
  *
  * Returns LTTNG_TRACKER_ID_OK on success,
  * LTTNG_TRACKER_ID_STATUS_INVALID when the tracker is not of type
@@ -132,12 +140,6 @@ extern enum lttng_tracker_id_status lttng_tracker_id_get_value(
 extern enum lttng_tracker_id_status lttng_tracker_id_get_string(
                const struct lttng_tracker_id *id, const char **value);
 
-/*
- * Destroys (frees) an array of tracker id.
- */
-extern void lttng_tracker_ids_destroy(
-               struct lttng_tracker_id **ids, size_t nr_ids);
-
 /*
  * Add ID to session tracker.
  *
@@ -162,20 +164,16 @@ extern int lttng_untrack_id(struct lttng_handle *handle,
                const struct lttng_tracker_id *id);
 
 /*
- * List IDs in the tracker.
+ * List IDs of a tracker.
  *
- * tracker_type is the type of tracker.
- * ids is set to an allocated array of IDs currently tracked.
- * On success, ids must be freed using lttng_tracker_id_destroy on each
- * constituent of the returned array  or using lttng_tracker_ids_destroy.
- * nr_ids is set to the number of entries contained by the ids array.
+ * On success, ids is allocated.
+ * The ids collection must be freed by the caller with lttng_destroy_ids().
  *
  * Returns 0 on success, else a negative LTTng error code.
  */
 extern int lttng_list_tracker_ids(struct lttng_handle *handle,
                enum lttng_tracker_type tracker_type,
-               struct lttng_tracker_id ***ids,
-               size_t *nr_ids);
+               struct lttng_tracker_ids **ids);
 
 /*
  * Backward compatibility.
@@ -215,6 +213,32 @@ extern int lttng_list_tracker_pids(struct lttng_handle *handle,
                int32_t **pids,
                size_t *nr_pids);
 
+/*
+ * Get a tracker id from the list at a given index.
+ *
+ * Note that the list maintains the ownership of the returned tracker id.
+ * It must not be destroyed by the user, nor should it be held beyond the
+ * lifetime of the tracker id list.
+ *
+ * Returns a tracker id, or NULL on error.
+ */
+extern const struct lttng_tracker_id *lttng_tracker_ids_get_at_index(
+               const struct lttng_tracker_ids *ids, unsigned int index);
+
+/*
+ * Get the number of tracker id in a tracker id list.
+ *
+ * Return LTTNG_TRACKER_ID_STATUS on sucess,
+ * LTTNG_TRACKER_ID_STATUS_INVALID when passed invalid parameters.
+ */
+extern enum lttng_tracker_id_status lttng_tracker_ids_get_count(
+               const struct lttng_tracker_ids *ids, unsigned int *count);
+
+/*
+ * Destroy a tracker id list.
+ */
+extern void lttng_tracker_ids_destroy(struct lttng_tracker_ids *ids);
+
 #ifdef __cplusplus
 }
 #endif
This page took 0.026496 seconds and 5 git commands to generate.