Added ec_pdo_list_find_by_pos_const().
authorFlorian Pose <fp@igh-essen.com>
Mon, 02 Jun 2008 10:12:31 +0000
changeset 932 dbcc06156a60
parent 931 482bbaf3e76b
child 933 618ab9e03321
Added ec_pdo_list_find_by_pos_const().
master/pdo_list.c
master/pdo_list.h
--- a/master/pdo_list.c	Mon Jun 02 08:54:51 2008 +0000
+++ b/master/pdo_list.c	Mon Jun 02 10:12:31 2008 +0000
@@ -279,6 +279,28 @@
 
 /*****************************************************************************/
 
+/** Finds a Pdo via its position in the list.
+ *
+ * Const version.
+ */
+const ec_pdo_t *ec_pdo_list_find_pdo_by_pos_const(
+        const ec_pdo_list_t *pl, /**< Pdo list. */
+        unsigned int pos /**< Position in the list. */
+        )
+{
+    const ec_pdo_t *pdo;
+
+    list_for_each_entry(pdo, &pl->list, list) {
+        if (pos--)
+            continue;
+        return pdo;
+    }
+
+    return NULL;
+}
+
+/*****************************************************************************/
+
 /**
  */
 unsigned int ec_pdo_list_count(
--- a/master/pdo_list.h	Mon Jun 02 08:54:51 2008 +0000
+++ b/master/pdo_list.h	Mon Jun 02 10:12:31 2008 +0000
@@ -75,6 +75,8 @@
 ec_pdo_t *ec_pdo_list_find_pdo(const ec_pdo_list_t *, uint16_t);
 const ec_pdo_t *ec_pdo_list_find_pdo_const(const ec_pdo_list_t *,
         uint16_t);
+const ec_pdo_t *ec_pdo_list_find_pdo_by_pos_const(
+        const ec_pdo_list_t *, unsigned int);
 unsigned int ec_pdo_list_count(const ec_pdo_list_t *);
 
 /*****************************************************************************/