util.h 1.89 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/* Icecast
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
 * Copyright 2000-2004, Jack Moffitt <jack@xiph.org, 
 *                      Michael Smith <msmith@xiph.org>,
 *                      oddsock <oddsock@xiph.org>,
 *                      Karl Heyes <karl@xiph.org>
 *                      and others (see AUTHORS for details).
 */

Jack Moffitt's avatar
Jack Moffitt committed
13 14 15
#ifndef __UTIL_H__
#define __UTIL_H__

16 17 18
#define XSLT_CONTENT 1
#define HTML_CONTENT 2

19 20 21
#define READ_ENTIRE_HEADER 1
#define READ_LINE 0

22 23
#define MAX_LINE_LEN 512

24
int util_timed_wait_for_fd(int fd, int timeout);
25
int util_read_header(int sock, char *buff, unsigned long len, int entire);
26
int util_check_valid_extension(const char *uri);
27
char *util_get_extension(const char *path);
28
char *util_get_path_from_uri(char *uri);
29
char *util_get_path_from_normalised_uri(const char *uri);
30 31 32
char *util_normalise_uri(const char *uri);
char *util_base64_encode(const char *data);
char *util_base64_decode(const char *input);
Michael Smith's avatar
Michael Smith committed
33
char *util_bin_to_hex(unsigned char *data, int len);
Jack Moffitt's avatar
Jack Moffitt committed
34

35 36
char *util_url_unescape(const char *src);
char *util_url_escape(const char *src);
37

38 39 40 41 42 43 44 45 46 47 48 49 50 51
/* 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);
52 53 54 55

#ifndef HAVE_LOCALTIME_R
struct tm *localtime_r (const time_t *timep, struct tm *result);
#endif
56
char *util_conv_string (const char *string, const char *in_charset, const char *out_charset);
57

58
int get_line(FILE *file, char *buf, size_t siz);
Jack Moffitt's avatar
Jack Moffitt committed
59
#endif  /* __UTIL_H__ */