2 * Copyright (C) 1997-2007 Andre Noll <maan@systemlinux.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
19 /** \file server.h common server data structures */
24 /** size of the selector_info and audio_file info strings of struct misc_meta_data */
25 #define MMD_INFO_SIZE 16384
28 * defines one command of para_server
30 struct server_command {
31 /** the name of the command */
33 /** pointer to the function that handles the command */
34 int (*handler)(int, int, char **);
35 /** the privileges a user must have to execute this command */
37 /** one-line description of the command */
38 const char *description;
39 /** summary of the command line options */
41 /** the long help text */
45 /** holds the arguments for the para_server's sender command */
46 struct sender_command_data{
47 /** greater than 0 indicates that a sender cmd is already queued */
49 /** the number of the sender in question */
51 /** used for the allow/deny/add/remove subcommands */
53 /** used for allow/deny */
55 /** the portnumber for add/remove */
60 * used for parent-child communication
62 * There's only one struct of this type which lives in shared memory
63 * for communication between the server instances. Access to this
64 * area is serialized via mmd_lock() and mmd_unlock(). There are two
65 * reasons for a variable to be included here:
67 * - At least one command (i.e. child of the server) must be able to
72 * - The contents are listed in the stat command and have to be up to
75 struct misc_meta_data {
76 /** information on the current audio file */
77 struct audio_format_info afi;
78 /** the size of the current audio file in bytes */
79 long unsigned int size;
80 /** the full path of the current audio file */
81 char filename[_POSIX_PATH_MAX];
82 /** the last modification file of the current audio file */
84 /** the number of the current audio format */
86 /** the "old" status flags -- commands may only read them */
87 unsigned int vss_status_flags;
88 /** the new status flags -- commands may set them **/
89 unsigned int new_vss_status_flags;
90 /** the number of data chunks sent for the current audio file */
91 long unsigned chunks_sent;
92 /** set by the jmp/ff commands to the new position in chunks */
93 long unsigned repos_request;
94 /** the number of the chunk currently sent out*/
95 long unsigned current_chunk;
96 /** the milliseconds that have been skipped of the current audio file */
98 /** the time para_server started to stream */
99 struct timeval stream_start;
100 /** the event counter
102 * commands may increase this to force a status update to be sent to all
106 /** the number of audio files already sent */
107 unsigned int num_played;
108 /** the number of executed commands */
109 unsigned int num_commands;
110 /** the number of connections para_server received so far */
111 unsigned int num_connects;
112 /** the number of connections currently active */
113 unsigned int active_connections;
114 /** the process id of para_server */
116 /** a string that gets filled in by the current audio file selector */
117 char selector_info[MMD_INFO_SIZE];
118 /** the number if the current audio file selector */
120 /** commands set this to non-zero to change the current selector */
122 /** used by the sender command */
123 struct sender_command_data sender_cmd_data;
126 extern struct server_args_info conf;
128 int handle_connect(int fd, struct sockaddr_in *addr);
129 void mmd_unlock(void);