client.h 2.07 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/* Icecast
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
 * Copyright 2000-2004, Jack Moffitt <jack@xiph.org, 
 *                      Michael Smith <msmith@xiph.org>,
 *                      oddsock <oddsock@xiph.org>,
 *                      Karl Heyes <karl@xiph.org>
 *                      and others (see AUTHORS for details).
 */

Jack Moffitt's avatar
Jack Moffitt committed
13 14 15 16 17 18 19 20
/* client.h
**
** client data structions and function definitions
**
*/
#ifndef __CLIENT_H__
#define __CLIENT_H__

Michael Smith's avatar
Michael Smith committed
21
#include "connection.h"
Michael Smith's avatar
Michael Smith committed
22 23
#include "refbuf.h"
#include "httpp/httpp.h"
Michael Smith's avatar
Michael Smith committed
24

Jack Moffitt's avatar
Jack Moffitt committed
25 26
typedef struct _client_tag
{
Michael Smith's avatar
Michael Smith committed
27
    /* the client's connection */
28
    connection_t *con;
Michael Smith's avatar
Michael Smith committed
29
    /* the client's http headers */
30
    http_parser_t *parser;
Jack Moffitt's avatar
Jack Moffitt committed
31

32 33
    /* http response code for this client */
    int respcode;
Jack Moffitt's avatar
Jack Moffitt committed
34

35 36
    /* is client getting intro data */
    long intro_offset;
Karl Heyes's avatar
Karl Heyes committed
37

Karl Heyes's avatar
Karl Heyes committed
38 39 40
    /* where in the queue the client is */
    refbuf_t *refbuf;

41 42
    /* position in first buffer */
    unsigned long pos;
43

Michael Smith's avatar
Michael Smith committed
44 45 46
    /* Client username, if authenticated */
    char *username;

47 48
    /* Format-handler-specific data for this client */
    void *format_data;
49 50 51

    /* function to call to release format specific resources */
    void (*free_client_data)(struct _client_tag *client);
Karl Heyes's avatar
Karl Heyes committed
52

53 54 55
    /* write out data associated with client */
    int (*write_to_client)(struct _client_tag *client);

Karl Heyes's avatar
Karl Heyes committed
56 57 58
    /* function to check if refbuf needs updating */
    int (*check_buffer)(struct source_tag *source, struct _client_tag *client);

Jack Moffitt's avatar
Jack Moffitt committed
59 60 61 62
} 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
63
void client_send_504(client_t *client, char *message);
64
void client_send_404(client_t *client, char *message);
65
void client_send_401(client_t *client);
66
void client_send_403(client_t *client);
67
void client_send_400(client_t *client, char *message);
68
int client_send_bytes (client_t *client, const void *buf, unsigned len);
69
int client_read_bytes (client_t *client, void *buf, unsigned len);
Karl Heyes's avatar
Karl Heyes committed
70
void client_set_queue (client_t *client, refbuf_t *refbuf);
Jack Moffitt's avatar
Jack Moffitt committed
71 72

#endif  /* __CLIENT_H__ */