|
MPD
|
00001 /* 00002 * Copyright (C) 2003-2010 The Music Player Daemon Project 00003 * http://www.musicpd.org 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, write to the Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00018 */ 00019 00020 #ifndef MPD_CLIENT_INTERNAL_H 00021 #define MPD_CLIENT_INTERNAL_H 00022 00023 #include "client.h" 00024 #include "command.h" 00025 00026 #undef G_LOG_DOMAIN 00027 #define G_LOG_DOMAIN "client" 00028 00029 struct deferred_buffer { 00030 size_t size; 00031 char data[sizeof(long)]; 00032 }; 00033 00034 struct client { 00035 GIOChannel *channel; 00036 guint source_id; 00037 00039 struct fifo_buffer *input; 00040 00041 unsigned permission; 00042 00044 int uid; 00045 00049 GTimer *last_activity; 00050 00051 GSList *cmd_list; /* for when in list mode */ 00052 int cmd_list_OK; /* print OK after each command execution */ 00053 size_t cmd_list_size; /* mem cmd_list consumes */ 00054 GQueue *deferred_send; /* for output if client is slow */ 00055 size_t deferred_bytes; /* mem deferred_send consumes */ 00056 unsigned int num; /* client number */ 00057 00058 char send_buf[16384]; 00059 size_t send_buf_used; /* bytes used this instance */ 00060 00062 bool idle_waiting; 00063 00066 unsigned idle_flags; 00067 00069 unsigned idle_subscriptions; 00070 }; 00071 00072 extern unsigned int client_max_connections; 00073 extern int client_timeout; 00074 extern size_t client_max_command_list_size; 00075 extern size_t client_max_output_buffer_size; 00076 00077 bool 00078 client_list_is_empty(void); 00079 00080 bool 00081 client_list_is_full(void); 00082 00083 struct client * 00084 client_list_get_first(void); 00085 00086 void 00087 client_list_add(struct client *client); 00088 00089 void 00090 client_list_foreach(GFunc func, gpointer user_data); 00091 00092 void 00093 client_list_remove(struct client *client); 00094 00095 void 00096 client_close(struct client *client); 00097 00098 static inline void 00099 new_cmd_list_ptr(struct client *client, const char *s) 00100 { 00101 client->cmd_list = g_slist_prepend(client->cmd_list, g_strdup(s)); 00102 } 00103 00104 static inline void 00105 free_cmd_list(GSList *list) 00106 { 00107 for (GSList *tmp = list; tmp != NULL; tmp = g_slist_next(tmp)) 00108 g_free(tmp->data); 00109 00110 g_slist_free(list); 00111 } 00112 00113 void 00114 client_set_expired(struct client *client); 00115 00120 void 00121 client_schedule_expire(void); 00122 00126 void 00127 client_deinit_expire(void); 00128 00129 enum command_return 00130 client_read(struct client *client); 00131 00132 enum command_return 00133 client_process_line(struct client *client, char *line); 00134 00135 void 00136 client_write_deferred(struct client *client); 00137 00138 void 00139 client_write_output(struct client *client); 00140 00141 gboolean 00142 client_in_event(GIOChannel *source, GIOCondition condition, 00143 gpointer data); 00144 00145 #endif
1.7.3