client.h 2.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/* 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).
Philipp Schafft's avatar
Philipp Schafft committed
11
 * Copyright 2011-2012, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
12 13
 */

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

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

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

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

36 37 38
    /* auth completed, 0 not yet, 1 passed */
    int authenticated;

39 40
    /* is client getting intro data */
    long intro_offset;
Karl Heyes's avatar
Karl Heyes committed
41

Karl Heyes's avatar
Karl Heyes committed
42 43 44
    /* where in the queue the client is */
    refbuf_t *refbuf;

45
    /* position in first buffer */
46
    unsigned int pos;
47

48 49 50
    /* auth used for this client */
    struct auth_tag *auth;

Michael Smith's avatar
Michael Smith committed
51 52 53
    /* Client username, if authenticated */
    char *username;

54 55 56
    /* Client password, if authenticated */
    char *password;

57 58
    /* Format-handler-specific data for this client */
    void *format_data;
59 60 61

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

63 64 65
    /* write out data associated with client */
    int (*write_to_client)(struct _client_tag *client);

Karl Heyes's avatar
Karl Heyes committed
66 67 68
    /* 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
69 70
} client_t;

71
int client_create (client_t **c_ptr, connection_t *con, http_parser_t *parser);
Jack Moffitt's avatar
Jack Moffitt committed
72
void client_destroy(client_t *client);
73
void client_send_100(client_t *client);
74
void client_send_404(client_t *client, const char *message);
75
void client_send_401(client_t *client);
76 77
void client_send_403(client_t *client, const char *message);
void client_send_400(client_t *client, const char *message);
78
void client_send_500(client_t *client, const char *message);
79
int client_send_bytes (client_t *client, const void *buf, unsigned len);
80
int client_read_bytes (client_t *client, void *buf, unsigned len);
Karl Heyes's avatar
Karl Heyes committed
81
void client_set_queue (client_t *client, refbuf_t *refbuf);
82
int client_check_source_auth (client_t *client, const char *mount);
Jack Moffitt's avatar
Jack Moffitt committed
83 84

#endif  /* __CLIENT_H__ */