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

utils.h File Reference

Go to the source code of this file.

Defines

#define MIN(a, b)   (a < b ? a : b)
#define MAX(a, b)   (a > b ? a : b)
#define KLONE_FREE(p)   do {if (p) { free(p); p = NULL; }} while (0)
#define klone_die()   do { con(__VA_ARGS__); exit(EXIT_FAILURE); } while(0)
#define klone_die_if(cond,)   do { dbg_ifb(cond) klone_die(__VA_ARGS__); } while(0)

Typedefs

typedef void(* u_sig_t )(int)

Enumerations

enum  { URLCPY_VERBATIM, URLCPY_ENCODE, URLCPY_DECODE }
enum  { HEXCPY_VERBATIM, HEXCPY_ENCODE, HEXCPY_DECODE }
enum  { HTMLCPY_VERBATIM, HTMLCPY_ENCODE, HTMLCPY_DECODE }
enum  { SQLCPY_VERBATIM, SQLCPY_ENCODE, SQLCPY_DECODE }

Functions

int u_file_exists (const char *)
 Tell if the given file exists.
int u_write_debug_message (const char *, const char *, int, const char *, const char *,...)
int u_foreach_dir_item (const char *, unsigned int, int(*)(struct dirent *, const char *, void *), void *)
 Apply the supplied callback to each file in a given directory.
char * u_strnrchr (const char *s, char c, size_t len)
 Locate a character in a string.
char * u_stristr (const char *string, const char *sub)
 Locate a given substring ignoring case.
char * u_strnstr (const char *string, const char *sub, size_t stringlen)
 Locate a substring in another string.
ssize_t u_urlncpy (char *dst, const char *src, size_t slen, int flags)
 Copy and URL escape/unescape a given string.
ssize_t u_hexncpy (char *dst, const char *src, size_t slen, int flags)
 Copy and HEX encode/decode a given string.
ssize_t u_htmlncpy (char *dst, const char *src, size_t slen, int flags)
 Copy and HTML escape/unescape a given string.
ssize_t u_sqlncpy (char *dst, const char *src, size_t slen, int flags)
 Copy and SQL escape/unescape a given string.
int u_printf_ccstr (io_t *o, const char *buf, size_t sz)
int u_file_open (const char *file, int flags, io_t **pio)
 Create an io_t object from the file system object file.
int u_tmpfile_open (io_t **pio)
 Create a temporary io_t object.
int u_getline (io_t *io, u_string_t *ln)
 Read a line from the io_t object io.
int u_fgetline (FILE *in, u_string_t *ln)
 get a line from a FILE object
int u_io_unzip_copy (io_t *out, const unsigned char *data, size_t size)
void u_tohex (char *hex, const char *src, size_t sz)
 Convert a given string in hexadecimal representation.
char u_tochex (int n)
int u_md5 (char *buf, size_t sz, char out[MD5_DIGEST_BUFSZ])
 Calculate the MD5 digest over a given buffer.
int u_md5io (io_t *io, char out[MD5_DIGEST_BUFSZ])
 Calculate the MD5 hash over an io_t stream.
int u_signal (int sig, u_sig_t handler)
int u_sig_block (int sig)
int u_sig_unblock (int sig)
const char * u_guess_mime_type (const char *file_name)
 Guess the MIME type of a file.
const mime_map_tu_get_mime_map (const char *file_name)
 Get the MIME type of a file.
int u_match_ext (const char *filename, const char *extension)
 Match filename extension.
int u_tt_to_rfc822 (char dst[], time_t ts)
 Convert a time_t value to a rfc822 time string.
int u_httpdate_to_tt (const char *str, time_t *tp)
 Convert an HTTP time string to time_t.
int u_rfc822_to_tt (const char *str, time_t *tp)
 Convert an rfc822 time string to time_t.
int u_rfc850_to_tt (const char *str, time_t *tp)
 Convert an rfc850 time string to time_t.
int u_asctime_to_tt (const char *str, time_t *tp)
 Convert an asctime(3) string to time_t.
void u_print_version_and_exit (void)


Define Documentation

 
#define klone_die  )     do { con(__VA_ARGS__); exit(EXIT_FAILURE); } while(0)
 

Definition at line 43 of file utils.h.

#define klone_die_if cond   )     do { dbg_ifb(cond) klone_die(__VA_ARGS__); } while(0)
 

Definition at line 44 of file utils.h.

#define KLONE_FREE  )     do {if (p) { free(p); p = NULL; }} while (0)
 

Definition at line 41 of file utils.h.

#define MAX a,
 )     (a > b ? a : b)
 

Definition at line 38 of file utils.h.

Referenced by session_module_init().

#define MIN a,
 )     (a < b ? a : b)
 

Definition at line 34 of file utils.h.

Referenced by header_load_from_cgienv(), io_copy(), io_gets(), io_name_get(), and io_read().


Typedef Documentation

typedef void(* u_sig_t)(int)
 

Definition at line 88 of file utils.h.


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
URLCPY_VERBATIM 
URLCPY_ENCODE 
URLCPY_DECODE 

Definition at line 60 of file utils.h.

anonymous enum
 

Enumeration values:
HEXCPY_VERBATIM 
HEXCPY_ENCODE 
HEXCPY_DECODE 

Definition at line 63 of file utils.h.

anonymous enum
 

Enumeration values:
HTMLCPY_VERBATIM 
HTMLCPY_ENCODE 
HTMLCPY_DECODE 

Definition at line 66 of file utils.h.

anonymous enum
 

Enumeration values:
SQLCPY_VERBATIM 
SQLCPY_ENCODE 
SQLCPY_DECODE 

Definition at line 69 of file utils.h.


Function Documentation

int u_io_unzip_copy io_t out,
const unsigned char *  data,
size_t  size
 

int u_sig_block int  sig  ) 
 

int u_sig_unblock int  sig  ) 
 

int u_write_debug_message const char *  ,
const char *  ,
int  ,
const char *  ,
const char *  ,
  ...
 


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