Client.hxx 1.95 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
#include "Compiler.h"
24

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

28
struct sockaddr;
29
class EventLoop;
30
struct Partition;
31
class Client;
32

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

35
void
36
client_new(EventLoop &loop, Partition &partition,
37
	   int fd, const struct sockaddr *sa, size_t sa_length, int uid);
38

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

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

57
gcc_pure
58
unsigned client_get_permission(const Client *client);
59

60
void client_set_permission(Client *client, unsigned permission);
61

62 63 64
/**
 * Write a C string to the client.
 */
65
void client_puts(Client *client, const char *s);
66

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

/**
 * Write a printf-like formatted string to the client.
 */
Max Kellermann's avatar
Max Kellermann committed
75
gcc_printf(2,3)
76
void
77
client_printf(Client *client, const char *fmt, ...);
78

Warren Dukes's avatar
Warren Dukes committed
79
#endif