bfc1508d (kx 2023-03-24 03:55:33 +0300 1)
bfc1508d (kx 2023-03-24 03:55:33 +0300 2) #ifndef __HTTP_H
bfc1508d (kx 2023-03-24 03:55:33 +0300 3) #define __HTTP_H
bfc1508d (kx 2023-03-24 03:55:33 +0300 4)
bfc1508d (kx 2023-03-24 03:55:33 +0300 5) #define HTTP_VERSION "2"
bfc1508d (kx 2023-03-24 03:55:33 +0300 6)
bfc1508d (kx 2023-03-24 03:55:33 +0300 7) #ifdef __cplusplus
bfc1508d (kx 2023-03-24 03:55:33 +0300 8) extern "C" {
bfc1508d (kx 2023-03-24 03:55:33 +0300 9) #endif
bfc1508d (kx 2023-03-24 03:55:33 +0300 10)
bfc1508d (kx 2023-03-24 03:55:33 +0300 11)
bfc1508d (kx 2023-03-24 03:55:33 +0300 12) typedef void (*http_errfunc)( const char *fmt, ... );
bfc1508d (kx 2023-03-24 03:55:33 +0300 13)
bfc1508d (kx 2023-03-24 03:55:33 +0300 14) extern void http_error( const char *fmt, ... ) __attribute__((format (printf,1,2)));
bfc1508d (kx 2023-03-24 03:55:33 +0300 15) extern http_errfunc http_fatal; /* Default Fatal Error Function == http_error() */
bfc1508d (kx 2023-03-24 03:55:33 +0300 16)
bfc1508d (kx 2023-03-24 03:55:33 +0300 17)
bfc1508d (kx 2023-03-24 03:55:33 +0300 18) extern const signed char hexval_table[256];
bfc1508d (kx 2023-03-24 03:55:33 +0300 19) static inline unsigned int hexval( unsigned char c )
bfc1508d (kx 2023-03-24 03:55:33 +0300 20) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 21) return hexval_table[c];
bfc1508d (kx 2023-03-24 03:55:33 +0300 22) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 23) /*******************************************************************
bfc1508d (kx 2023-03-24 03:55:33 +0300 24) Convert two consecutive hexadecimal digits into a char. Return a
bfc1508d (kx 2023-03-24 03:55:33 +0300 25) negative value on error. Don't run over the end of short strings.
bfc1508d (kx 2023-03-24 03:55:33 +0300 26) */
bfc1508d (kx 2023-03-24 03:55:33 +0300 27) static inline int hex2chr( const char *s )
bfc1508d (kx 2023-03-24 03:55:33 +0300 28) {
bfc1508d (kx 2023-03-24 03:55:33 +0300 29) unsigned int val = hexval(s[0]);
bfc1508d (kx 2023-03-24 03:55:33 +0300 30) return (val & ~0xf) ? val : (val << 4) | hexval(s[1]);
bfc1508d (kx 2023-03-24 03:55:33 +0300 31) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 32)
bfc1508d (kx 2023-03-24 03:55:33 +0300 33) extern char *url_decode_mem( const char *url, int len );
bfc1508d (kx 2023-03-24 03:55:33 +0300 34) extern char *url_percent_decode( const char *encoded );
bfc1508d (kx 2023-03-24 03:55:33 +0300 35) extern char *url_decode_parameter_name( const char **query );
bfc1508d (kx 2023-03-24 03:55:33 +0300 36) extern char *url_decode_parameter_value( const char **query );
bfc1508d (kx 2023-03-24 03:55:33 +0300 37) extern void http_parse_querystring( const char *txt, void (*fn)(const char *name, const char *value) );
bfc1508d (kx 2023-03-24 03:55:33 +0300 38)
bfc1508d (kx 2023-03-24 03:55:33 +0300 39)
bfc1508d (kx 2023-03-24 03:55:33 +0300 40) extern char *fmt( const char *format,... ) __attribute__((format (printf,1,2)));
bfc1508d (kx 2023-03-24 03:55:33 +0300 41) extern char *fmtalloc( const char *format,... ) __attribute__((format (printf,1,2)));
bfc1508d (kx 2023-03-24 03:55:33 +0300 42)
bfc1508d (kx 2023-03-24 03:55:33 +0300 43)
bfc1508d (kx 2023-03-24 03:55:33 +0300 44) extern char *http_date( time_t t );
bfc1508d (kx 2023-03-24 03:55:33 +0300 45) extern const char *http_status( int status_code );
bfc1508d (kx 2023-03-24 03:55:33 +0300 46)
bfc1508d (kx 2023-03-24 03:55:33 +0300 47)
bfc1508d (kx 2023-03-24 03:55:33 +0300 48) #ifdef __cplusplus
bfc1508d (kx 2023-03-24 03:55:33 +0300 49) }
bfc1508d (kx 2023-03-24 03:55:33 +0300 50) #endif
bfc1508d (kx 2023-03-24 03:55:33 +0300 51)
bfc1508d (kx 2023-03-24 03:55:33 +0300 52) #endif /* __HTTP_H */