summaryrefslogtreecommitdiff
path: root/src/object.c
diff options
context:
space:
mode:
author[email protected] <[email protected]>2010-11-21 23:57:33 +0000
committer[email protected] <[email protected]>2010-11-21 23:57:33 +0000
commitf84c16c60d257372cabbb9265bc10383cd87cf71 (patch)
treea0cc764815562ec5cd6c490a4aaa81a4b549879b /src/object.c
parentd174592eff271d3225725c135bf6a59f8f535363 (diff)
recover rt_object_find function.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1085 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'src/object.c')
-rw-r--r--src/object.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/object.c b/src/object.c
index 4544d82ca4..34bae8b191 100644
--- a/src/object.c
+++ b/src/object.c
@@ -367,4 +367,54 @@ rt_err_t rt_object_is_systemobject(rt_object_t object)
return -RT_ERROR;
}
+/**
+ * This function will find specified name object from object
+ * container.
+ *
+ * @param name the specified name of object.
+ * @param type the type of object
+ *
+ * @return the found object or RT_NULL if there is no this object
+ * in object container.
+ *
+ * @note this routine only can be invoke in none-interrupt status.
+ */
+rt_object_t rt_object_find(const char* name, rt_uint8_t type)
+{
+ struct rt_object* object;
+ struct rt_list_node* node;
+ struct rt_object_information *information;
+ extern volatile rt_uint8_t rt_interrupt_nest;
+
+ /* parameter check */
+ if ((name == RT_NULL) ||
+ (type > RT_Object_Class_Unknown))
+ return RT_NULL;
+
+ /* which is invoke in interrupt status */
+ if (rt_interrupt_nest != 0)
+ RT_ASSERT(0);
+
+ /* enter critical */
+ rt_enter_critical();
+
+ /* try to find object */
+ information = &rt_object_container[type];
+ for (node = information->object_list.next; node != &(information->object_list); node = node->next)
+ {
+ object = rt_list_entry(node, struct rt_object, list);
+ if (rt_strncmp(object->name, name, RT_NAME_MAX) == 0)
+ {
+ /* leave critical */
+ rt_exit_critical();
+
+ return (rt_object_t)object;
+ }
+ }
+
+ /* leave critical */
+ rt_exit_critical();
+
+ return RT_NULL;
+}
/*@}*/