add a utility function to detect redirects and handle them
[project/uclient.git] / uclient-backend.h
1 #ifndef __UCLIENT_INTERNAL_H
2 #define __UCLIENT_INTERNAL_H
3
4 struct uclient_url;
5
6 struct uclient_backend {
7         const char * const * prefix;
8
9         struct uclient *(*alloc)(void);
10         void (*free)(struct uclient *cl);
11         void (*update_url)(struct uclient *cl);
12
13         int (*connect)(struct uclient *cl);
14         int (*request)(struct uclient *cl);
15
16         int (*read)(struct uclient *cl, char *buf, unsigned int len);
17         int (*write)(struct uclient *cl, char *buf, unsigned int len);
18 };
19
20 struct uclient_url {
21         const struct uclient_backend *backend;
22         int prefix;
23
24         const char *host;
25         const char *port;
26         const char *location;
27
28         const char *auth;
29 };
30
31 void uclient_backend_set_error(struct uclient *cl);
32 void uclient_backend_set_eof(struct uclient *cl);
33 void uclient_backend_reset_state(struct uclient *cl);
34 struct uclient_url *uclient_get_url(const char *url_str, const char *auth_str);
35
36 #endif