You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/12/11 17:21:20 UTC

svn commit: r889682 - in /commons/sandbox/runtime/trunk/src/main/native: include/acr_ini.h shared/ini.c

Author: mturk
Date: Fri Dec 11 16:21:19 2009
New Revision: 889682

URL: http://svn.apache.org/viewvc?rev=889682&view=rev
Log:
Add attribute getter

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/acr_ini.h
    commons/sandbox/runtime/trunk/src/main/native/shared/ini.c

Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_ini.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_ini.h?rev=889682&r1=889681&r2=889682&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_ini.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_ini.h Fri Dec 11 16:21:19 2009
@@ -160,7 +160,7 @@
                                                  const char *val);
 /**
  * Add new key value attribute to the node if not added already
- * @param node Node for which to add addribute.
+ * @param node Node for which to add attribute.
  * @param key Attribute key.
  * @param val New attribute value.
  * @note if the attribute with the given key already exists for the
@@ -172,6 +172,16 @@
                                                  const char *val);
 
 /**
+ * Get the value attribute associated with key.
+ * @param node Node for which to get attribute.
+ * @param key Attribute key.
+ * @return Attribute value or NULL if key was not found.
+ */
+ACR_DECLARE(const char *) ACR_IniNodeAttrGet(JNIEnv *env,
+                                             acr_ini_node_t *node,
+                                             const char *key);
+
+/**
  * Add value to the existing attribute value.
  * @param attr Attribute for which to add value.
  * @param val String to add.

Modified: commons/sandbox/runtime/trunk/src/main/native/shared/ini.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/ini.c?rev=889682&r1=889681&r2=889682&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/ini.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/ini.c Fri Dec 11 16:21:19 2009
@@ -189,6 +189,24 @@
     return ap;
 }
 
+ACR_DECLARE(const char *) ACR_IniNodeAttrGet(JNIEnv *_E, acr_ini_node_t *node,
+                                             const char *key)
+{
+    acr_ini_attr_t *ap;
+
+    if (!key) {
+        return NULL;
+    }
+    for (ap  = ACR_RING_FIRST(&(node->attr_ring));
+         ap != ACR_RING_SENTINEL(&(node->attr_ring), acr_ini_attr_t, link);
+         ap = ACR_RING_NEXT(ap, link)) {
+        if (!strcasecmp(key, ap->key)) {
+            return ap->val;
+        }
+    }
+    return NULL;
+}
+
 ACR_DECLARE(acr_ini_attr_t *) ACR_IniNodeAttrAdd(JNIEnv *_E, acr_ini_node_t *node,
                                 const char *key, const char *val)
 {