Changes the names of structures:
- struct afb_req becomes struct afb_hreq
- struct afb_req_post becomes struct afb_hreq_post
This new 'h', meaning HTTP, is insert to avoid mix-up
with api requests.
Change-Id: Ief08ff2d5494a2a0322cb2fa1903da90ec91f147
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
const char *upload_data;
size_t *upload_data_size;
};
const char *upload_data;
size_t *upload_data_size;
};
AFB_session *session;
struct MHD_Connection *connection;
enum afb_method method;
AFB_session *session;
struct MHD_Connection *connection;
enum afb_method method;
size_t lenurl;
const char *tail;
size_t lentail;
size_t lenurl;
const char *tail;
size_t lentail;
- struct afb_req **recorder;
- int (*post_handler) (struct afb_req *, struct afb_req_post *);
- int (*post_completed) (struct afb_req *, struct afb_req_post *);
+ struct afb_hreq **recorder;
+ int (*post_handler) (struct afb_hreq *, struct afb_hreq_post *);
+ int (*post_completed) (struct afb_hreq *, struct afb_hreq_post *);
struct afb_req_handler *next;
const char *prefix;
size_t length;
struct afb_req_handler *next;
const char *prefix;
size_t length;
- int (*handler) (struct afb_req *, struct afb_req_post *, void *);
+ int (*handler) (struct afb_hreq *, struct afb_hreq_post *, void *);
void *data;
int priority;
};
void *data;
int priority;
};
* if and only if the prefix exists and is terminated by a leading
* slash
*/
* if and only if the prefix exists and is terminated by a leading
* slash
*/
-int afb_req_unprefix(struct afb_req *request, const char *prefix, size_t length)
+int afb_req_unprefix(struct afb_hreq *request, const char *prefix, size_t length)
{
/* check the prefix ? */
if (length > request->lentail || (request->tail[length] && request->tail[length] != '/')
{
/* check the prefix ? */
if (length > request->lentail || (request->tail[length] && request->tail[length] != '/')
-int afb_req_valid_tail(struct afb_req *request)
+int afb_req_valid_tail(struct afb_hreq *request)
{
return validsubpath(request->tail);
}
{
return validsubpath(request->tail);
}
-void afb_req_reply_error(struct afb_req *request, unsigned int status)
+void afb_req_reply_error(struct afb_hreq *request, unsigned int status)
{
char *buffer;
int length;
{
char *buffer;
int length;
MHD_destroy_response(response);
}
MHD_destroy_response(response);
}
-int afb_request_redirect_to(struct afb_req *request, const char *url)
+int afb_request_redirect_to(struct afb_hreq *request, const char *url)
{
struct MHD_Response *response;
{
struct MHD_Response *response;
-int afb_request_one_page_api_redirect(struct afb_req *request, struct afb_req_post *post, void *data)
+int afb_request_one_page_api_redirect(struct afb_hreq *request, struct afb_hreq_post *post, void *data)
{
size_t plen;
char *url;
{
size_t plen;
char *url;
}
struct afb_req_handler *afb_req_handler_new(struct afb_req_handler *head, const char *prefix,
}
struct afb_req_handler *afb_req_handler_new(struct afb_req_handler *head, const char *prefix,
- int (*handler) (struct afb_req *, struct afb_req_post *, void *),
+ int (*handler) (struct afb_hreq *, struct afb_hreq_post *, void *),
void *data, int priority)
{
struct afb_req_handler *link, *iter, *previous;
void *data, int priority)
{
struct afb_req_handler *link, *iter, *previous;
}
int afb_req_add_handler(AFB_session * session, const char *prefix,
}
int afb_req_add_handler(AFB_session * session, const char *prefix,
- int (*handler) (struct afb_req *, struct afb_req_post *, void *), void *data, int priority)
+ int (*handler) (struct afb_hreq *, struct afb_hreq_post *, void *), void *data, int priority)
{
struct afb_req_handler *head;
{
struct afb_req_handler *head;
-static int relay_to_doRestApi(struct afb_req *request, struct afb_req_post *post, void *data)
+static int relay_to_doRestApi(struct afb_hreq *request, struct afb_hreq_post *post, void *data)
{
return doRestApi(request->connection, request->session, &request->tail[1], get_method_name(request->method),
post->upload_data, post->upload_data_size, (void **)request->recorder);
}
{
return doRestApi(request->connection, request->session, &request->tail[1], get_method_name(request->method),
post->upload_data, post->upload_data_size, (void **)request->recorder);
}
-static int afb_req_reply_file_if_exist(struct afb_req *request, int dirfd, const char *filename)
+static int afb_req_reply_file_if_exist(struct afb_hreq *request, int dirfd, const char *filename)
-static int afb_req_reply_file(struct afb_req *request, int dirfd, const char *filename)
+static int afb_req_reply_file(struct afb_hreq *request, int dirfd, const char *filename)
{
int rc = afb_req_reply_file_if_exist(request, dirfd, filename);
if (rc == 0)
{
int rc = afb_req_reply_file_if_exist(request, dirfd, filename);
if (rc == 0)
-static int handle_alias(struct afb_req *request, struct afb_req_post *post, void *data)
+static int handle_alias(struct afb_hreq *request, struct afb_hreq_post *post, void *data)
{
char *path;
struct afb_diralias *da = data;
{
char *path;
struct afb_diralias *da = data;
size_t * upload_data_size,
void **recorder)
{
size_t * upload_data_size,
void **recorder)
{
- struct afb_req_post post;
- struct afb_req request;
+ struct afb_hreq_post post;
+ struct afb_hreq request;
enum afb_method method;
AFB_session *session;
struct afb_req_handler *iter;
enum afb_method method;
AFB_session *session;
struct afb_req_handler *iter;
post.upload_data_size = upload_data_size;
#if 0
post.upload_data_size = upload_data_size;
#if 0
- struct afb_req *previous;
+ struct afb_hreq *previous;
previous = *recorder;
if (previous) {
previous = *recorder;
if (previous) {
request.method = method;
request.tail = request.url = url;
request.lentail = request.lenurl = strlen(url);
request.method = method;
request.tail = request.url = url;
request.lentail = request.lenurl = strlen(url);
- request.recorder = (struct afb_req **)recorder;
+ request.recorder = (struct afb_hreq **)recorder;
request.post_handler = NULL;
request.post_completed = NULL;
request.post_data = NULL;
request.post_handler = NULL;
request.post_completed = NULL;
request.post_data = NULL;