//#undef DEBUG
-//-----------------------------------------------------------------
/**
* ul_dbuff_set_capacity - change capacity of buffer to at least @new_capacity
* @buf: buffer structure
return buf->capacity;
}
-//-----------------------------------------------------------------
/**
* ul_dbuff_set_len - sets a new len of the buffer, change the capacity if neccessary
* @buf: buffer structure
return buf->len;
}
-//-----------------------------------------------------------------
/**
* ul_dbuff_cpy - copies bytes to buffer and change its capacity if neccessary like memset
* @buf: buffer structure
return buf->len;
}
-//-----------------------------------------------------------------
/**
* ul_dbuff_cpy - copies bytes to buffer and change its capacity if neccessary
* @buf: buffer structure
return buf->len;
}
-//-----------------------------------------------------------------
/**
* ul_dbuff_cat - appends bytes at end of buffer and change its capacity if neccessary
* @buf: buffer structure
return buf->len;
}
-//-----------------------------------------------------------------
/**
* ul_dbuff_strcat - appends str at dhe end of buffer and change its capacity if neccessary
* @buf: buffer structure
return ul_dbuff_cat(buf, str, strlen(str) + 1);
}
-//-----------------------------------------------------------------
/**
* ul_dbuff_strcpy - copy str to the buffer and change its capacity if neccessary
* @buf: buffer structure
return ul_dbuff_strcat(buf, str);
}
-//-----------------------------------------------------------------
/**
* ul_dbuff_append_byte - appends byte at dhe end of buffer and change its capacity if neccessary
* @buf: buffer structure
return ul_dbuff_cat(buf, &b, 1);
}
-//-----------------------------------------------------------------
/**
* ul_dbuff_ltrim - remove all white space characters from the left
* @buf: buffer structure
return buf->len;
}
-//-----------------------------------------------------------------
/**
* ul_dbuff_rtrim - remove all white space characters from the right
* @buf: buffer structure
return buf->len;
}
-//-----------------------------------------------------------------
/**
* ul_dbuff_trim - remove all white space characters from the right and from the left
* @buf: buffer structure
ul_dbuff_rtrim(buf);
return ul_dbuff_ltrim(buf);
}
-//-----------------------------------------------------------------
+
/**
* ul_dbuff_cpos - searches string for char
* @buf: searched dbuff
if(ret >= buf->len) ret = -1;
return ret;
}
-//-----------------------------------------------------------------
+
/**
* ul_str_cpos - searches string for char
* @str: zero terminated string
if(!str[ret]) ret = -1;
return ret;
}
-//-----------------------------------------------------------------
+
/**
* ul_str_pos - searches string for substring
* @str: zero terminated string
}
return -1;
}
-//-----------------------------------------------------------------
+
/**
* ul_str_ncpy - copies string to the buffer
* @to: buffer where to copy str
to[i] = '\0';
return i;
}
-//-----------------------------------------------------------------
+
/**
* ul_dbuff_cut_pos - cut first @n bytes from @fromdb and copies it to @todb.
* If @n is greater than fromdb.len whole @fromdb is copied to @todb.
memmove(fromdb->data, fromdb->data + n, fromdb->len - n);
ul_dbuff_set_len(fromdb, newlen);
}
-//-----------------------------------------------------------------
+
/**
* ul_dbuff_cut - cuts bytes before delimiter + delimiter char from @fromdb and copies tham to the @todb
* If @fromdb doesn't contain delimiter @todb is trimmed to zero length.
if(pos < 0) pos = -1;
ul_dbuff_cut_pos(fromdb, todb, pos+1);
}
-//-----------------------------------------------------------------
+
/**
* ul_dbuff_cut_token - cuts not whitespaces from %fromdb to %todb.
* Leading whitespaces are ignored. Cut string is trimmed.
{
const unsigned char *pc = (unsigned char*)fromdb->data;
int pos;
- // skip leading white spaces
+ /* skip leading white spaces */
for(pos=0; pc[pos]>0 && pc[pos]<=' ' && pos<fromdb->len; pos++);
- // skip token
+ /* skip token */
for(; pc[pos]>' ' && pos<fromdb->len; pos++);
ul_dbuff_cut_pos(fromdb, todb, pos);
ul_dbuff_trim(todb);
}
-//-----------------------------------------------------------------
-