2009-03-13 18:43:16 +01:00
|
|
|
/*
|
2011-01-29 10:13:54 +01:00
|
|
|
* Copyright (C) 2003-2011 The Music Player Daemon Project
|
2009-03-13 18:43:16 +01:00
|
|
|
* http://www.musicpd.org
|
2004-02-24 00:41:20 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2009-03-13 18:43:16 +01:00
|
|
|
*
|
|
|
|
* 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.
|
2004-02-24 00:41:20 +01:00
|
|
|
*/
|
|
|
|
|
2008-10-31 09:19:53 +01:00
|
|
|
#ifndef MPD_CLIENT_H
|
|
|
|
#define MPD_CLIENT_H
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2012-08-02 18:15:49 +02:00
|
|
|
#include "gcc.h"
|
|
|
|
|
2008-10-08 10:49:29 +02:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2008-12-29 17:42:43 +01:00
|
|
|
struct sockaddr;
|
2013-01-14 23:42:06 +01:00
|
|
|
class EventLoop;
|
2013-01-07 10:59:56 +01:00
|
|
|
struct Partition;
|
2013-01-03 17:27:26 +01:00
|
|
|
class Client;
|
2008-08-29 09:36:42 +02:00
|
|
|
|
2008-08-28 20:03:02 +02:00
|
|
|
void client_manager_init(void);
|
2004-02-24 00:41:20 +01:00
|
|
|
|
2013-01-04 23:07:11 +01:00
|
|
|
void
|
2013-01-14 23:42:06 +01:00
|
|
|
client_new(EventLoop &loop, Partition &partition,
|
2013-01-04 23:07:11 +01:00
|
|
|
int fd, const struct sockaddr *sa, size_t sa_length, int uid);
|
2008-08-29 09:36:40 +02:00
|
|
|
|
2008-10-15 22:34:21 +02:00
|
|
|
/**
|
|
|
|
* returns the uid of the client process, or a negative value if the
|
|
|
|
* uid is unknown
|
|
|
|
*/
|
2012-08-02 18:15:49 +02:00
|
|
|
gcc_pure
|
2013-01-03 17:27:26 +01:00
|
|
|
int client_get_uid(const Client *client);
|
2008-10-15 22:34:21 +02:00
|
|
|
|
2012-02-13 20:00:33 +01:00
|
|
|
/**
|
|
|
|
* Is this client running on the same machine, connected with a local
|
|
|
|
* (UNIX domain) socket?
|
|
|
|
*/
|
2012-08-02 18:15:49 +02:00
|
|
|
gcc_pure
|
2012-02-13 20:00:33 +01:00
|
|
|
static inline bool
|
2013-01-03 17:27:26 +01:00
|
|
|
client_is_local(const Client *client)
|
2012-02-13 20:00:33 +01:00
|
|
|
{
|
|
|
|
return client_get_uid(client) > 0;
|
|
|
|
}
|
|
|
|
|
2012-08-02 18:15:49 +02:00
|
|
|
gcc_pure
|
2013-01-03 17:27:26 +01:00
|
|
|
unsigned client_get_permission(const Client *client);
|
2008-09-07 19:16:34 +02:00
|
|
|
|
2013-01-03 17:27:26 +01:00
|
|
|
void client_set_permission(Client *client, unsigned permission);
|
2008-09-07 19:16:34 +02:00
|
|
|
|
2008-09-07 13:24:51 +02:00
|
|
|
/**
|
|
|
|
* Write a C string to the client.
|
|
|
|
*/
|
2013-01-03 17:27:26 +01:00
|
|
|
void client_puts(Client *client, const char *s);
|
2008-09-07 13:24:51 +02:00
|
|
|
|
2008-09-07 13:25:54 +02:00
|
|
|
/**
|
|
|
|
* Write a printf-like formatted string to the client.
|
|
|
|
*/
|
2013-01-03 17:27:26 +01:00
|
|
|
void client_vprintf(Client *client, const char *fmt, va_list args);
|
2008-09-07 13:25:54 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Write a printf-like formatted string to the client.
|
|
|
|
*/
|
2013-10-15 09:13:22 +02:00
|
|
|
gcc_printf(2,3)
|
2012-08-02 18:15:49 +02:00
|
|
|
void
|
2013-01-03 17:27:26 +01:00
|
|
|
client_printf(Client *client, const char *fmt, ...);
|
2008-09-07 13:25:54 +02:00
|
|
|
|
2004-02-24 00:41:20 +01:00
|
|
|
#endif
|