Y-lib
Loadrunner libraries
y_string.c
Go to the documentation of this file.
1 /*
2  * Ylib Loadrunner function library.
3  * Copyright (C) 2005-2014 Floris Kraak <randakar@gmail.com> | <fkraak@ymor.nl>
4  * Copyright (C) 2009 Raymond de Jongh <ferretproof@gmail.com> | <rdjongh@ymor.nl>
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  */
20 
30 #ifndef _Y_STRING_C_
31 #define _Y_STRING_C_
33 
35 #include "y_core.c"
36 
38 
50 #define y_get_int_from_char(c) (isdigit(c) ? c - ‘0’: 0)
51 
53 
69 #define y_int_strlen(number) (number?(int)floor(log10(abs(number)))+(number<0?2:1):1)
70 
86 void y_copy_param(char* source_param, char* dest_param)
87 {
88  char* buffer;
89  unsigned long size;
90  char* source = y_get_parameter_eval_string(source_param); // Puts the parameter name into parameter seperators { }.
91  lr_eval_string_ext(source, strlen(source), &buffer, &size, 0, 0, -1); // Evaluates the result and copy the data into buffer.
92  free(source); // Free the intermediate parameter name.
93  lr_save_var(buffer, size, 0, dest_param); // Save the result.
94  lr_eval_string_ext_free(&buffer); // Free the buffer.
95 }
96 
114 void y_uppercase_parameter(const char* param_name)
115 {
116  char *result = y_get_parameter_or_null(param_name);
117  if(result == NULL)
118  {
119  lr_error_message("Nonexistant parameter %s passed to y_uppercase_parameter(): Aborting.", param_name);
120  lr_abort();
121  }
122  strupr(result);
123  lr_save_string(result, param_name);
124 }
125 
144 void y_substr(const char *original_parameter, const char *result_parameter, const char *left, const char *right)
145 {
146  char *p1;
147  char *str = y_get_parameter_or_null(original_parameter);
148  if( str == NULL )
149  {
150  lr_error_message("y_substr(): Error: Parameter %s does not exist!", original_parameter);
151  lr_abort();
152  }
153 
154  // zoek start
155  if (left) {
156  p1 = strstr(str, left);
157  if (p1) str = p1 + strlen(left);
158  // else start is positie 0...
159  }
160 
161  // zoek eind
162  if (right) {
163  p1 = strstr(str, right);
164  if (p1) {
165  lr_param_sprintf(result_parameter, "%.*s", p1 - str, str); // of sprintf
166  return;
167  }
168  }
169  lr_save_string(str, result_parameter);
170 }
171 
172 
188 void y_left( const char *original_parameter, const char *search, const char *result_parameter )
189 {
190  char *original = y_get_parameter_or_null(original_parameter);
191  if( original == NULL )
192  {
193  lr_error_message("y_left(): Error: Parameter %s does not exist!", original_parameter);
194  lr_abort();
195  }
196  else if( search == NULL || strlen(search) == 0 )
197  {
198  lr_save_string(original, result_parameter);
199  lr_log_message("Warning: Empty search parameter passed to y_left()");
200  return;
201  }
202  else
203  {
204  char *buffer;
205  char *posPtr = (char *)strstr(original, search);
206  int pos = (int)(posPtr - original);
207  //lr_log_message("y_left: original=%s, search=%s, resultParam=%s", original, search, resultParam);
208 
209  if( posPtr == NULL )
210  {
211  lr_save_string(original, result_parameter);
212  return;
213  }
214  //lr_log_message("pos = %d", pos);
215 
216  // Copy the original to a temporary buffer
217  buffer = y_strdup(original);
218  buffer[pos] = '\0'; // make the cut
219  lr_save_string(buffer, result_parameter); // save the result
220  free(buffer);
221  }
222 }
223 
224 
240 void y_right( const char *original_parameter, const char *search, const char *result_parameter)
241 {
242  char* original = y_get_parameter_or_null(original_parameter);
243  if( original == NULL )
244  {
245  lr_error_message("y_right(): Error: Parameter %s does not exist!", original_parameter);
246  lr_abort();
247  }
248  else if( search == NULL || strlen(search) == 0 )
249  {
250  lr_save_string(original, result_parameter);
251  lr_log_message("Warning: Empty search parameter passed to y_right()");
252  return;
253  }
254  else
255  {
256  char* posPtr = (char *)strstr(original, search);
257  //int pos = (int)(posPtr - original);
258  //lr_log_message("y_right: original=%s, search=%s, resultParam=%s", original, search, result_parameter);
259 
260  if( posPtr == NULL )
261  {
262  lr_save_string(original, result_parameter);
263  return;
264  }
265  //lr_log_message("pos = %d", pos);
266  posPtr = posPtr + strlen(search);
267  lr_save_string(posPtr, result_parameter);
268  }
269 }
270 
271 
290 void y_last_right( const char *original_parameter, const char *search, const char *result_parameter)
291 {
292  char *result = y_get_parameter_or_null(original_parameter);
293  if( result == NULL )
294  {
295  lr_error_message("y_last_right(): Error: Parameter %s does not exist!", original_parameter);
296  lr_abort();
297  }
298  else if( search == NULL || strlen(search) == 0 )
299  {
300  lr_save_string(result, result_parameter);
301  lr_log_message("Warning: Empty search parameter passed to y_last_right()");
302  return;
303  }
304  else
305  {
306  char *posPtr;
307  //lr_log_message("y_last_right: original=%s, search=%s, resultParam=%s", original, search, resultParameter);
308  do
309  {
310  posPtr = (char *)strstr(result, search);
311  //pos = (int)(posPtr - result);
312  //lr_log_message("pos = %d", pos);
313 
314  // not found, save what we have as the result.
315  if( posPtr == NULL )
316  {
317  lr_save_string(result, result_parameter);
318  return;
319  }
320  // found, update the result pointer and go find more..
321  result = posPtr + strlen(search);
322  }
323  while(1);
324  }
325 }
326 
327 
341 void y_split_str( const char *original, const char *separator, char *left, char *right)
342 {
343  char *buffer;
344  char *posPtr = (char *)strstr(original, separator);
345  int pos = (int)(posPtr - original);;
346 
347  //lr_log_message("y_split_str: original=%s, search=%s", original, search);
348 
349  if( posPtr == NULL )
350  {
351  // Copy the original to the left hand output buffer.
352  strncpy(left, original, strlen(original)+1); // Let's not forget to copy the null byte, too.
353  return;
354  }
355  //lr_log_message("pos = %d", pos);
356 
357  // Copy the left hand using pos bytes from the original
358  strncpy(left, original, pos);
359  left[pos] = '\0'; // make the cut by putting a null character at the end.
360 
361  // Copy the right hand side starting from the position just after the found string.
362  {
363  char *start = posPtr + strlen(separator);
364  strncpy(right, start, strlen(start)+1); // Let's not forget to copy the null byte, too.
365  }
366 }
367 
368 
389 void y_split( const char *originalParameter, const char *separator, const char *leftParameter, const char *rightParameter)
390 {
391  char *item = y_get_parameter(originalParameter);
392  int len = strlen(item);
393 
394  if( len < strlen(separator) )
395  {
396  // Since the separator doesn't even fit in the item, searching is pointless.
397  // Store the original in the left hand parameter, the right hand is empty.
398  lr_save_string(originalParameter, leftParameter);
399  lr_save_string("", rightParameter);
400  return;
401 
402  }
403  else
404  {
405 
406  // Left hand side
407  // If the separator isn't found the full original string gets stored here.
408  // Don't forget the 0 byte at the end though..
409  char *left = y_mem_alloc(len+1);
410 
411  // Right hand side
412  // If the separator gets found in position 1 the remainder of the
413  // original string gets stored here (and left gets a zero-length string).
414  char *right = y_mem_alloc(len-strlen(separator)+1);
415 
416  // Start off with zero-length strings. We can safely assume
417  // both variables contain garbage when freshly allocated.
418  left[0] = '\0';
419  right[0] = '\0';
420 
421  // This is where the magic happens.
422  y_split_str(item, separator, left, right);
423 
424  // Store the results in parameters.
425  lr_save_string(left, leftParameter);
426  free(left);
427  lr_save_string(right, rightParameter);
428  free(right);
429  }
430 }
431 
432 
455 void y_chop( const char* parameter )
456 {
457  char *result;
458  int i = 0;
459  char character;
460 
461  //lr_output_message( "y_chop(%s)", parameter);
462  result = y_get_parameter(parameter);
463 
464  // y_chop leading whitespace
465  character = result[i];
466  while( (character == ' ') || (character == '\r') || (character == '\n') || (character == '\t') )
467  {
468  character = result[++i];
469  }
470  result += i;
471 
472  //lr_output_message("result after removal of leading whitespace: %s", result);
473 
474  // y_chop trailing whitespace
475  i = strlen(result)-1;
476  character = result[i];
477  while( (i >= 0) &&
478  ( (character == ' ' ) ||
479  (character == '\r') ||
480  (character == '\n') ||
481  (character == '\t') ) )
482  {
483  character = result[--i];
484  }
485  result[i+1] = '\0';
486 
487  lr_save_string(result, parameter);
488 }
489 
490 
508 void y_replace( const char *parameter, const char *search, const char *replace )
509 {
510  int slen, rlen, plen; // lengte van search, replace, en basis string
511  int i = 0; // aantal replacements
512  int limit = 1000; // replacement limiet als replace > search
513 
514  char *c; // punt waar change moet beginnen
515  char *cend; // einde van de change = c+slen
516  char *last; // de \0 slotbyte van input string
517  char *buffer; // buffer voor bewerkingen
518  char *string; // originele string waar we in zoeken
519 
520  if ((search == NULL) || (strlen(search) <1))
521  return;
522  if (!search || !replace) return; // ongeldige search of_replace
523  if (!strcmp(search, replace)) return; // search == replace: geen wijziging
524 
525  slen = strlen (search); // de lengte van search
526  rlen = strlen (replace); // de lengte van replace
527 
528  string = y_get_parameter(parameter); // <-- memory allocated by loadrunner, too small if replace > search
529  plen = strlen(string);
530 
531  //lr_log_message("y_replace(%s, %s, %s) - slen %d, rlen %d, plen %d", parameter, search, replace, slen, rlen, plen);
532 
533  if ( rlen > slen)
534  {
535  // Reserve memory for -limit- replacements.
536  size_t size = plen + ((rlen-slen) * limit);
537  buffer = y_mem_alloc( size );
538  snprintf( buffer, size, "%s", string );
539  }
540  else
541  {
542  // No need to reserve memory
543  buffer = string;
544  }
545 
546  last = buffer + strlen(buffer) +1; // het einde van de string, de null byte
547  c = buffer; // initialiseer c - buffer moet intact blijven
548 
549  while (c = (char*) strstr(c, search)) // doorzoek de search string vanaf waar je gebleven bent
550  {
551  //lr_output_message("c:%s", c);
552 
553  i++;
554  if (slen != rlen) // zijn search en replace van verschillende lengte?
555  {
556  if( i >= limit )
557  {
558  lr_log_message("Unable to handle more than %d search-and-replaces, apologies for the inconvenience.", limit);
559  break;
560  }
561  cend = c+slen; // cend is de plaats van waaraf de string moet opschuiven
562  //lr_output_message("memmove(dest=%d, src=%d, size=%d)", (long)(c+rlen), (long)(cend), (long)(last-cend) );
563  memmove (c+rlen , cend, last-cend); // verplaats de rest van de string - als de geheugenberekening niet klopt gaat dit stuk!
564  //lr_output_message("memmove completed, result = %s", c);
565  last = last - slen + rlen; // en bereken het nieuwe eindpunt
566  }
567  memmove(c, replace, rlen); // execute the replacement
568  c += rlen; // start the next search at the point where the replacement ended
569  }
570  lr_save_string(buffer, parameter);
571 
572  if( rlen > slen )
573  {
574  free(buffer);
575  }
576 }
577 
578 
594 void y_remove_string_from_parameter(const char* paramName, const char* removeMe)
595 {
596  char *parameter;
597  char *removePtr;
598  int remlen;
599 
600  //lr_log_message("y_remove_string_from_parameter( remove:%s, parameter:%s )", removeMe, paramName);
601 
602  if(!removeMe || !*removeMe)
603  return;
604 
605  // fetch the contents of the parameter to change
606  parameter = y_get_parameter(paramName);
607  // removePtr is used to track our progress through this string
608  removePtr = parameter;
609  remlen = strlen(removeMe);
610 
611  // while we find occurrances of the string we're looking for
612  while ( removePtr = (char *)strstr( removePtr, removeMe ) )
613  {
614  // copy the characters between the end of the data we wish to remove and end-of-string
615  // to the place where we found our offending content.
616  char* origin = removePtr + remlen;
617  strncpy(removePtr, origin, (strlen(origin)+1));
618  }
619 
620  // store it in the original parameter
621  lr_save_string( parameter, paramName );
622 }
623 
624 
636 void y_param_unique(char *param)
637 {
638  char buf[25]; // base64 of UUID's are always 24 characters, plus null byte.
639  lr_generate_uuid_on_buf(buf); // Probably a wrapper for http://msdn.microsoft.com/en-us/library/windows/desktop/aa379205(v=vs.85).aspx
640  lr_save_var(buf, 22, 0, param); // save & trim off ==
641 }
642 
643 
644 
646 
678 void y_random_string_buffer_core(const char *parameter, int minimumLength, int maximumLength,
679  int minWordLength, int maxWordLength, char *characterSet)
680 {
681  char *buffer;
682  int charSetSize; // length of the characterSet
683  int length = 0;
684  int max = -1;
685 
686  char randomNumber;
687  int lettersInWord;
688 
689  charSetSize=strlen(characterSet);
690 
691  //lr_message("minimumLength %d -- maximumLength %d -- minWordLength %d -- maxWordLength %d",
692  // minimumLength, maximumLength, minWordLength, maxWordLength);
693 
694  // error checks - lots of code that saves us headaches later
695  if( minimumLength < 0 ) {
696  lr_error_message( "minimumLength less than 0 (%d)", minimumLength );
697  }
698  else if( maximumLength < 1 ) {
699  lr_error_message( "maximumLength less than 1 (%d)", maximumLength );
700  }
701  else if( maximumLength > (1024 * 1024) ) {
702  lr_error_message( "maximumLength too big (%d)", maximumLength );
703  }
704  else if( maximumLength < minimumLength ) {
705  lr_error_message( "minimumLength (%d) bigger than maximumLength (%d)", minimumLength, maximumLength );
706  }
707  else if(maximumLength > minimumLength) {
708  // Not an error
709  max = y_rand_between(minimumLength, maximumLength);
710  lr_log_message("Max: %d", max);
711  }
712  else if(maximumLength == minimumLength) {
713  // Not an error either
714  max = maximumLength;
715  }
716  else {
717  lr_error_message("This can never happen. If we reach this point it's a bug.");
718  }
719 
720  // if we got an error
721  if( max < 0 )
722  {
723  lr_set_transaction_status(LR_FAIL);
724  lr_exit(LR_EXIT_ITERATION_AND_CONTINUE, LR_FAIL);
725  }
726 
727  // get memory for the buffer
728  buffer = (char *)y_mem_alloc( max +1 );
729  // note: if this fails y_mem_alloc() aborts the script, so no error handling needed.
730 
731  while( length < max )
732  {
733 // lr_message("Length: %d max: %d", length, max);
734 // lettersInWord = ((y_rand() % 8) + 2);
735  if( maxWordLength == 0 )
736  {
737  lettersInWord = maximumLength;
738  }
739  else
740  {
741  lettersInWord = y_rand_between(minWordLength, maxWordLength);
742  if( lettersInWord < 0 )
743  {
744  lr_error_message( "y_rand_between() returned an errorcode (%d)", lettersInWord );
745  lr_set_transaction_status(LR_FAIL);
746  lr_exit(LR_EXIT_ITERATION_AND_CONTINUE, LR_FAIL);
747  }
748  }
749 
750  while( lettersInWord-- && (length < (max)) )
751  {
752  randomNumber = (char) (y_rand() % charSetSize);
753  buffer[length++] = characterSet[randomNumber];
754  }
755 
756  if( maxWordLength != 0 )
757  {
758  if( length < max -1 )
759  {
760  buffer[length++] = ' ';
761  }
762  }
763  }
764  buffer[max] = '\0';
765 
766  lr_save_string(buffer, parameter);
767  free(buffer);
768 }
769 
771 
784 void y_random_string_buffer(const char *parameter, int minimumLength, int maximumLength)
785 {
786  y_random_string_buffer_core(parameter, minimumLength, maximumLength, 3, 8,
787  "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
788 }
789 
790 
792 
801 void y_random_number_buffer(const char *parameter, int minimumLength, int maximumLength)
802 {
803  y_random_string_buffer_core(parameter, minimumLength, maximumLength, 0, 0, "0123456789");
804 }
805 
806 
808 
818 void y_random_string_buffer_curses(const char *parameter, int minimumLength, int maximumLength)
819 {
820  y_random_string_buffer_core(parameter, minimumLength, maximumLength, 0, 0, "!@#$%^&*()");
821 }
822 
823 
825 
838 void y_random_string_buffer_hex(const char *parameter, int minimumLength, int maximumLength)
839 {
840  y_random_string_buffer_core(parameter, minimumLength, maximumLength, 0, 0, "0123456789ABCDEF");
841 }
842 
843 
844 
868 char* y_get_cleansed_parameter(const char* param_name, char replacement)
869 {
870  char* result;
871  unsigned long result_size;
872  size_t param_eval_size = strlen(param_name) +3; // parameter name + "{}" + '\0' (end of string)
873  char* param_eval_string = y_mem_alloc(param_eval_size);
874  //lr_log_message("y_cleanse_parameter(%s)", param_name );
875 
876  // Get the contents of the parameter using lr_eval_string_ext() - we can't use the
877  // regular version if we expect to find NULL in there.
878  snprintf( param_eval_string, param_eval_size, "{%s}", param_name );
879  lr_eval_string_ext(param_eval_string, param_eval_size-1, &result, &result_size, 0, 0, -1);
880  if( strcmp(param_eval_string, result) == 0 )
881  {
882  lr_error_message("y_get_cleansed_parameter: Parameter %s does not exist.", param_name);
883  lr_abort();
884  }
885  free(param_eval_string);
886 
887  //lr_log_message("Cleansing param %s, result starts with '%-*.*s' and contains %d bytes.", param_name, result_size, result_size, result, result_size);
888  if (result_size) {
889  char *ptr;
890  for(ptr = result; result_size--; ptr++)
891  if (*ptr == 0) *ptr = replacement;
892 
893  /*
894  // Now replace NULL bytes (NULL) in the input with something else..
895  for( result_strlen = strlen(result); result_strlen < result_size; result_strlen = strlen(result))
896  {
897  result[result_strlen] = replacement;
898  //lr_log_message("Cleansing param %s, result now '%-*.*s' and contains %d bytes.", param_name, result_size, result_size, result, result_size);
899  }*/
900  }
901  return result;
902 }
903 
926 void y_cleanse_parameter_ext(const char* param_name, char replacement)
927 {
928  if( param_name && strlen(param_name) )
929  {
930  char* result = y_get_cleansed_parameter(param_name, replacement);
931  lr_save_string(result, param_name);
932  lr_eval_string_ext_free(&result);
933  }
934  else
935  {
936  lr_error_message("Empty or NULL parameter name passed to y_cleanse_parameter_ext(): %s", param_name);
937  lr_abort();
938  }
939 }
940 
957 void y_cleanse_parameter(const char* param_name)
958 {
959  y_cleanse_parameter_ext(param_name, ' ');
960 }
961 
962 
963 #endif // _Y_STRING_C_
964 
char * strupr(char *string)
Documented at http://www.qnx.com/developers/docs/6.5.0/topic/com.qnx.doc.neutrino_lib_ref/s/strupr.html .
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...
Definition: y_string.c:188
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...
Definition: y_string.c:957
void y_chop(const char *parameter)
Remove leading and trailing whitespace from a parameter.
Definition: y_string.c:455
char * strstr(const char *string1, const char *string2)
Documented at http://www.cplusplus.com/reference/cstring/strstr/.
char * y_mem_alloc(size_t size)
Ylib wrapper for malloc()
Definition: y_core.c:221
Contains core ylib support functions needed for the functioning of the library.
void y_remove_string_from_parameter(const char *paramName, const char *removeMe)
Remove all occurrences of a specified text from a parameter.
Definition: y_string.c:594
int strcmp(const char *string1, const char *string2)
Documented at http://www.cplusplus.com/reference/cstring/strcmp/.
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 parame...
Definition: y_string.c:144
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.
Definition: y_string.c:784
void * memmove(void *dest, const void *src, size_t n)
Documented at http://www.cplusplus.com/reference/cstring/memmove/.
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 paramete...
Definition: y_string.c:508
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...
Definition: y_string.c:868
char * y_get_parameter_eval_string(const char *param_name)
Obtain the string required to fetch the contents of a parameter through lr_eval_string().
Definition: y_core.c:287
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...
Definition: y_string.c:240
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.
Definition: y_string.c:801
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 ...
Definition: y_string.c:389
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.
Definition: y_string.c:678
char * y_strdup(char *source)
Copy a string into a malloc&#39;d piece of memory using strdup(), and lr_abort() if the allocation fails...
Definition: y_core.c:268
size_t strlen(const char *string)
Documented at http://www.cplusplus.com/reference/cstring/strlen/.
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 paramete...
Definition: y_string.c:290
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...
Definition: y_string.c:926
int snprintf(char *buffer, size_t n, const char *format_string,...)
Documented at http://www.cplusplus.com/reference/cstdio/snprintf/. This function was introduced by t...
long y_rand(void)
Generate a random (integer) number between 0 and Y_RAND_MAX (30 bit maxint).
Definition: y_core.c:156
void y_uppercase_parameter(const char *param_name)
Convert the content of a parameter to UPPERCASE.
Definition: y_string.c:114
char * y_get_parameter(const char *param_name)
Get the content of a parameter and return it as a char *.
Definition: y_core.c:336
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...
Definition: y_string.c:838
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.
Definition: y_string.c:86
char * y_get_parameter_or_null(const char *param_name)
Get the content of a parameter and return it as a char *, or return NULL if it wasn&#39;t set...
Definition: y_core.c:373
int y_rand_between(int lowerbound, int upperbound)
Create a random number between two boundaries. (the boundaries are included!)
char * strncpy(char *destination, const char *source, size_t num)
Documented at http://www.cplusplus.com/reference/cstring/strncpy/.
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.
Definition: y_string.c:341
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).
Definition: y_string.c:818
void free(void *mem_address)
Documented at http://www.cplusplus.com/reference/cstdlib/free/.
void y_param_unique(char *param)
Create a unique parameter.
Definition: y_string.c:636