Main Page | Modules | Data Structures | File List | Data Fields

String


Functions

int u_buf_reserve (u_buf_t *ubuf, size_t size)
 Enlarge the underlaying memory block of the given buffer.
int u_buf_append (u_buf_t *ubuf, void *data, size_t size)
 Append some data to the buffer.
int u_buf_load (u_buf_t *ubuf, char *filename)
 Fill a buffer object with the content of a file.
int u_buf_detach (u_buf_t *ubuf)
 Release buffer's underlaying memory block without freeing it.
size_t u_buf_size (u_buf_t *ubuf)
 Return the size of memory block allocated by the buffer.
size_t u_buf_len (u_buf_t *ubuf)
 Return the length of the buffer.
int u_buf_clear (u_buf_t *ubuf)
 Clear a buffer.
int u_buf_set (u_buf_t *ubuf, void *data, size_t size)
 Set the value of a buffer.
void * u_buf_ptr (u_buf_t *ubuf)
 Return a pointer to the buffer internal momory block.
int u_buf_free (u_buf_t *ubuf)
 Free a buffer.
int u_buf_create (u_buf_t **pubuf)
 Create a new buffer.
int u_string_trim (u_string_t *s)
 Remove leading and trailing blanks.
int u_string_set_length (u_string_t *s, size_t len)
 Set the length of a string (shortening it).
size_t u_string_len (u_string_t *s)
 Return the string length.
const char * u_string_c (u_string_t *s)
 Return the string value.
int u_string_copy (u_string_t *dst, u_string_t *src)
 Copy the value of a string to another.
int u_string_clear (u_string_t *s)
 Clear a string.
int u_string_create (const char *buf, size_t len, u_string_t **ps)
 Create a new string.
int u_string_free (u_string_t *s)
 Free a string.
int u_string_set (u_string_t *s, const char *buf, size_t len)
 Set the value of a string.
int u_string_append (u_string_t *s, const char *buf, size_t len)
 Append a char* to a string.

Function Documentation

int u_buf_append u_buf_t *  ubuf,
void *  data,
size_t  size
 

Append data of size size to the given buffer. If needed the buffer will be enlarged.

Parameters:
ubuf buffer object
data the data block to append
size size of data
Returns:
0 on success, not zero on failure

Definition at line 72 of file buf.c.

References u_buf_reserve().

Referenced by u_buf_set().

int u_buf_clear u_buf_t *  ubuf  ) 
 

Totally erase the content of the given buffer. The memory allocated by the buffer will not be released until u_buf_free() is called.

Parameters:
ubuf buffer object
Returns:
0 on success, not zero on failure

Definition at line 210 of file buf.c.

Referenced by u_buf_load(), and u_buf_set().

int u_buf_create u_buf_t **  pubuf  ) 
 

Create a new buffer object and save its pointer to *ps.

Parameters:
pubuf on success will get the new buffer object
Returns:
0 on success, not zero on failure

Definition at line 296 of file buf.c.

References u_zalloc().

int u_buf_detach u_buf_t *  ubuf  ) 
 

Release the underlaying memory block of the given buffer without calling free() on it. The caller must free the buffer later on (probably after using it somwhow).

Use u_buf_ptr() to get the pointer of the memory block, u_buf_size() to get its size and u_buf_len() to get its length.

Parameters:
ubuf buffer object
Returns:
0 on success, not zero on failure

Definition at line 151 of file buf.c.

int u_buf_free u_buf_t *  ubuf  ) 
 

Release all resources and free the given buffer object.

Parameters:
ubuf buffer object
Returns:
0 on success, not zero on failure

Definition at line 275 of file buf.c.

References u_free().

size_t u_buf_len u_buf_t *  ubuf  ) 
 

Return the length of data store in the given buffer.

Parameters:
ubuf buffer object
Returns:
the data buffer length

Definition at line 191 of file buf.c.

int u_buf_load u_buf_t *  ubuf,
char *  filename
 

Open filename and copy its whole content into the given buffer.

Parameters:
ubuf buffer object
filename the source filename
Returns:
0 on success, not zero on failure

