util.h 1.2 KB
Newer Older
Jack Moffitt's avatar
Jack Moffitt committed
1 2 3
#ifndef __UTIL_H__
#define __UTIL_H__

4 5 6
#define XSLT_CONTENT 1
#define HTML_CONTENT 2

7
int util_timed_wait_for_fd(int fd, int timeout);
Jack Moffitt's avatar
Jack Moffitt committed
8
int util_read_header(int sock, char *buff, unsigned long len);
9
int util_check_valid_extension(char *uri);
10
char *util_get_extension(char *path);
11
char *util_get_path_from_uri(char *uri);
12 13
char *util_get_path_from_normalised_uri(char *uri);
char *util_normalise_uri(char *uri);
14
char *util_base64_encode(char *data);
15
char *util_base64_decode(unsigned char *input);
16
char *util_bin_to_hex(unsigned char *data, int len);
Jack Moffitt's avatar
Jack Moffitt committed
17

18
char *util_url_unescape(char *src);
19 20
char *util_url_escape(char *src);

21 22 23 24 25 26 27 28 29 30 31 32 33 34
/* String dictionary type, without support for NULL keys, or multiple
 * instances of the same key */
typedef struct _util_dict {
  char *key;
  char *val;
  struct _util_dict *next;
} util_dict;

util_dict *util_dict_new(void);
void util_dict_free(util_dict *dict);
/* dict, key must not be NULL. */
int util_dict_set(util_dict *dict, const char *key, const char *val);
const char *util_dict_get(util_dict *dict, const char *key);
char *util_dict_urlencode(util_dict *dict, char delim);
35 36 37 38 39

#ifndef HAVE_LOCALTIME_R
struct tm *localtime_r (const time_t *timep, struct tm *result);
#endif

Jack Moffitt's avatar
Jack Moffitt committed
40
#endif  /* __UTIL_H__ */