client.h 1003 Bytes
Newer Older
Jack Moffitt's avatar
Jack Moffitt committed
1 2 3 4 5 6 7 8
/* client.h
**
** client data structions and function definitions
**
*/
#ifndef __CLIENT_H__
#define __CLIENT_H__

Michael Smith's avatar
Michael Smith committed
9
#include "connection.h"
Michael Smith's avatar
Michael Smith committed
10 11
#include "refbuf.h"
#include "httpp/httpp.h"
Michael Smith's avatar
Michael Smith committed
12

Jack Moffitt's avatar
Jack Moffitt committed
13 14
typedef struct _client_tag
{
Michael Smith's avatar
Michael Smith committed
15
    /* the client's connection */
16
    connection_t *con;
Michael Smith's avatar
Michael Smith committed
17
    /* the client's http headers */
18
    http_parser_t *parser;
Jack Moffitt's avatar
Jack Moffitt committed
19

20 21
    /* http response code for this client */
    int respcode;
Jack Moffitt's avatar
Jack Moffitt committed
22

23 24 25 26
    /* buffer queue */
    refbuf_queue_t *queue;
    /* position in first buffer */
    unsigned long pos;
27

Michael Smith's avatar
Michael Smith committed
28 29 30
    /* Client username, if authenticated */
    char *username;

31 32
    /* Format-handler-specific data for this client */
    void *format_data;
Jack Moffitt's avatar
Jack Moffitt committed
33 34 35 36
} client_t;

client_t *client_create(connection_t *con, http_parser_t *parser);
void client_destroy(client_t *client);
Michael Smith's avatar
Michael Smith committed
37
void client_send_504(client_t *client, char *message);
38
void client_send_404(client_t *client, char *message);
39
void client_send_401(client_t *client);
40
void client_send_400(client_t *client, char *message);
Jack Moffitt's avatar
Jack Moffitt committed
41 42

#endif  /* __CLIENT_H__ */