Client.hxx 2.04 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright (C) 2003-2011 The Music Player Daemon Project
3
 * http://www.musicpd.org
Warren Dukes's avatar
Warren Dukes committed
4 5 6 7 8 9 10 11 12 13
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
14 15 16 17
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Warren Dukes's avatar
Warren Dukes committed
18 19
 */

20 21
#ifndef MPD_CLIENT_H
#define MPD_CLIENT_H
Warren Dukes's avatar
Warren Dukes committed
22

23 24
#include "gcc.h"

25
#include <stdbool.h>
26 27 28
#include <stddef.h>
#include <stdarg.h>

29
struct sockaddr;
30
struct player_control;
31
class Client;
32

33 34
void client_manager_init(void);
void client_manager_deinit(void);
Warren Dukes's avatar
Warren Dukes committed
35

36 37
void client_new(struct player_control *player_control,
		int fd, const struct sockaddr *sa, size_t sa_length, int uid);
38

39
gcc_pure
40
bool client_is_expired(const Client *client);
41

42 43 44 45
/**
 * returns the uid of the client process, or a negative value if the
 * uid is unknown
 */
46
gcc_pure
47
int client_get_uid(const Client *client);
48

49 50 51 52
/**
 * Is this client running on the same machine, connected with a local
 * (UNIX domain) socket?
 */
53
gcc_pure
54
static inline bool
55
client_is_local(const Client *client)
56 57 58 59
{
	return client_get_uid(client) > 0;
}

60
gcc_pure
61
unsigned client_get_permission(const Client *client);
62

63
void client_set_permission(Client *client, unsigned permission);
64

65 66 67
/**
 * Write a C string to the client.
 */
68
void client_puts(Client *client, const char *s);
69

70 71 72
/**
 * Write a printf-like formatted string to the client.
 */
73
void client_vprintf(Client *client, const char *fmt, va_list args);
74 75 76 77

/**
 * Write a printf-like formatted string to the client.
 */
78 79
gcc_fprintf
void
80
client_printf(Client *client, const char *fmt, ...);
81

Warren Dukes's avatar
Warren Dukes committed
82
#endif