summaryrefslogtreecommitdiff
path: root/csvncgi/http.h
blob: 6304b640e669109326383f21b0e5de25d1082020 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifndef    __HTTP_H
#define    __HTTP_H

#define HTTP_VERSION  "2"

#ifdef __cplusplus
extern "C" {
#endif


typedef void (*http_errfunc)( const char *fmt, ... );

extern void http_error( const char *fmt, ... ) __attribute__((format (printf,1,2)));
extern http_errfunc http_fatal; /* Default Fatal Error Function == http_error() */


extern const signed char hexval_table[256];
static inline unsigned int hexval( unsigned char c )
{
  return hexval_table[c];
}
/*******************************************************************
  Convert two consecutive hexadecimal digits into a char. Return a
  negative value on error. Don't run over the end of short strings.
 */
static inline int hex2chr( const char *s )
{
  unsigned int val = hexval(s[0]);
  return (val & ~0xf) ? val : (val << 4) | hexval(s[1]);
}

extern char *url_decode_mem( const char *url, int len );
extern char *url_percent_decode( const char *encoded );
extern char *url_decode_parameter_name( const char **query );
extern char *url_decode_parameter_value( const char **query );
extern void http_parse_querystring( const char *txt, void (*fn)(const char *name, const char *value) );


extern char *fmt( const char *format,... ) __attribute__((format (printf,1,2)));
extern char *fmtalloc( const char *format,... ) __attribute__((format (printf,1,2)));


extern char *http_date( time_t t );
extern const char *http_status( int status_code );


#ifdef __cplusplus
}
#endif

#endif  /* __HTTP_H */