Y-lib
Loadrunner libraries
|
Y-lib string function library. More...
#include "y_core.c"
Go to the source code of this file.
Functions | |
void | y_copy_param (char *source_param, char *dest_param) |
Copy a parameter to a new name. This is a semi-efficiënt parameter copy using lr_eval_string_ext(), with appropriate freeing of memory. More... | |
void | y_uppercase_parameter (const char *param_name) |
Convert the content of a parameter to UPPERCASE. More... | |
void | y_substr (const char *original_parameter, const char *result_parameter, const char *left, const char *right) |
Save a substring of a parameter into a new parameter. Search for a specific substring inside a parameter using left and right boundaries and save that into a new parameter. More... | |
void | y_left (const char *original_parameter, const char *search, const char *result_parameter) |
Split a string into 2 parts using the search string. Save the left part into the result parameter. More... | |
void | y_right (const char *original_parameter, const char *search, const char *result_parameter) |
Split a string into 2 parts using the search string. Save the right part into the result parameter. More... | |
void | y_last_right (const char *original_parameter, const char *search, const char *result_parameter) |
Split a string into 2 parts using the search string. Save the rightmost part into the result parameter. This is almost the same as y_right(), but doesn't stop at the first match - instead, it uses the last match. It's pretty much the difference between 'greedy' and 'not greedy' in a regular expression.. More... | |
void | y_split_str (const char *original, const char *separator, char *left, char *right) |
Split a string into 2 parts based on a search string. More... | |
void | y_split (const char *originalParameter, const char *separator, const char *leftParameter, const char *rightParameter) |
Split a parameter in two based on a seperating string. If the seperator is not found in the original parameter the original parameter will be stored in it's entirety in the left hand parameter. More... | |
void | y_chop (const char *parameter) |
Remove leading and trailing whitespace from a parameter. More... | |
void | y_replace (const char *parameter, const char *search, const char *replace) |
Search and replace inside a parameter. This replaces the content of the originally passed-in parameter with the new content when done. More... | |
void | y_remove_string_from_parameter (const char *paramName, const char *removeMe) |
Remove all occurrences of a specified text from a parameter. More... | |
void | y_param_unique (char *param) |
Create a unique parameter. More... | |
void | y_random_string_buffer_core (const char *parameter, int minimumLength, int maximumLength, int minWordLength, int maxWordLength, char *characterSet) |
Generates a random string with (pseudo) words created from a given string of characters. More... | |
void | y_random_string_buffer (const char *parameter, int minimumLength, int maximumLength) |
Returns a random string with (pseudo) words created from a given string of characters. More... | |
void | y_random_number_buffer (const char *parameter, int minimumLength, int maximumLength) |
Returns a random string of numbers with a given minimum and maximum length. More... | |
void | y_random_string_buffer_curses (const char *parameter, int minimumLength, int maximumLength) |
Returns a string containing only the "shift-1...shift 9 characters (on a US-keyboard). More... | |
void | y_random_string_buffer_hex (const char *parameter, int minimumLength, int maximumLength) |
Generates a random string with a hexadecimal number, of a given minimum and maximum length. More... | |
char * | y_get_cleansed_parameter (const char *param_name, char replacement) |
Get the content of a parameter without embedded null bytes (\0 characters) from the named parameter, if any. In some cases we want to fetch the content of a parameter but the parameter contains embedded NULL characters which make further processing harder. This will fetch a parameter but "cleanse" it from such contamination, leaving the rest of the data unaltered before returning it. More... | |
void | y_cleanse_parameter_ext (const char *param_name, char replacement) |
Clean a parameter by replacing any embedded NULL (null) characters with a replacement character. More... | |
void | y_cleanse_parameter (const char *param_name) |
Clean a parameter by replacing any embedded NULL (null) characters with a space. This is identical to y_cleanse_parameter_ext() with " " (a single space) selected as the replacement character. More... | |
Y-lib string function library.
Contains low level string and memory manipulation functions, insofar not provided by the C standard. The philosophy of ylib is that the script engineer should not be required to worry about C-strings and C-like memory manipulation when parameters will suffice. Most string manipulation functions in the y-lib library take loadrunner parameters as arguments and place their output in one or more of these parameters. This usually makes it easy to correlate a value (capturing it in a parameter), process it, then pass it on to the next request (again as a parameter).
Definition in file y_string.c.
void y_chop | ( | const char * | parameter | ) |
Remove leading and trailing whitespace from a parameter.
This does not support unicode, so it may not catch everything. Supported whitespace is: " "(=space) "\r"(=carrige return) "\n"(=line feed) "\t"(=tab) The result is stored in the original parameter.
[in] | parameter | The parameter to chop. |
Example:
Definition at line 455 of file y_string.c.
void y_cleanse_parameter | ( | const char * | param_name | ) |
Clean a parameter by replacing any embedded NULL (null) characters with a space. This is identical to y_cleanse_parameter_ext() with " " (a single space) selected as the replacement character.
[in] | param_name | The parameter to cleanse of nulls. |
Example:
Definition at line 957 of file y_string.c.
void y_cleanse_parameter_ext | ( | const char * | param_name, |
char | replacement | ||
) |
Clean a parameter by replacing any embedded NULL (null) characters with a replacement character.
This would normally only happen if you have used to web_reg_save_param() and the result contains one or more null-character(s). Any such characters are replaced with replacement_char and the result is stored in the original parameter. When no null-character is found, the result is unaltered.
[in] | param_name | The parameter to cleanse of nulls. |
[in] | replacement | A character that replaces any embedded nulls found. |
Example:
Definition at line 926 of file y_string.c.
void y_copy_param | ( | char * | source_param, |
char * | dest_param | ||
) |
Copy a parameter to a new name. This is a semi-efficiënt parameter copy using lr_eval_string_ext(), with appropriate freeing of memory.
[in] | source_param | The parameter to copy. |
[in] | dest_param | The name of the parameter to copy the first parameter to. |
Example:
Definition at line 86 of file y_string.c.
char* y_get_cleansed_parameter | ( | const char * | param_name, |
char | replacement | ||
) |
Get the content of a parameter without embedded null bytes (\0 characters) from the named parameter, if any. In some cases we want to fetch the content of a parameter but the parameter contains embedded NULL characters which make further processing harder. This will fetch a parameter but "cleanse" it from such contamination, leaving the rest of the data unaltered before returning it.
[in] | param_name | The parameter to cleanse of nulls. |
[in] | replacement | A character that replaces any embedded nulls found. |
Example:
Definition at line 868 of file y_string.c.
void y_last_right | ( | const char * | original_parameter, |
const char * | search, | ||
const char * | result_parameter | ||
) |
Split a string into 2 parts using the search string. Save the rightmost part into the result parameter. This is almost the same as y_right(), but doesn't stop at the first match - instead, it uses the last match. It's pretty much the difference between 'greedy' and 'not greedy' in a regular expression..
[in] | original_parameter | The parameter to search. |
[in] | search | The text preceding the text we're looking for. |
[in] | result_parameter | The name of the parameter to store the result in. |
Example:
Definition at line 290 of file y_string.c.
void y_left | ( | const char * | original_parameter, |
const char * | search, | ||
const char * | result_parameter | ||
) |
Split a string into 2 parts using the search string. Save the left part into the result parameter.
[in] | original_parameter | The parameter to search. |
[in] | search | The text after the text we're looking for. |
[in] | result_parameter | The name of the parameter to store the result in. |
Example:
Definition at line 188 of file y_string.c.
void y_param_unique | ( | char * | param | ) |
Create a unique parameter.
param | The name of a parameter to store the resulting string in. Length is always 22 (base64) characters. |
Example:
Definition at line 636 of file y_string.c.
void y_random_number_buffer | ( | const char * | parameter, |
int | minimumLength, | ||
int | maximumLength | ||
) |
Returns a random string of numbers with a given minimum and maximum length.
This function generates a string of numbers with a given minimum and maximum length.
[out] | parameter | Name of the LR-parameter in which the result is stored |
[in] | minimumLength | Minumum length of the string |
[in] | maximumLength | Maximum length of the string |
Definition at line 801 of file y_string.c.
void y_random_string_buffer | ( | const char * | parameter, |
int | minimumLength, | ||
int | maximumLength | ||
) |
Returns a random string with (pseudo) words created from a given string of characters.
This function uses a given set of characters to create words, separated by spaces. The words are minimal 3 characters long, and maximum 8 characters long. Should you need other word lenghts, use y_random_number_buffer_core(). The total length of the line is minimal minimumLength and maximum maximumLength long.
[out] | parameter | Name of the LR-parameter in which the result is stored |
[in] | minimumLength | Minumum length of the string |
[in] | maximumLength | Maximum length of the string |
Definition at line 784 of file y_string.c.
void y_random_string_buffer_core | ( | const char * | parameter, |
int | minimumLength, | ||
int | maximumLength, | ||
int | minWordLength, | ||
int | maxWordLength, | ||
char * | characterSet | ||
) |
Generates a random string with (pseudo) words created from a given string of characters.
This function uses a given set of characters to create words, separated by spaces. The words are minimal minWordLength characters long, and maximum minWordLength characters. The total length of the line is minimal minimumLength and maimum maximumLength long.
Example:
[out] | parameter | Name of the LR-parameter in which the result is stored |
[in] | minimumLength | Minumum length of the string |
[in] | maximumLength | Maximum length of the string |
[in] | minWordLength | Minimum length of the words within the string |
[in] | maxWordLength | Minimum length of the words within the string |
[in] | characterSet | The string is build from this string of characters |
Definition at line 678 of file y_string.c.
void y_random_string_buffer_curses | ( | const char * | parameter, |
int | minimumLength, | ||
int | maximumLength | ||
) |
Returns a string containing only the "shift-1...shift 9 characters (on a US-keyboard).
This function generates a string of non-alfa-characters with a given minimum and maximum length.
[out] | parameter | Name of the LR-parameter in which the result is stored |
[in] | minimumLength | Minumum length of the string |
[in] | maximumLength | Maximum length of the string |
Definition at line 818 of file y_string.c.
void y_random_string_buffer_hex | ( | const char * | parameter, |
int | minimumLength, | ||
int | maximumLength | ||
) |
Generates a random string with a hexadecimal number, of a given minimum and maximum length.
This function generates a string with a hexadecimal number.
Should you need other word lenghts, use y_random_number_buffer_core(). The total length of the line is minimal minimumLength and maimum maximumLength long.
[out] | parameter | Name of the LR-parameter in which the result is stored |
[in] | minimumLength | Minumum length of the string |
[in] | maximumLength | Maximum length of the string |
Definition at line 838 of file y_string.c.
void y_remove_string_from_parameter | ( | const char * | paramName, |
const char * | removeMe | ||
) |
Remove all occurrences of a specified text from a parameter.
This is a lighter weight alternative to the y_replace() function in cases where just want to remove text, rather than replace it with something else. Stores the result in the original parameter.
[in] | paramName | The parameter to search. |
[in] | removeMe | The text to remove. |
Example:
Definition at line 594 of file y_string.c.
void y_replace | ( | const char * | parameter, |
const char * | search, | ||
const char * | replace | ||
) |
Search and replace inside a parameter. This replaces the content of the originally passed-in parameter with the new content when done.
[in] | parameter | The parameter to search. |
[in] | search | What to search for. |
[in] | replace | What to replace it with. |
Example:
Definition at line 508 of file y_string.c.
void y_right | ( | const char * | original_parameter, |
const char * | search, | ||
const char * | result_parameter | ||
) |
Split a string into 2 parts using the search string. Save the right part into the result parameter.
[in] | original_parameter | The parameter to search. |
[in] | search | The text preceding the text we're looking for. |
[in] | result_parameter | The name of the parameter to store the result in. |
Example:
Definition at line 240 of file y_string.c.
void y_split | ( | const char * | originalParameter, |
const char * | separator, | ||
const char * | leftParameter, | ||
const char * | rightParameter | ||
) |
Split a parameter in two based on a seperating string. If the seperator is not found in the original parameter the original parameter will be stored in it's entirety in the left hand parameter.
[in] | originalParameter | The parameter to search. |
[in] | separator | The string to use as a seperation marker between the two parts. |
[in] | leftParameter | The parameter that will hold the left hand side of the split result. |
[in] | rightParameter | The parameter that will hold the right hand side of the split result. |
Example:
Definition at line 389 of file y_string.c.
void y_split_str | ( | const char * | original, |
const char * | separator, | ||
char * | left, | ||
char * | right | ||
) |
Split a string into 2 parts based on a search string.
[in] | original | The string to search. |
[in] | separator | The string to use as a seperation marker between the two parts. |
[in] | left | A preallocated char* buffer to hold the left hand side of the result. |
[in] | right | A preallocated char* buffer to hold the right hand side of the result. |
Definition at line 341 of file y_string.c.
void y_substr | ( | const char * | original_parameter, |
const char * | result_parameter, | ||
const char * | left, | ||
const char * | right | ||
) |
Save a substring of a parameter into a new parameter. Search for a specific substring inside a parameter using left and right boundaries and save that into a new parameter.
[in] | original_parameter | The parameter to search. |
[in] | result_parameter | The name of the parameter to store the result in. |
[in] | left | The left boundary - the text immediately preceding the substring in question. |
[in] | right | The right boundary. |
Example:
Definition at line 144 of file y_string.c.
void y_uppercase_parameter | ( | const char * | param_name | ) |
Convert the content of a parameter to UPPERCASE.
This will replace the content of the paramenter named in 'param_name' with the uppercased version. Does not affect non-alphabetic characters.
[in] | param_name | The parameter to convert to uppercase. |
Example:
Definition at line 114 of file y_string.c.