Hi,
I'd been hoping to use the CSV injection feature to insert whole headers in
addition to fields within existing headers but found the choice of delimiter
';' restrictive so I've created the attached patch to allow the
specification of a custom delimiter on the command line, it defaults to the
original ';' if omitted. Hope you find this useful.

The following example shows the convoluted delimiter ;;:: being used.

sipp 10.10.10.10:5060 -p 5060 -sf fieldtest.xml -inf database.csv
-infdelimiter ';;::'

Where your database.csv could contain.

user1;;::us...@testhost;;::Dummy-Header: dummyvalue;dummyparam=dummyvalue

Could someone let me know how/if submissions of associated documentation
updates are accepted?
Regards,
John
Index: infile.cpp
===================================================================
--- infile.cpp	(revision 582)
+++ infile.cpp	(working copy)
@@ -160,10 +160,10 @@
 
   do {
     oldpos = pos;
-    size_t localpos = line.find(';', oldpos);
+    size_t localpos = line.find(infdelimiter, oldpos);
 
     if (localpos != string::npos) {
-      pos = localpos + 1;
+      pos = localpos + strlen(infdelimiter);
     } else {
       pos = localpos;
       break;
@@ -189,7 +189,7 @@
 
   if (string::npos != pos) {
     // should not be decremented for fieldN
-    pos -= (oldpos + 1);
+    pos -= (oldpos + strlen(infdelimiter));
   }
 
   string x = line.substr(oldpos, pos);
Index: sipp.cpp
===================================================================
--- sipp.cpp	(revision 582)
+++ sipp.cpp	(working copy)
@@ -179,6 +179,7 @@
 	{"inf", "Inject values from an external CSV file during calls into the scenarios.\n"
                 "First line of this file say whether the data is to be read in sequence (SEQUENTIAL), random (RANDOM), or user (USER) order.\n"
 		"Each line corresponds to one call and has one or more ';' delimited data fields. Those fields can be referred as [field0], [field1], ... in the xml scenario file.  Several CSV files can be used simultaneously (syntax: -inf f1.csv -inf f2.csv ...)", SIPP_OPTION_INPUT_FILE, NULL, 1},
+	{"infdelimiter", "Set a custom delimiter for the external CSV file.  For example -inf users.csv -infdelimiter ';;'", SIPP_OPTION_STRING, &infdelimiter, 1 },
 	{"infindex", "file field\nCreate an index of file using field.  For example -inf users.csv -infindex users.csv 0 creates an index on the first key.", SIPP_OPTION_INDEX_FILE, NULL, 1 },
 
 	{"ip_field", "Set which field from the injection file contains the IP address from which the client will send its messages.\n"
Index: sipp.hpp
===================================================================
--- sipp.hpp	(revision 582)
+++ sipp.hpp	(working copy)
@@ -300,6 +300,9 @@
 
 #endif
 
+// External CSV custom delimiter
+extern char                 *infdelimiter      _DEFVAL(";")  ;
+
 // extern field file management
 typedef std::map<string, FileContents *> file_map;
 extern file_map inFiles;
------------------------------------------------------------------------------
Crystal Reports &#45; New Free Runtime and 30 Day Trial
Check out the new simplified licensign option that enables unlimited
royalty&#45;free distribution of the report engine for externally facing 
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Sipp-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sipp-users

Reply via email to