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

Miscellaneous


Functions

int u_isblank (int c)
 Returns 0 if c is neither a space or a tab, not-zero otherwise.
void u_trim (char *s)
 Removes leading and trailing blanks (spaces and tabs) from s.
int u_isblank_str (const char *ln)
 Returns 1 if ln is a blank string i.e. a string formed by ONLY spaces and/or tabs characters.
int u_isnl (int c)
 Returns 0 if c is neither a CR (\r) or a LF (\n), not-zero otherwise.
char * u_strndup (const char *s, size_t len)
 Dups the first len chars of s. Returns the dupped zero terminated string or NULL on error.
char * u_strdup (const char *s)
 Dups the supplied string s.
int u_savepid (const char *pf)
 Save the PID of the calling process to a file named pf (that should be a fully qualified path). Returns 0 on success, not-zero on error.
char * u_sstrncpy (char *dst, const char *src, size_t size)
 Safe string copy, see also the U_SSTRNCPY define Safe string copy which null-terminates the destination string dst before copying the source string src for no more than size bytes. Returns a pointer to the destination string dst.
void * u_memdup (const void *src, size_t size)
 Dups the memory block src of size size. Returns the pointer of the dup'd block on success, NULL on error.
int u_tokenize (char *wlist, const char *delim, char **tokv, size_t tokv_sz)
 tokenize the supplied wlist string
int u_snprintf (char *str, size_t size, const char *fmt,...)
 snprintf-like function that returns 0 on success and ~0 on error
int u_path_snprintf (char *buf, size_t sz, char sep, const char *fmt,...)
 snprintf-like function that handle path separator issues
int u_data_is_bin (char *data, size_t sz)
 Return 1 if the supplied buffer data has non-ascii bytes.
int u_load_file (const char *path, size_t sz_max, char **pbuf, size_t *psz)
 Load file into memory from the supplied FS entry.

Function Documentation

int u_load_file const char *  path,
size_t  sz_max,
char **  pbuf,
size_t *  psz
 

Parameters:
path the path name of the file
sz_max if >0 impose this size limit (otherwise unlimited)
pbuf the pointer to the memory location holding the file's contents as a value-result argument
psz size of the loaded file as a v-r argument
Returns:
0 on success, ~0 on error

Definition at line 291 of file misc.c.

References u_zalloc().

int u_path_snprintf char *  buf,
size_t  sz,
char  sep,
const char *  fmt,
  ...
 

Calls snprintf with the provided arguments and remove consecutive path separators from the resulting string.

Parameters:
buf destination buffer
sz size of str
sep path separator to use ('/' or '\')
fmt snprintf format string
Returns 0 on success, not-zero on error.

Definition at line 223 of file misc.c.

int u_snprintf char *  str,
size_t  size,
const char *  fmt,
  ...
 

snprintf-like function that returns 0 on success and ~0 on error

Parameters:
str destination buffer
size size of str
fmt snprintf format string
Returns 0 on success, not-zero on error.

Definition at line 192 of file misc.c.

int u_tokenize char *  wlist,
const char *  delim,
char **  tokv,
size_t  tokv_sz
 

Tokenize the delim separated string wlist and place its pieces (at most tokv_sz - 1) into tokv.

Parameters:
wlist list of strings possibily separated by chars in delim
delim set of token separators
tokv pre-allocated string array
tokv_sz number of cells in tokv array

Definition at line 153 of file misc.c.


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