Browse code

core: use PV api buffers for mod fixup

- functions to get the values from mod fixup structures use now the
buffers from PV api

Daniel-Constantin Mierla authored on 15/07/2011 14:42:21
Showing 2 changed files
... ...
@@ -1608,6 +1608,7 @@ static int _pv_print_buffer_size  = PV_DEFAULT_PRINT_BUFFER_SIZE;
1608 1608
 /* 6 mod params + 4 direct usage from mods */
1609 1609
 #define PV_DEFAULT_PRINT_BUFFER_SLOTS 10
1610 1610
 static int _pv_print_buffer_slots = PV_DEFAULT_PRINT_BUFFER_SLOTS;
1611
+static int _pv_print_buffer_index = 0;
1611 1612
 
1612 1613
 /**
1613 1614
  *
... ...
@@ -1677,10 +1678,9 @@ int pv_reinit_buffer(void)
1677 1678
 char* pv_get_buffer(void)
1678 1679
 {
1679 1680
 	char *p;
1680
-	static int _pv_print_buffer_itr = 0;
1681 1681
 
1682
-	p = _pv_print_buffer[_pv_print_buffer_itr];
1683
-	_pv_print_buffer_itr = (_pv_print_buffer_itr+1)%_pv_print_buffer_slots;
1682
+	p = _pv_print_buffer[_pv_print_buffer_index];
1683
+	_pv_print_buffer_index = (_pv_print_buffer_index+1)%_pv_print_buffer_slots;
1684 1684
 
1685 1685
 	return p;
1686 1686
 }
... ...
@@ -57,6 +57,7 @@
57 57
 #include "route_struct.h"
58 58
 #include "flags.h"
59 59
 #include "trim.h"
60
+#include "pvapi.h"
60 61
 #include "globals.h"
61 62
 #include "rpc_lookup.h"
62 63
 #include "sr_compat.h"
... ...
@@ -1501,8 +1502,6 @@ int fixup_str_2(void** param, int param_no)
1501 1502
 
1502 1503
 
1503 1504
 
1504
-#define PV_PRINT_BUF_SIZE  1024
1505
-#define PV_PRINT_BUF_NO    6
1506 1505
 /** Get the function parameter value as string.
1507 1506
  *  @return  0 - Success
1508 1507
  *          -1 - Cannot get value
... ...
@@ -1513,8 +1512,6 @@ int get_str_fparam(str* dst, struct sip_msg* msg, fparam_t* param)
1513 1512
 	int ret;
1514 1513
 	avp_t* avp;
1515 1514
 	pv_value_t pv_val;
1516
-	static int buf_itr = 0; /* ugly hack needed for PVE */
1517
-	static char pve_buf[PV_PRINT_BUF_NO][PV_PRINT_BUF_SIZE];
1518 1515
 	
1519 1516
 	switch(param->type) {
1520 1517
 		case FPARAM_REGEX:
... ...
@@ -1559,9 +1556,8 @@ int get_str_fparam(str* dst, struct sip_msg* msg, fparam_t* param)
1559 1556
 			}
1560 1557
 			break;
1561 1558
 		case FPARAM_PVE:
1562
-			dst->s=pve_buf[buf_itr];
1563
-			dst->len=PV_PRINT_BUF_SIZE;
1564
-			buf_itr = (buf_itr+1)%PV_PRINT_BUF_NO;
1559
+			dst->s=pv_get_buffer();
1560
+			dst->len=pv_get_buffer_size();
1565 1561
 			if (unlikely(pv_printf(msg, param->v.pve, dst->s, &dst->len)!=0)){
1566 1562
 				ERR("Could not convert the PV-formated string to str\n");
1567 1563
 				dst->len=0;