5 kx
5 kx #ifndef __HTTP_H
5 kx #define __HTTP_H
5 kx
5 kx #define HTTP_VERSION "2"
5 kx
5 kx #ifdef __cplusplus
5 kx extern "C" {
5 kx #endif
5 kx
5 kx
5 kx typedef void (*http_errfunc)( const char *fmt, ... );
5 kx
5 kx extern void http_error( const char *fmt, ... ) __attribute__((format (printf,1,2)));
5 kx extern http_errfunc http_fatal; /* Default Fatal Error Function == http_error() */
5 kx
5 kx
5 kx extern const signed char hexval_table[256];
5 kx static inline unsigned int hexval( unsigned char c )
5 kx {
5 kx return hexval_table[c];
5 kx }
5 kx /*******************************************************************
5 kx Convert two consecutive hexadecimal digits into a char. Return a
5 kx negative value on error. Don't run over the end of short strings.
5 kx */
5 kx static inline int hex2chr( const char *s )
5 kx {
5 kx unsigned int val = hexval(s[0]);
5 kx return (val & ~0xf) ? val : (val << 4) | hexval(s[1]);
5 kx }
5 kx
5 kx extern char *url_decode_mem( const char *url, int len );
5 kx extern char *url_percent_decode( const char *encoded );
5 kx extern char *url_decode_parameter_name( const char **query );
5 kx extern char *url_decode_parameter_value( const char **query );
5 kx extern void http_parse_querystring( const char *txt, void (*fn)(const char *name, const char *value) );
5 kx
5 kx
5 kx extern char *fmt( const char *format,... ) __attribute__((format (printf,1,2)));
5 kx extern char *fmtalloc( const char *format,... ) __attribute__((format (printf,1,2)));
5 kx
5 kx
5 kx extern char *http_date( time_t t );
5 kx extern const char *http_status( int status_code );
5 kx
5 kx
5 kx #ifdef __cplusplus
5 kx }
5 kx #endif
5 kx
5 kx #endif /* __HTTP_H */