Logo Search packages:      
Sourcecode: fence-agents version File versions  Download package

static char* str_prepare_for_sh ( char *  dest,
char *  source,
int  max_len 
) [static]

Prepare string for use in sh style environment. This function take source string and prepend/append quote (') to start/end of source string to dest string. Any occurence of quote in source string is replaced by '\'' sequence. Dest string must be preallocated.

destDestination string
sourceSource string
max_lenMaximum length of data written to dest string (including end 0)
Pointer to start of destination string.

Definition at line 218 of file ipmilan.c.

  char *dest_p=dest;
  char *max_dest=dest+max_len;

  if (dest_p+1>=max_dest) {*dest_p=0;return dest;}

  while (*source) {
    if (*source=='\'') {
      if (dest_p+4>=max_dest) {*dest_p=0;return dest;}

    } else {
      if (dest_p+1>=max_dest) {*dest_p=0;return dest;}


  if (dest_p+2>=max_dest) {*dest_p=0;return dest;}


  return dest;

Generated by  Doxygen 1.6.0   Back to index