Hi, Darren!

There is indeed a bug there, but the patch I've attached should fix it. Can you please apply it and test again? Let me know if this solves your issue.

Regards,

--
Ra(zvan Crainea
OpenSIPS Developer


On 12/16/2011 06:47 AM, Darren DeLitizia wrote:
Is this valid naming for avp's - $avp($var(i))

I am trying to loop through exec_avp results as I will never know how many rows are being returned. It is in a startup route and I am using a while statement to loop through. It is not recognizing naming. $avp($avp(i)) always returns NULL while something like $avp(2) will return the data

Tx
DD

exec_avp("/usr/bin/php /usr/local/etc/opensips/name_of_script.php ips");#gets list of ips and other carrier info
  if (is_avp_set("$avp(1)")) {
$var(x) = $avp(1); #$avp(1) is the amount of rows returned so I know how many to loop through
    $var(x) = $(var(x){s.int <http://s.int>}) + 1;
    avp_delete("$avp(1)");
    $avp(i) = 2;
    while($avp(i) <= $var(x)) {
      xlog("TEST -- $avp(i)\n");
      xlog("TEST -- $avp($avp(i))\n"); #
      $avp(ip) = $(avp($var(i)){s.select,0,;});
      $avp(carrier_ids) = $(avp($var(i)){s.select,1,;});
      $avp(route_types) = $(avp($var(i)){s.select,2,;});
      $avp(carrier_names) = $(avp($var(i)){s.select,0,;});
cache_store("local", "ips_carrier_ids_$avp(ip)", "$avp(carrier_ids)");# cache_store("local", "ips_carrier_names_$avp(ip)", "$avp(carrier_names)");# cache_store("local", "ips_carrier_types_$avp(ip)", "$avp(route_types)");#
      avp_delete("$avp($var(i))");
      $avp(i) = $avp(i) + 1;
    }
  }
}



_______________________________________________
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Index: pvar.c
===================================================================
--- pvar.c	(revision 8626)
+++ pvar.c	(working copy)
@@ -3879,16 +3879,14 @@
 		return -1;
 	}
 		
-	if((tv.flags&PV_TYPE_INT) && (tv.flags&PV_VAL_INT))
-	{
-		*avp_name = tv.ri;
-	} else {
-		/* search the name here */
-		*avp_name = get_avp_id(&tv.rs);
-		if (*avp_name == 0) {
-			LM_ERR("cannot find avp %.*s\n", tv.rs.len, tv.rs.s);
-			return -1;
-		}
+	if(!(tv.flags&PV_VAL_STR))
+		tv.rs.s = int2str(tv.ri, &tv.rs.len);
+
+	/* search the name here */
+	*avp_name = get_avp_id(&tv.rs);
+	if (*avp_name == 0) {
+		LM_ERR("cannot find avp %.*s\n", tv.rs.len, tv.rs.s);
+		return -1;
 	}
 	return 0;
 }
_______________________________________________
Users mailing list
Users@lists.opensips.org
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to