Definition at line 104 of file buf.c.

References u_buf_clear(), and u_buf_reserve().

void* u_buf_ptr u_buf_t *  ubuf  ) 
 

Return a void* pointer to the memory block allocated by the buffer object.

Parameters:
ubuf buffer object
Returns:
0 on success, not zero on failure

Definition at line 257 of file buf.c.

int u_buf_reserve u_buf_t *  ubuf,
size_t  size
 

Enlarge the buffer data block to (at least) size bytes.

Parameters:
ubuf buffer object
size requested size
Returns:
0 on success, not zero on failure

Definition at line 35 of file buf.c.

References u_realloc().

Referenced by u_buf_append(), and u_buf_load().

int u_buf_set u_buf_t *  ubuf,
void *  data,
size_t  size
 

Set the value of ubuf to data. If needed the buffer object will alloc more memory to store the data value.

Parameters:
ubuf buffer object
data the value that will be copied into the buffer
size size of data
Returns:
0 on success, not zero on failure

Definition at line 233 of file buf.c.

References u_buf_append(), and u_buf_clear().

size_t u_buf_size u_buf_t *  ubuf  ) 
 

Return the size of memory block allocated by the buffer.

Parameters:
ubuf buffer object
Returns:
the data buffer length

Definition at line 173 of file buf.c.

int u_string_append u_string_t *  s,
const char *  buf,
size_t  len
 

Append a char* value to the given string.

Parameters:
s string object
buf the value that will be appended to s
len length of buf
Returns:
0 on success, not zero on failure

Definition at line 227 of file str.c.

References u_realloc().

Referenced by u_string_copy(), u_string_create(), and u_string_set().

const char* u_string_c u_string_t *  s  )  [inline]
 

Return the const char* value of the given string object. Such const char* value cannot be modified, realloc'd or free'd.

Parameters:
s string object
Returns:
the string value or NULL if the string is empty

Definition at line 101 of file str.c.

int u_string_clear u_string_t *  s  ) 
 

Totally erase the content of the given string.

Parameters:
s string object
Returns:
0 on success, not zero on failure

Definition at line 131 of file str.c.

Referenced by u_string_copy(), and u_string_set().

int u_string_copy u_string_t *  dst,
u_string_t *  src
[inline]
 

Copy src string to dst string.

Parameters:
dst destination string
src source string
Returns:
0 on success, not zero on failure

Definition at line 116 of file str.c.

References u_string_append(), and u_string_clear().

int u_string_create const char *  buf,
size_t  len,
u_string_t **  ps
 

Create a new string object and save its pointer to *ps.

If buf is not NULL (and len > 0) the string will be initialized with the content of buf.

Parameters:
buf initial string value
len length of buf
ps on success will get the new string object
Returns:
0 on success, not zero on failure

Definition at line 157 of file str.c.

References u_string_append(), and u_zalloc().

int u_string_free u_string_t *  s  ) 
 

Release all resources and free the given string object.

Parameters:
s string object
Returns:
0 on success, not zero on failure

Definition at line 187 of file str.c.

size_t u_string_len u_string_t *  s  )  [inline]
 

Return the length of the given string.

Parameters:
s string object
Returns:
the string length

Definition at line 86 of file str.c.

int u_string_set u_string_t *  s,
const char *  buf,
size_t  len
 

Set the value of s to buf.

Parameters:
s string object
buf the value that will be copied to s
len length of buf
Returns:
0 on success, not zero on failure

Definition at line 210 of file str.c.

References u_string_append(), and u_string_clear().

int u_string_set_length u_string_t *  s,
size_t  len
 

Parameters:
s string object
len on success s will be len chars long
Returns:
0 on success, not zero on failure

Definition at line 62 of file str.c.

int u_string_trim u_string_t *  s  ) 
 

Remove leading and trailing blanks from the given string

Parameters:
s string object
Returns:
0 on success, not zero on failure

Definition at line 41 of file str.c.

References u_trim().


←Products
© 2005-2006 - KoanLogic S.r.l. - All rights reserved