MPD
client_internal.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2003-2010 The Music Player Daemon Project
3  * http://www.musicpd.org
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 #ifndef MPD_CLIENT_INTERNAL_H
21 #define MPD_CLIENT_INTERNAL_H
22 
23 #include "client.h"
24 #include "command.h"
25 
26 #undef G_LOG_DOMAIN
27 #define G_LOG_DOMAIN "client"
28 
30  size_t size;
31  char data[sizeof(long)];
32 };
33 
34 struct client {
35  GIOChannel *channel;
36  guint source_id;
37 
39  struct fifo_buffer *input;
40 
41  unsigned permission;
42 
44  int uid;
45 
49  GTimer *last_activity;
50 
51  GSList *cmd_list; /* for when in list mode */
52  int cmd_list_OK; /* print OK after each command execution */
53  size_t cmd_list_size; /* mem cmd_list consumes */
54  GQueue *deferred_send; /* for output if client is slow */
55  size_t deferred_bytes; /* mem deferred_send consumes */
56  unsigned int num; /* client number */
57 
58  char send_buf[16384];
59  size_t send_buf_used; /* bytes used this instance */
60 
63 
66  unsigned idle_flags;
67 
70 };
71 
72 extern unsigned int client_max_connections;
73 extern int client_timeout;
74 extern size_t client_max_command_list_size;
75 extern size_t client_max_output_buffer_size;
76 
77 bool
79 
80 bool
82 
83 struct client *
85 
86 void
88 
89 void
90 client_list_foreach(GFunc func, gpointer user_data);
91 
92 void
94 
95 void
96 client_close(struct client *client);
97 
98 static inline void
99 new_cmd_list_ptr(struct client *client, const char *s)
100 {
101  client->cmd_list = g_slist_prepend(client->cmd_list, g_strdup(s));
102 }
103 
104 static inline void
105 free_cmd_list(GSList *list)
106 {
107  for (GSList *tmp = list; tmp != NULL; tmp = g_slist_next(tmp))
108  g_free(tmp->data);
109 
110  g_slist_free(list);
111 }
112 
113 void
115 
120 void
122 
126 void
128 
129 enum command_return
130 client_read(struct client *client);
131 
132 enum command_return
133 client_process_line(struct client *client, char *line);
134 
135 void
137 
138 void
140 
141 gboolean
142 client_in_event(GIOChannel *source, GIOCondition condition,
143  gpointer data);
144 
145 #endif