Patches item #1766079, was opened at 2007-08-02 12:59
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=637566&aid=1766079&group_id=104305
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: sipp
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Simon Flannery (s1m0nflann3ry)
Assigned to: Nobody/Anonymous (nobody)
Summary: Implementation of hh:mm:ss (/sipp/trunk/scenario.cpp)
Initial Comment:
There is currently a function in the file "/sipp/trunk/scenario.cpp" called
get_time that does not support the hh:mm:ss time format. I have added code to
implement this simple task.
Note that I removed the use of the standard "strtod" function in preference to
using the standard "strtol" function - so I hope that will not break anything
else. I have tested it using MS VS C++ 2005 (professional, not express) and GNU
g++ using a simple test harness - see the attached file.
/* This function returns a time in milliseconds from a string.
* The multiplier is used to convert from the default input type into
* milliseconds. For example, for seconds you should use 1000 and for
* milliseconds use 1. */
long get_time(const char *ptr, const char *what, int multiplier) {
char *endptr;
long ret;
long time[2];
ret = 0; /* Clear it. */
if (isdigit(*ptr) == 0) {
ERROR_P2("%s, \"%s\" is not a valid time!\n", what, ptr);
}
ret = strtol(ptr, &endptr, 10);
if (*endptr) {
if (strcmp(endptr, "s") == 0) { /* Seconds */
ret *= 1000;
} else if (strcmp(endptr, "ms") == 0) { /* Milliseconds. */
/* Nothing. */
} else if (strcmp(endptr, "m") == 0) { /* Minutes. */
ret *= 60;
ret *= 1000;
} else if (strcmp(endptr, "h") == 0) { /* Hours. */
ret *= 60;
ret *= 60;
ret *= 1000;
} else if (strstr(endptr, ":") != NULL) {
time[0] = ret;
ret = strtol(++endptr, &endptr, 10);
if (strstr(endptr, ":") != NULL) {
time[1] = ret;
ret = strtol(++endptr, &endptr, 10);
if (!*endptr) {
ret += time[0] * 3600 + time[1] * 60;
} else {
ret = 0;
ERROR_P2("%s, \"%s\" is not a valid time!\n", what, ptr);
}
} else if (!*endptr) {
ret += time[0] * 600;
}
else {
ret = 0;
ERROR_P2("%s, \"%s\" is not a valid time!\n", what, ptr);
}
} else {
ret = 0;
ERROR_P2("%s, \"%s\" is not a valid time!\n", what, ptr);
}
} else {
ret *= multiplier;
}
return ret;
}
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=637566&aid=1766079&group_id=104305
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Sipp-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sipp-users